output blocks up to double-spaces

This commit is contained in:
Loic Nageleisen 2013-02-01 21:39:38 +01:00
parent e4bef3fbe0
commit 9916ebe0bc

15
main.c
View file

@ -80,16 +80,15 @@ void Post_printf(Post *self) {
char *nosp = NULL;
for (char *buf = self->body; *buf != '\0'; buf++) {
if (*buf != ' ') {
nosp = nosp == NULL ? buf : nosp;
if (*buf == '\n') {
printf("\n");
} else {
if (nosp != NULL) {
fwrite(nosp, sizeof(char), buf - nosp, stdout);
nosp = NULL;
nosp = nosp == NULL ? buf : nosp;
}
if (*(buf+1) != ' ' &&
*(buf+1) != '\0' &&
*(buf+1) != '\n') {
printf(" ");
} else {
if (nosp != NULL && *(buf+1) == ' ') {
fwrite(nosp, sizeof(char), buf+1 - nosp, stdout);
nosp = NULL;
}
}
}