diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-07 22:23:05 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-07 22:38:23 -0400 |
commit | e4026ff797fbfc743ef7b40ba70d565444a6d113 (patch) | |
tree | 53e629eddee9ee7839f9d9dd880781ced6e2675a | |
parent | 3f7048e0e99af50fe3555ab3f61f0ef1292959e4 (diff) |
scanner: Use indent() function in desc_dump()
-rw-r--r-- | src/scanner.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/src/scanner.c b/src/scanner.c index 3fba0ad..257b54b 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) { |