summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-08-18 11:01:00 +0200
committerJim Meyering <meyering@redhat.com>2009-08-18 11:02:36 +0200
commitea57d4648226fc3d713a10448fc4fc012ccacdf5 (patch)
tree7c9bc1387ae54c0bdcf02fa201eaade47c2d9925
parenteca6a4a21a7ca15e4c2a5e6d99eae43ab0bae787 (diff)
downloadcoreutils-ea57d4648226fc3d713a10448fc4fc012ccacdf5.tar.xz
sort: use more portable initialization syntax
* src/sort.c (find_unit_order): Spell out 256-element static initializer, rather than relying on C99 syntax. Required for Forte Developer 7 C 5.4 2002/03/09 on Solaris 10. Reported by Bernhard Voelker.
-rw-r--r--src/sort.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/sort.c b/src/sort.c
index 62ddd4993..832be5a39 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1701,10 +1701,29 @@ check_mixed_SI_IEC (char prefix, struct keyfield *key)
static int
find_unit_order (const char *number, struct keyfield *key)
{
- static const char orders [UCHAR_LIM] = {
- ['K']=1, ['M']=2, ['G']=3, ['T']=4, ['P']=5, ['E']=6, ['Z']=7, ['Y']=8,
- ['k']=1,
- };
+ static const char orders [UCHAR_LIM] =
+ {
+#if SOME_DAY_WE_WILL_REQUIRE_C99
+ ['K']=1, ['M']=2, ['G']=3, ['T']=4, ['P']=5, ['E']=6, ['Z']=7, ['Y']=8,
+ ['k']=1,
+#else
+ /* Generate the following table with this command:
+ perl -e 'my %a=(k=>1, K=>1, M=>2, G=>3, T=>4, P=>5, E=>6, Z=>7, Y=>8);
+ foreach my $i (0..255) {my $c=chr($i); $a{$c} ||= 0;print "$a{$c}, "}'\
+ |fmt */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 3,
+ 0, 0, 0, 1, 0, 2, 0, 0, 5, 0, 0, 0, 4, 0, 0, 0, 0, 8, 7, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+#endif
+ };
const unsigned char *p = number;