cargilld    2004/01/12 08:15:57

  Modified:    c/src/xercesc/internal DGXMLScanner.cpp IGXMLScanner2.cpp
                        ReaderMgr.cpp SGXMLScanner.cpp XMLScanner.cpp
               c/src/xercesc/util XMLURL.cpp XMLURL.hpp
               c/src/xercesc/validators/schema TraverseSchema.cpp
  Log:
  Avoid throwing malformedurl exceptions in XMLURL to avoid a threading problem on AIX.
  
  Revision  Changes    Path
  1.39      +11 -22    xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp
  
  Index: DGXMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- DGXMLScanner.cpp  30 Dec 2003 06:00:38 -0000      1.38
  +++ DGXMLScanner.cpp  12 Jan 2004 16:15:57 -0000      1.39
  @@ -2451,27 +2451,10 @@
           ReaderMgr::LastExtEntityInfo lastInfo;
           fReaderMgr.getLastExtEntityInfo(lastInfo);
   
  -        try
  +        XMLURL urlTmp(fMemoryManager);
  +        if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) ||
  +            (urlTmp.isRelative()))
           {
  -            XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer());
  -            if (urlTmp.isRelative())
  -            {
  -                ThrowXMLwithMemMgr
  -                (
  -                    MalformedURLException
  -                    , XMLExcepts::URL_NoProtocolPresent
  -                    , fMemoryManager
  -                );
  -            }
  -            else {
  -                if (fStandardUriConformant && urlTmp.hasInvalidChar())
  -                    ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  -                srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  -            }
  -        }
  -        catch(const MalformedURLException& e)
  -        {
  -            // Its not a URL, so lets assume its a local file name if non-standard 
uri is allowed
               if (!fStandardUriConformant)
                   srcToFill = new (fMemoryManager) LocalFileInputSource
                   (
  @@ -2480,8 +2463,14 @@
                       , fMemoryManager
                   );
               else
  -                throw e;
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);            
           }
  +        else
  +        {
  +            if (fStandardUriConformant && urlTmp.hasInvalidChar())
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +            srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager);
  +        }        
       }
   
       return srcToFill;
  
  
  
  1.58      +21 -44    xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp
  
  Index: IGXMLScanner2.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- IGXMLScanner2.cpp 30 Dec 2003 21:38:42 -0000      1.57
  +++ IGXMLScanner2.cpp 12 Jan 2004 16:15:57 -0000      1.58
  @@ -1738,28 +1738,10 @@
               ReaderMgr::LastExtEntityInfo lastInfo;
               fReaderMgr.getLastExtEntityInfo(lastInfo);
   
  -            try
  +            XMLURL urlTmp(fMemoryManager);
  +            if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), 
urlTmp)) ||
  +                (urlTmp.isRelative()))
               {
  -                XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer(), 
fMemoryManager);
  -                if (urlTmp.isRelative())
  -                {
  -                    ThrowXMLwithMemMgr
  -                    (
  -                        MalformedURLException
  -                        , XMLExcepts::URL_NoProtocolPresent
  -                        , fMemoryManager
  -                    );
  -                }
  -                else {
  -                    if (fStandardUriConformant && urlTmp.hasInvalidChar())
  -                        ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  -                    srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  -                }
  -            }
  -
  -            catch(const MalformedURLException& e)
  -            {
  -                // Its not a URL, so lets assume its a local file name if 
non-standard uri is allowed
                   if (!fStandardUriConformant)
                       srcToFill = new (fMemoryManager) LocalFileInputSource
                       (
  @@ -1768,8 +1750,14 @@
                           , fMemoryManager
                       );
                   else
  -                    throw e;
  +                    ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);            
               }
  +            else
  +            {
  +                if (fStandardUriConformant && urlTmp.hasInvalidChar())
  +                    ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +                srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  +            }        
           }
   
           // Put a janitor on the input source
  @@ -1920,27 +1908,10 @@
           ReaderMgr::LastExtEntityInfo lastInfo;
           fReaderMgr.getLastExtEntityInfo(lastInfo);
   
  -        try
  +        XMLURL urlTmp(fMemoryManager);
  +        if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) ||
  +            (urlTmp.isRelative()))
           {
  -            XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer());
  -            if (urlTmp.isRelative())
  -            {
  -                ThrowXMLwithMemMgr
  -                (
  -                    MalformedURLException
  -                    , XMLExcepts::URL_NoProtocolPresent
  -                    , fMemoryManager
  -                );
  -            }
  -            else {
  -                if (fStandardUriConformant && urlTmp.hasInvalidChar())
  -                    ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  -                srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  -            }
  -        }
  -        catch(const MalformedURLException& e)
  -        {
  -            // Its not a URL, so lets assume its a local file name if non-standard 
uri is allowed
               if (!fStandardUriConformant)
                   srcToFill = new (fMemoryManager) LocalFileInputSource
                   (
  @@ -1949,8 +1920,14 @@
                       , fMemoryManager
                   );
               else
  -                throw e;
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);            
           }
  +        else
  +        {
  +            if (fStandardUriConformant && urlTmp.hasInvalidChar())
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +            srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager);
  +        }        
       }
   
       return srcToFill;
  
  
  
  1.21      +37 -24    xml-xerces/c/src/xercesc/internal/ReaderMgr.cpp
  
  Index: ReaderMgr.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/ReaderMgr.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ReaderMgr.cpp     17 Dec 2003 00:18:34 -0000      1.20
  +++ ReaderMgr.cpp     12 Jan 2004 16:15:57 -0000      1.21
  @@ -544,6 +544,10 @@
           LastExtEntityInfo lastInfo;
           getLastExtEntityInfo(lastInfo);
   
  +// Keep this #if 0 block as it was exposing a threading problem on AIX.
  +// Got rid of the problem by changing XMLURL to not throw malformedurl
  +// exceptions.        
  +#if 0
           try
           {
               XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer(), 
fMemoryManager);
  @@ -576,6 +580,28 @@
               else
                   throw e;
           }
  +#else
  +        XMLURL urlTmp(fMemoryManager);
  +        if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) ||
  +            (urlTmp.isRelative()))
  +        {
  +            if (!fStandardUriConformant)
  +                srcToFill = new (fMemoryManager) LocalFileInputSource
  +                (
  +                    lastInfo.systemId
  +                    , expSysId.getRawBuffer()
  +                    , fMemoryManager
  +                );
  +            else
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);            
  +        }
  +        else
  +        {
  +            if (fStandardUriConformant && urlTmp.hasInvalidChar())
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +            srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager);
  +        }        
  +#endif
       }
   
       // Put a janitor on the input source
  @@ -653,29 +679,10 @@
           LastExtEntityInfo lastInfo;
           getLastExtEntityInfo(lastInfo);
   
  -        try
  -        {
  -            XMLURL urlTmp((!baseURI || !*baseURI) ? lastInfo.systemId : baseURI, 
expSysId.getRawBuffer(), fMemoryManager);
  -
  -            if (urlTmp.isRelative())
  -            {
  -                ThrowXMLwithMemMgr
  -                (
  -                    MalformedURLException
  -                    , XMLExcepts::URL_NoProtocolPresent
  -                    , fMemoryManager
  -                );
  -            }
  -            else {
  -                if (fStandardUriConformant && urlTmp.hasInvalidChar())
  -                    ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  -                srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  -            }
  -        }
  -
  -        catch(const MalformedURLException& e)
  +        XMLURL urlTmp(fMemoryManager);
  +        if ((!urlTmp.setURL((!baseURI || !*baseURI) ? lastInfo.systemId : baseURI, 
expSysId.getRawBuffer(), urlTmp)) ||
  +            (urlTmp.isRelative()))
           {
  -            // Its not a URL, so lets assume its a local file name if non-standard 
uri is allowed
               if (!fStandardUriConformant)
                   srcToFill = new (fMemoryManager) LocalFileInputSource
                   (
  @@ -684,8 +691,14 @@
                       , fMemoryManager
                   );
               else
  -                throw e;
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);            
           }
  +        else
  +        {
  +            if (fStandardUriConformant && urlTmp.hasInvalidChar())
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +            srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager);
  +        }        
       }
   
       // Put a janitor on the input source
  
  
  
  1.74      +21 -44    xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp
  
  Index: SGXMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- SGXMLScanner.cpp  30 Dec 2003 17:50:52 -0000      1.73
  +++ SGXMLScanner.cpp  12 Jan 2004 16:15:57 -0000      1.74
  @@ -3769,28 +3769,10 @@
               ReaderMgr::LastExtEntityInfo lastInfo;
               fReaderMgr.getLastExtEntityInfo(lastInfo);
   
  -            try
  +            XMLURL urlTmp(fMemoryManager);
  +            if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), 
urlTmp)) ||
  +                (urlTmp.isRelative()))
               {
  -                XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer());
  -                if (urlTmp.isRelative())
  -                {
  -                    ThrowXMLwithMemMgr
  -                    (
  -                        MalformedURLException
  -                        , XMLExcepts::URL_NoProtocolPresent
  -                        , fMemoryManager
  -                    );
  -                }
  -                else {
  -                    if (fStandardUriConformant && urlTmp.hasInvalidChar())
  -                        ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  -                    srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  -                }
  -            }
  -
  -            catch(const MalformedURLException& e)
  -            {
  -                // Its not a URL, so lets assume its a local file name if 
non-standard uri is allowed
                   if (!fStandardUriConformant)
                       srcToFill = new (fMemoryManager) LocalFileInputSource
                       (
  @@ -3799,8 +3781,14 @@
                           , fMemoryManager
                       );
                   else
  -                    throw e;
  +                    ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);            
               }
  +            else
  +            {
  +                if (fStandardUriConformant && urlTmp.hasInvalidChar())
  +                    ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +                srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  +            }        
           }
   
           // Put a janitor on the input source
  @@ -3929,27 +3917,10 @@
           ReaderMgr::LastExtEntityInfo lastInfo;
           fReaderMgr.getLastExtEntityInfo(lastInfo);
   
  -        try
  +        XMLURL urlTmp(fMemoryManager);
  +        if ((!urlTmp.setURL(lastInfo.systemId, expSysId.getRawBuffer(), urlTmp)) ||
  +            (urlTmp.isRelative()))
           {
  -            XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer());
  -            if (urlTmp.isRelative())
  -            {
  -                ThrowXMLwithMemMgr
  -                (
  -                    MalformedURLException
  -                    , XMLExcepts::URL_NoProtocolPresent
  -                    , fMemoryManager
  -                );
  -            }
  -            else {
  -                if (fStandardUriConformant && urlTmp.hasInvalidChar())
  -                    ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  -                srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  -            }
  -        }
  -        catch(const MalformedURLException& e)
  -        {
  -            // Its not a URL, so lets assume its a local file name if non-standard 
uri is allowed
               if (!fStandardUriConformant)
                   srcToFill = new (fMemoryManager) LocalFileInputSource
                   (
  @@ -3958,8 +3929,14 @@
                       , fMemoryManager
                   );
               else
  -                throw e;
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);            
           }
  +        else
  +        {
  +            if (fStandardUriConformant && urlTmp.hasInvalidChar())
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +            srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager);
  +        }              
       }
   
       return srcToFill;
  
  
  
  1.61      +81 -101   xml-xerces/c/src/xercesc/internal/XMLScanner.cpp
  
  Index: XMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.cpp,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- XMLScanner.cpp    9 Jan 2004 04:39:56 -0000       1.60
  +++ XMLScanner.cpp    12 Jan 2004 16:15:57 -0000      1.61
  @@ -433,15 +433,6 @@
               );
           return;
       }
  -    catch(const OutOfMemoryException&)
  -    {
  -        throw;
  -    }
  -    catch(...)
  -    {
  -        // Just rethrow this, since its not our problem
  -        throw;
  -    }
   
       Janitor<InputSource> janSrc(srcToUse);
       scanDocument(*srcToUse);
  @@ -472,28 +463,49 @@
           //  Create a temporary URL. Since this is the primary document,
           //  it has to be fully qualified. If not, then assume we are just
           //  mistaking a file for a URL.
  -        XMLURL tmpURL(systemId, fMemoryManager);
  -        if (tmpURL.isRelative()) {
  +        XMLURL tmpURL(fMemoryManager);
  +        if (XMLURL::parse(systemId, tmpURL)) {        
  +            if (tmpURL.isRelative()) {
  +                if (!fStandardUriConformant)
  +                    srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, 
fMemoryManager);
  +                else {
  +                    // since this is the top of the try/catch, cannot call 
ThrowXMLwithMemMgr
  +                    // emit the error directly
  +                    MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_NoProtocolPresent, fMemoryManager);
  +                    fInException = true;
  +                    emitError
  +                    (
  +                        XMLErrs::XMLException_Fatal
  +                        , e.getType()
  +                        , e.getMessage()
  +                    );
  +                    return false;
  +                }
  +            }
  +            else
  +            {
  +                if (fStandardUriConformant && tmpURL.hasInvalidChar()) {
  +                    MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +                    fInException = true;
  +                    emitError
  +                    (
  +                        XMLErrs::XMLException_Fatal
  +                        , e.getType()
  +                        , e.getMessage()
  +                    );
  +                    return false;
  +                }
  +                srcToUse = new (fMemoryManager) URLInputSource(tmpURL, 
fMemoryManager);
  +            }
  +        }
  +        else {
               if (!fStandardUriConformant)
  -                srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, 
fMemoryManager);
  +                srcToUse = new (fMemoryManager) LocalFileInputSource(systemId,  
fMemoryManager);
               else {
                   // since this is the top of the try/catch, cannot call 
ThrowXMLwithMemMgr
                   // emit the error directly
  -                MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_NoProtocolPresent, fMemoryManager);
  -                fInException = true;
  -                emitError
  -                (
  -                    XMLErrs::XMLException_Fatal
  -                    , e.getType()
  -                    , e.getMessage()
  -                );
  -                return false;
  -            }
  -        }
  -        else
  -        {
  -            if (fStandardUriConformant && tmpURL.hasInvalidChar()) {
  -                MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +                // lazy bypass ... since all MalformedURLException are fatal, no 
need to check the type
  +                MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_MalformedURL);
                   fInException = true;
                   emitError
                   (
  @@ -503,25 +515,6 @@
                   );
                   return false;
               }
  -            srcToUse = new (fMemoryManager) URLInputSource(tmpURL, fMemoryManager);
  -        }
  -    }
  -    catch(const MalformedURLException& e)
  -    {
  -        if (!fStandardUriConformant)
  -            srcToUse = new (fMemoryManager) LocalFileInputSource(systemId,  
fMemoryManager);
  -        else {
  -            // since this is the top of the try/catch, cannot call 
ThrowXMLwithMemMgr
  -            // emit the error directly
  -            // lazy bypass ... since all MalformedURLException are fatal, no need 
to check the type
  -            fInException = true;
  -            emitError
  -            (
  -                XMLErrs::XMLException_Fatal
  -                , e.getType()
  -                , e.getMessage()
  -            );
  -            return false;
           }
       }
       catch(const XMLException& excToCatch)
  @@ -552,15 +545,6 @@
               );
           return false;
       }
  -    catch(const OutOfMemoryException&)
  -    {
  -        throw;
  -    }
  -    catch(...)
  -    {
  -        // Just rethrow this, since its not our problem
  -        throw;
  -    }
   
       Janitor<InputSource> janSrc(srcToUse);
       return scanFirst(*srcToUse, toFill);
  @@ -1631,29 +1615,53 @@
               //  Create a temporary URL. Since this is the primary document,
               //  it has to be fully qualified. If not, then assume we are just
               //  mistaking a file for a URL.
  -            XMLURL tmpURL(systemId, fMemoryManager);
  -            if (tmpURL.isRelative())
  +            XMLURL tmpURL(fMemoryManager);
  +
  +            if (XMLURL::parse(systemId, tmpURL)) {            
  +
  +                if (tmpURL.isRelative())
  +                {
  +                    if (!fStandardUriConformant)
  +                        srcToUse = new (fMemoryManager) 
LocalFileInputSource(systemId, fMemoryManager);
  +                    else {
  +                        // since this is the top of the try/catch, cannot call 
ThrowXMLwithMemMgr
  +                        // emit the error directly
  +                        MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_NoProtocolPresent, fMemoryManager);
  +                        fInException = true;
  +                        emitError
  +                        (
  +                            XMLErrs::XMLException_Fatal
  +                            , e.getType()
  +                            , e.getMessage()
  +                        );
  +                        return 0;
  +                    }
  +                }
  +                else
  +                {
  +                    if (fStandardUriConformant && tmpURL.hasInvalidChar()) {
  +                        MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +                        fInException = true;
  +                        emitError
  +                        (
  +                            XMLErrs::XMLException_Fatal
  +                            , e.getType()
  +                            , e.getMessage()
  +                        );
  +                        return 0;
  +                    }
  +                    srcToUse = new (fMemoryManager) URLInputSource(tmpURL, 
fMemoryManager);
  +                }
  +            }
  +            else         
               {
                   if (!fStandardUriConformant)
                       srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, 
fMemoryManager);
                   else {
                       // since this is the top of the try/catch, cannot call 
ThrowXMLwithMemMgr
                       // emit the error directly
  -                    MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_NoProtocolPresent, fMemoryManager);
  -                    fInException = true;
  -                    emitError
  -                    (
  -                        XMLErrs::XMLException_Fatal
  -                        , e.getType()
  -                        , e.getMessage()
  -                    );
  -                    return 0;
  -                }
  -            }
  -            else
  -            {
  -                if (fStandardUriConformant && tmpURL.hasInvalidChar()) {
  -                    MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +                    // lazy bypass ... since all MalformedURLException are fatal, 
no need to check the type
  +                    MalformedURLException e(__FILE__, __LINE__, 
XMLExcepts::URL_MalformedURL);
                       fInException = true;
                       emitError
                       (
  @@ -1663,25 +1671,6 @@
                       );
                       return 0;
                   }
  -                srcToUse = new (fMemoryManager) URLInputSource(tmpURL, 
fMemoryManager);
  -            }
  -        }
  -        catch(const MalformedURLException& e)
  -        {
  -            if (!fStandardUriConformant)
  -                srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, 
fMemoryManager);
  -            else {
  -                // since this is the top of the try/catch, cannot call 
ThrowXMLwithMemMgr
  -                // emit the error directly
  -                // lazy bypass ... since all MalformedURLException are fatal, no 
need to check the type
  -                fInException = true;
  -                emitError
  -                (
  -                    XMLErrs::XMLException_Fatal
  -                    , e.getType()
  -                    , e.getMessage()
  -                );
  -                return 0;
               }
           }
           catch(const XMLException& excToCatch)
  @@ -1711,15 +1700,6 @@
                       , excToCatch.getMessage()
                   );
                   return 0;
  -        }
  -        catch(const OutOfMemoryException&)
  -        {
  -            throw;
  -        }
  -        catch(...)
  -        {
  -            // Just rethrow this, since its not our problem
  -            throw;
           }
       }
   
  
  
  
  1.12      +33 -3     xml-xerces/c/src/xercesc/util/XMLURL.cpp
  
  Index: XMLURL.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLURL.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XMLURL.cpp        17 Dec 2003 00:18:35 -0000      1.11
  +++ XMLURL.cpp        12 Jan 2004 16:15:57 -0000      1.12
  @@ -221,8 +221,8 @@
       , fHasInvalidChar(false)
   {
        try
  -     {
  -             setURL(baseURL, relativeURL);
  +     {       
  +        setURL(baseURL, relativeURL);
        }
       catch(const OutOfMemoryException&)
       {
  @@ -424,6 +424,7 @@
       catch(...)
       {
           cleanup();
  +        throw;
       }
   }
   
  @@ -537,6 +538,35 @@
                        }
                }
        }
  +}
  +
  +// this version of setURL doesn't throw a malformedurl exception
  +// instead it returns false when it failed (or when it would of
  +// thrown a malformedurl exception)
  +bool XMLURL::setURL(const XMLCh* const    baseURL
  +                  , const XMLCh* const    relativeURL
  +                  , XMLURL& xmlURL)
  +{
  +    cleanup();
  +
  +    // Parse our URL string
  +    if (parse(relativeURL, xmlURL))
  +    {
  +         //  If its relative and the base is non-null and non-empty, then
  +         //  parse the base URL string and conglomerate them.
  +         //
  +         if (isRelative() && baseURL && *baseURL)
  +         {              
  +             XMLURL basePart(fMemoryManager);
  +            if (parse(baseURL, basePart)  && conglomerateWithBase(basePart, false))
  +            {    
  +                     return true;                                        
  +                 }
  +         }
  +        else
  +            return true;
  +    }
  +    return false;
   }
   
   void XMLURL::setURL(const XMLURL&         baseURL
  
  
  
  1.12      +6 -3      xml-xerces/c/src/xercesc/util/XMLURL.hpp
  
  Index: XMLURL.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLURL.hpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XMLURL.hpp        26 Aug 2003 21:05:32 -0000      1.11
  +++ XMLURL.hpp        12 Jan 2004 16:15:57 -0000      1.12
  @@ -175,8 +175,11 @@
           const   XMLURL&         baseURL
           , const XMLCh* const    relativeURL
       );
  -
  -
  +    // a version of setURL that doesn't throw malformed url exceptions
  +    bool setURL(
  +        const XMLCh* const    baseURL
  +        , const XMLCh* const    relativeURL
  +        , XMLURL& xmlURL);
       // -----------------------------------------------------------------------
       //  Miscellaneous methods
       // -----------------------------------------------------------------------
  
  
  
  1.107     +18 -21    xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp
  
  Index: TraverseSchema.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v
  retrieving revision 1.106
  retrieving revision 1.107
  diff -u -r1.106 -r1.107
  --- TraverseSchema.cpp        6 Jan 2004 03:55:26 -0000       1.106
  +++ TraverseSchema.cpp        12 Jan 2004 16:15:57 -0000      1.107
  @@ -6448,28 +6448,25 @@
       //  the update resolveEntity accepting nameSpace, a schemImport could
       //  pass a null schemaLocation)
       if (!srcToFill && loc) {
  -
  -        try {
  -
  -            XMLURL urlTmp(fSchemaInfo->getCurrentSchemaURL(), normalizedURI, 
fMemoryManager);
  -
  -            if (urlTmp.isRelative()) {
  -                ThrowXMLwithMemMgr(MalformedURLException,
  -                         XMLExcepts::URL_NoProtocolPresent, fMemoryManager);
  -            }
  -            else {
  -                if (fScanner->getStandardUriConformant() && urlTmp.hasInvalidChar())
  -                    ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  -                srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  -            }
  -        }
  -        catch(const MalformedURLException& e) {
  -            // Its not a URL, so lets assume its a local file name if non-standard 
URI is allowed
  -            if (!fScanner->getStandardUriConformant())
  -                srcToFill = new (fMemoryManager) 
LocalFileInputSource(fSchemaInfo->getCurrentSchemaURL(),normalizedURI, fMemoryManager);
  +        XMLURL urlTmp(fMemoryManager);
  +        if ((!urlTmp.setURL(fSchemaInfo->getCurrentSchemaURL(), normalizedURI, 
urlTmp)) ||
  +            (urlTmp.isRelative()))
  +        {
  +           if (!fScanner->getStandardUriConformant())
  +                srcToFill = new (fMemoryManager) LocalFileInputSource
  +                (   fSchemaInfo->getCurrentSchemaURL()
  +                    , normalizedURI                    
  +                    , fMemoryManager
  +                );
               else
  -                throw e;
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);            
           }
  +        else
  +        {
  +             if (fScanner->getStandardUriConformant() && urlTmp.hasInvalidChar())
  +                ThrowXMLwithMemMgr(MalformedURLException, 
XMLExcepts::URL_MalformedURL, fMemoryManager);
  +             srcToFill = new (fMemoryManager) URLInputSource(urlTmp, 
fMemoryManager);
  +        }          
       }
   
       return srcToFill;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to