From 25f13e77e6ce47e7a87559813e802ffb8c3b957f Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Mon, 5 Nov 2018 13:53:00 +0100 Subject: [PATCH] add --relative to testURI Example: testURI --relative --base file:///a/b/c file:///a/x/y Result: ../x/y --- testURI.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/testURI.c b/testURI.c index d20989d4b..0043b203d 100644 --- a/testURI.c +++ b/testURI.c @@ -19,6 +19,7 @@ static const char *base = NULL; static int escape = 0; static int debug = 0; +static int relative = 0; static void handleURI(const char *str) { int ret; @@ -57,7 +58,12 @@ static void handleURI(const char *str) { } } } else { - res = xmlBuildURI((xmlChar *)str, (xmlChar *) base); + if (relative) { + res = xmlBuildRelativeURI((xmlChar *)str, (xmlChar *) base); + } else { + res = xmlBuildURI((xmlChar *)str, (xmlChar *) base); + } + if (res != NULL) { printf("%s\n", (char *) res); } @@ -74,6 +80,11 @@ static void handleURI(const char *str) { int main(int argc, char **argv) { int i, arg = 1; + if ((argc > arg) && (argv[arg] != NULL) && + (!strcmp(argv[arg], "--relative"))) { + arg++; + relative++; + } if ((argc > arg) && (argv[arg] != NULL) && ((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) { arg++;