MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_cmd_match

Function db_cmd_match

freebsd/ddb/db_command.c:270–301  ·  view source on GitHub ↗

* Helper function to match a single command. */

Source from the content-addressed store, hash-verified

268 * Helper function to match a single command.
269 */
270static void
271db_cmd_match(char *name, struct command *cmd, struct command **cmdp,
272 int *resultp)
273{
274 char *lp, *rp;
275 int c;
276
277 lp = name;
278 rp = cmd->name;
279 while ((c = *lp) == *rp) {
280 if (c == 0) {
281 /* complete match */
282 *cmdp = cmd;
283 *resultp = CMD_UNIQUE;
284 return;
285 }
286 lp++;
287 rp++;
288 }
289 if (c == 0) {
290 /* end of name, not end of command -
291 partial match */
292 if (*resultp == CMD_FOUND) {
293 *resultp = CMD_AMBIGUOUS;
294 /* but keep looking for a full match -
295 this lets us match single letters */
296 } else {
297 *cmdp = cmd;
298 *resultp = CMD_FOUND;
299 }
300 }
301}
302
303/*
304 * Search for command prefix.

Callers 1

db_cmd_searchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected