groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [groff] 1.22.4.rc4 - Final RC before official 1.22.4


From: Ingo Schwarze
Subject: Re: [groff] 1.22.4.rc4 - Final RC before official 1.22.4
Date: Sat, 8 Dec 2018 19:17:59 +0100
User-agent: Mutt/1.8.0 (2017-02-23)

Hi Ralph,

Ralph Corderoy wrote on Sat, Dec 08, 2018 at 11:28:40AM +0000:
> Ingo:
>> Ralph:
>>> Ingo:
>>>> Ralph:

>>>>> The time-honoured way to get modern-day `printf foo' is
>>>>>     echo foo | tr -d \\012

>> Why would you want to return to echo(1)?
 
> Because I was giving the `time-honoured way' and I thought I saw a
> recent mention on this that if something still works on older systems
> then it's nice not to needlessly break it.

The printf(1) utility is already used in

 * Makefile.in (5 places)
 * bootstrap (8 places)
 * build-aux (10 places in multiple scripts)
 * configure (several places)

and so on, so i don't think there is any point in trying to avoid it.

In this case, changing from "echo -n" to "printf" is a minimal (and
canonical) fix, simpler than a pipeline, and possibly even more
portable nowadays - i'm not quite sure about the locale(1) implications
of "tr -d \\012", even though i have no doubt that it worked before
the advent of multi-byte locales (not sure about EBCDIC).

[...]
>>  .  pso sh -c \
>>         "printf '%s' '.ds *f ' ; \
>>          ls \\*[fontpath]/dev\*[.T] \
>> -        | tr '[:cntrl:]' '[ *32]'"
>> +        | tr '\\\\n' ' '"
>>  .  \"       This dummy line is necessary; the preceding line eats it.

> I've avoided trying to understand the aim until now.  Given zero or more
> files in a directory, the string `*f' should be set to their names?
> sed makes this easy.
> 
>     $ for n in {0..3}; do
>     >     (echo '.ds *f'; seq $n) |
>     >     sed '$!s/$/ \\/'
>     > done
>     .ds *f
>     .ds *f \
>     1
>     .ds *f \
>     1 \
>     2
>     .ds *f \
>     1 \
>     2 \
>     3
>     $
> 
> As a `.pso':
> 
>     $ cat ingo.tr
>     .pl 1
>     .nf
>     .ds fontpath /usr/share/groff/1.22.3/font
>     .pso (echo '.ds *f'; ls \*[fontpath]/dev\*[.T]) | sed '$!s/$/ \\\\/'
>     .tm *f=`\*(*f'
>     $
>     $ nroff -U ingo.tr
>     *f=`B BI DESC I R'
> 
>     $
> 
> Using `[:cntrl:]' to try and wipe out a `\n' in the name of portability
> to systems with unknown behaviour is misleading.  As the reader, I
> thought the aim was to wipe out any and all control characters.
> Puzzled, that's when I took the time to try and understand the aim.  :-)

The code quality of hdtbl is in general abysmal - so bad that i wonder
whether it was a mistake to include it.  So no doubt, you could spend
lots of time improving it, if you wanted to.

But that's not what i'm trying to do, in particular not five minutes
before release.  The point here is to fix bugs in a minimal way,
minimal in the sense of avoiding changes of behaviour and code that
are not required to fix bugs, in order to minimize the risk of
breaking stuff during the last five minutes.

You are probably right that weeding out other control characters is
not needed; that's my suspicion, too.  But i don't like general cleanup
work so shortly before release.

There is no indication that weeding out control characters breaks
anything, so all that needs fixing now is the now-portable usage
of tr(1).

Yours,
  Ingo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]