[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] [PATCH] pp should interpret #num as #line num

From: Sergey Korshunoff
Subject: Re: [Tinycc-devel] [PATCH] pp should interpret #num as #line num
Date: Wed, 7 Jan 2015 06:01:49 +0300

Using a strtoul with TOK_PPNUM to convert string to number is a
standard method in tcc. And strtoul() is much shorter and faster then
parse_number(). parse_number deal with floats and long long integers
and ... And there is no need to declare any function or move it.

2015-01-07 1:26 GMT+03:00, Thomas Preud'homme <address@hidden>:
> Le mardi 6 janvier 2015, 12:52:06 Sergey Korshunoff a écrit :
>> v2 of the patch, which uses strtoul() insteed of the parse_number()
> As I said, I was just looking for some explanation about why the
> parse_number
> was necessary. The reason is that when dealing with TOK_LINE, next() is
> called. next() will call next_nomacro() and then execute this piece of
> code:
>     /* convert preprocessor tokens into C tokens */
>     if (tok == TOK_PPNUM &&
>         (parse_flags & PARSE_FLAG_TOK_NUM)) {
>         parse_number((char *)tokc.cstr->data);
>     }
> And at the top of the function preprocess that deal with TOK_LINE:
> So yeah, the next token after TOK_LINE becomes a number and can be found in
> tokc.i. If dealing with a #N macro, it would be a TOK_PPNUM and you'd need
> to
> use parse_number to turn it into a normal number.
> Therefore the approach in your first patch was perfectly fine. One thing
> though:
> could you rather move parse_number just before preprocess rather than
> predeclare it? Unless there is a reason for it to be at this place in the
> file
> in which case you can at least move the prototype declaration close the
> next_nomacro_spc () one.
> Thanks for your patch.
> Best regards,
> Thomas

reply via email to

[Prev in Thread] Current Thread [Next in Thread]