Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): inline Str_FindSubstring in JobOutput



details:   https://anonhg.NetBSD.org/src/rev/ad9d3c58bcbd
branches:  trunk
changeset: 976762:ad9d3c58bcbd
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 03 15:00:57 2020 +0000

description:
make(1): inline Str_FindSubstring in JobOutput

diffstat:

 usr.bin/make/job.c     |  10 ++++------
 usr.bin/make/nonints.h |   3 +--
 usr.bin/make/str.c     |  44 ++------------------------------------------
 3 files changed, 7 insertions(+), 50 deletions(-)

diffs (120 lines):

diff -r b0903060da62 -r ad9d3c58bcbd usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Oct 03 14:41:20 2020 +0000
+++ b/usr.bin/make/job.c        Sat Oct 03 15:00:57 2020 +0000
@@ -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 @@
 {
     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 @@
                while (*cp == ' ' || *cp == '\t' || *cp == '\n') {
                    cp++;
                }
-               ecp = Str_FindSubstring(cp, commandShell->noPrint);
            } else {
                return cp;
            }
diff -r b0903060da62 -r ad9d3c58bcbd usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Sat Oct 03 14:41:20 2020 +0000
+++ b/usr.bin/make/nonints.h    Sat Oct 03 15:00:57 2020 +0000
@@ -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 @@
 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 */
diff -r b0903060da62 -r ad9d3c58bcbd usr.bin/make/str.c
--- a/usr.bin/make/str.c        Sat Oct 03 14:41:20 2020 +0000
+++ b/usr.bin/make/str.c        Sat Oct 03 15:00:57 2020 +0000
@@ -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 @@
 }
 
 /*
- * 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.



Home | Main Index | Thread Index | Old Index