From ad4e4e79ac6b9fcb182f3cd834120ec79512ac9a Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
Date: Wed, 23 Jun 2021 06:24:54 -0700
Subject: 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.
---
 ftw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'ftw.c')

diff --git a/ftw.c b/ftw.c
index 4e78e801..074952e1 100644
--- a/ftw.c
+++ b/ftw.c
@@ -111,7 +111,7 @@ val ftw_wrap(val dirpath, val fn, val flags_in, val nopenfd_in)
   } else {
     int nopenfd = c_num(default_arg(nopenfd_in, num_fast(20)), self);
     int flags = c_num(default_arg(flags_in, zero), self);
-    char *dirpath_u8 = utf8_dup_to(c_str(dirpath));
+    char *dirpath_u8 = utf8_dup_to(c_str(dirpath, self));
     int res = (s_callback = fn,
                nftw(dirpath_u8, ftw_callback, nopenfd, flags));
     s_callback = nil;
-- 
cgit v1.2.3