summaryrefslogtreecommitdiffstats
path: root/src/dom/xmlreader.cpp
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2008-05-01 19:15:49 +0000
committerishmal <ishmal@users.sourceforge.net>2008-05-01 19:15:49 +0000
commit1e3ebdbb6db4694488063e89caca3d41f8861c00 (patch)
tree28c836ab32b5414773f9909857e97dbabb724ebc /src/dom/xmlreader.cpp
parentReplace freeSnapSkew() by constrainedSnapSkew(). There is no such thing as fr... (diff)
downloadinkscape-1e3ebdbb6db4694488063e89caca3d41f8861c00.tar.gz
inkscape-1e3ebdbb6db4694488063e89caca3d41f8861c00.zip
Clean up. More commenting. Smarten SvgParser and rename to SvgReader.
(bzr r5570)
Diffstat (limited to 'src/dom/xmlreader.cpp')
-rw-r--r--src/dom/xmlreader.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/dom/xmlreader.cpp b/src/dom/xmlreader.cpp
index 825851479..fc4eee51f 100644
--- a/src/dom/xmlreader.cpp
+++ b/src/dom/xmlreader.cpp
@@ -49,9 +49,9 @@ namespace dom
//#########################################################################
struct EntityInfo
{
- char *escape;
+ const char *escape;
int escapeLength;
- char *value;
+ const char *value;
};
@@ -75,7 +75,7 @@ static EntityInfo entityTable[] =
/**
*
*/
-void XmlReader::error(char *fmt, ...)
+void XmlReader::error(const char *fmt, ...)
{
va_list args;
fprintf(stderr, "XmlReader:error at line %d, column %d:", lineNr, colNr);
@@ -156,7 +156,7 @@ int XmlReader::peek(int p)
* Test if the given substring exists at the given position
* in parsebuf. Use peek() in case of out-of-bounds
*/
-bool XmlReader::match(int pos, char const *str)
+bool XmlReader::match(int pos, const char *str)
{
while (*str)
{
@@ -883,8 +883,9 @@ XmlReader::parse(const DOMString &str)
{
DocumentPtr doc = parse(str, 0, str.size());
+ if (!doc)
+ return doc;
doc->normalizeDocument();
-
return doc;
}
@@ -892,12 +893,15 @@ XmlReader::parse(const DOMString &str)
*
*/
org::w3c::dom::DocumentPtr
-XmlReader::parseFile(char *fileName)
+XmlReader::parseFile(const DOMString &fileName)
{
-
+ DocumentPtr doc;
+
DOMString buf = loadFile(fileName);
+ if (buf.size() == 0)
+ return doc; /*doc still null*/
- DocumentPtr doc = parse(buf, 0, buf.size());
+ doc = parse(buf, 0, buf.size());
return doc;
}
@@ -912,16 +916,19 @@ XmlReader::parseFile(char *fileName)
*
*/
org::w3c::dom::DOMString
-XmlReader::loadFile(char *fileName)
+XmlReader::loadFile(const DOMString &fileName)
{
+ DOMString buf;
- if (!fileName)
- return NULL;
- FILE *f = fopen(fileName, "rb");
+ if (fileName.size() == 0)
+ return buf;
+ FILE *f = fopen(fileName.c_str(), "rb");
if (!f)
- return NULL;
+ {
+ //error here
+ return buf;
+ }
- DOMString buf;
while (!feof(f))
{
int ch = fgetc(f);