View Issue Details

IDProjectCategoryView StatusLast Update
0032076FPCPatchpublic2017-07-08 14:02
ReporterThaddy de KoningAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformallOSallOS Versionall
Product Version3.1.1Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0032076: PATCH: strutils: in operator for string in array of string
DescriptionThis comes from a forum question.
overloading the in operator to find a match in an array of string seems rather logical.

string and unicodestring provided, using available routines
TagsNo tags attached.
Fixed in Revision36679
FPCOldBugId
FPCTarget
Attached Files
  • strutils.in-operator.patch (1,417 bytes)
    Index: rtl-objpas/src/inc/strutils.pp
    ===================================================================
    --- rtl-objpas/src/inc/strutils.pp	(revision 36614)
    +++ rtl-objpas/src/inc/strutils.pp	(working copy)
    @@ -46,7 +46,8 @@
     Function AnsiIndexStr(const AText: string; const AValues: array of string): Integer;
     Function MatchStr(const AText: UnicodeString; const AValues: array of UnicodeString): Boolean;
     Function IndexStr(const AText: UnicodeString; const AValues: array of UnicodeString): Integer;
    -
    +Operator in (const AText: string; const AValues: array of string):Boolean;inline;
    +Operator in (const AText: UnicodeString; const AValues: array of UnicodeString):Boolean;inline;
     { ---------------------------------------------------------------------
         Miscellaneous
       ---------------------------------------------------------------------}
    @@ -998,6 +999,17 @@
            exit(i);                                 // make sure it is the first val.
     end;
     
    +
    +Operator in (const AText:string;const AValues: array of string):Boolean;
    +begin
    +  Result := AnsiIndexStr(AText,AValues) <>-1;   
    +end;
    +
    +
    +Operator in (const AText:UnicodeString;const AValues: array of UnicodeString):Boolean;
    +begin
    +  Result := IndexStr(AText,AValues) <> -1;
    +end;
     { ---------------------------------------------------------------------
         Playthingies
       ---------------------------------------------------------------------}
    

Activities

Thaddy de Koning

2017-06-29 11:20

reporter  

strutils.in-operator.patch (1,417 bytes)
Index: rtl-objpas/src/inc/strutils.pp
===================================================================
--- rtl-objpas/src/inc/strutils.pp	(revision 36614)
+++ rtl-objpas/src/inc/strutils.pp	(working copy)
@@ -46,7 +46,8 @@
 Function AnsiIndexStr(const AText: string; const AValues: array of string): Integer;
 Function MatchStr(const AText: UnicodeString; const AValues: array of UnicodeString): Boolean;
 Function IndexStr(const AText: UnicodeString; const AValues: array of UnicodeString): Integer;
-
+Operator in (const AText: string; const AValues: array of string):Boolean;inline;
+Operator in (const AText: UnicodeString; const AValues: array of UnicodeString):Boolean;inline;
 { ---------------------------------------------------------------------
     Miscellaneous
   ---------------------------------------------------------------------}
@@ -998,6 +999,17 @@
        exit(i);                                 // make sure it is the first val.
 end;
 
+
+Operator in (const AText:string;const AValues: array of string):Boolean;
+begin
+  Result := AnsiIndexStr(AText,AValues) <>-1;   
+end;
+
+
+Operator in (const AText:UnicodeString;const AValues: array of UnicodeString):Boolean;
+begin
+  Result := IndexStr(AText,AValues) <> -1;
+end;
 { ---------------------------------------------------------------------
     Playthingies
   ---------------------------------------------------------------------}

Michael Van Canneyt

2017-07-08 14:02

administrator   ~0101607

Thanks. Applied the patch.

Issue History

Date Modified Username Field Change
2017-06-29 11:20 Thaddy de Koning New Issue
2017-06-29 11:20 Thaddy de Koning File Added: strutils.in-operator.patch
2017-07-03 11:31 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-07-03 11:31 Michael Van Canneyt Status new => assigned
2017-07-08 14:02 Michael Van Canneyt Fixed in Revision => 36679
2017-07-08 14:02 Michael Van Canneyt Note Added: 0101607
2017-07-08 14:02 Michael Van Canneyt Status assigned => resolved
2017-07-08 14:02 Michael Van Canneyt Fixed in Version => 3.1.1
2017-07-08 14:02 Michael Van Canneyt Resolution open => fixed
2017-07-08 14:02 Michael Van Canneyt Target Version => 3.2.0