From e4026ff797fbfc743ef7b40ba70d565444a6d113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 7 May 2012 22:23:05 -0400 Subject: [PATCH] scanner: Use indent() function in desc_dump() --- src/scanner.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/src/scanner.c b/src/scanner.c index 3fba0ade..257b54bc 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -138,10 +138,26 @@ uppercase_dup(const char *src) return u; } +static const char *indent(int n) +{ + const char *whitespace[] = { + "\t\t\t\t\t\t\t\t\t\t\t\t", + "\t\t\t\t\t\t\t\t\t\t\t\t ", + "\t\t\t\t\t\t\t\t\t\t\t\t ", + "\t\t\t\t\t\t\t\t\t\t\t\t ", + "\t\t\t\t\t\t\t\t\t\t\t\t ", + "\t\t\t\t\t\t\t\t\t\t\t\t ", + "\t\t\t\t\t\t\t\t\t\t\t\t ", + "\t\t\t\t\t\t\t\t\t\t\t\t " + }; + + return whitespace[n % 8] + 12 - n / 8; +} + static void desc_dump(char *src, int startcol) { - int i, j = 0, col = startcol, line = 0; + int i, col = startcol, line = 0; /* Strip leading space */ for (i = 0; isspace(src[i]); i++) @@ -156,14 +172,8 @@ desc_dump(char *src, int startcol) src[i] = ' '; if (col > 72 && isspace(src[i])) { - if (src[i+1]) { - putchar('\n'); - for (j = 0; j < startcol; j++) - putchar(' '); - putchar(' '); - putchar('*'); - putchar(' '); - } + if (src[i+1]) + printf("\n%s* ", indent(startcol + 1)); line++; col = startcol; } else { @@ -619,22 +629,6 @@ emit_event_wrappers(struct wl_list *message_list, struct interface *interface) } } -static const char *indent(int n) -{ - const char *whitespace[] = { - "\t\t\t\t\t\t\t\t\t\t\t\t", - "\t\t\t\t\t\t\t\t\t\t\t\t ", - "\t\t\t\t\t\t\t\t\t\t\t\t ", - "\t\t\t\t\t\t\t\t\t\t\t\t ", - "\t\t\t\t\t\t\t\t\t\t\t\t ", - "\t\t\t\t\t\t\t\t\t\t\t\t ", - "\t\t\t\t\t\t\t\t\t\t\t\t ", - "\t\t\t\t\t\t\t\t\t\t\t\t " - }; - - return whitespace[n % 8] + 12 - n / 8; -} - static void emit_enumerations(struct interface *interface) {