This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pointers are not permitted as case values


On Wed, Oct 02, 2002 at 11:41:55AM -0400, Jack Howarth wrote:
> Hello,
>     In rebuilding some srpms on ppclinux using gcc 3.2.1pre,
> I noticed that hfsplusutils no longer builds. For the
> 1.0.4-4 srpm of that package I now get...
> 
> gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../libhfsp/src    -O2 -Wall -c `test -f 'glob.c' || echo './'`glob.c
> glob.c: In function `strmatch':
> glob.c:51: pointers are not permitted as case values
> make[2]: *** [glob.o] Error 1
> 
> which matches the code...
> 
> static
> int strmatch(const char *str, const char *pat)
> {
>     while (1)
>     {
>         if (!*str && *pat && *pat != '*')
>             return 0; // no more string but still pattern
> 
>         switch (*pat)
>         {
>             case NULL:  // pattern at end
>                 return (!*str); // String at end ?
> 
>             case '*':  // match all
>                 if (*++pat == 0)
>                     return 1;
> 
> Does this have to be totally rewritten for gcc 3.2.1 or do
> we have a simple hack like doing a cast on the *pat in the
> switch statement so the compiler doesn't think it is dealing
> with a pointer?

*pat isn't the case value.  NULL is the case value.  It shouldn't be
NULL, it should be '\0'.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]