[Gnucash-changes] r14079 - gnucash/trunk - Convert `localtime` to
`localtime_r`, after seeing localtime fail (strange as it is...).
Joshua Sled
jsled at cvs.gnucash.org
Mon May 15 17:03:23 EDT 2006
Author: jsled
Date: 2006-05-15 17:03:22 -0400 (Mon, 15 May 2006)
New Revision: 14079
Trac: http://svn.gnucash.org/trac/changeset/14079
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/lib/libqof/qof/gnc-date.c
Log:
Convert `localtime` to `localtime_r`, after seeing localtime fail (strange as it is...).
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-05-15 14:51:52 UTC (rev 14078)
+++ gnucash/trunk/ChangeLog 2006-05-15 21:03:22 UTC (rev 14079)
@@ -1,3 +1,10 @@
+2006-05-15 Joshua Sled <jsled at asynchronous.org>
+
+ * lib/libqof/qof/gnc-date.c (timespecCanonicalDayTime)
+ (qof_print_date_buff, dateSeparator, gnc_timespec_last_mday)
+ (gnc_timespec2dmy): convert `localtime` to `localtime_r`, after
+ seeing localtime fail (strange as it is...).
+
2006-05-15 Christian Stimming <stimming at tuhh.de>
* doc/README.german: Updated German README which was horribly
Modified: gnucash/trunk/lib/libqof/qof/gnc-date.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/gnc-date.c 2006-05-15 14:51:52 UTC (rev 14078)
+++ gnucash/trunk/lib/libqof/qof/gnc-date.c 2006-05-15 21:03:22 UTC (rev 14079)
@@ -248,11 +248,10 @@
Timespec
timespecCanonicalDayTime(Timespec t)
{
- struct tm tm, *result;
+ struct tm tm;
Timespec retval;
time_t t_secs = t.tv_sec + (t.tv_nsec / NANOS_PER_SECOND);
- result = localtime(&t_secs);
- tm = *result;
+ localtime_r(&t_secs, &tm);
gnc_tm_set_day_middle(&tm);
retval.tv_sec = mktime(&tm);
retval.tv_nsec = 0;
@@ -496,16 +495,16 @@
size_t
qof_print_date_buff (char * buff, size_t len, time_t t)
{
- struct tm *theTime;
+ struct tm theTime;
if (!buff) return 0 ;
- theTime = localtime (&t);
+ localtime_r(&t, &theTime);
return qof_print_date_dmy_buff (buff, len,
- theTime->tm_mday,
- theTime->tm_mon + 1,
- theTime->tm_year + 1900);
+ theTime.tm_mday,
+ theTime.tm_mon + 1,
+ theTime.tm_year + 1900);
}
size_t
@@ -939,13 +938,13 @@
else
{ /* Make a guess */
unsigned char string[256];
- struct tm *tm;
+ struct tm tm;
time_t secs;
unsigned char *s;
secs = time(NULL);
- tm = localtime(&secs);
- strftime(string, sizeof(string), GNC_D_FMT, tm);
+ localtime_r(&secs, &tm);
+ strftime(string, sizeof(string), GNC_D_FMT, &tm);
for (s = string; s != '\0'; s++)
if (!isdigit(*s))
@@ -1191,22 +1190,22 @@
int
gnc_timespec_last_mday (Timespec t)
{
- struct tm *result;
+ struct tm result;
time_t t_secs = t.tv_sec + (t.tv_nsec / NANOS_PER_SECOND);
- result = localtime(&t_secs);
- return date_get_last_mday (result);
+ localtime_r(&t_secs, &result);
+ return date_get_last_mday (&result);
}
void
gnc_timespec2dmy (Timespec t, int *day, int *month, int *year)
{
- struct tm *result;
+ struct tm result;
time_t t_secs = t.tv_sec + (t.tv_nsec / NANOS_PER_SECOND);
- result = localtime(&t_secs);
+ localtime_r(&t_secs, &result);
- if (day) *day = result->tm_mday;
- if (month) *month = result->tm_mon+1;
- if (year) *year = result->tm_year+1900;
+ if (day) *day = result.tm_mday;
+ if (month) *month = result.tm_mon+1;
+ if (year) *year = result.tm_year+1900;
}
/********************************************************************\
More information about the gnucash-changes
mailing list