mirror of
https://github.com/swaywm/sway.git
synced 2024-12-27 23:47:21 +01:00
swaynag: don't drop \n for first line
This commit is contained in:
parent
41d858b439
commit
26c5ef18ba
1 changed files with 4 additions and 8 deletions
|
@ -19,18 +19,14 @@ static char *read_from_stdin() {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!buffer) {
|
||||
buffer = strdup(line);
|
||||
} else {
|
||||
buffer = realloc(buffer, strlen(buffer) + strlen(line) + 2);
|
||||
strcat(buffer, line);
|
||||
strcat(buffer, "\n");
|
||||
}
|
||||
size_t curlen = buffer ? strlen(buffer) : 0;
|
||||
buffer = realloc(buffer, curlen + strlen(line) + 2);
|
||||
snprintf(buffer + curlen, strlen(line) + 2, "%s\n", line);
|
||||
|
||||
free(line);
|
||||
}
|
||||
|
||||
if (buffer && buffer[strlen(buffer) - 1] == '\n') {
|
||||
while (buffer && buffer[strlen(buffer) - 1] == '\n') {
|
||||
buffer[strlen(buffer) - 1] = '\0';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue