Update comment and use correct string for strlen()

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2017-12-27 00:35:38 +01:00
parent bc3d1f1c2e
commit 372dbca40a
+5 -4
View File
@@ -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++;
}
}