Recent

Author Topic: WrapText Bug ?  (Read 2871 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: 14213
  • Probably until I exterminate Putin.
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 »
Specialize a type, not a var.

bytebites

  • Hero Member
  • *****
  • Posts: 633
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.

 

TinyPortal © 2005-2018