summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--debug.c14
-rw-r--r--lib.c45
-rw-r--r--lib.h3
4 files changed, 70 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b99044a..2e65b7c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/debug.c b/debug.c
index 16076a94..808e60af 100644
--- a/debug.c
+++ b/debug.c
@@ -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);
diff --git a/lib.c b/lib.c
index 9aaa9f04..9f2b48ed 100644
--- a/lib.c
+++ b/lib.c
@@ -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;
diff --git a/lib.h b/lib.h
index 3762dacd..8c50eb9b 100644
--- a/lib.h
+++ b/lib.h
@@ -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);