summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-22 00:58:18 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-22 00:58:18 -0800
commitaded325cb48f684b3a0849acde7ec31db48733ce (patch)
treeb87dce2ae9df01a1f66d3c2ff43af93e3047387e /lib.c
parent9462f8c7b3d57ccaaa73fd0e891f8a82b41c4b84 (diff)
downloadtxr-aded325cb48f684b3a0849acde7ec31db48733ce.tar.gz
txr-aded325cb48f684b3a0849acde7ec31db48733ce.tar.bz2
txr-aded325cb48f684b3a0849acde7ec31db48733ce.zip
The C function nullp is being renamed to null, and the rarely
used global variable null which holds a symbol becomes null_s. A new macro called nilp is added that more efficiently checks whether an object is nil, producing a C boolean value rather than t or nil. Most of the uses of nullp in the codebase just become the more streamlined nilp. * debug.c (show_bindings): nullp to nilp * eval.c (lookup_var, lookup_var_l, lookup_fun, lookup_sym_lisp1, do_eval, expand_qquote, expand_quasi, expand_op): nullp to nilp. (op_modplace): nullp to null. (eval_init): Update registration of null and not from C function nullp to null. * filter.c (trie_compress, html_hex_continue): nullp to nil. (filter_string_tree): null to null_s. * hash.c (hash_next): nullp to nilp. * lib.c (null): Variable renamed to null_s. (code2type): null to null_s. (lazy_flatten_scan, chainv, lazy_str, lazy_str_force_upto, obj_print, obj_pprint): nullp to nilp. (obj_init): null to null_s; nullp to null. * lib.h (null): declaration changed to null_s. (nullp): Inline function renamed to null. (nilp): New macro. * match.c (do_match_line): nullp to nilp. * rand.c (make_random_state): Likewise. * regex.c (compile_regex): Likewise.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib.c b/lib.c
index 82b1c6c8..b082c7fe 100644
--- a/lib.c
+++ b/lib.c
@@ -68,7 +68,7 @@ val packages;
val system_package, keyword_package, user_package;
-val null, t, cons_s, str_s, chr_s, fixnum_s, sym_s, pkg_s, fun_s, vec_s;
+val null_s, t, cons_s, str_s, chr_s, fixnum_s, sym_s, pkg_s, fun_s, vec_s;
val stream_s, hash_s, hash_iter_s, lcons_s, lstr_s, cobj_s, cptr_s;
val env_s, bignum_s, float_s;
val var_s, expr_s, regex_s, chset_s, set_s, cset_s, wild_s, oneplus_s;
@@ -110,7 +110,7 @@ val identity(val obj)
static val code2type(int code)
{
switch ((type_t) code) {
- case NIL: return null;
+ case NIL: return null_s;
case CONS: return cons_s;
case STR: return str_s;
case LIT: return str_s;
@@ -1101,7 +1101,7 @@ static val lazy_flatten_scan(val list, val *escape)
for (;;) {
if (list) {
val a = car(list);
- if (nullp(a)) {
+ if (nilp(a)) {
list = cdr(list);
} else if (atom(a)) {
return list;
@@ -3738,7 +3738,7 @@ val chainv(val funlist)
static val do_and(val fun1_list, val args)
{
for (; fun1_list; fun1_list = cdr(fun1_list))
- if (nullp(apply(car(fun1_list), args, nil)))
+ if (nilp(apply(car(fun1_list), args, nil)))
return nil;
return t;
@@ -4209,7 +4209,7 @@ val lazy_str(val lst, val term, val limit)
term = default_arg(term, lit("\n"));
limit = default_bool_arg(limit);
- if (nullp(lst)) {
+ if (nilp(lst)) {
obj->ls.prefix = null_string;
obj->ls.list = nil;
} else {
@@ -4251,7 +4251,7 @@ val lazy_str_force_upto(val lstr, val index)
lim = cdr(lstr->ls.opts);
while (ge(index, length_str(lstr->ls.prefix)) && lstr->ls.list &&
- or2(nullp(lim),gt(lim,zero)))
+ or2(null(lim),gt(lim,zero)))
{
val next = pop(&lstr->ls.list);
val term = car(lstr->ls.opts);
@@ -5074,7 +5074,7 @@ static void obj_init(void)
lit("t"), 0), make_sym(lit("t")));
set(t->s.package, user_package);
- null = intern(lit("null"), user_package);
+ null_s = intern(lit("null"), user_package);
cons_s = intern(lit("cons"), user_package);
str_s = intern(lit("str"), user_package);
chr_s = intern(lit("chr"), user_package);
@@ -5172,7 +5172,7 @@ static void obj_init(void)
identity_f = func_n1(identity);
car_f = func_n1(car);
cdr_f = func_n1(cdr);
- null_f = func_n1(nullp);
+ null_f = func_n1(null);
gensym_counter = zero;
prog_string = string(progname);
}
@@ -5220,7 +5220,7 @@ val obj_print(val obj, val out)
for (iter = obj; consp(iter); iter = cdr(iter)) {
obj_print(car(iter), out);
- if (nullp(cdr(iter))) {
+ if (nilp(cdr(iter))) {
put_char(closepar, out);
} else if (consp(cdr(iter))) {
put_char(chr(' '), out);
@@ -5386,7 +5386,7 @@ val obj_pprint(val obj, val out)
for (iter = obj; consp(iter); iter = cdr(iter)) {
obj_pprint(car(iter), out);
- if (nullp(cdr(iter))) {
+ if (nilp(cdr(iter))) {
put_char(closepar, out);
} else if (consp(cdr(iter))) {
put_char(chr(' '), out);