Re: Unofficial GNU/Hurd release (#636568)
On Thu, 2012-10-11 at 11:14 +0200, Pino Toscano wrote:
> Hi,
>
> Alle giovedì 11 ottobre 2012, Svante Signell ha scritto:
> > > Should be updated:
> > > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=636568
> >
> > Next package on the list: xerces-c
> >
> > Attached is an updated patch for bug #636568, use_posix_fcns.patch,
> > the *.dsc and *.debian.tar.gz files to enable a successful build for
> > GNU/Hurd.
> > use_posix_fcns.patch
> > ---
> > a/src/xercesc/util/FileManagers/PosixFileMgr.cpp.orig
> > b/src/xercesc/util/FileManagers/PosixFileMgr.cpp
> > @@ -187,27 +187,32 @@
> > ArrayJanitor<char> janText(newSrc, manager);
> >
> > // Use a local buffer that is big enough for the largest legal path
> > - char absPath[PATH_MAX + 1];
> > -
> > + char *absPath;
> > + XMLCh *ret;
> > +
>
> You are turning a whitespace line into an empty line, which is not
> needed.
> Also this is C++, so you can declare "ret" right at assign time, like
> it is done also elsewhere.
Changed, also for absPath!
> > // get the absolute path
> > - if (!realpath(newSrc, absPath))
> > + absPath = realpath(newSrc, NULL);
> > + if (absPath == NULL)
>
> Looking at the rest of the file, the style for NULL pointer checks is
> !foo, so adapt to that.
Changed.
> > - char dirBuf[PATH_MAX + 2];
> > - char *curDir = getcwd(&dirBuf[0], PATH_MAX + 1);
> > + XMLCh *ret;
>
> Same as above (declare at assign).
Changed.
> > - if (!curDir)
> > + if (curDir == NULL)
>
> Why did you change this?
Dunno, changed! A new patch attached. OK now?
> Also, when done with the above fixed, do not forget to:
> a) send the patch upstream
Will do.
> b) send the updated patch to the Debian bug, otherwise there's only
> and old (and wrong) patch
Yes, of course.
Thanks!
Index: xerces-c-3.1.1/src/xercesc/util/FileManagers/PosixFileMgr.cpp
===================================================================
--- xerces-c-3.1.1.orig/src/xercesc/util/FileManagers/PosixFileMgr.cpp 2012-10-11 08:33:27.000000000 +0200
+++ xerces-c-3.1.1/src/xercesc/util/FileManagers/PosixFileMgr.cpp 2012-10-11 11:32:27.000000000 +0200
@@ -187,27 +187,28 @@
ArrayJanitor<char> janText(newSrc, manager);
// 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))
+ char *absPath = realpath(newSrc, NULL);
+ if (!absPath)
ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetBasePathName, manager);
-
- return XMLString::transcode(absPath, manager);
+ XMLCh *ret = XMLString::transcode(absPath, manager);
+ free(absPath);
+ return ret;
}
XMLCh*
PosixFileMgr::getCurrentDirectory(MemoryManager* const manager)
{
- char dirBuf[PATH_MAX + 2];
- char *curDir = getcwd(&dirBuf[0], PATH_MAX + 1);
+ char *curDir = getcwd(NULL, 0);
if (!curDir)
ThrowXMLwithMemMgr(XMLPlatformUtilsException,
XMLExcepts::File_CouldNotGetBasePathName, manager);
- return XMLString::transcode(curDir, manager);
+ XMLCh *ret = XMLString::transcode(curDir, manager);
+ free(curDir);
+ return ret;
}
Reply to: