Mail Archives: djgpp/1994/09/01/09:10:40
Stephen R. Whiteley writes:
> Tried the new libc.a in dj112m1.zip, however found that the tempnam()
> function returns NULL (noticed this in make-3.71/job.c). Put back
> the 111m5 libc.a and everything was cool.
I had the same problem (with tmpnam()), and I'm busy tracking the error.
I think the problem is located in stat().
stat() doesn't return ENOENT when called with a non-existent path.
I've included a small test program below.
Regards,
Pieter Kunst (kunst AT prl DOT philips DOT nl)
==============================================================================
#define _INCLUDE_POSIX_SOURCE
#include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
int main()
{
struct stat sbuf;
char path[100];
int rv;
extern int errno;
strcpy (path, "/nonexist"); /* non-existing filename */
rv = stat(path, &sbuf);
printf ("path = %s, rv = %d\n", path, rv);
printf ("errno = %d\n", errno);
switch (errno)
{
case ENOENT: /* 2 */
printf ("%d = No such file or directory\n", errno);
break;
#ifdef ENMFILE
case ENMFILE:
printf ("%d = No more files\n", errno);
break;
#endif
}
return 0;
}
==============================================================================
Output of the program above on HP-UX system:
==============================================================================
path = /nonexist, rv = -1
errno = 2
2 = No such file or directory
==============================================================================
Output of the program above with DJ112M1:
==============================================================================
path = /nonexist, rv = -1
errno = 18
18 = No more files
==============================================================================
- Raw text -