From 84e46ded31ebc3df3c9dd6171ee7c0c79d7af68d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 10 Dec 2017 12:00:00 -0500 Subject: [PATCH] Improve list output --- Makefile | 4 ++-- src/main.c | 19 +++++++++++++++---- diff --git a/Makefile b/Makefile index 346d873196cebf3ee2240caba2d6f9f51b6dc0ee..87c8817a353ed4a34b9d2b285b90401f08e12633 100644 --- 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 @@ .build/util.o .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 index a70283b93bcfd711643556d74061f0373e4f4da7..b57c962c6d90393e223fbdd00b33c56df79702d9 100644 --- a/src/main.c +++ b/src/main.c @@ -171,18 +171,29 @@ roff_macro(p, "RS", "4", NULL); } 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 @@ case '-': 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"); -- 2.48.1