Browse Source

* fixed widechar const to widestring, fixes bug #4155

git-svn-id: trunk@638 -
florian 20 years ago
parent
commit
7c10694bc3
3 changed files with 23 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 4 1
      compiler/ncnv.pas
  3. 18 0
      tests/webtbs/tw4155.pp

+ 1 - 0
.gitattributes

@@ -6141,6 +6141,7 @@ tests/webtbs/tw4140.pp svneol=native#text/plain
 tests/webtbs/tw4150.pp svneol=native#text/plain
 tests/webtbs/tw4150.pp svneol=native#text/plain
 tests/webtbs/tw4151.pp svneol=native#text/plain
 tests/webtbs/tw4151.pp svneol=native#text/plain
 tests/webtbs/tw4152.pp svneol=native#text/plain
 tests/webtbs/tw4152.pp svneol=native#text/plain
+tests/webtbs/tw4155.pp svneol=native#text/plain
 tests/webtbs/tw4162.pp svneol=native#text/plain
 tests/webtbs/tw4162.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain

+ 4 - 1
compiler/ncnv.pas

@@ -809,7 +809,10 @@ implementation
               if tstringdef(resulttype.def).string_typ=st_widestring then
               if tstringdef(resulttype.def).string_typ=st_widestring then
                begin
                begin
                  initwidestring(ws);
                  initwidestring(ws);
-                 concatwidestringchar(ws,tcompilerwidechar(chr(tordconstnode(left).value)));
+                 if torddef(left.resulttype.def).typ=uwidechar then
+                   concatwidestringchar(ws,tcompilerwidechar(tordconstnode(left).value))
+                 else
+                   concatwidestringchar(ws,tcompilerwidechar(chr(tordconstnode(left).value)));
                  hp:=cstringconstnode.createwstr(ws);
                  hp:=cstringconstnode.createwstr(ws);
                  donewidestring(ws);
                  donewidestring(ws);
                end
                end

+ 18 - 0
tests/webtbs/tw4155.pp

@@ -0,0 +1,18 @@
+{ %OPT=-Fcutf8}
+{ Source provided for Free Pascal Bug Report 4155 }
+{ Submitted by "rimga" on  2005-07-04 }
+{ e-mail: [email protected] }
+{this file encoded in UTF8}
+{cmd fpc twchar.pas -FcUTF8}
+var
+  c: widestring;
+  c2: widestring;
+begin
+  c:= 'ą';      //problem handling char constants
+  c2:= 'ąa';
+  if c[1]<>c2[1] then
+    WriteLn('problem')
+  else
+    Writeln('OK');
+  Readln;
+end.