You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ca...@apache.org on 2005/06/21 21:02:38 UTC
svn commit: r191709 - in /xerces/c/branches/xerces-2.7/src/xercesc/util:
XMLString.cpp XMLURL.cpp XMLURL.hpp
Author: cargilld
Date: Tue Jun 21 12:02:38 2005
New Revision: 191709
URL: http://svn.apache.org/viewcvs?rev=191709&view=rev
Log:
Add back changes Bertoni made that were overwritten.
Modified:
xerces/c/branches/xerces-2.7/src/xercesc/util/XMLString.cpp
xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.cpp
xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.hpp
Modified: xerces/c/branches/xerces-2.7/src/xercesc/util/XMLString.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/util/XMLString.cpp?rev=191709&r1=191708&r2=191709&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/util/XMLString.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/util/XMLString.cpp Tue Jun 21 12:02:38 2005
@@ -43,6 +43,7 @@
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/XMLUri.hpp>
+#include <xercesc/util/XMLURL.hpp>
#include <xercesc/internal/XMLReader.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -647,32 +648,37 @@
(colPos == nameLen - 1) ) // <URI>':'
return false;
- // Examine URI
- if (colPos > 0)
+
+ // Examine localpart
+ if (!XMLString::isValidNCName(&name[colPos+1]))
+ {
+ return false;
+ }
+ else if (colPos == 0)
+ {
+ return true;
+ }
+ else
{
- XMLCh* temp = (XMLCh*) &(name[colPos]);
- *temp = 0;
+ // Examine URI
+ XMLCh* const temp =
+ (XMLCh*) manager->allocate((colPos + 1) * sizeof(XMLCh));
+ const ArrayJanitor<XMLCh> jan(temp, manager);
+
+ copyNString(temp, name, colPos);
+ temp[colPos] = 0;
try
{
- XMLUri newURI(name, manager); // no relative uri support here
- *temp = chColon;
+ XMLUri newURI(temp, manager); // no relative uri support here
}
- catch(const OutOfMemoryException&)
+ catch (const MalformedURLException&)
{
- *temp = chColon;
return false;
}
- catch (...)
- {
- *temp = chColon;
- return false;
- }
- }
-
- // Examine localpart
- return XMLString::isValidNCName(&(name[colPos+1]));
+ return true;
+ }
}
@@ -1662,7 +1668,7 @@
(
(strLen+1) * sizeof(XMLCh)
);//new XMLCh[strLen+1];
- XMLCh* retPtr = &(retBuf[0]);
+ XMLCh* retPtr = &retBuf[0];
XMLCh* startPtr = toConvert;
while ( *startPtr )
@@ -1762,7 +1768,7 @@
(
(endPtr - startPtr + 1) * sizeof(XMLCh)
);//new XMLCh[endPtr - startPtr + 1];
- XMLCh* retPtr = &(retBuf[0]);
+ XMLCh* retPtr = &retBuf[0];
bool inSpace = false;
while (startPtr < endPtr)
{
@@ -1809,7 +1815,7 @@
(
(XMLString::stringLen(toConvert) + 1) * sizeof(XMLCh)
);//new XMLCh[ XMLString::stringLen(toConvert) + 1];
- XMLCh* retPtr = &(retBuf[0]);
+ XMLCh* retPtr = &retBuf[0];
XMLCh* startPtr = toConvert;
while (*startPtr)
Modified: xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.cpp?rev=191709&r1=191708&r2=191709&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.cpp Tue Jun 21 12:02:38 2005
@@ -164,6 +164,8 @@
{
}
+typedef JanitorMemFunCall<XMLURL> CleanupType;
+
XMLURL::XMLURL(const XMLCh* const baseURL
, const XMLCh* const relativeURL
, MemoryManager* const manager) :
@@ -180,19 +182,20 @@
, fURLText(0)
, fHasInvalidChar(false)
{
+ CleanupType cleanup(this, &XMLURL::cleanUp);
+
try
{
setURL(baseURL, relativeURL);
}
catch(const OutOfMemoryException&)
{
+ cleanup.release();
+
throw;
}
- catch(...)
- {
- cleanup();
- throw;
- }
+
+ cleanup.release();
}
XMLURL::XMLURL(const XMLCh* const baseURL
@@ -211,6 +214,8 @@
, fURLText(0)
, fHasInvalidChar(false)
{
+ CleanupType cleanup(this, &XMLURL::cleanUp);
+
XMLCh* tmpRel = XMLString::transcode(relativeURL, fMemoryManager);
ArrayJanitor<XMLCh> janRel(tmpRel, fMemoryManager);
try
@@ -219,13 +224,12 @@
}
catch(const OutOfMemoryException&)
{
+ cleanup.release();
+
throw;
}
- catch(...)
- {
- cleanup();
- throw;
- }
+
+ cleanup.release();
}
XMLURL::XMLURL(const XMLURL& baseURL
@@ -243,19 +247,20 @@
, fURLText(0)
, fHasInvalidChar(false)
{
+ CleanupType cleanup(this, &XMLURL::cleanUp);
+
try
{
setURL(baseURL, relativeURL);
}
catch(const OutOfMemoryException&)
{
+ cleanup.release();
+
throw;
}
- catch(...)
- {
- cleanup();
- throw;
- }
+
+ cleanup.release();
}
XMLURL::XMLURL(const XMLURL& baseURL
@@ -273,6 +278,8 @@
, fURLText(0)
, fHasInvalidChar(false)
{
+ CleanupType cleanup(this, &XMLURL::cleanUp);
+
XMLCh* tmpRel = XMLString::transcode(relativeURL, fMemoryManager);
ArrayJanitor<XMLCh> janRel(tmpRel, fMemoryManager);
try
@@ -281,14 +288,12 @@
}
catch(const OutOfMemoryException&)
{
- throw;
- }
- catch(...)
- {
- cleanup();
+ cleanup.release();
+
throw;
}
+ cleanup.release();
}
XMLURL::XMLURL(const XMLCh* const urlText,
@@ -306,19 +311,20 @@
, fURLText(0)
, fHasInvalidChar(false)
{
+ CleanupType cleanup(this, &XMLURL::cleanUp);
+
try
{
setURL(urlText);
}
catch(const OutOfMemoryException&)
{
+ cleanup.release();
+
throw;
}
- catch(...)
- {
- cleanup();
- throw;
- }
+
+ cleanup.release();
}
XMLURL::XMLURL(const char* const urlText,
@@ -336,6 +342,8 @@
, fURLText(0)
, fHasInvalidChar(false)
{
+ CleanupType cleanup(this, &XMLURL::cleanUp);
+
XMLCh* tmpText = XMLString::transcode(urlText, fMemoryManager);
ArrayJanitor<XMLCh> janRel(tmpText, fMemoryManager);
try
@@ -344,13 +352,12 @@
}
catch(const OutOfMemoryException&)
{
+ cleanup.release();
+
throw;
}
- catch(...)
- {
- cleanup();
- throw;
- }
+
+ cleanup.release();
}
XMLURL::XMLURL(const XMLURL& toCopy) :
@@ -367,6 +374,8 @@
, fURLText(0)
, fHasInvalidChar(toCopy.fHasInvalidChar)
{
+ CleanupType cleanup(this, &XMLURL::cleanUp);
+
try
{
fFragment = XMLString::replicate(toCopy.fFragment, fMemoryManager);
@@ -379,18 +388,17 @@
}
catch(const OutOfMemoryException&)
{
+ cleanup.release();
+
throw;
}
- catch(...)
- {
- cleanup();
- throw;
- }
+
+ cleanup.release();
}
XMLURL::~XMLURL()
{
- cleanup();
+ cleanUp();
}
@@ -403,7 +411,7 @@
return *this;
// Clean up our stuff
- cleanup();
+ cleanUp();
// And copy his stuff
fMemoryManager = toAssign.fMemoryManager;
@@ -473,14 +481,14 @@
//
// Try to parse the URL.
//
- cleanup();
+ cleanUp();
parse(urlText);
}
void XMLURL::setURL(const XMLCh* const baseURL
, const XMLCh* const relativeURL)
{
- cleanup();
+ cleanUp();
// Parse our URL string
parse(relativeURL);
@@ -496,7 +504,7 @@
XMLURL basePart(baseURL, fMemoryManager);
if (!conglomerateWithBase(basePart, false))
{
- cleanup();
+ cleanUp();
ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_RelativeBaseURL, fMemoryManager);
}
}
@@ -510,7 +518,7 @@
, const XMLCh* const relativeURL
, XMLURL& xmlURL)
{
- cleanup();
+ cleanUp();
// Parse our URL string
if (parse(relativeURL, xmlURL))
@@ -535,7 +543,7 @@
void XMLURL::setURL(const XMLURL& baseURL
, const XMLCh* const relativeURL)
{
- cleanup();
+ cleanUp();
// Parse our URL string
parse(relativeURL);
@@ -765,7 +773,7 @@
// Just a central place to handle cleanup, since its done from a number
// of different spots.
//
-void XMLURL::cleanup()
+void XMLURL::cleanUp()
{
fMemoryManager->deallocate(fFragment);//delete [] fFragment;
fMemoryManager->deallocate(fHost);//delete [] fHost;
@@ -1464,3 +1472,4 @@
XERCES_CPP_NAMESPACE_END
+
\ No newline at end of file
Modified: xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.hpp?rev=191709&r1=191708&r2=191709&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.hpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/util/XMLURL.hpp Tue Jun 21 12:02:38 2005
@@ -155,7 +155,7 @@
// Private helper methods
// -----------------------------------------------------------------------
void buildFullText();
- void cleanup();
+ void cleanUp();
bool conglomerateWithBase(const XMLURL& baseURL, bool useExceptions=true);
void parse
(
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org