[hackers] [sbase] Use xrealpath() in du(1) || sin
commit 5be9c21ce43b028fb27b51cb7a7c02e05736f002
Author: sin <sin_AT_2f30.org>
Date: Thu Jan 23 21:16:05 2014 +0000
Use xrealpath() in du(1)
diff --git a/du.c b/du.c
index e250e0c..c6289cd 100644
--- a/du.c
+++ b/du.c
_AT_@ -26,6 +26,17 @@ usage(void)
eprintf("usage: %s [-a | -s] [-k] [file...]
", argv0);
}
+static char *
+xrealpath(const char *pathname, char *resolved)
+{
+ char *r;
+
+ r = realpath(pathname, resolved);
+ if (!r)
+ eprintf("realpath: %s:");
+ return r;
+}
+
int
main(int argc, char *argv[])
{
_AT_@ -59,12 +70,12 @@ main(int argc, char *argv[])
if (argc < 1) {
n = du(".");
if (sflag)
- print(n, realpath(".", file));
+ print(n, xrealpath(".", file));
} else {
for (; argc > 0; argc--, argv++) {
n = du(argv[0]);
if (sflag)
- print(n, realpath(argv[0], file));
+ print(n, xrealpath(argv[0], file));
}
}
return EXIT_SUCCESS;
_AT_@ -142,7 +153,7 @@ du(const char *path)
cwd, dent->d_name) >= sizeof(file))
enprintf(EXIT_FAILURE, "path too long
");
} else {
- realpath(dent->d_name, file);
+ xrealpath(dent->d_name, file);
}
print(m, file);
}
_AT_@ -152,6 +163,6 @@ du(const char *path)
done:
if (!sflag)
- print(n, realpath(path, file));
+ print(n, xrealpath(path, file));
return n;
}
Received on Thu Jan 23 2014 - 22:17:30 CET
This archive was generated by hypermail 2.3.0
: Thu Jan 23 2014 - 22:24:11 CET