lchat

A line oriented chat front end for ii.
git clone git://git.suckless.org/lchat
Log | Files | Refs | README

commit 6ac420add96b2b3df6364d2c0d170ae8b0d41af5
parent 7effd7e7013dd385bf4cd6d4fbaea28475ab4886
Author: Tom Schwindl <schwindl@posteo.de>
Date:   Tue,  6 Sep 2022 17:30:39 +0200

lchat: Do not implement bell_match() twice, use `util.h' instead

Diffstat:
MMakefile | 6+++---
Mlchat.c | 24+-----------------------
2 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/Makefile b/Makefile @@ -16,8 +16,8 @@ uninstall: test: sl_test ./sl_test -lchat: lchat.o slackline.o - $(CC) -o $@ lchat.o slackline.o $(LIBS) +lchat: lchat.o slackline.o util.o + $(CC) -o $@ lchat.o slackline.o util.o $(LIBS) lchat.o: lchat.c $(CC) -c $(CFLAGS) -D_BSD_SOURCE -D_XOPEN_SOURCE -D_GNU_SOURCE \ @@ -37,4 +37,4 @@ slackline.o: slackline.c slackline.h $(CC) -c $(CFLAGS) -o $@ slackline.c util.o: util.c util.h - $(CC) -c $(CFLAGS) -o $@ util.c + $(CC) -c $(CFLAGS) -D_BSD_SOURCE -o $@ util.c diff --git a/lchat.c b/lchat.c @@ -31,6 +31,7 @@ #include <unistd.h> #include "slackline.h" +#include "util.h" #ifndef INFTIM #define INFTIM -1 @@ -82,29 +83,6 @@ read_file_line(const char *file) return line; } -static bool -bell_match(const char *str, const char *regex_file) -{ - FILE *fh = NULL; - char cmd[BUFSIZ]; - - if (access(regex_file, R_OK) == -1) - return true; - - snprintf(cmd, sizeof cmd, "exec grep -qf %s", regex_file); - - if ((fh = popen(cmd, "w")) == NULL) - err(EXIT_FAILURE, "popen"); - - if (fputs(str, fh) == EOF) - err(EXIT_FAILURE, "fputs"); - - if (pclose(fh) == 0) - return true; - - return false; -} - static void line_output(struct slackline *sl, char *file) {