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

Re: range of characters in regexp in locale aware environment (Re: Bug#281368: sed: regexes fail on et_EE.UTF-8 locale)



On Tue, Nov 16, 2004 at 12:31:19PM +0900, Fumitoshi UKAI wrote:
> At Mon, 15 Nov 2004 14:58:37 +0200,
> Marko Kreen wrote:
> > # regex from configure:
> >   echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'

> In et_EE locale, collate order would be:
>  a b c d e f g h i j k l m n o p q r s z t u v w x y
> according to LC_COLLATE in /usr/share/i18n/locales/et_EE.
> 
> So, "[a-z]" will be "[abcdefghijklmnopqrsz]", and it won't match with any of
> 't' 'u' 'v' 'w' 'x' 'y',  because these are out of range of a-z.
> 
> This is why "[-_a-zA-Z0-9]*=" will matches "ild=" of "--build=i386-linux"
> (note that 'u' is out of range of the "[-_a-zA-Z0-9]") and the result becomes
> "--bui386-linux" ("ild="=>"" by 's/[-_a-zA-Z0-9]*=//', so 
> "--bu" + "i386-linux" is the result).
> 
> In this case, correct regexp whould be
>  s/[-_[:alpha:][:digit:]]*=//
> 
> If you think this collate order is a bug, you should claim this 
> against locales package.

AFAIR the collate order is right.  And now I think about it,
that means et_EE.iso-8859-1 will fail too...

You said "many users misunderstand range of characters machtes"
but the regex is from autoconf code - should use of a-z be
reported as bug in package or should users in weird locales
expect such failures?

At least I set root locale to en_US ...

-- 
marko



Reply to: