← board

strutils: the Ansi* predicate family is missing

Missing, all present in FPC 3.2.2 and Delphi

name what it does
AnsiContainsStr(s, sub) case-sensitive substring test
AnsiContainsText(s, sub) case-insensitive substring test
AnsiStartsStr(prefix, s) prefix test (note the argument order — prefix first)
AnsiEndsStr(suffix, s) suffix test
AnsiIndexStr(s, array) index of the first exact match, or -1
AnsiReplaceStr(s, old, new) StringReplace with [rfReplaceAll]
AddChar(c, s, n) left-pad s with c to length n
AddCharR(c, s, n) right-pad

Already present, which is why this reads as a corner rather than a hole: PadLeft, PadRight, DupeString, PosEx, ReverseString, IfThen.

Notes for whoever takes it

Gate

A .pas covering all eight against FPC 3.2.2, including empty strings, an absent needle, a needle equal to the haystack, and the no-truncate case, plus make lib-test green.

Resolution (2026-08-15)

Twelve functions landed in lib/rtl/strutils.pas — the eight above plus the ...Text twins FPC also ships and the ticket did not list: AnsiStartsText, AnsiEndsText, AnsiIndexText, AnsiReplaceText. A probe with a ...Str but no ...Text twin is the same surface gap one call later.

A 27-row probe was diffed against FPC 3.2.2 ({$mode objfpc}{$H+}) and matches on every row. Three contracts were measured, not assumed, and each is now a comment in the source next to the code it explains:

Test: 22 rows appended to test/lib_strutil.pas (37 -> 59 =ok), chosen as the rows nobody guesses right rather than one per function — argument order, the empty needle on both sides, -1-not-0, case sensitivity on each Str/Text pair, and the no-truncate case.

Log