From 4fa0843d4d2c86be0ff28eaa011e94d54b2ec5ba Mon Sep 17 00:00:00 2001 From: ampli Date: Thu, 23 Jan 2020 19:24:56 +0200 Subject: [PATCH] !!word/m: Prevent empty lines --- link-grammar/dict-common/print-dict.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/link-grammar/dict-common/print-dict.c b/link-grammar/dict-common/print-dict.c index bfc98f4c7a..56b6dceed6 100644 --- a/link-grammar/dict-common/print-dict.c +++ b/link-grammar/dict-common/print-dict.c @@ -89,7 +89,15 @@ static void print_expression_tag_end(Dictionary dict, dyn_str *e, const Exp *n, break; case Exptag_macro: if (*indent < 0) break; - dyn_strcat(e, "\n"); + /* The sole purpose of the checks before issuing "\n" is to prevent + * empty lines when printing connector macros w/o introducing a + * separate version of this function for connector macro printing. */ + if (dyn_strlen(e) > 0) + { + dyn_trimback(e); + if ((dyn_str_value(e)[dyn_strlen(e)-1]) != '\n') + dyn_strcat(e, "\n"); + } for(int i = 0; i < *indent - MACRO_INDENTATION/2; i++) dyn_strcat(e, " "); (*indent) -= MACRO_INDENTATION;