[PATCH 17/65] print_out: compare at start of line...

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Thu, 17 Apr 2014 15:43:25 +0200

.. also there is no need to create a new buffer

Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
---
 ii.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/ii.c b/ii.c
index 768cc00..9d3b6e0 100644
--- a/ii.c
+++ b/ii.c
_AT_@ -211,15 +211,18 @@ tokenize(char **result, size_t reslen, char *str, char delim) {
 
 static void
 print_out(char *channel, char *buf) {
-	char outfile[_POSIX_PATH_MAX] = "", server[IRC_CHANNEL_MAX + 6] = "";
+	char outfile[_POSIX_PATH_MAX] = "";
 	char buft[18] = "";
 	FILE *out = NULL;
 	time_t t = time(NULL);
 
-	if(channel)
-		snprintf(server, sizeof(server), "-!- %s", channel);
-	if(strstr(buf, server))
+	/* starts with "-!- " channel */
+	if(channel && !strncmp(buf, "-!- ", 4) &&
+	   !strncmp(&buf[4], channel, strlen(channel)))
+	{
+		printf("channel set to empty string\n");
 		channel = "";
+	}
 	create_filepath(outfile, sizeof(outfile), channel, "out");
 	if(!(out = fopen(outfile, "a")))
 		return;
-- 
2.4.10
--Multipart=_Mon__9_May_2016_17_21_10_+0200_I.6cpFVydhq75aaE
Content-Type: text/x-diff;
 name="0018-time-format-Y-m-d-H-M-is-more-familiar.patch"
Content-Disposition: attachment;
 filename="0018-time-format-Y-m-d-H-M-is-more-familiar.patch"
Content-Transfer-Encoding: 7bit
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Mon May 09 2016 - 17:24:22 CEST