Introduce strbegins() macro and replace all open-coded instances

This test is done quite a bit across the tree, and the open-coded variants make it easy to have an
accidental mismatch between the length of the prefix being tested and the length actually passed to
strncmp().

This fixes an issue of that type comparing the server version against the prefix "u2.10", where the old
code used an incorrect length of 4.
This commit is contained in:
Kevin Easton
2017-06-06 23:47:10 +10:00
parent 09395464ff
commit 0a16ab16ac
14 changed files with 52 additions and 51 deletions

View File

@@ -263,7 +263,7 @@ static int i = 0;
return NULL;
while (fgets(buffer, 254, mail))
if (!strncmp(MAIL_DELIMITER, buffer, 5))
if (strbegins(buffer, MAIL_DELIMITER))
count++;
fclose(mail);