Avoid undefined behavior when strcoll fails,
authorJim Meyering <jim@meyering.net>
Sun, 20 Jan 2002 20:44:49 +0000 (20:44 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 20 Jan 2002 20:44:49 +0000 (20:44 +0000)
commit72d40f6724f8e15cbbc7ddb0d70114e6fdd81e51
tree0be37031a7cdd558877b30edf5c1bc4da94d2d3e
parent99f7bd761fa83ae236a983899fff72d799b04a84
Avoid undefined behavior when strcoll fails,
by resorting the directory with strcmp instead.

Include <setjmp.h>.
Include "quote.h".
(compare_atime, rev_cmp_atime, compare_ctime, rev_cmp_ctime,
compare_mtime, rev_cmp_mtime, compare_size, rev_comp_size,
compare_name, rev_cmp_name, compare_extension, rev_cmp_extension,
compare_version, rev_compare_version): Move before use, so that
we can remove the forward declaration.  Reimplement in terms of
the new functions described below, using xstrcoll instead of strcoll.
(failed_strcoll): New var.
(xstrcoll): New function.
(V): New type.
(cmp_ctime, compstr_ctime, rev_str_ctime): New functions.
(cmp_mtime, compstr_mtime, rev_str_mtime): Likewise.
(cmp_atime, compstr_atime, rev_str_atime): Likewise.
(cmp_size, compstr_size, rev_str_size): Likewise.
(cmp_version): Likewise.
(cmp_name, compstr_name, rev_str_name): Likewise.
(cmp_extension, compstr_extension, rev_str_extension): Likewise.
(sort_files): Use prototype for internal function var.
If the strcoll-based comparison fails, fall back on a strcmp-based one.
src/ls.c