diff options
author | rms <rms@138bc75d-0d04-0410-961f-82ee72b054a4> | 1992-03-26 23:23:31 +0000 |
---|---|---|
committer | rms <rms@138bc75d-0d04-0410-961f-82ee72b054a4> | 1992-03-26 23:23:31 +0000 |
commit | 5044f88a540c563348d1970b4e214c4d3a090c63 (patch) | |
tree | 6a807803460921f049e740b7afbc3080ad0cb7d9 /gcc/protoize.c | |
parent | cfedf4ab46d28260f7d25bd6d143d4dddaa4aaf9 (diff) | |
download | gcc-5044f88a540c563348d1970b4e214c4d3a090c63.tar.gz |
*** empty log message ***
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@592 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/protoize.c')
-rw-r--r-- | gcc/protoize.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/protoize.c b/gcc/protoize.c index 29d947b79b8..c5b377e1228 100644 --- a/gcc/protoize.c +++ b/gcc/protoize.c @@ -1320,11 +1320,22 @@ shortpath (cwd, filename) path_p++; unmatched_slash_count++; } + + /* Find out how many directory levels in cwd were *not* matched. */ while (*cwd_p) if (*cwd_p++ == '/') - unmatched_slash_count++; + unmatched_slash_count++; + + /* Now we know how long the "short name" will be. + Reject it if longer than the input. */ + if (unmatched_slash_count * 3 + strlen (path_p) >= filename_len) + return filename; + + /* For each of them, put a `../' at the beginning of the short name. */ while (unmatched_slash_count--) { + /* Give up if the result gets to be longer + than the absolute path name. */ if (rel_buffer + filename_len <= rel_buf_p + 3) return filename; *rel_buf_p++ = '.'; @@ -1332,6 +1343,7 @@ shortpath (cwd, filename) *rel_buf_p++ = '/'; } + /* Then tack on the unmatched part of the desired file's name. */ do { if (rel_buffer + filename_len <= rel_buf_p) |