diff options
Diffstat (limited to 'contrib/global/lib/makepath.c')
-rw-r--r-- | contrib/global/lib/makepath.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/contrib/global/lib/makepath.c b/contrib/global/lib/makepath.c index ba00ecfc6c2f..cf9858e95aab 100644 --- a/contrib/global/lib/makepath.c +++ b/contrib/global/lib/makepath.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved. + * Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,11 +28,15 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * makepath.c 20-Oct-97 + * makepath.c 15-May-98 * */ #include <sys/param.h> +#include "die.h" #include "makepath.h" +#include "strbuf.h" + +static STRBUF *sb; /* * makepath: make path from directory and file. * @@ -42,16 +46,21 @@ */ char * makepath(dir, file) -char *dir; -char *file; +const char *dir; +const char *file; { - static char path[MAXPATHLEN+1]; - char *p; + int length; - strcpy(path, dir); - p = path + strlen(path); - if (*(p - 1) != '/') - *p++ = '/'; - strcpy(p, file); - return path; + if (sb == NULL) + sb = stropen(); + strstart(sb); + if ((length = strlen(dir)) > MAXPATHLEN) + die1("path name too long. '%s'\n", dir); + strputs(sb, dir); + strunputc(sb, '/'); + strputc(sb, '/'); + strputs(sb, file); + if ((length = strlen(strvalue(sb))) > MAXPATHLEN) + die1("path name too long. '%s'\n", dir); + return strvalue(sb); } |