[fpc-devel] StrPos giving a access violation

2005-12-09 Thread Graeme Geldenhuys
Hi, The 3rd unit test fails due to StrPos giving a access violation. I ran this same unit test under Delphi 7 and it passed as StrPos returned a nil value when passing two '' param values. Has this been reported as a bug yet? - CUT --- var lFrom: string;

[fpc-devel] StrPos giving a access violation

2005-12-09 Thread Graeme Geldenhuys
Hi Forgot to mention, I ran this using: Free Pascal Compiler version 2.0.1 [2005/10/02] for i386 on Windows 2000 G. Original Message Subject: StrPos giving a access violation Date: Thu, 08 Dec 2005 14:26:14 +0200 From: Graeme Geldenhuys <[EMAIL PROTECTED]> Organization: Maste

Re: [fpc-devel] StrPos giving a access violation

2005-12-09 Thread Jonas Maebe
On 8 dec 2005, at 13:26, Graeme Geldenhuys wrote: The 3rd unit test fails due to StrPos giving a access violation. I ran this same unit test under Delphi 7 and it passed as StrPos returned a nil value when passing two '' param values. Has this been reported as a bug yet? No. I've fixed

Re: [fpc-devel] StrPos giving a access violation

2005-12-09 Thread Marc Weustink
Graeme Geldenhuys wrote: Hi, The 3rd unit test fails due to StrPos giving a access violation. I ran this same unit test under Delphi 7 and it passed as StrPos returned a nil value when passing two '' param values. Has this been reported as a bug yet? - CUT --

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Graeme Geldenhuys
Jonas Maebe wrote: No. I've fixed it and added a test. You can check whether something has been reported as a bug by going to http://www.freepascal.org/bugs.html Thanks for that! If possible, a copy of your unit tests would be nice addition to our test suite. I will go through the unit

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Graeme Geldenhuys
Marc Weustink wrote: StrPos is expecting 2 PChar params and not a Pointer. Please use PChar(lFrom) and PChar(lSearch) to let the compiler make the proper string to PChar conversion. You never ever can cast a string to a pchar using Pointer() I see your point, and amended my code. Nonetheless

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Jonas Maebe
On 12 dec 2005, at 08:12, Graeme Geldenhuys wrote: StrPos is expecting 2 PChar params and not a Pointer. Please use PChar(lFrom) and PChar(lSearch) to let the compiler make the proper string to PChar conversion. You never ever can cast a string to a pchar using Pointer() I see your point,

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Micha Nelissen
Jonas Maebe wrote: strpos, I don't know about Delphi. If you typecast an ansistring to a pchar, then the compiler makes sure that if the ansistring is empty (and thus a null pointer), a valid pointer to an empty null-terminated string is returned. Is that not also undocumented behaviour ?

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Jonas Maebe
On 12 dec 2005, at 12:17, Micha Nelissen wrote: strpos, I don't know about Delphi. If you typecast an ansistring to a pchar, then the compiler makes sure that if the ansistring is empty (and thus a null pointer), a valid pointer to an empty null-terminated string is returned. Is that

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Michael Van Canneyt
On Mon, 12 Dec 2005, Jonas Maebe wrote: On 12 dec 2005, at 12:17, Micha Nelissen wrote: strpos, I don't know about Delphi. If you typecast an ansistring to a pchar, then the compiler makes sure that if the ansistring is empty (and thus a null pointer), a valid pointer to an empty null-t

RE: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread peter green
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Micha > Nelissen > Sent: 12 December 2005 11:18 > To: FPC developers' list > Subject: Re: [fpc-devel] StrPos giving a access violation > > > Jonas Maebe wrote: > &

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Graeme Geldenhuys
Jonas Maebe wrote: Is that not also undocumented behaviour ? I'm quite sure it isn't: afaik typecasting an ansistring to a pchar is fully supported. This means that an empty ansistring must result in an empty (as opposed to an invalid) pchar. Taken from Delphi 7 help: Mixing Delphi st

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Micha Nelissen
Graeme Geldenhuys wrote: Taken from Delphi 7 help: Mixing Delphi strings and null-terminated strings * You can also use Pointer(S) to cast a long string to an untyped pointer. But if S is empty, the typecast returns nil. * PChar(S) always returns a pointer to a memory block; if S is empty, a

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Jonas Maebe
On 12 dec 2005, at 13:30, Micha Nelissen wrote: Taken from Delphi 7 help: Mixing Delphi strings and null-terminated strings * You can also use Pointer(S) to cast a long string to an untyped pointer. But if S is empty, the typecast returns nil. * PChar(S) always returns a pointer to a memory b

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Micha Nelissen
Jonas Maebe wrote: It happens in more in Pascal. For example, single(longint_var) is also not the same as single(pointer(longint_var)) (let's assume a 32bit system). In the former case, the longint is convert to a floating point number with the same value. In the latter case, you get a floa

Re: [fpc-devel] StrPos giving a access violation

2005-12-12 Thread Jonas Maebe
On 12 dec 2005, at 13:57, Micha Nelissen wrote: It happens in more in Pascal. For example, single(longint_var) is also not the same as single(pointer(longint_var)) (let's assume a 32bit system). In the former case, the longint is convert to a floating point number with the same value. I