[hackers] [lchat] filter/indent: properly reset textwidth on newlines || Ivo Cicchese

From: <git_AT_suckless.org>
Date: Thu, 20 Nov 2025 22:36:15 +0100 (CET)

commit 0837556c21869b36dba23d19c0e882a82be56106
Author: Ivo Cicchese <tizero_AT_autistici.org>
AuthorDate: Thu Nov 20 17:00:34 2025 +0100
Commit: Jan Klemkow <j.klemkow_AT_wemelug.de>
CommitDate: Thu Nov 20 22:34:25 2025 +0100

    filter/indent: properly reset textwidth on newlines

diff --git a/Makefile b/Makefile
index bb41165..be708ad 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -31,7 +31,7 @@ lchat.o: lchat.c
 
 filter: filter/indent
 filter/indent: filter/indent.c util.o util.h
- $(CC) $(CFLAGS) -o $_AT_ filter/indent.c util.o
+ $(CC) $(CFLAGS) -D_BSD_SOURCE -o $_AT_ filter/indent.c util.o
 
 sl_test.o: sl_test.c slackline.h
         $(CC) $(CFLAGS) -Wno-sign-compare -c -o $_AT_ sl_test.c
diff --git a/filter/indent.c b/filter/indent.c
index c9be0e9..9360281 100644
--- a/filter/indent.c
+++ b/filter/indent.c
_AT_@ -68,11 +68,10 @@ main(void)
                 /* print indented text */
                 while ((word = strsep(&next, " ")) != NULL) {
                         tw -= strlen(word) + 1;
- if (tw < 0 && !first) {
+ if (tw < 0 && !first)
                                 fputs("\n ", stdout);
- tw = cols - pw;
- first = true;
- }
+ if (tw < 0)
+ tw = cols - pw - strlen(word);
 
                         fputc(' ', stdout);
                         fputs(word, stdout);
Received on Thu Nov 20 2025 - 22:36:15 CET

This archive was generated by hypermail 2.3.0 : Thu Nov 20 2025 - 22:36:49 CET