gbranden pushed a commit to branch master
in repository groff.
commit b6032814bb8341fa14756f7de1df0f3590903acf
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Dec 27 19:22:13 2023 -0600
[troff]: Accept `hla` request without arguments.
[troff]: Add another explicit mechanism for disabling hyphenation;
accept an `hla` request without arguments for this purpose.
* src/roff/troff/env.cpp (select_hyphenation_language): Do it.
* doc/groff.texi (Manipulating Hyphenation):
* man/groff.7.man (Request short reference):
* man/groff_diff.7.man (New requests):
* NEWS: Document it.
* src/roff/groff/tests/hla-request-works.sh: Test it.
* src/roff/groff/groff.am (groff_TESTS): Run test.
Fixes https://savannah.gnu.org/bugs/?64958>.
---
ChangeLog | 18 ++++++++
NEWS | 3 ++
doc/groff.texi | 18 ++++----
man/groff.7.man | 5 +++
man/groff_diff.7.man | 6 ++-
src/roff/groff/groff.am | 1 +
src/roff/groff/tests/hla-request-works.sh | 72 +++++++++++++++++++++++++++++++
src/roff/troff/env.cpp | 5 +--
8 files changed, 115 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8ee79c0f2..88c94b70e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2023-12-27 G. Branden Robinson <[email protected]>
+
+ [troff]: Add another explicit mechanism for disabling
+ hyphenation; accept an `hla` request without arguments for this
+ purpose.
+
+ * src/roff/troff/env.cpp (select_hyphenation_language): Do it.
+
+ * doc/groff.texi (Manipulating Hyphenation):
+ * man/groff.7.man (Request short reference):
+ * man/groff_diff.7.man (New requests):
+ * NEWS: Document it.
+
+ * src/roff/groff/tests/hla-request-works.sh: Test it.
+ * src/roff/groff/groff.am (groff_TESTS): Run test.
+
+ Fixes https://savannah.gnu.org/bugs/?64958>.
+
2023-12-27 G. Branden Robinson <[email protected]>
* src/roff/groff/tests/dot-trap_register_works.sh: Fix thinko.
diff --git a/NEWS b/NEWS
index 57d7f6232..314388a4f 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,9 @@ o A new read-only, string-valued register, `.trap`,
interpolates the
o A new request, `phw`, reports to the standard error stream the current
list of hyphenation exceptions.
+o The `hla` request, when invoked with no arguments, now clears the
+ hyphenation language, disabling automatic hyphenation.
+
eqn
---
diff --git a/doc/groff.texi b/doc/groff.texi
index 91980b4a0..e2f8c8d5b 100644
--- a/doc/groff.texi
+++ b/doc/groff.texi
@@ -8950,24 +8950,26 @@ the hyphenation `kin-der'. The other two hyphenation
points
(`kin-der-g�r-ten') are missed.
@endDefreq
-@DefreqList {hla, lang}
+@DefreqList {hla, [@Var{lang}]}
@DefregListEndx {.hla}
@cindex @code{hpf} request, and hyphenation language
@cindex @code{hw} request, and hyphenation language
@pindex troffrc
@pindex troffrc-end
-Set the hyphenation language to @var{lang}. Hyphenation exceptions
-specified with the @code{hw} request and hyphenation patterns and
-exceptions specified with the @code{hpf} and @code{hpfa} requests are
-associated with the hyphenation language. The @code{hla} request is
-usually invoked by a localization file, which is turn loaded by the
-@file{troffrc} or @file{troffrc-end} file; see the @code{hpf} request
-above.
+Set the hyphenation language to @var{lang}, or clear it if there is no
+argument. Hyphenation exceptions specified with the @code{hw} request
+and hyphenation patterns and exceptions specified with the @code{hpf}
+and @code{hpfa} requests are associated with the hyphenation language.
+The @code{hla} request is usually invoked by a localization file, which
+is turn loaded by the @file{troffrc} or @file{troffrc-end} file; see the
+@code{hpf} request above.
@cindex hyphenation language register (@code{.hla})
The hyphenation language is available in the read-only string-valued
register @samp{.hla}; it is associated with the environment
(@pxref{Environments}).
+
+If no hyphenation language is set, automatic hyphenation will not occur.
@endDefreq
@DefreqList {hlm, [@Var{n}]}
diff --git a/man/groff.7.man b/man/groff.7.man
index 8eb049570..e962145ba 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -3308,6 +3308,11 @@ to
and so on.
.
.TPx
+.REQ .hla
+Clear the hyphenation language
+(disabling automatic hyphenation).
+.
+.TPx
.REQ .hla ident
Set the hyphenation language to
.IR ident .
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index 1f9484b82..5fea28d9d 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -2564,9 +2564,11 @@ corresponding hyphenation patterns contain them.
.
.
.TP
-.BI .hla\~ lang
+.BR .hla\~ [\c
+.IR lang ]
Set the hyphenation language to
-.IR lang .
+.IR lang ,
+or clear it if there is no argument.
.
Hyphenation exceptions specified with the
.B hw
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index 61c9451bd..782768c11 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -58,6 +58,7 @@ groff_TESTS = \
src/roff/groff/tests/evc_produces_no_output_if_invalid.sh \
src/roff/groff/tests/fp_should_not_traverse_directories.sh \
src/roff/groff/tests/handle_special_input_code_points.sh \
+ src/roff/groff/tests/hla-request-works.sh \
src/roff/groff/tests/html_works_with_grn_and_eqn.sh \
src/roff/groff/tests/initialization_is_quiet.sh \
src/roff/groff/tests/localization_works.sh \
diff --git a/src/roff/groff/tests/hla-request-works.sh
b/src/roff/groff/tests/hla-request-works.sh
new file mode 100755
index 000000000..037f00178
--- /dev/null
+++ b/src/roff/groff/tests/hla-request-works.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Copyright (C) 2023 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+ echo ...FAILED >&2
+ fail=yes
+}
+
+input='.ec @
+.ll 30n
+.tm before=@n[.hla]
+.de Madison
+Religious bondage shackles and debilitates the mind and unfits it for
+every noble enterprise.
+.br
+..
+.Madison
+.hla
+.tm after=@n[.hla]
+.Madison'
+
+ 1 Religious bondage shackles and
+ 2 debilitates the mind and un-
+ 3 fits it for every noble enter-
+ 4 prise.
+ 5 Religious bondage shackles and
+ 6 debilitates the mind and
+ 7 unfits it for every noble
+ 8 enterprise.
+
+error=$(printf "%s\n" "$input" | "$groff" -T ascii 2>&1 > /dev/null)
+echo "$error"
+
+output=$(printf "%s\n" "$input" | "$groff" -T ascii 2> /dev/null | nl)
+echo "$output"
+
+echo "checking initial language reported by .hla register" >&2
+echo "$error" | grep -Fqx 'before=en' || wail
+
+echo "checking that words get automatically hyphenated" >&2
+echo "$output" | grep -Eqx ' +2.*debilitates +the +mind +and +un-' \
+ || wail
+
+echo "checking final language reported by .hla register" >&2
+echo "$error" | grep -Fqx 'after=' || wail
+
+echo "checking that words don't get automatically hyphenated" >&2
+echo "$output" | grep -Eqx ' +6.*debilitates +the +mind +and' \
+ || wail
+
+test -z "$fail"
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index e229135c8..fdcb24b59 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3599,13 +3599,12 @@ struct hyphenation_language {
};
dictionary language_dictionary(5);
-hyphenation_language *current_language = 0;
+hyphenation_language *current_language = 0 /* nullptr */;
static void select_hyphenation_language()
{
if (!has_arg()) {
- warning(WARN_MISSING, "hyphenation language selection request"
- " expects argument");
+ current_language = 0 /* nullptr */;
skip_line();
return;
}
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit