GNU bug report logs -
#19874
25.0.50; encode-time not working as expected
Previous Next
Reported by: ashish.is <at> lostca.se (Ashish SHUKLA)
Date: Sun, 15 Feb 2015 13:42:01 UTC
Severity: normal
Found in version 25.0.50
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #85 received at 19874 <at> debbugs.gnu.org (full text, mbox):
On Thu, Feb 26 2015, Paul Eggert wrote:
> Emacs's putenv implementation should be portable to any POSIX
> platform, but FreeBSD 10.1 getenv+setenv has a bug. The attached
> program should work on any POSIX platform, and it does work on
> GNU/Linux and on Solaris, but it doesn't work on FreeBSD 10.1. Emacs
> has similar code, which apparently also runs afoul of the FreeBSD bug.
>
> #include <stdio.h>
> #include <stdlib.h>
> extern char **environ;
> char env1[] = "abc=def";
> char *small_environ[] = { env1, 0 };
> int
> main (void)
> {
> environ = small_environ;
> if (setenv ("mno", "pqr", 0) != 0)
> return perror ("setenv"), 1;
> env1[0] = 'x';
> if (! getenv ("xbc"))
> return fprintf (stderr, "getenv failed\n"), 1;
> return 0;
> }
IIUC, the standard explicitly permits the FreeBSD behaviour, so the
program above does not seem to be conforming:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getenv.html
If the application switches to a complete new environment by
assigning a new value to environ, this can be detected by
getenv(), setenv(), unsetenv(), or putenv() and the
implementation can at that point reinitialize based on the new
environment. (This may include copying the environment strings
into a new array and assigning environ to point to it.)
This bug report was last modified 5 years and 119 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.