Selaa lähdekoodia

compiler: load binary unicode mappings in cpavailable() call instead of separate loadbinarycp() call

git-svn-id: trunk@26379 -
paul 11 vuotta sitten
vanhempi
commit
93883d1264
2 muutettua tiedostoa jossa 15 lisäystä ja 17 poistoa
  1. 1 1
      compiler/scandir.pas
  2. 14 16
      compiler/widestr.pas

+ 1 - 1
compiler/scandir.pas

@@ -1511,7 +1511,7 @@ unit scandir;
             s:=current_scanner.readcomment;
             if (upper(s)='UTF8') or (upper(s)='UTF-8') then
               current_settings.sourcecodepage:=CP_UTF8
-            else if not(cpavailable(s) or loadbinarycp(s)) then
+            else if not cpavailable(s) then
               Message1(option_code_page_not_available,s)
             else
               current_settings.sourcecodepage:=codepagebyname(s);

+ 14 - 16
compiler/widestr.pas

@@ -56,14 +56,13 @@ unit widestr;
     procedure unicode2ascii(r : pcompilerwidestring;p : pchar;cp : tstringencoding);
     function hasnonasciichars(const p: pcompilerwidestring): boolean;
     function getcharwidestring(r : pcompilerwidestring;l : SizeInt) : tcompilerwidechar;
-    function cpavailable(const s : string) : boolean;
-    function cpavailable(cp : word) : boolean;
+    function cpavailable(const s: string) : boolean;
+    function cpavailable(cp: word) : boolean;
     procedure changecodepage(
       s : pchar; l : SizeInt; scp : tstringencoding;
       d : pchar; dcp : tstringencoding
     );
     function codepagebyname(const s : string) : tstringencoding;
-    function loadbinarycp(const s: String): Boolean;
 
   implementation
 
@@ -287,14 +286,22 @@ unit widestr;
       end;
 
 
-    function cpavailable(const s : string) : boolean;
+    function cpavailable(const s: string): boolean;
       begin
-          cpavailable:=mappingavailable(lower(s));
+        result:=mappingavailable(lower(s));
+        {$if FPC_FULLVERSION>20700}
+        if not result then
+          result:=(unicodepath<>'')and(registerbinarymapping(unicodepath+'charset',lower(s)));
+        {$ifend}
       end;
 
-    function cpavailable(cp : word) : boolean;
+    function cpavailable(cp: word): boolean;
       begin
-          cpavailable:=mappingavailable(cp);
+        result:=mappingavailable(cp);
+        {$if FPC_FULLVERSION>20700}
+        if not result then
+          result:=(unicodepath<>'')and(registerbinarymapping(unicodepath+'charset','cp'+tostr(cp)));
+        {$ifend}
       end;
 
     procedure changecodepage(
@@ -329,13 +336,4 @@ unit widestr;
           Result:=p^.cp;
       end;
 
-    function loadbinarycp(const s: String): Boolean;
-      begin
-        {$if FPC_FULLVERSION>20700}
-        result:=(unicodepath<>'')and(registerbinarymapping(unicodepath+'charset',s));
-        {$else}
-        result:=false;
-        {$ifend}
-      end;
-
 end.