Is it a problem in function localtime(...)?

Yang, Huaichen huaichen.yang@cirrus.com
Wed Apr 16 22:42:00 GMT 2003


The localtime(...) is running OK in cygwin. However, if I run the
following program out of cygwin (didn't start cygwin): When I
commented the line "loctime = localtime (&curtime)", there is no
problem. All environment variables can be shown up correctly; If
I uncommented this line, the first two environment variables were
replaced with binary characters, that crached down the program.
The problem seems that if some Cygwin environment variable
doesn't exist, the localtime() will destroy the environment
variable list, instead of returning a NULL.

#include <time.h>
#include <stdio.h>

int main (int argc, char *argv[], char *envp[])
{
  time_t curtime;
  struct tm *loctime;
  int i;

  /* Get the current time. */
  curtime = time (NULL);

  /* Convert it to local time representation. */
  loctime = localtime (&curtime);

  for (i = 0; envp[i] != 0; ++i)
  {
      printf("-->env[%d]=\"%s\"\n", i, envp[i]);
  }
  return 0;
}

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list