summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-03-09 13:13:07 -0700
committerKarl Williamson <khw@cpan.org>2017-10-24 08:14:08 -0600
commit083b2a61ee6281f67b6d6a21ad5d27e6219df60f (patch)
tree19277306a3682affdd69bcc12a1e4b1c58306ca0
parent5bad3c4f3a4515aaa622eecdf6f5a84fcaff7ed9 (diff)
downloadperl-083b2a61ee6281f67b6d6a21ad5d27e6219df60f.tar.gz
Convert strcmp into strEQ, strNE
The latter two are easier to read
-rw-r--r--cygwin/cygwin.c8
-rw-r--r--ext/DynaLoader/dl_aix.xs4
-rw-r--r--ext/DynaLoader/dl_win32.xs2
-rw-r--r--ext/Hash-Util-FieldHash/FieldHash.xs2
-rw-r--r--ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm2
-rw-r--r--ext/POSIX/POSIX.xs2
-rw-r--r--ext/POSIX/lib/POSIX.pm2
-rw-r--r--ext/XS-APItest/APItest.pm2
-rw-r--r--ext/XS-APItest/APItest.xs6
-rw-r--r--symbian/symbian_stubs.c4
-rw-r--r--vms/vms.c49
-rw-r--r--win32/win32.c2
12 files changed, 40 insertions, 45 deletions
diff --git a/cygwin/cygwin.c b/cygwin/cygwin.c
index 24b278f2fd..7bcf02ab34 100644
--- a/cygwin/cygwin.c
+++ b/cygwin/cygwin.c
@@ -488,7 +488,7 @@ XS(XS_Cygwin_mount_flags)
pathname = SvPV_nolen(ST(0));
- if (!strcmp(pathname, "/cygdrive")) {
+ if (strEQ(pathname, "/cygdrive")) {
char user[PATH_MAX];
char system[PATH_MAX];
char user_flags[PATH_MAX];
@@ -511,7 +511,7 @@ XS(XS_Cygwin_mount_flags)
int found = 0;
setmntent (0, 0);
while ((mnt = getmntent (0))) {
- if (!strcmp(pathname, mnt->mnt_dir)) {
+ if (strEQ(pathname, mnt->mnt_dir)) {
strcpy(flags, mnt->mnt_type);
if (strlen(mnt->mnt_opts) > 0) {
strcat(flags, ",");
@@ -536,12 +536,12 @@ XS(XS_Cygwin_mount_flags)
user_flags, system_flags);
if (strlen(user) > 0) {
- if (strcmp(user,pathname)) {
+ if (strNE(user,pathname)) {
sprintf(flags, "%s,cygdrive,%s", user_flags, user);
found++;
}
} else {
- if (strcmp(user,pathname)) {
+ if (strNE(user,pathname)) {
sprintf(flags, "%s,cygdrive,%s", system_flags, system);
found++;
}
diff --git a/ext/DynaLoader/dl_aix.xs b/ext/DynaLoader/dl_aix.xs
index 8e7d8ac0a5..54a8e3db13 100644
--- a/ext/DynaLoader/dl_aix.xs
+++ b/ext/DynaLoader/dl_aix.xs
@@ -226,7 +226,7 @@ void *dlopen(char *path, int mode)
* Scan the list of modules if have the module already loaded.
*/
for (mp = dl_modList; mp; mp = mp->next)
- if (strcmp(mp->name, path) == 0) {
+ if (strEQ(mp->name, path)) {
mp->refCnt++;
return mp;
}
@@ -364,7 +364,7 @@ void *dlsym(void *handle, const char *symbol)
* the result to function pointers anyways.
*/
for (ep = mp->exports, i = mp->nExports; i; i--, ep++)
- if (strcmp(ep->name, symbol) == 0)
+ if (strEQ(ep->name, symbol))
return ep->addr;
dl_errvalid++;
strcpy(dl_errbuf, "dlsym: undefined symbol ");
diff --git a/ext/DynaLoader/dl_win32.xs b/ext/DynaLoader/dl_win32.xs
index 9c5b809470..b076f2141c 100644
--- a/ext/DynaLoader/dl_win32.xs
+++ b/ext/DynaLoader/dl_win32.xs
@@ -102,7 +102,7 @@ dl_static_linked(char *filename)
if (hptr = strstr(ptr, *p)) {
/* found substring, need more detailed check if module name match */
if (hptr==ptr) {
- return strcmp(ptr, *p)==0;
+ return strEQ(ptr, *p);
}
if (hptr[strlen(*p)] == 0)
return hptr[-1]=='/';
diff --git a/ext/Hash-Util-FieldHash/FieldHash.xs b/ext/Hash-Util-FieldHash/FieldHash.xs
index 2fcb612525..9cfd87a694 100644
--- a/ext/Hash-Util-FieldHash/FieldHash.xs
+++ b/ext/Hash-Util-FieldHash/FieldHash.xs
@@ -431,7 +431,7 @@ OUTPUT:
void
CLONE(char* classname)
CODE:
- if (0 == strcmp(classname, "Hash::Util::FieldHash")) {
+ if (strEQ(classname, "Hash::Util::FieldHash")) {
HUF_global(aTHX_ HUF_CLONE);
HUF_fix_objects(aTHX);
}
diff --git a/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm b/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm
index 0d0b7921c3..7b39cca450 100644
--- a/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm
+++ b/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Scalar::Util qw( reftype);
-our $VERSION = '1.19';
+our $VERSION = '1.20';
require Exporter;
our @ISA = qw(Exporter);
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index e52fa5b0e0..3bfeb6c80a 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -1791,7 +1791,7 @@ fix_win32_tzenv(void)
perl_tz_env = "";
if (crt_tz_env == NULL)
crt_tz_env = "";
- if (strcmp(perl_tz_env, crt_tz_env) != 0) {
+ if (strNE(perl_tz_env, crt_tz_env)) {
newenv = (char*)malloc((strlen(perl_tz_env) + 4) * sizeof(char));
if (newenv != NULL) {
sprintf(newenv, "TZ=%s", perl_tz_env);
diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm
index 2fd13c2225..ff61981aee 100644
--- a/ext/POSIX/lib/POSIX.pm
+++ b/ext/POSIX/lib/POSIX.pm
@@ -4,7 +4,7 @@ use warnings;
our ($AUTOLOAD, %SIGRT);
-our $VERSION = '1.79';
+our $VERSION = '1.80';
require XSLoader;
diff --git a/ext/XS-APItest/APItest.pm b/ext/XS-APItest/APItest.pm
index d4edcac51a..cdc7e5c380 100644
--- a/ext/XS-APItest/APItest.pm
+++ b/ext/XS-APItest/APItest.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Carp;
-our $VERSION = '0.92';
+our $VERSION = '0.93';
require XSLoader;
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index e9a55b4030..9eafb0adf2 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -3340,13 +3340,13 @@ test_coplabel()
cop = &PL_compiling;
Perl_cop_store_label(aTHX_ cop, "foo", 3, 0);
label = Perl_cop_fetch_label(aTHX_ cop, &len, &utf8);
- if (strcmp(label,"foo")) croak("fail # cop_fetch_label label");
+ if (strNE(label,"foo")) croak("fail # cop_fetch_label label");
if (len != 3) croak("fail # cop_fetch_label len");
if (utf8) croak("fail # cop_fetch_label utf8");
/* SMALL GERMAN UMLAUT A */
Perl_cop_store_label(aTHX_ cop, "fo\xc3\xa4", 4, SVf_UTF8);
label = Perl_cop_fetch_label(aTHX_ cop, &len, &utf8);
- if (strcmp(label,"fo\xc3\xa4")) croak("fail # cop_fetch_label label");
+ if (strNE(label,"fo\xc3\xa4")) croak("fail # cop_fetch_label label");
if (len != 4) croak("fail # cop_fetch_label len");
if (!utf8) croak("fail # cop_fetch_label utf8");
@@ -3477,7 +3477,7 @@ test_op_list()
#define iv_op(iv) newSVOP(OP_CONST, 0, newSViv(iv))
#define check_op(o, expect) \
do { \
- if (strcmp(test_op_list_describe(o), (expect))) \
+ if (strNE(test_op_list_describe(o), (expect))) \
croak("fail %s %s", test_op_list_describe(o), (expect)); \
} while(0)
a = op_append_elem(OP_LIST, NULL, NULL);
diff --git a/symbian/symbian_stubs.c b/symbian/symbian_stubs.c
index c997446cfd..314bd5772c 100644
--- a/symbian/symbian_stubs.c
+++ b/symbian/symbian_stubs.c
@@ -89,7 +89,7 @@ struct protoent* getprotobynumber(int number) {
struct protoent* getprotobyname(const char* name) {
int i;
for (i = 0; i < sizeof(protocols)/sizeof(struct protoent); i++)
- if (strcmp(name, protocols[i].p_name) == 0)
+ if (strEQ(name, protocols[i].p_name))
return (struct protoent*)(&(protocols[i]));
return 0;
}
@@ -97,7 +97,7 @@ struct protoent* getprotobyname(const char* name) {
struct servent* getservbyname(const char* name, const char* proto) {
int i;
for (i = 0; i < sizeof(services)/sizeof(struct servent); i++)
- if (strcmp(name, services[i].s_name) == 0)
+ if (strEQ(name, services[i].s_name))
return (struct servent*)(&(services[i]));
return 0;
}
diff --git a/vms/vms.c b/vms/vms.c
index df0aed85b7..98077a44e8 100644
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -293,7 +293,7 @@ is_unix_filespec(const char *path)
/* If the user wants UNIX files, "." needs to be treated as in UNIX */
if (decc_filename_unix_report || decc_filename_unix_only) {
- if (strcmp(path,".") == 0)
+ if (strEQ(path,".")
ret_val = 1;
}
}
@@ -844,10 +844,10 @@ S_remove_ppf_prefix(const char *lnm, char *eqv, unsigned short int eqvlen)
{
if (*((int *)lnm) == *((int *)"SYS$") &&
eqvlen >= 4 && eqv[0] == 0x1b && eqv[1] == 0x00 &&
- ( (lnm[4] == 'O' && !strcmp(lnm,"SYS$OUTPUT")) ||
- (lnm[4] == 'I' && !strcmp(lnm,"SYS$INPUT")) ||
- (lnm[4] == 'E' && !strcmp(lnm,"SYS$ERROR")) ||
- (lnm[4] == 'C' && !strcmp(lnm,"SYS$COMMAND")) ) ) {
+ ( (lnm[4] == 'O' && strEQ(lnm,"SYS$OUTPUT")) ||
+ (lnm[4] == 'I' && strEQ(lnm,"SYS$INPUT")) ||
+ (lnm[4] == 'E' && strEQ(lnm,"SYS$ERROR")) ||
+ (lnm[4] == 'C' && strEQ(lnm,"SYS$COMMAND")) ) ) {
memmove(eqv, eqv+4, eqvlen-4);
eqvlen -= 4;
@@ -1637,7 +1637,7 @@ Perl_my_setenv(pTHX_ const char *lnm, const char *eqv)
char uplnm[8];
int i;
for (i = 0; lnm[i]; i++) uplnm[i] = toUPPER_A(lnm[i]);
- if (!strcmp(uplnm,"DEFAULT")) {
+ if (strEQ(uplnm,"DEFAULT")) {
if (eqv && *eqv) my_chdir(eqv);
return;
}
@@ -3720,7 +3720,7 @@ store_pipelocs(pTHX)
if (SvROK(dirsv)) continue;
dir = SvPVx(dirsv,n_a);
- if (strcmp(dir,".") == 0) continue;
+ if (strEQ(dir,".")) continue;
if ((tounixpath_utf8(dir, unixdir, NULL)) == NULL)
continue;
@@ -6047,11 +6047,11 @@ int_fileify_dirspec(const char *dir, char *buf, int *utf8_fl)
* ... do_fileify_dirspec("myroot",buf,1) ...
* does something useful.
*/
- if (dirlen >= 2 && !strcmp(trndir+dirlen-2,".]")) {
+ if (dirlen >= 2 && strEQ(trndir+dirlen-2,".]")) {
trndir[--dirlen] = '\0';
trndir[dirlen-1] = ']';
}
- if (dirlen >= 2 && !strcmp(trndir+dirlen-2,".>")) {
+ if (dirlen >= 2 && strEQ(trndir+dirlen-2,".>")) {
trndir[--dirlen] = '\0';
trndir[dirlen-1] = '>';
}
@@ -6139,7 +6139,7 @@ int_fileify_dirspec(const char *dir, char *buf, int *utf8_fl)
} while ((cp1 = strstr(cp1,"/.")) != NULL);
lastdir = strrchr(trndir,'/');
}
- else if (dirlen >= 7 && !strcmp(&trndir[dirlen-7],"/000000")) {
+ else if (dirlen >= 7 && strEQ(&trndir[dirlen-7],"/000000")) {
char * ret_chr;
/* Ditto for specs that end in an MFD -- let the VMS code
* figure out whether it's a real device or a rooted logical. */
@@ -6697,7 +6697,7 @@ int_pathify_dirspec(const char *dir, char *buf)
trnlen = strlen(trndir);
/* Trap simple rooted lnms, and return lnm:[000000] */
- if (!strcmp(trndir+trnlen-2,".]")) {
+ if (strEQ(trndir+trnlen-2,".]")) {
my_strlcpy(buf, dir, VMS_MAXRSS);
strcat(buf, ":[000000]");
PerlMem_free(trndir);
@@ -7816,7 +7816,6 @@ posix_to_vmsspec_hardway(char *vmspath, int vmspath_len, const char *unixpath,
&vs_len);
while (sts == 0) {
- int cmp;
/* A logical name must be a directory or the full
specification. It is only a full specification if
@@ -7864,8 +7863,7 @@ posix_to_vmsspec_hardway(char *vmspath, int vmspath_len, const char *unixpath,
/* This should not be there, but nothing is perfect */
if (r_len > 9) {
- cmp = strcmp(&r_spec[1], "000000.");
- if (cmp == 0) {
+ if (strEQ(&r_spec[1], "000000.")) {
r_spec += 7;
r_spec[7] = '[';
r_len -= 7;
@@ -7886,8 +7884,7 @@ posix_to_vmsspec_hardway(char *vmspath, int vmspath_len, const char *unixpath,
d_spec[0] = '[';
d_spec[d_len - 1] = ']';
if (d_len > 9) {
- cmp = strcmp(&d_spec[1], "000000.");
- if (cmp == 0) {
+ if (strEQ(&d_spec[1], "000000.")) {
d_spec += 7;
d_spec[7] = '[';
d_len -= 7;
@@ -8025,10 +8022,8 @@ posix_to_vmsspec_hardway(char *vmspath, int vmspath_len, const char *unixpath,
dir_start = 1;
dir_dot = 1;
if (vmslen > 7) {
- int cmp;
rptr = vmsptr - 7;
- cmp = strcmp(rptr,"000000.");
- if (cmp == 0) {
+ if (strEQ(rptr,"000000.")) {
vmslen -= 7;
vmsptr -= 7;
vmsptr[1] = '\0';
@@ -8570,13 +8565,13 @@ int_tovmsspec(const char *path, char *rslt, int dir_flag, int * utf8_flag)
/* DECC special handling */
if (!islnm) {
- if (strcmp(rslt,"bin") == 0) {
+ if (strEQ(rslt,"bin")) {
strcpy(rslt,"sys$system");
cp1 = rslt + 10;
*cp1 = 0;
islnm = simple_trnlnm(rslt,trndev,VMS_MAXRSS-1);
}
- else if (strcmp(rslt,"tmp") == 0) {
+ else if (strEQ(rslt,"tmp")) {
strcpy(rslt,"sys$scratch");
cp1 = rslt + 11;
*cp1 = 0;
@@ -8590,7 +8585,7 @@ int_tovmsspec(const char *path, char *rslt, int dir_flag, int * utf8_flag)
while (*(cp2+1) == '/') cp2++; /* Skip multiple /s */
islnm = simple_trnlnm(rslt,trndev,VMS_MAXRSS-1);
}
- else if (strcmp(rslt,"dev") == 0) {
+ else if (strEQ(rslt,"dev")) {
if (strncmp(cp2,"/null", 5) == 0) {
if ((cp2[5] == 0) || (cp2[5] == '/')) {
strcpy(rslt,"NLA0");
@@ -9184,7 +9179,7 @@ mp_getredirection(pTHX_ int *ac, char ***av)
* subprocess, so we satisfy that desire.
*/
ap = argv[argc-1];
- if (0 == strcmp("&", ap))
+ if (strEQ(ap, "&"))
exit(background_process(aTHX_ --argc, argv));
if (*ap && '&' == ap[strlen(ap)-1])
{
@@ -9197,7 +9192,7 @@ mp_getredirection(pTHX_ int *ac, char ***av)
*/
for (j = 0; j < argc; ++j)
{
- if (0 == strcmp("<", argv[j]))
+ if (strEQ(argv[j], "<"))
{
if (j+1 >= argc)
{
@@ -9212,7 +9207,7 @@ mp_getredirection(pTHX_ int *ac, char ***av)
in = 1 + ap;
continue;
}
- if (0 == strcmp(">", ap))
+ if (strEQ(ap, ">"))
{
if (j+1 >= argc)
{
@@ -9263,7 +9258,7 @@ mp_getredirection(pTHX_ int *ac, char ***av)
}
continue;
}
- if (0 == strcmp("|", argv[j]))
+ if (strEQ(argv[j], "|"))
{
if (j+1 >= argc)
{
@@ -9349,7 +9344,7 @@ mp_getredirection(pTHX_ int *ac, char ***av)
if (out != NULL) vmssetuserlnm("SYS$OUTPUT", out);
if (err != NULL) {
- if (strcmp(err,"&1") == 0) {
+ if (strEQ(err, "&1")) {
dup2(fileno(stdout), fileno(stderr));
vmssetuserlnm("SYS$ERROR", "SYS$OUTPUT");
} else {
diff --git a/win32/win32.c b/win32/win32.c
index 2e82c53462..5a23cb6c67 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1832,7 +1832,7 @@ win32_getenv(const char *name)
char *end = strchr(cur,'=');
if (end && end != cur) {
*end = '\0';
- if (!strcmp(cur,name)) {
+ if (strEQ(cur,name)) {
curitem = sv_2mortal(newSVpv(end+1,0));
*end = '=';
break;