From 750cc25f32f27eacc90177fbacd064bac05ac4d9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 14 Sep 2014 07:59:15 -0700 Subject: Fix broken one-letter commands. In this idiotic program, one-letter commands like .B arg or .B are blindly encoded as a two byte code and so they have two codes, based on whether the name is followed by a space or newline. We must preserve this behavior in the str_to_code function, or else fix numerous places. --- man2html/man2html.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/man2html/man2html.c b/man2html/man2html.c index 98f7993..ca014c0 100644 --- a/man2html/man2html.c +++ b/man2html/man2html.c @@ -105,11 +105,19 @@ expand_string(int nr) static int str_to_code(char *str) { - int code = 0; + int code = 0, count = 0; + while (*str && !isspace(*str)) { code *= 256; code += *str++; + count++; } + + if (count == 1) { + code *= 256; + code += ' '; + } + return code; } -- cgit v1.2.3