[libxml2] add --relative to testURI
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] add --relative to testURI
- Date: Thu, 29 Nov 2018 21:40:50 +0000 (UTC)
commit 25f13e77e6ce47e7a87559813e802ffb8c3b957f
Author: Thomas Holder <thomas holder schrodinger com>
Date: Mon Nov 5 13:53:00 2018 +0100
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 d20989d4..0043b203 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++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]