Re: [PATCH] dir.c: avoid c99 array initialization
From: David Kågedal <hidden>
Date: 2016-06-15 22:45:14
Brandon Casey [off-list ref] writes:
The following syntax:
char foo[] = {
[0] = 1,
[7] = 2,
[15] = 3
};
is a c99 construct which some compilers do not support even though they
support other c99 constructs. Use an alternative.But the alternative is much worse. So how important is it to support non-C99 compilers?
quoted hunk ↗ jump to hunk
--- dir.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)diff --git a/dir.c b/dir.c index 29d1d5b..14d2eea 100644 --- a/dir.c +++ b/dir.c@@ -680,13 +680,14 @@ static int cmp_name(const void *p1, const void *p2) */ static int simple_length(const char *match) { - const char special[256] = { - [0] = 1, ['?'] = 1, - ['\\'] = 1, ['*'] = 1, - ['['] = 1 - }; + char special[256] = { 1, }; int len = -1; + special['?'] = 1; + special['\\'] = 1; + special['*'] = 1; + special['['] = 1; + for (;;) { unsigned char c = *match++; len++;
-- David Kågedal