Przeglądaj źródła

* fixed string code page after setstring(rawbytestring,..) (mantis #29833)

git-svn-id: trunk@33268 -
Jonas Maebe 9 lat temu
rodzic
commit
5919ca84bb
3 zmienionych plików z 17 dodań i 1 usunięć
  1. 1 0
      .gitattributes
  2. 7 1
      compiler/pinline.pas
  3. 9 0
      tests/test/tw29833.pp

+ 1 - 0
.gitattributes

@@ -12921,6 +12921,7 @@ tests/test/tutf8cpl.pp svneol=native#text/plain
 tests/test/tvarpropsetter1.pp svneol=native#text/plain
 tests/test/tvarpropsetter1.pp svneol=native#text/plain
 tests/test/tvarpropsetter2.pp svneol=native#text/plain
 tests/test/tvarpropsetter2.pp svneol=native#text/plain
 tests/test/tvarset1.pp svneol=native#text/plain
 tests/test/tvarset1.pp svneol=native#text/plain
+tests/test/tw29833.pp svneol=native#text/plain
 tests/test/twarn1.pp svneol=native#text/pascal
 tests/test/twarn1.pp svneol=native#text/pascal
 tests/test/tweaklib1.pp svneol=native#text/plain
 tests/test/tweaklib1.pp svneol=native#text/plain
 tests/test/tweaklib2.pp svneol=native#text/plain
 tests/test/tweaklib2.pp svneol=native#text/plain

+ 7 - 1
compiler/pinline.pas

@@ -515,6 +515,7 @@ implementation
       var
       var
         paras, strpara, pcharpara: tnode;
         paras, strpara, pcharpara: tnode;
         procname: string;
         procname: string;
+        cp: tstringencoding;
       begin
       begin
         consume(_LKLAMMER);
         consume(_LKLAMMER);
         paras:=parse_paras(false,false,_RKLAMMER);
         paras:=parse_paras(false,false,_RKLAMMER);
@@ -534,7 +535,12 @@ implementation
                   ( = paras.right.right) is an ansistring, add a codepage
                   ( = paras.right.right) is an ansistring, add a codepage
                   parameter }
                   parameter }
                 if is_ansistring(strpara.resultdef) then
                 if is_ansistring(strpara.resultdef) then
-                  paras:=ccallparanode.create(genintconstnode(tstringdef(strpara.resultdef).encoding),paras);
+                  begin
+                    cp:=tstringdef(strpara.resultdef).encoding;
+                    if (cp=globals.CP_NONE) then
+                      cp:=0;
+                    paras:=ccallparanode.create(genintconstnode(cp),paras);
+                  end;
                 procname:='fpc_setstring_'+tstringdef(strpara.resultdef).stringtypname;
                 procname:='fpc_setstring_'+tstringdef(strpara.resultdef).stringtypname;
                 { decide which version to call based on the second parameter }
                 { decide which version to call based on the second parameter }
                 if not is_shortstring(strpara.resultdef) then
                 if not is_shortstring(strpara.resultdef) then

+ 9 - 0
tests/test/tw29833.pp

@@ -0,0 +1,9 @@
+var
+  aURI,Server:rawbytestring;
+
+begin
+  aURI:='abcdefg';
+  SetString(Server,@aURI[1],Length(aURI));
+  if stringcodepage(server)=CP_NONE then
+    halt(1);
+end.