summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/str.c
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-10-28 23:33:57 +0000
committerjmallett <jmallett@FreeBSD.org>2002-10-28 23:33:57 +0000
commit1d4b44fe4a5179218b67807b2f8a72b1ea5e30da (patch)
treee236724d2a28f3e60d37eeb142b7049cd93427bb /usr.bin/make/str.c
parent46972a1cd987b2dea0a141dde525fdc000ab59d2 (diff)
downloadFreeBSD-src-1d4b44fe4a5179218b67807b2f8a72b1ea5e30da.zip
FreeBSD-src-1d4b44fe4a5179218b67807b2f8a72b1ea5e30da.tar.gz
Split var.c into var.c and var_modify.c and move all the modification funcs
to var_modify.c, for readability. constify some low hanging fruit (string manipulation functions) and the upper layers appropriately. No longer use the private strstr(3) implementation, while changing string code. Tested by: lots of successful make buildworld.
Diffstat (limited to 'usr.bin/make/str.c')
-rw-r--r--usr.bin/make/str.c55
1 files changed, 9 insertions, 46 deletions
diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c
index 56cb71f..a6fdb63 100644
--- a/usr.bin/make/str.c
+++ b/usr.bin/make/str.c
@@ -253,44 +253,6 @@ 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.
- *
- * XXX should be strstr(3).
- */
-char *
-Str_FindSubstring(char *string, char *substring)
-{
- char *a, *b;
-
- /*
- * First scan quickly through the two strings looking for a single-
- * character match. When it's found, then compare the rest of the
- * substring.
- */
-
- for (b = substring; *string != 0; string += 1) {
- if (*string != *b)
- continue;
- a = string;
- for (;;) {
- if (*b == 0)
- return(string);
- if (*a++ != *b++)
- break;
- }
- b = substring;
- }
- return((char *) NULL);
-}
-
-/*
* Str_Match --
*
* See if a particular string matches a particular pattern.
@@ -302,7 +264,7 @@ Str_FindSubstring(char *string, char *substring)
* Side effects: None.
*/
int
-Str_Match(char *string, char *pattern)
+Str_Match(const char *string, const char *pattern)
{
char c2;
@@ -404,12 +366,13 @@ thisCharOK: ++pattern;
*
*-----------------------------------------------------------------------
*/
-char *
-Str_SYSVMatch(char *word, char *pattern, int *len)
+const char *
+Str_SYSVMatch(const char *word, const char *pattern, int *len)
{
- char *p = pattern;
- char *w = word;
- char *m;
+ const char *m, *p, *w;
+
+ p = pattern;
+ w = word;
if (*w == '\0') {
/* Zero-length word cannot be matched against */
@@ -468,9 +431,9 @@ Str_SYSVMatch(char *word, char *pattern, int *len)
*-----------------------------------------------------------------------
*/
void
-Str_SYSVSubst(Buffer buf, char *pat, char *src, int len)
+Str_SYSVSubst(Buffer buf, const char *pat, const char *src, int len)
{
- char *m;
+ const char *m;
if ((m = strchr(pat, '%')) != NULL) {
/* Copy the prefix */
OpenPOWER on IntegriCloud