This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
RE: Problem with getenv("HOME")
- To: "'gnu-win32 at cygnus dot com'" <gnu-win32 at cygnus dot com>, "'Wolfgang Stuerzlinger'" <stuerzl at cs dot unc dot edu>
- Subject: RE: Problem with getenv("HOME")
- From: Sergey Okhapkin <sos at prospect dot com dot ru>
- Date: Wed, 29 Oct 1997 10:42:08 +0300
- 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@cygnus.com" with one line of text: "help".