Skip to content

Instantly share code, notes, and snippets.

@siefca
Last active August 5, 2021 11:09
Show Gist options
  • Save siefca/03cf5a90280c28342081da5f2b1f03bd to your computer and use it in GitHub Desktop.
Save siefca/03cf5a90280c28342081da5f2b1f03bd to your computer and use it in GitHub Desktop.
streq
#include <string.h>
#undef streq
#ifndef STREQ
# define STREQ streq
#endif
int
STREQ (const char *p1, const char *p2)
{
const unsigned char *s1 = (const unsigned char *) p1;
const unsigned char *s2 = (const unsigned char *) p2;
unsigned char c1, c2;
do
{
c1 = (unsigned char) *s1++;
c2 = (unsigned char) *s2++;
}
while (c1 == c2 && c1 != '\0');
return (c1 == c2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment