Author | Jamozed <[email protected]> |
Date | 2020-07-06 11:22:05 |
Commit | 5ee88034400c39b9850454dcf52972af5ec76f20 |
Parent | 69fd1df5999ae1a77aabff6cce656e65484be71d |
realpath: Use libokv error reporting
Diffstat
M | src/realpath.c | | | 21 | +++++++++++---------- |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/realpath.c b/src/realpath.c index ff40e7c..69e8109 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -1,4 +1,4 @@ -// realpath.c, version 1.0.0 +// realpath.c, version 1.0.1 // OMKOV coreutils realpath // Copyright (C) 2020, Jakob Wakeling // All rights reserved. @@ -33,21 +33,22 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. */ -#include "error.h" #include "optget.h" -#include <errno.h> +#include <error.h> + #include <stdbool.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> + +#define VERSION "1.0.1" static inline int rpath(const char *path); static void help(void); static void version(void); -int main(int argc, char *argv[]) { +int main(int ac, char *av[]) { A0 = av[0]; lop_t lops[] = { { "help", ARG_NUL, 256 }, { "version", ARG_NUL, 257 }, @@ -55,7 +56,7 @@ int main(int argc, char *argv[]) { }; opt_t opt = OPTGET_INIT; opt.str = ""; opt.lops = lops; int o; - while((o = optget(&opt, argv, 1)) != -1) switch (o) { + while((o = optget(&opt, av, 1)) != -1) switch (o) { case 256: { help(); return 0; } case 257: { version(); return 0; } default: { return 1; } @@ -63,9 +64,9 @@ int main(int argc, char *argv[]) { bool warned = false; - if (opt.ind == argc) { rpath("."); } - else for (char **p = &argv[opt.ind]; *p; ++p) if (rpath(*p)) { - warn("%s: %s: %s\n", argv[0], *p, serrno); warned = true; + if (opt.ind == ac) { rpath("."); } + else for (char **p = &av[opt.ind]; *p; ++p) if (rpath(*p)) { + warn("%s: %s\n", *p, serr()); warned = true; } return warned; @@ -90,7 +91,7 @@ static void help(void) { } static void version() { - puts("OMKOV coreutils realpath, version 1.0.0"); + puts("OMKOV coreutils realpath, version " VERSION); puts("Copyright (C) 2020, Jakob Wakeling"); puts("All rights reserved."); puts("OMKOV Permissive Licence (https://www.omkov.net/OLPE)");