make: add more details to debug logging of .for loops

This commit is contained in:
rillig 2023-06-01 09:02:14 +00:00
parent 78e97c0a70
commit a7d1ba3ffa
6 changed files with 60 additions and 52 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: for.c,v 1.175 2023/06/01 07:44:10 rillig Exp $ */
/* $NetBSD: for.c,v 1.176 2023/06/01 09:02:14 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.175 2023/06/01 07:44:10 rillig Exp $");
MAKE_RCSID("$NetBSD: for.c,v 1.176 2023/06/01 09:02:14 rillig Exp $");
typedef struct ForLoop {
@ -513,7 +513,12 @@ For_NextIteration(ForLoop *f, Buffer *body)
f->nextItem += (unsigned int)f->vars.len;
ForLoop_SubstBody(f, f->nextItem - (unsigned int)f->vars.len, body);
DEBUG1(FOR, "For: loop body:\n%s", body->data);
if (DEBUG(FOR)) {
char *details = ForLoop_Details(f);
debug_printf("For: loop body with %s:\n%s",
details, body->data);
free(details);
}
return true;
}

View File

@ -3,7 +3,7 @@ make: "directive-for-empty.mk" line 34: Missing argument for ".error"
make: "directive-for-empty.mk" line 34: Missing argument for ".error"
make: "directive-for-empty.mk" line 34: Missing argument for ".error"
For: end for 1
For: loop body:
For: loop body with i = value:
# The identifier 'empty' can only be used in conditions such as .if, .ifdef or
# .elif. In other lines the string 'empty(' must be preserved.
CPPFLAGS+= -Dmessage="empty(i)"

View File

@ -1,52 +1,52 @@
For: end for 1
For: loop body:
For: loop body with chars = !"#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~:
. info ${:U!"#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~}
make: Unclosed variable expression, expecting '}' for modifier "U!"" of variable "" with value "!""
make: "directive-for-escape.mk" line 21: !"
For: end for 1
For: loop body:
For: loop body with chars = !"\\#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~:
. info ${:U!"\\\\#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~}
make: Unclosed variable expression, expecting '}' for modifier "U!"\\\\" of variable "" with value "!"\\"
make: "directive-for-escape.mk" line 32: !"\\
For: end for 1
For: loop body:
For: loop body with i = $:
. info ${:U\$}
make: "directive-for-escape.mk" line 47: $
For: loop body:
For: loop body with i = ${V}:
. info ${:U${V}}
make: "directive-for-escape.mk" line 47: value
For: loop body:
For: loop body with i = ${V:=-with-modifier}:
. info ${:U${V:=-with-modifier}}
make: "directive-for-escape.mk" line 47: value-with-modifier
For: loop body:
For: loop body with i = $(V):
. info ${:U$(V)}
make: "directive-for-escape.mk" line 47: value
For: loop body:
For: loop body with i = $(V:=-with-modifier):
. info ${:U$(V:=-with-modifier)}
make: "directive-for-escape.mk" line 47: value-with-modifier
For: end for 1
For: loop body:
For: loop body with i = ${UNDEF:U\$\$:
# ${:U\${UNDEF\:U\\$\\$}
For: loop body:
For: loop body with i = {{}}:
# ${:U{{\}\}}
For: loop body:
For: loop body with i = end}:
# ${:Uend\}}
For: end for 1
For: loop body:
For: loop body with i = ${UNDEF:U\$\$:
. info ${:U\${UNDEF\:U\\$\\$}
make: "directive-for-escape.mk" line 101: ${UNDEF:U\backslash$
For: loop body:
For: loop body with i = {{}}:
. info ${:U{{\}\}}
make: "directive-for-escape.mk" line 101: {{}}
For: loop body:
For: loop body with i = end}:
. info ${:Uend\}}
make: "directive-for-escape.mk" line 101: end}
For: end for 1
For: loop body:
For: loop body with i = begin<${UNDEF:Ufallback:N{{{}}}}>end:
. info ${:Ubegin<${UNDEF:Ufallback:N{{{}}}}>end}
make: "directive-for-escape.mk" line 122: begin<fallback>end
For: end for 1
For: loop body:
For: loop body with i = $:
. info ${:U\$}
make: "directive-for-escape.mk" line 131: $
make: "directive-for-escape.mk" line 140: invalid character ':' in .for loop variable name
@ -54,7 +54,7 @@ For: end for 1
make: "directive-for-escape.mk" line 150: invalid character '}' in .for loop variable name
For: end for 1
For: end for 1
For: loop body:
For: loop body with i = inner:
. info . $$i: ${:Uinner}
. info . $${i}: ${:Uinner}
. info . $${i:M*}: ${:Uinner:M*}
@ -81,19 +81,22 @@ make: "directive-for-escape.mk" line 199: eight and no cents.
For: end for 1
make: "directive-for-escape.mk" line 212: newline in .for value
make: "directive-for-escape.mk" line 212: newline in .for value
For: loop body:
For: loop body with i = "
":
. info short: ${:U" "}
. info long: ${:U" "}
make: "directive-for-escape.mk" line 213: short: " "
make: "directive-for-escape.mk" line 214: long: " "
For: end for 1
For: loop body:
For: loop body with i = "
":
For: end for 1
Parse_PushInput: .for loop in directive-for-escape.mk, line 230
make: "directive-for-escape.mk" line 230: newline in .for value
in .for loop from directive-for-escape.mk:230 with i = "
"
For: loop body:
For: loop body with i = "
":
: ${:U" "}
SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `directive-for-escape.mk'
Parsing line 231: : ${:U" "}
@ -103,42 +106,42 @@ SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `directive-for-escape
Parsing line 233: .MAKEFLAGS: -d0
ParseDependency(.MAKEFLAGS: -d0)
For: end for 1
For: loop body:
For: loop body with i = #:
# ${:U#}
For: loop body:
For: loop body with i = \\#:
# ${:U\\\\#}
For: end for 1
For: loop body:
For: loop body with i = $:
# ${:U\$}
For: loop body:
For: loop body with i = $i:
# ${:U$i}
For: loop body:
For: loop body with i = $(i):
# ${:U$(i)}
For: loop body:
For: loop body with i = ${i}:
# ${:U${i}}
For: loop body:
For: loop body with i = $$:
# ${:U$$}
For: loop body:
For: loop body with i = $$$$:
# ${:U$$$$}
For: loop body:
For: loop body with i = ${:U\$\$}:
# ${:U${:U\$\$}}
For: end for 1
For: loop body:
For: loop body with i = ${.TARGET}:
# ${:U${.TARGET}}
For: loop body:
For: loop body with i = ${.TARGET}:
# ${:U${.TARGET}}
For: loop body:
For: loop body with i = $${.TARGET}:
# ${:U$${.TARGET\}}
For: loop body:
For: loop body with i = $${.TARGET}:
# ${:U$${.TARGET\}}
For: end for 1
For: loop body:
For: loop body with i = (((:
# ${:U(((}
For: loop body:
For: loop body with i = {{{:
# ${:U{{{}
For: loop body:
For: loop body with i = ))):
# ${:U)))}
For: loop body:
For: loop body with i = }}}:
# ${:U\}\}\}}
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests

View File

@ -1,4 +1,4 @@
# $NetBSD: directive-for-escape.mk,v 1.18 2023/05/09 19:43:12 rillig Exp $
# $NetBSD: directive-for-escape.mk,v 1.19 2023/06/01 09:02:14 rillig Exp $
#
# Test escaping of special characters in the iteration values of a .for loop.
# These values get expanded later using the :U variable modifier, and this
@ -74,11 +74,11 @@ VALUES= $${UNDEF:U\$$\$$ {{}} end}
# When these words are injected into the body of the .for loop, each inside a
# '${:U...}' expression, the result is:
#
# expect: For: loop body:
# expect: For: loop body with i = ${UNDEF:U\$\$:
# expect: # ${:U\${UNDEF\:U\\$\\$}
# expect: For: loop body:
# expect: For: loop body with i = {{}}:
# expect: # ${:U{{\}\}}
# expect: For: loop body:
# expect: For: loop body with i = end}:
# expect: # ${:Uend\}}
# expect: For: end for 1
#

View File

@ -28,13 +28,13 @@ make: "directive-for.mk" line 257: if-less endif
For: new loop 2
For: end for 2
For: end for 1
For: loop body:
For: loop body with outer = o:
.\
for inner in i
.\
endfor
For: end for 1
For: loop body:
For: loop body with inner = i:
make: "directive-for.mk" line 305: newline-item=(a)
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests

View File

@ -1,22 +1,22 @@
For: new loop 2
For: end for 2
For: end for 1
For: loop body:
For: loop body with outer = a:
. for inner in 1 2
VAR.${:Ua}${inner}= value
. endfor
For: end for 1
For: loop body:
For: loop body with inner = 1:
VAR.${:Ua}${:U1}= value
For: loop body:
For: loop body with inner = 2:
VAR.${:Ua}${:U2}= value
For: loop body:
For: loop body with outer = b:
. for inner in 1 2
VAR.${:Ub}${inner}= value
. endfor
For: end for 1
For: loop body:
For: loop body with inner = 1:
VAR.${:Ub}${:U1}= value
For: loop body:
For: loop body with inner = 2:
VAR.${:Ub}${:U2}= value
exit status 0