Module Name:    src
Committed By:   rillig
Date:           Thu Dec 31 03:19:01 UTC 2020

Modified Files:
        src/usr.bin/make: for.c

Log Message:
make(1): clean up ForReadMore

After the previous clean up in for.c 1.123 from 2020-12-30, GCC 5.5 did
not inline the function SubstVarLong anymore since it was now called
from 2 places.  GCC didn't notice that the function call was essentially
the same since in differed only in the end character.

By combining the cases for ${V} and $(V), the code becomes even shorter
than before, while still being understandable.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/usr.bin/make/for.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/for.c
diff -u src/usr.bin/make/for.c:1.124 src/usr.bin/make/for.c:1.125
--- src/usr.bin/make/for.c:1.124	Thu Dec 31 03:10:29 2020
+++ src/usr.bin/make/for.c	Thu Dec 31 03:19:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.124 2020/12/31 03:10:29 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.125 2020/12/31 03:19:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.124 2020/12/31 03:10:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.125 2020/12/31 03:19:00 rillig Exp $");
 
 static int forLevel = 0;	/* Nesting level */
 
@@ -459,13 +459,11 @@ ForReadMore(void *v_arg, size_t *out_len
 	mark = Buf_GetAll(&f->body, NULL);
 	body_end = mark + Buf_Len(&f->body);
 	for (p = mark; (p = strchr(p, '$')) != NULL;) {
-		if (p[1] == '{') {
+		char ch = p[1];
+		if (ch == '{' || ch == '(') {
 			p += 2;
-			SubstVarLong(f, &p, &mark, '}');
-		} else if (p[1] == '(') {
-			p += 2;
-			SubstVarLong(f, &p, &mark, ')');
-		} else if (p[1] != '\0') {
+			SubstVarLong(f, &p, &mark, ch == '{' ? '}' : ')');
+		} else if (ch != '\0') {
 			p++;
 			SubstVarShort(f, &p, &mark);
 		} else

Reply via email to