[fpc-pascal]absolute identifier

ron wilson ron.wilson at coastgames.com
Wed Apr 10 21:09:32 CEST 2002

how about for type casting?

    buf: array[1..255] of char;
    buflen: byte;
    str: ansistring;

should i setlength before typecasting?

ron wilson 

-----Original Message-----
From: fpc-pascal-admin at deadlock.et.tudelft.nl
[mailto:fpc-pascal-admin at deadlock.et.tudelft.nl]On Behalf Of Jonas Maebe
Sent: Wednesday, April 10, 2002 8:52 AM
To: fpc-pascal at deadlock.et.tudelft.nl
Subject: Re: [fpc-pascal]absolute identifier

On dinsdag, maart 26, 2002, at 04:43 , ron wilson wrote:

> so in my application, yyleng is referencing the length of the string,
> yytext, by using the absolute identifier.  i thought i could change all
> references to yyleng to length(yytext), but the lexer often assigns 
> yyleng
> manually (ugh!), e.g. yyleng:=n; OR inc(yyleng);.

You can use setlength(yytext,n) and setlength(yytext,length(yytext)+1) 
in those cases. But when you're using ansistrings, make sure you do 
those length adaptions *before* you write anything past the previous 
end-of-string, since otherwise you'll get segmentation faults.


fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org

More information about the fpc-pascal mailing list