All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lint-man.mk: Use a pipeline instead of the groff(1) wrapper
@ 2022-08-27 19:09 Alejandro Colomar
  2022-08-28  8:36 ` Ralph Corderoy
  0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar @ 2022-08-27 19:09 UTC (permalink / raw)
  To: linux-man; +Cc: Alejandro Colomar, Ralph Corderoy, G. Branden Robinson, groff

This more explicitly shows how stuff really works, and allows
inspecting some intermediate steps in case it may be necessary.

Cc: Ralph Corderoy <ralph@inputplus.co.uk>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: <groff@gnu.org>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---

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(-)

diff --git a/lib/lint-man.mk b/lib/lint-man.mk
index 63d86fe11..269240c3a 100644
--- a/lib/lint-man.mk
+++ b/lib/lint-man.mk
@@ -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 $@
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] lint-man.mk: Use a pipeline instead of the groff(1) wrapper
  2022-08-27 19:09 [PATCH] lint-man.mk: Use a pipeline instead of the groff(1) wrapper Alejandro Colomar
@ 2022-08-28  8:36 ` Ralph Corderoy
  2022-08-28 11:20   ` Alejandro Colomar
  0 siblings, 1 reply; 4+ messages in thread
From: Ralph Corderoy @ 2022-08-28  8:36 UTC (permalink / raw)
  To: groff; +Cc: linux-man

Hi Alejandro,

> +DEFAULT_EQNFLAGS := -Tutf8
...
> +DEFAULT_TROFFFLAGS   += -Tutf8

I'd have a variable set to ‘utf8’ to ease changing to another output
device.

> -	$(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
    $

-- 
Cheers, Ralph.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lint-man.mk: Use a pipeline instead of the groff(1) wrapper
  2022-08-28  8:36 ` Ralph Corderoy
@ 2022-08-28 11:20   ` Alejandro Colomar
  2022-08-28 11:53     ` Alejandro Colomar
  0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar @ 2022-08-28 11:20 UTC (permalink / raw)
  To: Ralph Corderoy, groff; +Cc: linux-man


[-- Attachment #1.1: Type: text/plain, Size: 2234 bytes --]

Hi Ralph,

On 8/28/22 10:36, Ralph Corderoy wrote:
> Hi Alejandro,
> 
>> +DEFAULT_EQNFLAGS := -Tutf8
> ...
>> +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?


> 
>> -	$(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
>      $
> 

Fixed too.

Cheers,

Alex
-- 
Alejandro Colomar
<http://www.alejandro-colomar.es/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lint-man.mk: Use a pipeline instead of the groff(1) wrapper
  2022-08-28 11:20   ` Alejandro Colomar
@ 2022-08-28 11:53     ` Alejandro Colomar
  0 siblings, 0 replies; 4+ messages in thread
From: Alejandro Colomar @ 2022-08-28 11:53 UTC (permalink / raw)
  To: Ralph Corderoy, groff; +Cc: linux-man


[-- Attachment #1.1: Type: text/plain, Size: 3335 bytes --]

Hi Ralph, Branden,

On 8/28/22 13:20, Alejandro Colomar wrote:
> Hi Ralph,
> 
> On 8/28/22 10:36, Ralph Corderoy wrote:
>> Hi Alejandro,
>>
>>> +DEFAULT_EQNFLAGS := -Tutf8
>> ...
>>> +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?

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

-- 
Alejandro Colomar
<http://www.alejandro-colomar.es/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-28 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-27 19:09 [PATCH] lint-man.mk: Use a pipeline instead of the groff(1) wrapper Alejandro Colomar
2022-08-28  8:36 ` Ralph Corderoy
2022-08-28 11:20   ` Alejandro Colomar
2022-08-28 11:53     ` Alejandro Colomar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.