Ignore:
Timestamp:
Jul 18, 2015, 5:06:52 PM (6 years ago)
Author:
katerina
Message:

Enhancements and fixes for tickets #374, #375, #376, #377, #378, and #379.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_log_parse_generic.c

    r362 r481  
    4646static void default_time (struct sh_logrecord * record)
    4747{
    48   struct tm ts;
     48  struct tm   ts;
     49  struct tm * ts_ptr;
    4950  char   tmp[80];
    5051  size_t len;
     
    5354 
    5455#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R)
    55   localtime_r (&(record->timestamp), &ts);
     56  ts_ptr = localtime_r (&(record->timestamp), &ts);
    5657#else
    57   memcpy(&ts, localtime(&(record->timestamp)), sizeof(struct tm));
     58  ts_ptr = localtime(&(record->timestamp));
     59  if (ts_ptr)
     60    memcpy(&ts, ts_ptr, sizeof(struct tm));
    5861#endif
    59   len = strftime(tmp, sizeof(tmp), _("%Y-%m-%dT%H:%M:%S"), &ts);
    60 
     62  if (ts_ptr)
     63    len = strftime(tmp, sizeof(tmp), _("%Y-%m-%dT%H:%M:%S"), &ts);
     64  else
     65    {
     66      sl_strlcpy(tmp, _("1970-01-01T00:00:00"), sizeof(tmp));
     67      len = strlen(tmp);
     68    }
    6169  record->timestr   = sh_string_new_from_lchar(tmp, len);
    6270
Note: See TracChangeset for help on using the changeset viewer.