diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-11-13 20:54:48 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-11-14 08:37:26 -0800 |
commit | ea8bf1c897290d2283033d8e3546a970cdd096f3 (patch) | |
tree | 45020f16bcceec996d9d5b5608f02143394ef4bc /sysif.c | |
parent | 9f633256dea9a141bc5a4d96b2b9c47e3ecb4858 (diff) | |
download | txr-ea8bf1c897290d2283033d8e3546a970cdd096f3.tar.gz txr-ea8bf1c897290d2283033d8e3546a970cdd096f3.tar.bz2 txr-ea8bf1c897290d2283033d8e3546a970cdd096f3.zip |
Implementing *print-base* and ~d format directive.
* debug.c (show_bindings): Use ~d for level, so as
not to be influenced by *print-base*.
(debug): Use ~d for line numbers.
* lib.c (gensym): Use ~d conversion specifier
for formatting gensym counter into symbol name.
* match.c (LOG_MISMATCH, LOG_MATCH): Use ~d for
line number references.
(h_skip, h_coll, h_fun, h_chr, match_line_completely, v_skip,
v_fuzz, v_gather, v_collect, v_output, v_filter, v_fun,
v_assert, v_load, v_line, h_assert, open_data_source): Use ~d
for line refs, number of iterations, errno values.
* parser.c (repl): Use ~d for prompt line numbers,
numbered variables and the expr-<n> string in error
messages.
* parser.l (yyerrorf, source_loc_str): Use ~d for line
numbers.
* stream.c (print_base_s): New symbol variable.
(formatv): Implement *print-base*.
(stdio_maybe_read_error, stdio_maybe_error, stdio_close,
pipe_close, open_directory, open_file, open_fileno, open_tail,
open_process, run, remove_path): Use ~d for errno values.
(stream_init): Initialize print_base_s and register
*print-base* special variable.
sysif.c (mkdir_wrap, ensure_dir, getcwd_wrap, mknod_wrap,
chmod_wrap, symlink_wrap, link_wrap, readlink_wrap,
excec_wrap, stat_impl, pipe_wrap, poll_wrap, getgroups_wrap,
setuid_wrap, seteuid_wrap, setgid_wrap): Use ~d for
errno values and system function results.
* txr.1: Documented *print-base* and ~d conversion specifier.
Diffstat (limited to 'sysif.c')
-rw-r--r-- | sysif.c | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -191,7 +191,7 @@ static val mkdir_wrap(val path, val mode) free(u8path); if (err < 0) - uw_throwf(file_error_s, lit("mkdir ~a: ~a/~s"), + uw_throwf(file_error_s, lit("mkdir ~a: ~d/~s"), path, num(errno), string_utf8(strerror(errno)), nao); return t; @@ -203,7 +203,7 @@ static val mkdir_wrap(val path, val mode) (void) mode; if (err < 0) - uw_throwf(file_error_s, lit("mkdir ~a: ~a/~s"), + uw_throwf(file_error_s, lit("mkdir ~a: ~d/~s"), path, num(errno), string_utf8(strerror(errno)), nao); return t; @@ -265,7 +265,7 @@ static val ensure_dir(val path, val mode) if (ret != t) uw_throwf(file_error_s, - lit("ensure-dir: ~a: ~a/~s"), path, ret, + lit("ensure-dir: ~a: ~d/~s"), path, ret, string_utf8(strerror(c_num(ret))), nao); return ret; @@ -280,7 +280,7 @@ static val chdir_wrap(val path) free(u8path); if (err < 0) - uw_throwf(file_error_s, lit("chdir ~a: ~a/~s"), + uw_throwf(file_error_s, lit("chdir ~a: ~d/~s"), path, num(errno), string_utf8(strerror(errno)), nao); return t; } @@ -295,7 +295,7 @@ static val getcwd_wrap(void) if (getcwd(u8buf, guess) == 0) { free(u8buf); if (errno != ERANGE) { - uw_throwf(file_error_s, lit("getcwd: ~a/~s"), + uw_throwf(file_error_s, lit("getcwd: ~d/~s"), num(errno), string_utf8(strerror(errno)), nao); } if (2 * guess > guess) @@ -340,11 +340,11 @@ static val mknod_wrap(val path, val mode, val dev) if (err < 0) #if HAVE_MAKEDEV - uw_throwf(file_error_s, lit("mknod ~a ~a ~a (~a:~a): ~a/~s"), + uw_throwf(file_error_s, lit("mknod ~a ~a ~a (~d:~d): ~d/~s"), path, mode, dev, major_wrap(dev), minor_wrap(dev), num(errno), string_utf8(strerror(errno)), nao); #else - uw_throwf(file_error_s, lit("mknod ~a ~a ~a: ~a/~s"), + uw_throwf(file_error_s, lit("mknod ~a ~a ~a: ~d/~s"), path, mode, dev, num(errno), string_utf8(strerror(errno)), nao); #endif @@ -363,7 +363,7 @@ static val chmod_wrap(val path, val mode) free(u8path); if (err < 0) - uw_throwf(file_error_s, lit("chmod ~a ~a: ~a/~s"), + uw_throwf(file_error_s, lit("chmod ~a #o~o: ~d/~s"), path, mode, num(errno), string_utf8(strerror(errno)), nao); return t; } @@ -380,7 +380,7 @@ static val symlink_wrap(val target, val to) free(u8target); free(u8to); if (err < 0) - uw_throwf(file_error_s, lit("symlink ~a ~a: ~a/~s"), + uw_throwf(file_error_s, lit("symlink ~a ~a: ~d/~s"), target, to, num(errno), string_utf8(strerror(errno)), nao); return t; } @@ -393,7 +393,7 @@ static val link_wrap(val target, val to) free(u8target); free(u8to); if (err < 0) - uw_throwf(file_error_s, lit("link ~a ~a: ~a/~s"), + uw_throwf(file_error_s, lit("link ~a ~a: ~d/~s"), target, to, num(errno), string_utf8(strerror(errno)), nao); return t; } @@ -415,7 +415,7 @@ static val readlink_wrap(val path) uw_throwf(file_error_s, lit("readlink: weird problem"), nao); } else if (bytes <= 0) { free(u8buf); - uw_throwf(file_error_s, lit("readlink ~a: ~a/~s"), + uw_throwf(file_error_s, lit("readlink ~a: ~d/~s"), path, num(errno), string_utf8(strerror(errno)), nao); } else { val out; @@ -521,7 +521,7 @@ static val exec_wrap(val file, val args_opt) argv[i] = 0; if (execvp(argv[0], argv) < 0) - uw_throwf(file_error_s, lit("execvp ~a: ~a/~s"), + uw_throwf(file_error_s, lit("execvp ~a: ~d/~s"), file, num(errno), string_utf8(strerror(errno)), nao); uw_throwf(file_error_s, lit("execvp ~a returned"), file, nao); } @@ -639,7 +639,7 @@ static val stat_impl(val obj, int (*statfn)(val, struct stat *), int res = statfn(obj, &st); if (res == -1) - uw_throwf(file_error_s, lit("unable to ~a ~a: ~a/~s"), + uw_throwf(file_error_s, lit("unable to ~a ~a: ~d/~s"), name, obj, num(errno), string_utf8(strerror(errno)), nao); return if3(opt_compat && opt_compat <= 113, @@ -670,7 +670,7 @@ static val pipe_wrap(void) { int fd[2]; if (pipe(fd) < 0) - uw_throwf(file_error_s, lit("pipe failed: ~a/~s"), + uw_throwf(file_error_s, lit("pipe failed: ~d/~s"), num(errno), string_utf8(strerror(errno)), nao); return cons(num(fd[0]), num(fd[1])); } @@ -749,7 +749,7 @@ static val poll_wrap(val poll_list, val timeout_in) if (res < 0) { free(pfd); - uw_throwf(file_error_s, lit("poll failed: ~a/~s"), + uw_throwf(file_error_s, lit("poll failed: ~d/~s"), num(errno), string_utf8(strerror(errno)), nao); } @@ -820,7 +820,7 @@ static val getgroups_wrap(void) free(arr); } - uw_throwf(system_error_s, lit("getgroups failed: ~a/~s"), + uw_throwf(system_error_s, lit("getgroups failed: ~d/~s"), num(errno), string_utf8(strerror(errno)), nao); abort(); } @@ -828,7 +828,7 @@ static val getgroups_wrap(void) static val setuid_wrap(val nval) { if (setuid(c_num(nval)) == -1) - uw_throwf(system_error_s, lit("setuid failed: ~a/~s"), + uw_throwf(system_error_s, lit("setuid failed: ~d/~s"), num(errno), string_utf8(strerror(errno)), nao); return t; } @@ -836,7 +836,7 @@ static val setuid_wrap(val nval) static val seteuid_wrap(val nval) { if (seteuid(c_num(nval)) == -1) - uw_throwf(system_error_s, lit("seteuid failed: ~a/~s"), + uw_throwf(system_error_s, lit("seteuid failed: ~d/~s"), num(errno), string_utf8(strerror(errno)), nao); return t; } @@ -844,7 +844,7 @@ static val seteuid_wrap(val nval) static val setgid_wrap(val nval) { if (setgid(c_num(nval)) == -1) - uw_throwf(system_error_s, lit("setgid failed: ~a/~s"), + uw_throwf(system_error_s, lit("setgid failed: ~d/~s"), num(errno), string_utf8(strerror(errno)), nao); return t; } @@ -852,7 +852,7 @@ static val setgid_wrap(val nval) static val setegid_wrap(val nval) { if (setegid(c_num(nval)) == -1) - uw_throwf(system_error_s, lit("setegid failed: ~a/~s"), + uw_throwf(system_error_s, lit("setegid failed: ~d/~s"), num(errno), string_utf8(strerror(errno)), nao); return t; } |