commit 84e46ded31ebc3df3c9dd6171ee7c0c79d7af68d
parent bd924fa2ec29d96d3538e975b34c2f7c2105a670
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 10 Dec 2017 12:00:00 -0500
Improve list output
Diffstat:
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,6 +1,6 @@
VERSION=1.0.0
CC=cc
-CFLAGS=-DVERSION='"$(VERSION)"' -Wall -Wextra -Werror -Wno-unused-parameter -std=c99 -pedantic
+CFLAGS=-DVERSION='"$(VERSION)"' -Wall -Wextra -Werror -Wno-unused-parameter
LDFLAGS=-static
INCLUDE=-Iinclude
PREFIX=/usr/local
@@ -23,7 +23,7 @@ OBJECTS=\
.build/%.o: src/%.c
@mkdir -p .build
- $(CC) -std=c99 -c -o $@ $(CFLAGS) $(INCLUDE) $<
+ $(CC) -std=c99 -pedantic -c -o $@ $(CFLAGS) $(INCLUDE) $<
scdoc: $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^
diff --git a/src/main.c b/src/main.c
@@ -171,18 +171,29 @@ static int parse_indent(struct parser *p, int *indent, bool write) {
} else if (i != *indent && ch == '\t') {
parser_fatal(p, "Indented by an amount greater than 1");
}
+ *indent = i;
}
- *indent = i;
return i;
}
+static void list_header(struct parser *p, const char *sym) {
+ roff_macro(p, "RS", "4", NULL);
+ fprintf(p->output, ".ie n \\{\\\n");
+ fprintf(p->output, "\\h'-04'%s\\h'+03'\\c\n", sym);
+ fprintf(p->output, ".\\}\n");
+ fprintf(p->output, ".el \\{\\\n");
+ roff_macro(p, "IP", sym, "4", NULL);
+ fprintf(p->output, ".\\}\n");
+}
+
static void parse_list(struct parser *p, int *indent) {
uint32_t ch;
if ((ch = parser_getch(p)) != ' ') {
parser_fatal(p, "Expected space before start of list entry");
}
- roff_macro(p, "IP", "\\(bu", "4", NULL);
+ list_header(p, "\\(bu");
parse_text(p);
+ roff_macro(p, "RE", NULL);
do {
parse_indent(p, indent, true);
if ((ch = parser_getch(p)) == UTF8_INVALID) {
@@ -195,9 +206,9 @@ static void parse_list(struct parser *p, int *indent) {
if ((ch = parser_getch(p)) != ' ') {
parser_fatal(p, "Expected space before start of list entry");
}
- fprintf(p->output, ".sp -1\n");
- roff_macro(p, "IP", "\\(bu", "4", NULL);
+ list_header(p, "\\(bu");
parse_text(p);
+ roff_macro(p, "RE", NULL);
break;
default:
fprintf(p->output, "\n");