Browse Source

VCL PosEx instead of our PosFrom

Source commit: d4a46bcee39232af963ea38255997e685224309a
Martin Prikryl 9 years ago
parent
commit
6317742dd4
2 changed files with 5 additions and 17 deletions
  1. 5 16
      source/core/Common.cpp
  2. 0 1
      source/core/Common.h

+ 5 - 16
source/core/Common.cpp

@@ -50,17 +50,6 @@ UnicodeString DeleteChar(UnicodeString Str, wchar_t C)
   return Str;
 }
 //---------------------------------------------------------------------------
-int PosFrom(const UnicodeString & SubStr, const UnicodeString & Str, int Index)
-{
-  UnicodeString S = Str.SubString(Index, Str.Length() - Index + 1);
-  int Result = S.Pos(SubStr);
-  if (Result > 0)
-  {
-    Result += Index - 1;
-  }
-  return Result;
-}
-//---------------------------------------------------------------------------
 template<typename T>
 void DoPackStr(T & Str)
 {
@@ -3039,10 +3028,10 @@ UnicodeString __fastcall RtfRemoveHyperlinks(UnicodeString Text)
   // See also RtfEscapeParam
   int Index = 1;
   int P;
-  while ((P = PosFrom(RtfHyperlinkFieldPrefix, Text, Index)) > 0)
+  while ((P = PosEx(RtfHyperlinkFieldPrefix, Text, Index)) > 0)
   {
     int Index2 = P + RtfHyperlinkFieldPrefix.Length();
-    int P2 = PosFrom(RtfHyperlinkFieldSuffix, Text, Index2);
+    int P2 = PosEx(RtfHyperlinkFieldSuffix, Text, Index2);
     if (P2 > 0)
     {
       Text.Delete(P, P2 - P + RtfHyperlinkFieldSuffix.Length());
@@ -3063,7 +3052,7 @@ UnicodeString __fastcall RtfEscapeParam(UnicodeString Param)
   int Index = 1;
   while (true)
   {
-    int P1 = PosFrom(Quote, Param, Index);
+    int P1 = PosEx(Quote, Param, Index);
     if (P1 == 0)
     {
       // no more quotes
@@ -3071,9 +3060,9 @@ UnicodeString __fastcall RtfEscapeParam(UnicodeString Param)
     }
     else
     {
-      int P2 = PosFrom(RtfHyperlinkFieldPrefix, Param, Index);
+      int P2 = PosEx(RtfHyperlinkFieldPrefix, Param, Index);
       int P3;
-      if ((P2 > 0) && (P2 < P1) && ((P3 = PosFrom(RtfHyperlinkFieldSuffix, Param, P2)) > 0))
+      if ((P2 > 0) && (P2 < P1) && ((P3 = PosEx(RtfHyperlinkFieldSuffix, Param, P2)) > 0))
       {
         // skip HYPERLINK
         Index = P3 + RtfHyperlinkFieldSuffix.Length();

+ 0 - 1
source/core/Common.h

@@ -26,7 +26,6 @@ extern const UnicodeString PasswordMask;
 //---------------------------------------------------------------------------
 UnicodeString ReplaceChar(UnicodeString Str, wchar_t A, wchar_t B);
 UnicodeString DeleteChar(UnicodeString Str, wchar_t C);
-int PosFrom(const UnicodeString & SubStr, const UnicodeString & Str, int Index);
 void PackStr(UnicodeString & Str);
 void PackStr(RawByteString & Str);
 void PackStr(AnsiString & Str);