This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: pointers are not permitted as case values
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Jack Howarth <howarth at bromo dot msbb dot uc dot edu>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 2 Oct 2002 11:47:12 -0400
- Subject: Re: pointers are not permitted as case values
- References: <200210021541.LAA13107@bromo.msbb.uc.edu>
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