Browse Source

* Improvement of SysGetEnvironmentList by Alexey Torgashin. Fixes issue #40347

Michaël Van Canneyt 2 years ago
parent
commit
31edc46202
1 changed files with 11 additions and 13 deletions
  1. 11 13
      packages/fcl-base/src/custapp.pp

+ 11 - 13
packages/fcl-base/src/custapp.pp

@@ -176,22 +176,20 @@ Procedure SysGetEnvironmentList(List : TStrings;NamesOnly : Boolean);
 
 var
    s : string;
-   i,l,j,count : longint;
+   i,j,count : longint;
 
 begin
   count:=GetEnvironmentVariableCount;
-  if count>0 then
-    for j:=1 to count  do
-     begin
-       s:=GetEnvironmentString(j);
-       l:=Length(s);
-       If NamesOnly then
-          begin
-            I:=pos('=',s);
-            If (I>0) then
-              S:=Copy(S,1,I-1);
-          end;
-       List.Add(S);
+  for j:=1 to count  do
+    begin
+    s:=GetEnvironmentString(j);
+    If NamesOnly then
+      begin
+      I:=pos('=',s);
+      If (I>1) then
+        S:=Copy(S,1,I-1);
+      end;
+    List.Add(S);
     end;
 end;