Commit d4fd5bde authored by Jay Berkenbilt's avatar Jay Berkenbilt

Fix HURD problem

parent 16ad93d2
xerces-c (3.1.1-5) unstable; urgency=medium
* Apply upstream patch for PATH_MAX to enable compilation on GNU hurd.
(Closes: #636568)
-- Jay Berkenbilt <qjb@debian.org> Wed, 08 Jan 2014 15:48:01 -0500
xerces-c (3.1.1-4) unstable; urgency=low
* Update standards version to 3.9.5. Opting for shlibs files because of
......
Description: check for PATH_MAX
Bug: https://issues.apache.org/jira/browse/XERCESC-1998
Bug-Debian: http://bugs.debian.org/636568
Origin: upstream, http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/FileManagers/PosixFileMgr.cpp?r1=673975&r2=1478186&pathrev=1478186&view=patch
Index: xerces-c/src/xercesc/util/FileManagers/PosixFileMgr.cpp
===================================================================
--- xerces-c.orig/src/xercesc/util/FileManagers/PosixFileMgr.cpp 2014-01-08 15:44:25.211067958 -0500
+++ xerces-c/src/xercesc/util/FileManagers/PosixFileMgr.cpp 2014-01-08 15:44:25.207067926 -0500
@@ -19,9 +19,16 @@
* $Id: PosixFileMgr.cpp 673975 2008-07-04 09:23:56Z borisk $
*/
+#include <config.h>
#include <stdio.h>
+
+#if HAVE_UNISTD_H
#include <unistd.h>
+#endif
+
+#if HAVE_LIMITS_H
#include <limits.h>
+#endif
#include <xercesc/util/FileManagers/PosixFileMgr.hpp>
@@ -74,7 +81,7 @@
PosixFileMgr::fileClose(FileHandle f, MemoryManager* const manager)
{
if (!f)
- ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
if (fclose((FILE*)f))
ThrowXMLwithMemMgr(XMLPlatformUtilsException,
@@ -86,7 +93,7 @@
PosixFileMgr::fileReset(FileHandle f, MemoryManager* const manager)
{
if (!f)
- ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
// Seek to the start of the file
if (fseek((FILE*)f, 0, SEEK_SET))
@@ -99,7 +106,7 @@
PosixFileMgr::curPos(FileHandle f, MemoryManager* const manager)
{
if (!f)
- ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
long curPos = ftell((FILE*)f);
@@ -114,7 +121,7 @@
PosixFileMgr::fileSize(FileHandle f, MemoryManager* const manager)
{
if (!f)
- ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
// Get the current position
long curPos = ftell((FILE*)f);
@@ -141,16 +148,16 @@
PosixFileMgr::fileRead(FileHandle f, XMLSize_t byteCount, XMLByte* buffer, MemoryManager* const manager)
{
if (!f || !buffer)
- ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
XMLSize_t bytesRead = 0;
- if (byteCount > 0)
- {
- bytesRead = fread((void*)buffer, 1, byteCount, (FILE*)f);
-
- if (ferror((FILE*)f))
- ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile, manager);
- }
+ if (byteCount > 0)
+ {
+ bytesRead = fread((void*)buffer, 1, byteCount, (FILE*)f);
+
+ if (ferror((FILE*)f))
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile, manager);
+ }
return bytesRead;
}
@@ -160,17 +167,17 @@
PosixFileMgr::fileWrite(FileHandle f, XMLSize_t byteCount, const XMLByte* buffer, MemoryManager* const manager)
{
if (!f || !buffer)
- ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::CPtr_PointerIsZero, manager);
while (byteCount > 0)
{
XMLSize_t bytesWritten = fwrite(buffer, sizeof(XMLByte), byteCount, (FILE*)f);
if (ferror((FILE*)f))
- ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile, manager);
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile, manager);
- buffer += bytesWritten;
- byteCount -= bytesWritten;
+ buffer += bytesWritten;
+ byteCount -= bytesWritten;
}
}
@@ -186,28 +193,47 @@
char* newSrc = XMLString::transcode(srcPath, manager);
ArrayJanitor<char> janText(newSrc, manager);
+#if HAVE_PATH_MAX
// Use a local buffer that is big enough for the largest legal path
char absPath[PATH_MAX + 1];
// get the absolute path
if (!realpath(newSrc, absPath))
- ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetBasePathName, manager);
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetBasePathName, manager);
- return XMLString::transcode(absPath, manager);
+ XMLCh* ret = XMLString::transcode(absPath, manager);
+#else
+ // get the absolute path
+ char *absPath = realpath(newSrc, NULL);
+ if(!absPath)
+ ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetBasePathName, manager);
+
+ XMLCh* ret = XMLString::transcode(absPath, manager);
+ free(absPath);
+#endif
+ return ret;
}
XMLCh*
PosixFileMgr::getCurrentDirectory(MemoryManager* const manager)
{
+#if HAVE_PATH_MAX
char dirBuf[PATH_MAX + 2];
char *curDir = getcwd(&dirBuf[0], PATH_MAX + 1);
+#else
+ char *curDir = getcwd(NULL, 0);
+#endif
if (!curDir)
ThrowXMLwithMemMgr(XMLPlatformUtilsException,
XMLExcepts::File_CouldNotGetBasePathName, manager);
- return XMLString::transcode(curDir, manager);
+ XMLCh* ret = XMLString::transcode(curDir, manager);
+#if !HAVE_PATH_MAX
+ free(curDir);
+#endif
+ return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment