This time it resulted in small code changes:
function old new delta
nexpr 820 828 +8
tail_main 1200 1202 +2
wrapf 166 167 +1
parse_mount_options 227 209 -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 11/-18) Total: -7 bytes
watchdog function, presumably to catch infinite loop bugs.
(control-C can do the same thing, and the alarms were too short in
any case.) also, switch to sigsetjmp/siglongjmp in order to allow
repeated use of control-C -- otherwise it works once, then not again.
buffer between commands, not recalculate its length all the time,
and to not reallocate its fixed-length buffer frequently.
fixed the 'c', 'd', and 'y' commands to properly handle both motions
that are just part of a line, and those that are multiline. for
instance, now "c%" and "2cw" work correctly, whether the motions span
lines or not.
added some permissble motions for 'c', 'd', and 'y': namely 'h',
'l', SPACE, BS, and DEL
inetd,syslogd: use safe_read instead of open-coded EINTR handling
syslogd: bail out if you see null read from Unix socket
(should never happen, but if it does, spinning forever
and eating 100% CPU is not a good idea)
trylink: explain how to modify link and drastically decrease amount
of padding (unfortunately, needs hand editing ATM).
*: add ALIGN1 / ALIGN2 to global strings and arrays of bytes and shorts
size saving: 0.5k
* the puzzling message on error is replaced with strerror(errno)
so it should be even more detailed and smaller at the same time.
* merged code in edit_file() and code for ':edit <file>' in colon() into
new func init_text_buffer(). Was horribly duplicate. Moved most of
error/sanity checking to file_insert(). Result is that you get a proper
validation (prevent reading /dev/*) and error messages for ':r <file>'
* renamed 'cfn' to 'current_filename' for improved readability
* merged smallint vi_readonly and readonly into bitfields into
readonly_mode to save space.
* added text_size variable to keep track how big the text buffer is.
This is used to fix a buffer overflow. To reproduce bug:
./busybox vi TODO
:r Makefile
vi segfaults due to no buffer checking is done at all. som redesign is
needed here but i added a check in text_hole_make() to aviod the
segfault at least.
* removed isblnk() and use isblank(3) instead.
* fixed compiler warning by displaying the return code for :!<command>
This makes things bigger than needed but since the patch reduces the
overall size... (see below)
* new func next_tabstop(int) merges some duplicate code. There are more
cuplicode here but i couldnt find a good way to merge them.
* Fix *ANNOYING* placement of cursor on '\t' characters. To reproduce:
echo -e "\thello" > file1
./busybox vi file1
Try to insert some text at the beginning of line. Text will be inserted
but cursor is blinking somewhere else. The patch should make busybox vi
behave more like original vi(m). Costs a few bytes but its worth it
imho.
* new_text() is moved into init_text_buffer()
* the previously added update_ro_status() was moved info file_insert due
to duplication removal mentioned above.
function old new delta
init_text_buffer - 245 +245
file_insert 312 420 +108
next_tabstop - 82 +82
text_hole_make 154 171 +17
do_cmd 5093 5100 +7
static.cmd_mode_indicator - 5 +5
refresh 1248 1253 +5
current_filename - 4 +4
yank_delete 161 164 +3
what_reg 96 99 +3
end_cmd_q 78 81 +3
char_insert 440 442 +2
readonly_mode - 1 +1
vi_readonly 1 - -1
setops 154 153 -1
readonly 1 - -1
vi_setops 4 1 -3
string_insert 161 158 -3
cfn 4 - -4
show_status_line 532 514 -18
readit 519 500 -19
move_to_col 161 138 -23
vi_main 495 433 -62
isblnk 75 - -75
.rodata 4751 4655 -96
edit_file 892 787 -105
new_text 125 - -125
update_ro_status 131 - -131
colon 3848 3667 -181
------------------------------------------------------------------------------
(add/remove: 5/6 grow/shrink: 8/10 up/down: 485/-848) Total: -363
bytes
text data bss dec hex filename
34751 873 4260 39884 9bcc busybox_old
34439 877 4260 39576 9a98 busybox_unstripped
awk: some 'lineno' vars were shorts, made them ints (code got smaller)
awk: rename global t to global ttt. still an awful name, but at least
you can grep for it now.
function old new delta
ttt - 28 +28
mysleep 104 120 +16
readit 408 418 +10
lineno 2 4 +2
parse_program 338 339 +1
evaluate 6446 6445 -1
syntax_error 25 23 -2
next_token 917 915 -2
new_node 26 24 -2
tv 16 8 -8
skip_spaces 68 53 -15
t 28 - -28
rfds 128 - -128
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 4/6 up/down: 57/-186) Total: -129 bytes