summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-08-04 20:28:06 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-08-04 20:28:06 -0700
commit09a267a5b230f3d42aacb00188c3c168bbc4e42a (patch)
tree61b53a422e1d91eea03dd15c0437228c4a311428
parentf4c63c7c6779b8dd9b1fc850d27b2a502486c1de (diff)
downloadtxr-09a267a5b230f3d42aacb00188c3c168bbc4e42a.tar.gz
txr-09a267a5b230f3d42aacb00188c3c168bbc4e42a.tar.bz2
txr-09a267a5b230f3d42aacb00188c3c168bbc4e42a.zip
* stream.c (inc_indent): If a negative indentation increment goes below
zero, clamp it at zero. (set_indent): Clamp indentation value to zero.
-rw-r--r--ChangeLog6
-rw-r--r--stream.c4
2 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 1ed7ff51..f73128eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2015-08-04 Kaz Kylheku <kaz@kylheku.com>
+ * stream.c (inc_indent): If a negative indentation increment goes below
+ zero, clamp it at zero.
+ (set_indent): Clamp indentation value to zero.
+
+2015-08-04 Kaz Kylheku <kaz@kylheku.com>
+
* stream.c (vormat): Bugfix: when width specified as *
meets a negative argument, the width should be treated
as positive and the field left aligned. Instead, the
diff --git a/stream.c b/stream.c
index a44db8db..7d425d38 100644
--- a/stream.c
+++ b/stream.c
@@ -2686,6 +2686,8 @@ val set_indent(val stream, val indent)
cobj_handle(stream, stream_s));
val oldval = num(s->indent_chars);
s->indent_chars = c_num(indent);
+ if (s->indent_chars < 0)
+ s->indent_chars = 0;
return oldval;
}
@@ -2696,6 +2698,8 @@ val inc_indent(val stream, val delta)
val oldval = num(s->indent_chars);
val col = num(s->column);
s->indent_chars = c_num(plus(delta, col));
+ if (s->indent_chars < 0)
+ s->indent_chars = 0;
return oldval;
}