diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2024-07-04 10:39:16 -0400 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2024-07-04 10:39:16 -0400 |
| commit | e61179fe37a64e5d9ad8d9cd03f66302bbb79a35 (patch) | |
| tree | 760df4436d179da5a1cdce125f3eb742499ac9aa /src/main.c | |
| parent | Add cmake and clang format (diff) | |
| download | cli-e61179fe37a64e5d9ad8d9cd03f66302bbb79a35.zip | |
Format files
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 41 |
1 files changed, 20 insertions, 21 deletions
@@ -1,8 +1,8 @@ +#include "linebuffer.h" +#include "word.h" #include <stdbool.h> #include <stdio.h> #include <string.h> -#include "linebuffer.h" -#include "word.h" #define MAX_WORD_LENGTH 20 @@ -13,24 +13,23 @@ int main(void) { LineBuffer *lb = linebuffer_create(40); while (true) { - err = read_word(stdin, word, MAX_WORD_LENGTH + 1); - if (err == EOF) { - printf("Error reading word\n"); - return 1; - } - word_length = strlen(word); - if (word_length == 0) { - linebuffer_write(lb, stdout); - return 0; - } - if (word_length > MAX_WORD_LENGTH) { - word[MAX_WORD_LENGTH] = '*'; - } - if (word_length + 1 > linebuffer_space_remaining(lb)) { - linebuffer_write_justified(lb, stdout); - linebuffer_clear(lb); - } - linebuffer_append_word(lb, word); + err = read_word(stdin, word, MAX_WORD_LENGTH + 1); + if (err == EOF) { + printf("Error reading word\n"); + return 1; + } + word_length = strlen(word); + if (word_length == 0) { + linebuffer_write(lb, stdout); + return 0; + } + if (word_length > MAX_WORD_LENGTH) { + word[MAX_WORD_LENGTH] = '*'; + } + if (word_length + 1 > linebuffer_space_remaining(lb)) { + linebuffer_write_justified(lb, stdout); + linebuffer_clear(lb); + } + linebuffer_append_word(lb, word); } } - |