On Mon, 17 Jan 2005, Sam Ravnborg wrote:
>
> I'm trying to implement the above 'logic' right now.
> The basis datastructure looks like this so far:
> 
> struct includepath {
>       int searchlocaldir;   /* =0 if -I- has been given */
>       struct path {
>               enum dirtype {
>                       systemdir,  /* defined here or by -isystemdir */
>                       userdir,    /* defined by -I */
>                       userlim,    /* limited to include "" (by -I-) */
>                       empty       /* skip, try next */

Do you really need to have a dirtype?

Why not just have the "system directories start here" pointer, and reverse 
the meaning of it (right now sparse puts them _first_ in the list, not 
last)? Then:

 - always put the "" paths first (put the "current .c directory" and "." 
   very first), make "angle_includepaths" point past them (replace 
   "gcc_includepath" with renamed "angle_includepath".

 - -I- removes the "current .c directory" entry, which is easy to test 
   for: it would be the first one, except if the first one is "."

   This means that "userlim" is not needed

 - "add_include" always checks whether it existed already, and does 
   nothing if it did (regardless of whether the thing is added to the end 
   or to the middle of the list).

   This means that "userdir" is not needed.

 - "-isystemdir" always adds to the end of the list (no need to mark them 
   "systemdir" either)

 - "-I" always adds to _before_ the "sys_includepath" marker.

Then at lookup you just do:

 - if it uses "", start at the beginning
 - if it uses <>, start at "angle_includepath"
 - if it uses "include_next", start at the previous include-path entry

so at least the lookup is always a total no-brainer, and has no special
cases at all, and all the special cases would be at "insert into path" 
time.

                Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to