Lines Matching +full:cmd +full:- +full:max +full:- +full:name
3 /*-
70 /* readline compatibility stuff - look at readline sources/documentation */
215 if (i == -1) in _getc_function()
228 *ap = li->buffer; in _resize_fun()
244 len = strlen(p->pw_dir) + sizeof("/.history"); in _default_history_file()
248 (void)snprintf(path, len, "%s/.history", p->pw_dir); in _default_history_file()
272 return -1; in rl_set_prompt()
275 /* Remove adjacent end/start markers to avoid double-escapes. */ in rl_set_prompt()
326 if (tcgetattr(fileno(rl_instream), &t) != -1 && (t.c_lflag & ECHO) == 0) in rl_initialize()
338 return -1; in rl_initialize()
353 if (rl_set_prompt("") == -1) { in rl_initialize()
356 return -1; in rl_initialize()
361 /* set default mode to "emacs"-style and read setting afterwards */ in rl_initialize()
370 * Word completion - this has to go AFTER rebinding keys in rl_initialize()
371 * to emacs-style. in rl_initialize()
387 * Set some readline compatible key-bindings. in rl_initialize()
389 el_set(e, EL_BIND, "^R", "em-inc-search-prev", NULL); in rl_initialize()
394 el_set(e, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL); in rl_initialize()
395 el_set(e, EL_BIND, "\\e[4~", "ed-move-to-end", NULL); in rl_initialize()
396 el_set(e, EL_BIND, "\\e[7~", "ed-move-to-beg", NULL); in rl_initialize()
397 el_set(e, EL_BIND, "\\e[8~", "ed-move-to-end", NULL); in rl_initialize()
398 el_set(e, EL_BIND, "\\e[H", "ed-move-to-beg", NULL); in rl_initialize()
399 el_set(e, EL_BIND, "\\e[F", "ed-move-to-end", NULL); in rl_initialize()
404 el_set(e, EL_BIND, "\\e[3~", "ed-delete-next-char", NULL); in rl_initialize()
405 el_set(e, EL_BIND, "\\e[2~", "em-toggle-overwrite", NULL); in rl_initialize()
408 * Ctrl-left-arrow and Ctrl-right-arrow for word moving. in rl_initialize()
410 el_set(e, EL_BIND, "\\e[1;5C", "em-next-word", NULL); in rl_initialize()
411 el_set(e, EL_BIND, "\\e[1;5D", "ed-prev-word", NULL); in rl_initialize()
412 el_set(e, EL_BIND, "\\e[5C", "em-next-word", NULL); in rl_initialize()
413 el_set(e, EL_BIND, "\\e[5D", "ed-prev-word", NULL); in rl_initialize()
414 el_set(e, EL_BIND, "\\e\\e[C", "em-next-word", NULL); in rl_initialize()
415 el_set(e, EL_BIND, "\\e\\e[D", "ed-prev-word", NULL); in rl_initialize()
461 if (rl_set_prompt(prompt) == -1) in readline()
467 if (rl_event_hook && !(e->el_flags & NO_TTY)) { in readline()
488 lastidx = count - 1; in readline()
540 len += with_len - what_len; in _rl_compat_sub()
571 get_history_event(const char *cmd, int *cindex, int qchar) in get_history_event() argument
580 if (cmd[idx++] != history_expansion_char) in get_history_event()
584 if (cmd[idx] == history_expansion_char || cmd[idx] == '\0') { in get_history_event()
587 *cindex = cmd[idx]? (idx + 1):idx; in get_history_event()
591 if (cmd[idx] == '-') { in get_history_event()
596 if ('0' <= cmd[idx] && cmd[idx] <= '9') { in get_history_event()
600 while (cmd[idx] && '0' <= cmd[idx] && cmd[idx] <= '9') { in get_history_event()
601 num = num * 10 + cmd[idx] - '0'; in get_history_event()
605 num = history_length - num + history_base; in get_history_event()
611 return he->line; in get_history_event()
614 if (cmd[idx] == '?') { in get_history_event()
619 while (cmd[idx]) { in get_history_event()
620 if (cmd[idx] == '\n') in get_history_event()
622 if (sub && cmd[idx] == '?') in get_history_event()
624 if (!sub && (cmd[idx] == ':' || cmd[idx] == ' ' in get_history_event()
625 || cmd[idx] == '\t' || cmd[idx] == qchar)) in get_history_event()
629 len = (size_t)idx - (size_t)begin; in get_history_event()
630 if (sub && cmd[idx] == '?') in get_history_event()
639 (void)strlcpy(pat, cmd + begin, len + 1); in get_history_event()
654 ret = history_search(pat, -1); in get_history_event()
656 ret = history_search_prefix(pat, -1); in get_history_event()
658 if (ret == -1) { in get_history_event()
691 const char *cmd = *cmdp; in getfrom() local
698 for (; *cmd && *cmd != delim; cmd++) { in getfrom()
699 if (*cmd == '\\' && cmd[1] == delim) in getfrom()
700 cmd++; in getfrom()
701 if (len - 1 >= size) { in getfrom()
707 *cmdp = cmd; in getfrom()
713 what[len++] = *cmd; in getfrom()
717 *cmdp = cmd; in getfrom()
727 return -1; in getfrom()
730 if (!*cmd) { in getfrom()
733 return -1; in getfrom()
736 cmd++; /* shift after delim */ in getfrom()
737 *cmdp = cmd; in getfrom()
739 if (!*cmd) { in getfrom()
742 return -1; in getfrom()
753 const char *cmd = *cmdp; in getto() local
759 for (; *cmd && *cmd != delim; cmd++) { in getto()
768 if (*cmd == '&') { in getto()
774 if (*cmd == '\\' && (*(cmd + 1) == delim || *(cmd + 1) == '&')) in getto()
775 cmd++; in getto()
776 with[len++] = *cmd; in getto()
778 if (!*cmd) in getto()
782 *cmdp = cmd; in getto()
788 *cmdp = cmd; in getto()
789 return -1; in getto()
804 * the real function doing history expansion - takes as argument command
810 * returns -1 and *result points to NULL
818 const char *ptr, *cmd; in _history_expand_command() local
847 return -1; in _history_expand_command()
853 qchar = (offs > 0 && command[offs - 1] == '"') in _history_expand_command()
861 return -1; in _history_expand_command()
868 return -1; in _history_expand_command()
872 cmd = command + offs + idx + 1; in _history_expand_command()
876 if (*cmd == '%') /* last word matched by ?pat? */ in _history_expand_command()
878 else if (strchr("^*$-0123456789", *cmd)) { in _history_expand_command()
879 start = end = -1; in _history_expand_command()
880 if (*cmd == '^') in _history_expand_command()
881 start = end = 1, cmd++; in _history_expand_command()
882 else if (*cmd == '$') in _history_expand_command()
883 start = -1, cmd++; in _history_expand_command()
884 else if (*cmd == '*') in _history_expand_command()
885 start = 1, cmd++; in _history_expand_command()
886 else if (*cmd == '-' || isdigit((unsigned char) *cmd)) { in _history_expand_command()
888 while (*cmd && '0' <= *cmd && *cmd <= '9') in _history_expand_command()
889 start = start * 10 + *cmd++ - '0'; in _history_expand_command()
891 if (*cmd == '-') { in _history_expand_command()
892 if (isdigit((unsigned char) cmd[1])) { in _history_expand_command()
893 cmd++; in _history_expand_command()
895 while (*cmd && '0' <= *cmd && *cmd <= '9') in _history_expand_command()
896 end = end * 10 + *cmd++ - '0'; in _history_expand_command()
897 } else if (cmd[1] == '$') { in _history_expand_command()
898 cmd += 2; in _history_expand_command()
899 end = -1; in _history_expand_command()
901 cmd++; in _history_expand_command()
902 end = -2; in _history_expand_command()
904 } else if (*cmd == '*') in _history_expand_command()
905 end = -1, cmd++; in _history_expand_command()
915 return -1; in _history_expand_command()
923 if (*cmd == '\0' || ((size_t)(cmd - (command + offs)) >= cmdlen)) { in _history_expand_command()
928 for (; *cmd; cmd++) { in _history_expand_command()
929 switch (*cmd) { in _history_expand_command()
957 ev = -1; in _history_expand_command()
958 delim = *++cmd; in _history_expand_command()
959 if (delim == '\0' || *++cmd == '\0') in _history_expand_command()
961 if ((ev = getfrom(&cmd, &from, search, delim)) != 1) in _history_expand_command()
963 if ((ev = getto(&cmd, &to, from, delim)) != 1) in _history_expand_command()
971 cmd--; in _history_expand_command()
985 * csh-style history expansion
1068 qchar = (j > 0 && str[j - 1] == '"' )? '"':0; in history_expand()
1075 len = i - start; in history_expand()
1079 len = j - i; in history_expand()
1087 ret = _history_expand_command (str, i, (j - i), &tmp); in history_expand()
1104 /* history_expand() returned -1 when the line */ in history_expand()
1107 ret = -1; in history_expand()
1122 size_t i, len, max; in history_arg_extract() local
1131 for (max = 0; arr[max]; max++) in history_arg_extract()
1133 max--; in history_arg_extract()
1136 start = (int)max; in history_arg_extract()
1138 end = (int)max; in history_arg_extract()
1140 end = (int)max + end + 1; in history_arg_extract()
1144 if (start < 0 || end < 0 || (size_t)start > max || in history_arg_extract()
1145 (size_t)end > max || start > end) in history_arg_extract()
1212 len = (size_t)i - (size_t)start; in history_tokenize()
1231 * limit size of history record to ``max'' events
1234 stifle_history(int max) in stifle_history() argument
1242 if (history(h, &ev, H_SETSIZE, max) == 0) { in stifle_history()
1243 max_input_history = max; in stifle_history()
1244 if (history_length > max) in stifle_history()
1245 history_base = history_length - max; in stifle_history()
1246 while (history_length > max) { in stifle_history()
1248 el_free(he->data); in stifle_history()
1249 el_free((void *)(unsigned long)he->line); in stifle_history()
1257 * "unlimit" size of history - set the limit to maximum allowed int value
1300 if ((fd = mkstemp(template)) == -1) { in history_truncate_file()
1318 (off_t)-1) { in history_truncate_file()
1328 count--; in history_truncate_file()
1346 cp = buf + left - 1; in history_truncate_file()
1350 while (--cp >= buf) { in history_truncate_file()
1352 if (--nlines == 0) { in history_truncate_file()
1363 count--; in history_truncate_file()
1382 if (fseeko(fp, (off_t)0, SEEK_SET) == (off_t)-1) { in history_truncate_file()
1387 if (fseeko(tp, (off_t)sizeof(buf) * count + (cp - buf), SEEK_SET) == in history_truncate_file()
1388 (off_t)-1) { in history_truncate_file()
1431 if (history(h, &ev, H_LOAD, filename) == -1) in read_history()
1453 return history(h, &ev, H_SAVE, filename) == -1 ? in write_history()
1471 if (history(h, &ev, H_NSAVE_FP, (size_t)n, fp) == -1) { in append_history()
1505 * (void **)-1 -- as in history_set_pos in history_get()
1507 if (history(h, &ev, H_DELDATA, num - history_base, (void **)-1) != 0) in history_get()
1540 if (history(h, &ev, H_ENTER, line) == -1) in add_history()
1569 if (history(h, &ev, H_DELDATA, num, &he->data) != 0) { in remove_history()
1574 he->line = ev.str; in remove_history()
1583 * replace the line and data of the num-th entry
1608 if (history(h, &ev, H_NEXT_EVDATA, num, &he->data)) in replace_history_entry()
1611 he->line = ev.str; in replace_history_entry()
1612 if (he->line == NULL) in replace_history_entry()
1629 * clear the history list - delete all entries
1716 return -1; in history_total_bytes()
1761 history_offset--; in previous_history()
1796 return -1; in history_search()
1801 return (int)(strp - ev.str); in history_search()
1806 return -1; in history_search()
1835 off = (pos > 0) ? pos : -pos; in history_search_pos()
1836 pos = (pos > 0) ? 1 : -1; in history_search_pos()
1839 return -1; in history_search_pos()
1843 return -1; in history_search_pos()
1856 return -1; in history_search_pos()
1864 tilde_expand(char *name) in tilde_expand() argument
1866 return fn_tilde_expand(name); in tilde_expand()
1870 filename_completion_function(const char *name, int state) in filename_completion_function() argument
1872 return fn_filename_completion_function(name, state); in filename_completion_function()
1906 && text[0] == pass->pw_name[0] in username_completion_function()
1907 && strcmp(text, pass->pw_name) == 0) in username_completion_function()
1914 return strdup(pass->pw_name); in username_completion_function()
1919 * el-compatible wrapper to send TSTP on ^Z
1944 * 'max' is maximum length of string in 'matches'.
1947 rl_display_match_list(char **matches, int len, int max) in rl_display_match_list() argument
1950 fn_display_match_list(e, matches, (size_t)len, (size_t)max, in rl_display_match_list()
2009 * bind key c to readline-type function func
2014 int retval = -1; in rl_bind_key()
2021 e->el_map.key[c] = ED_INSERT; in rl_bind_key()
2029 * read one key from input - handles chars pushed back
2070 /* XXX - int -> char conversion can lose on multichars */ in rl_insert()
2074 for (; count > 0; count--) in rl_insert()
2100 * Readline-4.0 appears to ignore the args. in rl_newline()
2124 rl_add_defun(const char *name, rl_command_func_t *fun, int c) in rl_add_defun() argument
2128 return -1; in rl_add_defun()
2130 el_set(e, EL_ADDFN, name, name, rl_bind_wrapper); in rl_add_defun()
2132 el_set(e, EL_BIND, dest, name, NULL); in rl_add_defun()
2144 if (buf == NULL || count-- <= 0) in rl_callback_read_char()
2146 if (count == 0 && buf[0] == e->el_tty.t_c[TS_IO][C_EOF]) in rl_callback_read_char()
2186 a[0] = (char)e->el_tty.t_c[TS_IO][C_REPRINT]; in rl_redisplay()
2198 while (count--) in rl_get_previous_history()
2243 return el_set(e, EL_BIND, "", var, value, NULL) == -1 ? 1 : 0; in rl_variable_bind()
2271 if (ioctl(el->el_infd, FIONREAD, &n) < 0) in _rl_event_read_char()
2272 return -1; in _rl_event_read_char()
2274 num_read = read(el->el_infd, &ch, (size_t)1); in _rl_event_read_char()
2278 if ((n = fcntl(el->el_infd, F_GETFL, 0)) < 0) in _rl_event_read_char()
2279 return -1; in _rl_event_read_char()
2280 if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0) in _rl_event_read_char()
2281 return -1; in _rl_event_read_char()
2282 num_read = read(el->el_infd, &ch, 1); in _rl_event_read_char()
2283 if (fcntl(el->el_infd, F_SETFL, n)) in _rl_event_read_char()
2284 return -1; in _rl_event_read_char()
2286 /* not non-blocking, but what you gonna do? */ in _rl_event_read_char()
2287 num_read = read(el->el_infd, &ch, 1); in _rl_event_read_char()
2288 return -1; in _rl_event_read_char()
2308 rl_point = (int)(li->cursor - li->buffer); in _rl_update_pos()
2309 rl_end = (int)(li->lastchar - li->buffer); in _rl_update_pos()
2328 if (li->buffer + from > li->lastchar) in rl_copy_text()
2329 from = (int)(li->lastchar - li->buffer); in rl_copy_text()
2331 if (li->buffer + to > li->lastchar) in rl_copy_text()
2332 to = (int)(li->lastchar - li->buffer); in rl_copy_text()
2334 len = (size_t)(to - from); in rl_copy_text()
2338 (void)strlcpy(out, li->buffer + from , len); in rl_copy_text()
2402 size_t len, max, i, j, min; in rl_completion_matches() local
2406 max = 10; in rl_completion_matches()
2407 if ((list = el_calloc(max, sizeof(*list))) == NULL) in rl_completion_matches()
2410 while ((match = (*fun)(str, (int)(len - 1))) != NULL) { in rl_completion_matches()
2412 if (len == max) { in rl_completion_matches()
2414 max += 10; in rl_completion_matches()
2415 if ((nl = el_realloc(list, max * sizeof(*nl))) == NULL) in rl_completion_matches()
2428 qsort(&list[1], len - 1, sizeof(*list), in rl_completion_matches()
2431 for (i = 1, a = list[i]; i < len - 1; i++, a = b) { in rl_completion_matches()
2487 hs->length = history_length; in history_get_history_state()
2585 if (c == -1) in rl_echo_signal_char()
2611 rl_set_keymap_name(const char *name, Keymap k) in rl_set_keymap_name() argument
2613 return name && k ? 0 : 0; in rl_set_keymap_name()