void Excn::SystemInterface::parse_step_option(const char *tokens)
{
  //: The defined formats for the count attribute are:<br>
  //:  <ul>
  //:    <li><missing> -- default -- 1 <= count <= oo  (all steps)</li>
  //:    <li>"X"                  -- X <= count <= X  (just step X) LAST for last step.</li>
  //:    <li>"X:Y"                -- X to Y by 1</li>
  //:    <li>"X:"                 -- X to oo by 1</li>
  //:    <li>":Y"                 -- 1 to Y by 1</li>
  //:    <li>"::Z"                -- 1 to oo by Z</li>
  //:  </ul>
  //: The count and step must always be >= 0

  // Break into tokens separated by ":"

  // Default is given in constructor above...

  if (tokens != nullptr) {
    if (strchr(tokens, ':') != nullptr) {
      // The string contains a separator

      int vals[3];
      vals[0] = stepMin_;
      vals[1] = stepMax_;
      vals[2] = stepInterval_;

      int j = 0;
      for (auto &val : vals) {
        // Parse 'i'th field
        char tmp_str[128];
        ;
        int k = 0;

        while (tokens[j] != '\0' && tokens[j] != ':') {
          tmp_str[k++] = tokens[j++];
        }

        tmp_str[k] = '\0';
        if (strlen(tmp_str) > 0)
          val = strtoul(tmp_str, nullptr, 0);

        if (tokens[j++] == '\0') {
          break; // Reached end of string
        }
      }
      stepMin_      = abs(vals[0]);
      stepMax_      = abs(vals[1]);
      stepInterval_ = abs(vals[2]);
    }
    else if (case_strcmp("LAST", tokens) == 0) {
      stepMin_ = stepMax_ = -1;
    }
    else {
      // Does not contain a separator, min == max
      stepMin_ = stepMax_ = strtol(tokens, nullptr, 0);
    }
  }
}
Exemple #2
0
const struct keyword *
in_word_set(register const char *str, register int len)
{

    static const struct keyword wordlist[] =
    {
	{"",},
	{"",},
	{"",},
	{"for", DBV_Prehistory, tFOR},
	{"",},
	{"endif", DBV_Prehistory, tENDIF},
	{"endfor", DBV_Prehistory, tENDFOR},
	{"e_range", DBV_Prehistory, tERROR, E_RANGE},
	{"endwhile", DBV_Prehistory, tENDWHILE},
	{"e_recmove", DBV_Prehistory, tERROR, E_RECMOVE},
	{"",},
	{"e_none", DBV_Prehistory, tERROR, E_NONE},
	{"",},
	{"e_propnf", DBV_Prehistory, tERROR, E_PROPNF},
	{"fork", DBV_Prehistory, tFORK},
	{"break", DBV_BreakCont, tBREAK},
	{"endtry", DBV_Exceptions, tENDTRY},
	{"endfork", DBV_Prehistory, tENDFORK},
	{"",},
	{"",},
	{"",},
	{"",},
	{"finally", DBV_Exceptions, tFINALLY},
	{"",},
	{"",},
	{"",},
	{"",},
	{"e_quota", DBV_Prehistory, tERROR, E_QUOTA},
	{"",},
	{"else", DBV_Prehistory, tELSE},
	{"",},
	{"elseif", DBV_Prehistory, tELSEIF},
	{"",},
	{"any", DBV_Exceptions, tANY},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"e_div", DBV_Prehistory, tERROR, E_DIV},
	{"e_args", DBV_Prehistory, tERROR, E_ARGS},
	{"e_varnf", DBV_Prehistory, tERROR, E_VARNF},
	{"e_verbnf", DBV_Prehistory, tERROR, E_VERBNF},
	{"",},
	{"",},
	{"e_perm", DBV_Prehistory, tERROR, E_PERM},
	{"if", DBV_Prehistory, tIF},
	{"",},
	{"",},
	{"",},
	{"",},
	{"in", DBV_Prehistory, tIN},
	{"e_invind", DBV_Prehistory, tERROR, E_INVIND},
	{"",},
	{"while", DBV_Prehistory, tWHILE},
	{"e_nacc", DBV_Prehistory, tERROR, E_NACC},
	{"",},
	{"continue", DBV_BreakCont, tCONTINUE},
	{"",},
	{"",},
	{"e_type", DBV_Prehistory, tERROR, E_TYPE},
	{"e_float", DBV_Float, tERROR, E_FLOAT},
	{"e_invarg", DBV_Prehistory, tERROR, E_INVARG},
	{"",},
	{"",},
	{"return", DBV_Prehistory, tRETURN},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"try", DBV_Exceptions, tTRY},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"e_maxrec", DBV_Prehistory, tERROR, E_MAXREC},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"",},
	{"except", DBV_Exceptions, tEXCEPT},
    };

    if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) {
	register int key = hash(str, len);

	if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE) {
	    register const char *s = wordlist[key].name;

	    if (*s == tolower(*str) && !case_strcmp(str + 1, s + 1))
		return &wordlist[key];
	}
    }
    return 0;
}