On Thu, 2008-04-17 at 05:49 -0700, Mark Glines via RT wrote:
> It looks like this is a parsing bug, caused by some weird stuff in one
> of my header files.  The top of my /usr/include/GL/gl_mangle.h looks
> like this:
> 
> #if 0
> #define GL_MANGLE_C1 "DO NOT EDIT!!! - TO REGENERATE from gl.h, EXECUTE
> THIS FILE IN SHELL (/bin/sh) and save the output"
> #define GL_MANGLE_C2 "This file is used to create GL function protypes
> and aliases for the function names"
>         files="gl.h glext.h"
> #define GL_MANGLE_C3 "get regeneration header - copy everything in this
> file above the 'REGENERATE_TO_END' line"
>         awk     '!done; /^\/\*REGENERATE_TO_END/ {done=1}' $0
>         echo ""
> #define GL_MANGLE_C4 get aliases
>         grep '^GLAPI' $files | sed -e 's/.*ENTRY gl\([^( ]*\).*$/#define
> gl\1           MANGLE(\1)/' | sort | uniq
>         echo ""
>         echo "#endif /* GL_MANGLE_H */"
>         exit
> #endif /* REGENERATION */

Oh man, that's just nasty.  What the heck was that coder thinking?!?
Clearly the problem is too much exposure to sed and awk.  :-)

I was hoping to not have to try to parse that kind of mess correctly,
but it looks like I've got three options:

  1. Parse the headers for real, instead of the current "80% solution".
  2. Special case '#if 0 ... #endif'.
  3. Parse the define *values*, and toss any that don't look right.

I'm thinking #3, since it's probably best to have that safety check
anyway, and it's probably the easiest.  I'll work on that one.

> Pretty, huh.

Oh yeah.  Nice catch, thank you!


-'f


Reply via email to