summaryrefslogtreecommitdiff
path: root/src/tc-realpath.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tc-realpath.c')
-rw-r--r--src/tc-realpath.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/tc-realpath.c b/src/tc-realpath.c
index 23609ca..b71c127 100644
--- a/src/tc-realpath.c
+++ b/src/tc-realpath.c
@@ -8,6 +8,7 @@
#include <libHX/io.h>
#include <libHX/option.h>
#include <libHX/string.h>
+#include "internal.h"
static unsigned int rp_flags;
static unsigned int rp_absolute;
@@ -24,9 +25,9 @@ static const struct HXoption rp_option_table[] = {
HXOPT_TABLEEND,
};
-static bool rp_get_options(int *argc, const char ***argv)
+static bool rp_get_options(char **oargv, int *argc, char ***argv)
{
- if (HX_getopt(rp_option_table, argc, argv, HXOPT_USAGEONERR) !=
+ if (HX_getopt5(rp_option_table, oargv, argc, argv, HXOPT_USAGEONERR) !=
HXOPT_ERR_SUCCESS)
return false;
rp_flags = HX_REALPATH_DEFAULT;
@@ -47,18 +48,19 @@ static void t_1(void)
HXmc_free(tmp);
}
-int main(int argc, const char **argv)
+int main(int argc, char **oargv)
{
+ char **argv = nullptr;
hxmc_t *res;
int ret;
- if (!rp_get_options(&argc, &argv))
+ if (!rp_get_options(oargv, &argc, &argv))
return EXIT_FAILURE;
t_1();
res = NULL;
- while (--argc > 0) {
- ret = HX_realpath(&res, *++argv, rp_flags);
+ for (int i = 1; i < argc; ++i) {
+ ret = HX_realpath(&res, argv[argc], rp_flags);
if (ret < 0) {
perror("HX_realpath");
printf("\n");
@@ -66,5 +68,6 @@ int main(int argc, const char **argv)
printf("%s\n", res);
}
}
+ HX_zvecfree(argv);
return EXIT_SUCCESS;
}