* * *

Author Topic: WrapText Bug ?  (Read 588 times)

comingnine

  • New member
  • *
  • Posts: 25
WrapText Bug ?
« on: September 07, 2018, 03:04:52 pm »
It seems that the implementation of FPC's WrapText breaks the line at the first white space AFTER MaxCol, which does not make sense. What if the very token at the boundary is as long as another MaxCol ?

Since the documentation of FPC's WrapText does not specify the exact behavior, could you comment whether this is a bug ?

https://www.freepascal.org/docs-html/rtl/sysutils/wraptext.html

The Delphi documentations clearly state that WrapText breaks the line before MaxCol.
http://www.delphibasics.co.uk/RTL.asp?Name=wraptext
http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.SysUtils.WrapText

Code: [Select]
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
{$IFOPT D+} {$DEFINE DEBUG} {$ENDIF}
{$ASSERTIONS ON}
program WrapTextBug;
{$IFNDEF FPC}{$APPTYPE CONSOLE}{$ENDIF}
uses SysUtils;

var
  before, after : string;

begin
  // Set up a long string
  before := 'This is quite a long string, at least 50 chars long';

  // Split it into multiple lines, each 10 characters long
  after := WrapText(before, 10);

  // Show the before and after strings
  Writeln(before);
  Writeln('');
  Writeln(after);
end.

PS:
Another forum post about WrapText.
https://forum.lazarus.freepascal.org/index.php?topic=25715.0

Thaddy

  • Hero Member
  • *****
  • Posts: 6904
Re: WrapText Bug ?
« Reply #1 on: September 07, 2018, 06:22:53 pm »
What worries me more is the whitespace. Delphi counts whitespace, I guess.
It is not a bug perse, but it is incompatible with Delphi.
Plz report on the bug tracker. Platforms: all.
« Last Edit: September 07, 2018, 06:24:24 pm by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

bytebites

  • Full Member
  • ***
  • Posts: 160
Re: WrapText Bug ?
« Reply #2 on: September 07, 2018, 06:46:27 pm »

comingnine

  • New member
  • *
  • Posts: 25
Re: WrapText Bug ?
« Reply #3 on: September 08, 2018, 06:07:13 am »
It seems that the bug report states the bug is fixed.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus