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 #endif
#define iseol(_c) ((_c) == '\n' || (_c) == '\r') #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) #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 plen = strlen(path);
size_t slen = strlen(suffix); size_t slen = strlen(suffix);
return (plen >= slen && return (plen >= slen && rstreq(path+plen-slen, suffix));
strcmp(path+plen-slen, suffix) == 0);
} }
char * rpmGetCwd(void) char * rpmGetCwd(void)

View File

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

View File

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

View File

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