+1999-07-01 Cristian Gafton <gafton@redhat.com>
+
+ * time/strptime.c (strptime): Initialize the tm struct first to avoid
+ returning bogus results on incomplete data.
+ (strptime_internal): day_of_the_week() requres bith tm_mon and
+ tm_mday to be initializaed.
+ Computer them first if they are not given.
+ (strptime_internal): (have_mon, have_mday): New variables.
+
1999-07-01 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* inet/rcmd.c (__icheckhost): Fix typo in last patch.
int century, want_century;
int have_wday, want_xday;
int have_yday;
-
+ int have_mon, have_mday;
+
rp = buf;
fmt = format;
have_I = is_pm = 0;
century = -1;
want_century = 0;
- have_wday = want_xday = have_yday = 0;
+ have_wday = want_xday = have_yday = have_mon = have_mday = 0;
while (*fmt != '\0')
{
/* Match day of month. */
get_number (1, 31);
tm->tm_mday = val;
+ have_mday = 1;
want_xday = 1;
break;
case 'F':
/* Match number of month. */
get_number (1, 12);
tm->tm_mon = val - 1;
+ have_mon = 1;
want_xday = 1;
break;
case 'M':
/* Match day of month using alternate numeric symbols. */
get_alt_number (1, 31);
tm->tm_mday = val;
+ have_mday = 1;
want_xday = 1;
break;
case 'H':
/* Match month using alternate numeric symbols. */
get_alt_number (1, 12);
tm->tm_mon = val - 1;
+ have_mon = 1;
want_xday = 1;
break;
case 'M':
if (want_century && century != -1)
tm->tm_year = tm->tm_year % 100 + (century - 19) * 100;
- if (want_xday && !have_wday)
- day_of_the_week (tm);
+ if (want_xday && !have_wday) {
+ if ( !(have_mon && have_mday) && have_yday) {
+ /* we don't have tm_mon and/or tm_mday, compute them */
+ int t_mon = 0;
+ while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday)
+ t_mon++;
+ if (!have_mon)
+ tm->tm_mon = t_mon - 1;
+ if (!have_mday)
+ tm->tm_mday = tm->tm_yday - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1;
+ }
+ day_of_the_week (tm);
+ }
if (want_xday && !have_yday)
day_of_the_year (tm);