diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-03-14 12:02:02 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-03-14 12:02:02 -0700 |
commit | 488bc2f599aa6a2be792e36033ce087a9c5c7577 (patch) | |
tree | 41e9ebb73fc761ed60e8d988a0dadd10ebd7f3b6 | |
parent | d784d188d5da7c5e8d7253b7273c8e71f86485bc (diff) | |
download | txr-488bc2f599aa6a2be792e36033ce087a9c5c7577.tar.gz txr-488bc2f599aa6a2be792e36033ce087a9c5c7577.tar.bz2 txr-488bc2f599aa6a2be792e36033ce087a9c5c7577.zip |
lib: fix neglect to use self variable.
* arith.c (toint): Use self instead of repeating function name
in diagnostic.
* ftw.c (ftw_wrap): Likewise.
* glib.c (glow_wrap): Likewise.
* rand.c (make_random_state, random): Likewise.
* lib.c (nreverse, reverse, remove_if, int_str, less, chr_str,
chr_str_set, unintern, rehome_sym, in): Likewise.
(vector, obj_print_impl): Pass self to helper function instead
of repeating identical literal.
-rw-r--r-- | arith.c | 3 | ||||
-rw-r--r-- | ftw.c | 9 | ||||
-rw-r--r-- | glob.c | 4 | ||||
-rw-r--r-- | lib.c | 36 | ||||
-rw-r--r-- | rand.c | 12 |
5 files changed, 33 insertions, 31 deletions
@@ -3841,7 +3841,8 @@ val toint(val obj, val base) } /* fallthrough */ default: - uw_throwf(error_s, lit("toint: ~s is not convertible to integer"), obj, nao); + uw_throwf(error_s, lit("~a: ~s is not convertible to integer"), + self, obj, nao); } } @@ -93,8 +93,9 @@ val ftw_wrap(val dirpath, val fn, val flags_in, val nopenfd_in) val self = lit("ftw"); if (s_callback) { - uw_throwf(error_s, lit("ftw: cannot be re-entered from " - "ftw callback"), nao); + uw_throwf(error_s, + lit("~a: cannot be re-entered from ~a callback"), + self, self, nao); } else if (dirpath == nil) { return t; } else if (consp(dirpath)) { @@ -128,8 +129,8 @@ val ftw_wrap(val dirpath, val fn, val flags_in, val nopenfd_in) case -1: { int eno = errno; - uw_throwf(errno_to_file_error(eno), lit("ftw ~a: ~d/~s"), - dirpath, num(eno), errno_to_str(eno), nao); + uw_throwf(errno_to_file_error(eno), lit("~a ~a: ~d/~s"), + self, dirpath, num(eno), errno_to_str(eno), nao); } default: return num(res); @@ -73,8 +73,8 @@ val glob_wrap(val pattern, val flags, val errfun) if (s_errfunc) { free(pat_u8); - uw_throwf(error_s, lit("glob: glob cannot be re-entered from " - "its error callback function"), nao); + uw_throwf(error_s, lit("~a: glob cannot be re-entered from " + "its error callback function"), self, nao); } s_errfunc = default_null_arg(errfun); @@ -2005,7 +2005,7 @@ val nreverse(val in) return in; } default: - uw_throwf(error_s, lit("nreverse: cannot reverse ~s"), in, nao); + uw_throwf(error_s, lit("~a: cannot reverse ~s"), self, in, nao); } } @@ -2048,7 +2048,7 @@ val reverse(val seq_in) return obj; } default: - uw_throwf(error_s, lit("reverse: cannot reverse ~s"), seq_in, nao); + uw_throwf(error_s, lit("~a: cannot reverse ~s"), self, seq_in, nao); } } @@ -2707,7 +2707,7 @@ val remove_if(val pred, val seq_in, val keyfun_in) return out; } default: - uw_throwf(error_s, lit("remove-if: ~s isn't a sequence"), seq_in, nao); + uw_throwf(error_s, lit("~a: ~s isn't a sequence"), self, seq_in, nao); } } @@ -5371,7 +5371,7 @@ val int_str(val str, val base) if (zerox) return zero; } else if (b < 2 || b > 36) { - uw_throwf(error_s, lit("int-str: invalid base ~s"), base, nao); + uw_throwf(error_s, lit("~a: invalid base ~s"), self, base, nao); } /* TODO: detect if we have wcstoll */ @@ -5523,8 +5523,8 @@ tail: case less_compare: break; case less_cannot: - uw_throwf(type_error_s, lit("less: cannot compare ~s and ~s"), - left, right, nao); + uw_throwf(type_error_s, lit("~a: cannot compare ~s and ~s"), + self, left, right, nao); } switch (l_type) { @@ -5848,8 +5848,8 @@ val chr_str(val str, val ind) } if (index < 0 || !length_str_gt(str, ind)) - uw_throwf(error_s, lit("chr-str: ~s is out of range for string ~s"), - ind, str, nao); + uw_throwf(error_s, lit("~a: ~s is out of range for string ~s"), + self, ind, str, nao); if (lazy_stringp(str)) { lazy_str_force_upto(str, ind); @@ -5865,8 +5865,8 @@ val chr_str_set(val str, val ind, val chr) cnum index = c_num(ind, self); if (is_lit(str)) { - uw_throwf(error_s, lit("chr-str-set: cannot modify literal string ~s"), - str, nao); + uw_throwf(error_s, lit("~a: cannot modify literal string ~s"), + self, str, nao); } if (index < 0) { @@ -5875,8 +5875,8 @@ val chr_str_set(val str, val ind, val chr) } if (index < 0 || !length_str_gt(str, ind)) - uw_throwf(error_s, lit("chr-str-set: ~s is out of range for string ~s"), - ind, str, nao); + uw_throwf(error_s, lit("~a: ~s is out of range for string ~s"), + self, ind, str, nao); if (lazy_stringp(str)) { @@ -6465,8 +6465,8 @@ val unintern(val symbol, val package_in) if (symbol_package(symbol) == package) { if (symbol == nil) - uw_throwf(error_s, lit("unintern: cannot unintern ~s from ~s"), - symbol, package, nao); + uw_throwf(error_s, lit("~a: cannot unintern ~s from ~s"), + self, symbol, package, nao); symbol->s.package = nil; } @@ -6482,7 +6482,7 @@ val rehome_sym(val sym, val package_in) val name = symbol_name(sym); if (!sym) - uw_throwf(error_s, lit("rehome-sym: cannot rehome ~s"), sym, nao); + uw_throwf(error_s, lit("~a: cannot rehome ~s"), self, sym, nao); prot_sym_check(self, name, sym->s.package); prot_sym_check(self, name, package); @@ -8131,7 +8131,7 @@ val vector(val length, val initval) ucnum len = c_unum(length, self); ucnum alloc_plus = len + 2; ucnum size = if3(alloc_plus > len, alloc_plus, (ucnum) -1); - val *v = coerce(val *, chk_xalloc(size, sizeof *v, lit("vector"))); + val *v = coerce(val *, chk_xalloc(size, sizeof *v, self)); val vec = make_obj(); vec->v.type = VEC; initval = default_null_arg(initval); @@ -10984,7 +10984,7 @@ val in(val seq, val item, val testfun, val keyfun) return nil; } default: - type_mismatch(lit("in: ~s is not a sequence"), seq, nao); + type_mismatch(lit("~a: ~s is not a sequence"), self, seq, nao); } } } @@ -12671,7 +12671,7 @@ dot: if (obj->s.package == keyword_package) put_char(chr(':'), out); } else { - val prefix = symbol_needs_prefix(lit("print"), cur_package, obj); + val prefix = symbol_needs_prefix(self, cur_package, obj); if (prefix) { put_string(prefix, out); @@ -182,8 +182,8 @@ val make_random_state(val seed, val warmup) return rs; } else if (vectorp(seed)) { if (length(seed) < num_fast(17)) - uw_throwf(error_s, lit("make-random-state: vector ~s too short"), - seed, nao); + uw_throwf(error_s, lit("~a: vector ~s too short"), + self, seed, nao); for (i = 0; i < 16; i++) r->state[i] = c_unum(seed->v.vec[i], self); @@ -191,8 +191,8 @@ val make_random_state(val seed, val warmup) r->cur = c_num(seed->v.vec[i], self); return rs; } else { - uw_throwf(error_s, lit("make-random-state: seed ~s is not a number"), - seed, nao); + uw_throwf(error_s, lit("~a: seed ~s is not a number"), + self, seed, nao); } while (i > 0 && r->state[i - 1] == 0) @@ -353,8 +353,8 @@ val random(val state, val modulus) } } - uw_throwf(numeric_error_s, lit("random: invalid modulus ~s"), - modulus, nao); + uw_throwf(numeric_error_s, lit("~a: invalid modulus ~s"), + self, modulus, nao); } val rnd(val modulus, val state) |