Ver Fonte

* don't truncate environment variable strings in GetEnvironmentString()
* set the correct code page for the result of GetEnvironmentString() on
Windows and NativeNT

git-svn-id: branches/cpstrrtl@25103 -

Jonas Maebe há 12 anos atrás
pai
commit
8b77f62873
3 ficheiros alterados com 13 adições e 9 exclusões
  1. 1 0
      rtl/nativent/sysutils.pp
  2. 4 4
      rtl/objpas/sysutils/osutil.inc
  3. 8 5
      rtl/win/sysutils.pp

+ 1 - 0
rtl/nativent/sysutils.pp

@@ -1108,6 +1108,7 @@ begin
         len:=UnicodeToUTF8(Nil, hp, 0);
         SetLength(Result, len);
         UnicodeToUTF8(PChar(Result), hp, len);
+        SetCodePage(RawByteString(Result),CP_UTF8,false);
       end;
     end;
 end;

+ 4 - 4
rtl/objpas/sysutils/osutil.inc

@@ -66,11 +66,11 @@ begin
   Result:='';
   while assigned(EP^) and (Index>1) do
     begin
-    Dec(Index);
-    inc(EP);
+      dec(Index);
+      inc(EP);
     end;
-  If Assigned(EP^) then
-    Result:=StrPas(EP^);
+  if Assigned(EP^) then
+    Result:=EP^;
 end;
 
 

+ 8 - 5
rtl/win/sysutils.pp

@@ -1026,13 +1026,16 @@ begin
   hp:=p;
   If (Hp<>Nil) then
     begin
-    while (hp^<>#0) and (Index>1) do
+      while (hp^<>#0) and (Index>1) do
+        begin
+          Dec(Index);
+          hp:=hp+strlen(hp)+1;
+        end;
+    If (hp^<>#0) then
       begin
-      Dec(Index);
-      hp:=hp+strlen(hp)+1;
+        Result:=HP;
+        SetCodePage(RawByteString(Result),CP_OEMCP,false);
       end;
-    If (hp^<>#0) then
-      Result:=StrPas(HP);
     end;
   FreeEnvironmentStringsA(p);
 end;