mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +03:00
add --relative to testURI
Example: testURI --relative --base file:///a/b/c file:///a/x/y Result: ../x/y
This commit is contained in:
committed by
Daniel Veillard
parent
c7461f6547
commit
25f13e77e6
13
testURI.c
13
testURI.c
@@ -19,6 +19,7 @@
|
|||||||
static const char *base = NULL;
|
static const char *base = NULL;
|
||||||
static int escape = 0;
|
static int escape = 0;
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
|
static int relative = 0;
|
||||||
|
|
||||||
static void handleURI(const char *str) {
|
static void handleURI(const char *str) {
|
||||||
int ret;
|
int ret;
|
||||||
@@ -57,7 +58,12 @@ static void handleURI(const char *str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if (res != NULL) {
|
||||||
printf("%s\n", (char *) res);
|
printf("%s\n", (char *) res);
|
||||||
}
|
}
|
||||||
@@ -74,6 +80,11 @@ static void handleURI(const char *str) {
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
int i, arg = 1;
|
int i, arg = 1;
|
||||||
|
|
||||||
|
if ((argc > arg) && (argv[arg] != NULL) &&
|
||||||
|
(!strcmp(argv[arg], "--relative"))) {
|
||||||
|
arg++;
|
||||||
|
relative++;
|
||||||
|
}
|
||||||
if ((argc > arg) && (argv[arg] != NULL) &&
|
if ((argc > arg) && (argv[arg] != NULL) &&
|
||||||
((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) {
|
((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) {
|
||||||
arg++;
|
arg++;
|
||||||
|
|||||||
Reference in New Issue
Block a user