aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
AgeCommit message (Collapse)Author
2015-03-12libbb: introduce and use is_prefixed_with()Denys Vlasenko
function old new delta is_prefixed_with - 18 +18 complete_username 78 77 -1 man_main 737 735 -2 fsck_device 429 427 -2 unpack_ar_archive 80 76 -4 strip_unsafe_prefix 105 101 -4 singlemount 1054 1050 -4 rtc_adjtime_is_utc 90 86 -4 resolve_mount_spec 88 84 -4 parse_one_line 1029 1025 -4 parse_conf 1460 1456 -4 may_wakeup 83 79 -4 loadkmap_main 219 215 -4 get_irqs_from_stat 103 99 -4 get_header_cpio 913 909 -4 findfs_main 79 75 -4 fbsplash_main 1230 1226 -4 load_crontab 776 771 -5 expand_vars_to_list 1151 1146 -5 date_main 881 876 -5 skip_dev_pfx 30 24 -6 make_device 2199 2193 -6 complete_cmd_dir_file 773 767 -6 run_applet_and_exit 715 708 -7 uudecode_main 321 313 -8 pwdx_main 197 189 -8 execute 568 560 -8 i2cdetect_main 1186 1176 -10 procps_scan 1242 1230 -12 procps_read_smaps 1017 1005 -12 process_module 746 734 -12 patch_main 1903 1891 -12 nfsmount 3572 3560 -12 stack_machine 126 112 -14 process_timer_stats 449 435 -14 match_fstype 111 97 -14 do_ipaddr 1344 1330 -14 open_list_and_close 359 343 -16 get_header_tar 1795 1779 -16 prepend_new_eth_table 340 323 -17 fsck_main 1811 1794 -17 find_iface_state 56 38 -18 dnsd_main 1321 1303 -18 base_device 179 158 -21 find_keyword 104 82 -22 handle_incoming_and_exit 2785 2762 -23 parse_and_put_prompt 774 746 -28 modinfo 347 317 -30 find_action 204 171 -33 update_passwd 1470 1436 -34 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/49 up/down: 18/-540) Total: -522 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-07libpwdgrp: use getpwent() instead of getpwent_r()Denys Vlasenko
function old new delta massage_data_for_non_r_func - 90 +90 bb_internal_getpwent - 69 +69 getXXnam_r 94 162 +68 fill_bounds 131 128 -3 deluser_main 355 310 -45 complete_username 123 78 -45 getXXnam 163 90 -73 massage_data_for_r_func 103 - -103 bb_internal_getpwent_r 121 - -121 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 1/5 up/down: 227/-407) Total: -163 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-15lineedit: don't block when looking for escape sequence in vi-modeRon Yorston
In vi-mode lineedit tries to detect some escape sequences. After the ESC it reads the next character to check for certain values. This read should have a timeout or a user-entered ESC to switch to command mode doesn't properly handle the next character. Signed-off-by: Ron Yorston <rmy@tigress.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-10lineedit: don't fall back to simple line input if tty is in raw modeDenys Vlasenko
Testcase: shell command input after python ^Z should still work Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-10lineedit: fix trivial build failureDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-20lineedit: use unicode_strwidth instead of unicode_strlenDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-19lineedit: fix multi-line PS1 handling: calculate PS1 length from last \nDenys Vlasenko
function old new delta parse_and_put_prompt 755 774 +19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-08-19lineedit: improve Unicode handling (still buggy though)Denys Vlasenko
function old new delta unicode_strlen - 31 +31 read_line_input 3876 3879 +3 lineedit_read_key 255 246 -9 parse_and_put_prompt 785 755 -30 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/2 up/down: 34/-39) Total: -5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-07ash,hush: history builtinFlemming Madsen
function old new delta show_history - 39 +39 builtin_history - 16 +16 historycmd - 13 +13 bltins1 312 324 +12 builtintab 336 344 +8 popstring 134 140 +6 hush_main 1048 1046 -2 ash_main 1398 1396 -2 size_from_HISTFILESIZE 44 40 -4 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 3/3 up/down: 94/-8) Total: 86 bytes Signed-off-by: Flemming Madsen <busybox@themadsens.dk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29lineedit: \W on "/bin" should show "bin", not "/bin"Denys Vlasenko
function old new delta parse_and_put_prompt 793 785 -8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29lineedit: implement \T \t \A \@ prompts escapes, fix \W escape, drop \!Denys Vlasenko
function old new delta parse_and_put_prompt 742 793 +51 read_line_input 3836 3826 -10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-28lineedit: add handling of \H in promptDenys Vlasenko
Based on the patch by Arnaud RĂ©billout <rebillout@syscom.ch> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-27lineedit: initialize delptrShawn J. Goff
In vi mode, the 'p' and 'P' commands caused a segfault when nothing had been put in the buffer yet because the delptr was not initialized. Signed-off-by: Shawn J. Goff <shawn7400@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27lineedit: in !EDITING config, return -1 on fgets errorDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-07lineedit: fix Alt-D when cursor==0Cliff Frey
Signed-off-by: Cliff Frey <cliff@meraki.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-26lineedit: histfile can get emptied when CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=yDennis Groenen
When CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is set to y, the histfile will get cleared if the total amount of history lines is less than MAX_HISTORY. Only if the histfile is not empty _and_ the amount of lines currently in memory are equal to or greater than MAX_HISTORY, history saving will work as expected with this feature enabled. Output from defconfig + CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y: $ echo "foo" > ~/.ash_history $ ./busybox ash ~/busybox/a $ echo "bar" > /dev/null ~/busybox/a $ exit $ cat ~/.ash_history $ Output with the patch applied and same config as above: $ echo "foo" > ~/.ash_history $ ./busybox ash ~/busybox/b $ echo "bar" > /dev/null ~/busybox/b $ exit $ cat ~/.ash_history foo echo "bar" > /dev/null exit $ Signed-off-by: Dennis Groenen <tj.groenen at gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-20whitespace fixesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-15shell_builtin_read: set cc[VMIN] to 1; lineedit: don't clear c_cc[VINTR]Denys Vlasenko
First change fixes "read -n NUM". Apparently poll() won't report data availability if cc[VMIN] > 1 until there are at least cc[VMIN] bytes. function old new delta read_line_input 3885 3877 -8 shell_builtin_read 1097 1087 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18) Total: -18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-04lineedit: fix build failureDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-03lineedit: add support for M-b, M-f, M-d, M-BackspaceDenys Vlasenko
function old new delta ctrl_left - 96 +96 ctrl_right - 76 +76 static.esccmds 81 93 +12 read_line_input 3876 3885 +9 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/0 up/down: 193/0) Total: 193 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04lineedit: remove SAVE_HISTORY bit, ->hist_file can be used as indicatorDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04lineedit: add support for history saving on exitDenys Vlasenko
Based on the patch by Dennis Groenen <tj.groenen@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-04lineedit: fix atomic replace of history file; hush: fix $HISTFILE handlingDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-11libbb/lineedit: implement optional Ctrl-R history searchDenys Vlasenko
function old new delta read_line_input 3433 3957 +524 load_string 77 90 +13 input_tab 1086 1069 -17 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 537/-17) Total: 520 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-20lineedit: fix rare SEGV; mark a few FIXMEsAlexey Fomenko
Signed-off-by: Alexey Fomenko <ext-alexey.fomenko@nokia.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-31small fix for HISTFILESIZEDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-31ash,hush: optional support for $HISTFILESIZE.Denys Vlasenko
Based on patch from Alexey Fomenko (ext-alexey.fomenko AT nokia.com) function old new delta size_from_HISTFILESIZE - 44 +44 hush_main 998 1025 +27 ash_main 1348 1374 +26 read_line_input 3361 3372 +11 new_line_input_t 17 24 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-27lineedit: fixes for CONFIG_UNICODE_USING_LOCALE=yDenys Vlasenko
function old new delta load_string 45 91 +46 save_string 40 82 +42 reinit_unicode 34 61 +27 BB_PUTCHAR 97 120 +23 init_unicode 17 37 +20 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/0 up/down: 158/0) Total: 158 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-08ash: fix TMOUT not restoring tty attributesDenys Vlasenko
function old new delta pgetc 420 500 +80 readtoken1 3202 3239 +37 read_line_input 3316 3337 +21 udhcpc_main 2610 2630 +20 file_get 266 272 +6 expandarg 958 963 +5 localcmd 257 259 +2 addLines 85 87 +2 read_line 94 95 +1 ed_main 2540 2541 +1 timed_out 1 - -1 lineedit_read_key 256 255 -1 alrm_sighandler 44 - -44 cmdloop 539 434 -105 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 10/2 up/down: 175/-151) Total: 24 bytes text data bss dec hex filename 887379 936 17200 905515 dd12b busybox_old 887411 936 17192 905539 dd143 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-22lineedit: fix tab-completion of filenames with spacesMike Shal
Using ash in busybox git version dea28e1e, tab completion doesn't seem to work properly for filenames that have special characters (such as spaces) in them. For example, with filenames "foo bar" and "foo zap", typing "ls fo<TAB>" correctly expands to "ls foo\ ", but then continuing to type "b<TAB>" will produce "ls foo\ bbar", which is not correct (the 'b' is duplicated). Signed-off-by: Mike Shal <marfey@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-15lineedit: create history files with mode 0600Wolfram Sang
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-28*: use _exit() in sighandlers; showkey: do not use exit-thru-sighandlerMarek Polacek
While at it, make ESC sequences more readable; and removed check for isatty(stdin) in reset. Code shrink: text data bss dec hex filename 884771 936 17216 902923 dc70b busybox_old 884723 936 17216 902875 dc6db busybox_unstripped Signed-off-by: Marek Polacek <mmpolacek@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-09-07lineedit: do not hang on error, but return error indicator.Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03lineedit: on tab completion, show filenames obly in all cases (bash compat)Denys Vlasenko
function old new delta complete_cmd_dir_file 731 730 -1 Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03lineedit: allocate matchBuf only temporarily: saves MAX_LINELEN bytesDenys Vlasenko
function old new delta input_tab 1027 1041 +14 build_match_prefix 590 562 -28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-28) Total: -14 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03lineedit: de-indent large block in input_tab. No logic changes.Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03lineedit: rename tmp -> chosen_match; small code shrinkDenys Vlasenko
function old new delta input_tab 1016 1012 -4 Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03lineedit: stop using permanent int_buf[] (16k!): allocate itDenys Vlasenko
Now it is allocated temporarily only for the duretion of prefix generation, and also we only allocate the needed size, not maximally possible. function old new delta build_match_prefix 579 590 +11 remove_chunk 43 28 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 11/-15) Total: -4 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03lineedit: remove pos_buf[] array (up to 16k!); fix compat bugsDenys Vlasenko
pos_buf is a strange hack, easy to do without it. This also allows lines >32k long to be handled. Also simplified match prefix generations and made behavior more like bash. function old new delta remove_chunk - 43 +43 collapse_pos 79 - -79 build_match_prefix 804 579 -225 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/1 up/down: 43/-304) Total: -261 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03lineedit: return prefix len from tab completion helpersDenys Vlasenko
This kills horrific logic which deletes and re-adds prefix (!) function old new delta complete_cmd_dir_file 705 731 +26 complete_username 121 124 +3 input_tab 1041 1016 -25 build_match_prefix 838 804 -34 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 29/-59) Total: -30 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03lineedit: clean up tab completion code (variable reuse, comments)Denys Vlasenko
Noted bugs in behavior. Added debugging machinery. Decoupled variables reused for unrelated purposes: apparently, when not forced to use liveness analysis, gcc fares better. function old new delta complete_cmd_dir_file 699 705 +6 collapse_pos 75 79 +4 build_match_prefix 892 838 -54 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 10/-54) Total: -44 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-03preparatory cleanup patch for tab completion fixesDenys Vlasenko
renames and deinlines a few functions function old new delta input_tab - 1041 +1041 complete_cmd_dir_file - 699 +699 complete_username - 121 +121 username_completion 121 - -121 read_line_input 5002 3313 -1689 ------------------------------------------------------------------------------ (add/remove: 3/1 grow/shrink: 0/1 up/down: 1861/-1810) Total: 51 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-02lineedit: small readability improvement (same code)Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-02lineedit: fix completion with Unicode charsDenys Vlasenko
function old new delta read_line_input 4966 5002 +36 bb_wcstombs 170 159 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 36/-11) Total: 25 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-02lineedit: preparatory cleanup patch for Unicode completion fixDenys Vlasenko
Some logic changes and function renames. The fix will follow this patch, to mkae it distinct from cleanup. function old new delta build_match_prefix - 892 +892 username_completion - 121 +121 read_line_input 4902 4966 +64 username_tab_completion 235 - -235 find_match 892 - -892 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 1/0 up/down: 1077/-1127) Total: -50 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-07-25lineedit: mostly revert recent wrong logic in "ask terminal" codeDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-18lineedit: limit ASK_TERMINAL to the case when we can't find out the widthDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-18lineedit: cosmetics, no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-01lineedit: fix column display for wide and combining chars in TAB completionTomas Heinrich
function old new delta unicode_strwidth - 20 +20 read_line_input 4945 4953 +8 unicode_strlen 31 - -31 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 1/0 up/down: 28/-31) Total: -3 bytes Signed-off-by: Tomas Heinrich <heinrich.tomas@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-17typo fixDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>