Re: [PATCH 7/8] a) Use strcoll() in opendir() and alphasort()
Corinna Vinschen <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
On Feb 1 07:55, Sebastian Huber wrote: > On 31/01/2019 14:05, Sebastian Huber wrote: > > From: ache <[email protected]> > > > > as POSIX 2008 requires. It also matches now how our 'ls' works for years. > > > > b) Remove comment expressed 2 fears: > > 1) One just simple describe how strcoll() works in _any_ context, > > not for directories only. Are we plan to remove strcoll() from everything > > just because it is little more complex than strcmp()? I doubt, and > > directories give nothing different here. Moreover, strcoll() used > > in 'ls' for years and nobody complaints yet. > > > > 2) Plain wrong statement about undefined strcoll() behaviour. strcoll() > > always gives predictable results, falling back to strcmp() on any > > trouble, see strcoll(3). > > > > No objections from -current list discussion. > > --- > > newlib/libc/posix/scandir.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/newlib/libc/posix/scandir.c b/newlib/libc/posix/scandir.c > > index 94c583761..13354c05e 100644 > > --- a/newlib/libc/posix/scandir.c > > +++ b/newlib/libc/posix/scandir.c > > @@ -142,12 +142,13 @@ fail: > > /* > > * Alphabetic order comparison routine for those who want it. > > + * POSIX 2008 requires that alphasort() uses strcoll(). > > */ > > int > > -alphasort (const struct dirent **d1, > > - const struct dirent **d2) > > +alphasort(const struct dirent **d1, const struct dirent **d2) > > { > > - return(strcmp((*d1)->d_name, (*d2)->d_name)); > > + > > + return (strcoll((*d1)->d_name, (*d2)->d_name)); > > } > > #endif /* ! HAVE_OPENDIR */ > > After looking into newlib/libc/string/strcoll.c, this patch makes no sense. > I will not apply it. I disagree. POSIX requires alpphasort to call strcoll, so this is clearly a bug in newlib's implementation. Also, what if, at one point, somebody improves newlib's strcoll? Cygwin's alphasort uses strcoll as well. I'm just not quite sure why Cygwin still has its own implementation. There's nothing Cygwin-specific in there, except for the strcmp/strcoll difference. I guess I'll remove it after the Cygwin 3.0 release. Corinna -- Corinna Vinschen Cygwin Maintainer Red Hat
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlxUDmAACgkQ9TYGna5E T6BPTw//fZCNwIYEn6vdJCcif4jLZ+l3WVCgdOjo6CbbaSwODOgszFGN2hDTGIO3 BVI3bG8Dz8bsutt+YeQk/Fn13lqQucTAyaeI6NR3Vc61m04GQy6eDJ3IRzO5ALl2 /rwCMAXIWL8n0hsyTTWiBYfvDGpOrjh1R+D+/lGBISkgsRRIbVLMqzMGbaFnTuM8 a9CnkkPEmPV6SNebN9Z+olM2T53e4uH7I/ub2DQOkFsRHsm8H7vNqP3SQftCO1b2 1SEjZ2P8ng1xp+T129PQCLFDpYR3YzsM5eIhmveKmqCZ4QRxIbx2h/2Uhc5YCioC ch+qG62CV4BWI4ns4zrg6ac2IXjy2HXEwB1COpDe0GknQ+mc9o4rHGhNKQYgmSma Mixcl0xWAV5DSV4Z5ZwSrPFtI3MGEcHNS6Yx+b2VgLRfm2ooHHlhR81UMXNBEDd6 pi9e1ZPLU13m2Xpe4HZgPGxZgCMO9yTRPyCouFzgMeWgUdsz6idWKkHeQrsg5OZn bREioPONnbqTrEJgZTWcmoZnIXyd4Zsmo98h2BumgT+MGCR8JHsGTorhtBh36oxj 5ec94Zn8I+E9uW6R5odMDFyRS1Q/Q4D6N1PqMsixip7OmhnNGgj1WVabDQVmHeEc J+zsDXsZko0I0xmmzjSHfjwGmJLKkqWeCEsKFkdTrMDD0GNjv2s= =xRqI -----END PGP SIGNATURE-----