commit a3a853c548bca2f2513f49a6f04e3c953468fb6d
parent 9744a539ab8dd477b35577dc096a15a783e1f641
Author: Drew DeVault <sir@cmpwn.com>
Date: Mon, 14 May 2018 18:38:23 -0400
Fix dashes in preamable
Fixes https://todo.sr.ht/~sircmpwn/scdoc/9
Diffstat:
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -47,7 +47,7 @@ static void parse_preamble(struct parser *p) {
struct tm *now_tm = localtime(&now);
strftime(date, sizeof(date), "%F", now_tm);
while ((ch = parser_getch(p)) != UTF8_INVALID) {
- if (ch < 0x80 && isalnum(ch)) {
+ if ((ch < 0x80 && isalnum(ch)) || ch == '_' || ch == '-') {
assert(str_append_ch(name, ch) != -1);
} else if (ch == '(') {
section = parse_section(p);
diff --git a/test/preamble b/test/preamble
@@ -15,7 +15,7 @@ end 1
begin "Expects name to alphanumeric"
scdoc <<EOF >/dev/null
-____(8)
+!!!!(8)
EOF
end 1
@@ -42,3 +42,9 @@ scdoc <<EOF | grep '^\.TH "test" "8" "'"$(date +'%F')"'"' >/dev/null
test(8)
EOF
end 0
+
+begin "Preserves dashes"
+scdoc <<EOF | grep '^\.TH "test-manual" "8" "'"$(date +'%F')"'"' >/dev/null
+test-manual(8)
+EOF
+end 0