Fix for bug 146967 (Clean up Transformiix strings). r=Pike, sr=jst.

This commit is contained in:
peterv%netscape.com 2002-07-02 14:15:01 +00:00
Родитель f3c2d92ed8
Коммит 8bf305a18f
57 изменённых файлов: 1119 добавлений и 1834 удалений

Просмотреть файл

@ -65,7 +65,6 @@ LOBJS =../source/base/ArrayList.$(OBJ_SUFFIX) \
../source/base/Tokenizer.$(OBJ_SUFFIX) \ ../source/base/Tokenizer.$(OBJ_SUFFIX) \
../source/base/txAtoms.$(OBJ_SUFFIX) \ ../source/base/txAtoms.$(OBJ_SUFFIX) \
../source/base/txExpandedNameMap.$(OBJ_SUFFIX) \ ../source/base/txExpandedNameMap.$(OBJ_SUFFIX) \
../source/base/MozillaString.$(OBJ_SUFFIX) \
../source/base/txURIUtils.$(OBJ_SUFFIX) \ ../source/base/txURIUtils.$(OBJ_SUFFIX) \
../source/xml/dom/mozImpl/MozillaObjectWrapper.$(OBJ_SUFFIX) \ ../source/xml/dom/mozImpl/MozillaObjectWrapper.$(OBJ_SUFFIX) \
../source/xml/dom/mozImpl/MozillaAttr.$(OBJ_SUFFIX) \ ../source/xml/dom/mozImpl/MozillaAttr.$(OBJ_SUFFIX) \

Просмотреть файл

@ -50,7 +50,6 @@ CPP_OBJS= \
..\source\base\$(OBJDIR)\Tokenizer.obj \ ..\source\base\$(OBJDIR)\Tokenizer.obj \
..\source\base\$(OBJDIR)\txAtoms.obj \ ..\source\base\$(OBJDIR)\txAtoms.obj \
..\source\base\$(OBJDIR)\txExpandedNameMap.obj \ ..\source\base\$(OBJDIR)\txExpandedNameMap.obj \
..\source\base\$(OBJDIR)\MozillaString.obj \
..\source\base\$(OBJDIR)\txURIUtils.obj \ ..\source\base\$(OBJDIR)\txURIUtils.obj \
..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaObjectWrapper.obj \ ..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaObjectWrapper.obj \
..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaAttr.obj \ ..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaAttr.obj \

Просмотреть файл

@ -1121,13 +1121,6 @@
<FILEKIND>Text</FILEKIND> <FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS> <FILEFLAGS></FILEFLAGS>
</FILE> </FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>MozillaString.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE> <FILE>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>
<PATH>XMLUtils.cpp</PATH> <PATH>XMLUtils.cpp</PATH>
@ -2045,11 +2038,6 @@
<PATH>MozillaNotation.cpp</PATH> <PATH>MozillaNotation.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT> <PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF> </FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>MozillaString.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF> <FILEREF>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>
<PATH>XMLParser.cpp</PATH> <PATH>XMLParser.cpp</PATH>
@ -3219,13 +3207,6 @@
<FILEKIND>Text</FILEKIND> <FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS> <FILEFLAGS></FILEFLAGS>
</FILE> </FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>MozillaString.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE> <FILE>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>
<PATH>XMLUtils.cpp</PATH> <PATH>XMLUtils.cpp</PATH>
@ -4159,11 +4140,6 @@
<PATH>MozillaNotation.cpp</PATH> <PATH>MozillaNotation.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT> <PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF> </FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>MozillaString.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF> <FILEREF>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>
<PATH>NSPR20.shlb</PATH> <PATH>NSPR20.shlb</PATH>
@ -4395,12 +4371,6 @@
<PATH>Map.cpp</PATH> <PATH>Map.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT> <PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF> </FILEREF>
<FILEREF>
<TARGETNAME>transformiixDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>MozillaString.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF> <FILEREF>
<TARGETNAME>transformiixDebug.shlb</TARGETNAME> <TARGETNAME>transformiixDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE> <PATHTYPE>Name</PATHTYPE>

Просмотреть файл

@ -47,7 +47,7 @@ void CommandLineUtils::getOptions
//-- check full flag, otherwise try to find //-- check full flag, otherwise try to find
//-- flag within string //-- flag within string
if (!flags.contains(flag)) { if (!flags.contains(flag)) {
PRInt32 idx = 1; PRUint32 idx = 1;
String tmpFlag; String tmpFlag;
while(idx <= flag.length()) { while(idx <= flag.length()) {
flag.subString(0,idx, tmpFlag); flag.subString(0,idx, tmpFlag);

Просмотреть файл

@ -35,6 +35,7 @@
*/ */
#include "primitives.h" #include "primitives.h"
#include "XMLUtils.h"
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef WIN32 #ifdef WIN32
@ -130,17 +131,15 @@ MBool Double::isNeg(double aDbl)
*/ */
double Double::toDouble(const String& aSrc) double Double::toDouble(const String& aSrc)
{ {
PRInt32 idx = 0; PRUint32 idx = 0;
PRInt32 len = aSrc.length(); PRUint32 len = aSrc.length();
MBool digitFound = MB_FALSE; MBool digitFound = MB_FALSE;
// leading whitespace // leading whitespace
while (idx < len && while (idx < len &&
(aSrc.charAt(idx) == ' ' || XMLUtils::isWhitespace(aSrc.charAt(idx))) {
aSrc.charAt(idx) == '\n' ||
aSrc.charAt(idx) == '\r' ||
aSrc.charAt(idx) == '\t'))
++idx; ++idx;
}
// sign char // sign char
if (idx < len && aSrc.charAt(idx) == '-') if (idx < len && aSrc.charAt(idx) == '-')
@ -168,12 +167,10 @@ double Double::toDouble(const String& aSrc)
} }
// ending whitespace // ending whitespace
while ((aSrc.charAt(idx) == ' ' || while (idx < len &&
aSrc.charAt(idx) == '\n' || XMLUtils::isWhitespace(aSrc.charAt(idx))) {
aSrc.charAt(idx) == '\r' ||
aSrc.charAt(idx) == '\t') &&
idx < len)
++idx; ++idx;
}
// "."==NaN, ".0"=="0."==0 // "."==NaN, ".0"=="0."==0
if (digitFound && idx == len) { if (digitFound && idx == len) {

Просмотреть файл

@ -54,8 +54,6 @@ CPPSRCS = ArrayList.cpp \
ifdef TX_EXE ifdef TX_EXE
CPPSRCS += CommandLineUtils.cpp \ CPPSRCS += CommandLineUtils.cpp \
TxString.cpp TxString.cpp
else
CPPSRCS += MozillaString.cpp
endif endif
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

Просмотреть файл

Просмотреть файл

@ -143,15 +143,6 @@ void NamedMap::dumpMap() {
#endif #endif
} //-- dumpMap } //-- dumpMap
/**
* Returns the object reference in this Map associated with the given name
* @return the object reference in this Map associated with the given name
**/
TxObject* NamedMap::get(const char* key) {
String sKey = key;
return get(sKey);
} //-- get
/** /**
* Returns the object reference in this Map associated with the given name * Returns the object reference in this Map associated with the given name
* @return the object reference in this Map associated with the given name * @return the object reference in this Map associated with the given name
@ -190,15 +181,6 @@ StringList* NamedMap::keys() {
return list; return list;
} //-- keys } //-- keys
/**
* Adds the specified Node to the top of this Stack.
* @param node the Node to add to the top of the Stack
**/
void NamedMap::put(const char* key, TxObject* obj) {
String sKey = key;
put(sKey, obj);
} //-- put
/** /**
* Adds the specified Node to the top of this Stack. * Adds the specified Node to the top of this Stack.
* @param node the Node to add to the top of the Stack * @param node the Node to add to the top of the Stack
@ -333,17 +315,14 @@ NamedMap::BucketItem* NamedMap::getBucketItem(const String& key) {
/** /**
**/ **/
unsigned long NamedMap::hashKey(const String& key) { unsigned long NamedMap::hashKey(const String& key)
{
PRInt32 len = key.length(); PRUint32 len = key.length();
UNICODE_CHAR* chars = new UNICODE_CHAR[len];
key.toUnicode(chars);
unsigned long hashCode = 0; unsigned long hashCode = 0;
for (PRInt32 i = 0; i < len; i++) { for (PRUint32 i = 0; i < len; ++i) {
hashCode += ((PRInt32)chars[i]) << 3; hashCode += ((PRInt32)key.charAt(i)) << 3;
} }
delete [] chars;
return hashCode; return hashCode;
} //-- hashKey } //-- hashKey

Просмотреть файл

@ -73,22 +73,11 @@ public:
**/ **/
TxObject* get(const String& name); TxObject* get(const String& name);
/**
* Returns the object reference in this Map associated with the given name
* @return the object reference in this Map associated with the given name
**/
TxObject* get(const char* name);
/** /**
* Adds the Object reference to the map and associates it with the given name * Adds the Object reference to the map and associates it with the given name
**/ **/
void put(const String& name, TxObject* obj); void put(const String& name, TxObject* obj);
/**
* Adds the Object reference to the map and associates it with the given name
**/
void put(const char* name, TxObject* obj);
/** /**
* Removes all elements from the Map table * Removes all elements from the Map table
**/ **/

Просмотреть файл

@ -55,6 +55,7 @@
*/ */
#include "Tokenizer.h" #include "Tokenizer.h"
#include "XMLUtils.h"
/* /*
* Creates a new Tokenizer using the given source string * Creates a new Tokenizer using the given source string
@ -67,10 +68,8 @@ txTokenizer::txTokenizer(const String& aSource)
// Advance to start pos // Advance to start pos
while (mCurrentPos < mSize) { while (mCurrentPos < mSize) {
UNICODE_CHAR ch = mSource.charAt(mCurrentPos);
// If character is not a whitespace, we are at start of first token // If character is not a whitespace, we are at start of first token
if (ch != ' ' && ch != '\n' && if (!XMLUtils::isWhitespace(mSource.charAt(mCurrentPos)))
ch != '\r' && ch != '\t')
break; break;
++mCurrentPos; ++mCurrentPos;
} }
@ -87,18 +86,15 @@ void txTokenizer::nextToken(String& aBuffer)
while (mCurrentPos < mSize) { while (mCurrentPos < mSize) {
UNICODE_CHAR ch = mSource.charAt(mCurrentPos++); UNICODE_CHAR ch = mSource.charAt(mCurrentPos++);
// If character is not a delimiter we append it // If character is not a delimiter we append it
if (ch == ' ' || ch == '\n' || if (XMLUtils::isWhitespace(ch))
ch == '\r' || ch == '\t')
break; break;
aBuffer.append(ch); aBuffer.append(ch);
} }
// Advance to next start pos // Advance to next start pos
while (mCurrentPos < mSize) { while (mCurrentPos < mSize) {
UNICODE_CHAR ch = mSource.charAt(mCurrentPos);
// If character is not a whitespace, we are at start of next token // If character is not a whitespace, we are at start of next token
if (ch != ' ' && ch != '\n' && if (!XMLUtils::isWhitespace(mSource.charAt(mCurrentPos)))
ch != '\r' && ch != '\t')
break; break;
++mCurrentPos; ++mCurrentPos;
} }

Просмотреть файл

@ -61,8 +61,8 @@ public:
private: private:
PRInt32 mCurrentPos; PRUint32 mCurrentPos;
PRInt32 mSize; PRUint32 mSize;
String mSource; String mSource;
}; };

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -25,186 +25,224 @@
* *
*/ */
#ifndef MITRE_STRING #ifndef txString_h__
#define MITRE_STRING #define txString_h__
#include "TxObject.h" #include "TxObject.h"
#include "baseutils.h" #include "baseutils.h"
#include <iostream.h>
#ifdef TX_EXE #ifdef TX_EXE
#include <iostream.h>
typedef unsigned short UNICODE_CHAR; typedef unsigned short UNICODE_CHAR;
const PRInt32 kNotFound = -1;
#else #else
#include "nsString.h" #include "nsString.h"
typedef PRUnichar UNICODE_CHAR; typedef PRUnichar UNICODE_CHAR;
#endif #endif
#ifndef NULL class String
#define NULL 0 #ifdef TX_EXE
: public TxObject
#endif #endif
#define NOT_FOUND -1
class String : public TxObject
{ {
//Translate UNICODE_CHARs to Chars and output to the provided stream public:
friend ostream& operator<<(ostream& output, const String& source); /*
* Default constructor.
*/
String();
public: #ifdef TX_EXE
String(); //Default Constructor, create an empty string /*
String(PRInt32 initSize); //Create an empty string of a specific size * Copying constructor.
String(const String& source); //Create a copy of the source string */
String(const char* source); //Create a string from the characters String(const String& aSource);
String(const UNICODE_CHAR* source);
String(const UNICODE_CHAR* source, PRInt32 length); /*
#ifndef TX_EXE * Constructor, allocates a buffer and copies the supplied string buffer.
String(nsString* theNSString); * If aLength is zero it computes the length from the supplied string.
*/
explicit String(const UNICODE_CHAR* aSource, PRUint32 aLength = 0);
#else
explicit String(const nsAString& aSource);
#endif #endif
~String();
~String(); //Destroy the string, and free memory /*
* Append aSource to this string.
*/
void append(UNICODE_CHAR aSource);
void append(const String& aSource);
/*
* Insert aSource at aOffset in this string.
*/
void insert(PRUint32 aOffset, UNICODE_CHAR aSource);
void insert(PRUint32 aOffset, const String& aSource);
//Assign source to this string /*
virtual String& operator=(const String& source); * Replace characters starting at aOffset with aSource.
virtual String& operator=(const char* source); */
virtual String& operator=(const UNICODE_CHAR* source); void replace(PRUint32 aOffset, UNICODE_CHAR aSource);
virtual String& operator=(PRInt32 source); void replace(PRUint32 aOffset, const String& aSource);
//Grow buffer if necessary and append the source /*
virtual void append(UNICODE_CHAR source); * Delete aCount characters starting at aOffset.
virtual void append(char source); */
virtual void append(const String& source); void deleteChars(PRUint32 aOffset, PRUint32 aCount);
virtual void append(const char* source);
virtual void append(const UNICODE_CHAR* source);
virtual void append(const UNICODE_CHAR* source, PRInt32 length);
virtual void append(PRInt32 source);
//Provide the ability to insert data into the middle of a string /*
virtual void insert(PRInt32 offset, const UNICODE_CHAR source); * Returns the character at aIndex. Caller needs to check the
virtual void insert(PRInt32 offset, const char source); * index for out-of-bounds errors.
virtual void insert(PRInt32 offset, const String& source); */
virtual void insert(PRInt32 offset, const char* source); UNICODE_CHAR charAt(PRUint32 aIndex) const;
virtual void insert(PRInt32 offset, const UNICODE_CHAR* source);
virtual void insert(PRInt32 offset, const UNICODE_CHAR* source,
PRInt32 sourceLength);
virtual void insert(PRInt32 offset, PRInt32 source);
//Provide the ability to replace one or more characters /*
virtual void replace(PRInt32 offset, const UNICODE_CHAR source); * Clear the string.
virtual void replace(PRInt32 offset, const char source); */
virtual void replace(PRInt32 offset, const String& source); void clear();
virtual void replace(PRInt32 offset, const char* source);
virtual void replace(PRInt32 offset, const UNICODE_CHAR* source);
virtual void replace(PRInt32 offset, const UNICODE_CHAR* source,
PRInt32 srcLength);
virtual void replace(PRInt32 offset, PRInt32 source);
//Provide the ability to delete a range of charactes /*
virtual void deleteChars(PRInt32 offset, PRInt32 count); * Returns index of first occurrence of aData.
*/
PRInt32 indexOf(UNICODE_CHAR aData,
PRInt32 aOffset = 0) const;
PRInt32 indexOf(const String& aData, PRInt32 aOffset = 0) const;
/** /*
* Returns the character at index. * Returns index of last occurrence of aData.
* If the index is out of bounds, -1 will be returned. */
**/ PRInt32 lastIndexOf(UNICODE_CHAR aData,
virtual UNICODE_CHAR charAt(PRInt32 index) const; PRInt32 aOffset = 0) const;
virtual void clear(); //Clear string /*
* Check equality between strings.
*/
MBool isEqual(const String& aData) const;
virtual void ensureCapacity(PRInt32 capacity); //Make sure buffer is at least /*
//'size' * Check equality (ignoring case) between strings.
*/
MBool isEqualIgnoreCase(const String& aData) const;
//Returns index of first occurrence of data /*
virtual PRInt32 indexOf(UNICODE_CHAR data) const; * Check whether the string is empty.
virtual PRInt32 indexOf(UNICODE_CHAR data, PRInt32 offset) const; */
virtual PRInt32 indexOf(const String& data) const; MBool isEmpty() const;
virtual PRInt32 indexOf(const String& data, PRInt32 offset) const;
virtual MBool isEqual(const String& data) const; //Check equality between /*
//strings * Return the length of the string.
virtual MBool isEqualIgnoreCase(const String& data) const; */
PRUint32 length() const;
//Returns index of last occurrence of data /*
virtual PRInt32 lastIndexOf(UNICODE_CHAR data) const;
virtual PRInt32 lastIndexOf(UNICODE_CHAR data, PRInt32 offset) const;
virtual PRInt32 lastIndexOf(const String& data) const;
virtual PRInt32 lastIndexOf(const String& data, PRInt32 offset) const;
//Checks whether the string is empty
virtual MBool isEmpty() const;
virtual PRInt32 length() const; //Returns the length
/**
* Sets the Length of this String, if length is less than 0, it will
* be set to 0; if length > current length, the string will be extended
* and padded with '\0' null characters. Otherwise the String
* will be truncated
**/
virtual void setLength(PRInt32 length);
/**
* Sets the Length of this String, if length is less than 0, it will
* be set to 0; if length > current length, the string will be extended
* and padded with given pad character. Otherwise the String
* will be truncated
**/
virtual void setLength(PRInt32 length, UNICODE_CHAR padChar);
/**
* Returns a substring starting at start * Returns a substring starting at start
* Note: the dest String is cleared before use * Note: the dest String is cleared before use
**/ */
virtual String& subString(PRInt32 start, String& dest) const; String& subString(PRUint32 aStart, String& aDest) const;
/** /*
* Returns the subString starting at start and ending at end * Returns the subString starting at start and ending at end
* Note: the dest String is cleared before use * Note: the dest String is cleared before use
**/ */
virtual String& subString(PRInt32 start, PRInt32 end, String& dest) const; String& subString(PRUint32 aStart, PRUint32 aEnd,
String& aDest) const;
//Convert the internal rep. to a char buffer /*
virtual char* toCharArray() const; * Convert string to lowercase.
virtual char* toCharArray(char* dest) const; */
virtual UNICODE_CHAR* toUnicode(UNICODE_CHAR* dest) const; void toLowerCase();
virtual const UNICODE_CHAR* toUnicode() const;
virtual void toLowerCase(); //Convert string to lowercase /*
virtual void toUpperCase(); //Convert string to uppercase * Convert string to uppercase.
virtual void trim(); //Trim whitespace from both ends */
void toUpperCase();
virtual void reverse(); //Reverse the string /*
* Shorten the string to aLength.
*/
void truncate(PRUint32 aLength);
#ifndef TX_EXE #ifdef TX_EXE
virtual nsString& getNSString(); /*
virtual const nsString& getConstNSString() const; * Assignment operator. Override default assignment operator
#endif * only on standalone, the default will do the right thing for
* module.
protected: */
//Convert an Int into a String String& operator = (const String& aSource);
//TK 12/09/1999 - Make this function available to Derrived classes
String& ConvertInt(PRInt32 value, String& target);
//Calculates the length of a null terminated UNICODE_CHAR array
PRInt32 UnicodeLength(const UNICODE_CHAR* data);
private:
#ifndef TX_EXE
nsString* ptrNSString;
#else #else
PRInt32 strLength; /*
PRInt32 bufferLength; * Return a reference to this string's nsString.
UNICODE_CHAR* strBuffer; */
nsString& getNSString();
/*
* Return a const reference to this string's nsString.
*/
const nsString& getConstNSString() const;
#endif #endif
//String copies itself to the destination private:
void copyString(UNICODE_CHAR* dest); #ifndef TX_EXE
nsString mString;
#else
/*
* Make sure the string buffer can hold aCapacity characters.
*/
MBool ensureCapacity(PRUint32 aCapacity);
//Compare the two string representations for equality /*
MBool isEqual(const UNICODE_CHAR* data, const UNICODE_CHAR* search, * Allocate a new UNICODE_CHAR buffer and copy this string's
PRInt32 length) const; * buffer into it. Caller needs to free the buffer.
*/
UNICODE_CHAR* toUnicode() const;
/*
* Compute the unicode length of aData.
*/
static PRUint32 unicodeLength(const UNICODE_CHAR* aData);
/*
* Translate UNICODE_CHARs to Chars and output to the provided stream.
*/
friend ostream& operator << (ostream& aOutput, const String& aSource);
UNICODE_CHAR* mBuffer;
PRUint32 mBufferLength;
PRUint32 mLength;
#endif
// XXX DEPRECATED
public:
explicit String(PRUint32 aSize);
explicit String(const char* aSource); // XXX Used for literal strings
void append(const char* aSource);
MBool isEqual(const char* aData) const;
char* toCharArray() const;
// XXX DEPRECATED
}; };
ostream& operator<<(ostream& output, const String& source); #ifdef TX_EXE
ostream& operator << (ostream& aOutput, const String& aSource);
inline UNICODE_CHAR String::charAt(PRUint32 aIndex) const
{
NS_ASSERTION(aIndex < mLength, "|charAt| out-of-range");
return mBuffer[aIndex];
}
inline MBool String::isEmpty() const
{
return (mLength == 0);
}
inline PRUint32 String::length() const
{
return mLength;
}
#else
// txMozillaString.h contains all inline implementations for the
// Mozilla module.
#include "txMozillaString.h"
#endif #endif
#endif // txString_h__

Просмотреть файл

@ -66,5 +66,9 @@
#define MB_FALSE PR_FALSE #define MB_FALSE PR_FALSE
#endif #endif
#ifndef NULL
#define NULL 0
#endif
#endif #endif

Просмотреть файл

@ -48,17 +48,13 @@ CPP_OBJS= \
.\$(OBJDIR)\Tokenizer.obj \ .\$(OBJDIR)\Tokenizer.obj \
.\$(OBJDIR)\txAtoms.obj \ .\$(OBJDIR)\txAtoms.obj \
.\$(OBJDIR)\txExpandedNameMap.obj \ .\$(OBJDIR)\txExpandedNameMap.obj \
.\$(OBJDIR)\txURIUtils.obj $(NULL)
!ifndef TX_EXE !ifdef TX_EXE
CPP_OBJS = $(CPP_OBJS) \ CPP_OBJS = \
.\$(OBJDIR)\MozillaString.obj \
$(NULL)
!else
CPP_OBJS = $(CPP_OBJS) \
.\$(OBJDIR)\CommandLineUtils.obj \ .\$(OBJDIR)\CommandLineUtils.obj \
.\$(OBJDIR)\TxString.obj \ .\$(OBJDIR)\TxString.obj \
$(NULL) $(CPP_OBJS)
!endif !endif
EXPORTS = \ EXPORTS = \

Просмотреть файл

@ -0,0 +1,231 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Van der Beken <peterv@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef txMozillaString_h__
#define txMozillaString_h__
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
MOZ_DECL_CTOR_COUNTER(String)
inline String::String()
{
MOZ_COUNT_CTOR(String);
}
inline String::String(const nsAString& aSource) : mString(aSource)
{
MOZ_COUNT_CTOR(String);
}
inline String::~String()
{
MOZ_COUNT_DTOR(String);
}
inline void String::append(UNICODE_CHAR aSource)
{
mString.Append(aSource);
}
inline void String::append(const String& aSource)
{
mString.Append(aSource.mString);
}
inline void String::insert(PRUint32 aOffset,
UNICODE_CHAR aSource)
{
mString.Insert(aSource, aOffset);
}
inline void String::insert(PRUint32 aOffset, const String& aSource)
{
mString.Insert(aSource.mString, aOffset);
}
inline void String::replace(PRUint32 aOffset,
UNICODE_CHAR aSource)
{
mString.SetCharAt(aSource, aOffset);
}
inline void String::replace(PRUint32 aOffset, const String& aSource)
{
mString.Replace(aOffset, mString.Length() - aOffset, aSource.mString);
}
inline void String::deleteChars(PRUint32 aOffset,
PRUint32 aCount)
{
mString.Cut(aOffset, aCount);
}
inline UNICODE_CHAR String::charAt(PRUint32 aIndex) const
{
return mString.CharAt(aIndex);
}
inline void String::clear()
{
mString.Truncate();
}
inline PRInt32 String::indexOf(UNICODE_CHAR aData,
PRInt32 aOffset) const
{
return mString.FindChar(aData, (PRUint32)aOffset);
}
inline PRInt32 String::indexOf(const String& aData,
PRInt32 aOffset) const
{
return mString.Find(aData.mString, aOffset);
}
inline PRInt32 String::lastIndexOf(UNICODE_CHAR aData,
PRInt32 aOffset) const
{
return mString.RFindChar(aData, aOffset);
}
inline MBool String::isEqual(const String& aData) const
{
if (this == &aData)
return MB_TRUE;
return mString.Equals(aData.mString);
}
inline MBool String::isEqualIgnoreCase(const String& aData) const
{
if (this == &aData)
return MB_TRUE;
return mString.Equals(aData.mString, nsCaseInsensitiveStringComparator());
}
inline MBool String::isEmpty() const
{
return mString.IsEmpty();
}
inline PRUint32 String::length() const
{
return mString.Length();
}
inline void String::truncate(PRUint32 aLength)
{
mString.Truncate(aLength);
}
inline String& String::subString(PRUint32 aStart, String& aDest) const
{
PRUint32 length = mString.Length() - aStart;
if (length < 0) {
aDest.clear();
}
else {
aDest.mString.Assign(Substring(mString, aStart, length));
}
return aDest;
}
inline String& String::subString(PRUint32 aStart, PRUint32 aEnd,
String& aDest) const
{
PRUint32 length = aEnd - aStart;
if (length < 0) {
aDest.clear();
}
else {
aDest.mString.Assign(Substring(mString, aStart, length));
}
return aDest;
}
inline void String::toLowerCase()
{
ToLowerCase(mString);
}
inline void String::toUpperCase()
{
ToUpperCase(mString);
}
inline nsString& String::getNSString()
{
return mString;
}
inline const nsString& String::getConstNSString() const
{
return mString;
}
// XXX DEPRECATED
inline String::String(PRUint32 aSize)
{
MOZ_COUNT_CTOR(String);
mString.SetCapacity(aSize);
}
inline String::String(const char* aSource)
{
MOZ_COUNT_CTOR(String);
mString.AssignWithConversion(aSource);
}
inline void String::append(const char* aSource)
{
mString.AppendWithConversion(aSource);
}
inline MBool String::isEqual(const char* aData) const
{
return mString.EqualsWithConversion(aData);
}
inline char* String::toCharArray() const
{
return ToNewCString(mString);
}
#endif // txMozillaString_h__

Просмотреть файл

@ -186,7 +186,7 @@ void URIUtils::resolveHref(const String& href, const String& base,
void URIUtils::getFragmentIdentifier(const String& href, String& frag) { void URIUtils::getFragmentIdentifier(const String& href, String& frag) {
PRInt32 pos; PRInt32 pos;
pos = href.lastIndexOf('#'); pos = href.lastIndexOf('#');
if(pos != NOT_FOUND) if(pos != kNotFound)
href.subString(pos+1, frag); href.subString(pos+1, frag);
else else
frag.clear(); frag.clear();
@ -195,7 +195,7 @@ void URIUtils::getFragmentIdentifier(const String& href, String& frag) {
void URIUtils::getDocumentURI(const String& href, String& docUri) { void URIUtils::getDocumentURI(const String& href, String& docUri) {
PRInt32 pos; PRInt32 pos;
pos = href.lastIndexOf('#'); pos = href.lastIndexOf('#');
if(pos != NOT_FOUND) if(pos != kNotFound)
href.subString(0,pos,docUri); href.subString(0,pos,docUri);
else else
docUri = href; docUri = href;

Просмотреть файл

@ -77,42 +77,43 @@ int main(int argc, char** argv) {
options.setObjectDeletion(MB_TRUE); options.setObjectDeletion(MB_TRUE);
CommandLineUtils::getOptions(options, argc, argv, flags); CommandLineUtils::getOptions(options, argc, argv, flags);
if (!options.get("q")) { if (!options.get(String("q"))) {
String copyright("(C) 1999 The MITRE Corporation, Keith Visco, and contributors"); String copyright("(C) 1999 The MITRE Corporation, Keith Visco, and contributors");
cerr << xsltProcessor.getAppName() << " "; cerr << xsltProcessor.getAppName() << " ";
cerr << xsltProcessor.getAppVersion() << endl; cerr << xsltProcessor.getAppVersion() << endl;
cerr << copyright << endl; cerr << copyright << endl;
//-- print banner line //-- print banner line
PRInt32 fillSize = copyright.length() + 1; PRUint32 fillSize = copyright.length() + 1;
String fill; PRUint32 counter;
fill.setLength(fillSize, '-'); for (counter = 0; counter < fillSize; ++counter)
cerr << fill << endl << endl; cerr << '-';
cerr << endl << endl;
} }
if (options.get("h")) { if (options.get(String("h"))) {
printHelp(); printHelp();
return 0; return 0;
} }
String* xmlFilename = (String*)options.get("i"); String* xmlFilename = (String*)options.get(String("i"));
String* xsltFilename = (String*)options.get("s"); String* xsltFilename = (String*)options.get(String("s"));
String* outFilename = (String*)options.get("o"); String* outFilename = (String*)options.get(String("o"));
//-- open XML file //-- open XML file
istream* xmlInput = &cin; istream* xmlInput = &cin;
if (xmlFilename && ! xmlFilename->isEqual("-")) { if (xmlFilename && ! xmlFilename->isEqual("-")) {
char* chars = new char[xmlFilename->length()+1]; char* chars = xmlFilename->toCharArray();
xmlInput = new ifstream(xmlFilename->toCharArray(chars), ios::in); xmlInput = new ifstream(chars, ios::in);
delete chars; delete [] chars;
} }
//-- handle output stream //-- handle output stream
ostream* resultOutput = &cout; ostream* resultOutput = &cout;
ofstream resultFileStream; ofstream resultFileStream;
if ( outFilename && ! outFilename->isEqual("-")) { if ( outFilename && ! outFilename->isEqual("-")) {
char* chars = new char[outFilename->length()+1]; char* chars = outFilename->toCharArray();
resultFileStream.open(outFilename->toCharArray(chars), ios::out); resultFileStream.open(chars, ios::out);
delete chars; delete [] chars;
if ( !resultFileStream ) { if ( !resultFileStream ) {
cerr << "error opening output file: " << *xmlFilename << endl; cerr << "error opening output file: " << *xmlFilename << endl;
return -1; return -1;
@ -132,9 +133,9 @@ int main(int argc, char** argv) {
} }
else { else {
//-- open XSLT file //-- open XSLT file
char* chars = new char[xsltFilename->length()+1]; char* chars = xsltFilename->toCharArray();
ifstream xsltInput(xsltFilename->toCharArray(chars), ios::in); ifstream xsltInput(chars, ios::in);
delete chars; delete [] chars;
xsltProcessor.process(*xmlInput, *xmlFilename, xsltInput, *xsltFilename, *resultOutput); xsltProcessor.process(*xmlInput, *xmlFilename, xsltInput, *xsltFilename, *resultOutput);
} }
resultFileStream.close(); resultFileStream.close();

Просмотреть файл

@ -39,17 +39,17 @@ nsresult txExpandedName::init(const String& aQName,
if (!XMLUtils::isValidQName(aQName)) if (!XMLUtils::isValidQName(aQName))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
int idx = aQName.indexOf(':'); PRInt32 idx = aQName.indexOf(':');
if (idx >= 0) { if (idx != kNotFound) {
String localName, prefixStr; String localName, prefixStr;
aQName.subString(0, idx, prefixStr); aQName.subString(0, (PRUint32)idx, prefixStr);
txAtom* prefix = TX_GET_ATOM(prefixStr); txAtom* prefix = TX_GET_ATOM(prefixStr);
PRInt32 namespaceID = aResolver->lookupNamespaceID(prefix); PRInt32 namespaceID = aResolver->lookupNamespaceID(prefix);
if (namespaceID == kNameSpaceID_Unknown) if (namespaceID == kNameSpaceID_Unknown)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
mNamespaceID = namespaceID; mNamespaceID = namespaceID;
aQName.subString(idx+1, localName); aQName.subString((PRUint32)idx + 1, localName);
TX_IF_RELEASE_ATOM(mLocalName); TX_IF_RELEASE_ATOM(mLocalName);
mLocalName = TX_GET_ATOM(localName); mLocalName = TX_GET_ATOM(localName);
} }
@ -68,33 +68,36 @@ nsresult txExpandedName::init(const String& aQName,
//- Implementation of XMLUtils -/ //- Implementation of XMLUtils -/
//------------------------------/ //------------------------------/
void XMLUtils::getPrefix(const String& src, String& dest) { void XMLUtils::getPrefix(const String& src, String& dest)
{
//-- anything preceding ':' is the namespace part of the name // Anything preceding ':' is the namespace part of the name
int idx = src.indexOf(':'); PRInt32 idx = src.indexOf(':');
if ( idx > 0 ) { if (idx == kNotFound) {
//-- create new String to prevent any chars in dest from being return;
//-- lost
String tmp;
src.subString(0,idx, tmp);
dest.append(tmp);
} }
else dest.append(""); // Use a temporary String to prevent any chars in dest
// from being lost.
NS_ASSERTION(idx > 0, "This QName looks invalid.");
String tmp;
src.subString(0, (PRUint32)idx, tmp);
dest.append(tmp);
} }
void XMLUtils::getLocalPart(const String& src, String& dest) { void XMLUtils::getLocalPart(const String& src, String& dest)
{
//-- anything after ':' is the local part of the name // Anything after ':' is the local part of the name
int idx = src.indexOf(':'); PRInt32 idx = src.indexOf(':');
if ( idx < -1 ) idx = -1; if (idx == kNotFound) {
//-- create new String to prevent any chars in dest from being dest.append(src);
//-- lost return;
}
// Use a temporary String to prevent any chars in dest
// from being lost.
NS_ASSERTION(idx > 0, "This QName looks invalid.");
String tmp; String tmp;
src.subString(idx+1, tmp); src.subString((PRUint32)idx + 1, tmp);
dest.append(tmp); dest.append(tmp);
}
} //-- getLocalPart
MBool XMLUtils::isValidQName(const String& aName) MBool XMLUtils::isValidQName(const String& aName)
{ {
@ -139,74 +142,49 @@ MBool XMLUtils::isValidQName(const String& aName)
/** /**
* Returns true if the given string has only whitespace characters * Returns true if the given string has only whitespace characters
**/ **/
MBool XMLUtils::isWhitespace(const String& text) { MBool XMLUtils::isWhitespace(const String& aText)
for ( int i = 0; i < text.length(); i++ ) { {
PRInt32 ch = text.charAt(i); PRUint32 size = aText.length();
switch ( ch ) { PRUint32 i;
case ' ' : for (i = 0; i < size; ++i) {
case '\n' : if (!isWhitespace(aText.charAt(i))) {
case '\r' : return MB_FALSE;
case '\t' :
break;
default:
return MB_FALSE;
} }
} }
return MB_TRUE; return MB_TRUE;
} //-- isWhitespace }
/** /**
* Normalizes the value of a XML processing instruction * Normalizes the value of a XML processing instruction
**/ **/
void XMLUtils::normalizePIValue(String& piValue) { void XMLUtils::normalizePIValue(String& piValue)
PRInt32 size = piValue.length(); {
//-- make copy of chars String origValue(piValue);
UNICODE_CHAR* chars = new UNICODE_CHAR[size]; PRUint32 origLength = origValue.length();
piValue.toUnicode(chars); PRUint32 conversionLoop = 0;
//-- clear attValue UNICODE_CHAR prevCh = 0;
piValue.clear(); piValue.clear();
PRInt32 cc = 0; while (conversionLoop < origLength) {
UNICODE_CHAR prevCh = 0x0000; UNICODE_CHAR ch = origValue.charAt(conversionLoop);
while ( cc < size) {
UNICODE_CHAR ch = chars[cc++];
switch (ch) { switch (ch) {
case '>': case '>':
if ( prevCh == '?' ) { {
if (prevCh == '?') {
piValue.append(' '); piValue.append(' ');
} }
piValue.append(ch);
break; break;
}
default: default:
piValue.append(ch); {
break; break;
}
} }
piValue.append(ch);
prevCh = ch; prevCh = ch;
++conversionLoop;
} }
delete chars; }
} //-- noramlizePIValue
/**
* Is this a whitespace string to be stripped?
* Newlines (#xD), tabs (#x9), spaces (#x20), CRs (#xA) only?
* @param data the String to test for whitespace
**/
MBool XMLUtils::shouldStripTextnode (const String& data){
MBool toStrip = MB_TRUE;
for (PRInt32 i=0;toStrip && i<data.length();i++){
switch(data.charAt(i)) {
case 0x0020: // space
case 0x0009: // tab
case 0x000A: // LF
case 0x000D: // CR
break;
default:
toStrip = MB_FALSE;
break;
}
}
return toStrip;
} //-- shouldStripTextnode
// macros for inclusion of char range headers // macros for inclusion of char range headers
#define TX_CHAR_RANGE(ch, a, b) if (ch < a) return MB_FALSE; \ #define TX_CHAR_RANGE(ch, a, b) if (ch < a) return MB_FALSE; \

Просмотреть файл

@ -103,23 +103,26 @@ public:
*/ */
static MBool isValidQName(const String& aName); static MBool isValidQName(const String& aName);
/*
* Returns true if the given character is whitespace.
*/
static MBool isWhitespace(const UNICODE_CHAR& aChar)
{
return (aChar <= ' ' &&
(aChar == ' ' || aChar == '\r' ||
aChar == '\n'|| aChar == '\t'));
}
/** /**
* Returns true if the given string has only whitespace characters * Returns true if the given string has only whitespace characters
**/ **/
static MBool isWhitespace(const String& text); static MBool isWhitespace(const String& aText);
/** /**
* Normalizes the value of a XML processingInstruction * Normalizes the value of a XML processingInstruction
**/ **/
static void normalizePIValue(String& attValue); static void normalizePIValue(String& attValue);
/**
* Is this a whitespace string to be stripped?
* Newlines (#xD), tabs (#x9), spaces (#x20), CRs (#xA) only?
* @param data the String to test for whitespace
**/
static MBool shouldStripTextnode (const String& data);
/* /*
* Returns true if the given character represents a numeric letter (digit). * Returns true if the given character represents a numeric letter (digit).
*/ */

Просмотреть файл

@ -79,7 +79,7 @@ void CharacterData::setData(const String& aData)
* *
* @return the length of the character data * @return the length of the character data
*/ */
PRInt32 CharacterData::getLength() const PRUint32 CharacterData::getLength() const
{ {
NSI_FROM_TX(CharacterData) NSI_FROM_TX(CharacterData)
PRUint32 length = 0; PRUint32 length = 0;
@ -99,7 +99,7 @@ PRInt32 CharacterData::getLength() const
* *
* @return the length of the character data * @return the length of the character data
*/ */
String& CharacterData::substringData(PRInt32 aOffset, PRInt32 aCount, String& CharacterData::substringData(PRUint32 aOffset, PRUint32 aCount,
String& aDest) String& aDest)
{ {
NSI_FROM_TX(CharacterData) NSI_FROM_TX(CharacterData)
@ -129,7 +129,7 @@ void CharacterData::appendData(const String& aSource)
* @param aOffset the offset at which you want to insert the string * @param aOffset the offset at which you want to insert the string
* @param aSource the string that you want to insert into the character data * @param aSource the string that you want to insert into the character data
*/ */
void CharacterData::insertData(PRInt32 aOffset, const String& aSource) void CharacterData::insertData(PRUint32 aOffset, const String& aSource)
{ {
NSI_FROM_TX(CharacterData) NSI_FROM_TX(CharacterData)
@ -143,7 +143,7 @@ void CharacterData::insertData(PRInt32 aOffset, const String& aSource)
* @param aOffset the offset at which you want to delete data * @param aOffset the offset at which you want to delete data
* @param aCount the number of chars you want to delete * @param aCount the number of chars you want to delete
*/ */
void CharacterData::deleteData(PRInt32 aOffset, PRInt32 aCount) void CharacterData::deleteData(PRUint32 aOffset, PRUint32 aCount)
{ {
NSI_FROM_TX(CharacterData) NSI_FROM_TX(CharacterData)
@ -158,7 +158,7 @@ void CharacterData::deleteData(PRInt32 aOffset, PRInt32 aCount)
* @param aCount the number of chars you want to replace * @param aCount the number of chars you want to replace
* @param aSource the data that you want to replace it with * @param aSource the data that you want to replace it with
*/ */
void CharacterData::replaceData(PRInt32 aOffset, PRInt32 aCount, void CharacterData::replaceData(PRUint32 aOffset, PRUint32 aCount,
const String& aSource) const String& aSource)
{ {
NSI_FROM_TX(CharacterData) NSI_FROM_TX(CharacterData)

Просмотреть файл

@ -1,64 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
* Contributor(s): Tom Kneeland
* Peter Van der Beken <peter.vanderbeken@pandora.be>
*
*/
/* Implementation of the wrapper class to convert the Mozilla nsIDOMText
interface into a TransforMIIX Text interface.
*/
#include "mozilladom.h"
/**
* Construct a wrapper with the specified Mozilla object and document owner.
*
* @param aText the nsIDOMCharacterData you want to wrap
* @param aOwner the document that owns this object
*/
Text::Text(nsIDOMText* aText, Document* aOwner) : CharacterData(aText, aOwner)
{
}
/**
* Destructor
*/
Text::~Text()
{
}
/**
* Call nsIDOMText::SplitText to split the text.
*
* @param aOffset the offset at which you want to split
*
* @return the resulting Text object
*/
Text* Text::splitText(PRInt32 aOffset)
{
NSI_FROM_TX_NULL_CHECK(Text)
nsCOMPtr<nsIDOMText> split;
if (NS_SUCCEEDED(nsText->SplitText(aOffset, getter_AddRefs(split))))
return (Text*)ownerDocument->createWrapper(split);
else
return NULL;
}

Просмотреть файл

@ -471,13 +471,13 @@ class CharacterData : public Node
const String& getData(); const String& getData();
void setData(const String& aSource); void setData(const String& aSource);
PRInt32 getLength() const; PRUint32 getLength() const;
String& substringData(PRInt32 aOffset, PRInt32 aCount, String& aDest); String& substringData(PRUint32 aOffset, PRUint32 aCount, String& aDest);
void appendData(const String& aSource); void appendData(const String& aSource);
void insertData(PRInt32 aOffset, const String& aSource); void insertData(PRUint32 aOffset, const String& aSource);
void deleteData(PRInt32 aOffset, PRInt32 aCount); void deleteData(PRUint32 aOffset, PRUint32 aCount);
void replaceData(PRInt32 aOffset, PRInt32 aCount, const String& aSource); void replaceData(PRUint32 aOffset, PRUint32 aCount, const String& aSource);
private: private:
String nodeValue; String nodeValue;
@ -492,7 +492,7 @@ class Text : public CharacterData
Text(nsIDOMText* aText, Document* aOwner); Text(nsIDOMText* aText, Document* aOwner);
~Text(); ~Text();
Text* splitText(PRInt32 aOffset); Text* splitText(PRUint32 aOffset);
}; };
/* /*

Просмотреть файл

@ -38,7 +38,7 @@ Attr::Attr(const String& name, Document* owner):
specified = MB_FALSE; specified = MB_FALSE;
int idx = nodeName.indexOf(':'); int idx = nodeName.indexOf(':');
if (idx == NOT_FOUND) { if (idx == kNotFound) {
mLocalName = TX_GET_ATOM(nodeName); mLocalName = TX_GET_ATOM(nodeName);
if (mLocalName == txXMLAtoms::xmlns) if (mLocalName == txXMLAtoms::xmlns)
mNamespaceID = kNameSpaceID_XMLNS; mNamespaceID = kNameSpaceID_XMLNS;

Просмотреть файл

@ -34,7 +34,7 @@
//Construct a text object with the specified document owner and data //Construct a text object with the specified document owner and data
// //
CDATASection::CDATASection(const String& theData, Document* owner) : CDATASection::CDATASection(const String& theData, Document* owner) :
Text(Node::CDATA_SECTION_NODE, "#cdata-section", theData, owner) Text(Node::CDATA_SECTION_NODE, String("#cdata-section"), theData, owner)
{ {
} }

Просмотреть файл

@ -58,7 +58,7 @@ void CharacterData::setData(const String& source)
// //
//Returns the length of the data object. //Returns the length of the data object.
// //
PRInt32 CharacterData::getLength() const PRUint32 CharacterData::getLength() const
{ {
return nodeValue.length(); return nodeValue.length();
} }
@ -68,9 +68,9 @@ PRInt32 CharacterData::getLength() const
//characters away. //characters away.
// NOTE: An empty string will be returned in the event of an error. // NOTE: An empty string will be returned in the event of an error.
// //
String& CharacterData::substringData(PRInt32 offset, PRInt32 count, String& dest) String& CharacterData::substringData(PRUint32 offset, PRUint32 count, String& dest)
{ {
if ((offset >= 0) && (offset < nodeValue.length()) && (count > 0)) if ((offset < nodeValue.length()) && (count > 0))
return nodeValue.subString(offset, offset+count, dest); return nodeValue.subString(offset, offset+count, dest);
else else
{ {
@ -84,23 +84,23 @@ void CharacterData::appendData(const String& arg)
nodeValue.append(arg); nodeValue.append(arg);
} }
void CharacterData::insertData(PRInt32 offset, const String& arg) void CharacterData::insertData(PRUint32 offset, const String& arg)
{ {
if ((offset >= 0) && (offset < nodeValue.length())) if (offset < nodeValue.length())
nodeValue.insert(offset, arg); nodeValue.insert(offset, arg);
} }
void CharacterData::deleteData(PRInt32 offset, PRInt32 count) void CharacterData::deleteData(PRUint32 offset, PRUint32 count)
{ {
if ((offset >= 0) && (offset < nodeValue.length()) && (count > 0)) if ((offset < nodeValue.length()) && (count > 0))
nodeValue.deleteChars(offset, count); nodeValue.deleteChars(offset, count);
} }
void CharacterData::replaceData(PRInt32 offset, PRInt32 count, const String& arg) void CharacterData::replaceData(PRUint32 offset, PRUint32 count, const String& arg)
{ {
String tempString; String tempString;
if ((offset >= 0) && (offset < nodeValue.length()) && (count > 0)) if ((offset < nodeValue.length()) && (count > 0))
{ {
if (count < arg.length()) if (count < arg.length())
{ {

Просмотреть файл

@ -34,7 +34,7 @@
//Construct a text object with the specified document owner and data //Construct a text object with the specified document owner and data
// //
Comment::Comment(const String& theData, Document* owner) : Comment::Comment(const String& theData, Document* owner) :
CharacterData(Node::COMMENT_NODE, "#comment", theData, owner) CharacterData(Node::COMMENT_NODE, String("#comment"), theData, owner)
{ {
} }

Просмотреть файл

@ -30,10 +30,9 @@
#include "dom.h" #include "dom.h"
DOMImplementation::DOMImplementation() DOMImplementation::DOMImplementation() : implFeature("XML"),
implVersion("1.0")
{ {
implFeature = "XML";
implVersion = "1.0";
} }
DOMImplementation::~DOMImplementation() DOMImplementation::~DOMImplementation()
@ -45,7 +44,7 @@ DOMImplementation::~DOMImplementation()
//functionality of this DOM implementation/version. //functionality of this DOM implementation/version.
// //
MBool DOMImplementation::hasFeature(String feature, MBool DOMImplementation::hasFeature(String feature,
const String& version) const const String& version) const
{ {
feature.toUpperCase(); feature.toUpperCase();

Просмотреть файл

@ -38,7 +38,7 @@
//node constructor is called to identify the node type. //node constructor is called to identify the node type.
// //
Document::Document(DocumentType* theDoctype) : Document::Document(DocumentType* theDoctype) :
NodeDefinition(Node::DOCUMENT_NODE, "#document", NULL_STRING, NULL) NodeDefinition(Node::DOCUMENT_NODE, String("#document"), NULL_STRING, NULL)
{ {
documentElement = NULL; documentElement = NULL;
doctype = theDoctype; doctype = theDoctype;
@ -195,7 +195,7 @@ Node* Document::removeChild(Node* oldChild)
// //
DocumentFragment* Document::createDocumentFragment() DocumentFragment* Document::createDocumentFragment()
{ {
return new DocumentFragment("#document-fragment", NULL_STRING, this); return new DocumentFragment(String("#document-fragment"), NULL_STRING, this);
} }
// //

Просмотреть файл

@ -41,7 +41,7 @@ Element::Element(const String& tagName, Document* owner) :
mNamespaceID = kNameSpaceID_Unknown; mNamespaceID = kNameSpaceID_Unknown;
int idx = nodeName.indexOf(':'); int idx = nodeName.indexOf(':');
if (idx == NOT_FOUND) { if (idx == kNotFound) {
mLocalName = TX_GET_ATOM(nodeName); mLocalName = TX_GET_ATOM(nodeName);
} }
else { else {
@ -93,7 +93,7 @@ PRInt32 Element::getNamespaceID()
if (mNamespaceID>=0) if (mNamespaceID>=0)
return mNamespaceID; return mNamespaceID;
int idx = nodeName.indexOf(':'); int idx = nodeName.indexOf(':');
if (idx == NOT_FOUND) { if (idx == kNotFound) {
Node* node = this; Node* node = this;
while (node && node->getNodeType() == Node::ELEMENT_NODE) { while (node && node->getNodeType() == Node::ELEMENT_NODE) {
String nsURI; String nsURI;

Просмотреть файл

@ -399,7 +399,7 @@ PRInt32 NodeDefinition::lookupNamespaceID(txAtom* aPrefix)
else { else {
// No prefix, look up the default namespace by searching for xmlns // No prefix, look up the default namespace by searching for xmlns
// attributes. Remove the trailing :, set length to 5 (xmlns). // attributes. Remove the trailing :, set length to 5 (xmlns).
name.setLength(5); name.truncate(5);
} }
Attr* xmlns; Attr* xmlns;
while (node && node->getNodeType() == Node::ELEMENT_NODE) { while (node && node->getNodeType() == Node::ELEMENT_NODE) {

Просмотреть файл

@ -34,7 +34,7 @@
//Construct a text object with the specified document owner and data //Construct a text object with the specified document owner and data
// //
Text::Text(const String& theData, Document* owner) : Text::Text(const String& theData, Document* owner) :
CharacterData(Node::TEXT_NODE, "#text", theData, owner) CharacterData(Node::TEXT_NODE, String("#text"), theData, owner)
{ {
} }
@ -52,12 +52,12 @@ Text::Text(NodeType type, const String& name, const String& value,
//Split the text node at Offset into two siblings. Return a pointer to the new //Split the text node at Offset into two siblings. Return a pointer to the new
//sibling. //sibling.
// //
Text* Text::splitText(PRInt32 offset) Text* Text::splitText(PRUint32 offset)
{ {
Text* newTextSibling = NULL; Text* newTextSibling = NULL;
String newData; String newData;
if ((offset >= 0) && (offset < nodeValue.length())) if (offset < nodeValue.length())
{ {
newTextSibling = getOwnerDocument()->createTextNode(nodeValue.subString(offset, newData)); newTextSibling = getOwnerDocument()->createTextNode(nodeValue.subString(offset, newData));
getParentNode()->insertBefore(newTextSibling, getNextSibling()); getParentNode()->insertBefore(newTextSibling, getNextSibling());

Просмотреть файл

@ -510,13 +510,13 @@ class CharacterData : public NodeDefinition
public: public:
const String& getData() const; const String& getData() const;
void setData(const String& source); void setData(const String& source);
PRInt32 getLength() const; PRUint32 getLength() const;
String& substringData(PRInt32 offset, PRInt32 count, String& dest); String& substringData(PRUint32 offset, PRUint32 count, String& dest);
void appendData(const String& arg); void appendData(const String& arg);
void insertData(PRInt32 offset, const String& arg); void insertData(PRUint32 offset, const String& arg);
void deleteData(PRInt32 offset, PRInt32 count); void deleteData(PRUint32 offset, PRUint32 count);
void replaceData(PRInt32 offset, PRInt32 count, const String& arg); void replaceData(PRUint32 offset, PRUint32 count, const String& arg);
protected: protected:
CharacterData(NodeType type, const String& name, CharacterData(NodeType type, const String& name,
@ -532,7 +532,7 @@ class Text : public CharacterData
public: public:
Text(const String& theData, Document* owner); Text(const String& theData, Document* owner);
Text* splitText(PRInt32 offset); Text* splitText(PRUint32 offset);
//Override "child manipulation" function since Text Nodes can not have //Override "child manipulation" function since Text Nodes can not have
//any children. //any children.

Просмотреть файл

@ -168,8 +168,6 @@ void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
{ {
ParserState* ps = (ParserState*)userData; ParserState* ps = (ParserState*)userData;
Element* newElement; Element* newElement;
XML_Char* attName;
XML_Char* attValue;
XML_Char** theAtts = (XML_Char**)atts; XML_Char** theAtts = (XML_Char**)atts;
String nodeName((UNICODE_CHAR *)name); String nodeName((UNICODE_CHAR *)name);
@ -177,9 +175,9 @@ void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
while (*theAtts) while (*theAtts)
{ {
attName = *theAtts++; String attName((UNICODE_CHAR *)*theAtts++);
attValue = *theAtts++; String attValue((UNICODE_CHAR *)*theAtts++);
newElement->setAttribute((UNICODE_CHAR *)attName, (UNICODE_CHAR *)attValue); newElement->setAttribute(attName, attValue);
} }
ps->currentNode->appendChild(newElement); ps->currentNode->appendChild(newElement);
@ -197,8 +195,7 @@ void endElement(void *userData, const XML_Char* name)
void charData(void* userData, const XML_Char* s, int len) void charData(void* userData, const XML_Char* s, int len)
{ {
ParserState* ps = (ParserState*)userData; ParserState* ps = (ParserState*)userData;
String data; String data((UNICODE_CHAR*)s, len);
data.append((UNICODE_CHAR*)s, len);
Node* prevSib = ps->currentNode->getLastChild(); Node* prevSib = ps->currentNode->getLastChild();
if (prevSib && prevSib->getNodeType()==Node::TEXT_NODE){ if (prevSib && prevSib->getNodeType()==Node::TEXT_NODE){
((CharacterData*)prevSib)->appendData(data); ((CharacterData*)prevSib)->appendData(data);

Просмотреть файл

@ -107,30 +107,30 @@ Token::~Token()
* Complex Tokens * Complex Tokens
*/ */
//-- Nodetype tokens //-- Nodetype tokens
const String ExprLexer::COMMENT = "comment"; const String ExprLexer::COMMENT("comment");
const String ExprLexer::NODE = "node"; const String ExprLexer::NODE("node");
const String ExprLexer::PROC_INST = "processing-instruction"; const String ExprLexer::PROC_INST("processing-instruction");
const String ExprLexer::TEXT = "text"; const String ExprLexer::TEXT("text");
//-- boolean //-- boolean
const String ExprLexer::AND = "and"; const String ExprLexer::AND("and");
const String ExprLexer::OR = "or"; const String ExprLexer::OR("or");
//-- multiplicative operators //-- multiplicative operators
const String ExprLexer::MODULUS = "mod"; const String ExprLexer::MODULUS("mod");
const String ExprLexer::DIVIDE = "div"; const String ExprLexer::DIVIDE("div");
/** /**
* The set of Lexer error messages * The set of Lexer error messages
**/ **/
const String ExprLexer::error_message[] = const String ExprLexer::error_message[] =
{ {
"VariableReference expected", String("VariableReference expected"),
"Operator expected", String("Operator expected"),
"Literal is not closed", String("Literal is not closed"),
": not expected", String(": not expected"),
"! not expected, use != or not()", String("! not expected, use != or not()"),
"found a unkown character" String("found a unkown character")
}; };
//---------------/ //---------------/
@ -238,8 +238,8 @@ void ExprLexer::parse(const String& pattern)
return; return;
String tokenBuffer; String tokenBuffer;
PRInt32 iter = 0, start; PRUint32 iter = 0, start;
PRInt32 size = pattern.length(); PRUint32 size = pattern.length();
short defType; short defType;
UNICODE_CHAR ch; UNICODE_CHAR ch;
@ -278,8 +278,8 @@ void ExprLexer::parse(const String& pattern)
start = iter; start = iter;
while (++iter < size && while (++iter < size &&
XMLUtils::isNCNameChar(pattern.charAt(iter))) /* just go */ ; XMLUtils::isNCNameChar(pattern.charAt(iter))) /* just go */ ;
PRInt32 end = iter; PRUint32 end = iter;
if (pattern.charAt(iter)==COLON) { if (iter < size && pattern.charAt(iter)==COLON) {
// try QName or wildcard, might need to step back for axis // try QName or wildcard, might need to step back for axis
if (++iter < size) if (++iter < size)
if (XMLUtils::isLetter(pattern.charAt(iter))) if (XMLUtils::isLetter(pattern.charAt(iter)))
@ -319,7 +319,7 @@ void ExprLexer::parse(const String& pattern)
start = iter; start = iter;
while (++iter < size && while (++iter < size &&
isXPathDigit(pattern.charAt(iter))) /* just go */; isXPathDigit(pattern.charAt(iter))) /* just go */;
if (pattern.charAt(iter)=='.') if (iter < size && pattern.charAt(iter) == '.')
while (++iter < size && while (++iter < size &&
isXPathDigit(pattern.charAt(iter))) /* just go */; isXPathDigit(pattern.charAt(iter))) /* just go */;
addToken(new Token(pattern.subString(start,iter,subStr),Token::NUMBER)); addToken(new Token(pattern.subString(start,iter,subStr),Token::NUMBER));
@ -336,8 +336,8 @@ void ExprLexer::parse(const String& pattern)
case S_QUOTE : case S_QUOTE :
case D_QUOTE : case D_QUOTE :
start=iter; start=iter;
iter = pattern.indexOf(ch,start+1); iter = pattern.indexOf(ch, (PRInt32)start + 1);
if (iter==NOT_FOUND) { if (iter == kNotFound) {
// XXX Error reporting "unclosed literal" // XXX Error reporting "unclosed literal"
errorPos = start; errorPos = start;
errorCode = ERROR_UNCLOSED_LITERAL; errorCode = ERROR_UNCLOSED_LITERAL;

Просмотреть файл

@ -182,7 +182,7 @@ public:
ERROR_UNKNOWN_CHAR ERROR_UNKNOWN_CHAR
}; };
static const String error_message[]; static const String error_message[];
PRInt32 errorPos; PRUint32 errorPos;
short errorCode; short errorCode;
/* /*

Просмотреть файл

@ -56,8 +56,8 @@ AttributeValueTemplate* ExprParser::createAttributeValueTemplate
if (attValue.isEmpty()) if (attValue.isEmpty())
return avt; //XXX should return 0, but that causes crash in lre12 return avt; //XXX should return 0, but that causes crash in lre12
PRInt32 size = attValue.length(); PRUint32 size = attValue.length();
int cc = 0; PRUint32 cc = 0;
UNICODE_CHAR nextCh; UNICODE_CHAR nextCh;
UNICODE_CHAR ch; UNICODE_CHAR ch;
String buffer; String buffer;
@ -956,14 +956,14 @@ nsresult ExprParser::resolveQName(const String& aQName,
{ {
aNamespace = kNameSpaceID_None; aNamespace = kNameSpaceID_None;
String prefix, lName; String prefix, lName;
int idx = aQName.indexOf(':'); PRInt32 idx = aQName.indexOf(':');
if (idx > 0) { if (idx > 0) {
aQName.subString(0, idx, prefix); aQName.subString(0, (PRUint32)idx, prefix);
aPrefix = TX_GET_ATOM(prefix); aPrefix = TX_GET_ATOM(prefix);
if (!aPrefix) { if (!aPrefix) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
aQName.subString(idx + 1, lName); aQName.subString((PRUint32)idx + 1, lName);
aLocalName = TX_GET_ATOM(lName); aLocalName = TX_GET_ATOM(lName);
if (!aLocalName) { if (!aLocalName) {
TX_RELEASE_ATOM(aPrefix); TX_RELEASE_ATOM(aPrefix);

Просмотреть файл

@ -30,19 +30,19 @@
* This class represents a FunctionCall as defined by the XSL Working Draft * This class represents a FunctionCall as defined by the XSL Working Draft
**/ **/
const String FunctionCall::INVALID_PARAM_COUNT = const String FunctionCall::INVALID_PARAM_COUNT(
"invalid number of parameters for function: "; "invalid number of parameters for function: ");
const String FunctionCall::INVALID_PARAM_VALUE = const String FunctionCall::INVALID_PARAM_VALUE(
"invalid parameter value for function: "; "invalid parameter value for function: ");
//- Constructors -/ //- Constructors -/
/** /**
* Creates a new FunctionCall * Creates a new FunctionCall
**/ **/
FunctionCall::FunctionCall() { FunctionCall::FunctionCall() : name("void")
this->name = "void"; {
} //-- FunctionCall } //-- FunctionCall
/** /**

Просмотреть файл

@ -72,13 +72,6 @@ static const String NUMBER_FN;
static const String ROUND_FN; static const String ROUND_FN;
static const String CEILING_FN; static const String CEILING_FN;
static const String FLOOR_FN; static const String FLOOR_FN;
// OG-
//-- internal XSL processor functions
static const String ERROR_FN;
}; //-- XPathNames }; //-- XPathNames

Просмотреть файл

@ -40,10 +40,10 @@
//- PathExpr -/ //- PathExpr -/
//------------/ //------------/
const String PathExpr::RTF_INVALID_OP = const String PathExpr::RTF_INVALID_OP(
"Result tree fragments don't allow location steps"; "Result tree fragments don't allow location steps");
const String PathExpr::NODESET_EXPECTED = const String PathExpr::NODESET_EXPECTED(
"Filter expression must evaluate to a NodeSet"; "Filter expression must evaluate to a NodeSet");
/** /**
* Creates a new PathExpr * Creates a new PathExpr
@ -177,7 +177,7 @@ void PathExpr::evalDescendants (Expr* aStep, Node* aNode,
if (!(filterWS && if (!(filterWS &&
(child->getNodeType() == Node::TEXT_NODE || (child->getNodeType() == Node::TEXT_NODE ||
child->getNodeType() == Node::CDATA_SECTION_NODE) && child->getNodeType() == Node::CDATA_SECTION_NODE) &&
XMLUtils::shouldStripTextnode(child->getNodeValue()))) XMLUtils::isWhitespace(child->getNodeValue())))
evalDescendants(aStep, child, aContext, resNodes); evalDescendants(aStep, child, aContext, resNodes);
child = child->getNextSibling(); child = child->getNextSibling();
} }

Просмотреть файл

@ -59,7 +59,7 @@ ExprResult* StringExpr::evaluate(txIEvalContext* aContext)
**/ **/
void StringExpr::toString(String& str) { void StringExpr::toString(String& str) {
UNICODE_CHAR ch = '\''; UNICODE_CHAR ch = '\'';
if (value.indexOf(ch) != NOT_FOUND) if (value.indexOf(ch) != kNotFound)
ch = '\"'; ch = '\"';
str.append(ch); str.append(ch);
str.append(value); str.append(value);

Просмотреть файл

@ -31,6 +31,7 @@
#include "FunctionLib.h" #include "FunctionLib.h"
#include "XMLDOMUtils.h" #include "XMLDOMUtils.h"
#include "XMLUtils.h"
#include "txIXPathContext.h" #include "txIXPathContext.h"
#include <math.h> #include <math.h>
@ -118,11 +119,10 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
MBool first = MB_TRUE; MBool first = MB_TRUE;
String normed(resultStr.length()); String normed(resultStr.length());
UNICODE_CHAR c; UNICODE_CHAR c;
PRInt32 src; PRUint32 src;
for (src = 0; src < resultStr.length(); src++) { for (src = 0; src < resultStr.length(); src++) {
c = resultStr.charAt(src); c = resultStr.charAt(src);
if (c == ' ' || c == '\n' || if (XMLUtils::isWhitespace(c)) {
c == '\t' || c == '\r') {
addSpace = MB_TRUE; addSpace = MB_TRUE;
} }
else { else {
@ -198,7 +198,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
return new StringResult(); return new StringResult();
String resultStr; String resultStr;
src.subString((PRInt32)start, (PRInt32)end, resultStr); src.subString((PRUint32)start, (PRUint32)end, resultStr);
return new StringResult(resultStr); return new StringResult(resultStr);
} }
case SUBSTRING_AFTER: case SUBSTRING_AFTER:
@ -210,8 +210,8 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
evaluateToString((Expr*)iter.next(), aContext, arg1); evaluateToString((Expr*)iter.next(), aContext, arg1);
evaluateToString((Expr*)iter.next(), aContext, arg2); evaluateToString((Expr*)iter.next(), aContext, arg2);
PRInt32 idx = arg1.indexOf(arg2); PRInt32 idx = arg1.indexOf(arg2);
if (idx >= 0) { if (idx != kNotFound) {
PRInt32 len = arg2.length(); PRUint32 len = arg2.length();
arg1.subString(idx + len, arg2); arg1.subString(idx + len, arg2);
return new StringResult(arg2); return new StringResult(arg2);
} }
@ -226,7 +226,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
evaluateToString((Expr*)iter.next(), aContext, arg1); evaluateToString((Expr*)iter.next(), aContext, arg1);
evaluateToString((Expr*)iter.next(), aContext, arg2); evaluateToString((Expr*)iter.next(), aContext, arg2);
PRInt32 idx = arg1.indexOf(arg2); PRInt32 idx = arg1.indexOf(arg2);
if (idx >= 0) { if (idx != kNotFound) {
arg2.clear(); arg2.clear();
arg1.subString(0, idx, arg2); arg1.subString(0, idx, arg2);
return new StringResult(arg2); return new StringResult(arg2);
@ -246,12 +246,12 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
String oldChars, newChars, dest; String oldChars, newChars, dest;
evaluateToString((Expr*)iter.next(), aContext, oldChars); evaluateToString((Expr*)iter.next(), aContext, oldChars);
evaluateToString((Expr*)iter.next(), aContext, newChars); evaluateToString((Expr*)iter.next(), aContext, newChars);
PRInt32 i; PRUint32 i;
for (i = 0; i < src.length(); i++) { for (i = 0; i < src.length(); i++) {
PRInt32 idx = oldChars.indexOf(src.charAt(i)); PRInt32 idx = oldChars.indexOf(src.charAt(i));
if (idx >= 0) { if (idx != kNotFound) {
if (idx < newChars.length()) if (idx < newChars.length())
dest.append(newChars.charAt(idx)); dest.append(newChars.charAt((PRUint32)idx));
} }
else { else {
dest.append(src.charAt(i)); dest.append(src.charAt(i));

Просмотреть файл

@ -51,7 +51,7 @@ StringResult::StringResult(const String& str) {
**/ **/
StringResult::StringResult(const char* str) { StringResult::StringResult(const char* str) {
//-- copy str //-- copy str
this->value = str; this->value.append(str);
} //-- StringResult } //-- StringResult
/* /*

Просмотреть файл

@ -1,69 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is TransforMiiX XSLT processor.
*
* The Initial Developer of the Original Code is The MITRE Corporation.
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
*
* Portions created by Keith Visco as a Non MITRE employee,
* (C) 1999 Keith Visco. All Rights Reserved.
*
* Contributor(s):
* Keith Visco, kvisco@ziplink.net
* -- original author.
*
* Marina Mechtcheriakova, mmarina@mindspring.com
* -- added LANG_FN
*
*/
/**
* XPath names
**/
#include "FunctionLib.h"
//-- Function Names
const String XPathNames::BOOLEAN_FN = "boolean";
const String XPathNames::CONCAT_FN = "concat";
const String XPathNames::CONTAINS_FN = "contains";
const String XPathNames::COUNT_FN = "count";
const String XPathNames::FALSE_FN = "false";
const String XPathNames::ID_FN = "id";
const String XPathNames::LAST_FN = "last";
const String XPathNames::LOCAL_NAME_FN = "local-name";
const String XPathNames::NAME_FN = "name";
const String XPathNames::NAMESPACE_URI_FN = "namespace-uri";
const String XPathNames::NORMALIZE_SPACE_FN = "normalize-space";
const String XPathNames::NOT_FN = "not";
const String XPathNames::POSITION_FN = "position";
const String XPathNames::STARTS_WITH_FN = "starts-with";
const String XPathNames::STRING_FN = "string";
const String XPathNames::STRING_LENGTH_FN = "string-length";
const String XPathNames::SUBSTRING_FN = "substring";
const String XPathNames::SUBSTRING_AFTER_FN = "substring-after";
const String XPathNames::SUBSTRING_BEFORE_FN = "substring-before";
const String XPathNames::SUM_FN = "sum";
const String XPathNames::TRANSLATE_FN = "translate";
const String XPathNames::TRUE_FN = "true";
// OG+
const String XPathNames::NUMBER_FN = "number";
const String XPathNames::ROUND_FN = "round";
const String XPathNames::CEILING_FN = "ceiling";
const String XPathNames::FLOOR_FN = "floor";
// OG-
//Marina M. boolean function lang
const String XPathNames::LANG_FN = "lang";
//-- internal XSL processor functions
const String XPathNames::ERROR_FN = "error";

Просмотреть файл

@ -70,7 +70,7 @@ nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
nsIDOMXPathNSResolver *aResolver, nsIDOMXPathNSResolver *aResolver,
nsIDOMXPathExpression **aResult) nsIDOMXPathExpression **aResult)
{ {
String expressionString(PromiseFlatString(aExpression).get()); String expressionString(aExpression);
ParseContextImpl pContext(aResolver); ParseContextImpl pContext(aResolver);
Expr* expression = ExprParser::createExpr(expressionString, &pContext); Expr* expression = ExprParser::createExpr(expressionString, &pContext);
if (!expression) if (!expression)

Просмотреть файл

@ -37,107 +37,107 @@
#include "Names.h" #include "Names.h"
//-- Global Strings //-- Global Strings
const String HTML = "html"; const String HTML("html");
const String HTML_NS = "http://www.w3.org/1999/xhtml"; const String HTML_NS("http://www.w3.org/1999/xhtml");
const String STYLESHEET_PI = "xml-stylesheet"; const String STYLESHEET_PI("xml-stylesheet");
const String STYLESHEET_PI_OLD = "xml:stylesheet"; const String STYLESHEET_PI_OLD("xml:stylesheet");
const String XML_SPACE = "xml:space"; const String XML_SPACE("xml:space");
const String XSL_MIME_TYPE = "text/xsl"; const String XSL_MIME_TYPE("text/xsl");
const String XSLT_NS = "http://www.w3.org/1999/XSL/Transform"; const String XSLT_NS("http://www.w3.org/1999/XSL/Transform");
//-- Elements //-- Elements
const String APPLY_IMPORTS = "apply-imports"; const String APPLY_IMPORTS("apply-imports");
const String APPLY_TEMPLATES = "apply-templates"; const String APPLY_TEMPLATES("apply-templates");
const String ATTRIBUTE = "attribute"; const String ATTRIBUTE("attribute");
const String ATTRIBUTE_SET = "attribute-set"; const String ATTRIBUTE_SET("attribute-set");
const String CALL_TEMPLATE = "call-template"; const String CALL_TEMPLATE("call-template");
const String CHOOSE = "choose"; const String CHOOSE("choose");
const String COMMENT = "comment"; const String COMMENT("comment");
const String COPY = "copy"; const String COPY("copy");
const String COPY_OF = "copy-of"; const String COPY_OF("copy-of");
const String DECIMAL_FORMAT = "decimal-format"; const String DECIMAL_FORMAT("decimal-format");
const String ELEMENT = "element"; const String ELEMENT("element");
const String FOR_EACH = "for-each"; const String FOR_EACH("for-each");
const String IF = "if"; const String IF("if");
const String IMPORT = "import"; const String IMPORT("import");
const String INCLUDE = "include"; const String INCLUDE("include");
const String KEY = "key"; const String KEY("key");
const String MESSAGE = "message"; const String MESSAGE("message");
const String NUMBER = "number"; const String NUMBER("number");
const String OTHERWISE = "otherwise"; const String OTHERWISE("otherwise");
const String OUTPUT = "output"; const String OUTPUT("output");
const String PARAM = "param"; const String PARAM("param");
const String PROC_INST = "processing-instruction"; const String PROC_INST("processing-instruction");
const String PRESERVE_SPACE = "preserve-space"; const String PRESERVE_SPACE("preserve-space");
const String SORT = "sort"; const String SORT("sort");
const String STRIP_SPACE = "strip-space"; const String STRIP_SPACE("strip-space");
const String TEMPLATE = "template"; const String TEMPLATE("template");
const String TEXT = "text"; const String TEXT("text");
const String VALUE_OF = "value-of"; const String VALUE_OF("value-of");
const String VARIABLE = "variable"; const String VARIABLE("variable");
const String WHEN = "when"; const String WHEN("when");
const String WITH_PARAM = "with-param"; const String WITH_PARAM("with-param");
//-- Attributes //-- Attributes
const String ELEMENTS_ATTR = "elements"; const String ELEMENTS_ATTR("elements");
const String HREF_ATTR = "href"; const String HREF_ATTR("href");
const String MATCH_ATTR = "match"; const String MATCH_ATTR("match");
const String MODE_ATTR = "mode"; const String MODE_ATTR("mode");
const String NAME_ATTR = "name"; const String NAME_ATTR("name");
const String SELECT_ATTR = "select"; const String SELECT_ATTR("select");
const String TEST_ATTR = "test"; const String TEST_ATTR("test");
const String USE_ATTR = "use"; const String USE_ATTR("use");
//-- Attribute Values //-- Attribute Values
const String ANY_VALUE = "any"; const String ANY_VALUE("any");
const String ASCENDING_VALUE = "ascending"; const String ASCENDING_VALUE("ascending");
const String DESCENDING_VALUE = "descending"; const String DESCENDING_VALUE("descending");
const String LOWER_FIRST_VALUE = "lower-first"; const String LOWER_FIRST_VALUE("lower-first");
const String MULTIPLE_VALUE = "multiple"; const String MULTIPLE_VALUE("multiple");
const String NO_VALUE = "no"; const String NO_VALUE("no");
const String NUMBER_VALUE = "number"; const String NUMBER_VALUE("number");
const String PRESERVE_VALUE = "preserve"; const String PRESERVE_VALUE("preserve");
const String SINGLE_VALUE = "single"; const String SINGLE_VALUE("single");
const String STRIP_VALUE = "strip"; const String STRIP_VALUE("strip");
const String TEXT_VALUE = "text"; const String TEXT_VALUE("text");
const String UPPER_FIRST_VALUE = "upper-first"; const String UPPER_FIRST_VALUE("upper-first");
const String YES_VALUE = "yes"; const String YES_VALUE("yes");
//-- Stylesheet attributes //-- Stylesheet attributes
const String ANCESTOR_AXIS = "ancestor"; const String ANCESTOR_AXIS("ancestor");
const String ANCESTOR_OR_SELF_AXIS = "ancestor-or-self"; const String ANCESTOR_OR_SELF_AXIS("ancestor-or-self");
const String ATTRIBUTE_AXIS = "attribute"; const String ATTRIBUTE_AXIS("attribute");
const String CHILD_AXIS = "child"; const String CHILD_AXIS("child");
const String DESCENDANT_AXIS = "descendant"; const String DESCENDANT_AXIS("descendant");
const String DESCENDANT_OR_SELF_AXIS = "descendant-or-self"; const String DESCENDANT_OR_SELF_AXIS("descendant-or-self");
const String FOLLOWING_AXIS = "following"; const String FOLLOWING_AXIS("following");
const String FOLLOWING_SIBLING_AXIS = "following-sibling"; const String FOLLOWING_SIBLING_AXIS("following-sibling");
const String NAMESPACE_AXIS = "namespace"; const String NAMESPACE_AXIS("namespace");
const String PARENT_AXIS = "parent"; const String PARENT_AXIS("parent");
const String PRECEDING_AXIS = "preceding"; const String PRECEDING_AXIS("preceding");
const String PRECEDING_SIBLING_AXIS = "preceding-sibling"; const String PRECEDING_SIBLING_AXIS("preceding-sibling");
const String SELF_AXIS = "self"; const String SELF_AXIS("self");
//-- NodeTest Operators //-- NodeTest Operators
const String ATTRIBUTE_FNAME = "@"; const String ATTRIBUTE_FNAME("@");
const String COMMENT_FNAME = "comment"; const String COMMENT_FNAME("comment");
const String PI_FNAME = "processing-instruction"; const String PI_FNAME("processing-instruction");
const String TEXT_FNAME = "text"; const String TEXT_FNAME("text");
const String NODE_FNAME = "node"; const String NODE_FNAME("node");
const String IDENTITY_OP = "."; const String IDENTITY_OP(".");
const String PARENT_OP = ".."; const String PARENT_OP("..");
//-- XSLT additional functions //-- XSLT additional functions
const String DOCUMENT_FN = "document"; const String DOCUMENT_FN("document");
const String KEY_FN = "key"; const String KEY_FN("key");
const String FORMAT_NUMBER_FN = "format-number"; const String FORMAT_NUMBER_FN("format-number");
const String CURRENT_FN = "current"; const String CURRENT_FN("current");
const String UNPARSED_ENTITY_URI_FN = "unparsed-entity-uri"; const String UNPARSED_ENTITY_URI_FN("unparsed-entity-uri");
const String GENERATE_ID_FN = "generate-id"; const String GENERATE_ID_FN("generate-id");
const String SYSTEM_PROPERTY_FN = "system-property"; const String SYSTEM_PROPERTY_FN("system-property");
const String ELEMENT_AVAILABLE_FN = "element-available"; const String ELEMENT_AVAILABLE_FN("element-available");
const String FUNCTION_AVAILABLE_FN = "function-available"; const String FUNCTION_AVAILABLE_FN("function-available");
//-- MISC //-- MISC
const String WILD_CARD = "*"; const String WILD_CARD("*");

Просмотреть файл

@ -90,7 +90,7 @@ ProcessorState::ProcessorState(Document* aSourceDocument,
// add predefined default decimal format // add predefined default decimal format
defaultDecimalFormatSet = MB_FALSE; defaultDecimalFormatSet = MB_FALSE;
decimalFormats.put("", new txDecimalFormat); decimalFormats.put(String(), new txDecimalFormat);
decimalFormats.setObjectDeletion(MB_TRUE); decimalFormats.setObjectDeletion(MB_TRUE);
} }
@ -461,19 +461,24 @@ Node* ProcessorState::findTemplate(Node* aNode,
} }
} }
#ifdef PR_LOGGING #ifdef PR_LOGGING
char *nodeBuf = 0, *modeBuf = 0; char *nodeBuf = 0, *modeBuf = 0;
if (matchTemplate) { if (matchTemplate) {
char *matchBuf = 0, *uriBuf = 0; char *matchBuf = 0, *uriBuf = 0;
PR_LOG(txLog::xslt, PR_LOG_DEBUG, PR_LOG(txLog::xslt, PR_LOG_DEBUG,
("MatchTemplate, Pattern %s, Mode %s, Stylesheet %s, " \ ("MatchTemplate, Pattern %s, Mode %s, Stylesheet %s, " \
"Node %s\n", "Node %s\n",
(matchBuf = ((Element*)matchTemplate)->getAttribute("match").toCharArray()), (matchBuf = ((Element*)matchTemplate)->getAttribute(String("match")).toCharArray()),
(modeBuf = aMode.toCharArray()), (modeBuf = aMode.toCharArray()),
(uriBuf = matchTemplate->getBaseURI().toCharArray()), (uriBuf = matchTemplate->getBaseURI().toCharArray()),
(nodeBuf = aNode->getNodeName().toCharArray()))); (nodeBuf = aNode->getNodeName().toCharArray())));
delete matchBuf; #ifdef TX_EXE
delete uriBuf; delete [] matchBuf;
delete [] uriBuf;
#else
nsMemory::Free(matchBuf);
nsMemory::Free(uriBuf);
#endif
} }
else { else {
PR_LOG(txLog::xslt, PR_LOG_DEBUG, PR_LOG(txLog::xslt, PR_LOG_DEBUG,
@ -481,9 +486,14 @@ Node* ProcessorState::findTemplate(Node* aNode,
(nodeBuf = aNode->getNodeName().toCharArray()), (nodeBuf = aNode->getNodeName().toCharArray()),
(modeBuf = aMode.toCharArray()))); (modeBuf = aMode.toCharArray())));
} }
delete nodeBuf; #ifdef TX_EXE
delete modeBuf; delete [] nodeBuf;
#endif delete [] modeBuf;
#else
nsMemory::Free(nodeBuf);
nsMemory::Free(modeBuf);
#endif
#endif
return matchTemplate; return matchTemplate;
} }
@ -557,7 +567,7 @@ Expr* ProcessorState::getExpr(Element* aElem, ExprAttr aAttr)
expr = ExprParser::createExpr(attr, &pContext); expr = ExprParser::createExpr(attr, &pContext);
if (!expr) { if (!expr) {
String err = "Error in parsing XPath expression: "; String err("Error in parsing XPath expression: ");
err.append(attr); err.append(attr);
receiveError(err, NS_ERROR_XPATH_PARSE_FAILED); receiveError(err, NS_ERROR_XPATH_PARSE_FAILED);
} }
@ -596,7 +606,7 @@ txPattern* ProcessorState::getPattern(Element* aElem, PatternAttr aAttr)
pattern = txPatternParser::createPattern(attr, &pContext, this); pattern = txPatternParser::createPattern(attr, &pContext, this);
if (!pattern) { if (!pattern) {
String err = "Error in parsing pattern: "; String err("Error in parsing pattern: ");
err.append(attr); err.append(attr);
receiveError(err, NS_ERROR_XPATH_PARSE_FAILED); receiveError(err, NS_ERROR_XPATH_PARSE_FAILED);
} }
@ -929,7 +939,6 @@ MBool ProcessorState::isStripSpaceAllowed(Node* node)
ImportFrame* frame; ImportFrame* frame;
txListIterator frameIter(&mImportFrames); txListIterator frameIter(&mImportFrames);
String name = node->getNodeName();
while ((frame = (ImportFrame*)frameIter.next())) { while ((frame = (ImportFrame*)frameIter.next())) {
txListIterator iter(&frame->mWhiteNameTests); txListIterator iter(&frame->mWhiteNameTests);
while (iter.hasNext()) { while (iter.hasNext()) {
@ -939,7 +948,7 @@ MBool ProcessorState::isStripSpaceAllowed(Node* node)
} }
} }
if (mOutputFormat.mMethod == eHTMLOutput) { if (mOutputFormat.mMethod == eHTMLOutput) {
String ucName = name; String ucName = node->getNodeName();
ucName.toUpperCase(); ucName.toUpperCase();
if (ucName.isEqual("SCRIPT")) if (ucName.isEqual("SCRIPT"))
return MB_FALSE; return MB_FALSE;
@ -949,7 +958,7 @@ MBool ProcessorState::isStripSpaceAllowed(Node* node)
case Node::TEXT_NODE: case Node::TEXT_NODE:
case Node::CDATA_SECTION_NODE: case Node::CDATA_SECTION_NODE:
{ {
if (!XMLUtils::shouldStripTextnode(node->getNodeValue())) if (!XMLUtils::isWhitespace(node->getNodeValue()))
return MB_FALSE; return MB_FALSE;
return isStripSpaceAllowed(node->getParentNode()); return isStripSpaceAllowed(node->getParentNode());
} }

Просмотреть файл

@ -425,7 +425,7 @@ private:
**/ **/
class txNameTestItem { class txNameTestItem {
public: public:
txNameTestItem(txAtom* aPrefix, txAtom* aLocalName, PRUint32 aNSID, txNameTestItem(txAtom* aPrefix, txAtom* aLocalName, PRInt32 aNSID,
MBool stripSpace) MBool stripSpace)
: mNameTest(aPrefix, aLocalName, aNSID, Node::ELEMENT_NODE), : mNameTest(aPrefix, aLocalName, aNSID, Node::ELEMENT_NODE),
mStrips(stripSpace) mStrips(stripSpace)

Просмотреть файл

@ -86,8 +86,8 @@
* A warning message used by all templates that do not allow non character * A warning message used by all templates that do not allow non character
* data to be generated * data to be generated
**/ **/
const String XSLTProcessor::NON_TEXT_TEMPLATE_WARNING = const String XSLTProcessor::NON_TEXT_TEMPLATE_WARNING(
"templates for the following element are not allowed to generate non character data: "; "templates for the following element are not allowed to generate non character data: ");
/* /*
* Implement static variables for atomservice and dom. * Implement static variables for atomservice and dom.
@ -239,11 +239,11 @@ void XSLTProcessor::getHrefFromStylesheetPI(Document& xmlDocument, String& href)
**/ **/
void XSLTProcessor::parseStylesheetPI(String& data, String& type, String& href) { void XSLTProcessor::parseStylesheetPI(String& data, String& type, String& href) {
PRInt32 size = data.length(); PRUint32 size = data.length();
NamedMap bufferMap; NamedMap bufferMap;
bufferMap.put("type", &type); bufferMap.put(String("type"), &type);
bufferMap.put("href", &href); bufferMap.put(String("href"), &href);
int ccount = 0; PRUint32 ccount = 0;
MBool inLiteral = MB_FALSE; MBool inLiteral = MB_FALSE;
UNICODE_CHAR matchQuote = '"'; UNICODE_CHAR matchQuote = '"';
String sink; String sink;
@ -1039,7 +1039,7 @@ void XSLTProcessor::processAction(Node* aNode,
nodeType == Node::CDATA_SECTION_NODE) { nodeType == Node::CDATA_SECTION_NODE) {
const String& textValue = aXSLTAction->getNodeValue(); const String& textValue = aXSLTAction->getNodeValue();
if (!aPs->isXSLStripSpaceAllowed(aXSLTAction) || if (!aPs->isXSLStripSpaceAllowed(aXSLTAction) ||
!XMLUtils::shouldStripTextnode(textValue)) { !XMLUtils::isWhitespace(textValue)) {
NS_ASSERTION(mResultHandler, "mResultHandler must not be NULL!"); NS_ASSERTION(mResultHandler, "mResultHandler must not be NULL!");
mResultHandler->characters(textValue); mResultHandler->characters(textValue);
} }
@ -1323,8 +1323,8 @@ void XSLTProcessor::processAction(Node* aNode,
String value; String value;
processChildrenAsValue(aNode, actionElement, aPs, MB_TRUE, value); processChildrenAsValue(aNode, actionElement, aPs, MB_TRUE, value);
PRInt32 pos = 0; PRInt32 pos = 0;
PRInt32 length = value.length(); PRUint32 length = value.length();
while ((pos = value.indexOf('-', pos)) != NOT_FOUND) { while ((pos = value.indexOf('-', pos)) != kNotFound) {
++pos; ++pos;
if ((pos == length) || (value.charAt(pos) == '-')) if ((pos == length) || (value.charAt(pos) == '-'))
value.insert(pos++, ' '); value.insert(pos++, ' ');
@ -2258,7 +2258,7 @@ XSLTProcessor::startElement(ProcessorState* aPs, const String& aName, const PRIn
if (format->mMethod == eMethodNotSet) { if (format->mMethod == eMethodNotSet) {
// XXX Should check for whitespace-only sibling text nodes // XXX Should check for whitespace-only sibling text nodes
if ((aNsID == kNameSpaceID_None) && if ((aNsID == kNameSpaceID_None) &&
aName.isEqualIgnoreCase("html")) { aName.isEqualIgnoreCase(String("html"))) {
// Switch to html output mode according to the XSLT spec. // Switch to html output mode according to the XSLT spec.
format->mMethod = eHTMLOutput; format->mMethod = eHTMLOutput;
#ifndef TX_EXE #ifndef TX_EXE

Просмотреть файл

@ -3,9 +3,9 @@
#include "Names.h" #include "Names.h"
#include "txIXPathContext.h" #include "txIXPathContext.h"
const String XSL_VERSION_PROPERTY = "version"; const String XSL_VERSION_PROPERTY("version");
const String XSL_VENDOR_PROPERTY = "vendor"; const String XSL_VENDOR_PROPERTY("vendor");
const String XSL_VENDOR_URL_PROPERTY = "vendor-url"; const String XSL_VENDOR_URL_PROPERTY("vendor-url");
/* /*
Implementation of XSLT 1.0 extension function: system-property Implementation of XSLT 1.0 extension function: system-property

Просмотреть файл

@ -119,8 +119,8 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
int multiplier=1; int multiplier=1;
int groupSize=-1; int groupSize=-1;
int pos=0; PRUint32 pos = 0;
int formatLen = formatStr.length(); PRUint32 formatLen = formatStr.length();
MBool inQuote; MBool inQuote;
// Get right subexpression // Get right subexpression
@ -366,17 +366,18 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
if (groupSize < 0) if (groupSize < 0)
groupSize = intDigits * 2; //to simplify grouping groupSize = intDigits * 2; //to simplify grouping
res.setLength(res.length() + // XXX We shouldn't use SetLength.
intDigits + // integer digits res.getNSString().SetLength(res.length() +
1 + // decimal separator intDigits + // integer digits
maxFractionSize + // fractions 1 + // decimal separator
(intDigits-1)/groupSize); // group separators maxFractionSize + // fractions
(intDigits-1)/groupSize); // group separators
PRInt32 i = bufIntDigits + maxFractionSize - 1; PRInt32 i = bufIntDigits + maxFractionSize - 1;
MBool carry = (i+1 < buflen) && (buf[i+1] >= '5'); MBool carry = (i+1 < buflen) && (buf[i+1] >= '5');
MBool hasFraction = MB_FALSE; MBool hasFraction = MB_FALSE;
PRInt32 resPos = res.length()-1; PRUint32 resPos = res.length()-1;
// Fractions // Fractions
for (; i >= bufIntDigits; --i) { for (; i >= bufIntDigits; --i) {
@ -391,22 +392,23 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
else { else {
digit = buf[i] - '0'; digit = buf[i] - '0';
} }
if (hasFraction || digit != 0 || i < bufIntDigits+minFractionSize) { if (hasFraction || digit != 0 || i < bufIntDigits+minFractionSize) {
hasFraction = MB_TRUE; hasFraction = MB_TRUE;
res.replace(resPos--, res.replace(resPos--,
(UNICODE_CHAR)(digit + format->mZeroDigit)); (UNICODE_CHAR)(digit + format->mZeroDigit));
} }
else { else {
res.setLength(resPos--); res.truncate(resPos--);
} }
} }
// Decimal separator // Decimal separator
if (hasFraction) if (hasFraction) {
res.replace(resPos--, format->mDecimalSeparator); res.replace(resPos--, format->mDecimalSeparator);
else }
res.setLength(resPos--); else {
res.truncate(resPos--);
}
// Integer digits // Integer digits
for (i = 0; i < intDigits; ++i) { for (i = 0; i < intDigits; ++i) {
@ -423,15 +425,17 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
carry = digit == 0; carry = digit == 0;
} }
if (i != 0 && i%groupSize == 0) if (i != 0 && i%groupSize == 0) {
res.replace(resPos--, format->mGroupingSeparator); res.replace(resPos--, format->mGroupingSeparator);
}
res.replace(resPos--, (UNICODE_CHAR)(digit + format->mZeroDigit)); res.replace(resPos--, (UNICODE_CHAR)(digit + format->mZeroDigit));
} }
if (carry) { if (carry) {
if (i%groupSize == 0) if (i%groupSize == 0) {
res.insert(resPos + 1, format->mGroupingSeparator); res.insert(resPos + 1, format->mGroupingSeparator);
}
res.insert(resPos + 1, (UNICODE_CHAR)(1 + format->mZeroDigit)); res.insert(resPos + 1, (UNICODE_CHAR)(1 + format->mZeroDigit));
} }
@ -451,13 +455,12 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
* A representation of the XSLT element <xsl:decimal-format> * A representation of the XSLT element <xsl:decimal-format>
*/ */
txDecimalFormat::txDecimalFormat() txDecimalFormat::txDecimalFormat() : mInfinity("Infinity"),
mNaN("NaN")
{ {
mDecimalSeparator = '.'; mDecimalSeparator = '.';
mGroupingSeparator = ','; mGroupingSeparator = ',';
mInfinity = "Infinity";
mMinusSign = '-'; mMinusSign = '-';
mNaN = "NaN";
mPercent = '%'; mPercent = '%';
mPerMille = 0x2030; mPerMille = 0x2030;
mZeroDigit = '0'; mZeroDigit = '0';

Просмотреть файл

@ -188,7 +188,7 @@ void txHTMLOutput::attribute(const String& aName,
} }
} }
if (!setAtt) { if (!setAtt) {
setAtt = new txAttribute(aNsID, localName, ""); setAtt = new txAttribute(aNsID, localName, String());
setAtt->mShorthand = MB_TRUE; setAtt->mShorthand = MB_TRUE;
mAttributes.add(setAtt); mAttributes.add(setAtt);
} }

Просмотреть файл

@ -116,10 +116,10 @@ void txOutputFormat::setFromDefaults()
case eXMLOutput: case eXMLOutput:
{ {
if (mVersion.isEmpty()) if (mVersion.isEmpty())
mVersion = "1.0"; mVersion.append("1.0");
if (mEncoding.isEmpty()) if (mEncoding.isEmpty())
mEncoding = "UTF-8"; mEncoding.append("UTF-8");
if (mOmitXMLDeclaration == eNotSet) if (mOmitXMLDeclaration == eNotSet)
mOmitXMLDeclaration = eFalse; mOmitXMLDeclaration = eFalse;
@ -128,33 +128,33 @@ void txOutputFormat::setFromDefaults()
mIndent = eFalse; mIndent = eFalse;
if (mMediaType.isEmpty()) if (mMediaType.isEmpty())
mMediaType = "text/xml"; mMediaType.append("text/xml");
break; break;
} }
case eHTMLOutput: case eHTMLOutput:
{ {
if (mVersion.isEmpty()) if (mVersion.isEmpty())
mVersion = "4.0"; mVersion.append("4.0");
if (mEncoding.isEmpty()) if (mEncoding.isEmpty())
mEncoding = "UTF-8"; mEncoding.append("UTF-8");
if (mIndent == eNotSet) if (mIndent == eNotSet)
mIndent = eTrue; mIndent = eTrue;
if (mMediaType.isEmpty()) if (mMediaType.isEmpty())
mMediaType = "text/html"; mMediaType.append("text/html");
break; break;
} }
case eTextOutput: case eTextOutput:
{ {
if (mEncoding.isEmpty()) if (mEncoding.isEmpty())
mEncoding = "UTF-8"; mEncoding.append("UTF-8");
if (mMediaType.isEmpty()) if (mMediaType.isEmpty())
mMediaType = "text/plain"; mMediaType.append("text/plain");
break; break;
} }

Просмотреть файл

@ -93,9 +93,9 @@ void txXMLOutput::characters(const String& aData)
closeStartTag(MB_FALSE); closeStartTag(MB_FALSE);
if (mInCDATASection) { if (mInCDATASection) {
PRInt32 i = 0; PRUint32 i = 0;
PRInt32 j = 0; PRUint32 j = 0;
PRInt32 length = aData.length(); PRUint32 length = aData.length();
*mOut << CDATA_START; *mOut << CDATA_START;
@ -317,7 +317,7 @@ void txXMLOutput::printUTF8Char(DOM_CHAR& ch)
void txXMLOutput::printUTF8Chars(const String& aData) void txXMLOutput::printUTF8Chars(const String& aData)
{ {
DOM_CHAR currChar; DOM_CHAR currChar;
PRInt32 i = 0; PRUint32 i = 0;
while (i < aData.length()) { while (i < aData.length()) {
currChar = aData.charAt(i++); currChar = aData.charAt(i++);
@ -329,7 +329,7 @@ void txXMLOutput::printWithXMLEntities(const String& aData,
MBool aAttribute) MBool aAttribute)
{ {
DOM_CHAR currChar; DOM_CHAR currChar;
PRInt32 i; PRUint32 i;
if (&aData == &NULL_STRING) if (&aData == &NULL_STRING)
return; return;

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsINodeInfo.h" #include "nsINodeInfo.h"
#include "XMLUtils.h"
#endif #endif
/* /*
@ -317,8 +318,6 @@ void txRootPattern::toString(String& aDest)
* argument. * argument.
*/ */
#define TX_IS_WHITE(c) (c == ' ' || c == '\r' || c == '\n'|| c == '\t')
txIdPattern::txIdPattern(const String aString) txIdPattern::txIdPattern(const String aString)
{ {
#ifdef TX_EXE #ifdef TX_EXE
@ -330,12 +329,12 @@ txIdPattern::txIdPattern(const String aString)
ids.EndReading(end); ids.EndReading(end);
pos = begin; pos = begin;
while (pos != end) { while (pos != end) {
while (pos != end && TX_IS_WHITE(*pos)) while (pos != end && XMLUtils::isWhitespace(*pos))
++pos; ++pos;
begin = pos; begin = pos;
if (!mIds.IsEmpty()) if (!mIds.IsEmpty())
mIds += PRUnichar(' '); mIds += PRUnichar(' ');
while (pos != end && !TX_IS_WHITE(*pos)) while (pos != end && !XMLUtils::isWhitespace(*pos))
++pos; ++pos;
mIds += Substring(begin, pos); mIds += Substring(begin, pos);
} }
@ -413,7 +412,7 @@ void txIdPattern::toString(String& aDest)
#ifdef TX_EXE #ifdef TX_EXE
aDest.append(mIds); aDest.append(mIds);
#else #else
aDest.append(mIds.get()); aDest.getNSString().Append(mIds);
#endif #endif
aDest.append("')"); aDest.append("')");
#ifdef DEBUG #ifdef DEBUG

Просмотреть файл

@ -122,7 +122,7 @@ MBool txNodeSorter::addSortElement(Element* aSortElement,
// Language // Language
String lang; String lang;
if (!getAttrAsAVT(aSortElement, txXSLTAtoms::lang, aContext, lang)) if (!getAttrAsAVT(aSortElement, txXSLTAtoms::lang, aContext, lang))
lang = DEFAULT_LANG; lang.append(DEFAULT_LANG);
// Case-order // Case-order
MBool upperFirst; MBool upperFirst;

Просмотреть файл

@ -143,11 +143,11 @@ int txResultStringComparator::compareValues(TxObject* aVal1, TxObject* aVal2)
StringValue* strval1 = (StringValue*)aVal1; StringValue* strval1 = (StringValue*)aVal1;
StringValue* strval2 = (StringValue*)aVal2; StringValue* strval2 = (StringValue*)aVal2;
#ifdef TX_EXE #ifdef TX_EXE
PRInt32 len1 = strval1->mStr.length(); PRUint32 len1 = strval1->mStr.length();
PRInt32 len2 = strval2->mStr.length(); PRUint32 len2 = strval2->mStr.length();
PRInt32 minLength = (len1 < len2) ? len1 : len2; PRUint32 minLength = (len1 < len2) ? len1 : len2;
PRInt32 c = 0; PRUint32 c = 0;
while (c < minLength) { while (c < minLength) {
UNICODE_CHAR ch1 = strval1->mStr.charAt(c); UNICODE_CHAR ch1 = strval1->mStr.charAt(c);
UNICODE_CHAR ch2 = strval2->mStr.charAt(c); UNICODE_CHAR ch2 = strval2->mStr.charAt(c);