FreeBSD/sys/ddb/db_command.c
/*
 * Helper function to match a single command.
 */
Helper function to match a single command.
Helper function to match a single command .
static void
db_cmd_match(char *name, struct command *cmd, struct command **cmdp,
    int *resultp)
{
	char *lp, *rp;
	int c;
	lp = name;
	rp = cmd->name;
	while ((c = *lp) == *rp) {
		if (c == 0) {
			*cmdp = cmd;
			*resultp = CMD_UNIQUE;
			return;
		}
		lp++;
		rp++;
	}
	if (c == 0) {
		if (*resultp == CMD_FOUND) {
			*resultp = CMD_AMBIGUOUS;
		} else {
			*cmdp = cmd;
			*resultp = CMD_FOUND;
		}
	}
}
static void db_cmd_match ( char * name , struct command * cmd , struct command * * cmdp , int * resultp ) { char * lp , * rp ; int c ; lp = name ; rp = cmd -> name ; while ( ( c = * lp ) == * rp ) { if ( c == 0 ) { * cmdp = cmd ; * resultp = CMD_UNIQUE ; return ; } lp ++ ; rp ++ ; } if ( c == 0 ) { if ( * resultp == CMD_FOUND ) { * resultp = CMD_AMBIGUOUS ; } else { * cmdp = cmd ; * resultp = CMD_FOUND ; } } }
Helper function to match a single command.
Helper function to match a single command .
/* complete match */ /* end of name, not end of command -
		   partial match */ /* but keep looking for a full match -
			   this lets us match single letters */