View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0037978 | FPC | RTL | public | 2020-10-24 12:02 | 2020-10-24 23:23 |
Reporter | wp | Assigned To | Michael Van Canneyt | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | feedback | Resolution | open | ||
Summary | 0037978: TStringList detected incorrect empty lines in partially quoted DelimitedText with spaces even when StrictDelimiter is true | ||||
Description | The documentation of TStringList.StrictDelimiter says: When StrictDelimiter is set to True then only the Delimiter character is considered when splitting the text in items: no quoting whatsoever is performed when writing the DelimitedText property. However, when reading the DelimitedText property, quoted strings are taken into account (so a quoted string can contain a delimiter that is treated as text instead of a delimiter). Applied to the DelimitedText 'abc;"def" ;ghi' (note the space after the "def") I would expect this to split into three parts. FPC, however adds an additional empty line between 'def' and 'ghi' | ||||
Steps To Reproduce | Run this program:program Project1; uses Classes; var SL: TStringList; i: Integer; begin SL := TStringList.Create; try SL.StrictDelimiter := true; SL.Delimiter := ';'; SL.DelimitedText := 'abc;"def" ;ghi'; for i := 0 to SL.Count-1 do WriteLn(i, ': ', SL[i]); finally SL.Free; end; ReadLn; end. The output is 0: abc 1: def 2: 3: ghi Tested on Windows 10 (64 bit) with Laz-trunk/FPC-trunk (32bit), and FPC 3.2.0 (32-bit and 64 bit), and FPC 3.0.4 (32-bit and 64 bit) | ||||
Tags | No tags attached. | ||||
Fixed in Revision | |||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
This is delphi compatible behaviour. I get the exact same output in Delphi. Highly illogical, I agree, but the whole TStrings has become highly illogical meanwhile, so no surprise there. I would not even know how to describe it correctly in the documentation :-( I will maybe add your program as an example, maybe an example says more than a 1000 words. |
|
OK -- Delphi compatibility does not mean that we have to do the same, and there are many many places which we improved in relatition to Delphi. TStrings has the property Options. Can't we add an option "soFixDelimiter" (or similar) which is OFF by default and thus guarantees backward and Delphi compatibility, but if set ON, the StringList behaves logically? So every user who needs the ultimate Delphi compatibility, even in nonsense, can keep the option off, but everyone wanting logical behavior can turn it on. No problem for me, when you add my test program to the docs. |
|
I am not opposed to such a patch, but I don't intend to spend time on this. It's bad enough trying to keep up with Delphi. Furthermore, I think people should write more their own specialized classes/helpers instead of relying on tstrings to cover every case under the sun. But if you provide a patch with matching test, I will certainly apply it. Name it soDelimiterIgnoresQuoting, if you decide to add such an option |
|
Should it really be soDelimiterIgnoresQuoting though? The question is what the desired result should be: - abc - def - ghi or - abc - "def"__ ('_' is whitespace here) - ghi The option name soDelimiterIgnoresQuoting" only makes sense for the later case in case of the former it would more like be soIgnoreWhitspaceOutsideQuotes or so. |
|
That is why I think TStringlist is such a mess. I personally would take the Strictdelimiter to mean that ONLY the Delimiter sign is used to delimit strings. Forget quoting and whatnot. But if you look at the documentation of Delphi http://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TStrings.StrictDelimiter then the current behaviour is simply correct and no changes are needed. |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-10-24 12:02 | wp | New Issue | |
2020-10-24 13:57 | Michael Van Canneyt | Assigned To | => Michael Van Canneyt |
2020-10-24 13:57 | Michael Van Canneyt | Status | new => resolved |
2020-10-24 13:57 | Michael Van Canneyt | Resolution | open => no change required |
2020-10-24 13:57 | Michael Van Canneyt | FPCTarget | => - |
2020-10-24 13:57 | Michael Van Canneyt | Note Added: 0126508 | |
2020-10-24 15:21 | wp | Status | resolved => feedback |
2020-10-24 15:21 | wp | Resolution | no change required => open |
2020-10-24 15:21 | wp | Note Added: 0126511 | |
2020-10-24 15:21 | wp | Note Edited: 0126511 | View Revisions |
2020-10-24 15:38 | wp | Note Edited: 0126511 | View Revisions |
2020-10-24 16:04 | Michael Van Canneyt | Note Added: 0126514 | |
2020-10-24 16:05 | Michael Van Canneyt | Note Edited: 0126514 | View Revisions |
2020-10-24 19:35 | Sven Barth | Note Added: 0126518 | |
2020-10-24 23:23 | Michael Van Canneyt | Note Added: 0126523 |