Example #1
0
/* Get a command and return its index. */
int get_command ()
{
    int		i, cmd_n;
    char	c, cmd_s[4];


    skip_junk();
    if (end_of_file)
	return -1;

    c = *input_line_pointer;
    /* Get first three characters of command word. */
    for (i = 0; i < 3; i++)
    {
	if (! isalpha (c)) return 0;
	cmd_s[i] = toupper (c);
	++input_line_pointer;
	c = *input_line_pointer;
    }
    cmd_s[3] = '\0';

    /* Skip everything after third character of command word. */
    while (1)
    {
	switch (c)
	{
	    case '\t':
	    case '\n':
	    case ' ':
	    case ',':
	    case ';':
		goto find_cmd;

	    default:
		++input_line_pointer;
		c = *input_line_pointer;
	}
    }

  find_cmd:

    /* Find corresponding string in list. */
    cmd_n = UNKNOWN;
    for (i = 1; i < NUM_COMMANDS; i++)
    {
	if (strcmp(cmd_s, command_abbr[i]) == 0)
	{
	    cmd_n = i;
	    break;
	}
    }

    return cmd_n;
}
Example #2
0
/* get the next token */
static char *get_next_token(void)
{
    skip_junk(0);
    if(!pos) {
	token_length = 0;
	token = 0;
	return 0;
    }
    token = pos;
    token_length = strcspn(token, " \t\n#:=");
    pos += token_length;
    return token;
}