[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: man(7), hyphen, and minus
From: |
Ralph Corderoy |
Subject: |
Re: man(7), hyphen, and minus |
Date: |
Tue, 27 Dec 2022 12:39:28 +0000 |
Hi Branden,
> > # Get a count of the number of lines before the first blank line, which
> > # we'll pass to .Vb as its parameter. This tells *roff to keep that
> > many
> > # lines together. We don't want to tell *roff to keep huge blocks
> > # together.
> > my @lines = split (m{ \n }xms, $text);
> > my $unbroken = 0;
> > for my $line (@lines) {
> > last if $line =~ m{ \A \s* \z }xms;
> > $unbroken++;
> > }
> > if ($unbroken > 12) {
> > $unbroken = 10;
> > }
...
> Well, you can throw away that line counting logic in Perl altogether
> and simply use `ne` _before_ EX (not EE).
I think the code is counting the number of lines in the first
‘paragraph’ although I find it misleading given it uses \A and \z with
//ms on a string which will only contain one line.
If that's its aim then it would be simpler to just count the number of
leading non-blank lines.
$ for s in '' $'\n' $'a\n' $'a\na\n' $'a\n\n' $'a\n\na\n'; do
> perl -n0777e '$n = () = /\G^.*\S.*\n/mg; print "$n\n"' <<<"$s"
> done
0
0
1
2
1
1
$
--
Cheers, Ralph.
- Re: man(7), hyphen, and minus, (continued)
Re: man(7), hyphen, and minus, Russ Allbery, 2022/12/23
- Re: man(7), hyphen, and minus, Richard Morse, 2022/12/23
- Re: man(7), hyphen, and minus, G. Branden Robinson, 2022/12/24
- Re: man(7), hyphen, and minus, Russ Allbery, 2022/12/24
- Re: man(7), hyphen, and minus, Nate Bargmann, 2022/12/24
- Re: man(7), hyphen, and minus, G. Branden Robinson, 2022/12/27
- Re: man(7), hyphen, and minus,
Ralph Corderoy <=
- Re: man(7), hyphen, and minus, Ingo Schwarze, 2022/12/29
Re: man(7), hyphen, and minus, Oliver Corff, 2022/12/24