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): replace *line with line[0]



details:   https://anonhg.NetBSD.org/src/rev/7656f34363fd
branches:  trunk
changeset: 947193:7656f34363fd
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 13 02:01:43 2020 +0000

description:
make(1): replace *line with line[0]

Since a line is not an iterator and since the expression *line typically
means "the current element", not "the first character", replacing *line
with line[0] more directly expresses the idea of accessing the first
character of a string.

diffstat:

 usr.bin/make/job.c   |   5 +++--
 usr.bin/make/main.c  |   5 +++--
 usr.bin/make/parse.c |  26 +++++++++++++++-----------
 3 files changed, 21 insertions(+), 15 deletions(-)

diffs (155 lines):

diff -r 52b27cb32098 -r 7656f34363fd usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sun Dec 13 01:51:08 2020 +0000
+++ b/usr.bin/make/job.c        Sun Dec 13 02:01:43 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.385 2020/12/12 18:53:53 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.386 2020/12/13 02:01:43 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.385 2020/12/12 18:53:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.386 2020/12/13 02:01:43 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -2354,6 +2354,7 @@
        Boolean fullSpec = FALSE;
        Shell *sh;
 
+       /* XXX: don't use line as an iterator variable */
        pp_skip_whitespace(&line);
 
        free(shellArgv);
diff -r 52b27cb32098 -r 7656f34363fd usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Dec 13 01:51:08 2020 +0000
+++ b/usr.bin/make/main.c       Sun Dec 13 02:01:43 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.495 2020/12/12 18:53:53 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.496 2020/12/13 02:01:43 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.495 2020/12/12 18:53:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.496 2020/12/13 02:01:43 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -683,6 +683,7 @@
 
        if (line == NULL)
                return;
+       /* XXX: don't use line as an iterator variable */
        for (; *line == ' '; ++line)
                continue;
        if (line[0] == '\0')
diff -r 52b27cb32098 -r 7656f34363fd usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sun Dec 13 01:51:08 2020 +0000
+++ b/usr.bin/make/parse.c      Sun Dec 13 02:01:43 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.477 2020/12/13 01:51:08 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.478 2020/12/13 02:01:43 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.477 2020/12/13 01:51:08 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.478 2020/12/13 02:01:43 rillig Exp $");
 
 /* types and constants */
 
@@ -1099,7 +1099,7 @@
 /* Handle special targets like .PATH, .DEFAULT, .BEGIN, .ORDER. */
 static void
 ParseDoDependencyTargetSpecial(ParseSpecial *inout_specType,
-                              const char *line,
+                              const char *line, /* XXX: bad name */
                               SearchPathList **inout_paths)
 {
        switch (*inout_specType) {
@@ -1164,7 +1164,8 @@
  * Call on the suffix module to give us a path to modify.
  */
 static Boolean
-ParseDoDependencyTargetPath(const char *line, SearchPathList **inout_paths)
+ParseDoDependencyTargetPath(const char *line, /* XXX: bad name */
+                           SearchPathList **inout_paths)
 {
        SearchPath *path;
 
@@ -1186,12 +1187,13 @@
  * See if it's a special target and if so set specType to match it.
  */
 static Boolean
-ParseDoDependencyTarget(const char *line, ParseSpecial *inout_specType,
+ParseDoDependencyTarget(const char *line, /* XXX: bad name */
+                       ParseSpecial *inout_specType,
                        GNodeType *out_tOp, SearchPathList **inout_paths)
 {
        int keywd;
 
-       if (!(*line == '.' && ch_isupper(line[1])))
+       if (!(line[0] == '.' && ch_isupper(line[1])))
                return TRUE;
 
        /*
@@ -1221,7 +1223,8 @@
 }
 
 static void
-ParseDoDependencyTargetMundane(char *line, StringList *curTargs)
+ParseDoDependencyTargetMundane(char *line, /* XXX: bad name */
+                              StringList *curTargs)
 {
        if (Dir_HasWildcards(line)) {
                /*
@@ -1666,6 +1669,7 @@
        /*
         * First, grind through the targets.
         */
+       /* XXX: don't use line as an iterator variable */
        if (!ParseDoDependencyTargets(&cp, &line, lstart, &specType, &tOp,
            &paths, &curTargs))
                goto out;
@@ -2257,11 +2261,11 @@
 }
 
 static void
-ParseDoInclude(char *line)
+ParseDoInclude(char *line /* XXX: bad name */)
 {
        char endc;              /* the character which ends the file spec */
        char *cp;               /* current position in file spec */
-       Boolean silent = *line != 'i';
+       Boolean silent = line[0] != 'i';
        char *file = line + (silent ? 8 : 7);
 
        /* Skip to delimiter character so we know where to look */
@@ -2302,7 +2306,7 @@
        (void)Var_Subst(file, VAR_CMDLINE, VARE_WANTRES, &file);
        /* TODO: handle errors */
 
-       Parse_include_file(file, endc == '>', *line == 'd', silent);
+       Parse_include_file(file, endc == '>', line[0] == 'd', silent);
        free(file);
 }
 
@@ -3128,7 +3132,7 @@
        if (line[0] == '.' && ParseDirective(line))
                return;
 
-       if (*line == '\t') {
+       if (line[0] == '\t') {
                ParseLine_ShellCommand(line + 1);
                return;
        }



Home | Main Index | Thread Index | Old Index