[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Wrong value on a type
From: |
Hans Aberg |
Subject: |
Re: Wrong value on a type |
Date: |
Sat, 3 Feb 2001 15:08:08 +0100 |
At 15:55 +0100 2001/01/23, Akim Demaille wrote:
>>... All that i did was change
>| /my_pattern/ { yylval = yytext; return STRING; }
>|
>| by the line
>|
>| /my_pattern/ { yylval = strdup (yytext); return STRING; }
>|
>| and the problem desapear!. But why do you say that this is not as perfect
>| as they could?
>
>Nope, for reasons similar to those given by Hans. I agree with him I
>don't remember having seen a written rule somewhere stating that
>yytext is null-terminated, but I never observed the converse. If you
>carefully read the Flex documentation, there are many samples that
>would break if the yytext was not 0-terminated (yet it shows how to
>use strdup), but I couldn't find any indication about it.
Actually, the code that Flex writes has a macro YY_DO_BEFORE_ACTION which
makes sure yytext is 0-terminated while the action is executed.
Hans Aberg
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Wrong value on a type,
Hans Aberg <=