Improve formatting
This commit is contained in:
parent
d1f2b6e25f
commit
014d2ab62c
|
@ -3,30 +3,17 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
int second = 0;
|
||||
static char *buf = NULL;
|
||||
static size_t size = 0;
|
||||
ssize_t len = 0;
|
||||
for (long n=1; (len = getline(&buf, &size, stdin)) > 0; n++)
|
||||
long n = 1;
|
||||
while(getline(&buf, &size, stdin) > 0)
|
||||
{
|
||||
if (n < 5)
|
||||
if (n++ < 5) /* overflow possible */
|
||||
continue;
|
||||
if (len && buf[len - 1] == '\n')
|
||||
buf[len - 1] = '\0';
|
||||
if (strncmp(buf,"-->", 3) == 0)
|
||||
{
|
||||
if (second)
|
||||
{
|
||||
second = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
putchar('\n');
|
||||
second = 1;
|
||||
}
|
||||
}
|
||||
else if (buf[0] != 0) /* Don't print newline at EOF */
|
||||
puts(buf);
|
||||
else if (buf[0] != 10)
|
||||
fputs(buf, stdout);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
10
popup.c
10
popup.c
|
@ -62,7 +62,7 @@ int get_max_len(char *string, XftFont *font, int max_text_width)
|
|||
eol--;
|
||||
}
|
||||
|
||||
for (int i = 0; i < eol; i++)
|
||||
for (int i = 0; i < MIN(eol+1, strlen(string)); i++)
|
||||
if (string[i] == '\n')
|
||||
{
|
||||
string[i] = ' ';
|
||||
|
@ -73,11 +73,9 @@ int get_max_len(char *string, XftFont *font, int max_text_width)
|
|||
while (eol && (string[eol] & 0xC0) == 0x80)
|
||||
--eol;
|
||||
|
||||
if (info.width <= max_text_width)
|
||||
return eol;
|
||||
|
||||
|
||||
/* prefer splitting at spaces */
|
||||
/* uncomment to always split at spaces */
|
||||
/* if (info.width <= max_text_width) */
|
||||
/* return eol; */
|
||||
/* int temp = eol; */
|
||||
/* while (string[eol] != ' ' && eol) */
|
||||
/* --eol; */
|
||||
|
|
Loading…
Reference in a new issue