delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/10/29/05:45:30

From: sos AT prospect DOT com DOT ru (Sergey Okhapkin)
Subject: RE: Problem with getenv("HOME")
29 Oct 1997 05:45:30 -0800 :
Message-ID: <01BCE457.4F1BC940.cygnus.gnu-win32@gater.krystalbank.msk.ru>
To: "'gnu-win32 AT cygnus DOT com'" <gnu-win32 AT cygnus DOT com>,
"'Wolfgang Stuerzlinger'" <stuerzl AT cs DOT unc DOT edu>
Cc: "'edel AT fnal DOT fov'" <edel AT fnal DOT fov>

Wolfgang Stuerzlinger wrote:
> By default the environment variable HOME is not set in the GNU-Win32
> environment.
> When getenv is called with ("HOME") as argument the return value is a
> string "(null)" instead of a NULL pointer. Is this a "standard" behaviour 
> or a bug?
>
> Wolfgang Stuerzlinger
>
> P.S.: This breaks commonly used code sequences like:
> 	sprintf(newName,"%s/%s",getenv("HOME"),fileName);

It's a bug in your example. getenv() returns NULL pointer, but sprintf 
formats it as a "(null)" string. You have to check getenv's return value 
before passing it somwhere.

--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia
Looking for a job.


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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