36 #if !defined(lint) && !defined(SCCSID)
38 static char sccsid[] =
"@(#)parse.c 8.1 (Berkeley) 6/4/93";
59 private const struct {
61 int (*func)(
EditLine *, int,
const Char **);
63 { STR(
"bind"), map_bind },
64 { STR(
"echotc"), terminal_echotc },
65 { STR(
"edit"), el_editmode },
66 { STR(
"history"), hist_command },
67 { STR(
"telltc"), terminal_telltc },
68 { STR(
"settc"), terminal_settc },
69 { STR(
"setty"), tty_stty },
78 parse_line(
EditLine *el,
const Char *line)
84 tok = FUN(tok,init)(NULL);
85 FUN(tok,str)(tok, line, &argc, &argv);
86 argc = FUN(el,
parse)(el, argc, argv);
103 ptr = Strchr(argv[0],
':');
110 l = (size_t)(ptr - argv[0] - 1);
111 tprog = el_malloc((l + 1) *
sizeof(*tprog));
114 (void) Strncpy(tprog, argv[0], l);
117 l = (size_t)el_match(el->el_prog, tprog);
124 for (i = 0; cmds[
i].name != NULL; i++)
125 if (Strcmp(cmds[i].
name, ptr) == 0) {
126 i = (*cmds[
i].func) (el, argc, argv);
138 parse__escape(
const Char **ptr)
178 const Char hex[] = STR(
"0123456789ABCDEF");
184 for (i = 0; i < 5; ++
i) {
185 h = Strchr(hex, *p++);
189 c = (c << 4) | ((
int)(h - hex));
208 for (cnt = 0, c = 0; cnt < 3; cnt++) {
210 if (ch < '0' || ch >
'7') {
214 c = (c << 3) | (ch -
'0');
216 if ((c & (wint_t)0xffffff00) != (wint_t)0)
225 }
else if (*p ==
'^') {
227 c = (*p ==
'?') ?
'\177' : (*p & 0237);
238 parse__string(Char *out,
const Char *in)
251 if ((n = parse__escape(&in)) == -1)
257 if (in[1] ==
'-' && in[2] !=
'\0') {
276 parse_cmd(
EditLine *el,
const Char *cmd)
280 for (b = el->el_map.help; b->name != NULL; b++)
281 if (Strcmp(b->name, cmd) == 0)