[LTP] [PATCH v2 1/7] docparse: Implement #define and #include
Cyril Hrubis
chrubis@suse.cz
Tue Nov 2 12:21:26 CET 2021
Hi!
> > +static void macro_get_string(FILE *f, char *buf, char *buf_end)
> > +{
> > + int c;
> > +
> > + for (;;) {
> > + c = fgetc(f);
> > +
> > + switch (c) {
> > + case '"':
>
> Luckily there are no instances of '#define MACRO "...\"...\"..."' in LTP
> AFAICT. Also there don't appear to be any '#define MACRO "..." \\n' that
> we would care about.
Well I can fix that and add a test to to be sure.
> > + case EOF:
> > + *buf = 0;
> > + return;
> > + default:
> > + if (buf < buf_end)
> > + *(buf++) = c;
> > + }
> > + }
> > +}
> > +
> > +static void macro_get_val(FILE *f, char *buf, size_t buf_len)
> > +{
> > + int c, prev = 0;
> > + char *buf_end = buf + buf_len - 1;
> > +
> > + c = fgetc(f);
> > + if (c == '"') {
>
> I guess this could be whitespace unless scanf slurps any trailing
> whitespace?
The scanf does not slurp any trainling whitespaces, so this should be
fixed by:
while (isspace(c = fgetc(f)));
With that we get slightly better output, so I will add that before
applying.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list