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, and amended my code. Nonetheless, Delphi never through a AV. I see Jonas created a fix for it though.

It is very dangerous to rely on undocumented behaviour. At least the TP documentation does not specify what happens if you pass a null pchar to 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.


Jonas
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to