From 67d640ad134c381ee22f5ec40f10706aad00b136 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 20 Jun 2005 20:46:11 +0000 Subject: [PATCH] * some parts of strutils cleaned up, bug #3124 fixed git-svn-id: trunk@459 - --- .gitattributes | 1 + rtl/objpas/strutils.pp | 25 ++++++++++++------------- tests/webtbs/tw3124.pp | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 tests/webtbs/tw3124.pp diff --git a/.gitattributes b/.gitattributes index ec8a62169f..c18b568b6c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5914,6 +5914,7 @@ tests/webtbs/tw3104.pp svneol=native#text/plain tests/webtbs/tw3109.pp svneol=native#text/plain tests/webtbs/tw3111.pp svneol=native#text/plain tests/webtbs/tw3113.pp svneol=native#text/plain +tests/webtbs/tw3124.pp svneol=native#text/plain tests/webtbs/tw3131.pp svneol=native#text/plain tests/webtbs/tw3137.pp svneol=native#text/plain tests/webtbs/tw3143.pp svneol=native#text/plain diff --git a/rtl/objpas/strutils.pp b/rtl/objpas/strutils.pp index 91ea326a4c..1aeed5d05a 100644 --- a/rtl/objpas/strutils.pp +++ b/rtl/objpas/strutils.pp @@ -22,7 +22,7 @@ uses SysUtils{, Types}; { --------------------------------------------------------------------- - Case sensitive search/replace + Case insensitive search/replace ---------------------------------------------------------------------} Function AnsiResemblesText(const AText, AOther: string): Boolean; @@ -34,7 +34,7 @@ Function AnsiMatchText(const AText: string; const AValues: array of string): Boo Function AnsiIndexText(const AText: string; const AValues: array of string): Integer; { --------------------------------------------------------------------- - Case insensitive search/replace + Case sensitive search/replace ---------------------------------------------------------------------} Function AnsiContainsStr(const AText, ASubText: string): Boolean; @@ -188,9 +188,8 @@ begin end; { --------------------------------------------------------------------- - Case sensitive search/replace + Case insensitive search/replace ---------------------------------------------------------------------} - Function AnsiResemblesText(const AText, AOther: string): Boolean; begin @@ -203,17 +202,17 @@ end; Function AnsiContainsText(const AText, ASubText: string): Boolean; begin - AnsiContainsText:=Pos(ASubText,AText)<>0; + AnsiContainsText:=AnsiPos(ASubText,AText)<>0; end; Function AnsiStartsText(const ASubText, AText: string): Boolean; begin - Result:=Copy(AText,1,Length(AsubText))=ASubText; + Result:=AnsiCompareText(Copy(AText,1,Length(AsubText)),ASubText)=0; end; Function AnsiEndsText(const ASubText, AText: string): Boolean; begin - result:=Copy(AText,Length(AText)-Length(ASubText)+1,Length(ASubText))=asubtext; + result:=AnsiCompareText(Copy(AText,Length(AText)-Length(ASubText)+1,Length(ASubText)),asubtext)=0; end; Function AnsiReplaceText(const AText, AFromText, AToText: string): string; @@ -262,13 +261,13 @@ end; { --------------------------------------------------------------------- - Case insensitive search/replace + Case sensitive search/replace ---------------------------------------------------------------------} Function AnsiContainsStr(const AText, ASubText: string): Boolean; begin - Result := Pos(ASubText,AText)<>0; + Result := AnsiPos(ASubText,AText)<>0; end; @@ -276,7 +275,7 @@ end; Function AnsiStartsStr(const ASubText, AText: string): Boolean; begin - Result := Pos(ASubText,AText)=1; + Result := AnsiPos(ASubText,AText)=1; end; @@ -284,7 +283,7 @@ end; Function AnsiEndsStr(const ASubText, AText: string): Boolean; begin - Result := Pos(ASubText,AText)=(length(AText)-length(ASubText)+1); + Result := AnsiPos(ASubText,AText)=(length(AText)-length(ASubText)+1); end; @@ -340,7 +339,7 @@ end; Function ReverseString(const AText: string): string; -var +var i,j:longint; begin @@ -1653,7 +1652,7 @@ begin h:=((ord(hexvalue^)+9) and 15) else if hexvalue^ IN ['0'..'9'] then h:=((ord(hexvalue^)) and 15) - else + else break; inc(hexvalue); if hexvalue^ IN ['A'..'F','a'..'f'] then diff --git a/tests/webtbs/tw3124.pp b/tests/webtbs/tw3124.pp new file mode 100644 index 0000000000..b5b09dd65b --- /dev/null +++ b/tests/webtbs/tw3124.pp @@ -0,0 +1,22 @@ +{ Source provided for Free Pascal Bug Report 3124 } +{ Submitted by "Radoslaw Stachowiak" on 2004-05-29 } +{ e-mail: zenek_tm@tenbit.pl } +program strtest; +{$apptype console} +{$ifdef fpc} + {$mode objfpc} +{$endif} + +uses strutils; + +var + a, b: ansistring; + +begin + a:='aaaa'; + b:='AaAa'; + if AnsiStartsText(a, b) then + writeln('ok') + else + halt(1); +end.