|
|
@ -19,18 +19,14 @@ static char *read_from_stdin() {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!buffer) {
|
|
|
|
size_t curlen = buffer ? strlen(buffer) : 0;
|
|
|
|
buffer = strdup(line);
|
|
|
|
buffer = realloc(buffer, curlen + strlen(line) + 2);
|
|
|
|
} else {
|
|
|
|
snprintf(buffer + curlen, strlen(line) + 2, "%s\n", line);
|
|
|
|
buffer = realloc(buffer, strlen(buffer) + strlen(line) + 2);
|
|
|
|
|
|
|
|
strcat(buffer, line);
|
|
|
|
|
|
|
|
strcat(buffer, "\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(line);
|
|
|
|
free(line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (buffer && buffer[strlen(buffer) - 1] == '\n') {
|
|
|
|
while (buffer && buffer[strlen(buffer) - 1] == '\n') {
|
|
|
|
buffer[strlen(buffer) - 1] = '\0';
|
|
|
|
buffer[strlen(buffer) - 1] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|