From 828599ce9e52bcd6a35d6b15bd7be4ed1199a90f Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz Date: Sun, 22 Apr 2012 18:51:24 +0000 Subject: [PATCH] [GB.XML] * BUG: the parser now supports white spaces (http://www.w3.org/TR/REC-xml/#NT-S git-svn-id: svn://localhost/gambas/trunk@4657 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.xml/src/element.cpp | 7 ++++++- gb.xml/src/main.cpp | 13 +++++++++++++ gb.xml/src/main.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gb.xml/src/element.cpp b/gb.xml/src/element.cpp index 2ff588bf1..39ed1d534 100644 --- a/gb.xml/src/element.cpp +++ b/gb.xml/src/element.cpp @@ -364,14 +364,19 @@ vector* Element::fromText(wstring data, wstring::size_type i, uint c, uin attr += s; INC; } + + while(i < data.length() && isWhiteSpace(s)) INC; + if(s != L"=") { i -= attr.length(); CLEAR throw HTMLParseException(c, l, NEAR, L"Expected '=' after attribute name."); } - INC; + + while(i < data.length() && isWhiteSpace(s)) INC; + wstring delimiter = s; if(delimiter != L"\"" && delimiter != L"'"){//Pas de délimiteur diff --git a/gb.xml/src/main.cpp b/gb.xml/src/main.cpp index d040c6808..19aabfe9d 100644 --- a/gb.xml/src/main.cpp +++ b/gb.xml/src/main.cpp @@ -180,6 +180,19 @@ bool isNameChar(wstring &s) (car == 0xB7) || INTER(0x0300, 0x036F) || INTER(0x203F, 0x2040); } +/* http://www.w3.org/TR/REC-xml/#NT-S + + S ::= (#x20 | #x9 | #xD | #xA)+ + + */ + +bool isWhiteSpace(wstring &s) +{ + const wchar_t car = (s.at(0)); + + return (car == 0x20) || (car == 0x9) || (car == 0xD) || (car == 0xA); +} + #ifndef __HMAIN_CPP GB_INTERFACE GB EXPORT; diff --git a/gb.xml/src/main.h b/gb.xml/src/main.h index 1c56a582e..6eb09d268 100644 --- a/gb.xml/src/main.h +++ b/gb.xml/src/main.h @@ -66,6 +66,7 @@ extern "C" GB_INTERFACE GB; bool isNameStartChar(wstring &s); bool isNameChar(wstring &s); +bool isWhiteSpace(wstring &s);