mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-03 09:01:42 -05:00
scanner: Fix desc_dump() to not extend beyond column 72
This commit is contained in:
parent
e4026ff797
commit
5b0d8f09af
1 changed files with 11 additions and 17 deletions
|
|
@ -157,29 +157,23 @@ static const char *indent(int n)
|
||||||
static void
|
static void
|
||||||
desc_dump(char *src, int startcol)
|
desc_dump(char *src, int startcol)
|
||||||
{
|
{
|
||||||
int i, col = startcol, line = 0;
|
int i, j, col = startcol;
|
||||||
|
|
||||||
/* Strip leading space */
|
for (i = 0; src[i]; i++) {
|
||||||
for (i = 0; isspace(src[i]); i++)
|
if (isspace(src[i]))
|
||||||
;
|
|
||||||
|
|
||||||
for (; src[i]; i++) {
|
|
||||||
/* Collapse multiple spaces into 1 */
|
|
||||||
if (isspace(src[i]) && isspace(src[i + 1]))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (isspace(src[i]))
|
j = i;
|
||||||
src[i] = ' ';
|
while (src[i] && !isspace(src[i]))
|
||||||
|
i++;
|
||||||
|
|
||||||
if (col > 72 && isspace(src[i])) {
|
if (col + i - j > 72) {
|
||||||
if (src[i+1])
|
printf("\n%s * ", indent(startcol));
|
||||||
printf("\n%s* ", indent(startcol + 1));
|
|
||||||
line++;
|
|
||||||
col = startcol;
|
col = startcol;
|
||||||
} else {
|
|
||||||
putchar(src[i]);
|
|
||||||
col++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
col += printf("%s%.*s",
|
||||||
|
col > startcol ? " " : "", i - j, &src[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue