Replace equal/not equal uses of str[n]cmp() with rstreq[n] in io code

This commit is contained in:
Panu Matilainen 2009-08-31 11:15:16 +03:00
parent 0c4e48de79
commit f4b39519d3
5 changed files with 8 additions and 10 deletions

View File

@ -10,7 +10,7 @@
#endif
#define iseol(_c) ((_c) == '\n' || (_c) == '\r')
#define STREQ(_t, _f, _fn) ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn)))
#define STREQ(_t, _f, _fn) ((_fn) == (sizeof(_t)-1) && rstreqn((_t), (_f), (_fn)))
#define MACROBUFSIZ (BUFSIZ * 2)

View File

@ -696,8 +696,7 @@ int rpmFileHasSuffix(const char *path, const char *suffix)
{
size_t plen = strlen(path);
size_t slen = strlen(suffix);
return (plen >= slen &&
strcmp(path+plen-slen, suffix) == 0);
return (plen >= slen && rstreq(path+plen-slen, suffix));
}
char * rpmGetCwd(void)

View File

@ -97,7 +97,7 @@ static int rpmhookTableFindBucket(rpmhookTable *table, const char *name)
ret = hash % (*table)->size;
bucket = &(*table)->bucket[ret];
while (bucket->name &&
(bucket->hash != hash || strcmp(bucket->name, name) != 0)) {
(bucket->hash != hash || !rstreq(bucket->name, name))) {
/* Collision resolution based on Python's perturb scheme. */
ret = ((ret << 2) + ret + perturb + 1) % (*table)->size;
perturb >>= 5;

View File

@ -286,7 +286,7 @@ int pgpValTok(pgpValTbl vs, const char * s, const char * se)
{
do {
size_t vlen = strlen(vs->str);
if (vlen <= (se-s) && !strncmp(s, vs->str, vlen))
if (vlen <= (se-s) && rstreqn(s, vs->str, vlen))
break;
} while ((++vs)->val != -1);
return vs->val;
@ -1436,7 +1436,7 @@ pgpArmor pgpReadPkts(const char * fn, uint8_t ** pkt, size_t * pktlen)
goto exit;
}
#define TOKEQ(_s, _tok) (!strncmp((_s), (_tok), sizeof(_tok)-1))
#define TOKEQ(_s, _tok) (rstreqn((_s), (_tok), sizeof(_tok)-1))
for (t = (char *)b; t && *t; t = te) {
if ((te = strchr(t, '\n')) == NULL)
@ -1498,8 +1498,7 @@ pgpArmor pgpReadPkts(const char * fn, uint8_t ** pkt, size_t * pktlen)
if (armortype == NULL) /* XXX can't happen */
continue;
rc = strncmp(t, armortype, strlen(armortype));
if (rc)
if (!rstreqn(t, armortype, strlen(armortype))
continue;
t += strlen(armortype);

View File

@ -81,11 +81,11 @@ urltype urlIsURL(const char * url)
if (url && *url) {
for (us = urlstrings; us->leadin != NULL; us++) {
if (strncmp(url, us->leadin, strlen(us->leadin)))
if (!rstreqn(url, us->leadin, strlen(us->leadin)))
continue;
return us->ret;
}
if (strcmp(url, "-") == 0)
if (rstreq(url, "-"))
return URL_IS_DASH;
}