compiler:

- return default compiler codepage to 8859-1
  - emit ansistring constants in CP_NONE by default
  - add new modeswitch systemcodepage which sets default compiler codepage to system and emits ansistring constants with systemcodepage as delphi do
  - add new mode DelphiUnicode with has the same switches as delphi mode + systemcodepage switch. Later it will also have string = unicodestring by default.

git-svn-id: trunk@19165 -
This commit is contained in:
paul 2011-09-21 01:23:42 +00:00
parent f2852137c8
commit 828367bebd
5 changed files with 20 additions and 7 deletions

View File

@ -59,7 +59,7 @@ uses
current_asmdata.getdatalabel(referencelab); current_asmdata.getdatalabel(referencelab);
list.concat(tai_label.create(referencelab)); list.concat(tai_label.create(referencelab));
end; end;
if encoding=CP_NONE then if (encoding=CP_NONE) and (m_systemcodepage in current_settings.modeswitches) then
encoding:=current_settings.sourcecodepage; encoding:=current_settings.sourcecodepage;
list.concat(tai_const.create_16bit(encoding)); list.concat(tai_const.create_16bit(encoding));
list.concat(tai_const.create_16bit(1)); list.concat(tai_const.create_16bit(1));

View File

@ -53,6 +53,7 @@ interface
m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring, m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
m_out,m_default_para,m_duplicate_names,m_hintdirective, m_out,m_default_para,m_duplicate_names,m_hintdirective,
m_property,m_default_inline,m_except,m_advanced_records]; m_property,m_default_inline,m_except,m_advanced_records];
delphiunicodemodeswitches = delphimodeswitches + [m_systemcodepage];
fpcmodeswitches = fpcmodeswitches =
[m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward, [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
m_cvar_support,m_initfinal,m_hintdirective, m_cvar_support,m_initfinal,m_hintdirective,
@ -1532,8 +1533,6 @@ implementation
init_settings:=default_settings; init_settings:=default_settings;
if init_settings.optimizecputype=cpu_none then if init_settings.optimizecputype=cpu_none then
init_settings.optimizecputype:=init_settings.cputype; init_settings.optimizecputype:=init_settings.cputype;
{ Compiler codepage should be default system codepage }
init_settings.sourcecodepage:=DefaultSystemCodePage;
LinkLibraryAliases :=TLinkStrMap.Create; LinkLibraryAliases :=TLinkStrMap.Create;
LinkLibraryOrder :=TLinkStrMap.Create; LinkLibraryOrder :=TLinkStrMap.Create;

View File

@ -295,7 +295,8 @@ interface
m_nested_procvars, { support nested procedural variables } m_nested_procvars, { support nested procedural variables }
m_non_local_goto, { support non local gotos (like iso pascal) } m_non_local_goto, { support non local gotos (like iso pascal) }
m_advanced_records, { advanced record syntax with visibility sections, methods and properties } m_advanced_records, { advanced record syntax with visibility sections, methods and properties }
m_isolike_unary_minus { unary minus like in iso pascal: same precedence level as binary minus/plus } m_isolike_unary_minus, { unary minus like in iso pascal: same precedence level as binary minus/plus }
m_systemcodepage { use system codepage as compiler codepage by default, emit ansistrings with system codepage }
); );
tmodeswitches = set of tmodeswitch; tmodeswitches = set of tmodeswitch;
@ -427,7 +428,8 @@ interface
'NESTEDPROCVARS', 'NESTEDPROCVARS',
'NONLOCALGOTO', 'NONLOCALGOTO',
'ADVANCEDRECORDS', 'ADVANCEDRECORDS',
'ISOUNARYMINUS'); 'ISOUNARYMINUS',
'SYSTEMCODEPAGE');
type type

View File

@ -324,6 +324,14 @@ implementation
if changeinit then if changeinit then
exclude(init_settings.localswitches,cs_do_inline); exclude(init_settings.localswitches,cs_do_inline);
end; end;
{ turn system codepage by default }
if m_systemcodepage in current_settings.modeswitches then
begin
current_settings.sourcecodepage:=DefaultSystemCodePage;
if changeinit then
init_settings.sourcecodepage:=DefaultSystemCodePage;
end;
end; end;
@ -340,6 +348,9 @@ implementation
else else
if s='DELPHI' then if s='DELPHI' then
current_settings.modeswitches:=delphimodeswitches current_settings.modeswitches:=delphimodeswitches
else
if s='DELPHIUNICODE' then
current_settings.modeswitches:=delphiunicodemodeswitches
else else
if s='TP' then if s='TP' then
current_settings.modeswitches:=tpmodeswitches current_settings.modeswitches:=tpmodeswitches

View File

@ -1,11 +1,12 @@
program tcpstr9; program tcpstr9;
{$mode delphiunicode}
{$apptype console} {$apptype console}
begin begin
// this test can be only run with the compiler built right now on the // this test can be only run with the compiler built right now on the
// same system // same system
if StringCodePage('test') <> DefaultSystemCodePage then if StringCodePage(AnsiString('test')) <> DefaultSystemCodePage then
begin begin
WriteLn(StringCodePage('test'), ' <> ', DefaultSystemCodePage); WriteLn(StringCodePage(AnsiString('test')), ' <> ', DefaultSystemCodePage);
halt(1); halt(1);
end; end;
Writeln('ok'); Writeln('ok');