cpplib bugfixes

Dave Brolley brolley@cygnus.com
Sun Feb 28 18:15:00 GMT 1999


Zack Weinberg wrote:

> This patch eliminates the remaining testsuite regressions for
> --enable-c-cpplib versus the default configuration.  --enable-cpplib
> may still have problems with line numbering, I'm not sure.
>
> Bugs fixed are:
> - do_line could corrupt the include hash table and/or attempt to free
> non-malloced memory.  I'd appreciate someone reviewing the logic in
> do_line, I'm not sure it's correct even now.

I looked at it, most closely at the logic for deciding whether to free
ip->last_nominal_fname. It seems safe enough and although I'm not
convinced that it could be equal to each of the pointers tested, I'm also
not convinced that it could not be either. Better safe than sorry.

The patch looks OK to me.

Dave

>
>
> - cpp_get_token would segfault if called after CPP_EOF was returned.
>
> - The wrapper macros in c-lex.c and c-common.c would attempt to push
> back EOF, leading to parse errors.
>
> Unlike the previous patch for these bugs, this one doesn't have a
> performance problem.
>
> zw
>
> 1999-02-11 09:46 -0500  Zack Weinberg  <zack@rabi.columbia.edu>
>
>         * c-common.c (UNGETC [USE_CPPLIB=1]): Do nothing if c is EOF.
>         * c-lex.c: Likewise.
>         * cpplib.c (cpp_push_buffer, cpp_pop_buffer): Use a linked
>         list in malloced memory for the buffer stack.
>         (cpp_get_token): Don't pop the last buffer off the stack.
>         Calls after CPP_EOF has been returned produce CPP_EOF with no
>         state change.
>         (cpp_finish): Pop last buffer here.
>         (do_line): Don't free ip->last_nominal_fname if it is equal to
>         ip->fname.
>         * cpplib.h (struct cpp_buffer): Remove unused fields, add prev
>         buffer pointer.
>         (struct cpp_reader): Remove buffer_stack.  Add
>         buffer_stack_depth.
>         (CPP_PREV_BUFFER, CPP_NULL_BUFFER): Buffer stack is now a
>         linked list.






More information about the Gcc-patches mailing list