Errors by name: Out, Fmt, Files and Scan test Sys.errIntr, errNoEntry, errDenied No bare errno numbers are left outside Sys.
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | repeat |
| 26 | 26 | n := Sys.read(fd, Buf.spare(b, 65536)); (* straight into b *) |
| 27 | 27 | if n > 0 then INC(b^.len, n); end; |
| 28 | - until (n <= 0) and (n # -4); (* -EINTR: a signal Sys.handle took; read again *) | |
| 28 | + until (n <= 0) and (n # Sys.errIntr); (* a signal Sys.handle took; read again *) | |
| 29 | 29 | Sys.close(fd); |
| 30 | 30 | return n; |
| 31 | 31 | end; |
| @@ -46,7 +46,7 @@ | ||
| 46 | 46 | while at < LEN(data) do |
| 47 | 47 | n := Sys.write(fd, data[at..LEN(data)]); |
| 48 | 48 | if n > 0 then at := at + n; |
| 49 | - elsif n # -4 then Sys.close(fd); return false; (* -EINTR: write again *) | |
| 49 | + elsif n # Sys.errIntr then Sys.close(fd); return false; (* a signal broke in: write again *) | |
| 50 | 50 | end; |
| 51 | 51 | end; |
| 52 | 52 | Sys.close(fd); |
| @@ -62,7 +62,7 @@ | ||
| 62 | 62 | if (load("/tmp/raz-files-test", ADR(b)) # 0) or (Buf.bytes(ADR(b)) # "abc") then Rt.stop("Files.load"); end; |
| 63 | 63 | if not read("/tmp/raz-files-test", ADR(b)) or (Buf.bytes(ADR(b)) # "abcabc") then Rt.stop("Files.read"); end; |
| 64 | 64 | _ := Sys.remove("/tmp/raz-files-test"); |
| 65 | - if load("/tmp/raz-files-test", ADR(b)) # -2 then Rt.stop("Files.load: no such file"); end; | |
| 65 | + if load("/tmp/raz-files-test", ADR(b)) # Sys.errNoEntry then Rt.stop("Files.load: no such file"); end; | |
| 66 | 66 | if load("/", ADR(b)) # -21 then Rt.stop("Files.load: a directory"); end; |
| 67 | 67 | if read("/", ADR(b)) or (b.len # 6) then Rt.stop("Files.read: a directory"); end; |
| 68 | 68 | Buf.done(ADR(b)); |
| @@ -141,7 +141,7 @@ | ||
| 141 | 141 | while LEN(s) > 0 do |
| 142 | 142 | n := Sys.write(Sys.stderr, s); |
| 143 | 143 | if n > 0 then s := s[n..LEN(s)]; |
| 144 | - elsif n # -4 then break; (* -EINTR: try again *) | |
| 144 | + elsif n # Sys.errIntr then break; (* a signal broke in: try again *) | |
| 145 | 145 | end; |
| 146 | 146 | end; |
| 147 | 147 | Arena.done(ADR(ar)); |
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | while i < n do |
| 25 | 25 | k := Sys.write(Sys.stdout, buf[i..n]); |
| 26 | 26 | if k > 0 then i := i + k; |
| 27 | - elsif k # -4 then break; (* -EINTR: try again *) | |
| 27 | + elsif k # Sys.errIntr then break; (* a signal broke in: try again *) | |
| 28 | 28 | end; |
| 29 | 29 | end; |
| 30 | 30 | n := 0; |
| @@ -470,13 +470,13 @@ | ||
| 470 | 470 | var fd, n, got, r, err: INT; info: Sys.Info; |
| 471 | 471 | begin |
| 472 | 472 | info, err := Sys.info(path); |
| 473 | - if err = -2 then return "there is no such file"; end; | |
| 474 | - if err = -13 then return "permission denied"; end; | |
| 473 | + if err = Sys.errNoEntry then return "there is no such file"; end; | |
| 474 | + if err = Sys.errDenied then return "permission denied"; end; | |
| 475 | 475 | if err < 0 then return "it can't be opened"; end; |
| 476 | 476 | if not info.file then return "it isn't a file"; end; |
| 477 | 477 | fd := Sys.openRead(path); |
| 478 | - if fd = -2 then return "there is no such file"; end; | |
| 479 | - if fd = -13 then return "permission denied"; end; | |
| 478 | + if fd = Sys.errNoEntry then return "there is no such file"; end; | |
| 479 | + if fd = Sys.errDenied then return "permission denied"; end; | |
| 480 | 480 | if fd < 0 then return "it can't be opened"; end; |
| 481 | 481 | n := INT(info.size); |
| 482 | 482 | cur.buf := grab(n + 1); |