| | @@ -7,6 +7,13 @@ |
| 7 | 7 | import Sys, Buf, Heap, Rt; |
| 8 | 8 | import SYSTEM; |
| 9 | 9 | |
| 10 | +(* The number of arguments, the program's name included; argument i |
| 11 | + exists for i below it. *) |
| 12 | +proc argCount*: INT; |
| 13 | +begin |
| 14 | + return ARGC(); |
| 15 | +end; |
| 16 | + |
| 10 | 17 | (* Argument i, a C string, as a slice; empty if there is no argument i, |
| 11 | 18 | as for i below 0 or from ARGC() on. *) |
| 12 | 19 | proc arg*(i: INT): []const U8; |
| | @@ -327,7 +334,8 @@ |
| 327 | 334 | if load("/tmp/raz-files-test", b) # Sys.errNoEntry then Rt.stop("Files.load: no such file"); end; |
| 328 | 335 | if load("/", b) # -21 then Rt.stop("Files.load: a directory"); end; |
| 329 | 336 | if read("/", b) or (b.len # 6) then Rt.stop("Files.read: a directory"); end; |
| 330 | | - if (LEN(arg(ARGC())) # 0) or (LEN(arg(-1)) # 0) then Rt.stop("Files.arg: past the arguments"); end; |
| 337 | + if (argCount() < 1) or (LEN(arg(0)) = 0) then Rt.stop("Files.argCount"); end; |
| 338 | + if (LEN(arg(argCount())) # 0) or (LEN(arg(-1)) # 0) then Rt.stop("Files.arg: past the arguments"); end; |
| 331 | 339 | Buf.done(b); |
| 332 | 340 | testPipe; |
| 333 | 341 | testTree; |