groff
[Top][All Lists]
Advanced

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

Re: [Groff] Re: What's missing for Unicode support of groff?


From: Zvezdan Petkovic
Subject: Re: [Groff] Re: What's missing for Unicode support of groff?
Date: Sun, 11 Dec 2005 13:46:05 -0500
User-agent: Mutt/1.4.2i

Werner,

On Sun, Dec 11, 2005 at 08:05:59AM +0100, Werner LEMBERG wrote:
> This is interesting, since it looks like a problem with sed.  You are
> using BSD sed, right?  Please show us what the following expression
> yields:
> 
>   makeinfo --version | sed 's/^.* \([^ ]\+\)$/\1/;1q'

The problem is in the sed expression.
This is a GNU sed or even vim regular expression, but not a POSIX sed
regular expression.

You can read about BSD sed (which is a superset of POSIX sed) here:
http://www.openbsd.org/cgi-bin/man.cgi?query=sed
That will tell you that sed uses basic regular expressions (not extended
like egrep).
It will also point you in Sed Regular Expression section to
re_format(7) manual page
http://www.openbsd.org/cgi-bin/man.cgi?query=re_format
That page has in the section Basic Regular Expressions, first bullet,

   o   `|', `+', and `?' are ordinary characters and there is no equiva-
               lent for their functionality.

Thus your expression should have been (only \+ has been replaced
with \{1,\} below):

        's/^.* \([^ ]\{1,\}\)$/\1/;1q'

In fact, I'd rather use

        sed -e 's/^.* \([^ ]\{1,\}\)$/\1/' -e '1q'

it's more readable.

> 
> with GNU sed, I get `4.8'.  Then I have
> 
>   echo 4.8 | sed 's/^\([0-9]*\).*$/\1/'

This one is fine.

> 
>     ==> 4
> 
>   echo 4.8 | sed 's/^[^.]\+\(.*\)$/\1/'

This one needs to be changed into

        sed 's/^[^.]\{1,\}\(.*\)$/\1/'
> 
>     ==> .8
> 
>   echo .8 | sed 's/\.\([0-9]*\).*$/\1/'

This one is fine.

> 
>     ==> 8
> 
> The various sed expressions are there to handle various possible
> version info strings like `4', `4.8', or `4.8.1'.
> 
> Before applying your patch I want to know the reason for the failure,
> probably reporting it to both the BSD sed and autoconf people.  Maybe
> my original regexps are non-POSIX...

As somebody already mentioned there is no sed maintainer for BSD.
It's a part of a whole OS, that is maintained as a single CVS tree.
I suggest not to report it though.
I'm quite certain you'd get a reply that it won't be changed from what
POSIX suggests.
Changing the expressions as I suggested above is the easiest path to
take.
I hope this was helpful.

Best regards,

        Zvezdan Petkovic




reply via email to

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