deps/kb_meme/meme-5.0.1/src/meme-sax.c
/*****************************************************************************
 * At the start of a new element check that all previous expected elements
 * have been found and that the current element hasn't been repeated too 
 * many times.
 ****************************************************************************/
At the start of a new element check that all previous expected elements
have been found and that the current element hasn't been repeated too
many times.
At the start of a new element check that all previous expected elements have been found and that the current element hasn ' t been repeated too many times .
int meme_update_es(PS_T *ps, PS_EN next_state) {
  ES_T *es, old_es;
  if (next_state < PS_ERROR ||  next_state > PS_END) {
    die("Bad state code!\n");
  }
  while ((es = (ES_T*)linklst_pop(ps->expected_stack)) != NULL && es->state != next_state) {
    old_es = *es;
    free(es);
    es = NULL;
    switch (old_es.expected) {
      case ES_ONCE:
      case ES_ONE_OR_MORE:
        if (old_es.found < 1) {
          error(ps, "Expected state %s not found!\n", state_names[old_es.state]);
          return false;
        }
    }
  }
  if (es != NULL) {
    es->found += 1;
    linklst_push(es, ps->expected_stack);
    switch (es->expected) {
      case ES_ONCE:
      case ES_ZERO_OR_ONE:
        if (es->found > 1) {
          error(ps, "Expected state %s only once!\n", state_names[es->state]);
          return false;
        }
      default:
        break;
    }
  } else {
    error(ps, "The state %s was not expected!\n", state_names[next_state]);
    return false;
  }
  return true;
}
int meme_update_es ( PS_T * ps , PS_EN next_state ) { ES_T * es , old_es ; if ( next_state < PS_ERROR || next_state > PS_END ) { die ( " \n " ) ; } while ( ( es = ( ES_T * ) linklst_pop ( ps -> expected_stack ) ) != NULL && es -> state != next_state ) { old_es = * es ; free ( es ) ; es = NULL ; switch ( old_es . expected ) { case ES_ONCE : case ES_ONE_OR_MORE : if ( old_es . found < 1 ) { error ( ps , " \n " , state_names [ old_es . state ] ) ; return false ; } } } if ( es != NULL ) { es -> found += 1 ; linklst_push ( es , ps -> expected_stack ) ; switch ( es -> expected ) { case ES_ONCE : case ES_ZERO_OR_ONE : if ( es -> found > 1 ) { error ( ps , " \n " , state_names [ es -> state ] ) ; return false ; } default : break ; } } else { error ( ps , " \n " , state_names [ next_state ] ) ; return false ; } return true ; }
At the start of a new element check that all previous expected elements
 have been found and that the current element hasn't been repeated too
 many times.
At the start of a new element check that all previous expected elements have been found and that the current element hasn ' t been repeated too many times .