~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/type/time.cc

  • Committer: Mark Atwood
  • Date: 2011-10-25 19:08:35 UTC
  • mfrom: (2445.1.6 rf)
  • Revision ID: me@mark.atwood.name-20111025190835-g21cn911ypxjd5fi
mergeĀ lp:~olafvdspek/drizzle/refactor7

Show diffs side-by-side

added added

removed removed

Lines of Context:
189
189
  was_cut= type::VALID;
190
190
 
191
191
  /* Skip space at start */
192
 
  for (; str != end && my_isspace(&my_charset_utf8_general_ci, *str) ; str++)
 
192
  for (; str != end && my_charset_utf8_general_ci.isspace(*str) ; str++)
193
193
    ;
194
194
 
195
 
  if (str == end || ! my_isdigit(&my_charset_utf8_general_ci, *str))
 
195
  if (str == end || not my_charset_utf8_general_ci.isdigit(*str))
196
196
  {
197
197
    was_cut= type::CUT;
198
198
    return(type::DRIZZLE_TIMESTAMP_NONE);
208
208
    (YYYY-MM-DD,  YYYYMMDD, YYYYYMMDDHHMMSS)
209
209
  */
210
210
  for (pos=str;
211
 
       pos != end && (my_isdigit(&my_charset_utf8_general_ci,*pos) || *pos == 'T');
 
211
       pos != end && (my_charset_utf8_general_ci.isdigit(*pos) || *pos == 'T');
212
212
       pos++)
213
213
    ;
214
214
 
233
233
        We do this by checking if there is two numbers separated by
234
234
        space in the input.
235
235
      */
236
 
      while (pos < end && !my_isspace(&my_charset_utf8_general_ci, *pos))
 
236
      while (pos < end && not my_charset_utf8_general_ci.isspace(*pos))
237
237
        pos++;
238
 
      while (pos < end && !my_isdigit(&my_charset_utf8_general_ci, *pos))
 
238
      while (pos < end && not my_charset_utf8_general_ci.isdigit(*pos))
239
239
        pos++;
240
240
      if (pos == end)
241
241
      {
269
269
  not_zero_date= 0;
270
270
  for (i = start_loop;
271
271
       i < MAX_DATE_PARTS-1 && str != end &&
272
 
         my_isdigit(&my_charset_utf8_general_ci,*str);
 
272
         my_charset_utf8_general_ci.isdigit(*str);
273
273
       i++)
274
274
  {
275
275
    const char *start= str;
276
276
    uint32_t tmp_value= (uint32_t) (unsigned char) (*str++ - '0');
277
 
    while (str != end && my_isdigit(&my_charset_utf8_general_ci,str[0]) &&
 
277
    while (str != end && my_charset_utf8_general_ci.isdigit(str[0]) &&
278
278
           (!is_internal_format || --field_length))
279
279
    {
280
280
      tmp_value=tmp_value*10 + (uint32_t) (unsigned char) (*str - '0');
313
313
      continue;
314
314
    }
315
315
    while (str != end &&
316
 
           (my_ispunct(&my_charset_utf8_general_ci,*str) ||
317
 
            my_isspace(&my_charset_utf8_general_ci,*str)))
 
316
           (my_charset_utf8_general_ci.ispunct(*str) ||
 
317
            my_charset_utf8_general_ci.isspace(*str)))
318
318
    {
319
 
      if (my_isspace(&my_charset_utf8_general_ci,*str))
 
319
      if (my_charset_utf8_general_ci.isspace(*str))
320
320
      {
321
321
        if (!(allow_space & (1 << i)))
322
322
        {
342
342
            continue;                           /* Not AM/PM */
343
343
          str+= 2;                              /* Skip AM/PM */
344
344
          /* Skip space after AM/PM */
345
 
          while (str != end && my_isspace(&my_charset_utf8_general_ci,*str))
 
345
          while (str != end && my_charset_utf8_general_ci.isspace(*str))
346
346
            str++;
347
347
        }
348
348
      }
425
425
      {
426
426
        for (; str != end ; str++)
427
427
        {
428
 
          if (!my_isspace(&my_charset_utf8_general_ci, *str))
 
428
          if (not my_charset_utf8_general_ci.isspace(*str))
429
429
          {
430
430
            not_zero_date= 1;                     /* Give warning */
431
431
            break;
446
446
 
447
447
    for (; str != end ; str++)
448
448
    {
449
 
      if (!my_isspace(&my_charset_utf8_general_ci,*str))
 
449
      if (not my_charset_utf8_general_ci.isspace(*str))
450
450
      {
451
451
        was_cut= type::CUT;
452
452
        break;
504
504
 
505
505
  this->neg=0;
506
506
  warning= 0;
507
 
  for (; str != end && my_isspace(&my_charset_utf8_general_ci,*str) ; str++)
 
507
  for (; str != end && my_charset_utf8_general_ci.isspace(*str) ; str++)
508
508
    length--;
509
509
  if (str != end && *str == '-')
510
510
  {
530
530
  }
531
531
 
532
532
  /* Not a timestamp. Try to get this as a DAYS_TO_SECOND string */
533
 
  for (value=0; str != end && my_isdigit(&my_charset_utf8_general_ci,*str) ; str++)
 
533
  for (value=0; str != end && my_charset_utf8_general_ci.isdigit(*str) ; str++)
534
534
    value=value*10L + (long) (*str - '0');
535
535
 
536
536
  /* Skip all space after 'days' */
537
537
  end_of_days= str;
538
 
  for (; str != end && my_isspace(&my_charset_utf8_general_ci, str[0]) ; str++)
 
538
  for (; str != end && my_charset_utf8_general_ci.isspace(str[0]) ; str++)
539
539
    ;
540
540
 
541
541
  found_days=found_hours=0;
542
542
  if ((uint32_t) (end-str) > 1 && str != end_of_days &&
543
 
      my_isdigit(&my_charset_utf8_general_ci, *str))
 
543
      my_charset_utf8_general_ci.isdigit(*str))
544
544
  {                                             /* Found days part */
545
545
    date[0]= (uint32_t) value;
546
546
    state= 1;                                   /* Assume next is hours */
547
547
    found_days= 1;
548
548
  }
549
549
  else if ((end-str) > 1 &&  *str == time_separator &&
550
 
           my_isdigit(&my_charset_utf8_general_ci, str[1]))
 
550
           my_charset_utf8_general_ci.isdigit(str[1]))
551
551
  {
552
552
    date[0]= 0;                                 /* Assume we found hours */
553
553
    date[1]= (uint32_t) value;
569
569
  /* Read hours, minutes and seconds */
570
570
  for (;;)
571
571
  {
572
 
    for (value=0; str != end && my_isdigit(&my_charset_utf8_general_ci,*str) ; str++)
 
572
    for (value=0; str != end && my_charset_utf8_general_ci.isdigit(*str) ; str++)
573
573
      value=value*10L + (long) (*str - '0');
574
574
    date[state++]= (uint32_t) value;
575
575
    if (state == 4 || (end-str) < 2 || *str != time_separator ||
576
 
        !my_isdigit(&my_charset_utf8_general_ci,str[1]))
 
576
        !my_charset_utf8_general_ci.isdigit(str[1]))
577
577
      break;
578
578
    str++;                                      /* Skip time_separator (':') */
579
579
  }
593
593
 
594
594
fractional:
595
595
  /* Get fractional second part */
596
 
  if ((end-str) >= 2 && *str == '.' && my_isdigit(&my_charset_utf8_general_ci,str[1]))
 
596
  if ((end-str) >= 2 && *str == '.' && my_charset_utf8_general_ci.isdigit(str[1]))
597
597
  {
598
598
    int field_length= 5;
599
599
    str++; value=(uint32_t) (unsigned char) (*str - '0');
600
 
    while (++str != end && my_isdigit(&my_charset_utf8_general_ci, *str))
 
600
    while (++str != end && my_charset_utf8_general_ci.isdigit(*str))
601
601
    {
602
602
      if (field_length-- > 0)
603
603
        value= value*10 + (uint32_t) (unsigned char) (*str - '0');
622
622
  /* (may occur as result of %g formatting of time value) */
623
623
  if ((end - str) > 1 &&
624
624
      (*str == 'e' || *str == 'E') &&
625
 
      (my_isdigit(&my_charset_utf8_general_ci, str[1]) ||
 
625
      (my_charset_utf8_general_ci.isdigit(str[1]) ||
626
626
       ((str[1] == '-' || str[1] == '+') &&
627
627
        (end - str) > 2 &&
628
 
        my_isdigit(&my_charset_utf8_general_ci, str[2]))))
 
628
        my_charset_utf8_general_ci.isdigit(str[2]))))
629
629
    return 1;
630
630
 
631
631
  if (internal_format_positions[7] != 255)
632
632
  {
633
633
    /* Read a possible AM/PM */
634
 
    while (str != end && my_isspace(&my_charset_utf8_general_ci, *str))
 
634
    while (str != end && my_charset_utf8_general_ci.isspace(*str))
635
635
      str++;
636
636
    if (str+2 <= end && (str[1] == 'M' || str[1] == 'm'))
637
637
    {
671
671
  {
672
672
    do
673
673
    {
674
 
      if (!my_isspace(&my_charset_utf8_general_ci,*str))
 
674
      if (not my_charset_utf8_general_ci.isspace(*str))
675
675
      {
676
676
        warning|= DRIZZLE_TIME_WARN_TRUNCATED;
677
677
        break;