sed-devel
[Top][All Lists]
Advanced

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

Re: sed 4.7 little behaviour change on regexp interval


From: Lorenzo Gaggini
Subject: Re: sed 4.7 little behaviour change on regexp interval
Date: Tue, 8 Jan 2019 09:11:00 +0000

On dom 06/01/19, 23:50, Assaf Gordon wrote:
> Hello,

Hello and thank your for your reply.


> there are actually few issues here:
> 
> First,
> which regex implementation is being used?
> It might sound like a silly question, but in fact there are at least two
> 'competing' implementations:
> either your system's native glibc implementation (and then glibc
> versions have slight differences), or the internal regex implementation
> that comes bundled with sed and grep (and awk etc.).
> That's why just saying "grep 3.3" is not sufficient,
> and similarly "sed 4.5" and "sed 4.7" are not - it depends on whether
> they used the internal (gnulib) regex implementati
> I suspect that if you built both sed 4.5 and 4.7 using
> "--with-included-regex" you'll get the "Invalid range end" error in both
> versions.
> 

You're right, grep 3.3 was built using "--without-included-regex".

Using the same flag also on the sed 4.7 build I don't have the
"Invalid range end" error.

I can't do test on the sed 4.5 build now but I suspect that
it didn't give me error because it was built using the
"--without-included-regex" flag too.


> Second,
> The issue here is that character "a" (ASCII 97) is larger than
> "Z" (ASCII 90) - the start is larger than the end.
> 
> The current internal gnulib regex implementation forbids ranges such as
> '[a-Z]'. I believe the most recent glibc behaves the same.

I didn't check the ASCII value of the range but it makes sense, "a" is
larger than "Z".


> 
> The problem is compounded by locales - basically,
> in any locale except POSIX/C, ranges are poorly defined.
> 
> In short, if you use ranges, use LC_ALL=C.
> Otherwise, using '[[:alpha:]]' is recommended.
> 

I agree, I rewrite my script using the '[[:alpha:]]' class.


> Hope this helps,
> 

Sure, very informative, thank you.

Regards.

-- 
Lorenzo Gaggini 
Register.it / Dada.eu
Gnu/Linux Sysadmin
Email: address@hidden

reply via email to

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