help-flex
[Top][All Lists]
Advanced

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

Re: YYText related problem in flex++


From: John W. Millaway
Subject: Re: YYText related problem in flex++
Date: Wed, 2 Jan 2002 13:53:51 -0800 (PST)

> I am using Flex++ to scan from a stream buffer.I have a structure with char
> pointers. 
> when a token is matched, i point these char pointers to YYText(), assign a
> null char
> to the last delimiter char. This way i avoid any strcpy or malloc.
> This works almost correctly, except for the first token. When i try to
> access the first token's
> value this way, null char is returned.
> If someone could answer this question i would be thankful

I'm surprised this works at all. You simply have to strdup() yytext if you want
to reliably preserve tokens. Internally, flex null-terminates yytext, but
*saves* the character before writing the null byte. The single saved character
is restored on the next call to yylex().



__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com



reply via email to

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