diff options
author | Florian Jung <flo@windfisch.org> | 2011-12-21 17:39:57 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-12-21 17:39:57 +0000 |
commit | 1057d7190242cdf9248671b316a398db805f5f56 (patch) | |
tree | ab50268a7db2f80cfb45a7ad6578fe735ab84ce5 /muse2/muse/xml.cpp | |
parent | 9977c7114089b8708d310268833b83343caa0fd1 (diff) | |
parent | c36a5508aa42e596b005425208054af9a60734b4 (diff) |
merged with trunk (that is, pulled the fixes from release_2_0)
only quickly tested, seems okay on the first glance
Diffstat (limited to 'muse2/muse/xml.cpp')
-rw-r--r-- | muse2/muse/xml.cpp | 94 |
1 files changed, 72 insertions, 22 deletions
diff --git a/muse2/muse/xml.cpp b/muse2/muse/xml.cpp index 139437c1..45bed368 100644 --- a/muse2/muse/xml.cpp +++ b/muse2/muse/xml.cpp @@ -4,6 +4,7 @@ // $Id: xml.cpp,v 1.17.2.6 2009/12/07 20:48:45 spamatica Exp $ // // (C) Copyright 2000 Werner Schweer (ws@seh.de) +// (C) Copyright 2011 Tim E. Real (terminator356 on sourceforge) // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -24,6 +25,7 @@ #include <stdio.h> #include <stdarg.h> +#include <QByteArray> #include <QString> #include <QColor> #include <QWidget> @@ -112,9 +114,12 @@ void Xml::nextc() void Xml::token(int cc) { - char buffer[512]; + //char buffer[512]; + QByteArray buffer; + int i = 0; - for (; i < 511;) { + //for (; i < 511;) { + for (; i < 9999999;) { // Stop at a reasonably large amount 10 million. if (c == ' ' || c == '\t' || c == cc || c == '\n' || c == EOF) break; buffer[i++] = c; @@ -131,12 +136,16 @@ void Xml::token(int cc) void Xml::stoken() { - char buffer[1024*4]; + //char buffer[1024*4]; + QByteArray buffer; + int i = 0; buffer[i] = c; ++i; next(); - for (;i < 1024*4-1;) { + + //for (;i < 1024*4-1;) { + for (;i < 10000000*4-1;) { // Stop at a reasonably large amount 10 million. if (c == '"') { buffer[i++] = c; next(); @@ -207,8 +216,10 @@ QString Xml::strip(const QString& s) Xml::Token Xml::parse() { - char buffer[1024*1024]; // increase buffer -rj - char* p; + //char buffer[1024*1024]; // increase buffer -rj + //char* p; + QByteArray buffer; + int idx = 0; again: bool endFlag = false; @@ -262,15 +273,23 @@ Xml::Token Xml::parse() } if (c == '?') { next(); - p = buffer; + //p = buffer; + //p = buffer.data(); + idx = 0; for (;;) { if (c == '?' || c == EOF || c == '>') break; - *p++ = c; + + //*p++ = c; + buffer[idx++] = c; + // TODO: check overflow next(); } - *p = 0; + + //*p = 0; + buffer[idx] = 0; + _s1 = QString(buffer); if (c == EOF) { fprintf(stderr, "XML: unexpected EOF\n"); @@ -298,15 +317,23 @@ Xml::Token Xml::parse() } goto again; } - p = buffer; + //p = buffer; + //p = buffer.data(); + idx = 0; for (;;) { if (c == '/' || c == ' ' || c == '\t' || c == '>' || c == '\n' || c == EOF) break; // TODO: check overflow - *p++ = c; + + //*p++ = c; + buffer[idx++] = c; + next(); } - *p = 0; + + //*p = 0; + buffer[idx] = 0; + _s1 = QString(buffer); // skip white space: while (c == ' ' || c == '\t' || c == '\n') @@ -355,26 +382,43 @@ Xml::Token Xml::parse() fprintf(stderr, "XML: level = 0\n"); goto error; } - p = buffer; + //p = buffer; + //p = buffer.data(); + idx = 0; for (;;) { if (c == EOF || c == '<') break; if (c == '&') { next(); if (c == '<') { // be tolerant with old muse files - *p++ = '&'; + + //*p++ = '&'; + buffer[idx++] = '&'; + continue; } - char name[32]; - char* dp = name; - *dp++ = c; - for (; dp-name < 31;) { + + //char name[32]; + //char* dp = name; + QByteArray name; + int name_idx = 0; + + //*dp++ = c; + name[name_idx++] = c; + + //for (; dp-name < 31;) { + for (; name_idx < 9999999;) { // Stop at a reasonably large amount 10 million. next(); if (c == ';') break; - *dp++ = c; + + //*dp++ = c; + name[name_idx++] = c; } - *dp = 0; + + //*dp = 0; + name[name_idx] = 0; + if (strcmp(name, "lt") == 0) c = '<'; else if (strcmp(name, "gt") == 0) @@ -388,10 +432,16 @@ Xml::Token Xml::parse() else c = '?'; } - *p++ = c; + + //*p++ = c; + buffer[idx++] = c; + next(); } - *p = 0; + + //*p = 0; + buffer[idx] = 0; + _s1 = QString(buffer); if (c == '<') |