At 2025-03-30T22:24:18+0000, Lennart Jablonka wrote:
> POSIX doesn’t explicitly specify (or explicitly un-specify) what
> happens when a backslash in the format string is followed by a
> character other than those listed by POSIX with special behavior.
> OpenBSD’s printf, at least, warns about it and prints the literal
> character following the backslash.

Thanks for the report.  That is indeed a problem.

[...]
> diff --git a/src/roff/groff/tests/html-device-smoke-test.sh 
> b/src/roff/groff/tests/html-device-smoke-test.sh
> index 8d2aad7fd..d8fa234a8 100755
> --- a/src/roff/groff/tests/html-device-smoke-test.sh
> +++ b/src/roff/groff/tests/html-device-smoke-test.sh
> @@ -103,7 +103,7 @@ printf '\303\241' | "$groff" -k -Thtml | grep -qx 
> '<p>&aacute;</p>' \
>  # We test compatibility-mode HTML output somewhat differently since
>  # preconv only emits groffish \[uXXXX] escapes for non-ASCII codepoints.
>  echo "checking -C -k -Thtml" >&2
> -printf "\('a" | "$groff" -C -k -Thtml | grep -qx '<p>&aacute;</p>' \
> +printf "\\\\('a" | "$groff" -C -k -Thtml | grep -qx '<p>&aacute;</p>' \
>      || wail
>  
>  test -z "$fail"

I went with my own patch for this.

diff --git a/ChangeLog b/ChangeLog
index a72009abf..a1a5f4216 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-04-11  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       * src/roff/groff/tests/html-device-smoke-test.sh: Use printf(1)
+       more portably (`\(` is not well-defined in a format string).
+       Thanks to Lennart Jablonka for the report and a proposed patch.
+
 2025-03-30  Lennart Jablonka <h...@ljabl.com>

        Don't use non-POSIX syntax `\+` in BREs.
diff --git a/src/roff/groff/tests/html-device-smoke-test.sh 
b/src/roff/groff/tests/html-device-smoke-test.sh
index 8d2aad7fd..eb8f1f4d7 100755
--- a/src/roff/groff/tests/html-device-smoke-test.sh
+++ b/src/roff/groff/tests/html-device-smoke-test.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (C) 2020-2024 Free Software Foundation, Inc.
+# Copyright (C) 2020-2025 Free Software Foundation, Inc.
 #
 # This file is part of groff.
 #
@@ -103,9 +103,9 @@ printf '\303\241' | "$groff" -k -Thtml | grep -qx 
'<p>&aacute;</p>' \
 # We test compatibility-mode HTML output somewhat differently since
 # preconv only emits groffish \[uXXXX] escapes for non-ASCII codepoints.
 echo "checking -C -k -Thtml" >&2
-printf "\('a" | "$groff" -C -k -Thtml | grep -qx '<p>&aacute;</p>' \
+printf '\('a | "$groff" -C -k -Thtml | grep -qx '<p>&aacute;</p>' \
     || wail

 test -z "$fail"

-# vim:set ai et sw=4 ts=4 tw=72:
+# vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:

Regards,
Branden

Attachment: signature.asc
Description: PGP signature

Reply via email to