FreeBSD/contrib/subversion/subversion/libsvn_subr/date.c
/* Attempt to match the date-string in VALUE to the provided TEMPLATE,
   using the rules defined above.  Return TRUE on successful match,
   FALSE otherwise.  On successful match, fill in *EXP with the
   matched values and set *LOCALTZ to TRUE if the local time zone
   should be used to interpret the match (i.e. if no time zone
   information was provided), or FALSE if not. */
Attempt to match the date-string in VALUE to the provided TEMPLATE,
using the rules defined above.  Return TRUE on successful match,
FALSE otherwise.  On successful match, fill in *EXP with the
matched values and set *LOCALTZ to TRUE if the local time zone
should be used to interpret the match , or FALSE if not.
Attempt to match the date - string in VALUE to the provided TEMPLATE using the rules defined above . Return TRUE on successful match FALSE otherwise . On successful match fill in * EXP with the matched values and set * LOCALTZ to TRUE if the local time zone should be used to interpret the match or FALSE if not .
static svn_boolean_t
template_match(apr_time_exp_t *expt, svn_boolean_t *localtz,
               const char *template, const char *value)
{
  int multiplier = 100000;
  int tzind = 0;
  match_state ms;
  char *base = (char *)&ms;
  memset(&ms, 0, sizeof(ms));
  for (;;)
    {
      const rule *match = find_rule(*template++);
      char vchar = *value++;
      apr_int32_t *place;
      if (!match || (match->valid
                     && (!vchar || !strchr(match->valid, vchar))))
        return FALSE;
      place = (apr_int32_t *)(base + match->offset);
      switch (match->action)
        {
        case ACCUM:
          *place = *place * 10 + vchar - '0';
          continue;
        case MICRO:
          *place += (vchar - '0') * multiplier;
          multiplier /= 10;
          continue;
        case TZIND:
          tzind = vchar;
          continue;
        case SKIP:
          value--;
          continue;
        case NOOP:
          continue;
        case SKIPFROM:
          if (!vchar)
            break;
          match = find_rule(*template);
          if (!strchr(match->valid, vchar))
            template = strchr(template, ']') + 1;
          value--;
          continue;
        case ACCEPT:
          if (vchar)
            return FALSE;
          break;
        }
      break;
    }
  if (ms.offhours > 23 || ms.offminutes > 59)
    return FALSE;
  switch (tzind)
    {
    case '+':
      ms.base.tm_gmtoff = ms.offhours * 3600 + ms.offminutes * 60;
      break;
    case '-':
      ms.base.tm_gmtoff = -(ms.offhours * 3600 + ms.offminutes * 60);
      break;
    }
  *expt = ms.base;
  *localtz = (tzind == 0);
  return TRUE;
}
static svn_boolean_t template_match ( apr_time_exp_t * expt , svn_boolean_t * localtz , const char * template , const char * value ) { int multiplier = 100000 ; int tzind = 0 ; match_state ms ; char * base = ( char * ) & ms ; memset ( & ms , 0 , sizeof ( ms ) ) ; for ( ; ; ) { const rule * match = find_rule ( * template ++ ) ; char vchar = * value ++ ; apr_int32_t * place ; if ( ! match || ( match -> valid && ( ! vchar || ! strchr ( match -> valid , vchar ) ) ) ) return FALSE ; place = ( apr_int32_t * ) ( base + match -> offset ) ; switch ( match -> action ) { case ACCUM : * place = * place * 10 + vchar - ' ' ; continue ; case MICRO : * place += ( vchar - ' ' ) * multiplier ; multiplier /= 10 ; continue ; case TZIND : tzind = vchar ; continue ; case SKIP : value -- ; continue ; case NOOP : continue ; case SKIPFROM : if ( ! vchar ) break ; match = find_rule ( * template ) ; if ( ! strchr ( match -> valid , vchar ) ) template = strchr ( template , ' ' ) + 1 ; value -- ; continue ; case ACCEPT : if ( vchar ) return FALSE ; break ; } break ; } if ( ms . offhours > 23 || ms . offminutes > 59 ) return FALSE ; switch ( tzind ) { case ' ' : ms . base . tm_gmtoff = ms . offhours * 3600 + ms . offminutes * 60 ; break ; case ' ' : ms . base . tm_gmtoff = - ( ms . offhours * 3600 + ms . offminutes * 60 ) ; break ; } * expt = ms . base ; * localtz = ( tzind == 0 ) ; return TRUE ; }
Attempt to match the date-string in VALUE to the provided TEMPLATE,
using the rules defined above.
Attempt to match the date - string in VALUE to the provided TEMPLATE using the rules defined above .
/* Compute the address of memory location affected by this
         rule by adding match->offset bytes to the address of ms.
         Because this is a byte-quantity, it is necessary to cast
         &ms to char *. */ /* Validate gmt offset here, since we can't reliably do it later. */ /* tzind will be '+' or '-' for an explicit time zone, 'Z' to
     indicate UTC, or 0 to indicate local time. */