Mail Archives: djgpp/2002/12/16/08:30:39
065211 AT bud DOT swin DOT edu DOT au (MURPHY, Jeremy W) wrote in
news:atkeh5$1fh$1 AT c3p0 DOT cc DOT swin DOT edu DOT au:
> Howdy,
>
> not sure if my previous post went through, but I've refined my
> question anyway, so forgive me for repeating myself.
>
> I haven't programmed in djgpp for a while, so I'm a bit out of touch
> with its idiosyncrasies.
>
> I notice that if TMPDIR="c:/djgpp/tmp", it comes up as "c:\djgpp\tmp"
> in a program if you use getenv() or tmpnam(), which I assume is the
> correct behaviour, it makes sense.
>
> Problem is that I'm compiling and running some C which had UNIX in
> mind, and so is using the result of getenv() as part of a call to
> system(), and the backslashes are getting eaten up, or something.
> So calling system("uname -s > c:\djgpp\tmp/dj200000 2>&1") is
> resulting in:
> c:\djgpp\tmp/dj400000: c:djgpptmp/dj200000: No such file or directory
> (ENOENT)
you may want to look at the documentation for _fixpath. i don't know if
the value of `_crt0_startup_flags' has any effect on how environment
strings are read, although I suspect not.
C:\Dload\misc>cat eee.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main(void)
{
char fixed_path[FILENAME_MAX];
puts(getenv("TEMP"));
_fixpath(getenv("TEMP"), fixed_path);
puts(fixed_path);
return 0;
}
C:\Dload\misc>gcc -Wall eee.c -o eee.exe
C:\Dload\misc>eee
C:\WINDOWS\TEMP
c:/WINDOWS/TEMP
--
A. Sinan Unur
asu1 AT c-o-r-n-e-l-l DOT edu
Remove dashes for address
Spam bait: mailto:uce AT ftc DOT gov
- Raw text -