From 5810ff81544f3b15992059025d59cd9fb074b80c Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 8 Oct 2016 22:23:34 +0000 Subject: [PATCH] * Patch from Maciej Izak for delphi compatible TLocaleOptions (bug ID 30660) git-svn-id: trunk@34683 - --- rtl/objpas/sysutils/sysstr.inc | 58 +++++++++++++++++++++++++++++++-- rtl/objpas/sysutils/sysstrh.inc | 13 ++++++-- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/rtl/objpas/sysutils/sysstr.inc b/rtl/objpas/sysutils/sysstr.inc index 1e1208310f..93e598fae3 100644 --- a/rtl/objpas/sysutils/sysstr.inc +++ b/rtl/objpas/sysutils/sysstr.inc @@ -112,6 +112,14 @@ Function UpperCase(Const S : AnsiString) : AnsiString; end; +function UpperCase(const s: string; LocaleOptions: TLocaleOptions): string; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} + begin + case LocaleOptions of + loInvariantLocale: Result:=UpperCase(s); + loUserLocale: Result:=AnsiUpperCase(s); + end; + end; + { LowerCase returns a copy of S where all uppercase characters ( from A to Z ) have been converted to lowercase } Function Lowercase(Const S : AnsiString) : AnsiString; @@ -120,6 +128,15 @@ Function Lowercase(Const S : AnsiString) : AnsiString; end; +function LowerCase(const s: string; LocaleOptions: TLocaleOptions): string; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} + begin + case LocaleOptions of + loInvariantLocale: Result:=LowerCase(s); + loUserLocale: Result:=AnsiLowerCase(s); + end; + end; + + function LowerCase(const V: variant): string; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} begin result:=LowerCase(ansistring(V)); @@ -165,6 +182,14 @@ begin result:=CAPSIZEINT(Count1-Count2); end; +function CompareStr(const S1, S2: string; LocaleOptions: TLocaleOptions): Integer; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} +begin + case LocaleOptions of + loInvariantLocale: Result:=CompareStr(S1,S2); + loUserLocale: Result:=AnsiCompareStr(S1,S2); + end; +end; + { CompareMemRange returns the result of comparison of Length bytes at P1 and P2 case result P1 < P2 < 0 @@ -190,7 +215,7 @@ end; S1 > S2 > 0 S1 = S2 = 0 } -function CompareText(const S1, S2: string): Integer; +function CompareText(const S1, S2: string): Integer; overload; var i, count, count1, count2: sizeint; @@ -231,18 +256,45 @@ begin result:=CAPSIZEINT(Count1-Count2); end; -function SameText(const s1,s2:String):Boolean; +function CompareText(const S1, S2: string; LocaleOptions: TLocaleOptions): Integer; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} + +begin + case LocaleOptions of + loInvariantLocale: Result:=CompareText(S1,S2); + loUserLocale: Result:=AnsiCompareText(S1,S2); + end; +end; + +function SameText(const s1,s2:String):Boolean; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} begin Result:=CompareText(S1,S2)=0; end; -function SameStr(const s1,s2:String):Boolean; +function SameText(const s1,s2:String; LocaleOptions: TLocaleOptions):Boolean; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} + +begin + case LocaleOptions of + loInvariantLocale: Result:=SameText(S1,S2); + loUserLocale: Result:=AnsiSameText(S1,S2); + end; +end; + +function SameStr(const s1,s2:String):Boolean; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} begin Result:=CompareStr(S1,S2)=0; end; +function SameStr(const s1,s2:String; LocaleOptions: TLocaleOptions):Boolean; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} + +begin + case LocaleOptions of + loInvariantLocale: Result:=SameStr(S1,S2); + loUserLocale: Result:=AnsiSameStr(S1,S2); + end; +end; + {$ifndef FPC_NOGENERICANSIROUTINES} {==============================================================================} { Ansi string functions } diff --git a/rtl/objpas/sysutils/sysstrh.inc b/rtl/objpas/sysutils/sysstrh.inc index b2aac2191d..401db8e880 100644 --- a/rtl/objpas/sysutils/sysstrh.inc +++ b/rtl/objpas/sysutils/sysstrh.inc @@ -20,6 +20,7 @@ type PString = ObjPas.PString; + TLocaleOptions = (loInvariantLocale, loUserLocale); { For FloatToText } TFloatFormat = (ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency); @@ -69,16 +70,22 @@ procedure DisposeStr(S: PShortString); overload; procedure AssignStr(var P: PString; const S: string); procedure AppendStr(var Dest: String; const S: string); function UpperCase(const s: string): string; overload; +function UpperCase(const s: string; LocaleOptions: TLocaleOptions): string; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} function LowerCase(const s: string): string; overload; +function LowerCase(const s: string; LocaleOptions: TLocaleOptions): string; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} { the compiler can't decide else if it should use the char or the ansistring version for a variant } function LowerCase(const V: variant): string; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} function CompareStr(const S1, S2: string): Integer; overload; +function CompareStr(const S1, S2: string; LocaleOptions: TLocaleOptions): Integer; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} function CompareMemRange(P1, P2: Pointer; Length: PtrUInt): integer;{$ifdef SYSUTILSINLINE}inline;{$endif} function CompareMem(P1, P2: Pointer; Length: PtrUInt): Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif} -function CompareText(const S1, S2: string): Integer; -function SameText(const s1,s2:String):Boolean; -function SameStr(const s1,s2:String):Boolean; +function CompareText(const S1, S2: string): Integer; overload; +function CompareText(const S1, S2: string; LocaleOptions: TLocaleOptions): Integer; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} +function SameText(const s1,s2:String):Boolean; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} +function SameText(const s1,s2:String; LocaleOptions: TLocaleOptions):Boolean; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} +function SameStr(const s1,s2:String):Boolean; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} +function SameStr(const s1,s2:String; LocaleOptions: TLocaleOptions):Boolean; overload;{$ifdef SYSUTILSINLINE}inline;{$endif} function AnsiUpperCase(const s: string): string;{$ifdef SYSUTILSINLINE}inline;{$endif} function AnsiLowerCase(const s: string): string;{$ifdef SYSUTILSINLINE}inline;{$endif}