From: David Kågedal Date: Thu, 28 Aug 2008 15:32:07 GMT Subject: Re: [PATCH] dir.c: avoid c99 array initialization Message-ID: <871w09kvew.fsf@lysator.liu.se> In-Reply-To: Brandon Casey 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? > --- > 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