[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 11/35: [troff]: `hpf{,a}` now accept spacey file names.
From: |
G. Branden Robinson |
Subject: |
[groff] 11/35: [troff]: `hpf{,a}` now accept spacey file names. |
Date: |
Tue, 10 Dec 2024 16:35:33 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 28f6050d578d4ab4c2d76a8905cbb8e22febef02
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Dec 7 09:58:15 2024 -0600
[troff]: `hpf{,a}` now accept spacey file names.
The `hpf` and `hpfa` requests now accept leading and embedded spaces in
their "file" arguments, just like `so`.
* src/roff/troff/input.cpp (read_hyphenation_patterns_from_file): Gather
the argument with `read_string()` (which reads a potentially spaceful
argument including a discardable leading double quote), not
`get_long_name()` (which reads a GNU troff identifier). Call
`tok.next()` afterwards.
(load_hyphenation_patterns_from_file)
(append_hyphenation_patterns_from_file): "Peek" at the input stream
when checking for arguments to avoid advancing the input stream
pointer past the first character in the `hpf` or `hpfa` request
argument. Annotate why we do not call `skip_next()` at the end of the
request handler, as most do.
* doc/groff.texi.in (Manipulating Hyphenation):
* man/groff.7.man (Request short reference):
* man/groff_diff.7.man (New requests): Document it.
* NEWS: Update existing items.
---
ChangeLog | 24 ++++++++++++++++++++++++
NEWS | 9 +++++----
doc/groff.texi.in | 4 ++--
man/groff.7.man | 8 ++++----
man/groff_diff.7.man | 6 ++++--
src/roff/troff/env.cpp | 20 +++++++++++---------
6 files changed, 50 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1571008b8..f00413fec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2024-12-07 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: The `hpf` and `hpfa` requests now accept leading and
+ embedded spaces in their "file" arguments, just like `so`.
+
+ * src/roff/troff/input.cpp
+ (read_hyphenation_patterns_from_file): Gather the argument with
+ `read_string()` (which reads a potentially spaceful argument
+ including a discardable leading double quote), not
+ `get_long_name()` (which reads a GNU troff identifier). Call
+ `tok.next()` afterwards.
+ (load_hyphenation_patterns_from_file)
+ (append_hyphenation_patterns_from_file): "Peek" at the input
+ stream when checking for arguments to avoid advancing the input
+ stream pointer past the first character in the `hpf` or `hpfa`
+ request argument. Annotate why we do not call `skip_next()` at
+ the end of the request handler, as most do.
+
+ * doc/groff.texi.in (Manipulating Hyphenation):
+ * man/groff.7.man (Request short reference):
+ * man/groff_diff.7.man (New requests): Document it.
+
+ * NEWS: Update existing items.
+
2024-12-07 G. Branden Robinson <g.branden.robinson@gmail.com>
[troff]: The `cf` and `trf` requests now accept leading and
diff --git a/NEWS b/NEWS
index 9004c1cec..d89d7c7a7 100644
--- a/NEWS
+++ b/NEWS
@@ -57,12 +57,13 @@ troff
warning diagnostic in the "range" category.
* GNU troff now strips a leading neutral double quote from the argument
- to the `cf`, `mso`, `msoquiet`, `pi`, `pso`, `so`, `soquiet`, `sy`,
- and `trf` requests, allowing it to contain embedded leading spaces.
+ to the `cf`, `hpf`, `hpfa`, `mso`, `msoquiet`, `pi`, `pso`, `so`,
+ `soquiet`, `sy`, and `trf` requests, allowing it to contain embedded
+ leading spaces.
* GNU troff now accepts space characters in the argument to the `cf`,
- `mso`, `msoquiet`, `so`, `soquiet`, `trf` requests. See "soelim"
- below.
+ `hpf`, `hpfa`, `mso`, `msoquiet`, `so`, `soquiet`, `trf` requests.
+ See "soelim" below.
* The "el" warning category has been withdrawn. If enabled (which it
was not by default), the formatter would emit a diagnostic if it
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index 17b7c8196..713e19570 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -8869,8 +8869,8 @@ register @samp{.hydefault}; it is associated with the
environment
@endDefreq
@need 200
-@DefreqList {hpf, pattern-file}
-@DefreqListEndx {hpfa, pattern-file}
+@DefreqList {hpf, [@code{"}]@Var{pattern-file}}
+@DefreqListEndx {hpfa, [@code{"}]@Var{pattern-file}}
@cindex hyphenation patterns (@code{hpf})
@cindex patterns for hyphenation (@code{hpf})
Read hyphenation patterns from @var{pattern-file}, which is sought
diff --git a/man/groff.7.man b/man/groff.7.man
index 5c6753a70..1b57acdc8 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -3417,14 +3417,14 @@ Set the consecutive automatically hyphenated line limit
to
A negative value means \[lq]no limit\[rq].
.
.TPx
-.REQ .hpf pattern-file
+.REQ .hpf file
Read hyphenation patterns from
-.IR pattern-file .
+.IR file .
.
.TPx
-.REQ .hpfa pattern-file
+.REQ .hpfa file
Append hyphenation patterns from
-.IR pattern-file .
+.IR file .
.
.TPx
.REQ .hpfcode "a b \fR[\fPc d\fR] .\|.\|.\fP"
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index 211eb2ad1..cb153bb7e 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -2767,7 +2767,8 @@ explicit hyphens are not.
.
.
.TP
-.BI .hpf\~ pattern-file
+.BR .hpf\~ [ \[dq] ]\c
+.I pattern-file
Read hyphenation patterns from
.IR pattern-file .
.
@@ -2930,7 +2931,8 @@ won't automatically hyphenate at all.
.
.
.TP
-.BI .hpfa\~ pattern-file
+.BR .hpfa\~ [ \[dq] ]\c
+.I pattern-file
As
.BR hpf ,
except that the hyphenation patterns and exceptions from
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 1f6ceae2a..e23d67b1b 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -4520,39 +4520,41 @@ void hyphenate(hyphen_list *h, unsigned flags)
static void read_hyphenation_patterns_from_file(bool append)
{
- // TODO: Read a file name, not a groff identifier.
- symbol name = get_long_name(true /* required */);
- if (!name.is_null()) {
+ char *filename = read_string();
+ if (filename != 0 /* nullptr */) {
if (0 /* nullptr */ == current_language)
error("no current hyphenation language");
else
- current_language->patterns.read_patterns_file(
- name.contents(), append,
- ¤t_language->exceptions);
+ current_language->patterns.read_patterns_file(filename, append,
+ ¤t_language->exceptions);
}
- skip_line();
+ tok.next();
}
static void load_hyphenation_patterns_from_file()
{
- if (!has_arg()) {
+ if (!has_arg(true /* peek */)) {
warning(WARN_MISSING, "hyphenation pattern load request expects"
" argument");
skip_line();
return;
}
read_hyphenation_patterns_from_file(false /* append */);
+ // No `skip_line()` here; the above function calls `read_string()` and
+ // `tok.next()`.
}
static void append_hyphenation_patterns_from_file()
{
- if (!has_arg()) {
+ if (!has_arg(true /* peek */)) {
warning(WARN_MISSING, "hyphenation pattern appendment request"
" expects argument");
skip_line();
return;
}
read_hyphenation_patterns_from_file(true /* append */);
+ // No `skip_line()` here; the above function calls `read_string()` and
+ // `tok.next()`.
}
// Most hyphenation functionality is environment-specific; see
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 11/35: [troff]: `hpf{,a}` now accept spacey file names.,
G. Branden Robinson <=