I'd like to suggest the attached diff. What removing this code would do is make the `mso` request no longer look for "tmac.s" if "s.tmac" is specified as the request's argument, and vice versa.
Here's my case against. 1. It's needless complexity. 2. The main things you'd need this for are full-service traditional macro package names on AT&T troff environments, where they're (sometimes) named "tmac.s", "tmac.an", and so forth. 2a. Except not all AT&T troff environments name them that way. DWB 3.3 troff, for instance stores them without "tmac" in the name at all. $ ls ~/dwb/lib/macros an color csmacros mmn mmt pictures ptx safe strings.mm v view 2b. Usually, full-service macro packages are loaded via the command line with the `-m` option, which is still supported, and does the foregoing aggressive search. 3. The `mso` request itself is not portable, but a groff extension. So this feature is not applicable to the use case of trying to format a read-only legacy *roff document with groff. 4. If you wanted to hack on a legacy *roff document and use this feature to load a macro file from the "macro path", you could equivalently do this. .mso s.tmac .mso tmac.s 5. But, you may point out, that will probably throw at least one warning, for whichever of these files isn't present on the system. That's harmless, but... 6. As of groff 1.23.0, you can do this. .msoquiet s.tmac .msoquiet tmac.s ...which won't throw any diagnostics about missing files. I therefore think this code has outlived whatever utility it had. N.B., I have zero intention of killing `mso` altogether, just this weird feature whereupon failing to open the specified file name, it rewrites its argument to go looking for a _different_ file name. Comments? Regards, Branden
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index 6735b845c..4b157dfe1 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -8133,31 +8133,6 @@ void do_macro_source(bool quietly) tok.next(); char *path; FILE *fp = mac_path->open_file(nm.contents(), &path); - // .mso cannot go through open_mac_file, which handles the -m option - // and expects only an identifier like "s" or "an", not a file name. - // We need to do it here manually: If we have tmac.FOOBAR, try - // FOOBAR.tmac and vice versa. - if (!fp) { - const char *fn = nm.contents(); - size_t fnlen = strlen(fn); - if (strncasecmp(fn, MACRO_PREFIX, sizeof(MACRO_PREFIX) - 1) == 0) { - char *s = new char[fnlen + sizeof(MACRO_POSTFIX)]; - strcpy(s, fn + sizeof(MACRO_PREFIX) - 1); - strcat(s, MACRO_POSTFIX); - fp = mac_path->open_file(s, &path); - delete[] s; - } - if (!fp) { - if (strncasecmp(fn + fnlen - sizeof(MACRO_POSTFIX) + 1, - MACRO_POSTFIX, sizeof(MACRO_POSTFIX) - 1) == 0) { - char *s = new char[fnlen + sizeof(MACRO_PREFIX)]; - strcpy(s, MACRO_PREFIX); - strncat(s, fn, fnlen - sizeof(MACRO_POSTFIX) + 1); - fp = mac_path->open_file(s, &path); - delete[] s; - } - } - } if (fp) { input_stack::push(new file_iterator(fp, symbol(path).contents())); free(path);
signature.asc
Description: PGP signature