diff options
author | Jari Aalto <jari.aalto@cante.net> | 2001-04-06 19:14:31 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:53 +0000 |
commit | 28ef6c316f1aff914bb95ac09787a3c83c1815fd (patch) | |
tree | 2812fe7ffc9beec4f99856906ddfcafda54cf16a /lib/sh/makepath.c | |
parent | bb70624e964126b7ac4ff085ba163a9c35ffa18f (diff) | |
download | bash-28ef6c316f1aff914bb95ac09787a3c83c1815fd.tar.gz |
Imported from ../bash-2.05.tar.gz.
Diffstat (limited to 'lib/sh/makepath.c')
-rw-r--r-- | lib/sh/makepath.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/sh/makepath.c b/lib/sh/makepath.c index dfc12108..ba2bcb9c 100644 --- a/lib/sh/makepath.c +++ b/lib/sh/makepath.c @@ -68,7 +68,7 @@ sh_makepath (path, dir, flags) int flags; { int dirlen, pathlen; - char *ret, *xpath; + char *ret, *xpath, *r, *s; if (path == 0 || *path == '\0') { @@ -102,14 +102,15 @@ sh_makepath (path, dir, flags) dirlen -= 2; } - ret = xmalloc (2 + dirlen + pathlen); - strcpy (ret, xpath); - if (xpath[pathlen - 1] != '/') - { - ret[pathlen++] = '/'; - ret[pathlen] = '\0'; - } - strcpy (ret + pathlen, dir); + r = ret = xmalloc (2 + dirlen + pathlen); + s = xpath; + while (*s) + *r++ = *s++; + if (s[-1] != '/') + *r++ = '/'; + s = dir; + while (*r++ = *s++) + ; if (xpath != path) free (xpath); return (ret); |