delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/04/16/14:16:11

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <973C11FE0E3ED41183B200508BC7774C0C95EB84@csexchange.crystal.cirrus.com>
From: "Yang, Huaichen" <huaichen DOT yang AT cirrus DOT com>
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: Is it a problem in function localtime(...)?
Date: Wed, 16 Apr 2003 13:15:42 -0500
MIME-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019