Skip to content

Commit eb65b89

Browse files
committed
Update StrWrap routines to take non -ve int params
StrWrap was accepting Integer maximum line lengths and indents, which makes no sense. Unsurprisingly the routine was failing tests that passed negative margin and maximum lengths. So MaxLineLen and Margin parameters were changed from Integer to Word.
1 parent 4733e39 commit eb65b89

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Src/UStrUtils.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ function StrSplit(const Str: UnicodeString; const Delim: UnicodeString;
228228
/// offsets each line using spaces to form a left margin of size given by
229229
/// Margin.</summary>
230230
/// <remarks>Output lines are separated by CRLF.</remarks>
231-
function StrWrap(const Str: UnicodeString; const MaxLen, Margin: Integer):
231+
function StrWrap(const Str: UnicodeString; const MaxLen, Margin: UInt16):
232232
UnicodeString; overload;
233233

234234
/// <summary>Word wraps each paragraph of text in Paras so that each line of a
235235
/// paragraph has lines of maximum length MaxLineLen and is offset by the
236236
/// number of spaces gvien by Margin. Blanks lines are used to separate
237237
/// output paragraphs iff SeparateParas is true.</summary>
238238
/// <remarks>Output lines are separated by CRLF.</remarks>
239-
function StrWrap(const Paras: TStrings; const MaxLineLen, Margin: Integer;
239+
function StrWrap(const Paras: TStrings; const MaxLineLen, Margin: UInt16;
240240
const SeparateParas: Boolean): UnicodeString; overload;
241241

242242
/// <summary>Checks in string Str forms a valid sentence and, if not, adds a
@@ -773,7 +773,7 @@ function StrWindowsLineBreaks(const Str: UnicodeString): UnicodeString;
773773
Result := StrReplace(Result, LF, CRLF);
774774
end;
775775

776-
function StrWrap(const Str: UnicodeString; const MaxLen, Margin: Integer):
776+
function StrWrap(const Str: UnicodeString; const MaxLen, Margin: UInt16):
777777
UnicodeString;
778778
var
779779
Word: UnicodeString; // next word in input Str
@@ -823,7 +823,7 @@ function StrWrap(const Str: UnicodeString; const MaxLen, Margin: Integer):
823823
end;
824824
end;
825825

826-
function StrWrap(const Paras: TStrings; const MaxLineLen, Margin: Integer;
826+
function StrWrap(const Paras: TStrings; const MaxLineLen, Margin: UInt16;
827827
const SeparateParas: Boolean): UnicodeString; overload;
828828
var
829829
Para: string;

0 commit comments

Comments
 (0)