Commit aa549ce4 authored by Thiago Fransosi Farina's avatar Thiago Fransosi Farina Committed by Ian Lance Taylor

cmd/dist: Reuse streq whenever possible.

Basically this cleanup replaces all the usage usages of strcmp() == 0,
found by the following command line:

$ grep -R strcmp cmd/dist | grep "0"

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/123330043
parent 392bc898
...@@ -575,7 +575,7 @@ hassuffix(char *p, char *suffix) ...@@ -575,7 +575,7 @@ hassuffix(char *p, char *suffix)
np = strlen(p); np = strlen(p);
ns = strlen(suffix); ns = strlen(suffix);
return np >= ns && strcmp(p+np-ns, suffix) == 0; return np >= ns && streq(p+np-ns, suffix);
} }
// hasprefix reports whether p begins with prefix. // hasprefix reports whether p begins with prefix.
......
...@@ -447,7 +447,7 @@ xreaddir(Vec *dst, char *dir) ...@@ -447,7 +447,7 @@ xreaddir(Vec *dst, char *dir)
if(d == nil) if(d == nil)
fatal("opendir %s: %s", dir, strerror(errno)); fatal("opendir %s: %s", dir, strerror(errno));
while((dp = readdir(d)) != nil) { while((dp = readdir(d)) != nil) {
if(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) if(streq(dp->d_name, ".") || streq(dp->d_name, ".."))
continue; continue;
vadd(dst, dp->d_name); vadd(dst, dp->d_name);
} }
...@@ -549,7 +549,7 @@ hassuffix(char *p, char *suffix) ...@@ -549,7 +549,7 @@ hassuffix(char *p, char *suffix)
np = strlen(p); np = strlen(p);
ns = strlen(suffix); ns = strlen(suffix);
return np >= ns && strcmp(p+np-ns, suffix) == 0; return np >= ns && streq(p+np-ns, suffix);
} }
// hasprefix reports whether p begins with prefix. // hasprefix reports whether p begins with prefix.
...@@ -712,7 +712,7 @@ main(int argc, char **argv) ...@@ -712,7 +712,7 @@ main(int argc, char **argv)
fatal("unknown architecture: %s", u.machine); fatal("unknown architecture: %s", u.machine);
} }
if(strcmp(gohostarch, "arm") == 0) if(streq(gohostarch, "arm"))
maxnbg = 1; maxnbg = 1;
// The OS X 10.6 linker does not support external linking mode. // The OS X 10.6 linker does not support external linking mode.
...@@ -724,7 +724,7 @@ main(int argc, char **argv) ...@@ -724,7 +724,7 @@ main(int argc, char **argv)
// //
// Roughly, OS X 10.N shows up as uname release (N+4), // Roughly, OS X 10.N shows up as uname release (N+4),
// so OS X 10.6 is uname version 10 and OS X 10.8 is uname version 12. // so OS X 10.6 is uname version 10 and OS X 10.8 is uname version 12.
if(strcmp(gohostos, "darwin") == 0) { if(streq(gohostos, "darwin")) {
if(uname(&u) < 0) if(uname(&u) < 0)
fatal("uname: %s", strerror(errno)); fatal("uname: %s", strerror(errno));
osx = atoi(u.release) - 4; osx = atoi(u.release) - 4;
......
...@@ -773,7 +773,7 @@ hassuffix(char *p, char *suffix) ...@@ -773,7 +773,7 @@ hassuffix(char *p, char *suffix)
np = strlen(p); np = strlen(p);
ns = strlen(suffix); ns = strlen(suffix);
return np >= ns && strcmp(p+np-ns, suffix) == 0; return np >= ns && streq(p+np-ns, suffix);
} }
bool bool
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment