diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2025-07-12 11:13:22 -0400 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2025-07-12 11:13:22 -0400 |
| commit | a9dd71ffaca74346d5e3b8789a0da769ca0d890a (patch) | |
| tree | 792e05bfed01bc3e361009bb31622cdf6cce0567 /src/main.c | |
| parent | Use exit code 0 for -h (diff) | |
| download | cli-a9dd71ffaca74346d5e3b8789a0da769ca0d890a.zip | |
Refactor usage of linebuffer to avoid using internal _num_words
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -43,7 +43,7 @@ int main(int argc, char *argv[]) { int justify(size_t linebuffer_capacity, FILE *in, FILE *out) { const size_t MAX_WORD_LENGTH = linebuffer_capacity; - char word[MAX_WORD_LENGTH + 2]; + char word[MAX_WORD_LENGTH + 1]; size_t word_length; int read_word_result; LineBuffer *lb = linebuffer_create(linebuffer_capacity); @@ -72,7 +72,7 @@ int justify(size_t linebuffer_capacity, FILE *in, FILE *out) { fprintf(stderr, "Error reading word\n"); return EXIT_FAILURE; } - if (lb->_num_words > 0) { + if (linebuffer_space_remaining(lb) < linebuffer_capacity) { linebuffer_write(lb, out); } linebuffer_destroy(lb); |