- tempnam would set the errno to 2 on the Mac even though everything seemed to be working as expected.

SVN r2161 (trunk)
This commit is contained in:
Christoph Oelckers 2010-02-14 08:13:50 +00:00
parent 6ec30761c6
commit 8a843e4b3c

View file

@ -30,15 +30,21 @@ int main(int argc, char **argv)
// Use svnversion to get the revision number. If that fails, pretend it's
// revision 0. Note that this requires you have the command-line svn tools installed.
sprintf (run, "svnversion -cn %s", argv[1]);
if ((name = tempnam(NULL, "svnout")) != NULL &&
(stream = freopen(name, "w+b", stdout)) != NULL &&
system(run) == 0 &&
errno == 0 &&
fseek(stream, 0, SEEK_SET) == 0 &&
fgets(currev, sizeof currev, stream) == currev &&
(isdigit(currev[0]) || (currev[0] == '-' && currev[1] == '1')))
if ((name = tempnam(NULL, "svnout")) != NULL)
{
gotrev = 1;
#ifdef __APPLE__
// tempnam will return errno of 2 even though it is successful for our purposes.
errno = 0;
#endif
if((stream = freopen(name, "w+b", stdout)) != NULL &&
system(run) == 0 &&
errno == 0 &&
fseek(stream, 0, SEEK_SET) == 0 &&
fgets(currev, sizeof currev, stream) == currev &&
(isdigit(currev[0]) || (currev[0] == '-' && currev[1] == '1')))
{
gotrev = 1;
}
}
if (stream != NULL)
{