From 372dbca40a79cd62fca58ef549798385e70c6264 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 27 Dec 2017 00:35:38 +0100 Subject: [PATCH] Update comment and use correct string for strlen() Signed-off-by: DL6ER --- grep.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/grep.c b/grep.c index fb24b787..17e27fa4 100644 --- a/grep.c +++ b/grep.c @@ -187,7 +187,8 @@ int countlineswith(const char* str, const char* fname) } // Search through file - // getline reads a string from the specified file up to either a newline character or EOF + // getline reads a string from the specified file up to either a + // newline character or EOF while(getline(&buffer, &size, fp) != -1) { // Strip potential newline character at the end of line we just read @@ -211,10 +212,10 @@ int countlineswith(const char* str, const char* fname) // These functions return a pointer to the beginning of // the located substring, or NULL if the substring is not // found. Hence, we compare the length of the substring to - // the wildcard entry to determine if there is anything - // behind the wildcard. This avoids that given + // the wildcard entry to rule out the possiblity that + // there is anything behind the wildcard. This avoids that given // "*example.com" "example.com.xxxxx" would also match. - if(buf != NULL && strlen(buf) == strlen(str)) + if(buf != NULL && strlen(buf) == strlen(buffer+1)) found++; } }