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): rename mode constants for ParseGetLine...



details:   https://anonhg.NetBSD.org/src/rev/ff32d6c1c17b
branches:  trunk
changeset: 957977:ff32d6c1c17b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 19 16:05:33 2020 +0000

description:
make(1): rename mode constants for ParseGetLine to be more expressive

diffstat:

 usr.bin/make/parse.c |  40 ++++++++++++++++------------------------
 1 files changed, 16 insertions(+), 24 deletions(-)

diffs (110 lines):

diff -r 5f507bb2c6a7 -r ff32d6c1c17b usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Dec 19 16:00:17 2020 +0000
+++ b/usr.bin/make/parse.c      Sat Dec 19 16:05:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.498 2020/12/19 15:29:28 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.499 2020/12/19 16:05:33 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.498 2020/12/19 15:29:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.499 2020/12/19 16:05:33 rillig Exp $");
 
 /* types and constants */
 
@@ -2791,25 +2791,26 @@
         * Backslash line continuations are folded into a single space.
         * A trailing comment, if any, is discarded.
         */
-       PARSE_NORMAL,
+       GLM_NONEMPTY,
 
        /*
         * Return the next line, even if it is empty or a comment.
+        * Preserve backslash-newline to keep the line numbers correct.
         *
         * Used in .for loops to collect the body of the loop while waiting
         * for the corresponding .endfor.
         */
-       PARSE_RAW,
+       GLM_FOR_BODY,
 
        /*
-        * Return the next line that is a directive.
+        * Return the next line that starts with a dot.
         * Backslash line continuations are folded into a single space.
         * A trailing comment, if any, is discarded.
         *
         * Used in .if directives to skip over irrelevant branches while
         * waiting for the corresponding .endif.
         */
-       PARSE_SKIP
+       GLM_DOT
 } GetLineMode;
 
 /* Return the next "interesting" logical line from the current file. */
@@ -2832,27 +2833,18 @@
                if (line_end == line || firstComment == line) {
                        if (res == PRLR_EOF)
                                return NULL;
-                       if (mode != PARSE_RAW)
+                       if (mode != GLM_FOR_BODY)
                                continue;
                }
 
                /* We now have a line of data */
                *line_end = '\0';
 
-               if (mode == PARSE_RAW) {
-                       /* Leave '\' (etc) in line buffer (eg 'for' lines) */
-                       return line;
-               }
-
-               if (mode == PARSE_SKIP) {
-                       /* Completely ignore non-directives */
-                       if (line[0] != '.')
-                               continue;
-                       /*
-                        * We could do more of the .else/.elif/.endif checks
-                        * here.
-                        */
-               }
+               if (mode == GLM_FOR_BODY)
+                       return line;    /* Don't join the physical lines. */
+
+               if (mode == GLM_DOT && line[0] != '.')
+                       continue;
                break;
        }
 
@@ -2891,7 +2883,7 @@
        int rval;
 
        for (;;) {
-               line = ParseGetLine(PARSE_NORMAL);
+               line = ParseGetLine(GLM_NONEMPTY);
                if (line == NULL)
                        return NULL;
 
@@ -2904,7 +2896,7 @@
                 */
                switch (Cond_EvalLine(line)) {
                case COND_SKIP:
-                       while ((line = ParseGetLine(PARSE_SKIP)) != NULL) {
+                       while ((line = ParseGetLine(GLM_DOT)) != NULL) {
                                if (Cond_EvalLine(line) == COND_PARSE)
                                        break;
                                /*
@@ -2939,7 +2931,7 @@
                        lineno = CurFile()->lineno;
                        /* Accumulate loop lines until matching .endfor */
                        do {
-                               line = ParseGetLine(PARSE_RAW);
+                               line = ParseGetLine(GLM_FOR_BODY);
                                if (line == NULL) {
                                        Parse_Error(PARSE_FATAL,
                                            "Unexpected end of file "



Home | Main Index | Thread Index | Old Index