diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-06-23 06:24:54 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-06-23 06:24:54 -0700 |
commit | ad4e4e79ac6b9fcb182f3cd834120ec79512ac9a (patch) | |
tree | 44aae8e017bc51f526fded0d85bf3a63ba00ad8f /time.c | |
parent | eed035b792cb3b1b2723fa2b1ca0dd7fb5e5fe31 (diff) | |
download | txr-ad4e4e79ac6b9fcb182f3cd834120ec79512ac9a.tar.gz txr-ad4e4e79ac6b9fcb182f3cd834120ec79512ac9a.tar.bz2 txr-ad4e4e79ac6b9fcb182f3cd834120ec79512ac9a.zip |
c_str now takes a self argument.
Adding a self parameter to c_str so that when a non-string
occurs, the error is reported against a function.
Legend:
A - Pass existing self to c_str.
B - Define self and pass to c_str and possibly other
functions.
C - Take new self parameter and pass to c_str and possibly
other functions.
D - Pass existing self to c_str and/or other functions.
E - Define self and pass to other functions, not c_str.
X - Pass nil to c_str.
* buf.c (buf_strm_put_string, buf_str): B.
* chksum.c (sha256_str, md5_str): C.
(sha256_hash, md5_hash): D.
* eval.c (load): D.
* ffi.c (ffi_varray_dynsize, ffi_str_put, ffi_wstr_put, ffi_bstr_put): A.
(ffi_char_array_put, ffi_wchar_array_put): C.
(ffi_bchar_array_put): A.
(ffi_array_put, ffi_array_out, ffi_varray_put): D.
* ftw.c (ftw_wrap): A.
* glob.c (glob_wrap): A.
* lib.c (copy_str, length_str, coded_length,split_str_set,
list_str, cmp_str, num_str, out_json_str, out_json_rec,
display_width): B.
(upcase_str, downcase_str, string_extend, search_str,
do_match_str, do_rmatch_str, sub_str, replace_str,
cat_str_append, split_str_keep, trim_str, int_str, chr_str,
span_str, compl_span_str, break_str, length_str_gt,
length_str_ge, length_str_lt, length_str_le, find, rfind, pos,
rpos, mismatch, rmismatch): A.
(c_str): Add self parameter and use in type mismatch diagnostic.
If the parameter is nil, use "internal error".
(flo_str): B, and correction to "flot-str" typo.
(out_lazy_str, out_quasi_str, obj_print_impl): D.
* lib.h (c_str): Declaration updated.
* match.c (dump_var): X.
(v_load): D.
* parser.c (open_txr_file): C.
(load_rcfile): E.
(find_matching_syms, provide_atom): X.
(hist_save, repl): B.
* parser.h (open_txr_file): Declaration updated.
* parser.y (chrlit): X.
* regex.c (search_regex): A.
* socket.c (getaddrinfo_wrap, sockaddr_pack): A.
(dgram_put_string): B.
(open_sockfd): D.
(sock_connect): E.
* stream.c (stdio_put_string, tail_strategy, vformat_str,
open_directory, open_file, open_tail, remove_path,
rename_path, tmpfile_wrap, mkdtemp_wrap, mkstemp_wrap): B.
(do_parse_mode, parse_mode, make_string_byte_input_stream): B.
(normalize_mode, normalize_mode_no_bin): E.
(string_out_put_string, formatv, put_string, open_fileno,
open_subprocess, open_command, base_name,
dir_name, short_suffix, long_suffix): A.
(run): D.
(win_escape_cmd, win_escape_arg): X.
* stream.h (parse_mode, normalize_mode,
normalize_mode_no_bin): Declarations updated.
* sysif.c (mkdir_wrap, do_utimes, dlopen_wrap, dlsym_wrap,
dlvsym_wrap): A.
(do_stat, do_lstat): C.
(mkdir_nothrow_exists, ensure_dir): E.
(chdir_wrap, rmdir_wrap, mkfifo_wrap, chmod_wrap,
symlink_wrap, link_wrap, readlink_wrap, exec_wrap,
getenv_wrap, setenv_wrap, unsetenv_wrap, getpwnam_wrap,
getgrnam_wrap, crypt_wrap, fnmatch_wrap, realpath_wrap,
opendir_wrap): B.
(stat_impl): statfn pointer-to-function argument now takes
self parameter. When calling it, we pass name.
* syslog.c (openlog_wrap, syslog_wrapv): A.
* time.c (time_string_local, time_string_utc,
time_string_meth, time_parse_meth): A.
(strptime_wrap): B.
* txr.c (txr_main): D.
* y.tab.c.shipped: Updated.
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -125,7 +125,7 @@ val time_string_local(val time, val format) { val self = lit("time-string-local"); time_t secs = c_time(time, self); - const wchar_t *wcfmt = c_str(format); + const wchar_t *wcfmt = c_str(format, self); char *u8fmt = utf8_dup_to(wcfmt); val timestr = string_time(localtime_r, u8fmt, secs); free(u8fmt); @@ -136,7 +136,7 @@ val time_string_utc(val time, val format) { val self = lit("time-string-utc"); time_t secs = c_time(time, self); - const wchar_t *wcfmt = c_str(format); + const wchar_t *wcfmt = c_str(format, self); char *u8fmt = utf8_dup_to(wcfmt); val timestr = string_time(gmtime_r, u8fmt, secs); free(u8fmt); @@ -317,8 +317,9 @@ static struct tm epoch_tm(void) static int strptime_wrap(val string, val format, struct tm *ptms) { - const wchar_t *w_str = c_str(string); - const wchar_t *w_fmt = c_str(format); + val self = lit("strptime"); + const wchar_t *w_str = c_str(string, self); + const wchar_t *w_fmt = c_str(format, self); char *str = utf8_dup_to(w_str); char *fmt = utf8_dup_to(w_fmt); char *ptr = strptime(str, fmt, ptms); @@ -407,7 +408,7 @@ static val time_string_meth(val time_struct, val format) struct tm tms = all_zero_init; time_struct_to_tm(&tms, time_struct, t, self); char buffer[512] = ""; - char *fmt = utf8_dup_to(c_str(format)); + char *fmt = utf8_dup_to(c_str(format, self)); if (strftime(buffer, sizeof buffer, fmt, &tms) == 0) buffer[0] = 0; @@ -427,8 +428,8 @@ static val time_parse_meth(val time_struct, val format, val string) val ret = nil; { - const wchar_t *w_str = c_str(string); - const wchar_t *w_fmt = c_str(format); + const wchar_t *w_str = c_str(string, self); + const wchar_t *w_fmt = c_str(format, self); char *str = utf8_dup_to(w_str); char *fmt = utf8_dup_to(w_fmt); char *ptr = strptime(str, fmt, &tms); |