[fpc-devel] AdjustLineBreaks: fixed in trunk, broken in fixes_3_2 (?)

Bart bartjunk64 at gmail.com
Sun Dec 17 17:27:12 CET 2023


Hi,

Just noticed that AdjustLineBreaks is broken if the Style parameter is
set to tlbsCR. (Tested with 3.2.2).
In fpc main this is fixed, in fixes_3_2 this still seems broken.

The fix in main was committed in 1c4151d8 (1 merge reques t!396 Fix,
shorten*, and speed up AdjustLineBreaks.( MR by Rika))
In the MR Rika comments: "presently, AdjustLineBreaks might just not
work, because it attempts to optimize the case of unchanged string by
looking only if the length has changed, which does not account for
possible changing lone #13 to #10."
It does not mention that (before the fix)
AdjustLineBreak(SomeStringWithCRLF, tlbsCR) changed the linebreaks to
LineFeed instead of CarriageReturn.

I would request that the changes from commit 1c4151d8 are merged to fixes_3_2.


For completeness I attached a sample program demonstrating the error.
Run with commandlineparameter --3.2.2 to see 3.2.2 behaviour
Run with commandlineparameter --fixes to see fixes_3_2 behaviour
Run with commandlineparameter --trunk to see fpc main (with commit
1c4151d8) behaviour
Run without commandline parameter to get the default behaviour of your
current compiler.

For both 3.2.2 and fixes code it outputs:

LF: OK: one[LF]two[LF]three

CR: Fail
  Expected: one[CR]two[CR]three
  Got     : one[LF]two[LF]three

CRLF: OK: one[CR][LF]two[CR][LF]three

LF to CR: Fail
  Expected: one[CR]two[CR]three
  Got     : one[LF]two[LF]three

LF->CR->CRLF: OK: one[CR][LF]two[CR][LF]three

CRLF->LF->CR: Fail
  Expected: one[CR]two[CR]three
  Got     : one[LF]two[LF]three

The code for main outputs:
LF: OK: one[LF]two[LF]three

CR: OK: one[CR]two[CR]three

CRLF: OK: one[CR][LF]two[CR][LF]three

LF to CR: OK: one[CR]two[CR]three

LF->CR->CRLF: OK: one[CR][LF]two[CR][LF]three

CRLF->LF->CR: OK: one[CR]two[CR]three

-- 
Bart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.pas
Type: application/octet-stream
Size: 7179 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20231217/a7084775/attachment.obj>


More information about the fpc-devel mailing list