summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7d831ab)
raw | patch | inline | side by side (parent: 7d831ab)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 16 Jun 2019 11:07:10 +0000 (14:07 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 16 Jun 2019 11:07:10 +0000 (14:07 +0300) |
index 220b6b9499a60acb36f725e529fdc28d73b7d00f..165e9c67eafdd1bf07c9fcf9de022ba36be76ddb 100644 (file)
Binary files a/src/generic/Dev2/Mod/LnkChmod.odc and b/src/generic/Dev2/Mod/LnkChmod.odc differ
Binary files a/src/generic/Dev2/Mod/LnkChmod.odc and b/src/generic/Dev2/Mod/LnkChmod.odc differ
index d29048ebf3612f6ec44dc2172f2ca13eaedcd705..95820c708877ffa96923be53ae54f8d80611bbb3 100644 (file)
VAR res: INTEGER; s: ARRAY 2 OF CHAR; ss: ARRAY 12 OF SHORTCHAR;
BEGIN
s[0] := ch; s[1] := 0X;
- HostLang.StringToHost(s, ss, TRUE, res);
+ HostLang.StringToHost(s, ss, HostLang.replace, res);
ASSERT(res = 0, 100);
res := unistd.write(1, S.ADR(ss[0]), LEN(ss$));
res := unistd.fsync(1)
VAR ss: POINTER TO ARRAY OF SHORTCHAR; res: INTEGER;
BEGIN
NEW(ss, LEN(s$) * 4 + 1);
- HostLang.StringToHost(s, ss, TRUE, res);
+ HostLang.StringToHost(s, ss, HostLang.replace, res);
ASSERT(res = 0, 100);
res := unistd.write(1, S.ADR(ss[0]), LEN(ss$));
res := unistd.fsync(1)
index 8b0fc0058d30c7ae1f699bcf69d5b42eba55dbbb..7f5b91dd779c396a7ff8da6211525f3f0b6acd1d 100644 (file)
ASSERT(f.state = new, 20);
ASSERT(name # "", 21);
ASSERT(IsName(name), 22);
- HostLang.StringToHost(f.pathname, p0, FALSE, err);
+ HostLang.StringToHost(f.pathname, p0, HostLang.pep383, err);
IF err = 0 THEN
dir := f.pathname$;
DirName(dir);
- HostLang.StringToHost(dir + "/" + name, p1, FALSE, err);
+ HostLang.StringToHost(dir + "/" + name, p1, HostLang.pep383, err);
IF err = 0 THEN
x := stdio.rename(p0, p1);
IF x = 0 THEN res := 0 (* no error *)
IF f.state # closed THEN
f.Flush;
IF f.state = new THEN
- HostLang.StringToHost(f.pathname, path, FALSE, err);
+ HostLang.StringToHost(f.pathname, path, HostLang.pep383, err);
ASSERT(err = 0, 100);
res := unistd.unlink(path);
ASSERT(res = 0, 101);
BEGIN
ASSERT(loc # NIL, 20);
WITH loc: Locator DO
- HostLang.StringToHost(loc.path, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path, pathname, HostLang.pep383, err);
IF err = 0 THEN
MakeDir(pathname, res);
IF res = 0 THEN
pathname := pathname + "/" + ".newXXXXXX";
fd := stdlib.mkstemp(pathname);
IF fd # -1 THEN
- NEW(f); HostLang.HostToString(pathname, f.pathname, FALSE, err);
+ NEW(f); HostLang.HostToString(pathname, f.pathname, HostLang.pep383, err);
IF err = 0 THEN
(* !!! get valid inode? *)
f.fd := fd; f.len := 0; f.state := new; f.ino := 0;
ASSERT(name # "", 21);
WITH loc: Locator DO
IF IsName(name) THEN
- HostLang.StringToHost(loc.path + "/" + name, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + name, pathname, HostLang.pep383, err);
IF err = 0 THEN
res := macro.stat(pathname, s);
IF res = 0 THEN
lock.l_pid := 0;
res := fcntl.fcntl(fd, fcntl.F_SETLK, S.ADR(lock));
IF res # -1 THEN
- NEW(f); HostLang.HostToString(pathname, f.pathname, FALSE, err);
+ NEW(f); HostLang.HostToString(pathname, f.pathname, HostLang.pep383, err);
IF err = 0 THEN
f.fd := fd; f.len := s.st_size; f.ino := s.st_ino;
IF isShared THEN f.state := shared
ASSERT(IsName(name), 21);
WITH loc: Locator DO
IF IsName(name) THEN
- HostLang.StringToHost(loc.path + "/" + name, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + name, pathname, HostLang.pep383, err);
IF err = 0 THEN
res := unistd.unlink(pathname);
IF res = 0 THEN loc.res := 0 (* no error *)
ASSERT(new # "", 22);
WITH loc: Locator DO
IF IsName(old) & IsName(new) THEN
- HostLang.StringToHost(loc.path + "/" + old, p0, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + old, p0, HostLang.pep383, err);
IF err = 0 THEN
- HostLang.StringToHost(loc.path + "/" + new, p1, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + new, p1, HostLang.pep383, err);
IF err = 0 THEN
res := stdio.rename(p0, p1);
IF res = 0 THEN loc.res := 0 (* no error *)
WITH loc0: Locator DO
WITH loc1: Locator DO
IF IsName(name0) & IsName(name1) THEN
- HostLang.StringToHost(loc0.path + "/" + name0, a0, FALSE, err);
+ HostLang.StringToHost(loc0.path + "/" + name0, a0, HostLang.pep383, err);
IF err = 0 THEN
err := macro.stat(a0, s0);
IF err = 0 THEN
- HostLang.StringToHost(loc1.path + "/" + name1, a1, FALSE, err);
+ HostLang.StringToHost(loc1.path + "/" + name1, a1, HostLang.pep383, err);
IF err = 0 THEN
err := macro.stat(a1, s1);
IF err = 0 THEN
BEGIN
ASSERT(loc # NIL, 20);
WITH loc: Locator DO
- HostLang.StringToHost(loc.path, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path, pathname, HostLang.pep383, err);
IF err = 0 THEN
p := dirent.opendir(pathname);
IF p # NIL THEN
ent := dirent.readdir(p);
WHILE ent # NIL DO
- HostLang.HostToString(ent.d_name, name, FALSE, err);
+ HostLang.HostToString(ent.d_name, name, HostLang.pep383, err);
IF err = 0 THEN
- HostLang.StringToHost(loc.path + "/" + name, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + name, pathname, HostLang.pep383, err);
IF err = 0 THEN
res := macro.stat(pathname, s);
IF (res = 0) & ~IsDir(s) THEN
BEGIN
ASSERT(loc # NIL, 20);
WITH loc: Locator DO
- HostLang.StringToHost(loc.path, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path, pathname, HostLang.pep383, err);
IF err = 0 THEN
p := dirent.opendir(pathname);
IF p # NIL THEN
ent := dirent.readdir(p);
WHILE ent # NIL DO
- HostLang.HostToString(ent.d_name, name, FALSE, err);
+ HostLang.HostToString(ent.d_name, name, HostLang.pep383, err);
IF err = 0 THEN
- HostLang.StringToHost(loc.path + "/" + name, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + name, pathname, HostLang.pep383, err);
IF err = 0 THEN
res := macro.stat(pathname, s);
IF (res = 0) & IsDir(s) & (name # ".") & (name # "..") THEN
index 00a7935d943d72e04a795f1e86d35f537638d2cb..c3b60a2b1a4b169740001bb83ac3f95d792f7bd0 100644 (file)
CONST
maxLen = 32;
+ (* modes *)
+ replace* = 0; pep383x* = 1; pep383* = 2;
+
VAR
lang-, country-, encoding-: ARRAY maxLen OF CHAR;
c2sc, sc2c, invalid: iconv.iconv_t;
- (* PEP 383 *)
-
- PROCEDURE StringToHost* (IN in: ARRAY OF CHAR; OUT out: ARRAY OF SHORTCHAR; low: BOOLEAN; OUT res: INTEGER);
- VAR i, j, err: INTEGER; maxlen, len, count: iconv.size_t; inadr, outadr: Kernel.ADDRESS; ch: SHORTCHAR;
+ PROCEDURE StringToHost* (IN in: ARRAY OF CHAR; OUT out: ARRAY OF SHORTCHAR; mode: INTEGER; OUT res: INTEGER);
+ VAR i, j, err: INTEGER; maxlen, len, count: iconv.size_t; inadr, outadr: Kernel.ADDRESS; sch: SHORTCHAR;
BEGIN
+ ASSERT(mode IN {replace..pep383}, 20);
ASSERT(c2sc # invalid, 100);
i := 0; err := 0;
outadr := S.ADR(out[0]);
IF count # 0 THEN
CASE macro.errno() OF
| errno.EILSEQ:
- (* !!! HALT(101)*) (* invalid input char *)
- IF maxlen < 1 THEN
- err := 1
+ IF mode = replace THEN
+ IF maxlen < 1 THEN
+ err := 1
+ ELSE
+ sch := "?";
+ S.PUT(outadr, sch); INC(outadr); DEC(maxlen);
+ INC(j); DEC(len, 2)
+ END
ELSE
- ch := "?";
- S.PUT(outadr, ch); INC(outadr); DEC(maxlen);
- INC(j); DEC(len, 2)
- END
+ err := 3
+ END;
| errno.E2BIG: err := 1 (* unexpected end of out *)
- | errno.EINVAL: HALT(102) (* unexpected end of input *)
- | errno.EBADF: HALT(103) (* invalid iconv descriptor *)
- ELSE HALT(104) (* unknown error *)
+ | errno.EINVAL: HALT(101) (* unexpected end of input *)
+ | errno.EBADF: HALT(102) (* invalid iconv descriptor *)
+ ELSE HALT(103) (* unknown error *)
END
END
END;
IF maxlen < 1 THEN
err := 1
ELSE
- ch := SHORT(CHR(ORD(in[i]) MOD 256));
- IF low OR (ch > 7FX) THEN
- S.PUT(outadr, ch); INC(outadr); DEC(maxlen);
+ sch := SHORT(CHR(ORD(in[i]) MOD 256));
+ IF (mode IN {replace, pep383x}) OR (sch > 7FX) THEN
+ S.PUT(outadr, sch); INC(outadr); DEC(maxlen);
INC(i)
ELSE
- err := 3 (* invalid char *)
+ err := 3
END
END
END
END;
- ch := 0X;
- S.PUT(outadr, ch);
+ sch := 0X;
+ S.PUT(outadr, sch);
res := err
END StringToHost;
- PROCEDURE HostToString* (IN in: ARRAY OF SHORTCHAR; OUT out: ARRAY OF CHAR; low: BOOLEAN; OUT res: INTEGER);
+ PROCEDURE HostToString* (IN in: ARRAY OF SHORTCHAR; OUT out: ARRAY OF CHAR; mode: INTEGER; OUT res: INTEGER);
VAR err: INTEGER; maxin, maxout, count: iconv.size_t; inadr, outadr: Kernel.ADDRESS; sch: SHORTCHAR; ch: CHAR;
BEGIN
+ ASSERT(mode IN {replace..pep383}, 20);
ASSERT(sc2c # invalid, 100);
err := 0;
inadr := S.ADR(in[0]);
ELSIF maxin < 1 THEN
err := 2 (* unexpected end of input buffer *)
ELSE
- S.GET(inadr, sch); INC(inadr); DEC(maxin);
- ch := CHR(0D800H + ORD(sch));
- IF low OR (ch > 7FX) THEN
+ IF mode = replace THEN
+ sch := "?"; ch := "?"; INC(inadr); DEC(maxin);
+ ELSE
+ S.GET(inadr, sch); INC(inadr); DEC(maxin);
+ ch := CHR(0D800H + ORD(sch));
+ END;
+ IF (mode IN {replace, pep383x}) OR (sch > 7FX) THEN
S.PUT(outadr, ch); INC(outadr, 2); DEC(maxout, 2)
ELSE
err := 3 (* invalid char *)