summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-02-05 00:06:02 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2016-02-05 00:06:02 -0800
commit555472cf8d1ffe99506fdbd2a87e2e33bb3b197f (patch)
treebeabf7ac93ee86838b2c4592d478e6f652b16172
parentcdb0a5e8602ce2475555c48c9f285e736ccb22ef (diff)
Fixed tabs in indentation.
Closes #101. This patch fixes `S_advance_offset` so that it doesn't gobble a tab character when advancing less than the width of a tab.
-rw-r--r--man/man3/cmark.314
-rw-r--r--src/blocks.c8
2 files changed, 12 insertions, 10 deletions
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
index 33f152b..bffe73d 100644
--- a/man/man3/cmark.3
+++ b/man/man3/cmark.3
@@ -1,4 +1,4 @@
-.TH cmark 3 "January 11, 2016" "LOCAL" "Library Functions Manual"
+.TH cmark 3 "February 02, 2016" "LOCAL" "Library Functions Manual"
.SH
NAME
.PP
@@ -363,8 +363,8 @@ otherwise 0.
\fIint\f[] \fBcmark_node_set_list_start\f[](\fIcmark_node *node\f[], \fIint start\f[])
.PP
-Sets starting number of \f[I]node\f[], if it is an ordered list. Returns
-1 on success, 0 on failure.
+Sets starting number of \f[I]node\f[], if it is an ordered list.
+Returns 1 on success, 0 on failure.
.PP
\fIint\f[] \fBcmark_node_get_list_tight\f[](\fIcmark_node *node\f[])
@@ -389,8 +389,8 @@ Returns the info string from a fenced code block.
\fIint\f[] \fBcmark_node_set_fence_info\f[](\fIcmark_node *node\f[], \fIconst char *info\f[])
.PP
-Sets the info string in a fenced code block, returning 1 on success and
-0 on failure.
+Sets the info string in a fenced code block, returning 1 on success
+and 0 on failure.
.PP
\fIconst char *\f[] \fBcmark_node_get_url\f[](\fIcmark_node *node\f[])
@@ -517,8 +517,8 @@ Returns 1 on success, 0 on failure.
\fIint\f[] \fBcmark_node_append_child\f[](\fIcmark_node *node\f[], \fIcmark_node *child\f[])
.PP
-Adds \f[I]child\f[] to the end of the children of \f[I]node\f[]. Returns
-1 on success, 0 on failure.
+Adds \f[I]child\f[] to the end of the children of \f[I]node\f[].
+Returns 1 on success, 0 on failure.
.PP
\fIvoid\f[] \fBcmark_consolidate_text_nodes\f[](\fIcmark_node *root\f[])
diff --git a/src/blocks.c b/src/blocks.c
index 9f41e1f..6d02a84 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -570,12 +570,14 @@ static void S_advance_offset(cmark_parser *parser, cmark_chunk *input,
bufsize_t count, bool columns) {
char c;
int chars_to_tab;
+ int chars_to_advance;
while (count > 0 && (c = peek_at(input, parser->offset))) {
if (c == '\t') {
chars_to_tab = TAB_STOP - (parser->column % TAB_STOP);
- parser->column += chars_to_tab;
- parser->offset += 1;
- count -= (columns ? chars_to_tab : 1);
+ chars_to_advance = chars_to_tab > count ? count : chars_to_tab;
+ parser->column += chars_to_advance;
+ parser->offset += chars_to_advance < chars_to_tab ? 0 : 1;
+ count -= (columns ? chars_to_advance : 1);
} else {
parser->offset += 1;
parser->column += 1; // assume ascii; block starts are ascii