فهرست منبع

Merged revisions 1482 via svnmerge from
http://[email protected]/svn/fpc/trunk

r1482 (peter)
* convert constant widestring to ansistring before assigning to pchar

git-svn-id: branches/fixes_2_0@1514 -

peter 20 سال پیش
والد
کامیت
027555b871
3فایلهای تغییر یافته به همراه22 افزوده شده و 1 حذف شده
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/ncnv.pas
  3. 16 0
      tests/webtbs/tw4254.pp

+ 1 - 0
.gitattributes

@@ -6048,6 +6048,7 @@ tests/webtbs/tw4239.pp svneol=native#text/plain
 tests/webtbs/tw4240.pp svneol=native#text/plain
 tests/webtbs/tw4247.pp svneol=native#text/plain
 tests/webtbs/tw4253.pp svneol=native#text/plain
+tests/webtbs/tw4254.pp svneol=native#text/plain
 tests/webtbs/tw4260.pp svneol=native#text/plain
 tests/webtbs/tw4266.pp -text
 tests/webtbs/tw4272.pp svneol=native#text/plain

+ 5 - 1
compiler/ncnv.pas

@@ -1056,7 +1056,11 @@ implementation
       begin
          result:=nil;
          if is_pwidechar(resulttype.def) then
-           inserttypeconv(left,cwidestringtype);
+           inserttypeconv(left,cwidestringtype)
+         else
+           if is_pchar(resulttype.def) and
+              is_widestring(left.resulttype.def) then
+             inserttypeconv(left,cansistringtype);
       end;
 
 

+ 16 - 0
tests/webtbs/tw4254.pp

@@ -0,0 +1,16 @@
+{ Source provided for Free Pascal Bug Report 4254 }
+{ Submitted by "rimga" on  2005-08-04 }
+{ e-mail: [email protected] }
+//when source encoded in utf8
+var
+  p: pchar;
+begin
+  p:= 'abc'#261;
+  //constant is internally treated as of wide chars a0b0c0#105 (it is ok)
+  //but assigning it to pchar it has to be converted to 8-bit chars
+  if strlen(p)= 1 then
+    begin
+    writeln('problem');
+    halt(1);
+    end;
+end.