lint-man.mk: Use a pipeline instead of the groff(1) wrapper
PATCH 1/1 lint-man.mk: Use a pipeline instead of the groff(1) wrapper
This more explicitly shows how stuff really works, and allows inspecting some intermediate steps in case it may be necessary.
---
Hi Ralph and Branden,
Would you recommend this change? Is it correct? It seems to work.
Cheers,
Alex
lib/lint-man.mk | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-)
lib/lint-man.mk +25 -13
@@ -16,20 +16,29 @@ include $(srcdir)/lib/src.mk TMACDIR := $(SYSCONFDIR)/groff/tmac +TBL := tbl + +DEFAULT_EQNFLAGS := -Tutf8 +EXTRA_EQNFLAGS := +EQNFLAGS := $(DEFAULT_EQNFLAGS) $(EXTRA_EQNFLAGS) +EQN := eqn + TMACFILES := $(shell $(FIND) $(TMACDIR) -not -type d | $(SORT)) TMACNAMES := $(basename $(notdir $(TMACFILES))) -GROFF_CHECKSTYLE_LVL := 3 -DEFAULT_GROFFFLAGS := -man -DEFAULT_GROFFFLAGS += -t -DEFAULT_GROFFFLAGS += -M $(TMACDIR) -DEFAULT_GROFFFLAGS += $(foreach x,$(TMACNAMES),-m $(x)) -DEFAULT_GROFFFLAGS += -rCHECKSTYLE=$(GROFF_CHECKSTYLE_LVL) -DEFAULT_GROFFFLAGS += -ww -DEFAULT_GROFFFLAGS += -Tutf8 -DEFAULT_GROFFFLAGS += -rLL=80n -EXTRA_GROFFFLAGS := -GROFFFLAGS := $(DEFAULT_GROFFFLAGS) $(EXTRA_GROFFFLAGS) -GROFF := groff +TROFF_CHECKSTYLE_LVL := 3 +DEFAULT_TROFFFLAGS := -man +DEFAULT_TROFFFLAGS += -t +DEFAULT_TROFFFLAGS += -M $(TMACDIR) +DEFAULT_TROFFFLAGS += $(foreach x,$(TMACNAMES),-m $(x)) +DEFAULT_TROFFFLAGS += -rCHECKSTYLE=$(TROFF_CHECKSTYLE_LVL) +DEFAULT_TROFFFLAGS += -ww +DEFAULT_TROFFFLAGS += -Tutf8 +DEFAULT_TROFFFLAGS += -rLL=80n +EXTRA_TROFFFLAGS := +TROFFFLAGS := $(DEFAULT_TROFFFLAGS) $(EXTRA_TROFFFLAGS) +TROFF := troff + +GROTTY := grotty DEFAULT_MANDOCFLAGS := -man DEFAULT_MANDOCFLAGS += -Tlint
@@ -48,7 +57,10 @@ lint_man := $(foreach x,$(linters_man),lint-man-$(x)) $(_LINT_man_groff): $(_LINTDIR)/%.lint-man.groff.touch: $(MANDIR)/% | $$(@D)/. $(info LINT (groff) $@) - $(GROFF) $(GROFFFLAGS) $< \ + $(TBL) <$< \ + | $(EQN) $(EQNFLAGS) \ + | $(TROFF) $(TROFFFLAGS) \ + | $(GROTTY) \ | sed 's/\x1b\[[^@-~]*[@-~]//g' \ | (! grep -n '.\{80\}.') touch $@
Signature · 1 line
2.37.2
Hi Alejandro,
Quoted 1 line
+DEFAULT_EQNFLAGS := -Tutf8
...
Quoted 1 line
+DEFAULT_TROFFFLAGS += -Tutf8
I'd have a variable set to ‘utf8’ to ease changing to another output device.
lib/lint-man.mk lint_man := $(foreach x,$(linters_man),lint-man-$(x)) · line 60
Quoted 2 lines
lib/lint-man.mk +1
-1- $(GROFF) $(GROFFFLAGS) $< \ + $(TBL) <$< \
You've ditched passing the filename, instead using standard input. This prevents the filename being passed through the pipeline which will presumably result in poorer messages.
$ tbl /etc/passwd | grep '^\.'
.if !\n(.g .ab GNU tbl requires GNU troff.
.if !dTS .ds TS
.if !dTE .ds TE
→ .lf 1 /etc/passwd
$Signature · 1 line
Cheers, Ralph.
Hi Ralph,
Quoted 8 lines · Ralph Corderoy
Hi Alejandro,
Quoted 1 line
+DEFAULT_EQNFLAGS := -Tutf8
...
Quoted 1 line
+DEFAULT_TROFFFLAGS += -Tutf8
I'd have a variable set to ‘utf8’ to ease changing to another output device.
Done; thanks! And as I said in another thread, I changed it back to ascii, since I noticed a problem with boxed tables (actually several).
I noticed another issue: for some reason, the boxed tables are being generated wider than the terminal, exactly by one char. If I specify -rLL=80, the right edge of the box is placed at column 81; if I specify LL to be 72, the right edge of the box is at col 73.
See the example below (I tweaked it to use 64 chars to overcome Thunderbird issues):
$ tbl man3/err.3 \
| eqn -Tascii \
| troff -man -t -M ./etc/groff/tmac -m checkstyle -rCHECKSTYLE=3 \
-ww -Tascii -rLL=64n \
| grotty -c \
| col -b -x \
| (! grep -n '.\{64\}.')
21: noreturn void verr(int eval, const char *fmt, va_list args);
22: noreturn void verrx(int eval, const char *fmt, va_list args);
51: +-----------------------+---------------+----------------+
52: |Interface | Attribute | Value |
53: +-----------------------+---------------+----------------+
54: |err(), errx(), warn(), | Thread safety | MT-Safe locale |
55: |warnx(), verr(), | | |
56: |verrx(), vwarn(), | | |
57: |vwarnx() | | |
58: +-----------------------+---------------+----------------+Do you know how I can fix that?
Quoted 8 lines
lib/lint-man.mk lint_man := $(foreach x,$(linters_man),lint-man-$(x)) · line 60
Quoted 3 lines
lib/lint-man.mk +1
-1- $(GROFF) $(GROFFFLAGS) $< \ + $(TBL) <$< \You've ditched passing the filename, instead using standard input. This prevents the filename being passed through the pipeline which will presumably result in poorer messages.
Quoted 7 lines
$ tbl /etc/passwd | grep '^\.'
.if !\n(.g .ab GNU tbl requires GNU troff.
.if !dTS .ds TS
.if !dTE .ds TE
→ .lf 1 /etc/passwd
$Fixed too.
Cheers,
Alex
Signature · 2 lines
Alejandro Colomar <http://www.alejandro-colomar.es/>
Hi Ralph, Branden,
Quoted 40 lines · Alejandro Colomar
Hi Ralph,
Quoted 8 lines · Ralph Corderoy
Hi Alejandro,
Quoted 1 line
+DEFAULT_EQNFLAGS := -Tutf8
...
Quoted 1 line
+DEFAULT_TROFFFLAGS += -Tutf8
I'd have a variable set to ‘utf8’ to ease changing to another output device.
Done; thanks! And as I said in another thread, I changed it back to ascii, since I noticed a problem with boxed tables (actually several).
I noticed another issue: for some reason, the boxed tables are being generated wider than the terminal, exactly by one char. If I specify -rLL=80, the right edge of the box is placed at column 81; if I specify
LL to be 72, the right edge of the box is at col 73.See the example below (I tweaked it to use 64 chars to overcome Thunderbird issues):
$ tbl man3/err.3 \ | eqn -Tascii \ | troff -man -t -M ./etc/groff/tmac -m checkstyle -rCHECKSTYLE=3 \ -ww -Tascii -rLL=64n \ | grotty -c \ | col -b -x \ | (! grep -n '.\{64\}.') 21: noreturn void verr(int eval, const char *fmt, va_list args); 22: noreturn void verrx(int eval, const char *fmt, va_list args); 51: +-----------------------+---------------+----------------+ 52: |Interface | Attribute | Value | 53: +-----------------------+---------------+----------------+ 54: |err(), errx(), warn(), | Thread safety | MT-Safe locale | 55: |warnx(), verr(), | | | 56: |verrx(), vwarn(), | | | 57: |vwarnx() | | | 58: +-----------------------+---------------+----------------+
Quoted 1 line
Do you know how I can fix that?
Hmmm, I've been testing things, and groff -rLL=78 behaves as MANWIDTH=80 man. That's weird. We come back to this 78 issue we didn't know exactly why it was there.
Searching through man-db's source code, it seems to confirm that subtraction:
alx@asus5775:~/src/cjwatson/man-db$ grepc get_line_length ./lib/linelength.h:23: int get_line_length (void);
./lib/linelength.c:49:
int get_line_length (void)
{
const char *columns;
int width;
#ifdef TIOCGWINSZ
int dev_tty, tty_fd = -1;#endif
if (line_length != -1)
return line_length;
line_length = 80;
columns = getenv ("MANWIDTH");
if (columns != NULL) {
width = atoi (columns);
if (width > 0)
return line_length = width;
}
[...]
}alx@asus5775:~/src/cjwatson/man-db$ grepc get_roff_line_length
./src/man.c:651:
static int get_roff_line_length (void)
{
int line_length = cat_width ? cat_width : get_line_length (); /* groff >= 1.18 defaults to 78. */
if ((!troff || ditroff) && line_length != 80) {
int length = line_length * 39 / 40;
if (length > line_length - 2)
return line_length - 2;
else
return length;
} else
return 0;
}Cheers,
Alex
Signature · 2 lines
Alejandro Colomar <http://www.alejandro-colomar.es/>