Module Name:    src
Committed By:   rillig
Date:           Sat Oct  3 15:00:57 UTC 2020

Modified Files:
        src/usr.bin/make: job.c nonints.h str.c

Log Message:
make(1): inline Str_FindSubstring in JobOutput


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/usr.bin/make/job.c
cvs rdiff -u -r1.133 -r1.134 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.65 -r1.66 src/usr.bin/make/str.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.254 src/usr.bin/make/job.c:1.255
--- src/usr.bin/make/job.c:1.254	Thu Oct  1 22:42:00 2020
+++ src/usr.bin/make/job.c	Sat Oct  3 15:00:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.254 2020/10/01 22:42:00 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.255 2020/10/03 15:00:57 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.254 2020/10/01 22:42:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.255 2020/10/03 15:00:57 rillig Exp $");
 
 # define STATIC static
 
@@ -1580,9 +1580,8 @@ JobOutput(Job *job, char *cp, char *endp
 {
     char *ecp;
 
-    if (commandShell->noPrint) {
-	ecp = Str_FindSubstring(cp, commandShell->noPrint);
-	while (ecp != NULL) {
+    if (commandShell->noPrint && commandShell->noPrint[0] != '\0') {
+	while ((ecp = strstr(cp, commandShell->noPrint)) != NULL) {
 	    if (cp != ecp) {
 		*ecp = '\0';
 		if (!beSilent && msg && job->node != lastNode) {
@@ -1609,7 +1608,6 @@ JobOutput(Job *job, char *cp, char *endp
 		while (*cp == ' ' || *cp == '\t' || *cp == '\n') {
 		    cp++;
 		}
-		ecp = Str_FindSubstring(cp, commandShell->noPrint);
 	    } else {
 		return cp;
 	    }

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.133 src/usr.bin/make/nonints.h:1.134
--- src/usr.bin/make/nonints.h:1.133	Thu Oct  1 23:44:36 2020
+++ src/usr.bin/make/nonints.h	Sat Oct  3 15:00:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.133 2020/10/01 23:44:36 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.134 2020/10/03 15:00:57 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -147,7 +147,6 @@ Words_Free(Words w) {
 char *str_concat2(const char *, const char *);
 char *str_concat3(const char *, const char *, const char *);
 char *str_concat4(const char *, const char *, const char *, const char *);
-char *Str_FindSubstring(const char *, const char *);
 Boolean Str_Match(const char *, const char *);
 
 /* suff.c */

Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.65 src/usr.bin/make/str.c:1.66
--- src/usr.bin/make/str.c:1.65	Sun Sep 13 15:15:51 2020
+++ src/usr.bin/make/str.c	Sat Oct  3 15:00:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.65 2020/09/13 15:15:51 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.66 2020/10/03 15:00:57 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*	"@(#)str.c	5.8 (Berkeley) 6/1/90"	*/
-MAKE_RCSID("$NetBSD: str.c,v 1.65 2020/09/13 15:15:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.66 2020/10/03 15:00:57 rillig Exp $");
 
 /* Return the concatenation of s1 and s2, freshly allocated. */
 char *
@@ -269,46 +269,6 @@ done:
 }
 
 /*
- * Str_FindSubstring -- See if a string contains a particular substring.
- *
- * Input:
- *	string		String to search.
- *	substring	Substring to find in string.
- *
- * 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 *
-Str_FindSubstring(const char *string, const char *substring)
-{
-	const 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++) {
-		if (*string != *b)
-			continue;
-		a = string;
-		for (;;) {
-			if (*b == 0)
-				return UNCONST(string);
-			if (*a++ != *b++)
-				break;
-		}
-		b = substring;
-	}
-	return NULL;
-}
-
-/*
  * Str_Match -- Test if a string matches a pattern like "*.[ch]".
  *
  * XXX this function does not detect or report malformed patterns.

Reply via email to