From 21ac5dfb3b9c80e7475ca650f50e685b2c156f73 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 11 Oct 2011 08:58:56 +0000 Subject: [PATCH] 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 - --- compiler/globtype.pas | 2 +- compiler/ncgcon.pas | 2 +- compiler/options.pas | 3 ++- compiler/scandir.pas | 17 +++++++++-------- compiler/scanner.pas | 5 +++++ 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/compiler/globtype.pas b/compiler/globtype.pas index b13b790dd8..ed6f69d564 100644 --- a/compiler/globtype.pas +++ b/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 } diff --git a/compiler/ncgcon.pas b/compiler/ncgcon.pas index efd8a6e424..5e57403331 100644 --- a/compiler/ncgcon.pas +++ b/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 diff --git a/compiler/options.pas b/compiler/options.pas index f273d7652e..e356f81eb3 100644 --- a/compiler/options.pas +++ b/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; diff --git a/compiler/scandir.pas b/compiler/scandir.pas index 7d3f5a7b6b..a828b5c12b 100644 --- a/compiler/scandir.pas +++ b/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; diff --git a/compiler/scanner.pas b/compiler/scanner.pas index 749546110e..15a6ebe7c7 100644 --- a/compiler/scanner.pas +++ b/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;