Module Name:    src
Committed By:   rillig
Date:           Fri Sep 11 04:32:39 UTC 2020

Modified Files:
        src/usr.bin/make: dir.c job.c strlist.c suff.c var.c

Log Message:
make(1): replace *a->b with a->b[0]

This allows the code to be read strictly from left to right.  In most
places this style was already used.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/usr.bin/make/dir.c
cvs rdiff -u -r1.228 -r1.229 src/usr.bin/make/job.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/strlist.c
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/make/suff.c
cvs rdiff -u -r1.491 -r1.492 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.137 src/usr.bin/make/dir.c:1.138
--- src/usr.bin/make/dir.c:1.137	Mon Sep  7 19:48:08 2020
+++ src/usr.bin/make/dir.c	Fri Sep 11 04:32:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.137 2020/09/07 19:48:08 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.138 2020/09/11 04:32:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.137 2020/09/07 19:48:08 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.138 2020/09/11 04:32:39 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.137 2020/09/07 19:48:08 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.138 2020/09/11 04:32:39 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -579,7 +579,7 @@ DirMatchFiles(const char *pattern, Path 
     Hash_Entry *entry;		/* Current entry in the table */
     Boolean isDot;		/* TRUE if the directory being searched is . */
 
-    isDot = (*p->name == '.' && p->name[1] == '\0');
+    isDot = (p->name[0] == '.' && p->name[1] == '\0');
 
     for (entry = Hash_EnumFirst(&p->files, &search);
 	 entry != NULL;

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.228 src/usr.bin/make/job.c:1.229
--- src/usr.bin/make/job.c:1.228	Mon Sep  7 05:32:12 2020
+++ src/usr.bin/make/job.c	Fri Sep 11 04:32:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.228 2020/09/07 05:32:12 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.229 2020/09/11 04:32:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.228 2020/09/07 05:32:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.229 2020/09/11 04:32:39 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.228 2020/09/07 05:32:12 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.229 2020/09/11 04:32:39 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -804,7 +804,7 @@ JobPrintCommand(void *cmdp, void *jobp)
 			DBPRINTF("%s\n", commandShell->ignErr);
 		}
 	    } else if (commandShell->ignErr &&
-		      (*commandShell->ignErr != '\0'))
+		       commandShell->ignErr[0] != '\0')
 	    {
 		/*
 		 * The shell has no error control, so we need to be
@@ -849,7 +849,7 @@ JobPrintCommand(void *cmdp, void *jobp)
 	 */
 
 	if (!commandShell->hasErrCtl && commandShell->errOut &&
-	    (*commandShell->errOut != '\0')) {
+	    commandShell->errOut[0] != '\0') {
 		if (!(job->flags & JOB_SILENT) && !shutUp) {
 			if (commandShell->hasEchoCtl) {
 				DBPRINTF("%s\n", commandShell->echoOff);
@@ -1474,8 +1474,8 @@ JobMakeArgv(Job *job, char **argv)
     argv[0] = UNCONST(shellName);
     argc = 1;
 
-    if ((commandShell->exit && (*commandShell->exit != '-')) ||
-	(commandShell->echo && (*commandShell->echo != '-')))
+    if ((commandShell->exit && commandShell->exit[0] != '-') ||
+	(commandShell->echo && commandShell->echo[0] != '-'))
     {
 	/*
 	 * At least one of the flags doesn't have a minus before it, so
@@ -2179,7 +2179,7 @@ Shell_Init(void)
     if (commandShell->echo == NULL) {
 	commandShell->echo = "";
     }
-    if (commandShell->hasErrCtl && *commandShell->exit) {
+    if (commandShell->hasErrCtl && commandShell->exit[0] != '\0') {
 	if (shellErrFlag &&
 	    strcmp(commandShell->exit, &shellErrFlag[1]) != 0) {
 	    free(shellErrFlag);

Index: src/usr.bin/make/strlist.c
diff -u src/usr.bin/make/strlist.c:1.6 src/usr.bin/make/strlist.c:1.7
--- src/usr.bin/make/strlist.c:1.6	Tue Aug 25 17:37:09 2020
+++ src/usr.bin/make/strlist.c	Fri Sep 11 04:32:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strlist.c,v 1.6 2020/08/25 17:37:09 rillig Exp $	*/
+/*	$NetBSD: strlist.c,v 1.7 2020/09/11 04:32:39 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2008 - 2009 The NetBSD Foundation, Inc.
@@ -33,11 +33,11 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: strlist.c,v 1.6 2020/08/25 17:37:09 rillig Exp $";
+static char rcsid[] = "$NetBSD: strlist.c,v 1.7 2020/09/11 04:32:39 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: strlist.c,v 1.6 2020/08/25 17:37:09 rillig Exp $");
+__RCSID("$NetBSD: strlist.c,v 1.7 2020/09/11 04:32:39 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -80,7 +80,7 @@ strlist_add_str(strlist_t *sl, char *str
 	sl->sl_num = n;
 	items = sl->sl_items;
 	if (n >= sl->sl_max) {
-		items = bmake_realloc(items, (n + 7) * sizeof *sl->sl_items);
+		items = bmake_realloc(items, (n + 7) * sizeof *items);
 		sl->sl_items = items;
 		sl->sl_max = n + 6;
 	}

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.145 src/usr.bin/make/suff.c:1.146
--- src/usr.bin/make/suff.c:1.145	Tue Sep  8 05:26:21 2020
+++ src/usr.bin/make/suff.c	Fri Sep 11 04:32:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.145 2020/09/08 05:26:21 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.146 2020/09/11 04:32:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.145 2020/09/08 05:26:21 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.146 2020/09/11 04:32:39 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)suff.c	8.4 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: suff.c,v 1.145 2020/09/08 05:26:21 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.146 2020/09/11 04:32:39 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -969,7 +969,7 @@ SuffAddSrc(void *sp, void *lsp)
 
     targ = ls->s;
 
-    if ((s->flags & SUFF_NULL) && (*s->name != '\0')) {
+    if ((s->flags & SUFF_NULL) && s->name[0] != '\0') {
 	/*
 	 * If the suffix has been marked as the NULL suffix, also create a Src
 	 * structure for a file with no suffix attached. Two birds, and all

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.491 src/usr.bin/make/var.c:1.492
--- src/usr.bin/make/var.c:1.491	Tue Sep  8 05:26:21 2020
+++ src/usr.bin/make/var.c	Fri Sep 11 04:32:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.491 2020/09/08 05:26:21 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.492 2020/09/11 04:32:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.491 2020/09/08 05:26:21 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.492 2020/09/11 04:32:39 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.491 2020/09/08 05:26:21 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.492 2020/09/11 04:32:39 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2969,7 +2969,7 @@ ApplyModifier_SysV(const char **pp, Appl
      * string. Note the pattern is anchored at the end.
      */
     (*pp)--;
-    if (lhs[0] == '\0' && *st->val == '\0') {
+    if (lhs[0] == '\0' && st->val[0] == '\0') {
 	st->newVal = st->val;	/* special case */
     } else {
 	ModifyWord_SYSVSubstArgs args = {st->ctxt, lhs, rhs};

Reply via email to