add --relative to testURI
Example: testURI --relative --base file:///a/b/c file:///a/x/y
Result: ../x/y
diff --git a/testURI.c b/testURI.c
index d20989d..0043b20 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 @@
}
}
} 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);
}
@@ -75,6 +81,11 @@
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++;
base = argv[arg];