Browse Source

* return an empty string for paramstr(value>paramcount) (already correct
for other targets, mantis #11169)

git-svn-id: trunk@10704 -

Jonas Maebe 17 years ago
parent
commit
57087da620
6 changed files with 23 additions and 6 deletions
  1. 1 0
      .gitattributes
  2. 4 3
      rtl/beos/system.pp
  3. 4 1
      rtl/bsd/system.pp
  4. 3 1
      rtl/linux/system.pp
  5. 4 1
      rtl/solaris/system.pp
  6. 7 0
      tests/webtbs/tw11169.pp

+ 1 - 0
.gitattributes

@@ -8138,6 +8138,7 @@ tests/webtbs/tw11042.pp svneol=native#text/plain
 tests/webtbs/tw11053.pp svneol=native#text/plain
 tests/webtbs/tw11053.pp svneol=native#text/plain
 tests/webtbs/tw1111.pp svneol=native#text/plain
 tests/webtbs/tw1111.pp svneol=native#text/plain
 tests/webtbs/tw11139.pp svneol=native#text/plain
 tests/webtbs/tw11139.pp svneol=native#text/plain
+tests/webtbs/tw11169.pp svneol=native#text/plain
 tests/webtbs/tw1117.pp svneol=native#text/plain
 tests/webtbs/tw1117.pp svneol=native#text/plain
 tests/webtbs/tw1122.pp svneol=native#text/plain
 tests/webtbs/tw1122.pp svneol=native#text/plain
 tests/webtbs/tw1123.pp svneol=native#text/plain
 tests/webtbs/tw1123.pp svneol=native#text/plain

+ 4 - 3
rtl/beos/system.pp

@@ -272,11 +272,12 @@ begin
   begin
   begin
     paramstr := execpathstr;
     paramstr := execpathstr;
   end
   end
-  else
+  else if (l < argc) then
   begin
   begin
-    paramstr := '';
     paramstr:=strpas(argv[l]);
     paramstr:=strpas(argv[l]);
-  end;
+  end
+  else
+    paramstr := '';
 end;
 end;
 
 
 Procedure Randomize;
 Procedure Randomize;

+ 4 - 1
rtl/bsd/system.pp

@@ -103,7 +103,10 @@ function paramstr(l: longint) : string;
 //       paramstr := execpathstr;
 //       paramstr := execpathstr;
 //     end
 //     end
 //   else
 //   else
-     paramstr:=strpas(argv[l]);
+     if (l < argc) then
+       paramstr:=strpas(argv[l])
+     else
+       paramstr:='';
  end;
  end;
 
 
 Procedure Randomize;
 Procedure Randomize;

+ 3 - 1
rtl/linux/system.pp

@@ -121,8 +121,10 @@ function paramstr(l: longint) : string;
      begin
      begin
        paramstr := execpathstr;
        paramstr := execpathstr;
      end
      end
+   else if (l < argc) then
+     paramstr:=strpas(argv[l])
    else
    else
-     paramstr:=strpas(argv[l]);
+     paramstr:='';
  end;
  end;
 
 
 Procedure Randomize;
 Procedure Randomize;

+ 4 - 1
rtl/solaris/system.pp

@@ -83,7 +83,10 @@ function paramstr(l: longint) : string;
 //       paramstr := execpathstr;
 //       paramstr := execpathstr;
 //     end
 //     end
 //   else
 //   else
-     paramstr:=strpas(argv[l]);
+     if (l < argc) then
+       paramstr:=strpas(argv[l])
+     else
+       paramstr:='';
  end;
  end;
 
 
 Procedure Randomize;
 Procedure Randomize;

+ 7 - 0
tests/webtbs/tw11169.pp

@@ -0,0 +1,7 @@
+var
+  l: longint;
+begin
+  for l:=1 to 255 do
+    if paramstr(l) <> '' then
+      halt(1);
+end.