raz / commit 460315e4

commit
460315e40c8adb246655caa70cf7a85f128c8320
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
505decc4
Errors by name: Out, Fmt, Files and Scan test Sys.errIntr, errNoEntry, errDenied

No bare errno numbers are left outside Sys.

patch · log

4 files changed, +9 -9

lib/Files.raz (history) modified +3 -3

@@ -25,7 +25,7 @@
2525 repeat
2626 n := Sys.read(fd, Buf.spare(b, 65536)); (* straight into b *)
2727 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 *)
2929 Sys.close(fd);
3030 return n;
3131 end;
@@ -46,7 +46,7 @@
4646 while at < LEN(data) do
4747 n := Sys.write(fd, data[at..LEN(data)]);
4848 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 *)
5050 end;
5151 end;
5252 Sys.close(fd);
@@ -62,7 +62,7 @@
6262 if (load("/tmp/raz-files-test", ADR(b)) # 0) or (Buf.bytes(ADR(b)) # "abc") then Rt.stop("Files.load"); end;
6363 if not read("/tmp/raz-files-test", ADR(b)) or (Buf.bytes(ADR(b)) # "abcabc") then Rt.stop("Files.read"); end;
6464 _ := 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;
6666 if load("/", ADR(b)) # -21 then Rt.stop("Files.load: a directory"); end;
6767 if read("/", ADR(b)) or (b.len # 6) then Rt.stop("Files.read: a directory"); end;
6868 Buf.done(ADR(b));

lib/Fmt.raz (history) modified +1 -1

@@ -141,7 +141,7 @@
141141 while LEN(s) > 0 do
142142 n := Sys.write(Sys.stderr, s);
143143 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 *)
145145 end;
146146 end;
147147 Arena.done(ADR(ar));

lib/Out.raz (history) modified +1 -1

@@ -24,7 +24,7 @@
2424 while i < n do
2525 k := Sys.write(Sys.stdout, buf[i..n]);
2626 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 *)
2828 end;
2929 end;
3030 n := 0;

src/Scan.raz (history) modified +4 -4

@@ -470,13 +470,13 @@
470470 var fd, n, got, r, err: INT; info: Sys.Info;
471471 begin
472472 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;
475475 if err < 0 then return "it can't be opened"; end;
476476 if not info.file then return "it isn't a file"; end;
477477 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;
480480 if fd < 0 then return "it can't be opened"; end;
481481 n := INT(info.size);
482482 cur.buf := grab(n + 1);