delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/16/08:30:39

From: "A. Sinan Unur" <asu1 AT c-o-r-n-e-l-l DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: back slash compatibility prob
Date: 16 Dec 2002 13:20:18 GMT
Organization: Cornell University
Lines: 54
Sender: asu1 AT cornell DOT invalid (on pool-141-149-208-61.syr.east.verizon.net)
Message-ID: <Xns92E654D4AD5CAasu1cornelledu@132.236.56.8>
References: <atkeh5$1fh$1 AT c3p0 DOT cc DOT swin DOT edu DOT au>
NNTP-Posting-Host: pool-141-149-208-61.syr.east.verizon.net
X-Trace: news01.cit.cornell.edu 1040044818 19415 141.149.208.61 (16 Dec 2002 13:20:18 GMT)
X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu
NNTP-Posting-Date: 16 Dec 2002 13:20:18 GMT
User-Agent: Xnews/5.04.25
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019