gbranden pushed a commit to branch master in repository groff. commit 24d4975ebe515a9e3530c738822603aeccb96cde Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Fri Jul 12 10:01:40 2024 -0500
[nroff]: Support argument clustering. * src/roff/nroff/nroff.sh: Support argument clustering by iterating over the argument list and declustering options that can be clustered (`-abCEikpRStUzZ`). * src/roff/nroff/tests/verbose_option_works.sh: Test it. * NEWS: Document it. Fixes <https://savannah.gnu.org/bugs/?64684>. --- ChangeLog | 14 ++++++++++++++ NEWS | 3 +++ src/roff/nroff/nroff.sh | 28 ++++++++++++++++++++++++++++ src/roff/nroff/tests/verbose_option_works.sh | 10 ++++++++++ 4 files changed, 55 insertions(+) diff --git a/ChangeLog b/ChangeLog index b1087bbe4..e2dc10c71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2024-07-12 G. Branden Robinson <g.branden.robin...@gmail.com> + + [nroff]: Support argument clustering. + + * src/roff/nroff/nroff.sh: Support argument clustering by + iterating over the argument list and declustering options that + can be clustered (`-abCEikpRStUzZ`). + + * src/roff/nroff/tests/verbose_option_works.sh: Test it. + + * NEWS: Document it. + + Fixes <https://savannah.gnu.org/bugs/?64684>. + 2024-07-11 G. Branden Robinson <g.branden.robin...@gmail.com> * src/roff/nroff/nroff.sh: Support groff `-a`, `-D`, `-I`, and diff --git a/NEWS b/NEWS index 956a56e97..37f194452 100644 --- a/NEWS +++ b/NEWS @@ -119,6 +119,9 @@ nroff o nroff now recognizes the -a, -D, -I, and -Z options and passes them through to groff. +o nroff now supports clustered options ("-tzms", for example) as groff, + troff, and other GNU getopt-using programs do. + Macro packages -------------- diff --git a/src/roff/nroff/nroff.sh b/src/roff/nroff/nroff.sh index c2469da75..143fa7053 100644 --- a/src/roff/nroff/nroff.sh +++ b/src/roff/nroff/nroff.sh @@ -41,6 +41,34 @@ summary=" Format documents with groff(1) for TTY (terminal) devices. See the nroff(1) manual page." +# Break up option clusters into separate arguments. +newargs= +for arg +do + thisarg=$arg + while : + do + case $thisarg in + -[abCEikpRStUzZ]) + newargs="$newargs $thisarg" + break + ;; + -[abCEikpRStUzZ]*) + remainder=${thisarg#??} + thisarg=${thisarg%%$remainder} + newargs="$newargs $thisarg" + thisarg=-$remainder + ;; + *) + newargs="$newargs $thisarg" + break + ;; + esac + done +done + +set -- $newargs + for arg do if [ -n "$is_option_argument_pending" ] diff --git a/src/roff/nroff/tests/verbose_option_works.sh b/src/roff/nroff/tests/verbose_option_works.sh index 8a2b3e38a..32faab8a3 100755 --- a/src/roff/nroff/tests/verbose_option_works.sh +++ b/src/roff/nroff/tests/verbose_option_works.sh @@ -84,6 +84,16 @@ nroff -V -d FOO=BAR 1 | sed "$sedexpr" nroff -V -d FOO=BAR 1 | sed "$sedexpr" \ | grep -qx "test-groff -Tascii -mtty-char -d FOO=BAR 1" || wail +echo "checking argument declustering: 'nroff -V -tz'" >&2 +nroff -V -tz | sed "$sedexpr" +nroff -V -tz | sed "$sedexpr" \ + | grep -qx "test-groff -Tascii -mtty-char -t -z" || wail + +echo "checking argument declustering: 'nroff -V -tzms'" >&2 +nroff -V -tzms | sed "$sedexpr" +nroff -V -tzms | sed "$sedexpr" \ + | grep -qx "test-groff -Tascii -mtty-char -t -z -ms" || wail + test -z "$fail" # vim:set ai et sw=4 ts=4 tw=72: _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit