commit 6ac420add96b2b3df6364d2c0d170ae8b0d41af5
Author:     Tom Schwindl <[email protected]>
AuthorDate: Tue Sep 6 17:30:39 2022 +0200
Commit:     Jan Klemkow <[email protected]>
CommitDate: Tue Sep 20 17:12:54 2022 +0200

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

diff --git a/Makefile b/Makefile
index cc24402..24ef10c 100644
--- 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
index 3d820c2..714c194 100644
--- 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)
 {

Reply via email to