summaryrefslogtreecommitdiffstats
path: root/contrib/global/lib/makepath.c
diff options
context:
space:
mode:
authorsimokawa <simokawa@FreeBSD.org>1999-01-18 07:32:38 +0000
committersimokawa <simokawa@FreeBSD.org>1999-01-18 07:32:38 +0000
commit2272b595f94bb24d28f1524c2d4d2af1e4d92a5a (patch)
tree96201fab23a758e986d824520e570eea28db9659 /contrib/global/lib/makepath.c
parent87e157657c9fd75113fff659682ef4736e6c0db5 (diff)
downloadFreeBSD-src-2272b595f94bb24d28f1524c2d4d2af1e4d92a5a.zip
FreeBSD-src-2272b595f94bb24d28f1524c2d4d2af1e4d92a5a.tar.gz
Merge from verdor branch (v_3_4_2) and remove obsolete files.
Diffstat (limited to 'contrib/global/lib/makepath.c')
-rw-r--r--contrib/global/lib/makepath.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/contrib/global/lib/makepath.c b/contrib/global/lib/makepath.c
index 7efba18..26de065 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,12 +28,16 @@
* 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 <string.h>
#include <sys/param.h>
+#include "die.h"
#include "makepath.h"
+#include "strbuf.h"
+
+static STRBUF *sb;
/*
* makepath: make path from directory and file.
*
@@ -43,16 +47,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);
}
OpenPOWER on IntegriCloud