diff options
Diffstat (limited to 'usr.bin/make/str.c')
| -rw-r--r-- | usr.bin/make/str.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c index e1e5968922bd2..7df8e8d2f113f 100644 --- a/usr.bin/make/str.c +++ b/usr.bin/make/str.c @@ -1,5 +1,3 @@ -/* $NetBSD: str.c,v 1.12 1996/03/29 02:17:34 jtc Exp $ */ - /*- * Copyright (c) 1988, 1989, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -39,12 +37,8 @@ */ #ifndef lint -#if 0 -static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90"; -#else -static char rcsid[] = "$NetBSD: str.c,v 1.12 1996/03/29 02:17:34 jtc Exp $"; -#endif -#endif /* not lint */ +static char sccsid[] = "@(#)str.c 8.6 (Berkeley) 4/28/95"; +#endif /* not lint */ #include "make.h" @@ -60,7 +54,7 @@ void str_init() { char *p1; - argv = (char **)emalloc(((argmax = 50) + 1) * sizeof(char *)); + argv = (char **)emalloc((argmax = 50) * sizeof(char *)); argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1); } @@ -73,15 +67,15 @@ str_init() void str_end() { - if (argv) { - if (argv[0]) - free(argv[0]); + if (argv[0]) { + free(argv[0]); free((Address) argv); } if (buffer) free(buffer); } + /*- * str_concat -- * concatenate the two strings, inserting a space or slash between them, @@ -207,8 +201,9 @@ brk_string(str, store_argc, expand) *t++ = '\0'; if (argc == argmax) { argmax *= 2; /* ramp up fast */ - argv = (char **)erealloc(argv, - (argmax + 1) * sizeof(char *)); + if (!(argv = (char **)realloc(argv, + argmax * sizeof(char *)))) + enomem(); } argv[argc++] = start; start = (char *)NULL; @@ -223,7 +218,7 @@ brk_string(str, store_argc, expand) ch = *++p; break; } - + switch (ch = *++p) { case '\0': case '\n': @@ -260,12 +255,12 @@ done: argv[argc] = (char *)NULL; /* * Str_FindSubstring -- See if a string contains a particular substring. - * + * * Results: If string contains substring, the return value is the location of * the first matching instance of substring in string. If string doesn't * contain substring, the return value is NULL. Matching is done on an exact * character-for-character basis with no wildcards or special characters. - * + * * Side effects: None. */ char * @@ -298,13 +293,13 @@ Str_FindSubstring(string, substring) /* * Str_Match -- - * + * * See if a particular string matches a particular pattern. - * + * * Results: Non-zero is returned if string matches pattern, 0 otherwise. The * matching operation permits the following special characters in the * pattern: *?\[] (see the man page for details on what these mean). - * + * * Side effects: None. */ int @@ -401,8 +396,8 @@ thisCharOK: ++pattern; /*- *----------------------------------------------------------------------- * Str_SYSVMatch -- - * Check word against pattern for a match (% is wild), - * + * Check word against pattern for a match (% is wild), + * * Results: * Returns the beginning position of a match or null. The number * of characters matched is returned in len. @@ -452,7 +447,7 @@ Str_SYSVMatch(word, pattern, len) return m; } while (*w++ != '\0'); - + return NULL; } @@ -463,7 +458,7 @@ Str_SYSVMatch(word, pattern, len) * Substitute '%' on the pattern with len characters from src. * If the pattern does not contain a '%' prepend len characters * from src. - * + * * Results: * None * |
