diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-08-04 21:19:30 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-08-04 21:19:30 -0700 |
commit | 8a702d43a463472474e9f0adab6858a1637c2a1f (patch) | |
tree | 20b3e71b89838b3cb8fc6a13933985349c3946da | |
parent | c3b2ec8a4d4eb7419a748b939da7657e01aada99 (diff) | |
download | txr-8a702d43a463472474e9f0adab6858a1637c2a1f.tar.gz txr-8a702d43a463472474e9f0adab6858a1637c2a1f.tar.bz2 txr-8a702d43a463472474e9f0adab6858a1637c2a1f.zip |
* stream.c (put_string): In indent mode, put_string has
to process all the characters as if by put_char,
(which we now do literally that way).
(set_indent_mode): Bugfix: no longer reset the column
to zero when turning off indent mode. This is wrong since
streams do column counting all the time.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | stream.c | 13 |
2 files changed, 16 insertions, 6 deletions
@@ -1,5 +1,14 @@ 2015-08-04 Kaz Kylheku <kaz@kylheku.com> + * stream.c (put_string): In indent mode, put_string has + to process all the characters as if by put_char, + (which we now do literally that way). + (set_indent_mode): Bugfix: no longer reset the column + to zero when turning off indent mode. This is wrong since + streams do column counting all the time. + +2015-08-04 Kaz Kylheku <kaz@kylheku.com> + * stream.c (vformat): Implement ~! format directive for indentation. Allow negative widths to be specified with a leading minus sign, so that we can indent to the left. @@ -2568,19 +2568,21 @@ val put_string(val string, val stream_in) cnum col = s->column; const wchar_t *str = c_str(string), *p = str; + if (s->indent_mode != indent_off) { + while (*str) + put_char(chr(*str++), stream); + return t; + } + for (; *p; p++) { switch (*p) { case '\n': col = 0; break; case '\t': - if (s->indent_mode != indent_off && col == 0) - col = s->indent_chars; col = (col + 1) | 7; break; default: - if (s->indent_mode != indent_off && col == 0) - col = s->indent_chars; if (iswprint(*p)) col++; break; @@ -2709,8 +2711,7 @@ val set_indent_mode(val stream, val mode) struct strm_base *s = coerce(struct strm_base *, cobj_handle(stream, stream_s)); val oldval = num_fast(s->indent_mode); - if ((s->indent_mode = (enum indent_mode) c_num(mode)) == indent_off) - s->column = 0; + s->indent_mode = (enum indent_mode) c_num(mode); return oldval; } |