summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-02-02 10:17:40 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-02-02 10:17:40 -0800
commit0d3fc60bfb0d85e4c79550caec0f65976a9692f4 (patch)
tree68f34758c3bbe987570788dbb28c74d11709825a /match.c
parentdf3337250fdff73a0d6076d4ada1719aaecdaafd (diff)
downloadtxr-0d3fc60bfb0d85e4c79550caec0f65976a9692f4.tar.gz
txr-0d3fc60bfb0d85e4c79550caec0f65976a9692f4.tar.bz2
txr-0d3fc60bfb0d85e4c79550caec0f65976a9692f4.zip
* match.c (format_field): Regression. Was not handling modifiers
which are compound expression (e.g. computed field widths). This was broken by the first commit of 2012-01-26.
Diffstat (limited to 'match.c')
-rw-r--r--match.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/match.c b/match.c
index c4ccfd8c..9e3aa488 100644
--- a/match.c
+++ b/match.c
@@ -1219,29 +1219,27 @@ val format_field(val obj, val modifier, val filter, val eval_fun)
} else if (keywordp(item)) {
plist = modifier;
break;
- } else if (consp(item)) {
- if (car(item) == dwim_s) {
- val arg_expr = second(item);
+ } else if (consp(item) && car(item) == dwim_s) {
+ val arg_expr = second(item);
- if (consp(arg_expr) && car(arg_expr) == cons_s) {
- val from = funcall1(eval_fun, second(arg_expr));
- val to = funcall1(eval_fun, third(arg_expr));
+ if (consp(arg_expr) && car(arg_expr) == cons_s) {
+ val from = funcall1(eval_fun, second(arg_expr));
+ val to = funcall1(eval_fun, third(arg_expr));
- obj = if3((vectorp(obj)),
- sub_vec(obj, from, to),
- sub_list(obj, from, to));
- } else {
- val arg = funcall1(eval_fun, arg_expr);
- if (bignump(arg) || fixnump(arg)) {
- if (vectorp(obj))
- obj = vecref(obj, arg);
- else
- obj = listref(obj, arg);
- } else {
- uw_throwf(query_error_s, lit("format_field: bad index: ~s"),
- arg, nao);
- }
- }
+ obj = if3((vectorp(obj)),
+ sub_vec(obj, from, to),
+ sub_list(obj, from, to));
+ } else {
+ val arg = funcall1(eval_fun, arg_expr);
+ if (bignump(arg) || fixnump(arg)) {
+ if (vectorp(obj))
+ obj = vecref(obj, arg);
+ else
+ obj = listref(obj, arg);
+ } else {
+ uw_throwf(query_error_s, lit("format_field: bad index: ~s"),
+ arg, nao);
+ }
}
} else {
val v = funcall1(eval_fun, item);