Browse Source

compiler: output ansistring constants in explicit codepage if codepage is explicitly defined using either $codepage directive or compiler switch or for SystemCodepage modeswitch

git-svn-id: trunk@19462 -
paul 14 years ago
parent
commit
21ac5dfb3b
5 changed files with 18 additions and 11 deletions
  1. 1 1
      compiler/globtype.pas
  2. 1 1
      compiler/ncgcon.pas
  3. 2 1
      compiler/options.pas
  4. 9 8
      compiler/scandir.pas
  5. 5 0
      compiler/scanner.pas

+ 1 - 1
compiler/globtype.pas

@@ -139,7 +139,7 @@ interface
          cs_support_c_operators,
          { generation }
          cs_profile,cs_debuginfo,cs_compilesystem,
-         cs_lineinfo,cs_implicit_exceptions,
+         cs_lineinfo,cs_implicit_exceptions,cs_explicit_codepage,
          { linking }
          cs_create_smart,cs_create_dynamic,cs_create_pic,
          { browser switches are back }

+ 1 - 1
compiler/ncgcon.pas

@@ -292,7 +292,7 @@ implementation
                   if cp=CP_NONE then
                     cp:=0;
                   { for delphiuncode mode output CP_ACP constants in the compiler codepage }
-                  if (cp=0) and (m_systemcodepage in current_settings.modeswitches) then
+                  if (cp=0) and (cs_explicit_codepage in current_settings.moduleswitches) then
                     cp:=current_settings.sourcecodepage;
                   entry := PHashSetItem(TTagHashSet(pool).FindOrAdd(value_str,len,cp))
                 end

+ 2 - 1
compiler/options.pas

@@ -867,11 +867,12 @@ begin
                  'c' :
                    begin
                      if (upper(more)='UTF8') or (upper(more)='UTF-8') then
-                        init_settings.sourcecodepage:=CP_UTF8
+                       init_settings.sourcecodepage:=CP_UTF8
                      else if not(cpavailable(more)) then
                        Message1(option_code_page_not_available,more)
                      else
                        init_settings.sourcecodepage:=codepagebyname(more);
+                     include(init_settings.moduleswitches,cs_explicit_codepage);
                    end;
                  'C' :
                    RCCompiler := More;

+ 9 - 8
compiler/scandir.pas

@@ -1370,14 +1370,15 @@ unit scandir;
           Message(scan_w_switch_is_global)
         else
           begin
-             current_scanner.skipspace;
-             s:=current_scanner.readcomment;
-             if (upper(s)='UTF8') or (upper(s)='UTF-8') then
-               current_settings.sourcecodepage:=CP_UTF8
-             else if not(cpavailable(s)) then
-               Message1(option_code_page_not_available,s)
-             else
-               current_settings.sourcecodepage:=codepagebyname(s);
+            current_scanner.skipspace;
+            s:=current_scanner.readcomment;
+            if (upper(s)='UTF8') or (upper(s)='UTF-8') then
+              current_settings.sourcecodepage:=CP_UTF8
+            else if not(cpavailable(s)) then
+              Message1(option_code_page_not_available,s)
+            else
+              current_settings.sourcecodepage:=codepagebyname(s);
+            include(current_settings.moduleswitches,cs_explicit_codepage);
           end;
       end;
 

+ 5 - 0
compiler/scanner.pas

@@ -348,8 +348,12 @@ implementation
         if m_systemcodepage in current_settings.modeswitches then
           begin
             current_settings.sourcecodepage:=DefaultSystemCodePage;
+            include(current_settings.moduleswitches,cs_explicit_codepage);
             if changeinit then
+            begin
               init_settings.sourcecodepage:=DefaultSystemCodePage;
+              include(init_settings.moduleswitches,cs_explicit_codepage);
+            end;
           end;
       end;
 
@@ -2650,6 +2654,7 @@ In case not, the value returned can be arbitrary.
                        inc(inputpointer,3);
                        message(scan_c_switching_to_utf8);
                        current_settings.sourcecodepage:=CP_UTF8;
+                       include(current_settings.moduleswitches,cs_explicit_codepage);
                      end;
 
                    line_no:=1;