Revision 1857
| trunk/nntpgrab_core/strptime.c (revision 1857) | ||
|---|---|---|
| 107 | 107 | 
                  __label__ do_normal; \  | 
              
| 108 | 108 | 
                  if (*decided != raw) \  | 
              
| 109 | 109 | 
                        {                                                                              \
                 | 
              
| 110 | 
                  const char *alts = _NL_CURRENT (LC_TIME, ALT_DIGITS); \  | 
              |
| 111 | 
                  int __n = n; \  | 
              |
| 112 | 
                  int any = 0; \  | 
              |
| 113 | 
                  while (*rp == ' ') \  | 
              |
| 114 | 
                  ++rp; \  | 
              |
| 115 | 
                  val = 0; \  | 
              |
| 116 | 
                         do {                                                                  \
                 | 
              |
| 117 | 
                  val *= 10; \  | 
              |
| 118 | 
                  while (*alts != '\0') \  | 
              |
| 119 | 
                             {                                                                 \
                 | 
              |
| 120 | 
                  size_t len = strlen (alts); \  | 
              |
| 121 | 
                  if (strncasecmp (alts, rp, len) == 0) \  | 
              |
| 122 | 
                  break; \  | 
              |
| 123 | 
                  alts += len + 1; \  | 
              |
| 124 | 
                  ++val; \  | 
              |
| 125 | 
                  } \  | 
              |
| 126 | 
                  if (*alts == '\0') \  | 
              |
| 127 | 
                             {                                                                 \
                 | 
              |
| 128 | 
                  if (*decided == not && ! any) \  | 
              |
| 129 | 
                  goto do_normal; \  | 
              |
| 130 | 
                  /* If we haven't read anything it's an error. */ \  | 
              |
| 131 | 
                  if (! any) \  | 
              |
| 132 | 
                  return NULL; \  | 
              |
| 133 | 
                  /* Correct the premature multiplication. */ \  | 
              |
| 134 | 
                  val /= 10; \  | 
              |
| 135 | 
                  break; \  | 
              |
| 136 | 
                  } \  | 
              |
| 137 | 
                  else \  | 
              |
| 138 | 
                  *decided = loc; \  | 
              |
| 139 | 
                  } while (--__n > 0 && val * 10 <= to); \  | 
              |
| 140 | 
                  if (val < from || val > to) \  | 
              |
| 141 | 
                  return NULL; \  | 
              |
| 110 | 
                  const char *alts = _NL_CURRENT (LC_TIME, ALT_DIGITS); \  | 
              |
| 111 | 
                  int __n = n; \  | 
              |
| 112 | 
                  int any = 0; \  | 
              |
| 113 | 
                  while (*rp == ' ') \  | 
              |
| 114 | 
                  ++rp; \  | 
              |
| 115 | 
                  val = 0; \  | 
              |
| 116 | 
                          do {                                                                 \
                 | 
              |
| 117 | 
                  val *= 10; \  | 
              |
| 118 | 
                  while (*alts != '\0') \  | 
              |
| 119 | 
                              {                                                                \
                 | 
              |
| 120 | 
                  size_t len = strlen (alts); \  | 
              |
| 121 | 
                  if (strncasecmp (alts, rp, len) == 0) \  | 
              |
| 122 | 
                  break; \  | 
              |
| 123 | 
                  alts += len + 1; \  | 
              |
| 124 | 
                  ++val; \  | 
              |
| 125 | 
                  } \  | 
              |
| 126 | 
                  if (*alts == '\0') \  | 
              |
| 127 | 
                              {                                                                \
                 | 
              |
| 128 | 
                  if (*decided == not && ! any) \  | 
              |
| 129 | 
                  goto do_normal; \  | 
              |
| 130 | 
                  /* If we haven't read anything it's an error. */ \  | 
              |
| 131 | 
                  if (! any) \  | 
              |
| 132 | 
                  return NULL; \  | 
              |
| 133 | 
                  /* Correct the premature multiplication. */ \  | 
              |
| 134 | 
                  val /= 10; \  | 
              |
| 135 | 
                  break; \  | 
              |
| 136 | 
                  } \  | 
              |
| 137 | 
                  else \  | 
              |
| 138 | 
                  *decided = loc; \  | 
              |
| 139 | 
                  } while (--__n > 0 && val * 10 <= to); \  | 
              |
| 140 | 
                  if (val < from || val > to) \  | 
              |
| 141 | 
                  return NULL; \  | 
              |
| 142 | 142 | 
                  } \  | 
              
| 143 | 143 | 
                  else \  | 
              
| 144 | 144 | 
                        {                                                                              \
                 | 
              
| ... | ... | |
| 232 | 232 | 
                  the weekday. */  | 
              
| 233 | 233 | 
                  int corr_year = 1900 + tm->tm_year - (tm->tm_mon < 2);  | 
              
| 234 | 234 | 
                  int wday = (-473  | 
              
| 235 | 
                  + (365 * (tm->tm_year - 70))  | 
              |
| 236 | 
                  + (corr_year / 4)  | 
              |
| 237 | 
                  - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0)  | 
              |
| 238 | 
                  + (((corr_year / 4) / 25) / 4)  | 
              |
| 239 | 
                  + __mon_yday[0][tm->tm_mon]  | 
              |
| 240 | 
                  + tm->tm_mday - 1);  | 
              |
| 235 | 
                  + (365 * (tm->tm_year - 70))  | 
              |
| 236 | 
                  + (corr_year / 4)  | 
              |
| 237 | 
                  - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0)  | 
              |
| 238 | 
                  + (((corr_year / 4) / 25) / 4)  | 
              |
| 239 | 
                  + __mon_yday[0][tm->tm_mon]  | 
              |
| 240 | 
                  + tm->tm_mday - 1);  | 
              |
| 241 | 241 | 
                  tm->tm_wday = ((wday % 7) + 7) % 7;  | 
              
| 242 | 242 | 
                  }  | 
              
| 243 | 243 | 
                   | 
              
| ... | ... | |
| 246 | 246 | 
                  day_of_the_year (struct tm *tm)  | 
              
| 247 | 247 | 
                  {
                 | 
              
| 248 | 248 | 
                  tm->tm_yday = (__mon_yday[__isleap (1900 + tm->tm_year)][tm->tm_mon]  | 
              
| 249 | 
                  + (tm->tm_mday - 1));  | 
              |
| 249 | 
                  + (tm->tm_mday - 1));  | 
              |
| 250 | 250 | 
                  }  | 
              
| 251 | 251 | 
                   | 
              
| 252 | 252 | 
                  static char *  | 
              
| ... | ... | |
| 254 | 254 | 
                  internal_function  | 
              
| 255 | 255 | 
                  #endif  | 
              
| 256 | 256 | 
                  strptime_internal __P ((const char *rp, const char *fmt, struct tm *tm,  | 
              
| 257 | 
                  enum locale_status *decided, int era_cnt));  | 
              |
| 257 | 
                  enum locale_status *decided, int era_cnt));  | 
              |
| 258 | 258 | 
                   | 
              
| 259 | 259 | 
                  static char *  | 
              
| 260 | 260 | 
                  #ifdef _LIBC  | 
              
| ... | ... | |
| 267 | 267 | 
                  enum locale_status *decided;  | 
              
| 268 | 268 | 
                  int era_cnt;  | 
              
| 269 | 269 | 
                  {
                 | 
              
| 270 | 
                  const char *rp_backup;  | 
              |
| 271 | 270 | 
                  int cnt;  | 
              
| 272 | 271 | 
                  size_t val;  | 
              
| 273 | 272 | 
                  int have_I, is_pm;  | 
              
| ... | ... | |
| 277 | 276 | 
                  int have_yday;  | 
              
| 278 | 277 | 
                  int have_mon, have_mday;  | 
              
| 279 | 278 | 
                  #ifdef _NL_CURRENT  | 
              
| 279 | 
                  const char *rp_backup;  | 
              |
| 280 | 280 | 
                  size_t num_eras;  | 
              
| 281 | 
                  struct era_entry *era;  | 
              |
| 281 | 282 | 
                  #endif  | 
              
| 282 | 
                  struct era_entry *era;  | 
              |
| 283 | 283 | 
                   | 
              
| 284 | 284 | 
                  have_I = is_pm = 0;  | 
              
| 285 | 285 | 
                  century = -1;  | 
              
| ... | ... | |
| 292 | 292 | 
                  while (*fmt != '\0')  | 
              
| 293 | 293 | 
                      {
                 | 
              
| 294 | 294 | 
                  /* A white space in the format string matches 0 more or white  | 
              
| 295 | 
                  space in the input string. */  | 
              |
| 295 | 
                  space in the input string. */  | 
              |
| 296 | 296 | 
                  if (isspace (*fmt))  | 
              
| 297 | 
                         {
                 | 
              |
| 298 | 
                  while (isspace (*rp))  | 
              |
| 299 | 
                  ++rp;  | 
              |
| 300 | 
                  ++fmt;  | 
              |
| 301 | 
                  continue;  | 
              |
| 302 | 
                  }  | 
              |
| 297 | 
                          {
                 | 
              |
| 298 | 
                  while (isspace (*rp))  | 
              |
| 299 | 
                  ++rp;  | 
              |
| 300 | 
                  ++fmt;  | 
              |
| 301 | 
                  continue;  | 
              |
| 302 | 
                  }  | 
              |
| 303 | 303 | 
                   | 
              
| 304 | 304 | 
                  /* Any character but `%' must be matched by the same character  | 
              
| 305 | 
                  in the iput string. */  | 
              |
| 305 | 
                  in the iput string. */  | 
              |
| 306 | 306 | 
                  if (*fmt != '%')  | 
              
| 307 | 
                         {
                 | 
              |
| 308 | 
                  match_char (*fmt++, *rp++);  | 
              |
| 309 | 
                  continue;  | 
              |
| 310 | 
                  }  | 
              |
| 307 | 
                          {
                 | 
              |
| 308 | 
                  match_char (*fmt++, *rp++);  | 
              |
| 309 | 
                  continue;  | 
              |
| 310 | 
                  }  | 
              |
| 311 | 311 | 
                   | 
              
| 312 | 312 | 
                  ++fmt;  | 
              
| 313 | 313 | 
                  #ifndef _NL_CURRENT  | 
              
| ... | ... | |
| 315 | 315 | 
                  start_over:  | 
              
| 316 | 316 | 
                  #endif  | 
              
| 317 | 317 | 
                   | 
              
| 318 | 
                  #ifdef _NL_CURRENT  | 
              |
| 318 | 319 | 
                  /* Make back up of current processing pointer. */  | 
              
| 319 | 320 | 
                  rp_backup = rp;  | 
              
| 321 | 
                  #endif  | 
              |
| 320 | 322 | 
                   | 
              
| 321 | 323 | 
                  switch (*fmt++)  | 
              
| 322 | 
                         {
                 | 
              |
| 323 | 
                  case '%':  | 
              |
| 324 | 
                  /* Match the `%' character itself. */  | 
              |
| 325 | 
                           match_char ('%', *rp++);
                 | 
              |
| 326 | 
                  break;  | 
              |
| 327 | 
                  case 'a':  | 
              |
| 328 | 
                  case 'A':  | 
              |
| 329 | 
                  /* Match day of week. */  | 
              |
| 330 | 
                  for (cnt = 0; cnt < 7; ++cnt)  | 
              |
| 331 | 
                             {
                 | 
              |
| 324 | 
                          {
                 | 
              |
| 325 | 
                  case '%':  | 
              |
| 326 | 
                  /* Match the `%' character itself. */  | 
              |
| 327 | 
                            match_char ('%', *rp++);
                 | 
              |
| 328 | 
                  break;  | 
              |
| 329 | 
                  case 'a':  | 
              |
| 330 | 
                  case 'A':  | 
              |
| 331 | 
                  /* Match day of week. */  | 
              |
| 332 | 
                  for (cnt = 0; cnt < 7; ++cnt)  | 
              |
| 333 | 
                              {
                 | 
              |
| 332 | 334 | 
                  #ifdef _NL_CURRENT  | 
              
| 333 | 
                  if (*decided !=raw)  | 
              |
| 334 | 
                                 {
                 | 
              |
| 335 | 
                  if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp))  | 
              |
| 336 | 
                                     {
                 | 
              |
| 337 | 
                  if (*decided == not  | 
              |
| 338 | 
                  && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt),  | 
              |
| 339 | 
                  weekday_name[cnt]))  | 
              |
| 340 | 
                  *decided = loc;  | 
              |
| 341 | 
                  break;  | 
              |
| 342 | 
                  }  | 
              |
| 343 | 
                  if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp))  | 
              |
| 344 | 
                                     {
                 | 
              |
| 345 | 
                  if (*decided == not  | 
              |
| 346 | 
                  && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt),  | 
              |
| 347 | 
                  ab_weekday_name[cnt]))  | 
              |
| 348 | 
                  *decided = loc;  | 
              |
| 349 | 
                  break;  | 
              |
| 350 | 
                  }  | 
              |
| 351 | 
                  }  | 
              |
| 335 | 
                  if (*decided !=raw)  | 
              |
| 336 | 
                                  {
                 | 
              |
| 337 | 
                  if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp))  | 
              |
| 338 | 
                                      {
                 | 
              |
| 339 | 
                  if (*decided == not  | 
              |
| 340 | 
                  && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt),  | 
              |
| 341 | 
                  weekday_name[cnt]))  | 
              |
| 342 | 
                  *decided = loc;  | 
              |
| 343 | 
                  break;  | 
              |
| 344 | 
                  }  | 
              |
| 345 | 
                  if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp))  | 
              |
| 346 | 
                                      {
                 | 
              |
| 347 | 
                  if (*decided == not  | 
              |
| 348 | 
                  && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt),  | 
              |
| 349 | 
                  ab_weekday_name[cnt]))  | 
              |
| 350 | 
                  *decided = loc;  | 
              |
| 351 | 
                  break;  | 
              |
| 352 | 
                  }  | 
              |
| 353 | 
                  }  | 
              |
| 352 | 354 | 
                  #endif  | 
              
| 353 | 
                  if (*decided != loc  | 
              |
| 354 | 
                  && (match_string (weekday_name[cnt], rp)  | 
              |
| 355 | 
                  || match_string (ab_weekday_name[cnt], rp)))  | 
              |
| 356 | 
                                 {
                 | 
              |
| 357 | 
                  *decided = raw;  | 
              |
| 358 | 
                  break;  | 
              |
| 359 | 
                  }  | 
              |
| 360 | 
                  }  | 
              |
| 361 | 
                  if (cnt == 7)  | 
              |
| 362 | 
                  /* Does not match a weekday name. */  | 
              |
| 363 | 
                  return NULL;  | 
              |
| 364 | 
                  tm->tm_wday = cnt;  | 
              |
| 365 | 
                  have_wday = 1;  | 
              |
| 366 | 
                  break;  | 
              |
| 367 | 
                  case 'b':  | 
              |
| 368 | 
                  case 'B':  | 
              |
| 369 | 
                  case 'h':  | 
              |
| 370 | 
                  /* Match month name. */  | 
              |
| 371 | 
                  for (cnt = 0; cnt < 12; ++cnt)  | 
              |
| 372 | 
                             {
                 | 
              |
| 355 | 
                  if (*decided != loc  | 
              |
| 356 | 
                  && (match_string (weekday_name[cnt], rp)  | 
              |
| 357 | 
                  || match_string (ab_weekday_name[cnt], rp)))  | 
              |
| 358 | 
                                  {
                 | 
              |
| 359 | 
                  *decided = raw;  | 
              |
| 360 | 
                  break;  | 
              |
| 361 | 
                  }  | 
              |
| 362 | 
                  }  | 
              |
| 363 | 
                  if (cnt == 7)  | 
              |
| 364 | 
                  /* Does not match a weekday name. */  | 
              |
| 365 | 
                  return NULL;  | 
              |
| 366 | 
                  tm->tm_wday = cnt;  | 
              |
| 367 | 
                  have_wday = 1;  | 
              |
| 368 | 
                  break;  | 
              |
| 369 | 
                  case 'b':  | 
              |
| 370 | 
                  case 'B':  | 
              |
| 371 | 
                  case 'h':  | 
              |
| 372 | 
                  /* Match month name. */  | 
              |
| 373 | 
                  for (cnt = 0; cnt < 12; ++cnt)  | 
              |
| 374 | 
                              {
                 | 
              |
| 373 | 375 | 
                  #ifdef _NL_CURRENT  | 
              
| 374 | 
                  if (*decided !=raw)  | 
              |
| 375 | 
                                 {
                 | 
              |
| 376 | 
                  if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp))  | 
              |
| 377 | 
                                     {
                 | 
              |
| 378 | 
                  if (*decided == not  | 
              |
| 379 | 
                  && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt),  | 
              |
| 380 | 
                  month_name[cnt]))  | 
              |
| 381 | 
                  *decided = loc;  | 
              |
| 382 | 
                  break;  | 
              |
| 383 | 
                  }  | 
              |
| 384 | 
                  if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp))  | 
              |
| 385 | 
                                     {
                 | 
              |
| 386 | 
                  if (*decided == not  | 
              |
| 387 | 
                  && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt),  | 
              |
| 388 | 
                  ab_month_name[cnt]))  | 
              |
| 389 | 
                  *decided = loc;  | 
              |
| 390 | 
                  break;  | 
              |
| 391 | 
                  }  | 
              |
| 392 | 
                  }  | 
              |
| 376 | 
                  if (*decided !=raw)  | 
              |
| 377 | 
                                  {
                 | 
              |
| 378 | 
                  if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp))  | 
              |
| 379 | 
                                      {
                 | 
              |
| 380 | 
                  if (*decided == not  | 
              |
| 381 | 
                  && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt),  | 
              |
| 382 | 
                  month_name[cnt]))  | 
              |
| 383 | 
                  *decided = loc;  | 
              |
| 384 | 
                  break;  | 
              |
| 385 | 
                  }  | 
              |
| 386 | 
                  if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp))  | 
              |
| 387 | 
                                      {
                 | 
              |
| 388 | 
                  if (*decided == not  | 
              |
| 389 | 
                  && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt),  | 
              |
| 390 | 
                  ab_month_name[cnt]))  | 
              |
| 391 | 
                  *decided = loc;  | 
              |
| 392 | 
                  break;  | 
              |
| 393 | 
                  }  | 
              |
| 394 | 
                  }  | 
              |
| 393 | 395 | 
                  #endif  | 
              
| 394 | 
                  if (match_string (month_name[cnt], rp)  | 
              |
| 395 | 
                  || match_string (ab_month_name[cnt], rp))  | 
              |
| 396 | 
                                 {
                 | 
              |
| 397 | 
                  *decided = raw;  | 
              |
| 398 | 
                  break;  | 
              |
| 399 | 
                  }  | 
              |
| 400 | 
                  }  | 
              |
| 401 | 
                  if (cnt == 12)  | 
              |
| 402 | 
                  /* Does not match a month name. */  | 
              |
| 403 | 
                  return NULL;  | 
              |
| 404 | 
                  tm->tm_mon = cnt;  | 
              |
| 405 | 
                  want_xday = 1;  | 
              |
| 406 | 
                  break;  | 
              |
| 407 | 
                  case 'c':  | 
              |
| 408 | 
                  /* Match locale's date and time format. */  | 
              |
| 396 | 
                  if (match_string (month_name[cnt], rp)  | 
              |
| 397 | 
                  || match_string (ab_month_name[cnt], rp))  | 
              |
| 398 | 
                                  {
                 | 
              |
| 399 | 
                  *decided = raw;  | 
              |
| 400 | 
                  break;  | 
              |
| 401 | 
                  }  | 
              |
| 402 | 
                  }  | 
              |
| 403 | 
                  if (cnt == 12)  | 
              |
| 404 | 
                  /* Does not match a month name. */  | 
              |
| 405 | 
                  return NULL;  | 
              |
| 406 | 
                  tm->tm_mon = cnt;  | 
              |
| 407 | 
                  want_xday = 1;  | 
              |
| 408 | 
                  break;  | 
              |
| 409 | 
                  case 'c':  | 
              |
| 410 | 
                  /* Match locale's date and time format. */  | 
              |
| 409 | 411 | 
                  #ifdef _NL_CURRENT  | 
              
| 410 | 
                  if (*decided != raw)  | 
              |
| 411 | 
                             {
                 | 
              |
| 412 | 
                  if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT)))  | 
              |
| 413 | 
                                 {
                 | 
              |
| 414 | 
                  if (*decided == loc)  | 
              |
| 415 | 
                  return NULL;  | 
              |
| 416 | 
                  else  | 
              |
| 417 | 
                  rp = rp_backup;  | 
              |
| 418 | 
                  }  | 
              |
| 419 | 
                  else  | 
              |
| 420 | 
                                 {
                 | 
              |
| 421 | 
                  if (*decided == not &&  | 
              |
| 422 | 
                  strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT))  | 
              |
| 423 | 
                  *decided = loc;  | 
              |
| 424 | 
                  want_xday = 1;  | 
              |
| 425 | 
                  break;  | 
              |
| 426 | 
                  }  | 
              |
| 427 | 
                  *decided = raw;  | 
              |
| 428 | 
                  }  | 
              |
| 412 | 
                  if (*decided != raw)  | 
              |
| 413 | 
                              {
                 | 
              |
| 414 | 
                  if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT)))  | 
              |
| 415 | 
                                  {
                 | 
              |
| 416 | 
                  if (*decided == loc)  | 
              |
| 417 | 
                  return NULL;  | 
              |
| 418 | 
                  else  | 
              |
| 419 | 
                  rp = rp_backup;  | 
              |
| 420 | 
                  }  | 
              |
| 421 | 
                  else  | 
              |
| 422 | 
                                  {
                 | 
              |
| 423 | 
                  if (*decided == not &&  | 
              |
| 424 | 
                  strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT))  | 
              |
| 425 | 
                  *decided = loc;  | 
              |
| 426 | 
                  want_xday = 1;  | 
              |
| 427 | 
                  break;  | 
              |
| 428 | 
                  }  | 
              |
| 429 | 
                  *decided = raw;  | 
              |
| 430 | 
                  }  | 
              |
| 429 | 431 | 
                  #endif  | 
              
| 430 | 
                  if (!recursive (HERE_D_T_FMT))  | 
              |
| 431 | 
                  return NULL;  | 
              |
| 432 | 
                  want_xday = 1;  | 
              |
| 433 | 
                  break;  | 
              |
| 434 | 
                  case 'C':  | 
              |
| 435 | 
                  /* Match century number. */  | 
              |
| 432 | 
                  if (!recursive (HERE_D_T_FMT))  | 
              |
| 433 | 
                  return NULL;  | 
              |
| 434 | 
                  want_xday = 1;  | 
              |
| 435 | 
                  break;  | 
              |
| 436 | 
                  case 'C':  | 
              |
| 437 | 
                  /* Match century number. */  | 
              |
| 436 | 438 | 
                  #ifdef _NL_CURRENT  | 
              
| 437 | 
                  match_century:  | 
              |
| 439 | 
                  match_century:  | 
              |
| 438 | 440 | 
                  #endif  | 
              
| 439 | 
                  get_number (0, 99, 2);  | 
              |
| 440 | 
                  century = val;  | 
              |
| 441 | 
                  want_xday = 1;  | 
              |
| 442 | 
                  break;  | 
              |
| 443 | 
                  case 'd':  | 
              |
| 444 | 
                  case 'e':  | 
              |
| 445 | 
                  /* Match day of month. */  | 
              |
| 446 | 
                  get_number (1, 31, 2);  | 
              |
| 447 | 
                  tm->tm_mday = val;  | 
              |
| 448 | 
                  have_mday = 1;  | 
              |
| 449 | 
                  want_xday = 1;  | 
              |
| 450 | 
                  break;  | 
              |
| 451 | 
                  case 'F':  | 
              |
| 452 | 
                           if (!recursive ("%Y-%m-%d"))
                 | 
              |
| 453 | 
                  return NULL;  | 
              |
| 454 | 
                  want_xday = 1;  | 
              |
| 455 | 
                  break;  | 
              |
| 456 | 
                  case 'x':  | 
              |
| 441 | 
                  get_number (0, 99, 2);  | 
              |
| 442 | 
                  century = val;  | 
              |
| 443 | 
                  want_xday = 1;  | 
              |
| 444 | 
                  break;  | 
              |
| 445 | 
                  case 'd':  | 
              |
| 446 | 
                  case 'e':  | 
              |
| 447 | 
                  /* Match day of month. */  | 
              |
| 448 | 
                  get_number (1, 31, 2);  | 
              |
| 449 | 
                  tm->tm_mday = val;  | 
              |
| 450 | 
                  have_mday = 1;  | 
              |
| 451 | 
                  want_xday = 1;  | 
              |
| 452 | 
                  break;  | 
              |
| 453 | 
                  case 'F':  | 
              |
| 454 | 
                            if (!recursive ("%Y-%m-%d"))
                 | 
              |
| 455 | 
                  return NULL;  | 
              |
| 456 | 
                  want_xday = 1;  | 
              |
| 457 | 
                  break;  | 
              |
| 458 | 
                  case 'x':  | 
              |
| 457 | 459 | 
                  #ifdef _NL_CURRENT  | 
              
| 458 | 
                  if (*decided != raw)  | 
              |
| 459 | 
                             {
                 | 
              |
| 460 | 
                  if (!recursive (_NL_CURRENT (LC_TIME, D_FMT)))  | 
              |
| 461 | 
                                 {
                 | 
              |
| 462 | 
                  if (*decided == loc)  | 
              |
| 463 | 
                  return NULL;  | 
              |
| 464 | 
                  else  | 
              |
| 465 | 
                  rp = rp_backup;  | 
              |
| 466 | 
                  }  | 
              |
| 467 | 
                  else  | 
              |
| 468 | 
                                 {
                 | 
              |
| 469 | 
                  if (*decided == not  | 
              |
| 470 | 
                  && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT))  | 
              |
| 471 | 
                  *decided = loc;  | 
              |
| 472 | 
                  want_xday = 1;  | 
              |
| 473 | 
                  break;  | 
              |
| 474 | 
                  }  | 
              |
| 475 | 
                  *decided = raw;  | 
              |
| 476 | 
                  }  | 
              |
| 460 | 
                  if (*decided != raw)  | 
              |
| 461 | 
                              {
                 | 
              |
| 462 | 
                  if (!recursive (_NL_CURRENT (LC_TIME, D_FMT)))  | 
              |
| 463 | 
                                  {
                 | 
              |
| 464 | 
                  if (*decided == loc)  | 
              |
| 465 | 
                  return NULL;  | 
              |
| 466 | 
                  else  | 
              |
| 467 | 
                  rp = rp_backup;  | 
              |
| 468 | 
                  }  | 
              |
| 469 | 
                  else  | 
              |
| 470 | 
                                  {
                 | 
              |
| 471 | 
                  if (*decided == not  | 
              |
| 472 | 
                  && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT))  | 
              |
| 473 | 
                  *decided = loc;  | 
              |
| 474 | 
                  want_xday = 1;  | 
              |
| 475 | 
                  break;  | 
              |
| 476 | 
                  }  | 
              |
| 477 | 
                  *decided = raw;  | 
              |
| 478 | 
                  }  | 
              |
| 477 | 479 | 
                  #endif  | 
              
| 478 | 
                  /* Fall through. */  | 
              |
| 479 | 
                  case 'D':  | 
              |
| 480 | 
                  /* Match standard day format. */  | 
              |
| 481 | 
                  if (!recursive (HERE_D_FMT))  | 
              |
| 482 | 
                  return NULL;  | 
              |
| 483 | 
                  want_xday = 1;  | 
              |
| 484 | 
                  break;  | 
              |
| 485 | 
                  case 'k':  | 
              |
| 486 | 
                  case 'H':  | 
              |
| 487 | 
                  /* Match hour in 24-hour clock. */  | 
              |
| 488 | 
                  get_number (0, 23, 2);  | 
              |
| 489 | 
                  tm->tm_hour = val;  | 
              |
| 490 | 
                  have_I = 0;  | 
              |
| 491 | 
                  break;  | 
              |
| 492 | 
                  case 'I':  | 
              |
| 493 | 
                  /* Match hour in 12-hour clock. */  | 
              |
| 494 | 
                  get_number (1, 12, 2);  | 
              |
| 495 | 
                  tm->tm_hour = val % 12;  | 
              |
| 496 | 
                  have_I = 1;  | 
              |
| 497 | 
                  break;  | 
              |
| 498 | 
                  case 'j':  | 
              |
| 499 | 
                  /* Match day number of year. */  | 
              |
| 500 | 
                  get_number (1, 366, 3);  | 
              |
| 501 | 
                  tm->tm_yday = val - 1;  | 
              |
| 502 | 
                  have_yday = 1;  | 
              |
| 503 | 
                  break;  | 
              |
| 504 | 
                  case 'm':  | 
              |
| 505 | 
                  /* Match number of month. */  | 
              |
| 506 | 
                  get_number (1, 12, 2);  | 
              |
| 507 | 
                  tm->tm_mon = val - 1;  | 
              |
| 508 | 
                  have_mon = 1;  | 
              |
| 509 | 
                  want_xday = 1;  | 
              |
| 510 | 
                  break;  | 
              |
| 511 | 
                  case 'M':  | 
              |
| 512 | 
                  /* Match minute. */  | 
              |
| 513 | 
                  get_number (0, 59, 2);  | 
              |
| 514 | 
                  tm->tm_min = val;  | 
              |
| 515 | 
                  break;  | 
              |
| 516 | 
                  case 'n':  | 
              |
| 517 | 
                  case 't':  | 
              |
| 518 | 
                  /* Match any white space. */  | 
              |
| 519 | 
                  while (isspace (*rp))  | 
              |
| 520 | 
                  ++rp;  | 
              |
| 521 | 
                  break;  | 
              |
| 522 | 
                  case 'p':  | 
              |
| 523 | 
                  /* Match locale's equivalent of AM/PM. */  | 
              |
| 480 | 
                  /* Fall through. */  | 
              |
| 481 | 
                  case 'D':  | 
              |
| 482 | 
                  /* Match standard day format. */  | 
              |
| 483 | 
                  if (!recursive (HERE_D_FMT))  | 
              |
| 484 | 
                  return NULL;  | 
              |
| 485 | 
                  want_xday = 1;  | 
              |
| 486 | 
                  break;  | 
              |
| 487 | 
                  case 'k':  | 
              |
| 488 | 
                  case 'H':  | 
              |
| 489 | 
                  /* Match hour in 24-hour clock. */  | 
              |
| 490 | 
                  get_number (0, 23, 2);  | 
              |
| 491 | 
                  tm->tm_hour = val;  | 
              |
| 492 | 
                  have_I = 0;  | 
              |
| 493 | 
                  break;  | 
              |
| 494 | 
                  case 'I':  | 
              |
| 495 | 
                  /* Match hour in 12-hour clock. */  | 
              |
| 496 | 
                  get_number (1, 12, 2);  | 
              |
| 497 | 
                  tm->tm_hour = val % 12;  | 
              |
| 498 | 
                  have_I = 1;  | 
              |
| 499 | 
                  break;  | 
              |
| 500 | 
                  case 'j':  | 
              |
| 501 | 
                  /* Match day number of year. */  | 
              |
| 502 | 
                  get_number (1, 366, 3);  | 
              |
| 503 | 
                  tm->tm_yday = val - 1;  | 
              |
| 504 | 
                  have_yday = 1;  | 
              |
| 505 | 
                  break;  | 
              |
| 506 | 
                  case 'm':  | 
              |
| 507 | 
                  /* Match number of month. */  | 
              |
| 508 | 
                  get_number (1, 12, 2);  | 
              |
| 509 | 
                  tm->tm_mon = val - 1;  | 
              |
| 510 | 
                  have_mon = 1;  | 
              |
| 511 | 
                  want_xday = 1;  | 
              |
| 512 | 
                  break;  | 
              |
| 513 | 
                  case 'M':  | 
              |
| 514 | 
                  /* Match minute. */  | 
              |
| 515 | 
                  get_number (0, 59, 2);  | 
              |
| 516 | 
                  tm->tm_min = val;  | 
              |
| 517 | 
                  break;  | 
              |
| 518 | 
                  case 'n':  | 
              |
| 519 | 
                  case 't':  | 
              |
| 520 | 
                  /* Match any white space. */  | 
              |
| 521 | 
                  while (isspace (*rp))  | 
              |
| 522 | 
                  ++rp;  | 
              |
| 523 | 
                  break;  | 
              |
| 524 | 
                  case 'p':  | 
              |
| 525 | 
                  /* Match locale's equivalent of AM/PM. */  | 
              |
| 524 | 526 | 
                  #ifdef _NL_CURRENT  | 
              
| 525 | 
                  if (*decided != raw)  | 
              |
| 526 | 
                             {
                 | 
              |
| 527 | 
                  if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp))  | 
              |
| 528 | 
                                 {
                 | 
              |
| 529 | 
                  if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR))  | 
              |
| 530 | 
                  *decided = loc;  | 
              |
| 531 | 
                  break;  | 
              |
| 532 | 
                  }  | 
              |
| 533 | 
                  if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp))  | 
              |
| 534 | 
                                 {
                 | 
              |
| 535 | 
                  if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR))  | 
              |
| 536 | 
                  *decided = loc;  | 
              |
| 537 | 
                  is_pm = 1;  | 
              |
| 538 | 
                  break;  | 
              |
| 539 | 
                  }  | 
              |
| 540 | 
                  *decided = raw;  | 
              |
| 541 | 
                  }  | 
              |
| 527 | 
                  if (*decided != raw)  | 
              |
| 528 | 
                              {
                 | 
              |
| 529 | 
                  if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp))  | 
              |
| 530 | 
                                  {
                 | 
              |
| 531 | 
                  if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR))  | 
              |
| 532 | 
                  *decided = loc;  | 
              |
| 533 | 
                  break;  | 
              |
| 534 | 
                  }  | 
              |
| 535 | 
                  if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp))  | 
              |
| 536 | 
                                  {
                 | 
              |
| 537 | 
                  if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR))  | 
              |
| 538 | 
                  *decided = loc;  | 
              |
| 539 | 
                  is_pm = 1;  | 
              |
| 540 | 
                  break;  | 
              |
| 541 | 
                  }  | 
              |
| 542 | 
                  *decided = raw;  | 
              |
| 543 | 
                  }  | 
              |
| 542 | 544 | 
                  #endif  | 
              
| 543 | 
                           if (!match_string (HERE_AM_STR, rp)) {
                 | 
              |
| 544 | 
                             if (match_string (HERE_PM_STR, rp)) {
                 | 
              |
| 545 | 
                  is_pm = 1;  | 
              |
| 546 | 
                             } else {
                 | 
              |
| 547 | 
                  return NULL;  | 
              |
| 545 | 
                            if (!match_string (HERE_AM_STR, rp)) {
                 | 
              |
| 546 | 
                              if (match_string (HERE_PM_STR, rp)) {
                 | 
              |
| 547 | 
                  is_pm = 1;  | 
              |
| 548 | 
                              } else {
                 | 
              |
| 549 | 
                  return NULL;  | 
              |
| 548 | 550 | 
                  }  | 
              
| 549 | 551 | 
                  }  | 
              
| 550 | 
                  break;  | 
              |
| 551 | 
                  case 'r':  | 
              |
| 552 | 
                  break;  | 
              |
| 553 | 
                  case 'r':  | 
              |
| 552 | 554 | 
                  #ifdef _NL_CURRENT  | 
              
| 553 | 
                  if (*decided != raw)  | 
              |
| 554 | 
                             {
                 | 
              |
| 555 | 
                  if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM)))  | 
              |
| 556 | 
                                 {
                 | 
              |
| 557 | 
                  if (*decided == loc)  | 
              |
| 558 | 
                  return NULL;  | 
              |
| 559 | 
                  else  | 
              |
| 560 | 
                  rp = rp_backup;  | 
              |
| 561 | 
                  }  | 
              |
| 562 | 
                  else  | 
              |
| 563 | 
                                 {
                 | 
              |
| 564 | 
                  if (*decided == not &&  | 
              |
| 565 | 
                  strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM),  | 
              |
| 566 | 
                  HERE_T_FMT_AMPM))  | 
              |
| 567 | 
                  *decided = loc;  | 
              |
| 568 | 
                  break;  | 
              |
| 569 | 
                  }  | 
              |
| 570 | 
                  *decided = raw;  | 
              |
| 571 | 
                  }  | 
              |
| 555 | 
                  if (*decided != raw)  | 
              |
| 556 | 
                              {
                 | 
              |
| 557 | 
                  if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM)))  | 
              |
| 558 | 
                                  {
                 | 
              |
| 559 | 
                  if (*decided == loc)  | 
              |
| 560 | 
                  return NULL;  | 
              |
| 561 | 
                  else  | 
              |
| 562 | 
                  rp = rp_backup;  | 
              |
| 563 | 
                  }  | 
              |
| 564 | 
                  else  | 
              |
| 565 | 
                                  {
                 | 
              |
| 566 | 
                  if (*decided == not &&  | 
              |
| 567 | 
                  strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM),  | 
              |
| 568 | 
                  HERE_T_FMT_AMPM))  | 
              |
| 569 | 
                  *decided = loc;  | 
              |
| 570 | 
                  break;  | 
              |
| 571 | 
                  }  | 
              |
| 572 | 
                  *decided = raw;  | 
              |
| 573 | 
                  }  | 
              |
| 572 | 574 | 
                  #endif  | 
              
| 573 | 
                  if (!recursive (HERE_T_FMT_AMPM))  | 
              |
| 574 | 
                  return NULL;  | 
              |
| 575 | 
                  break;  | 
              |
| 576 | 
                  case 'R':  | 
              |
| 577 | 
                           if (!recursive ("%H:%M"))
                 | 
              |
| 578 | 
                  return NULL;  | 
              |
| 579 | 
                  break;  | 
              |
| 580 | 
                  case 's':  | 
              |
| 581 | 
                           {
                 | 
              |
| 582 | 
                  /* The number of seconds may be very high so we cannot use  | 
              |
| 583 | 
                  the `get_number' macro. Instead read the number  | 
              |
| 584 | 
                  character for character and construct the result while  | 
              |
| 585 | 
                  doing this. */  | 
              |
| 586 | 
                  time_t secs = 0;  | 
              |
| 587 | 
                  if (*rp < '0' || *rp > '9')  | 
              |
| 588 | 
                  /* We need at least one digit. */  | 
              |
| 589 | 
                  return NULL;  | 
              |
| 575 | 
                  if (!recursive (HERE_T_FMT_AMPM))  | 
              |
| 576 | 
                  return NULL;  | 
              |
| 577 | 
                  break;  | 
              |
| 578 | 
                  case 'R':  | 
              |
| 579 | 
                            if (!recursive ("%H:%M"))
                 | 
              |
| 580 | 
                  return NULL;  | 
              |
| 581 | 
                  break;  | 
              |
| 582 | 
                  case 's':  | 
              |
| 583 | 
                            {
                 | 
              |
| 584 | 
                  /* The number of seconds may be very high so we cannot use  | 
              |
| 585 | 
                  the `get_number' macro. Instead read the number  | 
              |
| 586 | 
                  character for character and construct the result while  | 
              |
| 587 | 
                  doing this. */  | 
              |
| 588 | 
                  time_t secs = 0;  | 
              |
| 589 | 
                  if (*rp < '0' || *rp > '9')  | 
              |
| 590 | 
                  /* We need at least one digit. */  | 
              |
| 591 | 
                  return NULL;  | 
              |
| 590 | 592 | 
                   | 
              
| 591 | 
                  do  | 
              |
| 592 | 
                               {
                 | 
              |
| 593 | 
                  secs *= 10;  | 
              |
| 594 | 
                  secs += *rp++ - '0';  | 
              |
| 595 | 
                  }  | 
              |
| 596 | 
                  while (*rp >= '0' && *rp <= '9');  | 
              |
| 593 | 
                  do  | 
              |
| 594 | 
                                {
                 | 
              |
| 595 | 
                  secs *= 10;  | 
              |
| 596 | 
                  secs += *rp++ - '0';  | 
              |
| 597 | 
                  }  | 
              |
| 598 | 
                  while (*rp >= '0' && *rp <= '9');  | 
              |
| 597 | 599 | 
                   | 
              
| 598 | 
                  if (localtime_r (&secs, tm) == NULL)  | 
              |
| 599 | 
                  /* Error in function. */  | 
              |
| 600 | 
                  return NULL;  | 
              |
| 601 | 
                  }  | 
              |
| 602 | 
                  break;  | 
              |
| 603 | 
                  case 'S':  | 
              |
| 604 | 
                  get_number (0, 61, 2);  | 
              |
| 605 | 
                  tm->tm_sec = val;  | 
              |
| 606 | 
                  break;  | 
              |
| 607 | 
                  case 'X':  | 
              |
| 600 | 
                  if (localtime_r (&secs, tm) == NULL)  | 
              |
| 601 | 
                  /* Error in function. */  | 
              |
| 602 | 
                  return NULL;  | 
              |
| 603 | 
                  }  | 
              |
| 604 | 
                  break;  | 
              |
| 605 | 
                  case 'S':  | 
              |
| 606 | 
                  get_number (0, 61, 2);  | 
              |
| 607 | 
                  tm->tm_sec = val;  | 
              |
| 608 | 
                  break;  | 
              |
| 609 | 
                  case 'X':  | 
              |
| 608 | 610 | 
                  #ifdef _NL_CURRENT  | 
              
| 609 | 
                  if (*decided != raw)  | 
              |
| 610 | 
                             {
                 | 
              |
| 611 | 
                  if (!recursive (_NL_CURRENT (LC_TIME, T_FMT)))  | 
              |
| 612 | 
                                 {
                 | 
              |
| 613 | 
                  if (*decided == loc)  | 
              |
| 614 | 
                  return NULL;  | 
              |
| 615 | 
                  else  | 
              |
| 616 | 
                  rp = rp_backup;  | 
              |
| 617 | 
                  }  | 
              |
| 618 | 
                  else  | 
              |
| 619 | 
                                 {
                 | 
              |
| 620 | 
                  if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT))  | 
              |
| 621 | 
                  *decided = loc;  | 
              |
| 622 | 
                  break;  | 
              |
| 623 | 
                  }  | 
              |
| 624 | 
                  *decided = raw;  | 
              |
| 625 | 
                  }  | 
              |
| 611 | 
                  if (*decided != raw)  | 
              |
| 612 | 
                              {
                 | 
              |
| 613 | 
                  if (!recursive (_NL_CURRENT (LC_TIME, T_FMT)))  | 
              |
| 614 | 
                                  {
                 | 
              |
| 615 | 
                  if (*decided == loc)  | 
              |
| 616 | 
                  return NULL;  | 
              |
| 617 | 
                  else  | 
              |
| 618 | 
                  rp = rp_backup;  | 
              |
| 619 | 
                  }  | 
              |
| 620 | 
                  else  | 
              |
| 621 | 
                                  {
                 | 
              |
| 622 | 
                  if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT))  | 
              |
| 623 | 
                  *decided = loc;  | 
              |
| 624 | 
                  break;  | 
              |
| 625 | 
                  }  | 
              |
| 626 | 
                  *decided = raw;  | 
              |
| 627 | 
                  }  | 
              |
| 626 | 628 | 
                  #endif  | 
              
| 627 | 
                  /* Fall through. */  | 
              |
| 628 | 
                  case 'T':  | 
              |
| 629 | 
                  if (!recursive (HERE_T_FMT))  | 
              |
| 630 | 
                  return NULL;  | 
              |
| 631 | 
                  break;  | 
              |
| 632 | 
                  case 'u':  | 
              |
| 633 | 
                  get_number (1, 7, 1);  | 
              |
| 634 | 
                  tm->tm_wday = val % 7;  | 
              |
| 635 | 
                  have_wday = 1;  | 
              |
| 636 | 
                  break;  | 
              |
| 637 | 
                  case 'g':  | 
              |
| 638 | 
                  get_number (0, 99, 2);  | 
              |
| 639 | 
                  /* XXX This cannot determine any field in TM. */  | 
              |
| 640 | 
                  break;  | 
              |
| 641 | 
                  case 'G':  | 
              |
| 642 | 
                  if (*rp < '0' || *rp > '9')  | 
              |
| 643 | 
                  return NULL;  | 
              |
| 644 | 
                  /* XXX Ignore the number since we would need some more  | 
              |
| 645 | 
                  information to compute a real date. */  | 
              |
| 646 | 
                  do  | 
              |
| 647 | 
                  ++rp;  | 
              |
| 648 | 
                  while (*rp >= '0' && *rp <= '9');  | 
              |
| 649 | 
                  break;  | 
              |
| 650 | 
                  case 'U':  | 
              |
| 651 | 
                  case 'V':  | 
              |
| 652 | 
                  case 'W':  | 
              |
| 653 | 
                  get_number (0, 53, 2);  | 
              |
| 654 | 
                  /* XXX This cannot determine any field in TM without some  | 
              |
| 655 | 
                  information. */  | 
              |
| 656 | 
                  break;  | 
              |
| 657 | 
                  case 'w':  | 
              |
| 658 | 
                  /* Match number of weekday. */  | 
              |
| 659 | 
                  get_number (0, 6, 1);  | 
              |
| 660 | 
                  tm->tm_wday = val;  | 
              |
| 661 | 
                  have_wday = 1;  | 
              |
| 662 | 
                  break;  | 
              |
| 663 | 
                  case 'y':  | 
              |
| 629 | 
                  /* Fall through. */  | 
              |
| 630 | 
                  case 'T':  | 
              |
| 631 | 
                  if (!recursive (HERE_T_FMT))  | 
              |
| 632 | 
                  return NULL;  | 
              |
| 633 | 
                  break;  | 
              |
| 634 | 
                  case 'u':  | 
              |
| 635 | 
                  get_number (1, 7, 1);  | 
              |
| 636 | 
                  tm->tm_wday = val % 7;  | 
              |
| 637 | 
                  have_wday = 1;  | 
              |
| 638 | 
                  break;  | 
              |
| 639 | 
                  case 'g':  | 
              |
| 640 | 
                  get_number (0, 99, 2);  | 
              |
| 641 | 
                  /* XXX This cannot determine any field in TM. */  | 
              |
| 642 | 
                  break;  | 
              |
| 643 | 
                  case 'G':  | 
              |
| 644 | 
                  if (*rp < '0' || *rp > '9')  | 
              |
| 645 | 
                  return NULL;  | 
              |
| 646 | 
                  /* XXX Ignore the number since we would need some more  | 
              |
| 647 | 
                  information to compute a real date. */  | 
              |
| 648 | 
                  do  | 
              |
| 649 | 
                  ++rp;  | 
              |
| 650 | 
                  while (*rp >= '0' && *rp <= '9');  | 
              |
| 651 | 
                  break;  | 
              |
| 652 | 
                  case 'U':  | 
              |
| 653 | 
                  case 'V':  | 
              |
| 654 | 
                  case 'W':  | 
              |
| 655 | 
                  get_number (0, 53, 2);  | 
              |
| 656 | 
                  /* XXX This cannot determine any field in TM without some  | 
              |
| 657 | 
                  information. */  | 
              |
| 658 | 
                  break;  | 
              |
| 659 | 
                  case 'w':  | 
              |
| 660 | 
                  /* Match number of weekday. */  | 
              |
| 661 | 
                  get_number (0, 6, 1);  | 
              |
| 662 | 
                  tm->tm_wday = val;  | 
              |
| 663 | 
                  have_wday = 1;  | 
              |
| 664 | 
                  break;  | 
              |
| 665 | 
                  case 'y':  | 
              |
| 664 | 666 | 
                  #ifdef _NL_CURRENT  | 
              
| 665 | 
                  match_year_in_century:  | 
              |
| 667 | 
                  match_year_in_century:  | 
              |
| 666 | 668 | 
                  #endif  | 
              
| 667 | 
                  /* Match year within century. */  | 
              |
| 668 | 
                  get_number (0, 99, 2);  | 
              |
| 669 | 
                  /* The "Year 2000: The Millennium Rollover" paper suggests that  | 
              |
| 670 | 
                  values in the range 69-99 refer to the twentieth century. */  | 
              |
| 671 | 
                  tm->tm_year = val >= 69 ? val : val + 100;  | 
              |
| 672 | 
                  /* Indicate that we want to use the century, if specified. */  | 
              |
| 673 | 
                  want_century = 1;  | 
              |
| 674 | 
                  want_xday = 1;  | 
              |
| 675 | 
                  break;  | 
              |
| 676 | 
                  case 'Y':  | 
              |
| 677 | 
                  /* Match year including century number. */  | 
              |
| 678 | 
                  get_number (0, 9999, 4);  | 
              |
| 679 | 
                  tm->tm_year = val - 1900;  | 
              |
| 680 | 
                  want_century = 0;  | 
              |
| 681 | 
                  want_xday = 1;  | 
              |
| 682 | 
                  break;  | 
              |
| 683 | 
                  case 'Z':  | 
              |
| 684 | 
                  /* XXX How to handle this? */  | 
              |
| 685 | 
                  break;  | 
              |
| 686 | 
                  case 'E':  | 
              |
| 669 | 
                  /* Match year within century. */  | 
              |
| 670 | 
                  get_number (0, 99, 2);  | 
              |
| 671 | 
                  /* The "Year 2000: The Millennium Rollover" paper suggests that  | 
              |
| 672 | 
                  values in the range 69-99 refer to the twentieth century. */  | 
              |
| 673 | 
                  tm->tm_year = val >= 69 ? val : val + 100;  | 
              |
| 674 | 
                  /* Indicate that we want to use the century, if specified. */  | 
              |
| 675 | 
                  want_century = 1;  | 
              |
| 676 | 
                  want_xday = 1;  | 
              |
| 677 | 
                  break;  | 
              |
| 678 | 
                  case 'Y':  | 
              |
| 679 | 
                  /* Match year including century number. */  | 
              |
| 680 | 
                  get_number (0, 9999, 4);  | 
              |
| 681 | 
                  tm->tm_year = val - 1900;  | 
              |
| 682 | 
                  want_century = 0;  | 
              |
| 683 | 
                  want_xday = 1;  | 
              |
| 684 | 
                  break;  | 
              |
| 685 | 
                  case 'Z':  | 
              |
| 686 | 
                  /* XXX How to handle this? */  | 
              |
| 687 | 
                  break;  | 
              |
| 688 | 
                  case 'E':  | 
              |
| 687 | 689 | 
                  #ifdef _NL_CURRENT  | 
              
| 688 | 
                  switch (*fmt++)  | 
              |
| 689 | 
                             {
                 | 
              |
| 690 | 
                  case 'c':  | 
              |
| 691 | 
                  /* Match locale's alternate date and time format. */  | 
              |
| 692 | 
                  if (*decided != raw)  | 
              |
| 693 | 
                                 {
                 | 
              |
| 694 | 
                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT);  | 
              |
| 690 | 
                  switch (*fmt++)  | 
              |
| 691 | 
                              {
                 | 
              |
| 692 | 
                  case 'c':  | 
              |
| 693 | 
                  /* Match locale's alternate date and time format. */  | 
              |
| 694 | 
                  if (*decided != raw)  | 
              |
| 695 | 
                                  {
                 | 
              |
| 696 | 
                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT);  | 
              |
| 695 | 697 | 
                   | 
              
| 696 | 
                  if (*fmt == '\0')  | 
              |
| 697 | 
                  fmt = _NL_CURRENT (LC_TIME, D_T_FMT);  | 
              |
| 698 | 
                  if (*fmt == '\0')  | 
              |
| 699 | 
                  fmt = _NL_CURRENT (LC_TIME, D_T_FMT);  | 
              |
| 698 | 700 | 
                   | 
              
| 699 | 
                  if (!recursive (fmt))  | 
              |
| 700 | 
                                     {
                 | 
              |
| 701 | 
                  if (*decided == loc)  | 
              |
| 702 | 
                  return NULL;  | 
              |
| 703 | 
                  else  | 
              |
| 704 | 
                  rp = rp_backup;  | 
              |
| 705 | 
                  }  | 
              |
| 706 | 
                  else  | 
              |
| 707 | 
                                     {
                 | 
              |
| 708 | 
                  if (strcmp (fmt, HERE_D_T_FMT))  | 
              |
| 709 | 
                  *decided = loc;  | 
              |
| 710 | 
                  want_xday = 1;  | 
              |
| 711 | 
                  break;  | 
              |
| 712 | 
                  }  | 
              |
| 713 | 
                  *decided = raw;  | 
              |
| 714 | 
                  }  | 
              |
| 715 | 
                  /* The C locale has no era information, so use the  | 
              |
| 716 | 
                  normal representation. */  | 
              |
| 717 | 
                  if (!recursive (HERE_D_T_FMT))  | 
              |
| 718 | 
                  return NULL;  | 
              |
| 719 | 
                  want_xday = 1;  | 
              |
| 720 | 
                  break;  | 
              |
| 721 | 
                  case 'C':  | 
              |
| 722 | 
                  if (*decided != raw)  | 
              |
| 723 | 
                                 {
                 | 
              |
| 724 | 
                  if (era_cnt >= 0)  | 
              |
| 725 | 
                                     {
                 | 
              |
| 726 | 
                  era = _nl_select_era_entry (era_cnt);  | 
              |
| 727 | 
                  if (match_string (era->era_name, rp))  | 
              |
| 728 | 
                                         {
                 | 
              |
| 729 | 
                  *decided = loc;  | 
              |
| 730 | 
                  break;  | 
              |
| 731 | 
                  }  | 
              |
| 732 | 
                  else  | 
              |
| 733 | 
                  return NULL;  | 
              |
| 734 | 
                  }  | 
              |
| 735 | 
                  else  | 
              |
| 736 | 
                                     {
                 | 
              |
| 737 | 
                  num_eras = _NL_CURRENT_WORD (LC_TIME,  | 
              |
| 738 | 
                  _NL_TIME_ERA_NUM_ENTRIES);  | 
              |
| 739 | 
                  for (era_cnt = 0; era_cnt < (int) num_eras;  | 
              |
| 740 | 
                  ++era_cnt, rp = rp_backup)  | 
              |
| 741 | 
                                         {
                 | 
              |
| 742 | 
                  era = _nl_select_era_entry (era_cnt);  | 
              |
| 743 | 
                  if (match_string (era->era_name, rp))  | 
              |
| 744 | 
                                             {
                 | 
              |
| 745 | 
                  *decided = loc;  | 
              |
| 746 | 
                  break;  | 
              |
| 747 | 
                  }  | 
              |
| 748 | 
                  }  | 
              |
| 749 | 
                  if (era_cnt == (int) num_eras)  | 
              |
| 750 | 
                                         {
                 | 
              |
| 751 | 
                  era_cnt = -1;  | 
              |
| 752 | 
                  if (*decided == loc)  | 
              |
| 753 | 
                  return NULL;  | 
              |
| 754 | 
                  }  | 
              |
| 755 | 
                  else  | 
              |
| 756 | 
                  break;  | 
              |
| 757 | 
                  }  | 
              |
| 701 | 
                  if (!recursive (fmt))  | 
              |
| 702 | 
                                      {
                 | 
              |
| 703 | 
                  if (*decided == loc)  | 
              |
| 704 | 
                  return NULL;  | 
              |
| 705 | 
                  else  | 
              |
| 706 | 
                  rp = rp_backup;  | 
              |
| 707 | 
                  }  | 
              |
| 708 | 
                  else  | 
              |
| 709 | 
                                      {
                 | 
              |
| 710 | 
                  if (strcmp (fmt, HERE_D_T_FMT))  | 
              |
| 711 | 
                  *decided = loc;  | 
              |
| 712 | 
                  want_xday = 1;  | 
              |
| 713 | 
                  break;  | 
              |
| 714 | 
                  }  | 
              |
| 715 | 
                  *decided = raw;  | 
              |
| 716 | 
                  }  | 
              |
| 717 | 
                  /* The C locale has no era information, so use the  | 
              |
| 718 | 
                  normal representation. */  | 
              |
| 719 | 
                  if (!recursive (HERE_D_T_FMT))  | 
              |
| 720 | 
                  return NULL;  | 
              |
| 721 | 
                  want_xday = 1;  | 
              |
| 722 | 
                  break;  | 
              |
| 723 | 
                  case 'C':  | 
              |
| 724 | 
                  if (*decided != raw)  | 
              |
| 725 | 
                                  {
                 | 
              |
| 726 | 
                  if (era_cnt >= 0)  | 
              |
| 727 | 
                                      {
                 | 
              |
| 728 | 
                  era = _nl_select_era_entry (era_cnt);  | 
              |
| 729 | 
                  if (match_string (era->era_name, rp))  | 
              |
| 730 | 
                                          {
                 | 
              |
| 731 | 
                  *decided = loc;  | 
              |
| 732 | 
                  break;  | 
              |
| 733 | 
                  }  | 
              |
| 734 | 
                  else  | 
              |
| 735 | 
                  return NULL;  | 
              |
| 736 | 
                  }  | 
              |
| 737 | 
                  else  | 
              |
| 738 | 
                                      {
                 | 
              |
| 739 | 
                  num_eras = _NL_CURRENT_WORD (LC_TIME,  | 
              |
| 740 | 
                  _NL_TIME_ERA_NUM_ENTRIES);  | 
              |
| 741 | 
                  for (era_cnt = 0; era_cnt < (int) num_eras;  | 
              |
| 742 | 
                  ++era_cnt, rp = rp_backup)  | 
              |
| 743 | 
                                          {
                 | 
              |
| 744 | 
                  era = _nl_select_era_entry (era_cnt);  | 
              |
| 745 | 
                  if (match_string (era->era_name, rp))  | 
              |
| 746 | 
                                              {
                 | 
              |
| 747 | 
                  *decided = loc;  | 
              |
| 748 | 
                  break;  | 
              |
| 749 | 
                  }  | 
              |
| 750 | 
                  }  | 
              |
| 751 | 
                  if (era_cnt == (int) num_eras)  | 
              |
| 752 | 
                                          {
                 | 
              |
| 753 | 
                  era_cnt = -1;  | 
              |
| 754 | 
                  if (*decided == loc)  | 
              |
| 755 | 
                  return NULL;  | 
              |
| 756 | 
                  }  | 
              |
| 757 | 
                  else  | 
              |
| 758 | 
                  break;  | 
              |
| 759 | 
                  }  | 
              |
| 758 | 760 | 
                   | 
              
| 759 | 
                  *decided = raw;  | 
              |
| 760 | 
                  }  | 
              |
| 761 | 
                  /* The C locale has no era information, so use the  | 
              |
| 762 | 
                  normal representation. */  | 
              |
| 763 | 
                  goto match_century;  | 
              |
| 764 | 
                  case 'y':  | 
              |
| 765 | 
                  if (*decided == raw)  | 
              |
| 766 | 
                  goto match_year_in_century;  | 
              |
| 761 | 
                  *decided = raw;  | 
              |
| 762 | 
                  }  | 
              |
| 763 | 
                  /* The C locale has no era information, so use the  | 
              |
| 764 | 
                  normal representation. */  | 
              |
| 765 | 
                  goto match_century;  | 
              |
| 766 | 
                  case 'y':  | 
              |
| 767 | 
                  if (*decided == raw)  | 
              |
| 768 | 
                  goto match_year_in_century;  | 
              |
| 767 | 769 | 
                   | 
              
| 768 | 
                  get_number(0, 9999, 4);  | 
              |
| 769 | 
                  tm->tm_year = val;  | 
              |
| 770 | 
                  want_era = 1;  | 
              |
| 771 | 
                  want_xday = 1;  | 
              |
| 772 | 
                  break;  | 
              |
| 773 | 
                  case 'Y':  | 
              |
| 774 | 
                  if (*decided != raw)  | 
              |
| 775 | 
                                 {
                 | 
              |
| 776 | 
                  num_eras = _NL_CURRENT_WORD (LC_TIME,  | 
              |
| 777 | 
                  _NL_TIME_ERA_NUM_ENTRIES);  | 
              |
| 778 | 
                  for (era_cnt = 0; era_cnt < (int) num_eras;  | 
              |
| 779 | 
                  ++era_cnt, rp = rp_backup)  | 
              |
| 780 | 
                                     {
                 | 
              |
| 781 | 
                  era = _nl_select_era_entry (era_cnt);  | 
              |
| 782 | 
                  if (recursive (era->era_format))  | 
              |
| 783 | 
                  break;  | 
              |
| 784 | 
                  }  | 
              |
| 785 | 
                  if (era_cnt == (int) num_eras)  | 
              |
| 786 | 
                                     {
                 | 
              |
| 787 | 
                  era_cnt = -1;  | 
              |
| 788 | 
                  if (*decided == loc)  | 
              |
| 789 | 
                  return NULL;  | 
              |
| 790 | 
                  else  | 
              |
| 791 | 
                  rp = rp_backup;  | 
              |
| 792 | 
                  }  | 
              |
| 793 | 
                  else  | 
              |
| 794 | 
                                     {
                 | 
              |
| 795 | 
                  *decided = loc;  | 
              |
| 796 | 
                  era_cnt = -1;  | 
              |
| 797 | 
                  break;  | 
              |
| 798 | 
                  }  | 
              |
| 770 | 
                  get_number(0, 9999, 4);  | 
              |
| 771 | 
                  tm->tm_year = val;  | 
              |
| 772 | 
                  want_era = 1;  | 
              |
| 773 | 
                  want_xday = 1;  | 
              |
| 774 | 
                  break;  | 
              |
| 775 | 
                  case 'Y':  | 
              |
| 776 | 
                  if (*decided != raw)  | 
              |
| 777 | 
                                  {
                 | 
              |
| 778 | 
                  num_eras = _NL_CURRENT_WORD (LC_TIME,  | 
              |
| 779 | 
                  _NL_TIME_ERA_NUM_ENTRIES);  | 
              |
| 780 | 
                  for (era_cnt = 0; era_cnt < (int) num_eras;  | 
              |
| 781 | 
                  ++era_cnt, rp = rp_backup)  | 
              |
| 782 | 
                                      {
                 | 
              |
| 783 | 
                  era = _nl_select_era_entry (era_cnt);  | 
              |
| 784 | 
                  if (recursive (era->era_format))  | 
              |
| 785 | 
                  break;  | 
              |
| 786 | 
                  }  | 
              |
| 787 | 
                  if (era_cnt == (int) num_eras)  | 
              |
| 788 | 
                                      {
                 | 
              |
| 789 | 
                  era_cnt = -1;  | 
              |
| 790 | 
                  if (*decided == loc)  | 
              |
| 791 | 
                  return NULL;  | 
              |
| 792 | 
                  else  | 
              |
| 793 | 
                  rp = rp_backup;  | 
              |
| 794 | 
                  }  | 
              |
| 795 | 
                  else  | 
              |
| 796 | 
                                      {
                 | 
              |
| 797 | 
                  *decided = loc;  | 
              |
| 798 | 
                  era_cnt = -1;  | 
              |
| 799 | 
                  break;  | 
              |
| 800 | 
                  }  | 
              |
| 799 | 801 | 
                   | 
              
| 800 | 
                  *decided = raw;  | 
              |
| 801 | 
                  }  | 
              |
| 802 | 
                  get_number (0, 9999, 4);  | 
              |
| 803 | 
                  tm->tm_year = val - 1900;  | 
              |
| 804 | 
                  want_century = 0;  | 
              |
| 805 | 
                  want_xday = 1;  | 
              |
| 806 | 
                  break;  | 
              |
| 807 | 
                  case 'x':  | 
              |
| 808 | 
                  if (*decided != raw)  | 
              |
| 809 | 
                                 {
                 | 
              |
| 810 | 
                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT);  | 
              |
| 802 | 
                  *decided = raw;  | 
              |
| 803 | 
                  }  | 
              |
| 804 | 
                  get_number (0, 9999, 4);  | 
              |
| 805 | 
                  tm->tm_year = val - 1900;  | 
              |
| 806 | 
                  want_century = 0;  | 
              |
| 807 | 
                  want_xday = 1;  | 
              |
| 808 | 
                  break;  | 
              |
| 809 | 
                  case 'x':  | 
              |
| 810 | 
                  if (*decided != raw)  | 
              |
| 811 | 
                                  {
                 | 
              |
| 812 | 
                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT);  | 
              |
| 811 | 813 | 
                   | 
              
| 812 | 
                  if (*fmt == '\0')  | 
              |
| 813 | 
                  fmt = _NL_CURRENT (LC_TIME, D_FMT);  | 
              |
| 814 | 
                  if (*fmt == '\0')  | 
              |
| 815 | 
                  fmt = _NL_CURRENT (LC_TIME, D_FMT);  | 
              |
| 814 | 816 | 
                   | 
              
| 815 | 
                  if (!recursive (fmt))  | 
              |
| 816 | 
                                     {
                 | 
              |
| 817 | 
                  if (*decided == loc)  | 
              |
| 818 | 
                  return NULL;  | 
              |
| 819 | 
                  else  | 
              |
| 820 | 
                  rp = rp_backup;  | 
              |
| 821 | 
                  }  | 
              |
| 822 | 
                  else  | 
              |
| 823 | 
                                     {
                 | 
              |
| 824 | 
                  if (strcmp (fmt, HERE_D_FMT))  | 
              |
| 825 | 
                  *decided = loc;  | 
              |
| 826 | 
                  break;  | 
              |
| 827 | 
                  }  | 
              |
| 828 | 
                  *decided = raw;  | 
              |
| 829 | 
                  }  | 
              |
| 830 | 
                  if (!recursive (HERE_D_FMT))  | 
              |
| 831 | 
                  return NULL;  | 
              |
| 832 | 
                  break;  | 
              |
| 833 | 
                  case 'X':  | 
              |
| 834 | 
                  if (*decided != raw)  | 
              |
| 835 | 
                                 {
                 | 
              |
| 836 | 
                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT);  | 
              |
| 817 | 
                  if (!recursive (fmt))  | 
              |
| 818 | 
                                      {
                 | 
              |
| 819 | 
                  if (*decided == loc)  | 
              |
| 820 | 
                  return NULL;  | 
              |
| 821 | 
                  else  | 
              |
| 822 | 
                  rp = rp_backup;  | 
              |
| 823 | 
                  }  | 
              |
| 824 | 
                  else  | 
              |
| 825 | 
                                      {
                 | 
              |
| 826 | 
                  if (strcmp (fmt, HERE_D_FMT))  | 
              |
| 827 | 
                  *decided = loc;  | 
              |
| 828 | 
                  break;  | 
              |
| 829 | 
                  }  | 
              |
| 830 | 
                  *decided = raw;  | 
              |
| 831 | 
                  }  | 
              |
| 832 | 
                  if (!recursive (HERE_D_FMT))  | 
              |
| 833 | 
                  return NULL;  | 
              |
| 834 | 
                  break;  | 
              |
| 835 | 
                  case 'X':  | 
              |
| 836 | 
                  if (*decided != raw)  | 
              |
| 837 | 
                                  {
                 | 
              |
| 838 | 
                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT);  | 
              |
| 837 | 839 | 
                   | 
              
| 838 | 
                  if (*fmt == '\0')  | 
              |
| 839 | 
                  fmt = _NL_CURRENT (LC_TIME, T_FMT);  | 
              |
| 840 | 
                  if (*fmt == '\0')  | 
              |
| 841 | 
                  fmt = _NL_CURRENT (LC_TIME, T_FMT);  | 
              |
| 840 | 842 | 
                   | 
              
| 841 | 
                  if (!recursive (fmt))  | 
              |
| 842 | 
                                     {
                 | 
              |
| 843 | 
                  if (*decided == loc)  | 
              |
| 844 | 
                  return NULL;  | 
              |
| 845 | 
                  else  | 
              |
| 846 | 
                  rp = rp_backup;  | 
              |
| 847 | 
                  }  | 
              |
| 848 | 
                  else  | 
              |
| 849 | 
                                     {
                 | 
              |
| 850 | 
                  if (strcmp (fmt, HERE_T_FMT))  | 
              |
| 851 | 
                  *decided = loc;  | 
              |
| 852 | 
                  break;  | 
              |
| 853 | 
                  }  | 
              |
| 854 | 
                  *decided = raw;  | 
              |
| 855 | 
                  }  | 
              |
| 856 | 
                  if (!recursive (HERE_T_FMT))  | 
              |
| 857 | 
                  return NULL;  | 
              |
| 858 | 
                  break;  | 
              |
| 859 | 
                  default:  | 
              |
| 860 | 
                  return NULL;  | 
              |
| 861 | 
                  }  | 
              |
| 862 | 
                  break;  | 
              |
| 843 | 
                  if (!recursive (fmt))  | 
              |
| 844 | 
                                      {
                 | 
              |
| 845 | 
                  if (*decided == loc)  | 
              |
| 846 | 
                  return NULL;  | 
              |
| 847 | 
                  else  | 
              |
| 848 | 
                  rp = rp_backup;  | 
              |
| 849 | 
                  }  | 
              |
| 850 | 
                  else  | 
              |
| 851 | 
                                      {
                 | 
              |
| 852 | 
                  if (strcmp (fmt, HERE_T_FMT))  | 
              |
| 853 | 
                  *decided = loc;  | 
              |
| 854 | 
                  break;  | 
              |
| 855 | 
                  }  | 
              |
| 856 | 
                  *decided = raw;  | 
              |
| 857 | 
                  }  | 
              |
| 858 | 
                  if (!recursive (HERE_T_FMT))  | 
              |
| 859 | 
                  return NULL;  | 
              |
| 860 | 
                  break;  | 
              |
| 861 | 
                  default:  | 
              |
| 862 | 
                  return NULL;  | 
              |
| 863 | 
                  }  | 
              |
| 864 | 
                  break;  | 
              |
| 863 | 865 | 
                  #else  | 
              
| 864 | 
                  /* We have no information about the era format. Just use  | 
              |
| 865 | 
                  the normal format. */  | 
              |
| 866 | 
                  if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y'  | 
              |
| 867 | 
                  && *fmt != 'x' && *fmt != 'X')  | 
              |
| 868 | 
                  /* This is an illegal format. */  | 
              |
| 869 | 
                  return NULL;  | 
              |
| 866 | 
                  /* We have no information about the era format. Just use  | 
              |
| 867 | 
                  the normal format. */  | 
              |
| 868 | 
                  if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y'  | 
              |
| 869 | 
                  && *fmt != 'x' && *fmt != 'X')  | 
              |
| 870 | 
                  /* This is an illegal format. */  | 
              |
| 871 | 
                  return NULL;  | 
              |
| 870 | 872 | 
                   | 
              
| 871 | 
                  goto start_over;  | 
              |
| 873 | 
                  goto start_over;  | 
              |
| 872 | 874 | 
                  #endif  | 
              
| 873 | 
                  case 'O':  | 
              |
| 874 | 
                  switch (*fmt++)  | 
              |
| 875 | 
                             {
                 | 
              |
| 876 | 
                  case 'd':  | 
              |
| 877 | 
                  case 'e':  | 
              |
| 878 | 
                  /* Match day of month using alternate numeric symbols. */  | 
              |
| 879 | 
                  get_alt_number (1, 31, 2);  | 
              |
| 880 | 
                  tm->tm_mday = val;  | 
              |
| 881 | 
                  have_mday = 1;  | 
              |
| 882 | 
                  want_xday = 1;  | 
              |
| 883 | 
                  break;  | 
              |
| 884 | 
                  case 'H':  | 
              |
| 885 | 
                  /* Match hour in 24-hour clock using alternate numeric  | 
              |
| 886 | 
                  symbols. */  | 
              |
| 887 | 
                  get_alt_number (0, 23, 2);  | 
              |
| 888 | 
                  tm->tm_hour = val;  | 
              |
| 889 | 
                  have_I = 0;  | 
              |
| 890 | 
                  break;  | 
              |
| 891 | 
                  case 'I':  | 
              |
| 892 | 
                  /* Match hour in 12-hour clock using alternate numeric  | 
              |
| 893 | 
                  symbols. */  | 
              |
| 894 | 
                  get_alt_number (1, 12, 2);  | 
              |
| 895 | 
                  tm->tm_hour = val - 1;  | 
              |
| 896 | 
                  have_I = 1;  | 
              |
| 897 | 
                  break;  | 
              |
| 898 | 
                  case 'm':  | 
              |
| 899 | 
                  /* Match month using alternate numeric symbols. */  | 
              |
| 900 | 
                  get_alt_number (1, 12, 2);  | 
              |
| 901 | 
                  tm->tm_mon = val - 1;  | 
              |
| 902 | 
                  have_mon = 1;  | 
              |
| 903 | 
                  want_xday = 1;  | 
              |
| 904 | 
                  break;  | 
              |
| 905 | 
                  case 'M':  | 
              |
| 906 | 
                  /* Match minutes using alternate numeric symbols. */  | 
              |
| 907 | 
                  get_alt_number (0, 59, 2);  | 
              |
| 908 | 
                  tm->tm_min = val;  | 
              |
| 909 | 
                  break;  | 
              |
| 910 | 
                  case 'S':  | 
              |
| 911 | 
                  /* Match seconds using alternate numeric symbols. */  | 
              |
| 912 | 
                  get_alt_number (0, 61, 2);  | 
              |
| 913 | 
                  tm->tm_sec = val;  | 
              |
| 914 | 
                  break;  | 
              |
| 915 | 
                  case 'U':  | 
              |
| 916 | 
                  case 'V':  | 
              |
| 917 | 
                  case 'W':  | 
              |
| 918 | 
                  get_alt_number (0, 53, 2);  | 
              |
| 919 | 
                  /* XXX This cannot determine any field in TM without  | 
              |
| 920 | 
                  further information. */  | 
              |
| 921 | 
                  break;  | 
              |
| 922 | 
                  case 'w':  | 
              |
| 923 | 
                  /* Match number of weekday using alternate numeric symbols. */  | 
              |
| 924 | 
                  get_alt_number (0, 6, 1);  | 
              |
| 925 | 
                  tm->tm_wday = val;  | 
              |
| 926 | 
                  have_wday = 1;  | 
              |
| 927 | 
                  break;  | 
              |
| 928 | 
                  case 'y':  | 
              |
| 929 | 
                  /* Match year within century using alternate numeric symbols. */  | 
              |
| 930 | 
                  get_alt_number (0, 99, 2);  | 
              |
| 931 | 
                  tm->tm_year = val >= 69 ? val : val + 100;  | 
              |
| 932 | 
                  want_xday = 1;  | 
              |
| 933 | 
                  break;  | 
              |
| 934 | 
                  default:  | 
              |
| 935 | 
                  return NULL;  | 
              |
| 936 | 
                  }  | 
              |
| 937 | 
                  break;  | 
              |
| 938 | 
                  default:  | 
              |
| 939 | 
                  return NULL;  | 
              |
| 940 | 
                  }  | 
              |
| 875 | 
                  case 'O':  | 
              |
| 876 | 
                  switch (*fmt++)  | 
              |
| 877 | 
                              {
                 | 
              |
| 878 | 
                  case 'd':  | 
              |
| 879 | 
                  case 'e':  | 
              |
| 880 | 
                  /* Match day of month using alternate numeric symbols. */  | 
              |
| 881 | 
                  get_alt_number (1, 31, 2);  | 
              |
| 882 | 
                  tm->tm_mday = val;  | 
              |
| 883 | 
                  have_mday = 1;  | 
              |
| 884 | 
                  want_xday = 1;  | 
              |
| 885 | 
                  break;  | 
              |
| 886 | 
                  case 'H':  | 
              |
| 887 | 
                  /* Match hour in 24-hour clock using alternate numeric  | 
              |
| 888 | 
                  symbols. */  | 
              |
| 889 | 
                  get_alt_number (0, 23, 2);  | 
              |
| 890 | 
                  tm->tm_hour = val;  | 
              |
| 891 | 
                  have_I = 0;  | 
              |
| 892 | 
                  break;  | 
              |
| 893 | 
                  case 'I':  | 
              |
| 894 | 
                  /* Match hour in 12-hour clock using alternate numeric  | 
              |
| 895 | 
                  symbols. */  | 
              |
| 896 | 
                  get_alt_number (1, 12, 2);  | 
              |
| 897 | 
                  tm->tm_hour = val - 1;  | 
              |
| 898 | 
                  have_I = 1;  | 
              |
| 899 | 
                  break;  | 
              |
| 900 | 
                  case 'm':  | 
              |
| 901 | 
                  /* Match month using alternate numeric symbols. */  | 
              |
| 902 | 
                  get_alt_number (1, 12, 2);  | 
              |
| 903 | 
                  tm->tm_mon = val - 1;  | 
              |
| 904 | 
                  have_mon = 1;  | 
              |
| 905 | 
                  want_xday = 1;  | 
              |
| 906 | 
                  break;  | 
              |
| 907 | 
                  case 'M':  | 
              |
| 908 | 
                  /* Match minutes using alternate numeric symbols. */  | 
              |
| 909 | 
                  get_alt_number (0, 59, 2);  | 
              |
| 910 | 
                  tm->tm_min = val;  | 
              |
| 911 | 
                  break;  | 
              |
| 912 | 
                  case 'S':  | 
              |
| 913 | 
                  /* Match seconds using alternate numeric symbols. */  | 
              |
| 914 | 
                  get_alt_number (0, 61, 2);  | 
              |
| 915 | 
                  tm->tm_sec = val;  | 
              |
| 916 | 
                  break;  | 
              |
| 917 | 
                  case 'U':  | 
              |
| 918 | 
                  case 'V':  | 
              |
| 919 | 
                  case 'W':  | 
              |
| 920 | 
                  get_alt_number (0, 53, 2);  | 
              |
| 921 | 
                  /* XXX This cannot determine any field in TM without  | 
              |
| 922 | 
                  further information. */  | 
              |
| 923 | 
                  break;  | 
              |
| 924 | 
                  case 'w':  | 
              |
| 925 | 
                  /* Match number of weekday using alternate numeric symbols. */  | 
              |
| 926 | 
                  get_alt_number (0, 6, 1);  | 
              |
| 927 | 
                  tm->tm_wday = val;  | 
              |
| 928 | 
                  have_wday = 1;  | 
              |
| 929 | 
                  break;  | 
              |
| 930 | 
                  case 'y':  | 
              |
| 931 | 
                  /* Match year within century using alternate numeric symbols. */  | 
              |
| 932 | 
                  get_alt_number (0, 99, 2);  | 
              |
| 933 | 
                  tm->tm_year = val >= 69 ? val : val + 100;  | 
              |
| 934 | 
                  want_xday = 1;  | 
              |
| 935 | 
                  break;  | 
              |
| 936 | 
                  default:  | 
              |
| 937 | 
                  return NULL;  | 
              |
| 938 | 
                  }  | 
              |
| 939 | 
                  break;  | 
              |
| 940 | 
                  default:  | 
              |
| 941 | 
                  return NULL;  | 
              |
| 942 | 
                  }  | 
              |
| 941 | 943 | 
                  }  | 
              
| 942 | 944 | 
                   | 
              
| 943 | 945 | 
                  if (have_I && is_pm)  | 
              
| ... | ... | |
| 946 | 948 | 
                  if (century != -1)  | 
              
| 947 | 949 | 
                      {
                 | 
              
| 948 | 950 | 
                  if (want_century)  | 
              
| 949 | 
                  tm->tm_year = tm->tm_year % 100 + (century - 19) * 100;  | 
              |
| 951 | 
                  tm->tm_year = tm->tm_year % 100 + (century - 19) * 100;  | 
              |
| 950 | 952 | 
                  else  | 
              
| 951 | 
                  /* Only the century, but not the year. Strange, but so be it. */  | 
              |
| 952 | 
                  tm->tm_year = (century - 19) * 100;  | 
              |
| 953 | 
                  /* Only the century, but not the year. Strange, but so be it. */  | 
              |
| 954 | 
                  tm->tm_year = (century - 19) * 100;  | 
              |
| 953 | 955 | 
                  }  | 
              
| 954 | 956 | 
                   | 
              
| 955 | 957 | 
                  #ifdef _NL_CURRENT  | 
              
| ... | ... | |
| 957 | 959 | 
                      {
                 | 
              
| 958 | 960 | 
                  era = _nl_select_era_entry(era_cnt);  | 
              
| 959 | 961 | 
                  if (want_era)  | 
              
| 960 | 
                  tm->tm_year = (era->start_date[0]  | 
              |
| 961 | 
                  + ((tm->tm_year - era->offset)  | 
              |
| 962 | 
                  * era->absolute_direction));  | 
              |
| 962 | 
                  tm->tm_year = (era->start_date[0]  | 
              |
| 963 | 
                  + ((tm->tm_year - era->offset)  | 
              |
| 964 | 
                  * era->absolute_direction));  | 
              |
| 963 | 965 | 
                  else  | 
              
| 964 | 
                  /* Era start year assumed. */  | 
              |
| 965 | 
                  tm->tm_year = era->start_date[0];  | 
              |
| 966 | 
                  /* Era start year assumed. */  | 
              |
| 967 | 
                  tm->tm_year = era->start_date[0];  | 
              |
| 966 | 968 | 
                  }  | 
              
| 967 | 969 | 
                  else  | 
              
| 968 | 970 | 
                  #endif  | 
              
| ... | ... | |
| 972 | 974 | 
                  if (want_xday && !have_wday)  | 
              
| 973 | 975 | 
                      {
                 | 
              
| 974 | 976 | 
                  if ( !(have_mon && have_mday) && have_yday)  | 
              
| 975 | 
                         {
                 | 
              |
| 976 | 
                  /* We don't have tm_mon and/or tm_mday, compute them. */  | 
              |
| 977 | 
                  int t_mon = 0;  | 
              |
| 978 | 
                  while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday)  | 
              |
| 979 | 
                  t_mon++;  | 
              |
| 980 | 
                  if (!have_mon)  | 
              |
| 981 | 
                  tm->tm_mon = t_mon - 1;  | 
              |
| 982 | 
                  if (!have_mday)  | 
              |
| 983 | 
                  tm->tm_mday =  | 
              |
| 984 | 
                  (tm->tm_yday  | 
              |
| 985 | 
                  - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1);  | 
              |
| 986 | 
                  }  | 
              |
| 977 | 
                          {
                 | 
              |
| 978 | 
                  /* We don't have tm_mon and/or tm_mday, compute them. */  | 
              |
| 979 | 
                  int t_mon = 0;  | 
              |
| 980 | 
                  while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday)  | 
              |
| 981 | 
                  t_mon++;  | 
              |
| 982 | 
                  if (!have_mon)  | 
              |
| 983 | 
                  tm->tm_mon = t_mon - 1;  | 
              |
| 984 | 
                  if (!have_mday)  | 
              |
| 985 | 
                  tm->tm_mday =  | 
              |
| 986 | 
                  (tm->tm_yday  | 
              |
| 987 | 
                  - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1);  | 
              |
| 988 | 
                  }  | 
              |
| 987 | 989 | 
                  day_of_the_week (tm);  | 
              
| 988 | 990 | 
                  }  | 
              
| 989 | 991 | 
                  if (want_xday && !have_yday)  | 
              
| trunk/nntpgrab_core/download_thread.c (revision 1857) | ||
|---|---|---|
| 515 | 515 | 
                  connection_error_occured = TRUE;  | 
              
| 516 | 516 | 
                  }  | 
              
| 517 | 517 | 
                                      } else {
                 | 
              
| 518 | 
                  ng_plugin_emit_log_msg(NULL, NG_LOG_LEVEL_INFO, "nntpconnection_connect_to_server SUCCEEDED, conn_id = %i, poll_fd = %i", conn->connection_id, conn->poll_fd.fd);  | 
              |
| 518 | 
                  ng_plugin_emit_log_msg(NULL, NG_LOG_LEVEL_INFO, "nntpconnection_connect_to_server SUCCEEDED, conn_id = %i, poll_fd = %i", conn->connection_id, (int) conn->poll_fd.fd);  | 
              |
| 519 | 519 | 
                  reset_poll_fd_list(active_connections, &active_connection_polls, &num_active_connections);  | 
              
| 520 | 520 | 
                  }  | 
              
| 521 | 521 | 
                  }  | 
              
| trunk/nntpgrab_core/nntpconnection.c (revision 1857) | ||
|---|---|---|
| 586 | 586 | 
                  static void  | 
              
| 587 | 587 | 
                  nntpconnection_process_xover_data(NntpConnection *conn)  | 
              
| 588 | 588 | 
                  {
                 | 
              
| 589 | 
                  #if 0  | 
              |
| 589 | 590 | 
                  char buf[1024];  | 
              
| 590 | 591 | 
                  int length = 0;  | 
              
| 591 | 592 | 
                  gboolean more_data_ready = FALSE;  | 
              
| ... | ... | |
| 652 | 653 | 
                  }  | 
              
| 653 | 654 | 
                   | 
              
| 654 | 655 | 
                  return;  | 
              
| 656 | 
                  #endif  | 
              |
| 655 | 657 | 
                  }  | 
              
| 656 | 658 | 
                   | 
              
| 657 | 659 | 
                  void  | 
              
| ... | ... | |
| 660 | 662 | 
                  g_return_if_fail(conn != NULL);  | 
              
| 661 | 663 | 
                   | 
              
| 662 | 664 | 
                      if (!conn->active_method) {
                 | 
              
| 663 | 
                  ng_plugin_emit_log_msg(NULL, NG_LOG_LEVEL_INFO, "NNTP connection to server '%s' (connection_id %i, poll_fd %i) is in an undefined state", conn->server_info.servername, conn->connection_id, conn->poll_fd.fd);  | 
              |
| 665 | 
                  ng_plugin_emit_log_msg(NULL, NG_LOG_LEVEL_INFO, "NNTP connection to server '%s' (connection_id %i, poll_fd %i) is in an undefined state", conn->server_info.servername, conn->connection_id, (int) conn->poll_fd.fd);  | 
              |
| 664 | 666 | 
                          nntpconnection_disconnect_from_server(conn, DISCONNECT_UNEXPECTED, _("NNTP Connection is in an undefined state"), __FILE__, __LINE__);
                 | 
              
| 665 | 667 | 
                  return;  | 
              
| 666 | 668 | 
                  }  | 
              
| trunk/nntpgrab_core/nntpconnection_backend_native.c (revision 1857) | ||
|---|---|---|
| 124 | 124 | 
                  {
                 | 
              
| 125 | 125 | 
                  NntpconnectionBackendNativePrivate *conn_priv = NNTPCONNECTION_BACKEND_NATIVE(conn)->priv;  | 
              
| 126 | 126 | 
                  int retval;  | 
              
| 127 | 
                  #ifdef WIN32  | 
              |
| 128 | 
                  char *errmsg_tmp = NULL;  | 
              |
| 129 | 
                  #endif  | 
              |
| 130 | 127 | 
                   | 
              
| 131 | 128 | 
                  g_return_val_if_fail(conn != NULL, FALSE);  | 
              
Also available in: Unified diff
NNTPGrab

