Berkeley variant of time zone stuff

Keith Bostic seismo!berkeley.edu!bostic%okeeffe
Sun Mar 29 20:49:09 UTC 1987


> It may be, however, that the best way to ream out the environment is
> just to do
> 
> 	extern char **environ;
> 	static char *nullenv = NULL;
> 
> 	...
> 
> 		environ = &nullenv;
> 
> and be done with it.

The Berkeley man page for getenv has the comment:

     Unsetenv removes all occurrences of the string name from the
     environment.  There is no library provision for completely
     removing the current environment.  It is suggested that the
     following code be used to do so.

          static char    *envinit[1];
          extern char    **environ;
          environ = envinit;

>> Second, what about the notion of trying for localtime
>> (before defaulting to GMT) if the TZ environment variable
>> contains something nonsensical?  I eventually decided
>> against trying for local time; it makes for (very
>> marginally) simpler code, and I thought that (for US
>> users at least) getting dates reported in GMT would be
>> likelier to serve notice that something was wrong with
>> the TZ variable.

> I agree 100%.

The reason I put that code in was because I actually had the code
running on a machine that I couldn't put the /etc/zoneinfo directory
on.  And, for a couple of days, I got a first hand look at what happens
when things are 8 hours off.  With the current code, it would
require a major kernel problem to be more than an hour off.  Isn't
that worth having?

--keith



More information about the tz mailing list