mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
closed bug #66159 added --escape option some cleanup for xml2-config
* uri.c: closed bug #66159 * testURI.c: added --escape option * configure.in: some cleanup for xml2-config --cflags Daniel
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
Fri Dec 7 12:32:00 CET 2001 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* uri.c: closed bug #66159
|
||||||
|
* testURI.c: added --escape option
|
||||||
|
* configure.in: some cleanup for xml2-config --cflags
|
||||||
|
|
||||||
Thu Dec 6 15:31:30 CET 2001 Daniel Veillard <daniel@veillard.com>
|
Thu Dec 6 15:31:30 CET 2001 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* globals.c testThreads.c: removed some misplaced includes
|
* globals.c testThreads.c: removed some misplaced includes
|
||||||
|
@ -411,7 +411,7 @@ AC_ARG_WITH(iconv, [ --with-iconv[=DIR] Add ICONV support (on)])
|
|||||||
if test "$with_iconv" = "no" ; then
|
if test "$with_iconv" = "no" ; then
|
||||||
echo Disabling ICONV support
|
echo Disabling ICONV support
|
||||||
else
|
else
|
||||||
if test "$with_iconv" != "yes" ; then
|
if test "$with_iconv" != "yes" -a "$with_iconv" != "" ; then
|
||||||
CPPFLAGS="${CPPFLAGS} -I$with_iconv/include"
|
CPPFLAGS="${CPPFLAGS} -I$with_iconv/include"
|
||||||
# Export this since our headers include iconv.h
|
# Export this since our headers include iconv.h
|
||||||
XML_INCLUDEDIR="${XML_INCLUDEDIR} -I$with_iconv/include"
|
XML_INCLUDEDIR="${XML_INCLUDEDIR} -I$with_iconv/include"
|
||||||
|
93
testURI.c
93
testURI.c
@ -16,20 +16,62 @@
|
|||||||
#include <libxml/uri.h>
|
#include <libxml/uri.h>
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
static const char *base = NULL;
|
||||||
int i, ret, arg = 1;
|
static int escape = 0;
|
||||||
xmlURIPtr uri;
|
|
||||||
const char *base = NULL;
|
|
||||||
xmlChar *composite;
|
|
||||||
|
|
||||||
if ((argc > 1) && (argv[arg] != NULL) &&
|
static void handleURI(const char *str) {
|
||||||
|
int ret;
|
||||||
|
xmlURIPtr uri;
|
||||||
|
xmlChar *res = NULL, *parsed = NULL;
|
||||||
|
|
||||||
|
uri = xmlCreateURI();
|
||||||
|
|
||||||
|
if (base == NULL) {
|
||||||
|
ret = xmlParseURIReference(uri, str);
|
||||||
|
if (ret != 0)
|
||||||
|
printf("%s : error %d\n", str, ret);
|
||||||
|
else {
|
||||||
|
xmlNormalizeURIPath(uri->path);
|
||||||
|
if (escape != 0) {
|
||||||
|
parsed = xmlSaveUri(uri);
|
||||||
|
res = xmlURIEscape(parsed);
|
||||||
|
printf("%s\n", res);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
xmlPrintURI(stdout, uri);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res = xmlBuildURI((xmlChar *)str, (xmlChar *) base);
|
||||||
|
if (res != NULL) {
|
||||||
|
printf("%s\n", res);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("::ERROR::\n");
|
||||||
|
}
|
||||||
|
if (res != NULL)
|
||||||
|
xmlFree(res);
|
||||||
|
if (parsed != NULL)
|
||||||
|
xmlFree(parsed);
|
||||||
|
xmlFreeURI(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int i, arg = 1;
|
||||||
|
|
||||||
|
if ((argc > arg) && (argv[arg] != NULL) &&
|
||||||
((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) {
|
((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) {
|
||||||
arg++;
|
arg++;
|
||||||
base = argv[arg];
|
base = argv[arg];
|
||||||
if (base != NULL)
|
if (base != NULL)
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
uri = xmlCreateURI();
|
if ((argc > arg) && (argv[arg] != NULL) &&
|
||||||
|
((!strcmp(argv[arg], "-escape")) || (!strcmp(argv[arg], "--escape")))) {
|
||||||
|
arg++;
|
||||||
|
escape++;
|
||||||
|
}
|
||||||
if (argv[arg] == NULL) {
|
if (argv[arg] == NULL) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
|
|
||||||
@ -50,47 +92,14 @@ int main(int argc, char **argv) {
|
|||||||
i--;
|
i--;
|
||||||
str[i] = 0;
|
str[i] = 0;
|
||||||
}
|
}
|
||||||
|
handleURI(str);
|
||||||
if (base == NULL) {
|
|
||||||
ret = xmlParseURIReference(uri, str);
|
|
||||||
if (ret != 0)
|
|
||||||
printf("%s : error %d\n", str, ret);
|
|
||||||
else {
|
|
||||||
xmlNormalizeURIPath(uri->path);
|
|
||||||
xmlPrintURI(stdout, uri);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
composite = xmlBuildURI((xmlChar *)str, (xmlChar *) base);
|
|
||||||
if (composite != NULL) {
|
|
||||||
printf("%s\n", composite);
|
|
||||||
xmlFree(composite);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf("::ERROR::\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (argv[arg] != NULL) {
|
while (argv[arg] != NULL) {
|
||||||
if (base == NULL) {
|
handleURI(argv[arg]);
|
||||||
ret = xmlParseURIReference(uri, argv[arg]);
|
|
||||||
if (ret != 0)
|
|
||||||
printf("%s : error %d\n", argv[arg], ret);
|
|
||||||
else {
|
|
||||||
xmlPrintURI(stdout, uri);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
composite = xmlBuildURI((xmlChar *)argv[arg], (xmlChar *) base);
|
|
||||||
if (composite != NULL) {
|
|
||||||
printf("%s\n", composite);
|
|
||||||
xmlFree(composite);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xmlFreeURI(uri);
|
|
||||||
xmlMemoryDump();
|
xmlMemoryDump();
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
1
uri.c
1
uri.c
@ -1030,7 +1030,6 @@ xmlURIEscape(const xmlChar * str)
|
|||||||
segment = xmlURIEscapeStr(BAD_CAST uri->opaque, BAD_CAST "");
|
segment = xmlURIEscapeStr(BAD_CAST uri->opaque, BAD_CAST "");
|
||||||
NULLCHK(segment)
|
NULLCHK(segment)
|
||||||
ret = xmlStrcat(ret, segment);
|
ret = xmlStrcat(ret, segment);
|
||||||
ret = xmlStrcat(ret, BAD_CAST ":");
|
|
||||||
xmlFree(segment);
|
xmlFree(segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user