MCPcopy Create free account
hub / github.com/gwsw/less / mca_opt_char

Function mca_opt_char

command.c:439–501  ·  view source on GitHub ↗

* Handle a char of an option toggle command. */

(c)

Source from the content-addressed store, hash-verified

437 * Handle a char of an option toggle command.
438 */
439 static int
440mca_opt_char(c)
441 int c;
442{
443 PARG parg;
444
445 /*
446 * This may be a short option (single char),
447 * or one char of a long option name,
448 * or one char of the option parameter.
449 */
450 if (curropt == NULL && len_cmdbuf() == 0)
451 {
452 int ret = mca_opt_first_char(c);
453 if (ret != NO_MCA)
454 return (ret);
455 }
456 if (optgetname)
457 {
458 /* We're getting a long option name. */
459 if (!is_newline_char(c))
460 return (mca_opt_nonfirst_char(c));
461 if (curropt == NULL)
462 {
463 parg.p_string = get_cmdbuf();
464 error("There is no --%s option", &parg);
465 return (MCA_DONE);
466 }
467 optgetname = FALSE;
468 cmd_reset();
469 } else
470 {
471 if (is_erase_char(c))
472 return (NO_MCA);
473 if (curropt != NULL)
474 /* We're getting the option parameter. */
475 return (NO_MCA);
476 curropt = findopt(c);
477 if (curropt == NULL)
478 {
479 parg.p_string = propt(c);
480 error("There is no %s option", &parg);
481 return (MCA_DONE);
482 }
483 opt_lower = ASCII_IS_LOWER(c);
484 }
485 /*
486 * If the option which was entered does not take a
487 * parameter, toggle the option immediately,
488 * so user doesn't have to hit RETURN.
489 */
490 if ((optflag & ~OPT_NO_PROMPT) != OPT_TOGGLE ||
491 !opt_has_param(curropt))
492 {
493 toggle_option(curropt, opt_lower, "", optflag);
494 return (MCA_DONE);
495 }
496 /*

Callers 1

mca_charFunction · 0.85

Calls 12

len_cmdbufFunction · 0.85
mca_opt_first_charFunction · 0.85
is_newline_charFunction · 0.85
mca_opt_nonfirst_charFunction · 0.85
get_cmdbufFunction · 0.85
cmd_resetFunction · 0.85
is_erase_charFunction · 0.85
opt_has_paramFunction · 0.85
toggle_optionFunction · 0.85
start_mcaFunction · 0.85
opt_promptFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…