Commit Graph

96 Commits

Author SHA1 Message Date
Denys Vlasenko
19158a837d unicode: s/FEATURE_ASSUME_UNICODE/UNICODE_SUPPORT, add UNICODE_USING_LOCALE
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-26 14:06:56 +01:00
Tomas Heinrich
aa167556cd unicode: optional table for better handling of neutral bidi chars
Off:
function                                             old     new   delta
unicode_bidi_isrtl                                     -      55     +55
isrtl_str                                             51      65     +14
unicode_isrtl                                         55       -     -55
read_line_input                                     5003    4937     -66
------------------------------------------------------------------------------
(add/remove: 1/4 grow/shrink: 1/1 up/down: 69/-121)           Total: -52 bytes

On:
function                                             old     new   delta
static.neutral_b                                       -     320    +320
static.neutral_p                                       -     142    +142
unicode_bidi_isrtl                                     -      55     +55
unicode_bidi_is_neutral_wchar                          -      55     +55
isrtl_str                                             51      59      +8
unicode_isrtl                                         55       -     -55
read_line_input                                     5003    4937     -66
------------------------------------------------------------------------------
(add/remove: 4/4 grow/shrink: 1/1 up/down: 580/-121)          Total: 459 bytes

Signed-off-by: Tomas Heinrich <heinrich.tomas@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-26 13:13:24 +01:00
Tomas Heinrich
c5c006c10c lineedit: first shot at optional unicode bidi input support
function                                             old     new   delta
read_line_input                                     4886    5003    +117
in_uint16_table                                        -      97     +97
in_interval_table                                      -      78     +78
static.rtl_b                                           -      68     +68
unicode_isrtl                                          -      55     +55
isrtl_str                                              -      51     +51
static.rtl_p                                           -      42     +42
unicode_conv_to_printable2                           633     477    -156
------------------------------------------------------------------------------
(add/remove: 6/0 grow/shrink: 1/1 up/down: 508/-156)          Total: 352 bytes

Signed-off-by: Tomas Heinrich <heinrich.tomas@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-18 18:35:37 +01:00
Denys Vlasenko
58f108eb33 lineedit: fix another corner case with bad unicode input
function                                             old     new   delta
read_key                                             607     646     +39
readit                                                50      55      +5
getch_nowait                                         290     295      +5
hash_find                                            233     234      +1
xstrtoul_range_sfx                                   231     230      -1
passwd_main                                         1058    1056      -2
builtin_exit                                          45      43      -2
cmp_main                                             649     645      -4
lineedit_read_key                                    257     245     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/5 up/down: 50/-21)             Total: 29 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-11 21:17:55 +01:00
Tomas Heinrich
d2b04050c0 lineedit: invalid unicode characters are replaced with CONFIG_SUBST_WCHAR
function                                             old     new   delta
read_key_ungets                                        -      50     +50
lineedit_read_key                                    223     252     +29

Signed-off-by: Tomas Heinrich <heinrich.tomas@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-09 14:09:24 +01:00
Denys Vlasenko
9f93d62192 libbb: better unicode width support. Hopefully fixes bug 839.
Also opens up a possibility to make other unicode stuff smaller
and more correct later. but:

function                                             old     new   delta
static.combining                                       -     516    +516
bb_wcwidth                                             -     328    +328
unicode_cut_nchars                                     -     141    +141
mbstowc_internal                                       -      93     +93
in_table                                               -      78     +78
cal_main                                             899     961     +62
static.combining0x10000                                -      40     +40
unicode_strlen                                         -      31     +31
bb_mbstrlen                                           31       -     -31
bb_mbstowcs                                          173     102     -71
------------------------------------------------------------------------------
(add/remove: 7/1 grow/shrink: 1/1 up/down: 1289/-102)        Total: 1187 bytes

Uses code of Markus Kuhn, which is in public domain:
http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
"Permission to use, copy, modify, and distribute this software
 for any purpose and without fee is hereby granted. The author
 disclaims all warranties with regard to this software."

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-24 07:44:03 +01:00
Denys Vlasenko
28055028a7 fold: unicode support. Based on a patch by Tomas Heinrich <heinrich.tomas@gmail.com>
General Unicode support is tweaked to expose unicode_status.

function                                             old     new   delta
init_unicode                                           -      77     +77
write2stdout                                           -      19     +19
adjust_column                                         68      71      +3
unicode_status                                         -       1      +1
unicode_is_enabled                                     1       -      -1
grep_main                                            780     773      -7
fold_main                                            619     552     -67
check_unicode_in_env                                  77       -     -77
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 1/2 up/down: 100/-152)          Total: -52 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-04 20:49:58 +01:00
Denys Vlasenko
31e2e7b863 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-12 02:42:35 +01:00
Denys Vlasenko
13ad90627c ash: fix bad interaction of "stty -echo" + ASK_TERMINAL
function                                             old     new   delta
read_line_input                                     4820    4886     +66
put_prompt                                           108      47     -61
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 66/-61)              Total: 5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-11 03:19:30 +01:00
Denys Vlasenko
8131eea3dc *: introduce and use ffulsh_all()
function                                             old     new   delta
buffer_fill_and_print                                179     196     +17
fflush_all                                             -       9      +9
spawn                                                 87      92      +5
rtcwake_main                                         455     453      -2
...
alarm_intr                                            93      84      -9
readcmd                                             1072    1062     -10
bb_ask                                               345     333     -12
more_main                                            845     832     -13
flush_stdout_stderr                                   42      23     -19
xfflush_stdout                                        27       -     -27
flush_stderr                                          30       -     -30
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397)         Total: -366 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-02 14:19:51 +01:00
Denys Vlasenko
1f6d2307ba lineedit: REALLY fix compile error now
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-29 03:45:26 +01:00
Denys Vlasenko
4dc08262cf lineedit: compile fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-29 03:41:38 +01:00
Denys Vlasenko
d83bbf4193 rename sent_ESC_br_n6 variable to sent_ESC_br6n
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-27 10:47:49 +01:00
Denys Vlasenko
eb62d7c383 libbb/lineedit: try to make FEATURE_EDITING_ASK_TERMINAL less ugly
function                                             old     new   delta
read_line_input                                     4809    4829     +20
lineedit_read_key                                    207     223     +16
put_prompt                                           110     117      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 43/0)               Total: 43 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-27 10:34:06 +01:00
Denys Vlasenko
727e1b536e read_key,lineeedit: parse position answerback faster; sanitize its use
it's still not reliable, and probably cannot be made so...
added comment with explanation.

function                                             old     new   delta
put_prompt                                            52     110     +58
read_key                                             601     607      +6
lineedit_read_key                                    201     207      +6
win_changed                                          108     104      -4
read_line_input                                     4824    4809     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 70/-19)             Total: 51 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-26 15:23:32 +01:00
Denys Vlasenko
a17eeb847e lineedit: handle Ctrl-arrows
function                                             old     new   delta
read_line_input                                     4629    4824    +195
BB_isalnum                                             -      39     +39
BB_ispunct                                             -      35     +35
BB_isspace                                             -      31     +31
static.esccmds                                        69      93     +24
vi_word_motion                                       165     162      -3
vi_back_motion                                       204     198      -6
vi_end_motion                                        172     163      -9
bb_iswspace                                           28       -     -28
bb_iswpunct                                           32       -     -32
bb_iswalnum                                           37       -     -37
------------------------------------------------------------------------------
(add/remove: 3/3 grow/shrink: 5/8 up/down: 334/-129)          Total: 205 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-25 23:50:56 +01:00
Denys Vlasenko
04bb6b6a5a lineedit: do not hardcode ctrl-C and ctrl-D, use termios fields.
Unexpected code shrink is probably a gcc glitch:

function                                             old     new   delta
read_line_input                                     4771    4629    -142

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-14 12:53:04 +02:00
Denys Vlasenko
2f3f09c287 libbb/lineedit: restore ^D handling for unicode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-29 00:00:12 +02:00
Denys Vlasenko
db9c57eed1 libbb/lineedit: fix the case when we configured history to have 0 lines
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-27 02:48:53 +02:00
Denys Vlasenko
90a9904e9e remove some GNUisms. by Dan Fandrich (dan AT coneharvesters.com)
function                                             old     new   delta
logdirs_reopen                                      1310    1308      -2
read_line_input                                     4757    4753      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6)               Total: -6 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-06 02:36:23 +02:00
Denys Vlasenko
9531f7dad7 another small lineedit fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-16 14:33:16 +02:00
Denys Vlasenko
5c2e81bb67 fix a thinko in lineedit completion code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-16 14:14:34 +02:00
Denys Vlasenko
53fd1bf223 lineedit: code shrink
function                                             old     new   delta
collapse_pos                                           -      77     +77
read_line_input                                     4755    4757      +2
add_quote_for_spec_chars                              75      71      -4
find_match                                          1283     892    -391

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-16 02:19:39 +02:00
Denys Vlasenko
9038d6f8f5 remove trailing whitespace
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-15 20:02:19 +02:00
Denys Vlasenko
7dd0ce4953 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-15 18:27:47 +02:00
Denys Vlasenko
044b18083b lineedit+unicode: make TAB completion work again
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-12 02:50:35 +02:00
Denys Vlasenko
1302892a14 vi: small code shrink
function                                             old     new   delta
vi_word_motion                                       185     165     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-12 00:51:15 +02:00
Denys Vlasenko
42a8fd0db0 added simplified Unicode support for non-locale-enabled builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-11 21:36:13 +02:00
Denys Vlasenko
2e6d4ef695 lineedit: implement Unicode-aware line editing (optional)
When off:

function                                             old     new   delta
input_delete                                         133     140      +7
vi_word_motion                                       236     240      +4
vi_Back_motion                                        89      92      +3
vi_end_motion                                        223     225      +2
cmdedit_set_out_char                                  74      76      +2
vi_back_motion                                       198     199      +1
vi_Word_motion                                        87      88      +1
vi_End_motion                                         92      86      -6
read_line_input                                     6293    6270     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/2 up/down: 20/-29)             Total: -9 bytes

When on:

lineedit_read_key                                    146     272    +126
BB_PUTCHAR                                             -      94     +94
read_line_input                                     6293    6351     +58
save_string                                            -      43     +43
wcstombs                                               -      38     +38
mbstowcs                                               -      38     +38
save_command_ps_at_cur_history                        65      93     +28
input_delete                                         133     148     +15
vi_Back_motion                                        89      90      +1
vi_Word_motion                                        87      86      -1
cmdedit_set_out_char                                  74      73      -1
vi_End_motion                                         92      84      -8
vi_back_motion                                       198     187     -11
vi_word_motion                                       236     206     -30
vi_end_motion                                        223     184     -39
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 5/6 up/down: 441/-90)           Total: 351 bytes

There is one TODO and maybe some bugs :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-10 18:40:49 +02:00
Mike Frysinger
f524b6c87f lineedit: fix warning about unused label when VI editing is disabled
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Denys Vlasenko
4b7db4f2ca read_key: drop optimization where we read 3 bytes at once
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-29 10:39:06 +02:00
Denys Vlasenko
c396fe6306 lineedit: small fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-17 19:28:14 +02:00
Denys Vlasenko
020f40693a line editing: add an option to emit ESC [ 6 n and use results
This makes line editing able to recognize case when
cursor was not at the beginning of the line. It may also
be adapted later to find out display size (serial line users
would love it).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-17 16:44:54 +02:00
Denys Vlasenko
c15f40c3e7 lineedit: use read_key to recognize ESC sequence.
This fixes several vi mode bugs and prepares for further fixes.

function                                             old     new   delta
read_line_input                                     3287    5511   +2224
remember_in_history                                    -     499    +499
lineedit_read_key                                      -      70     +70
read_key                                             321     332     +11
input_tab                                           2823       -   -2823
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/0 up/down: 2804/-2823)        Total: -19 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-15 03:27:53 +02:00
Denis Vlasenko
5e34ff29bc *: mass renaming of USE_XXXX to IF_XXXX
and SKIP_XXXX to IF_NOT_XXXX - the second one was especially
badly named. It was not skipping anything!
2009-04-21 11:09:40 +00:00
Denis Vlasenko
c0ea82a457 libbb: revent previous version of "concurrent history updating"
and replace it with one which does not "snoop" history written
by others. (1) it is what bug 185 needs, and (2) it is less bloaty:

function                                             old     new   delta
load_history                                           -     252    +252
read_line_input                                     3155    3287    +132
next_token                                           914     918      +4
qrealloc                                              36      33      -3
getoptscmd                                           713     708      -5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 388/-8)            Total: 380 bytes
2009-03-23 06:33:37 +00:00
Denis Vlasenko
57abf9e947 libbb: make history saving/loading concurrent-safe
* all history writers always append (not overwrite) history files
* they reload history if they detect that file length has changed since last
write
* they trim history file only when it grows 4 times longer than MAXLINES
* they do this atomically by creating new file and renaming it to old

Unfortunately, this comes at a price:

function                                             old     new   delta
load_history                                           -     346    +346
read_line_input                                     3155    3358    +203
new_line_input_t                                      17      31     +14
...irrelevant small jitter...
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/5 up/down: 573/-13)           Total: 560 bytes
2009-03-22 19:00:05 +00:00
Denis Vlasenko
202ac504e1 *: code shrink by adding a wrapper around very common tcsetattr(0, TCSANOW, xx) op
function                                             old     new   delta
tcsetattr_stdin_TCSANOW                                -      14     +14
set_sane_term                                        116     113      -3
top_main                                            1277    1273      -4
make_new_session                                     421     415      -6
rawmode                                              133     126      -7
reset_term                                            18      10      -8
die                                                   43      35      -8
cookmode                                              62      54      -8
vlock_main                                           425     415     -10
read_line_input                                     3165    3155     -10
bb_askpass                                           357     347     -10
fsck_minix_main                                     3079    3065     -14
getty_main                                          2375    2332     -43
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/12 up/down: 14/-131)         Total: -117 bytes
2008-11-05 13:20:58 +00:00
Denis Vlasenko
3c385cd706 lineedit: fix bug 5824: Since version 23530 with lineedit.c,
"fdisk" & "ed" can't work any more
2008-11-02 00:41:05 +00:00
Denis Vlasenko
682ad3045c lineedit: fix problems with empty commands in history 2008-09-27 01:28:56 +00:00
Denis Vlasenko
f31c3b677d linedit: fix use-after-free 2008-08-20 00:46:32 +00:00
Denis Vlasenko
41660c5b2d another overlapping_strcpy 2008-07-22 20:25:24 +00:00
Denis Vlasenko
0f293b96dc fix all cases of strcpy on overlapping strings. 2008-07-22 20:16:55 +00:00
Denis Vlasenko
5415c856ea libbb: [x]fopen_for_{read,write} introduced and used.
(by Valdimir)

function                                             old     new   delta
config_open2                                           -      41     +41
config_read                                          507     542     +35
find_pair                                            169     187     +18
fopen_for_write                                        -      14     +14
fopen_for_read                                         -      14     +14
find_main                                            406     418     +12
xfopen_for_write                                       -      10     +10
xfopen_for_read                                        -      10     +10
popstring                                            134     140      +6
parse_inittab                                        396     401      +5
next_token                                           923     928      +5
pack_gzip                                           1659    1661      +2
bb__parsespent                                       117     119      +2
fallbackSort                                        1719    1717      -2
evalvar                                             1376    1374      -2
qrealloc                                              36      33      -3
...
...
...
...
singlemount                                         4579    4569     -10
process_stdin                                        443     433     -10
patch_main                                          1111    1101     -10
ifupdown_main                                       2175    2165     -10
file_action_grep                                      90      80     -10
uuidcache_init                                       649     637     -12
hush_main                                            797     785     -12
read_config                                          230     217     -13
dpkg_main                                           3835    3820     -15
read_line_input                                     3134    3110     -24
sysctl_main                                          232     203     -29
config_open                                           40      10     -30
WARN_BAD_LINE                                         44       -     -44
login_main                                          1714    1575    -139
------------------------------------------------------------------------------
(add/remove: 5/1 grow/shrink: 8/74 up/down: 174/-737)        Total: -563 bytes
2008-07-21 23:05:26 +00:00
Denis Vlasenko
deeed59de0 libbb: introduce and use xrealloc_vector
function                                             old     new   delta
xrealloc_vector_helper                                 -      51     +51
create_list                                           84      99     +15
getopt_main                                          690     695      +5
passwd_main                                         1049    1053      +4
get_cached                                            85      89      +4
msh_main                                            1377    1380      +3
add_match                                             42      41      -1
read_lines                                           720     718      -2
grave                                               1068    1066      -2
fill_match_lines                                     143     141      -2
add_to_dirlist                                        67      65      -2
add_input_file                                        49      47      -2
act                                                  252     250      -2
fsck_main                                           2252    2246      -6
man_main                                             765     757      -8
bb_internal_initgroups                               228     220      -8
cut_main                                            1052    1041     -11
add_edge_to_node                                      55      43     -12
dpkg_main                                           3851    3835     -16
ifupdown_main                                       2202    2178     -24
sort_main                                            838     812     -26
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/15 up/down: 82/-124)          Total: -42 bytes
2008-07-08 05:14:36 +00:00
Denis Vlasenko
78ff8197cc lineedit: document prompt handling 2008-06-28 21:03:43 +00:00
Denis Vlasenko
defc1ea340 *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on
text    data     bss     dec     hex filename
 808035     611    6868  815514   c719a busybox_old
 804472     611    6868  811951   c63af busybox_unstripped
2008-06-27 02:52:20 +00:00
Denis Vlasenko
b267ed95bc lineedit: correctly handle prompt longer than screen width. closes bug 3414 2008-05-25 21:52:03 +00:00
Denis Vlasenko
5599502a55 more -Wall warning fixes. -Wall is enabled now. 2008-05-18 22:28:26 +00:00
Denis Vlasenko
6b06cb80be more of -Wall fixes from Cristian Ionescu-Idbohrn.
Some are fixing real bugs.

function                                             old     new   delta
syslogd_main                                         938     958     +20
get_signum                                           136     143      +7
obj_load                                             777     782      +5
recv_from_to                                         210     214      +4
get_next_block                                      1795    1799      +4
display_topmem_process_list                         1117    1121      +4
logread_main                                         484     487      +3
buffer_fill_and_print                                 73      76      +3
kill_main                                            687     689      +2
ll_remember_index                                    240     241      +1
do_stats                                             452     453      +1
if_readconf                                          166     165      -1
display_process_list                                1192    1191      -1
run_applet_and_exit                                  507     505      -2
print_signames                                        33      31      -2
parse_one_line                                      1092    1090      -2
find_out_spec                                         57      55      -2
add_ksymoops_symbols                                 421     419      -2
ash_main                                            1407    1402      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 11/8 up/down: 54/-17)            Total: 37 bytes
2008-05-15 21:30:45 +00:00