summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5726e06)
raw | patch | inline | side by side (parent: 5726e06)
author | ishmal <ishmal@users.sourceforge.net> | |
Sat, 22 Apr 2006 10:48:46 +0000 (10:48 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Sat, 22 Apr 2006 10:48:46 +0000 (10:48 +0000) |
diff --git a/src/dom/cssparser.cpp b/src/dom/cssparser.cpp
index 2dc342704f8faa556a42dd3f41e05228045620a9..8f245c06dfa90d0d9f3cee647e8ab9aa05f4229a 100644 (file)
--- a/src/dom/cssparser.cpp
+++ b/src/dom/cssparser.cpp
{
while (*str)
{
- if (get(pos++) != *str++)
+ if (get(pos++) != (XMLCh) *str++)
return false;
}
return true;
int ch = fgetc(f);
if (ch<0)
break;
- str.push_back(ch);
+ str.push_back((XMLCh)ch);
}
fclose(f);
diff --git a/src/dom/dom.h b/src/dom/dom.h
index d533a7dca6a721be28fb85822e1401282b0dc57b..2248ad61f0512a2ca0892e66e71a2ddbf24bbb4d 100644 (file)
--- a/src/dom/dom.h
+++ b/src/dom/dom.h
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <string>
#include <vector>
-#define OWN_STRING
+#define DOM_STRING_GLIBMM
-#ifdef OWN_STRING
+#ifdef DOM_STRING_OWN
#include "domstring.h"
#else
+#ifdef DOM_STRING_GLIBMM
#include <glibmm.h>
-typedef Glib::ustring DOMString
+#else
+#include <string>
+#endif
#endif
#define XMLNSNAME "http://www.w3.org/2000/xmlns/"
-#ifndef OWN_STRING
-typedef unsigned short XMLCh;
+#ifdef DOM_STRING_OWN
+#else
+#ifdef DOM_STRING_GLIBMM
+typedef Glib::ustring DOMString;
+typedef gunichar XMLCh;
+#else
typedef std::string DOMString;
+typedef unsigned short XMLCh;
#endif
+#endif
+
/**
*
diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp
index b3197c94805dfe5f69c517b4b84b0a13ac98236f..e9da6291fb3dadec082bb97ef7b639c2b90f47e1 100644 (file)
--- a/src/dom/domimpl.cpp
+++ b/src/dom/domimpl.cpp
}
else
{
- localName.push_back(ch);
+ localName.push_back((XMLCh)ch);
}
}
}
diff --git a/src/dom/lsimpl.cpp b/src/dom/lsimpl.cpp
index 636dc6750d5f679ac4ee9f18a8423b61c60afa61..65807cc459ea4ca088fc2bea6e65d863d94e45ba 100644 (file)
--- a/src/dom/lsimpl.cpp
+++ b/src/dom/lsimpl.cpp
int ch = lsreader->get();
if (ch < 0)
break;
- buf.push_back(ch);
+ buf.push_back((XMLCh)ch);
}
XmlReader reader;
Document *doc = reader.parse(buf);
int ch = inputStream->get();
if (ch < 0)
break;
- buf.push_back(ch);
+ buf.push_back((XMLCh)ch);
}
XmlReader reader;
Document *doc = reader.parse(buf);
{
outbuf = "";
indent = 0;
-
+
writeNode(nodeArg);
//## Check in order specified in the L&S specs
index df0470045f041b747eeac74510de3c5ec46a85b4..d2da3150c668ad6be2d6d0e58f0b8fb4aefa44ef 100644 (file)
{
while (*str)
{
- if (get(pos++) != *str++)
+ if (get(pos++) != (XMLCh) *str++)
return false;
}
return true;
diff --git a/src/dom/uri.cpp b/src/dom/uri.cpp
index 8f5cf976d9ee92c7b4fb200d496e715b8e1bf8e5..286857e4177c7c87bb160991f90fd613f3f5f729 100644 (file)
--- a/src/dom/uri.cpp
+++ b/src/dom/uri.cpp
URI::URI(const URI &other)
{
init();
- scheme = other.scheme;
- schemeStr = other.schemeStr;
- authority = other.authority;
- port = other.port;
- path = other.path;
- absolute = other.absolute;
- query = other.query;
- fragment = other.fragment;
+ assign(other);
+}
+
+
+/**
+ *
+ */
+URI &URI::operator=(const URI &other)
+{
+ init();
+ assign(other);
+ return *this;
}
authority = "";
path = "";
absolute = false;
+ opaque = false;
query = "";
fragment = "";
}
+/**
+ *
+ */
+void URI::assign(const URI &other)
+{
+ scheme = other.scheme;
+ schemeStr = other.schemeStr;
+ authority = other.authority;
+ port = other.port;
+ path = other.path;
+ absolute = other.absolute;
+ opaque = other.opaque;
+ query = other.query;
+ fragment = other.fragment;
+}
+
//#########################################################################
//#A T T R I B U T E S
}
-bool URI::getIsAbsolute() const
+bool URI::isAbsolute() const
{
return absolute;
}
+bool URI::isOpaque() const
+{
+ return opaque;
+}
+
DOMString URI::getQuery() const
{
DOMString URI::getFragment() const
{
return fragment;
+}
+
+
+URI URI::resolve(const URI &other) const
+{
+ //### According to w3c, this is handled in 3 cases
+
+ //## 1
+ if (opaque || other.isAbsolute())
+ return other;
+
+ //## 2
+ if (other.fragment.size() > 0 &&
+ other.path.size() == 0 &&
+ other.scheme == SCHEME_NONE &&
+ other.authority.size() == 0 &&
+ other.query.size() == 0 )
+ {
+ URI fragUri = *this;
+ fragUri.fragment = other.fragment;
+ return fragUri;
+ }
+
+ //## 3 http://www.ietf.org/rfc/rfc2396.txt, section 5.2
+ URI newUri;
+ //# 3.1
+ newUri.scheme = scheme;
+ newUri.schemeStr = schemeStr;
+ newUri.query = other.query;
+ newUri.fragment = other.fragment;
+ if (other.authority.size() > 0)
+ {
+ //# 3.2
+ if (absolute || other.absolute)
+ newUri.absolute = true;
+ newUri.authority = other.authority;
+ newUri.port = other.port;//part of authority
+ newUri.path = other.path;
+ }
+ else
+ {
+ //# 3.3
+ if (other.absolute)
+ {
+ newUri.absolute = true;
+ newUri.path = other.path;
+ }
+ else
+ {
+ unsigned int pos = path.rfind('/');
+ if (pos != path.npos)
+ {
+ DOMString tpath = path.substr(pos);
+ tpath.append(other.path);
+ newUri.path = tpath;
+ newUri.normalize();
+ }
+ }
+ }
+ return newUri;
+}
+
+
+/**
+ *
+ */
+void URI::normalize() const
+{
+
+
+
+
+
+
}
else if (ch == ':')
portSpecified = true;
else if (portSpecified)
- portStr.push_back(ch);
+ portStr.push_back((XMLCh)ch);
else
- authority.push_back(ch);
+ authority.push_back((XMLCh)ch);
p++;
}
if (portStr.size() > 0)
if (ch == '/')
{
absolute = true;
- path.push_back(ch);
+ if (p>p0) //in other words, if '/' is not the first char
+ opaque = true;
+ path.push_back((XMLCh)ch);
p++;
}
ch = peek(p);
if (ch == '?' || ch == '#')
break;
- path.push_back(ch);
+ path.push_back((XMLCh)ch);
p++;
}
ch = peek(p);
if (ch == '#')
break;
- query.push_back(ch);
+ query.push_back((XMLCh)ch);
p++;
}
ch = peek(p);
if (ch == '?')
break;
- fragment.push_back(ch);
+ fragment.push_back((XMLCh)ch);
p++;
}
diff --git a/src/dom/uri.h b/src/dom/uri.h
index 722205036f6190d022d289c2c21d599bac092ee3..0de5420edcd1cea7222b8d426d74865593e8ebe0 100644 (file)
--- a/src/dom/uri.h
+++ b/src/dom/uri.h
*/
URI(const URI &other);
+ /**
+ * Assignment
+ */
+ URI &URI::operator=(const URI &other);
+
/**
*
*/
/**
*
*/
- virtual bool getIsAbsolute() const;
+ virtual bool isAbsolute() const;
+
+ /**
+ *
+ */
+ virtual bool isOpaque() const;
/**
*
*/
virtual DOMString getFragment() const;
+ /**
+ *
+ */
+ virtual URI resolve(const URI &other) const;
+
+ /**
+ *
+ */
+ virtual void normalize() const;
+
private:
void init();
+ //assign values of other to this. used by copy constructor
+ void assign(const URI &other);
+
int scheme;
DOMString schemeStr;
bool absolute;
+ bool opaque;
+
DOMString query;
DOMString fragment;
index b3c5ec9b0f31462190ed882696e595a0a988521f..99df889d9e3c98b1ea86ad045d3b6dfb6fa9107e 100644 (file)
--- a/src/dom/util/ziptool.cpp
+++ b/src/dom/util/ziptool.cpp
void encodeLiteralStatic(unsigned int ch);\r
\r
unsigned char windowBuf[32768];\r
+ //assume 32-bit ints\r
+ unsigned int windowHashBuf[32768];\r
};\r
\r
\r
*/\r
bool Deflater::compressWindow()\r
{\r
+ windowPos = 0;\r
unsigned int windowSize = window.size();\r
//### Compress as much of the window as possible\r
- int i=0;\r
- std::vector<unsigned char>::iterator iter;\r
- for (iter=window.begin() ; iter!=window.end() ; iter++)\r
- windowBuf[i++] = *iter;\r
\r
- while (windowPos < windowSize)\r
+ unsigned int hash = 0;\r
+ //Have each value be a long with the byte at this position,\r
+ //plus the 3 bytes after it in the window\r
+ for (int i=windowSize-1 ; i>=0 ; i--)\r
+ {\r
+ unsigned char ch = window[i];\r
+ windowBuf[i] = ch;\r
+ hash = ((hash<<8) & 0xffffff00) | ch;\r
+ windowHashBuf[i] = hash;\r
+ }\r
+\r
+ while (windowPos < windowSize - 3)\r
{\r
//### Find best match, if any\r
unsigned int bestMatchLen = 0;\r
{\r
for (unsigned int lookBack=0 ; lookBack<windowPos-4 ; lookBack++)\r
{\r
- unsigned int lookAhead=0;\r
- unsigned char *wp = &(windowBuf[windowPos]);\r
- unsigned char *lb = &(windowBuf[lookBack]);\r
- //Check first char, before continuing with string\r
- if (*lb++ == *wp++)\r
+ //Check 4-char hashes first, before continuing with string\r
+ if (windowHashBuf[lookBack] == windowHashBuf[windowPos])\r
{\r
- unsigned int lookAheadMax = windowSize - windowPos;\r
- if (lookBack + lookAheadMax >= windowPos)\r
- lookAheadMax = windowPos - lookBack;\r
+ unsigned int lookAhead=4;\r
+ unsigned int lookAheadMax = windowSize - 4 - windowPos;\r
+ if (lookBack + lookAheadMax >= windowPos -4 )\r
+ lookAheadMax = windowPos - 4 - lookBack;\r
if (lookAheadMax > 258)\r
lookAheadMax = 258;\r
- for (lookAhead = 1 ; lookAhead<lookAheadMax ; lookAhead++)\r
+ unsigned char *wp = &(windowBuf[windowPos+4]);\r
+ unsigned char *lb = &(windowBuf[lookBack+4]);\r
+ while (lookAhead<lookAheadMax)\r
{\r
if (*lb++ != *wp++)\r
break;\r
+ lookAhead++;\r
+ }\r
+ if (lookAhead > bestMatchLen)\r
+ {\r
+ bestMatchLen = lookAhead;\r
+ bestMatchDist = windowPos - lookBack;\r
}\r
- }\r
- if (lookAhead > bestMatchLen)\r
- {\r
- bestMatchLen = lookAhead;\r
- bestMatchDist = windowPos - lookBack;\r
}\r
}\r
}\r
}\r
}\r
\r
+ while (windowPos < windowSize)\r
+ encodeLiteralStatic(windowBuf[windowPos++]);\r
+\r
encodeLiteralStatic(256);\r
return true;\r
}\r
for (iter = uncompressed.begin(); iter != uncompressed.end() ; )\r
{\r
total += windowPos;\r
- //trace("total:%ld", total);\r
+ trace("total:%ld", total);\r
+ if (windowPos > window.size())\r
+ windowPos = window.size();\r
window.erase(window.begin() , window.begin()+windowPos);\r
while (window.size() < 32768 && iter != uncompressed.end())\r
{\r
window.push_back(*iter);\r
iter++;\r
}\r
- windowPos = 0;\r
if (window.size() >= 32768)\r
putBits(0x00, 1); //0 -- more blocks\r
else\r
\r
if (uncompressedSize != uncompBuf.size())\r
{\r
- error("Size mismatch. Received %ld, received %ld",\r
+ error("Size mismatch. Expected %ld, received %ld",\r
uncompressedSize, uncompBuf.size());\r
return false;\r
}\r
diff --git a/src/dom/xmlreader.cpp b/src/dom/xmlreader.cpp
index 218a71b6fe209e0a8d6cb7784fc1a48f172478c9..c36eec961c7dbd05e7a4f9dddc2042cc2d10e796 100644 (file)
--- a/src/dom/xmlreader.cpp
+++ b/src/dom/xmlreader.cpp
int b = get(p);\r
if (b<=' ' || b=='/' || b=='>' || b=='=')\r
break;\r
- result.push_back(b);\r
+ result.push_back((XMLCh)b);\r
p++;\r
}\r
return p;\r
shortWord = "";\r
}\r
else\r
- shortWord.push_back(b);\r
+ shortWord.push_back((XMLCh)b);\r
p++;\r
}\r
if (prefix.size() > 0)\r
}\r
else\r
{\r
- buf.push_back(b);\r
+ buf.push_back((XMLCh)b);\r
}\r
}\r
\r
break;\r
}\r
int ch = get(p++);\r
- buf.push_back(ch);\r
+ buf.push_back((XMLCh)ch);\r
}\r
\r
comment->setNodeValue(buf);\r
break;\r
}\r
int ch = get(p++);\r
- buf.push_back(ch);\r
+ buf.push_back((XMLCh)ch);\r
}\r
\r
/*printf("Got CDATA:%s\n",buf.c_str());*/\r
else\r
{\r
int ch = get(p++);\r
- buf.push_back(ch);\r
+ buf.push_back((XMLCh)ch);\r
}\r
}\r
\r
int ch = fgetc(f);\r
if (ch<0)\r
break;\r
- buf.push_back(ch);\r
+ buf.push_back((XMLCh)ch);\r
}\r
fclose(f);\r
\r
index b7d118d455c738c4adbabe84f0f9c0b8893f2562..6baaea9c5946eb3386be9f380f9c8b812fc8c1b6 100644 (file)
--- a/src/dom/xpathparser.cpp
+++ b/src/dom/xpathparser.cpp
if (!isLetterOrDigit(ch))\r
break;\r
ch = get(p++);\r
- str.push_back(ch);\r
+ str.push_back((XMLCh)ch);\r
}\r
return p;\r
}\r
}\r
else if (!isDigit(ch))\r
break;\r
- num.push_back(ch);\r
+ num.push_back((XMLCh)ch);\r
i++;\r
}\r
\r
ch = peek(p);\r
if (ch == quotechar)\r
break;\r
- result.push_back(ch);\r
+ result.push_back((XMLCh)ch);\r
p++;\r
}\r
p++; //skip over closing "\r
if (ch != '_' && !isLetter(ch))\r
return p0;\r
\r
- result.push_back(ch);\r
+ result.push_back((XMLCh)ch);\r
p++;\r
while (p < parselen)\r
{\r
isExtender(ch) ||\r
ch == '.' || ch == '-' || ch == '_' )\r
{\r
- result.push_back(ch);\r
+ result.push_back((XMLCh)ch);\r
p++;\r
}\r
else\r
int ch = peek(p);\r
if (ch == '*')\r
{\r
- result.push_back(ch);\r
+ result.push_back((XMLCh)ch);\r
p++;\r
return p;\r
}\r
ch = peek(p);\r
if (ch == '*')\r
{\r
- result.push_back(ch);\r
+ result.push_back((XMLCh)ch);\r
p++;\r
return p;\r
}\r