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): clean up ParseRawLine



details:   https://anonhg.NetBSD.org/src/rev/cd6db46b4463
branches:  trunk
changeset: 947587:cd6db46b4463
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 19 00:27:34 2020 +0000

description:
make(1): clean up ParseRawLine

diffstat:

 usr.bin/make/parse.c |  23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diffs (76 lines):

diff -r 3084195e7705 -r cd6db46b4463 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Dec 19 00:20:57 2020 +0000
+++ b/usr.bin/make/parse.c      Sat Dec 19 00:27:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.489 2020/12/19 00:20:57 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.490 2020/12/19 00:27:34 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.489 2020/12/19 00:20:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.490 2020/12/19 00:27:34 rillig Exp $");
 
 /* types and constants */
 
@@ -2661,17 +2661,19 @@
  * Do not unescape "\#", that's done by UnescapeBackslash.
  */
 static Boolean
-ParseRawLine(char **inout_line, char **out_ptr, char **out_line_end,
+ParseRawLine(char **out_line, char **out_line_end,
              char **out_escaped, char **out_comment, char *inout_ch,
              IFile *const cf)
 {
-       char *line = *inout_line;
+       char *line = cf->buf_ptr;
        char *ptr = line;
        char *line_end = line;
        char *escaped = NULL;
        char *comment = NULL;
        char ch = *inout_ch;
 
+       cf->lineno++;
+
        for (;;) {
                if (ptr == cf->buf_end) {
                        /* end of buffer */
@@ -2720,8 +2722,8 @@
                        line_end = ptr;
        }
 
-       *inout_line = line;
-       *out_ptr = ptr;
+       *out_line = line;
+       cf->buf_ptr = ptr;
        *out_line_end = line_end;
        *out_escaped = escaped;
        *out_comment = comment;
@@ -2795,7 +2797,6 @@
 ParseGetLine(GetLineMode mode)
 {
        IFile *cf = CurFile();
-       char *ptr;
        char ch;
        char *line;
        char *line_end;
@@ -2804,15 +2805,9 @@
 
        /* Loop through blank lines and comment lines */
        for (;;) {
-               cf->lineno++;
-               line = cf->buf_ptr;
-               if (!ParseRawLine(&line, &ptr, &line_end, &escaped, &comment,
-                   &ch, cf))
+               if (!ParseRawLine(&line, &line_end, &escaped, &comment, &ch, cf))
                        return NULL;
 
-               /* Save next 'to be processed' location */
-               cf->buf_ptr = ptr;
-
                /* Check we have a non-comment, non-blank line */
                if (line_end == line || comment == line) {
                        if (ch == '\0')



Home | Main Index | Thread Index | Old Index