On Thu, Jun 16, 2011 at 22:00, Ralf Wildenhues <ralf.wildenh...@gmx.de> wrote: > Hello, > > * Bert Wesarg wrote on Thu, Jun 16, 2011 at 08:19:23PM CEST: >> the parallel part is a little trickier. Because the line printing is >> done by awk. I would like to know, whether it is portable to use the >> printf function of awk. It is POSIX, but you may know that this >> doesn't count much. > > True. In case of doubt, try Solaris awk, that's fairly old.
I don't have access to a solaris system. > >> I couldn't find any prior usage in automake and >> autoconf either. Nor does the autoconf manual list printf as a >> functions in the traditional awk. > > Then I would prefer to do without. I don't see why you would need it > for your change at all, however. All the coloring is done from echo > statements even in the parallel case, and you can put the resets in > there as well, methinks. The parallel code uses an awk script (am__text_box) to generate the test report. Below is my current attempt with the help of awk's printf. Bert diff --git c/lib/am/check.am i/lib/am/check.am index 97ecb68..517e1ff 100644 lib/am/check.am --- c/lib/am/check.am +++ i/lib/am/check.am @@ -75,15 +75,17 @@ am__rst_title = sed 's/.*/ & /;h;s/./=/g;p;x;p;g;p;s/.*//' am__rst_section = sed 'p;s/./=/g;p;g' # Put stdin (possibly several lines separated by ". ") in a box. -am__text_box = $(AWK) '{ \ - n = split($$0, lines, "\\. "); max = 0; \ - for (i = 1; i <= n; ++i) \ - if (max < length(lines[i])) \ - max = length(lines[i]); \ - for (i = 0; i < max; ++i) line = line "="; \ - print line; \ - for (i = 1; i <= n; ++i) if (lines[i]) print lines[i];\ - print line; \ +am__text_box = $(AWK) '{ \ + n = split($$0, lines, "\\. "); max = 0; \ + for (i = 1; i <= n; ++i) \ + if (max < length(lines[i])) \ + max = length(lines[i]); \ + for (i = 0; i < max; ++i) line = line "="; \ + printf("%s%s%s\n", col, line, std); \ + for (i = 1; i <= n; ++i) \ + if (lines[i]) \ + printf("%s%s%s\n", col, lines[i], std); \ + printf("%s%s%s\n", col, line, std); \ }' # Solaris 10 'make', and several other traditional 'make' implementations, @@ -216,12 +218,11 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) test x"$$VERBOSE" = x || $$exit || cat $(TEST_SUITE_LOG); \ $(am__tty_colors); \ if $$exit; then \ - echo $(ECHO_N) "$$grn$(ECHO_C)"; \ + col="$$grn"; \ else \ - echo $(ECHO_N) "$$red$(ECHO_C)"; \ + col="$$red"; \ fi; \ - echo "$$msg" | $(am__text_box); \ - echo $(ECHO_N) "$$std$(ECHO_C)"; \ + echo "$$msg" | $(am__text_box) "col=$$col" "std=$$std"; \ $$exit RECHECK_LOGS = $(TEST_LOGS) @@ -401,14 +402,15 @@ check-TESTS: $(TESTS) fi; \ dashes=`echo "$$dashes" | sed s/./=/g`; \ if test "$$failed" -eq 0; then \ - echo "$$grn$$dashes"; \ + col="$$grn"; \ else \ - echo "$$red$$dashes"; \ + col="$$red"; \ fi; \ - echo "$$banner"; \ - test -z "$$skipped" || echo "$$skipped"; \ - test -z "$$report" || echo "$$report"; \ - echo "$$dashes$$std"; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ test "$$failed" -eq 0; \ else :; fi