Browse Source

* some parts of strutils cleaned up, bug #3124 fixed

git-svn-id: trunk@459 -
florian 20 years ago
parent
commit
67d640ad13
3 changed files with 35 additions and 13 deletions
  1. 1 0
      .gitattributes
  2. 12 13
      rtl/objpas/strutils.pp
  3. 22 0
      tests/webtbs/tw3124.pp

+ 1 - 0
.gitattributes

@@ -5914,6 +5914,7 @@ tests/webtbs/tw3104.pp svneol=native#text/plain
 tests/webtbs/tw3109.pp svneol=native#text/plain
 tests/webtbs/tw3109.pp svneol=native#text/plain
 tests/webtbs/tw3111.pp svneol=native#text/plain
 tests/webtbs/tw3111.pp svneol=native#text/plain
 tests/webtbs/tw3113.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/tw3131.pp svneol=native#text/plain
 tests/webtbs/tw3137.pp svneol=native#text/plain
 tests/webtbs/tw3137.pp svneol=native#text/plain
 tests/webtbs/tw3143.pp svneol=native#text/plain
 tests/webtbs/tw3143.pp svneol=native#text/plain

+ 12 - 13
rtl/objpas/strutils.pp

@@ -22,7 +22,7 @@ uses
   SysUtils{, Types};
   SysUtils{, Types};
 
 
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
-    Case sensitive search/replace
+    Case insensitive search/replace
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
 
 
 Function AnsiResemblesText(const AText, AOther: string): Boolean;
 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;
 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;
 Function AnsiContainsStr(const AText, ASubText: string): Boolean;
@@ -188,9 +188,8 @@ begin
 end;
 end;
 
 
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
-    Case sensitive search/replace
+    Case insensitive search/replace
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
-
 Function AnsiResemblesText(const AText, AOther: string): Boolean;
 Function AnsiResemblesText(const AText, AOther: string): Boolean;
 
 
 begin
 begin
@@ -203,17 +202,17 @@ end;
 Function AnsiContainsText(const AText, ASubText: string): Boolean;
 Function AnsiContainsText(const AText, ASubText: string): Boolean;
 
 
 begin
 begin
-  AnsiContainsText:=Pos(ASubText,AText)<>0;
+  AnsiContainsText:=AnsiPos(ASubText,AText)<>0;
 end;
 end;
 
 
 Function AnsiStartsText(const ASubText, AText: string): Boolean;
 Function AnsiStartsText(const ASubText, AText: string): Boolean;
 begin
 begin
-  Result:=Copy(AText,1,Length(AsubText))=ASubText;
+  Result:=AnsiCompareText(Copy(AText,1,Length(AsubText)),ASubText)=0;
 end;
 end;
 
 
 Function AnsiEndsText(const ASubText, AText: string): Boolean;
 Function AnsiEndsText(const ASubText, AText: string): Boolean;
 begin
 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;
 end;
 
 
 Function AnsiReplaceText(const AText, AFromText, AToText: string): string;
 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;
 Function AnsiContainsStr(const AText, ASubText: string): Boolean;
 
 
 begin
 begin
-  Result := Pos(ASubText,AText)<>0;
+  Result := AnsiPos(ASubText,AText)<>0;
 end;
 end;
 
 
 
 
@@ -276,7 +275,7 @@ end;
 Function AnsiStartsStr(const ASubText, AText: string): Boolean;
 Function AnsiStartsStr(const ASubText, AText: string): Boolean;
 
 
 begin
 begin
-  Result := Pos(ASubText,AText)=1;
+  Result := AnsiPos(ASubText,AText)=1;
 end;
 end;
 
 
 
 
@@ -284,7 +283,7 @@ end;
 Function AnsiEndsStr(const ASubText, AText: string): Boolean;
 Function AnsiEndsStr(const ASubText, AText: string): Boolean;
 
 
 begin
 begin
- Result := Pos(ASubText,AText)=(length(AText)-length(ASubText)+1);
+ Result := AnsiPos(ASubText,AText)=(length(AText)-length(ASubText)+1);
 end;
 end;
 
 
 
 
@@ -340,7 +339,7 @@ end;
 
 
 Function ReverseString(const AText: string): string;
 Function ReverseString(const AText: string): string;
 
 
-var 
+var
     i,j:longint;
     i,j:longint;
 
 
 begin
 begin
@@ -1653,7 +1652,7 @@ begin
       h:=((ord(hexvalue^)+9) and 15)
       h:=((ord(hexvalue^)+9) and 15)
     else if hexvalue^ IN ['0'..'9'] then
     else if hexvalue^ IN ['0'..'9'] then
       h:=((ord(hexvalue^)) and 15)
       h:=((ord(hexvalue^)) and 15)
-    else 
+    else
       break;
       break;
     inc(hexvalue);
     inc(hexvalue);
     if hexvalue^ IN ['A'..'F','a'..'f'] then
     if hexvalue^ IN ['A'..'F','a'..'f'] then

+ 22 - 0
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: [email protected] }
+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.