diff options
| author | Thiago Fransosi Farina <thiago.farina@gmail.com> | 2014-08-13 06:47:30 -0700 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2014-08-13 06:47:30 -0700 |
| commit | aa549ce449a0edccea03b7f4912ee3f9fa9b9b38 (patch) | |
| tree | 46eb73c6285428b5215c70e8aa27936868349d5c /src | |
| parent | 392bc8985e6b4b33603bfb9b546d301d3857a3cb (diff) | |
| download | go-aa549ce449a0edccea03b7f4912ee3f9fa9b9b38.tar.xz | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/dist/plan9.c | 6 | ||||
| -rw-r--r-- | src/cmd/dist/unix.c | 16 | ||||
| -rw-r--r-- | src/cmd/dist/windows.c | 4 |
3 files changed, 13 insertions, 13 deletions
diff --git a/src/cmd/dist/plan9.c b/src/cmd/dist/plan9.c index 8d492ebc67..e4bf251475 100644 --- a/src/cmd/dist/plan9.c +++ b/src/cmd/dist/plan9.c @@ -23,7 +23,7 @@ bprintf(Buf *b, char *fmt, ...) { va_list arg; char buf[4096]; - + breset(b); va_start(arg, fmt); vsnprintf(buf, sizeof buf, fmt, arg); @@ -572,10 +572,10 @@ bool hassuffix(char *p, char *suffix) { int np, ns; - + np = strlen(p); 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. diff --git a/src/cmd/dist/unix.c b/src/cmd/dist/unix.c index 8b943a2d95..4a78684b44 100644 --- a/src/cmd/dist/unix.c +++ b/src/cmd/dist/unix.c @@ -431,7 +431,7 @@ xremoveall(char *p) } bfree(&b); - vfree(&dir); + vfree(&dir); } // xreaddir replaces dst with a list of the names of the files in dir. @@ -441,13 +441,13 @@ xreaddir(Vec *dst, char *dir) { DIR *d; struct dirent *dp; - + vreset(dst); d = opendir(dir); if(d == nil) fatal("opendir %s: %s", dir, strerror(errno)); 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; vadd(dst, dp->d_name); } @@ -461,7 +461,7 @@ xworkdir(void) { Buf b; char *p; - + binit(&b); xgetenv(&b, "TMPDIR"); @@ -546,10 +546,10 @@ bool hassuffix(char *p, char *suffix) { int np, ns; - + np = strlen(p); 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. @@ -712,7 +712,7 @@ main(int argc, char **argv) fatal("unknown architecture: %s", u.machine); } - if(strcmp(gohostarch, "arm") == 0) + if(streq(gohostarch, "arm")) maxnbg = 1; // The OS X 10.6 linker does not support external linking mode. @@ -724,7 +724,7 @@ main(int argc, char **argv) // // 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. - if(strcmp(gohostos, "darwin") == 0) { + if(streq(gohostos, "darwin")) { if(uname(&u) < 0) fatal("uname: %s", strerror(errno)); osx = atoi(u.release) - 4; diff --git a/src/cmd/dist/windows.c b/src/cmd/dist/windows.c index 2839c4bc51..1102adff5e 100644 --- a/src/cmd/dist/windows.c +++ b/src/cmd/dist/windows.c @@ -770,10 +770,10 @@ bool hassuffix(char *p, char *suffix) { int np, ns; - + np = strlen(p); ns = strlen(suffix); - return np >= ns && strcmp(p+np-ns, suffix) == 0; + return np >= ns && streq(p+np-ns, suffix); } bool |
