From 03be4ba79f2fa68d966c81be4f32b36f9fe09813 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 5 Feb 2022 14:25:59 -0800 Subject: Use null_string throughout code base. * eval.c (load): Use null_string instead of lit(""). * lib.c (obj_init): Likewise. * match.c (LOG_MATCH, LOG_MISMATCH, do_txeval): Likewise. * parser.c (regex_parse, lisp_parse_impl, find_matching_syms): Likewise. * stream.c (do_parse_mode): Likewise. * txr.c (sysroot_init): Likewise. (txr_main): Replace string(L"") with null_string. --- eval.c | 2 +- lib.c | 2 +- match.c | 6 +++--- parser.c | 7 ++++--- stream.c | 2 +- txr.c | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/eval.c b/eval.c index dc0c97b3..5b1f4818 100644 --- a/eval.c +++ b/eval.c @@ -4663,7 +4663,7 @@ val load(val target) open_txr_file(path, &txr_lisp_p, &name, &stream, self); - if (match_str(or2(get_line(stream), lit("")), lit("#!"), nil)) + if (match_str(or2(get_line(stream), null_string), lit("#!"), nil)) parser_set_lineno(self, stream, two); else seek_stream(stream, zero, from_start_k); diff --git a/lib.c b/lib.c index 03d6cead..2f3f6603 100644 --- a/lib.c +++ b/lib.c @@ -13166,7 +13166,7 @@ static void obj_init(void) args_k = intern(lit("args"), keyword_package); nothrow_k = intern(lit("nothrow"), keyword_package); - colon_k = intern(lit(""), keyword_package); + colon_k = intern(null_string, keyword_package); auto_k = intern(lit("auto"), keyword_package); fun_k = intern(lit("fun"), keyword_package); wrap_k = intern(lit("wrap"), keyword_package); diff --git a/match.c b/match.c index e2d01b80..81cf7c8d 100644 --- a/match.c +++ b/match.c @@ -519,14 +519,14 @@ typedef val (*h_match_func)(match_line_ctx *c); plus(c->pos, c->base), c->file, c->data_lineno, nao); \ debuglf(elem, lit(" ~a"), c->dataline, nao); \ if (c_num(c->pos, lit("txr")) < 77) \ - debuglf(elem, lit(" ~*a^"), c->pos, lit(""), nao) + debuglf(elem, lit(" ~*a^"), c->pos, null_string, nao) #define LOG_MATCH(KIND, EXTENT) \ debuglf(elem, lit(KIND " matched, position ~a-~a (~a:~d)"), \ plus(c->pos, c->base), EXTENT, c->file, c->data_lineno, nao); \ debuglf(elem, lit(" ~a"), c->dataline, nao); \ if (c_num(EXTENT, lit("txr")) < 77) \ - debuglf(elem, lit(" ~*a~<*a^"), c->pos, lit(""), \ + debuglf(elem, lit(" ~*a~<*a^"), c->pos, null_string, \ minus(EXTENT, c->pos), lit("^"), nao) #define elem_bind(elem_var, directive_var, specline) \ @@ -2005,7 +2005,7 @@ static val do_txeval(val spec, val form, val bindings, val allow_unbound) uw_catch (exc_sym, exc) { val msg = if3(consp(exc), car(exc), exc); - if (stringp(msg) && !equal(msg, lit("")) && + if (stringp(msg) && !equal(msg, null_string) && chr_str(msg, zero) == chr('(')) { uw_throw (exc_sym, exc); diff --git a/parser.c b/parser.c index 645b933f..4609546b 100644 --- a/parser.c +++ b/parser.c @@ -620,7 +620,8 @@ val regex_parse(val string, val error_stream) { int gc = gc_state(0); - parse(&parser, if3(std_error != std_null, lit("regex"), lit("")), prime_regex); + parse(&parser, if3(std_error != std_null, lit("regex"), null_string), + prime_regex); gc_state(gc); } @@ -668,7 +669,7 @@ static val lisp_parse_impl(val self, enum prime_parser prime, for (;;) { int gc = gc_state(0); - parse(pi, if3(std_error != std_null, name, lit("")), prime); + parse(pi, if3(std_error != std_null, name, null_string), prime); mut(parser); gc_state(gc); @@ -962,7 +963,7 @@ static void find_matching_syms(lino_completions_t *cpl, val qualify = tnil(force_qualify || !is_cur); val pkg_name = if2(qualify, if3(package == keyword_package && !force_qualify, - lit(""), + null_string, package_name(package))); val syms = ((kind == 'S' || kind == 'M') ? hash_keys((get_slot_syms(package, is_cur, tnil(kind == 'M')))) diff --git a/stream.c b/stream.c index 90c1e34f..951815a3 100644 --- a/stream.c +++ b/stream.c @@ -1443,7 +1443,7 @@ static struct stdio_mode do_parse_mode(val mode_str, struct stdio_mode m_dfl, val self) { struct stdio_mode m = stdio_mode_init_blank; - const wchar_t *ms = c_str(default_arg_strict(mode_str, lit("")), self); + const wchar_t *ms = c_str(default_arg_strict(mode_str, null_string), self); int nredir = 0; switch (*ms) { diff --git a/txr.c b/txr.c index 0a9451eb..e94be080 100644 --- a/txr.c +++ b/txr.c @@ -329,7 +329,7 @@ static void sysroot_init(void) prog_dir = dir_name(prog_path); if (ref(prog_dir, negone) != chr(psc[0])) - prog_dir = scat3(prog_dir, chr(psc[0]), lit("")); + prog_dir = scat3(prog_dir, chr(psc[0]), null_string); if (!(maybe_sysroot(lit(TXR_REL_PATH)) || maybe_sysroot(lit(TXR_REL_PATH EXE_SUFF)) || @@ -668,7 +668,7 @@ int txr_main(int argc, char **argv) else if (deflist) bindings = cons(cons(sym, car(deflist)), bindings); else - bindings = cons(cons(sym, string(L"")), bindings); + bindings = cons(cons(sym, null_string), bindings); match_reg_var(sym); -- cgit v1.2.3