Forráskód Böngészése

* renamed fpc_WChar_To_ShortStr() compilerproc to fpc_UChar_To_ShortStr() for
consistency with other helpers
+ added lowercase(unicodechar) and lowercase(unicodestring) overloads (for some
reason only upcase() existed for them)

git-svn-id: branches/jvmbackend@18881 -

Jonas Maebe 14 éve
szülő
commit
1403e3df29
5 módosított fájl, 30 hozzáadás és 7 törlés
  1. 1 1
      compiler/ncnv.pas
  2. 2 2
      rtl/inc/compproc.inc
  3. 2 0
      rtl/inc/ustringh.inc
  4. 21 0
      rtl/inc/ustrings.inc
  5. 4 4
      tests/tbs/tb0429.pp

+ 1 - 1
compiler/ncnv.pas

@@ -1130,7 +1130,7 @@ implementation
                    if torddef(left.resultdef).ordtype<>uwidechar then
                      procname := 'fpc_char_to_shortstr'
                    else
-                     procname := 'fpc_wchar_to_shortstr';
+                     procname := 'fpc_uchar_to_shortstr';
                    addstatement(newstat,ccallnode.createintern(procname,ccallparanode.create(left,ccallparanode.create(
                      ctemprefnode.create(restemp),nil))));
                    addstatement(newstat,ctempdeletenode.create_normal_temp(restemp));

+ 2 - 2
rtl/inc/compproc.inc

@@ -442,9 +442,9 @@ Function fpc_UChar_To_UnicodeStr(const c : UnicodeChar): UnicodeString; compiler
 Function fpc_WChar_To_UnicodeStr(const c : WideChar): UnicodeString; compilerproc;
 Function fpc_UChar_To_AnsiStr(const c : UnicodeChar): AnsiString; compilerproc;
 {$ifndef FPC_STRTOSHORTSTRINGPROC}
-Function fpc_WChar_To_ShortStr(const c : WideChar): ShortString; compilerproc;
+Function fpc_UChar_To_ShortStr(const c : WideChar): ShortString; compilerproc;
 {$else FPC_STRTOSHORTSTRINGPROC}
-procedure fpc_WChar_To_ShortStr(out res : shortstring;const c : WideChar) compilerproc;
+procedure fpc_UChar_To_ShortStr(out res : shortstring;const c : WideChar) compilerproc;
 {$endif FPC_STRTOSHORTSTRINGPROC}
 {$endif FPC_HAS_FEATURE_WIDESTRINGS}
 

+ 2 - 0
rtl/inc/ustringh.inc

@@ -25,6 +25,8 @@ Function Pos (c : ShortString; Const s : UnicodeString) : SizeInt;{$ifdef SYSTEM
 
 Function UpCase(const s : UnicodeString) : UnicodeString;
 Function  UpCase(c:UnicodeChar):UnicodeChar;
+Function LowerCase(const s : UnicodeString) : UnicodeString;
+Function  LowerCase(c:UnicodeChar):UnicodeChar;
 
 Procedure Insert (Const Source : UnicodeString; Var S : UnicodeString; Index : SizeInt);
 Procedure Delete (Var S : UnicodeString; Index,Size: SizeInt);

+ 21 - 0
rtl/inc/ustrings.inc

@@ -1673,6 +1673,27 @@ begin
 end;
 
 
+{$ifndef FPC_HAS_LOWERCASE_UNICODECHAR}
+{$define FPC_HAS_LOWERCASE_UNICODECHAR}
+Function  LowerCase(c:UnicodeChar):UnicodeChar;
+var
+  s : UnicodeString;
+begin
+  s:=c;
+  result:=widestringmanager.LowerUnicodeStringProc(s)[1];
+end;
+{$endif FPC_HAS_LOWERCASE_UNICODECHAR}
+
+
+{$ifndef FPC_HAS_LOWERCASE_UNICODESTR}
+{$define FPC_HAS_LOWERCASE_UNICODESTR}
+function LowerCase(const s : UnicodeString) : UnicodeString;
+begin
+  result:=widestringmanager.LowerUnicodeStringProc(s);
+end;
+{$endif FPC_HAS_LOWERCASE_UNICODESTR}
+
+
 Procedure SetString (Out S : UnicodeString; Buf : PUnicodeChar; Len : SizeInt);
 begin
   SetLength(S,Len);

+ 4 - 4
tests/tbs/tb0429.pp

@@ -3,15 +3,15 @@
 var
   err : boolean;
 
-procedure lowercase(c:char);overload;
+procedure test(c:char);overload;
 begin
   writeln('char');
 end;
-procedure lowercase(c:shortstring);overload;
+procedure test(c:shortstring);overload;
 begin
   writeln('short');
 end;
-procedure lowercase(c:ansistring);overload;
+procedure test(c:ansistring);overload;
 begin
   writeln('ansi');
   err:=false;
@@ -26,7 +26,7 @@ begin
   { this should choosse the ansistring version }
   w:='';
   for i:=1 to 300 do w:=w+'.';
-  lowercase(w);
+  test(w);
   if err then
    begin
      writeln('Wrong lowercase Error!');