summaryrefslogtreecommitdiff
path: root/devel/bmake/files/stresep.c
diff options
context:
space:
mode:
Diffstat (limited to 'devel/bmake/files/stresep.c')
-rw-r--r--devel/bmake/files/stresep.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/devel/bmake/files/stresep.c b/devel/bmake/files/stresep.c
index 42ad8d08a6c..b36b55aa876 100644
--- a/devel/bmake/files/stresep.c
+++ b/devel/bmake/files/stresep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: stresep.c,v 1.1.1.1 2011/06/18 22:18:07 bsiegert Exp $ */
+/* $NetBSD: stresep.c,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -59,6 +59,7 @@ stresep(char **stringp, const char *delim, int esc)
char *s;
const char *spanp;
int c, sc;
+ size_t l;
char *tok;
if (stringp == NULL || delim == NULL)
@@ -66,23 +67,26 @@ stresep(char **stringp, const char *delim, int esc)
if ((s = *stringp) == NULL)
return NULL;
+ l = strlen(s) + 1;
for (tok = s;;) {
c = *s++;
+ l--;
while (esc != '\0' && c == esc) {
- (void)strcpy(s - 1, s);
+ memmove(s - 1, s, l);
c = *s++;
+ l--;
}
spanp = delim;
do {
if ((sc = *spanp++) == c) {
- if (c == 0)
+ if (c == '\0')
s = NULL;
else
- s[-1] = 0;
+ s[-1] = '\0';
*stringp = s;
return tok;
}
- } while (sc != 0);
+ } while (sc != '\0');
}
}
#endif