some bugfixes

master
Marc Wäckerlin 16 years ago
parent bca65f97a0
commit 67d71161b3
  1. 2
      configure.in
  2. 2
      doc/makefile.am
  3. 9
      install-64-and-32-bit-linux.sh
  4. 4
      src/xml-cxx/xml.hxx
  5. 47
      src/xml.cxx

@ -5,7 +5,7 @@ TST_DIR=test
DOC_DIR=doc
m4_define(x_packagename, libxml-cxx)
m4_define(x_major, 0)
m4_define(x_major, 1)
m4_define(x_minor, 0)
m4_define(x_least, 0)
AM_INIT_AUTOMAKE(x_packagename, x_major.x_minor.x_least, [marc@waeckerlin.org])

@ -8,7 +8,7 @@
develdir = ${pkgdatadir}/doc
devel_DATA = html/index.html
ALL_SRC = ${top_srcdir}/src/*.[ch]xx ${top_srcdir}/test/*.[ch]xx
ALL_SRC = ${top_srcdir}/*/*.[ch]xx ${top_srcdir}/*/*/*.[ch]xx
DIRS = html latex

@ -1,8 +1,4 @@
./bootstrap.sh && \
./configure && \
make && \
sudo make install && \
make clean && \
LDFLAGS="-L/usr/lib32 -m32" CXXFLAGS="-m32" ./configure \
--libdir=/usr/local/lib32 \
--build=x86_64 \
@ -16,5 +12,8 @@ make clean && \
--host=i586-mingw32msvc && \
make && \
sudo make install && \
make clean
make clean && \
./configure && \
make check && \
sudo make install

@ -110,6 +110,7 @@ namespace xml {
exception(std::string reason) throw();
exception(std::string reason, const Node& t) throw();
~exception() throw();
void line(unsigned long line) throw();
const char* what() const throw();
private:
std::string _what;
@ -402,7 +403,7 @@ namespace xml {
friend class stream_error;
Factory(); // not implemented
Factory(const Factory&); // not implemented
bool ws(char c) const throw();
bool ws(char c) throw();
std::auto_ptr<Node> read(std::istream& is, const Node& position)
throw(wrong_end_tag, wrong_start_tag, tag_expected, type_mismatch,
second_slash_in_tag, character_after_slash,
@ -414,6 +415,7 @@ namespace xml {
missing_end_tag,
attribute_value_not_quoted, access_error, duplicate_attribute);
std::auto_ptr<Node> _template;
unsigned long _line;
};
}

@ -49,6 +49,11 @@ namespace xml {
exception::~exception() throw() {
delete _node;
}
void exception::line(unsigned long line) throw() {
std::stringstream ss;
ss<<line;
_what += "\nat line: "+ss.str();
}
const char* exception::what() const throw() {
static std::string w;
if (!w.size()) {
@ -450,7 +455,7 @@ namespace xml {
}
//----------------------------------------------------------------------------
Factory::Factory(const Node& t) throw(): _template(t.clone()) {}
Factory::Factory(const Node& t) throw(): _template(t.clone()), _line(0) {}
const Node& Factory::operator*() const throw() {
return *_template;
}
@ -459,24 +464,32 @@ namespace xml {
second_slash_in_tag,
character_after_slash, missing_end_tag, attribute_value_not_quoted,
access_error, empty_stream, duplicate_attribute,
attributes_in_end_tag) {
attributes_in_end_tag) try {
_line=1;
std::auto_ptr<Node> node(_template->clone());
node->clear();
Tag res;
try {
while (true) try {
res = tag(is, *node);
*node<<res.attributes;
switch (res.type) {
case END: throw wrong_end_tag(*node, is, res);
case EMPTY: return node; // empty
case START: return read(is, *_template);
//! @todo store instead of ignore
case SPECIAL: break;
}
} catch (missing_end_tag&) {
throw empty_stream(*node, is, res);
}
*node<<res.attributes;
while (true) switch (res.type) {
case END: throw wrong_end_tag(*node, is, res);
case EMPTY: return node; // empty
case START: return read(is, *_template);
case SPECIAL: break; //! @todo ignored could be stored
}
}
bool Factory::ws(char c) const throw() {
} catch (exception& e) {
e.line(_line);
throw;
}
bool Factory::ws(char c) throw() {
static char last(0);
if ((c=='\n'||c=='\r')&&last!='\n'&&last!='\r') ++_line;
last = c;
return c==' '||c=='\t'||c=='\n'||c=='\r';
}
std::auto_ptr<Node> Factory::read(std::istream& is, const Node& node)
@ -516,8 +529,10 @@ namespace xml {
if (!is) throw missing_end_tag(position, is, tag);
if (c!='<') do tag.text+=c; while (is && is.get(c) && c!='<');
bool nameRead(false);
for (char last(c); is && is.get(c) && c!='>'; last = c) switch (c) {
case ' ': case '\t': case '\n': case '\r':
for (char last(c); is && is.get(c) && c!='>'; last=c) switch (c) {
case '\n': case '\r':
if (last!='\n'&&last!='\r') ++_line;
case ' ': case '\t':
if (!nameRead && tag.name.size()) nameRead=true;
break;
case '/':
@ -527,14 +542,16 @@ namespace xml {
break;
case '!': case '?':
if (last=='<') { // <! tag or <?xml.. starts
tag.special+=last;
do tag.special+=c; while (c!='>' && is && is.get(c));
tag.type=SPECIAL;
return tag;
}
default:
if (tag.type==EMPTY) throw character_after_slash(position, is, tag, c);
if (nameRead) { // read attribute
std::string attrname(1, c), attrvalue;
while (is && is.get(c) && c!='=' && !ws(c)) attrname+=c;
while (is && is.get(c) && c!='=' && c!='>' && !ws(c)) attrname+=c;
while (c!='=' && is && is.get(c) && ws(c)); // skip ws, search '='
if (c=='=') { // get the value
while (is && is.get(c) && ws(c)); // skip ws

Loading…
Cancel
Save