Explorar o código

compiler:
- prefer UnicodeString, WideString, PWideChar, PAnsiChar, AnsiString, ShortString when passing a string constant if default string is UnicodeString,
- change default string type to UnicodeString for MODE DelphiUnicode

git-svn-id: trunk@21094 -

paul %!s(int64=13) %!d(string=hai) anos
pai
achega
1a724f3e11
Modificáronse 2 ficheiros con 17 adicións e 5 borrados
  1. 16 4
      compiler/defcmp.pas
  2. 1 1
      compiler/globals.pas

+ 16 - 4
compiler/defcmp.pas

@@ -514,9 +514,17 @@ implementation
                             doconv:=tc_string_2_string;
                             { prefered string type depends on the $H switch }
                             if (m_default_unicodestring in current_settings.modeswitches) and
-                               (cs_refcountedstrings in current_settings.localswitches) and
-                               is_wide_or_unicode_string(def_to) then
-                              eq:=te_equal
+                               (cs_refcountedstrings in current_settings.localswitches) then
+                              case tstringdef(def_to).stringtype of
+                                st_unicodestring: eq:=te_equal;
+                                st_widestring: eq:=te_convert_l1;
+                                // widechar: eq:=te_convert_l2;
+                                // ansichar: eq:=te_convert_l3;
+                                st_ansistring: eq:=te_convert_l4;
+                                st_shortstring: eq:=te_convert_l5;
+                              else
+                                eq:=te_convert_l6;
+                              end
                             else if not(cs_refcountedstrings in current_settings.localswitches) and
                                (tstringdef(def_to).stringtype=st_shortstring) then
                               eq:=te_equal
@@ -1166,7 +1174,11 @@ implementation
                         (is_pchar(def_to) or is_pwidechar(def_to)) then
                       begin
                         doconv:=tc_cstring_2_pchar;
-                        eq:=te_convert_l2;
+                        if ((m_default_unicodestring in current_settings.modeswitches) xor
+                           is_pchar(def_to)) then
+                          eq:=te_convert_l2
+                        else
+                          eq:=te_convert_l3;
                       end
                      else
                       { chararray to pointer }

+ 1 - 1
compiler/globals.pas

@@ -53,7 +53,7 @@ interface
           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_property,m_default_inline,m_except,m_advanced_records];
-       delphiunicodemodeswitches = delphimodeswitches + [m_systemcodepage];
+       delphiunicodemodeswitches = delphimodeswitches + [m_systemcodepage,m_default_unicodestring];
        fpcmodeswitches =
          [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
           m_cvar_support,m_initfinal,m_hintdirective,