summaryrefslogtreecommitdiff
path: root/src/tc-realpath.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2023-12-17 14:18:48 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2023-12-17 14:18:48 +0100
commiteece9692d707ccb20356ec06955f8308c4e59ca7 (patch)
tree55186434884960d25d11736c8f846876d568fa08 /src/tc-realpath.c
parent987942a206ef0f2342bf81d5de6432c6af42b7e7 (diff)
New upstream version 4.19upstream/4.19
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;
}