Re: [fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-17 Thread Jorge Aldo G. de F. Junior
security rule #1 : never assume anything... 2010/3/7 lyh1 lyh1...@hotmail.com: But ShortStrings also store the length in string[0]. If I do a append, I think the string will append to string[1] So don't assume string are always initialized with null string? Message: 5 Date: Sun, 7 Mar

Re: [fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-07 Thread lyh1
But ShortStrings also store the length in string[0]. If I do a append, I think the string will append to string[1] So don't assume string are always initialized with null string? Message: 5 Date: Sun, 7 Mar 2010 00:17:03 +0100 From: Mattias Gaertner nc-gaert...@netcologne.de Subject: Re:

[fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-06 Thread lyh1
I have a a program that will read a string and parse the string to some sub-strings in sub routine. I add every character to a local string buffer in sub routine. The code work well in delphi but suddenly fail in fpc. When I watch the buffer, it display some garbage instead of null string when

Re: [fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-06 Thread Jonas Maebe
On 06 Mar 2010, at 21:13, lyh1 wrote: My question is we should always assign null string to variable before use or this a bug if I get garbage in unused string? If you want Delphi-compatible behaviour, you must add {$mode delphi} at the top of your program. In the default mode, string is an

Re: [fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-06 Thread Jonas Maebe
On 06 Mar 2010, at 22:03, Juha Manninen wrote: If you want Delphi-compatible behaviour, you must add {$mode delphi} at the top of your program. In the default mode, string is an alias for shortstring instead of ansistring ({$h-} mode). And even then you should initialize strings. They are

Re[2]: [fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-06 Thread JoshyFun
Hello FPC-Pascal, Saturday, March 6, 2010, 10:03:49 PM, you wrote: If you want Delphi-compatible behaviour, you must add {$mode delphi} at the top of your program. In the default mode, string is an alias for shortstring instead of ansistring ({$h-} mode). JM And even then you should

Re: [fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-06 Thread Juha Manninen
Sorry ... What ? It must be garanteed in ansistring mode! or everything will simple kboom! There is no way to initialize a non initialized string. By initializing I mean: str:=''; or some other assignment. I remember having garbage in strings in Delphi when I assumed they are empty. Or was

Re: [fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-06 Thread Bart
I thought only global variables were initialized to zero and local ones were just cereated on the stack? Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-06 Thread Jonas Maebe
On 07 Mar 2010, at 00:13, Juha Manninen wrote: I remember having garbage in strings in Delphi when I assumed they are empty. Or was it only with function's string return value, I am not sure. Anyway, after that I was careful to always assign my strings. You're right that it can be different

Re: [fpc-pascal] Is it save to think default value of untouched string is ''?

2010-03-06 Thread Mattias Gaertner
On Sun, 7 Mar 2010 01:13:05 +0200 Juha Manninen juha.manni...@phnet.fi wrote: Sorry ... What ? It must be garanteed in ansistring mode! or everything will simple kboom! There is no way to initialize a non initialized string. By initializing I mean: str:=''; or some other assignment.