bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getenv() and i370-ibm-openedition


From: Paul Gilmartin
Subject: getenv() and i370-ibm-openedition
Date: Wed, 23 Jul 2014 16:26:55 -0600
User-agent: Mozilla/5.0 (X11; SunOS i86pc; rv:6.0) Gecko/20110814 Thunderbird/6.0

Hello, bug-ncurses,

In: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getenv.html#tag_16_194_03
one may read:
    ...
char *getenv(const char *name);
    ...
[CX] [Option Start] The returned string pointer might be invalidated or [Option End]  the string content might be overwritten by a subsequent call to getenv(), [CX] [Option Start] setenv(), unsetenv(), or (if supported) putenv() ...

IBM is the only vendor I've known to exploit this behavior by copying the
string value into a volatile buffer.  (Their intent was to spare the programmer
the onus of keeping the argument to putenv() in static storage.)  This caused
me problems in Lynx; Tom Dickey generously incorporated my patch to copy the
returned value.

But I'm now informed that IBM supplies an alternative, __getenv(), which
simply returns a pointer to the string the programmer supplied to putenv()
after the "=".  Might the easy circumvention be:

    #if defined(__MVS__)
    #include <stdlib.h>
    #define getenv __getenv
    #endif

... so getenv is redefined somewhere after any header file mentioning
getenv but before any call to getenv() in ncurses?

Thanks,
gil


reply via email to

[Prev in Thread] Current Thread [Next in Thread]