deterministic order for include by wildcard
Henrique de Moraes Holschuh
hmh at hmh.eng.br
Mon Dec 28 23:42:19 CET 2015
On Mon, 28 Dec 2015, Ondrej Zajicek wrote:
> Results are alphabetically sorted. The wildcard expansion is implemented
> by standard glob() libc function, and unfortunately both Single UNIX
> specification and GNU C library documentation are lacking details about
> that. I would expect that it is a plain ASCII, non-localized alphabetic sort.
In glibc, glob() is locale-aware and it will use the locale's collating
order.
Refer to glibc source, posix/glob.c, around line 1247:
1247 if (!(flags & GLOB_NOSORT))
1248 {
1249 /* Sort the vector. */
1250 qsort (&pglob->gl_pathv[oldcount],
1251 pglob->gl_pathc + pglob->gl_offs - oldcount,
1252 sizeof (char *), collated_compare);
1253 }
...
1288 static int
1289 collated_compare (const void *a, const void *b)
1290 {
1291 const char *const s1 = *(const char *const * const) a;
1292 const char *const s2 = *(const char *const * const) b;
1293
1294 if (s1 == s2)
1295 return 0;
1296 if (s1 == NULL)
1297 return 1;
1298 if (s2 == NULL)
1299 return -1;
1300 return strcoll (s1, s2);
1301 }
That said, glibc will default the entire program to the C locale (or maybe
C.UTF-8 nowadays), unless setlocale() has been called.
If you are working in an unknown locale, though (e.g. setlocale() was called
to set the process locale to the system's locale), do *NOT* assume the
sorting will look like what you'd get out of ASCII.
> Not really. There is a bug tracker as a part of gitlab package used for
> BIRD, but it is not much used. I generally prefer bugs and requests to be
> are discussed on the mailing list. But for trivial fixes and subsequent
> progress tracking using bug tracker makes sense, so perhaps we could
> start to use it.
IME, you will find that without a bug tracker you will eventually have bug
reports falling through the cracks, and that "some things that should not
have been forgotten were lost."
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
More information about the Bird-users
mailing list