[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fnmatch: rely on more gnulib modules
From: |
Bruno Haible |
Subject: |
Re: fnmatch: rely on more gnulib modules |
Date: |
Sun, 31 May 2020 02:14:56 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; ) |
Hi Paul,
> Oops, I found a problem when trying to use that patch with coreutils: fnmatch
> now depends on a module wmempcpy that does not exist, causing the bootstrap
> to fail.
Oops, you can bet that I tested this patch only on glibc systems. :-(
Working on it now...
> Come to think of it, coreutils etc. don't want to worry about thw wmem*
> functions at all, since they don't use any wide-character code. So fnmatch
> needs
> to be buildable without worrying about providing substitutes for wmempcpy etc.
> And this means the patch needs to be revisited.
But fnmatch needs to work with multibyte characters. When you write "A?Z"
the single character between A and Z may be any multibyte character. Nowadays
UTF-8 locales are very widespread.
fnmatch's implementation is that it converts the pattern and string to wchar_t*
representations (through mbsrtowcs); this is the most reasonable and appropriate
implementation for fnmatch.
You could devise a different implementation that works on the multibyte
representation all the time. It would call mbrtowc many many times and thus
be slower than the current fnmatch implementation.
Bruno