commit bash-20191219 snapshot

This commit is contained in:
Chet Ramey
2020-01-02 10:27:49 -05:00
parent 3a7c642e22
commit 9420622819
14 changed files with 188 additions and 19 deletions
+28 -2
View File
@@ -156,6 +156,28 @@ strvec_copy (array)
return (ret);
}
/* Comparison routine for use by qsort that conforms to the new Posix
requirements (http://austingroupbugs.net/view.php?id=1070).
Perform a bytewise comparison if *S1 and *S2 collate equally. */
int
strvec_posixcmp (s1, s2)
register char **s1, **s2;
{
int result;
#if defined (HAVE_STRCOLL)
result = strcoll (*s1, *s2);
if (result != 0)
return result;
#endif
if ((result = **s1 - **s2) == 0)
result = strcmp (*s1, *s2);
return (result);
}
/* Comparison routine for use with qsort() on arrays of strings. Uses
strcoll(3) if available, otherwise it uses strcmp(3). */
int
@@ -176,10 +198,14 @@ strvec_strcmp (s1, s2)
/* Sort ARRAY, a null terminated array of pointers to strings. */
void
strvec_sort (array)
strvec_sort (array, posix)
char **array;
int posix;
{
qsort (array, strvec_len (array), sizeof (char *), (QSFUNC *)strvec_strcmp);
if (posix)
qsort (array, strvec_len (array), sizeof (char *), (QSFUNC *)strvec_posixcmp);
else
qsort (array, strvec_len (array), sizeof (char *), (QSFUNC *)strvec_strcmp);
}
/* Cons up a new array of words. The words are taken from LIST,