summaryrefslogtreecommitdiff
path: root/src/xine-utils
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2008-04-09 18:28:49 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2008-04-09 18:28:49 +0100
commit39939c95eff90545285a9a8f761d9fa6e9349358 (patch)
treeb8ea1fa3f2ddf1627eeecbd889f47226b01a45d8 /src/xine-utils
parent19357940a57c565ebe319729bd08d6e4800aff5d (diff)
parent628c4cbd9d023e74a7c6805d7ec0f163f2c172d1 (diff)
downloadxine-lib-39939c95eff90545285a9a8f761d9fa6e9349358.tar.gz
xine-lib-39939c95eff90545285a9a8f761d9fa6e9349358.tar.bz2
Merge from 1.2 main.
Diffstat (limited to 'src/xine-utils')
-rw-r--r--src/xine-utils/Makefile.am4
-rw-r--r--src/xine-utils/xmllexer.c2
-rw-r--r--src/xine-utils/xmlparser.c70
3 files changed, 76 insertions, 0 deletions
diff --git a/src/xine-utils/Makefile.am b/src/xine-utils/Makefile.am
index 75cab2131..0c664b0be 100644
--- a/src/xine-utils/Makefile.am
+++ b/src/xine-utils/Makefile.am
@@ -32,3 +32,7 @@ libxineutils_la_SOURCES = $(pppc_files) \
sorted_array.c \
pool.c \
ring_buffer.c
+
+noinst_PROGRAMS = xmltest
+xmltest_SOURCES = xmllexer.c xmlparser.c
+xmltest_CFLAGS = -DLOG -DXINE_XML_PARSER_TEST $(AM_CFLAGS)
diff --git a/src/xine-utils/xmllexer.c b/src/xine-utils/xmllexer.c
index 75a1aafec..394ca397f 100644
--- a/src/xine-utils/xmllexer.c
+++ b/src/xine-utils/xmllexer.c
@@ -445,6 +445,8 @@ int lexer_get_token_d(char ** _tok, int * _tok_size, int fixed) {
case '\"': /* " */
case ' ':
case '\t':
+ case '\n':
+ case '\r':
case '=':
case '/':
tok[tok_pos] = '\0';
diff --git a/src/xine-utils/xmlparser.c b/src/xine-utils/xmlparser.c
index 8ef828105..0c3d12f59 100644
--- a/src/xine-utils/xmlparser.c
+++ b/src/xine-utils/xmlparser.c
@@ -837,3 +837,73 @@ void xml_parser_dump_tree (const xml_node_t *node) {
node = node->next;
} while (node);
}
+
+#ifdef XINE_XML_PARSER_TEST
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+void *xine_xmalloc (size_t size)
+{
+ return malloc (size);
+}
+
+int main (int argc, char **argv)
+{
+ int i, ret = 0;
+ for (i = 1; argv[i]; ++i)
+ {
+ xml_node_t *tree;
+ int fd;
+ void *buf;
+ struct stat st;
+
+ if (stat (argv[i], &st))
+ {
+ perror (argv[i]);
+ ret = 1;
+ continue;
+ }
+ if (!S_ISREG (st.st_mode))
+ {
+ printf ("%s: not a file\n", argv[i]);
+ ret = 1;
+ continue;
+ }
+ fd = open (argv[i], O_RDONLY);
+ if (!fd)
+ {
+ perror (argv[i]);
+ ret = 1;
+ continue;
+ }
+ buf = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+ if (!buf)
+ {
+ perror (argv[i]);
+ if (close (fd))
+ perror (argv[i]);
+ ret = 1;
+ continue;
+ }
+
+ xml_parser_init (buf, st.st_size, 0);
+ if (!xml_parser_build_tree (&tree))
+ {
+ puts (argv[i]);
+ xml_parser_dump_tree (tree);
+ xml_parser_free_tree (tree);
+ }
+ else
+ printf ("%s: parser failure\n", argv[i]);
+
+ if (close (fd))
+ {
+ perror (argv[i]);
+ ret = 1;
+ }
+ }
+ return ret;
+}
+#endif