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): merge duplicate code for skipping hori...



details:   https://anonhg.NetBSD.org/src/rev/ddc6b88109ef
branches:  trunk
changeset: 1015992:ddc6b88109ef
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Nov 06 22:39:10 2020 +0000

description:
make(1): merge duplicate code for skipping horizontal whitespace

diffstat:

 usr.bin/make/cond.c |  24 ++++++++----------------
 usr.bin/make/make.h |   9 ++++++++-
 2 files changed, 16 insertions(+), 17 deletions(-)

diffs (96 lines):

diff -r d5e96afabc4e -r ddc6b88109ef usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Fri Nov 06 22:37:07 2020 +0000
+++ b/usr.bin/make/cond.c       Fri Nov 06 22:39:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.176 2020/11/06 20:50:48 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.177 2020/11/06 22:39:10 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.176 2020/11/06 20:50:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.177 2020/11/06 22:39:10 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -223,9 +223,7 @@
        return 0;
     }
 
-    while (*p == ' ' || *p == '\t') {
-       p++;
-    }
+    cpp_skip_hspace(&p);
 
     Buf_Init(&argBuf, 16);
 
@@ -264,9 +262,7 @@
     *out_arg = Buf_GetAll(&argBuf, &argLen);
     Buf_Destroy(&argBuf, FALSE);
 
-    while (*p == ' ' || *p == '\t') {
-       p++;
-    }
+    cpp_skip_hspace(&p);
 
     if (func != NULL && *p++ != ')') {
        Parse_Error(PARSE_WARNING, "Missing closing parenthesis for %s()",
@@ -811,9 +807,7 @@
        return t;
     }
 
-    while (par->p[0] == ' ' || par->p[0] == '\t') {
-       par->p++;
-    }
+    cpp_skip_hspace(&par->p);
 
     switch (par->p[0]) {
 
@@ -1018,8 +1012,7 @@
 
     lhsStrict = strictLHS;
 
-    while (*cond == ' ' || *cond == '\t')
-       cond++;
+    cpp_skip_hspace(&cond);
 
     if (info == NULL && (info = dflt_info) == NULL) {
        /* Scan for the entry for .if - it can't be first */
@@ -1094,9 +1087,8 @@
        cond_state = bmake_malloc(max_if_depth * sizeof *cond_state);
        cond_state[0] = IF_ACTIVE;
     }
-    /* skip leading character (the '.') and any whitespace */
-    for (line++; *line == ' ' || *line == '\t'; line++)
-       continue;
+    line++;            /* skip the leading '.' */
+    cpp_skip_hspace(&line);
 
     /* Find what type of if we're dealing with.  */
     if (line[0] == 'e') {
diff -r d5e96afabc4e -r ddc6b88109ef usr.bin/make/make.h
--- a/usr.bin/make/make.h       Fri Nov 06 22:37:07 2020 +0000
+++ b/usr.bin/make/make.h       Fri Nov 06 22:39:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.195 2020/11/06 22:37:07 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.196 2020/11/06 22:39:10 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -729,6 +729,13 @@
 }
 
 static inline MAKE_ATTR_UNUSED void
+cpp_skip_hspace(const char **pp)
+{
+    while (**pp == ' ' || **pp == '\t')
+       (*pp)++;
+}
+
+static inline MAKE_ATTR_UNUSED void
 pp_skip_whitespace(char **pp)
 {
     while (ch_isspace(**pp))



Home | Main Index | Thread Index | Old Index