Browse Source

* get_stringconst should handle widestring correctly: library & import names are unicodestring constants in unicode rtl

Michaël Van Canneyt 2 years ago
parent
commit
fb9c718371
1 changed files with 14 additions and 1 deletions
  1. 14 1
      compiler/pexpr.pas

+ 14 - 1
compiler/pexpr.pas

@@ -5000,6 +5000,11 @@ implementation
      constant. Then the constant is returned.}
     var
       p:tnode;
+      snode : tstringconstnode absolute p;
+      s : string;
+      pw : pcompilerwidestring;
+      pc : pansichar;
+
     begin
       get_stringconst:='';
       p:=comp_expr([ef_accept_equal]);
@@ -5010,8 +5015,16 @@ implementation
           else
             Message(parser_e_illegal_expression);
         end
+      else if (tstringconstnode(p).cst_type in [cst_unicodestring,cst_widestring]) then
+         begin
+         pw:=pcompilerwideString(tstringconstnode(p).value_str);
+         pc:=getmem(getlengthwidestring(pw));
+         unicode2ascii(pw,pc,current_settings.sourcecodepage);
+         get_stringconst:=strpas(pc);
+         freemem(pc);
+         end
       else
-        get_stringconst:=strpas(tstringconstnode(p).value_str);
+        get_stringconst:=strpas(snode.value_str);
       p.free;
     end;