gbranden pushed a commit to branch master
in repository groff.
commit 7ae45a1d4c641ea30007e2bb5bfa00de5e34d644
Author: Lennart Jablonka <[email protected]>
AuthorDate: Sun Mar 30 22:23:58 2025 +0000
Don't use non-POSIX `\+` syntax in BREs.
It's implementation-defined whether \+ behaves like literal + or like
\{1,\}. (The same applies to \? and \|; I didn't find uses of those.)
As it happens, OpenBSD treats it as literal '+'.
Found it through a failure of html-device-smoke-test.sh.
See
<https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/basedefs/V1_chap09.html#tag_09_03_02>.
---
ChangeLog | 20 ++++++++++++++++++++
m4/groff.m4 | 8 ++++----
makevarescape.sed | 2 +-
src/libs/libgroff/make-uniuni | 2 +-
src/roff/groff/tests/html-device-smoke-test.sh | 4 ++--
src/utils/afmtodit/make-afmtodit-tables | 2 +-
6 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 776037868..a72009abf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2025-03-30 Lennart Jablonka <[email protected]>
+
+ Don't use non-POSIX syntax `\+` in BREs.
+
+ It's implementation-defined whether \+ behaves like literal + or
+ like \{1,\}. (The same applies to \? and \|; I didn't find uses
+ of those.) As it happens, OpenBSD treats it as literal '+'.
+
+ * m4/groff.m4 (GROFF_PAGE):
+ * makevarescape.sed:
+ * src/libs/libgroff/make-uniuni:
+ * src/roff/groff/tests/html-device-smoke-test.sh:
+ * src/utils/afmtodit/make-afmtodit-tables: Use more portable
+ sed(1) and grep(1) syntax.
+
+ Found through a failure of html-device-smoke-test.sh.
+
+ See <https://pubs.opengroup.org/onlinepubs/\
+ 9799919799.2024edition/basedefs/V1_chap09.html#tag_09_03_02>.
+
2025-04-11 G. Branden Robinson <[email protected]>
[font]: Update and parallelize `DESC` file generation.
diff --git a/m4/groff.m4 b/m4/groff.m4
index 8657fdfa2..9f311e318 100644
--- a/m4/groff.m4
+++ b/m4/groff.m4
@@ -942,7 +942,7 @@ AC_DEFUN([GROFF_PAGE], [
papersize=/etc/papersize
if test -z "$PAGE" && test -r "$papersize"
then
- sedexpr='s/#.*//;s/[ \t]\+/ /;s/ \+$//;s/^ \+//;/^$/d;p'
+ sedexpr='s/#.*//;s/[ \t]\{1,\}/ /;s/ *$//;s/^ *//;/^$/d;p'
PAGE=`sed -n "$sedexpr" "$papersize"`
test -n "$PAGE" && whence=$papersize
fi
@@ -969,10 +969,10 @@ AC_DEFUN([GROFF_PAGE], [
if test -n "$descfile"
then
- if grep -q ['^paperlength[ ]\+841890'] "$descfile"
+ if grep -q ['^paperlength[ ]\{1,\}841890'] "$descfile"
then
PAGE=A4
- elif grep -q ['^papersize[ ]\+[aA]4'] "$descfile"
+ elif grep -q ['^papersize[ ]\{1,\}[aA]4'] "$descfile"
then
PAGE=A4
fi
@@ -986,7 +986,7 @@ AC_DEFUN([GROFF_PAGE], [
domains=
if test -r "$resolvconf"
then
- sedexpr='s/#.*//;s/[ \t]\+/ /;s/ \+$//;s/^ \+//;/^$/d;
+ sedexpr='s/#.*//;s/[ \t]\{1,\}/ /;s/ *$//;s/^ *//;/^$/d;
/^\(domain\|search\)/!d;s/\(domain\|search\) //;p'
domains=`sed -n "$sedexpr" "$resolvconf"`
fi
diff --git a/makevarescape.sed b/makevarescape.sed
index 2baa50c2d..a81f29a88 100644
--- a/makevarescape.sed
+++ b/makevarescape.sed
@@ -6,4 +6,4 @@ s/-/\\\\&/g
s/\^/\\\\[ha]/g
s/`/\\\\[ga]/g
s/~/\\\\[ti]/g
-s|[^ ]/\+|&\\\\:\\\\%|g
+s|[^ ]//*|&\\\\:\\\\%|g
diff --git a/src/libs/libgroff/make-uniuni b/src/libs/libgroff/make-uniuni
index 8d12d6104..c14ca170e 100755
--- a/src/libs/libgroff/make-uniuni
+++ b/src/libs/libgroff/make-uniuni
@@ -60,7 +60,7 @@ cat $$1 \
cat $$3 \
| sed -e '/#/d' \
-e '/^$/d' \
- -e 's/ \+/ /g' \
+ -e 's/ */ /g' \
-e 's/ *$//' \
-e 's/u//g' \
-e 's/^\([^ ]*\) /\1;/' > $$4
diff --git a/src/roff/groff/tests/html-device-smoke-test.sh
b/src/roff/groff/tests/html-device-smoke-test.sh
index cecafbe3a..8d2aad7fd 100755
--- a/src/roff/groff/tests/html-device-smoke-test.sh
+++ b/src/roff/groff/tests/html-device-smoke-test.sh
@@ -55,7 +55,7 @@ foobar
echo "checking production of inline image for tbl(1) table" >&2
output=$(echo "$input" | "$groff" -t -Thtml)
-echo "$output" | grep -q '<img src="grohtml-[0-9]\+-1.png"' || wail
+echo "$output" | grep -q '<img src="grohtml-[0-9]\{1,\}-1.png"' || wail
input='.EQ
x sup 2 + y sup 2 = z sup 2
@@ -63,7 +63,7 @@ x sup 2 + y sup 2 = z sup 2
echo "checking production of inline image for eqn(1) equation" >&2
output=$(echo "$input" | "$groff" -e -Thtml)
-echo "$output" | grep -q '<img src="grohtml-[0-9]\+-2.png"' || wail
+echo "$output" | grep -q '<img src="grohtml-[0-9]\{1,\}-2.png"' || wail
cleanup
diff --git a/src/utils/afmtodit/make-afmtodit-tables
b/src/utils/afmtodit/make-afmtodit-tables
index 38ab83c7e..6158f6726 100755
--- a/src/utils/afmtodit/make-afmtodit-tables
+++ b/src/utils/afmtodit/make-afmtodit-tables
@@ -74,7 +74,7 @@ cat $$1 \
cat $$3 \
| sed -e '/#/d' \
-e '/^$/d' \
- -e 's/ \+/ /g' \
+ -e 's/ */ /g' \
-e 's/ *$//' \
-e 's/u//g' \
-e 's/^\([^ ]*\) /\1;/' > $$4
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit