URL: <https://savannah.gnu.org/bugs/?66434>
Summary: [troff] want `so` and related requests to accept
file names with embedded spaces
Group: GNU roff
Submitter: gbranden
Submitted: Tue 12 Nov 2024 03:22:01 PM UTC
Category: Core
Severity: 1 - Wish
Item Group: Feature change
Status: In Progress
Privacy: Public
Assigned to: gbranden
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Tue 12 Nov 2024 03:22:01 PM UTC By: G. Branden Robinson <gbranden>
It'd be nice if this worked.
$ cat ATTIC/foo.groff
foo
.so bar baz.groff
qux
$ cat ATTIC/bar\ baz.groff
bar baz
$ (cd ATTIC; groff -a -ww -T ascii foo.groff | cat -s)
troff:foo.groff:2: error: cannot open 'bar': No such file or directory
<beginning of page>
foo qux
But with this patch and a couple of prerequisite changes:
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 6ad2770eb..cba7ecc75 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6570,23 +6570,17 @@ static void while_continue_request()
void do_source(bool quietly)
{
- symbol nm = get_long_name(true /* required */);
- if (nm.is_null())
- skip_line();
- else {
- while (!tok.is_newline() && !tok.is_eof())
- tok.next();
- errno = 0;
- FILE *fp = include_search_path.open_file_cautious(nm.contents());
- if (fp)
- input_stack::push(new file_iterator(fp, nm.contents()));
- else
- // Suppress diagnostic only if we're operating quietly and it's an
- // expected problem.
- if (!(quietly && (ENOENT == errno)))
- error("cannot open '%1': %2", nm.contents(), strerror(errno));
- tok.next();
- }
+ char *filename = read_string();
+ errno = 0;
+ FILE *fp = include_search_path.open_file_cautious(filename);
+ if (fp != 0 /* nullptr */)
+ input_stack::push(new file_iterator(fp, filename));
+ else
+ // Suppress diagnostic only if we're operating quietly and it's an
+ // expected problem.
+ if (!(quietly && (ENOENT == errno)))
+ error("cannot open '%1': %2", filename, strerror(errno));
+ tok.next();
}
void source_request() // .so
@@ -8740,26 +8734,20 @@ static void process_startup_file(const char
*filename)
void do_macro_source(bool quietly)
{
- symbol nm = get_long_name(true /* required */);
- if (nm.is_null())
- skip_line();
- else {
- while (!tok.is_newline() && !tok.is_eof())
- tok.next();
- char *path;
- FILE *fp = mac_path->open_file(nm.contents(), &path);
- if (fp != 0 /* nullptr */) {
- input_stack::push(new file_iterator(fp, symbol(path).contents()));
- free(path);
- }
- else
- // Suppress diagnostic only if we're operating quietly and it's an
- // expected problem.
- if (!quietly && (ENOENT == errno))
- warning(WARN_FILE, "cannot open macro file '%1': %2",
- nm.contents(), strerror(errno));
- tok.next();
+ char *macro_filename = read_string();
+ char *path;
+ FILE *fp = mac_path->open_file(macro_filename, &path);
+ if (fp != 0 /* nullptr */) {
+ input_stack::push(new file_iterator(fp, macro_filename));
+ free(path);
}
+ else
+ // Suppress diagnostic only if we're operating quietly and it's an
+ // expected problem.
+ if (!quietly && (ENOENT == errno))
+ warning(WARN_FILE, "cannot open macro file '%1': %2",
+ macro_filename, strerror(errno));
+ tok.next();
}
void macro_source_request() // .mso
...it can.
$ (cd ATTIC; ../build/test-groff -a -ww -T ascii foo.groff | cat -s)
<beginning of page>
foo bar baz qux
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?66434>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
