Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 1999-04

TIniFiles and $H+ issue

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael A. Hess

Greetings,

OK Michael now you have me confused. The more I thought about it, I don't understand. You indicated that TIniFiles needed to have $H+ set and then things worked with the TStringList.Add(''); problem.

Why?

Shouldn't it have worked without TIniFiles being set with $H+. TIniFiles didn't specifically use longstrings anyplace. If I made a shortened version of TIniFiles with less features then the Add worked correctly. I hadn't added the $H+. The test program you wrote which just talked to TStringList the same way that TIniFiles does didn't have $H+ and it still worked. Why would the fact that the amount of code in TIniFiles was greater cause it to not work? Does this mean that any code that is written to use TStringList or any of the FCL should have $H+ set? If TIniFiles passed a space (' ') instead of the empty string ('') then everything worked perfectly. Why did passing the empty string make a difference?

Shouldn't you be able to mix shortstrings and longstrings together?

==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com

Reply by email

Michael A. Hess
to Michael Van Canneyt: Good question. I understand that there is a bug somewhere, but I haven't been able to…
Michael Van Canneyt wrote 10 lines
Good question. I understand that there is a bug somewhere, but I haven't been able to find the 'minimal code snippet' to produce the error. Technically speaking, what happened is: Normally, a empty ansistring is a nil pointer; For some reason, your code passed (don't know how) pointer to #0 which is, strictly speaking, NOT equal to an empty string. (although it is if you use a pchar)

I understand this. That is what I discovered during my debugging but since I assumed that {$mode Delphi} already set for longstrings I never tried the {$H+} setting,

Show quoted text 5 lines
This got the internal ansistring code of the RTL confused, hence the error. But, like I said, I didn't find the minimal code that produces this bug :(

So again what is your advice? Should we ALWAYS be using the {$H+} option for anything we write using the FCL? If that is the case can we include that as part of the {$mode delphi} option, since that is normal delphi configuration since Delphi 2?

I'm also curious how long does it take for your submission to CVS to go through? I just tried and update and the inifiles.pp files update was there but nothing for ezcgi yet. Again just curious. :-)

==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com

Reply by email

Michael Van Canneyt
to Michael A. Hess: OK Michael now you have me confused. The more I thought about it, I don't understand. You…
Michael A. Hess wrote 19 lines
Greetings, OK Michael now you have me confused. The more I thought about it, I don't understand. You indicated that TIniFiles needed to have $H+ set and then things worked with the TStringList.Add(''); problem. Why? Shouldn't it have worked without TIniFiles being set with $H+. TIniFiles didn't specifically use longstrings anyplace. If I made a shortened version of TIniFiles with less features then the Add worked correctly. I hadn't added the $H+. The test program you wrote which just talked to TStringList the same way that TIniFiles does didn't have $H+ and it still worked. Why would the fact that the amount of code in TIniFiles was greater cause it to not work? Does this mean that any code that is written to use TStringList or any of the FCL should have $H+ set? If TIniFiles passed a space (' ') instead of the empty string ('') then everything worked perfectly. Why did passing the empty string make a difference?

Good question. I understand that there is a bug somewhere, but I haven't been able to find the 'minimal code snippet' to produce the error.

Technically speaking, what happened is:
Normally, a empty ansistring is a nil pointer;
For some reason, your code passed (don't know how) pointer to #0 which is, strictly speaking, NOT equal to an empty string. (although it is if you use a pchar)

This got the internal ansistring code of the RTL confused, hence the error.

But, like I said, I didn't find the minimal code that produces this bug :(

Michael.

Reply by email