More time setting/getting patches - the last of the patches from N. Boullis.

Make testiso9660 more stringent now that bugs have been removed.
This commit is contained in:
rocky
2008-06-03 08:40:14 +00:00
parent a8e617dc7d
commit 71b5f6e14a
3 changed files with 30 additions and 37 deletions

12
NEWS
View File

@@ -1,8 +1,11 @@
$Id: NEWS,v 1.122 2008/04/24 07:28:00 rocky Exp $ $Id: NEWS,v 1.123 2008/06/03 08:40:14 rocky Exp $
version 0.81cvs version 0.81cvs
- license of manual now GFDL 1.2 or later, with no invariant sections. - license of manual now GFDL 1.2 or later, with no invariant sections.
Source is GPL 3.
Thanks to Karl Berry.
- Nero image handling more complete. - Nero image handling more complete.
CD-Text processing. CD-Text processing.
@@ -11,11 +14,16 @@ version 0.81cvs
- ISRC query for image files. - ISRC query for image files.
Thanks to Robert William Fuller on the above two items
- Allow reading pregap of a track via get_track_pregap_lsn(). Add - Allow reading pregap of a track via get_track_pregap_lsn(). Add
Section on "CD-DA pregap" in libcdio manual Section on "CD-DA pregap" in libcdio manual
- Allow cross-compiling to mingw32. Patch from Peter Hartley. - Allow cross-compiling to mingw32. Patch from Peter Hartley.
- Make iso9660 time setting/getting routines (iso9660_{g,s}et_{d,l}time)
reentrant and remove bugs in that code. Courtesy Nicolas Boullis.
version 0.80 version 0.80
2008-03-15 2008-03-15
@@ -419,4 +427,4 @@ version 0.1
Routines split off from VCDImager. Routines split off from VCDImager.
$Id: NEWS,v 1.122 2008/04/24 07:28:00 rocky Exp $ $Id: NEWS,v 1.123 2008/06/03 08:40:14 rocky Exp $

View File

@@ -1,5 +1,5 @@
/* /*
$Id: iso9660.c,v 1.39 2008/05/31 12:18:33 rocky Exp $ $Id: iso9660.c,v 1.40 2008/06/03 08:40:15 rocky Exp $
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
Rocky Bernstein <rocky@gnu.org> Rocky Bernstein <rocky@gnu.org>
@@ -77,7 +77,7 @@ timegm(struct tm *tm)
} }
#endif #endif
static const char _rcsid[] = "$Id: iso9660.c,v 1.39 2008/05/31 12:18:33 rocky Exp $"; static const char _rcsid[] = "$Id: iso9660.c,v 1.40 2008/06/03 08:40:15 rocky Exp $";
/* Variables to hold debugger-helping enumerations */ /* Variables to hold debugger-helping enumerations */
enum iso_enum1_s iso_enums1; enum iso_enum1_s iso_enums1;
@@ -229,33 +229,26 @@ iso9660_get_ltime (const iso9660_ltime_t *p_ldate,
set_ltime_field(tm_min, lt_minute, 0); set_ltime_field(tm_min, lt_minute, 0);
set_ltime_field(tm_sec, lt_second, 0); set_ltime_field(tm_sec, lt_second, 0);
p_tm->tm_isdst= -1; /* information not available */ p_tm->tm_isdst= -1; /* information not available */
#ifndef HAVE_TM_GMTOFF
p_tm->tm_sec += p_ldate->lt_gmtoff * (15 * 60); p_tm->tm_sec += p_ldate->lt_gmtoff * (15 * 60);
#endif
/* Recompute tm_wday and tm_yday via mktime. mktime will also renormalize /* Recompute tm_wday and tm_yday via mktime. mktime will also renormalize
date values to account for the timezone offset. */ date values to account for the timezone offset. */
{ {
time_t t; time_t t;
struct tm temp_tm; struct tm temp_tm;
char *old_tzname=getenv("TZ");
char psz_gmt_tzset[]="TZ=GMT";
/* Put old_tzname at the beginning of the environment string,
so it can be restored as is with putenv. */
if (old_tzname)
old_tzname -= sizeof("TZ=")-1;
putenv(psz_gmt_tzset);
tzset();
t = mktime(p_tm); t = mktime(p_tm);
gmtime_r(&t, &temp_tm);
if (old_tzname)
putenv(old_tzname);
else
unsetenv("TZ");
p_tm->tm_wday = temp_tm.tm_wday; localtime_r(&t, &temp_tm);
p_tm->tm_yday = temp_tm.tm_yday;
memcpy(p_tm, &temp_tm, sizeof(struct tm));
} }
p_tm->tm_isdst= -1; /* information not available */
#ifdef HAVE_TM_GMTOFF
p_tm->tm_gmtoff = -p_ldate->lt_gmtoff * (15 * 60);
#endif
return true; return true;
} }

View File

@@ -1,5 +1,5 @@
/* /*
$Id: testiso9660.c,v 1.22 2008/05/28 01:48:38 rocky Exp $ $Id: testiso9660.c,v 1.23 2008/06/03 08:40:15 rocky Exp $
Copyright (C) 2003, 2006, 2007, 2008 Rocky Bernstein <rocky@gnu.org> Copyright (C) 2003, 2006, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
@@ -62,18 +62,15 @@ time_compare(struct tm *p_tm1, struct tm *p_tm2)
okay=false; okay=false;
} }
if (p_tm1->tm_min != p_tm2->tm_min) { if (p_tm1->tm_min != p_tm2->tm_min) {
printf("minute aren't equal. get: %d, set %d\n", printf("minutes aren't equal. get: %d, set %d\n",
p_tm1->tm_min, p_tm2->tm_min); p_tm1->tm_min, p_tm2->tm_min);
okay=false; okay=false;
} }
#if FIXED
/* Differences in daylight savings time may make these different.*/
if (p_tm1->tm_hour != p_tm2->tm_hour) { if (p_tm1->tm_hour != p_tm2->tm_hour) {
printf("hours aren't equal. get: %d, set %d\n", printf("hours aren't equal. get: %d, set %d\n",
p_tm1->tm_hour, p_tm2->tm_hour); p_tm1->tm_hour, p_tm2->tm_hour);
okay=false; okay=false;
} }
#endif
if (p_tm1->tm_sec != p_tm2->tm_sec) { if (p_tm1->tm_sec != p_tm2->tm_sec) {
printf("seconds aren't equal. get: %d, set %d\n", printf("seconds aren't equal. get: %d, set %d\n",
p_tm1->tm_sec, p_tm2->tm_sec); p_tm1->tm_sec, p_tm2->tm_sec);
@@ -95,6 +92,7 @@ time_compare(struct tm *p_tm1, struct tm *p_tm2)
p_tm1->tm_isdst, p_tm2->tm_isdst); p_tm1->tm_isdst, p_tm2->tm_isdst);
okay=false; okay=false;
} }
#endif
#ifdef HAVE_TM_GMTOFF #ifdef HAVE_TM_GMTOFF
if (p_tm1->tm_gmtoff != p_tm2->tm_gmtoff) { if (p_tm1->tm_gmtoff != p_tm2->tm_gmtoff) {
printf("GMT offsets aren't equal. get: %ld, set %ld\n", printf("GMT offsets aren't equal. get: %ld, set %ld\n",
@@ -102,6 +100,7 @@ time_compare(struct tm *p_tm1, struct tm *p_tm2)
okay=false; okay=false;
} }
if (p_tm1 != p_tm2 && p_tm1 && p_tm2) { if (p_tm1 != p_tm2 && p_tm1 && p_tm2) {
#ifdef FIXED
if (strcmp(p_tm1->tm_zone, p_tm2->tm_zone) != 0) { if (strcmp(p_tm1->tm_zone, p_tm2->tm_zone) != 0) {
printf("Time Zone values. get: %s, set %s\n", printf("Time Zone values. get: %s, set %s\n",
p_tm1->tm_zone, p_tm2->tm_zone); p_tm1->tm_zone, p_tm2->tm_zone);
@@ -109,8 +108,8 @@ time_compare(struct tm *p_tm1, struct tm *p_tm2)
Let's not call this a failure if everything else was okay. Let's not call this a failure if everything else was okay.
*/ */
} }
}
#endif #endif
}
#endif #endif
return okay; return okay;
} }
@@ -262,9 +261,7 @@ main (int argc, const char *argv[])
} }
{ {
time_t t1, t2;
p_tm = localtime(&now); p_tm = localtime(&now);
t1 = mktime(p_tm);
iso9660_set_ltime(p_tm, &ltime); iso9660_set_ltime(p_tm, &ltime);
if (!iso9660_get_ltime(&ltime, &tm)) { if (!iso9660_get_ltime(&ltime, &tm)) {
@@ -272,21 +269,16 @@ main (int argc, const char *argv[])
return 44; return 44;
} }
#ifdef FIXED if ( ! time_compare(p_tm, &tm) ) {
t2 = mktime(&tm);
if ( t1 != t2 && ! time_compare(p_tm, &tm) ) {
printf("local time retrieved with iso9660_get_ltime() not\n"); printf("local time retrieved with iso9660_get_ltime() not\n");
printf("same as that set with iso9660_set_ltime().\n"); printf("same as that set with iso9660_set_ltime().\n");
return 45; return 45;
} }
#endif
p_tm = gmtime(&now); p_tm = gmtime(&now);
t1 = mktime(p_tm);
iso9660_set_ltime(p_tm, &ltime); iso9660_set_ltime(p_tm, &ltime);
iso9660_get_ltime(&ltime, &tm); iso9660_get_ltime(&ltime, &tm);
t2 = mktime(&tm); if ( ! time_compare(p_tm, &tm) ) {
if ( t1 != t2 && ! time_compare(p_tm, &tm) ) {
printf("GMT time retrieved with iso9660_get_ltime() not\n"); printf("GMT time retrieved with iso9660_get_ltime() not\n");
printf("same as that set with iso9660_set_ltime().\n"); printf("same as that set with iso9660_set_ltime().\n");
return 46; return 46;