diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | debug.c | 14 | ||||
-rw-r--r-- | lib.c | 45 | ||||
-rw-r--r-- | lib.h | 3 |
4 files changed, 70 insertions, 3 deletions
@@ -1,3 +1,14 @@ +2012-02-28 Kaz Kylheku <kaz@kylheku.com> + + * debug.c: Missing d command implemented. + Condense the output to 8 times the screen width, for more context. + Condense the output in vertical mode (when the entire input line + is shown) not only character mode. + + * lib.c (remq, remql, remqual): New functions. + + * lib.h (remq, remql, remqual): Declared. + 2012-02-29 Kaz Kylheku <kaz@kylheku.com> Version 59 @@ -109,9 +109,11 @@ val debug(val form, val bindings, val data, val line, val pos, val base) } if (print_data) { + int lim = cols * 8; + if (data && pos) { - val half = num((cols - 8) / 2); - val full = num((cols - 8)); + val half = num((lim - 8) / 2); + val full = num((lim - 8)); val prefix, suffix; if (lt(pos, half)) { @@ -124,6 +126,10 @@ val debug(val form, val bindings, val data, val line, val pos, val base) format(std_debug, lit("data (~s:~s):\n~s . ~s\n"), line, plus(pos, base), prefix, suffix, nao); + } else if (data && length_str_ge(data, num(lim - 2))) { + format(std_debug, lit("data (~s):\n~s...~s\n"), line, + sub_str(data, zero, num(lim/2 - 4)), + sub_str(data, num(-(lim/2 - 3)), t), nao); } else { format(std_debug, lit("data (~s):\n~s\n"), line, data, nao); } @@ -166,12 +172,14 @@ val debug(val form, val bindings, val data, val line, val pos, val base) print_data = t; } else if (equal(command, lit("b")) || equal(command, lit("d"))) { if (!rest(input)) { - format(std_debug, lit("b needs argument\n"), nao); + format(std_debug, lit("~s needs argument\n"), command, nao); continue; } else { long n = wcstol(c_str(second(input)), NULL, 10); if (equal(command, lit("b"))) push(num(n), &breakpoints); + else + breakpoints = remql(num(n), breakpoints); } } else if (equal(command, lit("l"))) { format(std_debug, lit("breakpoints: ~s\n"), breakpoints, nao); @@ -625,6 +625,51 @@ val memqual(val obj, val list) return list; } +val remq(val obj, val list) +{ + list_collect_decl (out, ptail); + val lastmatch = cons(nil, list); + + for (; list; list = cdr(list)) { + if (car(list) == obj) { + list_collect_nconc(ptail, ldiff(cdr(lastmatch), list)); + lastmatch = list; + } + } + list_collect_nconc(ptail, cdr(lastmatch)); + return out; +} + +val remql(val obj, val list) +{ + list_collect_decl (out, ptail); + val lastmatch = cons(nil, list); + + for (; list; list = cdr(list)) { + if (eql(car(list), obj)) { + list_collect_nconc(ptail, ldiff(cdr(lastmatch), list)); + lastmatch = list; + } + } + list_collect_nconc(ptail, cdr(lastmatch)); + return out; +} + +val remqual(val obj, val list) +{ + list_collect_decl (out, ptail); + val lastmatch = cons(nil, list); + + for (; list; list = cdr(list)) { + if (equal(car(list), obj)) { + list_collect_nconc(ptail, ldiff(cdr(lastmatch), list)); + lastmatch = list; + } + } + list_collect_nconc(ptail, cdr(lastmatch)); + return out; +} + val tree_find(val obj, val tree, val testfun) { uses_or2; @@ -347,6 +347,9 @@ val lazy_flatten(val list); val memq(val obj, val list); val memql(val obj, val list); val memqual(val obj, val list); +val remq(val obj, val list); +val remql(val obj, val list); +val remqual(val obj, val list); val tree_find(val obj, val tree, val testfun); val some_satisfy(val list, val pred, val key); val all_satisfy(val list, val pred, val key); |