Commit Graph

533 Commits

Author SHA1 Message Date
Denis Vlasenko
1bb552b1d9 libbb: add xunlink()
patch: do not try to delete same file twice
2007-04-05 21:25:15 +00:00
Denis Vlasenko
ba2fb719b9 Copyright, help text, whitespace cleanups 2007-04-01 09:39:03 +00:00
Denis Vlasenko
17a1526f9e sed: a communal variable managed to slip past 'size'
('size' happily displays 0 bytes in data and bss,
but in reality sed.o used 180 bytes of it). Oh well.
function                                             old     new   delta
pipe_putc                                             67      76      +9
sed_main                                             627     633      +6
get_next_line                                        161     166      +5
bbg                                                  180       -    -180
(add/remove: 0/1 grow/shrink: 3/0 up/down: 20/-180)          Total: -160 bytes

sed: also make sed -i failure message less cryptic
2007-03-26 20:48:46 +00:00
Denis Vlasenko
55f30b05ac inetd,ed,msh: data/bss reduction (in mss, more than 9k of it) 2007-03-24 22:42:29 +00:00
Denis Vlasenko
219d14d514 random style fixes (extra spaces deleted) 2007-03-24 15:40:16 +00:00
Denis Vlasenko
58875aefe4 assorted fixes uncovered by randomconfig runs 2007-03-22 22:22:10 +00:00
Denis Vlasenko
2a51af2579 vi: fix signed char-induced potential bugs 2007-03-21 22:31:24 +00:00
Denis Vlasenko
afa37cf508 vi: remove Byte typedef and massive amount of casts.
also optimize many strlen() calls.
if (strlen(buf) <= 0) goto vc1 - ??!!
2007-03-21 00:05:35 +00:00
Denis Vlasenko
f9234135f8 vi: support $EXINIT and -c 2007-03-21 00:03:42 +00:00
Denis Vlasenko
4b0bb9e0fd sed: fix very obscure case of escaped newline in sed command
(needed for uclibc build, btw). Add testcase for it.
2007-03-16 23:36:58 +00:00
Denis Vlasenko
baca175912 kill superfluous returns at the end of void functions 2007-03-11 13:43:10 +00:00
Denis Vlasenko
be644a81e9 awk: support multiple -v options 2007-03-10 17:22:14 +00:00
Denis Vlasenko
8e858e2700 clean up accumulated whitespace damage 2007-03-07 09:35:43 +00:00
Denis Vlasenko
629563b5d7 awk: fix memory leak (can affect large file processing) 2007-02-24 17:05:52 +00:00
Denis Vlasenko
06af216528 suppress warnings about easch <applet>_main() having
no preceding prototype
2007-02-03 17:28:39 +00:00
Denis Vlasenko
34c4e5f0b3 silly space saving in sed 2007-01-30 22:25:16 +00:00
Denis Vlasenko
54767db8c7 micro optimization 2007-01-30 01:11:36 +00:00
Denis Vlasenko
9356b5022c preparatory patch for -Wwrite-strings #7: sed
remaining: shell (rather scary mess in msh.c)
2007-01-29 23:44:38 +00:00
Denis Vlasenko
b6aae0f381 preparatory patch for -Wwrite-strings #2 2007-01-29 22:51:25 +00:00
Denis Vlasenko
a41fdf331a preparatory patch for -Wwrite-strings #1 2007-01-29 22:51:00 +00:00
Denis Vlasenko
86811803e3 add to testsuite and fix yet another sed corner case 2007-01-29 17:10:19 +00:00
Denis Vlasenko
c562bb7487 disable -Wold-style-definition for gcc 3.x 2007-01-29 17:08:51 +00:00
Denis Vlasenko
fe7a9f1277 sed: fix 2 bugs (one testsuite entry + one newly found)
but more importantly make code more understandable
2007-01-29 14:31:47 +00:00
Denis Vlasenko
826c85f382 fix all known regressions with sed and also make it simpler 2007-01-28 23:26:15 +00:00
Denis Vlasenko
4ebaf10742 strdup -> xstrdup
sed: de-obfuscate piece of code
2007-01-19 21:33:19 +00:00
Denis Vlasenko
ef44d9d9f2 sed,get_line_from_file: improve comments 2007-01-17 23:16:16 +00:00
Denis Vlasenko
150f402b36 whitespace fixes (leading spaces to tab) 2007-01-13 21:06:21 +00:00
Denis Vlasenko
f7996f3b70 Trailing whitespace removal over entire tree 2007-01-11 17:20:00 +00:00
Denis Vlasenko
e1d3e034a9 awk: style fixes 2007-01-01 23:53:52 +00:00
Denis Vlasenko
6dc6ebbf44 awk: undo locale setting for numbers - or else parsing
can act quite mysteriously
date: add if(ENABLE_LOCALE_SUPPORT)
2007-01-01 23:53:12 +00:00
Denis Vlasenko
f782f52c8c awk: style cleanup. A lot of rw data moved to ro
(still has quite a lot of statics etc...).
getopt32-ification.
2007-01-01 23:51:30 +00:00
Denis Vlasenko
6a5dc5d75a next bunch of fixes for bugs found by randconfig 2006-12-30 18:42:29 +00:00
Denis Vlasenko
666da5e2c6 merge post-1.3.0 fixes 2006-12-26 18:17:42 +00:00
Denis Vlasenko
bf0a201008 style fixes
last xcalloc replaced by xzalloc
2006-12-26 10:42:51 +00:00
Denis Vlasenko
4cccc03768 remove useless casts (type*) xzalloc(...) 2006-12-22 18:37:07 +00:00
Denis Vlasenko
b95636c52f remove casts from xmalloc() 2006-12-19 23:36:04 +00:00
Denis Vlasenko
249fabf1a3 Add option to disable command execution from vi & awk 2006-12-19 00:29:22 +00:00
Denis Vlasenko
0a10da29a7 diff: comment - explain what happens when hunk fails to apply 2006-12-17 00:49:56 +00:00
Denis Vlasenko
f7583d89b0 patch: fix double-free (bug 1120) 2006-12-17 00:33:29 +00:00
Denis Vlasenko
9f739445cd inline strcmp(s, "-") [actually macro-ize it for now - gcc is too stupid] 2006-12-16 23:49:13 +00:00
Denis Vlasenko
2ea630f9a5 bb_makedev: fix for glibc 2.3.2
sed: fix C++ style declaration
2006-12-10 02:52:19 +00:00
Denis Vlasenko
2f8f71b20d sed: style fixes 2006-12-10 02:09:12 +00:00
Denis Vlasenko
1375bc7b67 sed: fix handling of files not ending in '\n' 2006-12-02 20:12:12 +00:00
Denis Vlasenko
8b22b07bc5 sed: improve handling of NULs 2006-12-02 17:58:10 +00:00
Denis Vlasenko
610c4aa197 ed: convert style to bbox's. No code changes. 2006-11-30 20:57:50 +00:00
Denis Vlasenko
ab24e18c7a passwd: rework:
* do not make backup copy by copying (just retain old file)
* correctly fall back to /etc/passwd if user is not in shadow
* fix bug with overlong passwd entries
* be permissive on some kinds of failures
* reduce stack usage
* code size: -500 bytes
2006-11-30 16:41:15 +00:00
Denis Vlasenko
d9e15f2068 style cleanup: return(a) -> return a, part 2 2006-11-27 16:49:55 +00:00
Denis Vlasenko
079f8afa0a style cleanup: return(a) -> return a, part 1 2006-11-27 16:49:31 +00:00
Denis Vlasenko
b54b208d90 Fix largefile breakage; advance version to 1.2.2 2006-10-27 09:05:40 +00:00
Denis Vlasenko
621204bbf6 get_terminal_width_height: do not pass insanely large values 2006-10-27 09:03:24 +00:00
Denis Vlasenko
d3d004dd35 last nail into error_msg() (de)capitalization 2006-10-27 09:02:31 +00:00
Denis Vlasenko
ddec5af6b0 rename functions to more understandable names 2006-10-26 23:25:17 +00:00
Denis Vlasenko
8077850330 sed: mostly style fixes, very small changes in actual code 2006-10-25 12:46:46 +00:00
Denis Vlasenko
d18a3a20db use skip_whitespace where appropriate 2006-10-25 12:46:03 +00:00
Denis Vlasenko
e1a0d486e4 message string changes, mostly for consistency, also -32 bytes in .rodata 2006-10-20 13:28:22 +00:00
Denis Vlasenko
ea62077b85 add open_read_close() and similar stuff 2006-10-14 02:23:43 +00:00
Denis Vlasenko
2d5ca60bfb bb_get_[chomped]line_from_file wasn't descriptive enough.
Renaming...
2006-10-12 22:43:20 +00:00
Denis Vlasenko
a6dbb08a48 small style fixes 2006-10-12 19:29:44 +00:00
Denis Vlasenko
1385899416 attempt to regularize atoi mess. 2006-10-08 12:49:22 +00:00
Denis Vlasenko
890ac9deb2 awk: && -> & in "n->info && OPCLSMASK" - fixes bug 1067 2006-10-07 15:16:19 +00:00
Denis Vlasenko
7d219aab70 build system overhaul 2006-10-05 10:17:08 +00:00
Denis Vlasenko
67b23e6043 getopt_ulflags -> getopt32.
It is impossible to formulate sane ABI based on
size of ulong because it can be 32-bit or 64-bit.
Basically it means that you cannot portably use
more that 32 option chars in one call anyway...
Make it explicit.
2006-10-03 21:00:06 +00:00
Denis Vlasenko
40920825d5 rename bb_default_error_retval -> xfunc_error_retval 2006-10-03 20:28:06 +00:00
Denis Vlasenko
9275814a9e lots of silly indent fixes 2006-10-03 19:56:34 +00:00
Denis Vlasenko
e2016e145b sed: -e options were handled in reverse order. fix that. 2006-10-01 21:37:40 +00:00
Denis Vlasenko
b97c9842a5 sed: unbreak multiple -e, -f option handling (my fault) 2006-10-01 21:05:12 +00:00
Denis Vlasenko
e175ff252f several fixes from openWRT project 2006-09-26 17:41:00 +00:00
Denis Vlasenko
099efbf99e awk: getopt_ulflags'isation 2006-09-22 09:02:30 +00:00
Denis Vlasenko
750fc6d7bb sed: getopt_ulflags'isation 2006-09-22 08:56:03 +00:00
Rob Landley
e9a7a6212b Change license statements (and clean up headers) on some of the files that
Erik or I are primary copyright holders on.
2006-09-22 02:52:41 +00:00
Denis Vlasenko
9213a9e0f2 whitespace cleanup 2006-09-17 16:28:10 +00:00
Rob Landley
d35c0efddb Bugfix for: echo '123456789' | sed 's/./|&/5' 2006-09-08 00:01:02 +00:00
Denis Vlasenko
6d655be5df removed a lot of trailing \n in bb_msg() calls. It is added
automatically by function itself.
2006-09-06 19:02:46 +00:00
Rob Landley
88621d7398 Svn 16007 broke the build under gcc 4.0.3. This fixes up some of the damage
(the e2fsprogs directory is too twisty and evil to easily fix, but I plan
to rewrite it anyway so I'll just bump that up in priority a bit).
2006-08-29 19:41:06 +00:00
Bernhard Reutner-Fischer
d591a360d3 - merge -r15463:15564 from busybox_scratch branch through these changesets:
------------------------------------------------------------------------
r15465 | aldot | 2006-06-21 20:48:06 +0200 (Wed, 21 Jun 2006) | 3 lines

- use CONFIG_BUSYBOX_EXEC_PATH as before it one was broken by a recent revert.
- use xchdir() since all is invain if it fails there anyways, supposedly

------------------------------------------------------------------------
r15466 | aldot | 2006-06-21 20:55:16 +0200 (Wed, 21 Jun 2006) | 2 lines

- adjust docs to take CONFIG_BUSYBOX_EXEC_PATH into account.

------------------------------------------------------------------------
r15467 | aldot | 2006-06-21 21:31:24 +0200 (Wed, 21 Jun 2006) | 18 lines

- partial fallout of my TREE_USED touchup against gcc-4.2: rip unused vars, save
s 144 bytes
   text    data     bss     dec     hex filename
 862434   10156  645924 1518514  172bb2 busybox.old
 862322   10156  645892 1518370  172b22 busybox
function                                             old     new   delta
z_len                                                  4       -      -4
textend                                                4       -      -4
part_nb                                                4       -      -4
insize                                                 4       -      -4
ifile_size                                             4       -      -4
do_link                                                4       -      -4
new_text                                              70      60     -10
ipaddr_list_link                                      33      23     -10
gzip_main                                            898     822     -76
------------------------------------------------------------------------------
(add/remove: 0/6 grow/shrink: 0/3 up/down: 0/-120)           Total: -120 bytes


------------------------------------------------------------------------
r15468 | aldot | 2006-06-21 21:43:05 +0200 (Wed, 21 Jun 2006) | 19 lines

- remove useless global exports
function                                             old     new   delta
rpm_main                                             940    1601    +661
rpm_getstring                                        107     112      +5
rpm_getint                                           148     153      +5
loop_through_files                                   103     106      +3
fileaction_dobackup                                  115     113      -2
fileaction_list                                        5       -      -5
rpm_getcount                                          42       -     -42
extract_cpio_gz                                      161       -    -161
rpm_gettags                                          504       -    -504
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 4/1 up/down: 674/-714)          Total: -40 bytes

   text    data     bss     dec     hex filename
 862322   10156  645892 1518370  172b22 busybox.old
 862290   10156  645892 1518338  172b02 busybox


------------------------------------------------------------------------
r15555 | aldot | 2006-06-30 14:10:11 +0200 (Fri, 30 Jun 2006) | 22 lines

- shrink syslog a little bit, move a big buffer (for 'line') off the bss, fold s
emaphore stuff into single caller manually.
  stats:
function                                             old     new   delta
logMessage                                           395     427     +32
message                                             1245    1257     +12
opts                                                   -       4      +4
small                                                  1       -      -1
local_logging                                          4       -      -4
doRemoteLog                                            4       -      -4
circular_logging                                       4       -      -4
syslogd_main                                        1299    1285     -14
static.res                                            36      16     -20
.rodata                                           186650  186586     -64
static.line                                         1025       -   -1025
------------------------------------------------------------------------------
(add/remove: 1/5 grow/shrink: 2/3 up/down: 48/-1136)        Total: -1088 bytes
cow@s37:~/src/busybox_scratch$ size sysklogd/syslogd.o{.orig,}
   text    data     bss     dec     hex filename
   3723     348    5242    9313    2461 sysklogd/syslogd.o.orig
   3697     348    4188    8233    2029 sysklogd/syslogd.o

==============================================================================
Overall bloatcheck for the changeset mentioned above:
function                                             old     new   delta
rpm_main                                             953    1608    +655
logMessage                                           395     427     +32
message                                             1245    1257     +12
opts                                                   -       4      +4
rpm_getstring                                        107     110      +3
rpm_getint                                           148     151      +3
loop_through_files                                   103     104      +1
small                                                  1       -      -1
fileaction_dobackup                                  115     113      -2
z_len                                                  4       -      -4
textend                                                4       -      -4
part_nb                                                4       -      -4
local_logging                                          4       -      -4
insize                                                 4       -      -4
ifile_size                                             4       -      -4
do_link                                                4       -      -4
doRemoteLog                                            4       -      -4
circular_logging                                       4       -      -4
fileaction_list                                        5       -      -5
new_text                                              70      60     -10
ipaddr_list_link                                      33      23     -10
clear_bufs                                            31      21     -10
syslogd_main                                        1287    1273     -14
builtin_help                                         190     176     -14
static.res                                            36      16     -20
builtin_source                                       229     199     -30
rpm_getcount                                          42       -     -42
gzip_main                                            842     786     -56
.rodata                                           227176  227112     -64
lash_main                                            609     527     -82
busy_loop                                           3883    3739    -144
extract_cpio_gz                                      155       -    -155
rpm_gettags                                          501       -    -501
static.line                                         1025       -   -1025
------------------------------------------------------------------------------
(add/remove: 1/15 grow/shrink: 6/12 up/down: 710/-2221)     Total: -1511 bytes
2006-08-20 17:35:13 +00:00
Rob Landley
d921b2ecc0 Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only
had one user), clean up lots of #includes...  General cleanup pass.  What I've
been doing for the last couple days.

And it conflicts!  I've removed httpd.c from this checkin due to somebody else
touching that file.  It builds for me.  I have to catch a bus.  (Now you know
why I'm looking forward to Mercurial.)
2006-08-03 15:41:12 +00:00
Rob Landley
4795e4e011 Rich Filker spotted that sed -e 's/xxx/[/' didn't work right. Did a smaller
fix than his, and shrank the code a bit on top of that so the net size is
smaller, and added a test to the test suite for this case.  Plus I cleaned up
the #includes and removed unnecessary "const"s while I was there.
2006-07-26 17:25:08 +00:00
"Robert P. J. Day"
63fc1a9e08 Standardize on the vi editing directives being on the first line. 2006-07-02 19:47:05 +00:00
"Robert P. J. Day"
68229837ff Remove all usage of the "register" storage class specifier. 2006-07-01 13:08:46 +00:00
Rob Landley
ea7c18514b Fix http://bugs.busybox.net/view.php?id=826 in which "(echo; echo) | sed x"
crashes because the empty state of the hold space is NULL but the empty
state of the pattern space is "".
2006-06-28 13:50:59 +00:00
Rob Landley
768945b762 A few patches from Erik Hovland, turning strncpy() into safe_strncpy() and
removing some unnecessary code.
2006-06-25 00:34:52 +00:00
Rob Landley
e5e1a10cd3 Remove pointless "inline" wrapper around get_terminal_width_height(). 2006-06-21 01:15:36 +00:00
Rob Landley
2d6af16035 Zubicaray reported a bug in vi that causes it to eat 100% cpu when you close
an xterm it's running in.  The vi signal behavior would catch and restarts lots
of signals, like SIGHUP, that should just kill the thing.  (Leftover behavior
from when it would segfault all the time.)  Filtered out the more obviously
bad ones.  If it segfaults, we should find and fix the problem.
2006-06-21 00:52:31 +00:00
Bernhard Reutner-Fischer
1e23b6fdb5 - make sure that we see string_insert only if we need it. 2006-06-09 07:12:27 +00:00
Bernhard Reutner-Fischer
19008b8373 - reuse strings and messages. Saves about 600B 2006-06-07 20:17:41 +00:00
Rob Landley
12d87550a3 Confirming it's not needed. 2006-06-05 17:32:44 +00:00
Bernhard Reutner-Fischer
a3d4bf38b0 - use bb functions instead of handrolling stuff.
- add XXX question about supposedly superfluous else clause
   text	   data	    bss	    dec	    hex	filename
   5918	      0	      0	   5918	   171e	editors/sed.o.orig
   5901	      0	      0	   5901	   170d	editors/sed.o
2006-06-03 21:40:11 +00:00
Rob Landley
299a6b4d7b Consolidate #include <sys/time.h> so libbb.h does it. 2006-05-27 21:42:58 +00:00
Rob Landley
8bb50782a5 Change llist_add_* to take the address of the list rather than returning the new
head, and change all the callers.
2006-05-26 23:44:51 +00:00
Rob Landley
5fc467e758 Yann Morin spotted some leftover flotsam from halfway through the recent
llist.c interface change that accidentally got checked in.  My bad.
2006-05-24 17:45:47 +00:00
Rob Landley
9ffd42317b Minor cleanups: Convert a few calloc() calls to xzalloc, remove unnecessary
memset, collate variable declarations...
2006-05-21 18:30:35 +00:00
Bernhard Reutner-Fischer
a254065e63 - remove SIGIOT as suggested by landley. 2006-05-19 17:54:05 +00:00
Bernhard Reutner-Fischer
4009ed91f7 - Rich Felker writes:
SIGIOT is not defined in any standard i can find and it seems to be
useless (alias for SIGABRT) on linux. i put it in #ifdef but it's
probably best just to remove it and cut down the size a bit.
2006-05-19 12:41:13 +00:00
Bernhard Reutner-Fischer
d9ed35c8b9 - remove superfluous legacy includes.
This applet should be converted to use llist; __NEED_DLLIST
2006-05-19 12:38:30 +00:00
Bernhard Reutner-Fischer
a2a647dfc1 - include strings.h
Thanks to Rich Felker for pointing this out.
2006-05-19 12:30:00 +00:00
Mike Frysinger
39440e520c pull Rules.mak from top_srcdir as pointed out by Robert P. J. Day on the mailing list 2006-05-13 02:33:09 +00:00
Rob Landley
e3f5a3fd82 Convert sed's static variables to a single global structure. 2006-05-09 03:53:55 +00:00
Rob Landley
0b65628395 Move sed over to the generic llist_t for append. Saves about 90 bytes. 2006-05-08 22:17:23 +00:00
Rob Landley
baa89b398d Patch to fix bug 868, and some related cleanup while I was in the area.
A tab is now taken as the end of filename if it's there, but if it isn't
(because the timestamp isn't there) we continue with the existing untruncated
line as the filename.
2006-05-07 21:10:06 +00:00
Rob Landley
a389651115 Remove bb_strlen() in favor of -fno-builtin-strlen. Saves as many bytes
as the old optimization did (actually does slightly better under gcc 4.0), and
simplifies the code.
2006-05-07 20:20:34 +00:00
Rob Landley
3b89039c25 It was sitting there, in the patches directory, for years. It was delete it
or apply it.  It's small, simple, evil, part of SUSv3, and we can switch it
off.
2006-05-04 20:56:43 +00:00
Mike Frysinger
4b7b8a58a1 touchup comment 2006-04-16 05:55:15 +00:00
Rob Landley
2ec922eed5 Patch from Robert P Day: let menuconfig indent stuff for us, we don't have
to do it in Config.in.
2006-04-13 23:22:16 +00:00
Paul Fox
b7b24d61e0 adjust ifdefs for inclusion of string_insert() routine 2006-04-05 14:17:24 +00:00
Paul Fox
f0305b7f75 fix behavior of ZZ, with respect to readonly mode(s). original
patch and report from Alexander Griesser.
2006-03-28 14:18:21 +00:00
Paul Fox
9360f42d32 add support for :wn (initial patch from Alexander Griesser) 2006-03-27 21:51:16 +00:00
Paul Fox
dbf935dae6 drop obsolete version string in favor of actual BB version (from
Bernhard Fischer)
2006-03-27 20:29:33 +00:00
Bernhard Reutner-Fischer
df10094870 - revert back to r14406 2006-03-13 19:04:00 +00:00
Rob Landley
bc68cd14cc Patch from Denis Vlasenko turning static const int (which gets emitted into
the busybox binary) into enums (which don't).
2006-03-10 19:22:06 +00:00
Rob Landley
1f305dc0fd Portability patch from rfelker. The bb_asprintf.c thing needs an eventual
follow up in platform.h to set the #ifdef, but the workaround works for
everybody, so...
2006-03-09 22:21:20 +00:00
Bernhard Reutner-Fischer
07a79e75f5 - backout using features which are not available with the previous stable
version of make (3.71.1).
2006-03-09 09:03:37 +00:00
Rob Landley
dfba741457 Robert P. Day removed 8 gazillion occurrences of "extern" on function
definitions.  (That should only be on prototypes.)
2006-03-06 20:47:33 +00:00
Bernhard Reutner-Fischer
022eb311d5 - use absolute path for top_builddir and top_srcdir.
Fixes make trying to include the very same file in an endless loop.
2006-03-02 17:33:25 +00:00
Bernhard Reutner-Fischer
c0bb308389 - silence warning about "'free_and_close_stuff' used but never defined" 2006-03-02 10:06:22 +00:00
Bernhard Reutner-Fischer
5d26126b9e - fixes parallel builds (make -j)
- use less resources for the buildsystem itself
2006-03-01 22:54:48 +00:00
Bernhard Reutner-Fischer
b7f39732f8 - fix compilation of sed.
error: static declaration of 'free_and_close_stuff' follows non-static declaration
  Tiny whitespace cleanup while at it,
  also make sure that we don't use CONFIG_ anymore.

Rob, hope this is ok w/ you..
2006-03-01 20:14:16 +00:00
Rob Landley
e7c43b66d7 Cleanup patch from Denis Vlasenko. Mostly variants of removing the if(x)
from before "if(x) free(x)".
2006-03-01 16:39:45 +00:00
Rob Landley
2b26fd5570 A few changes falling out from the effort to make sed handle embedded NUL bytes.
Checking in to reduce the diff between my tree and svn...
2006-02-24 02:30:39 +00:00
Rob Landley
d6e14d8bee Don't build directory libraries unless we're building an applet that needs it.
Cherry-picked from Devin Bayer's big MacOS X patch.
2006-02-21 19:11:35 +00:00
Rob Landley
46e351d478 Patch from awk maintainer (Dmitry Zakhrov) to fix bugs 642, 663, and 667. 2006-02-14 16:05:32 +00:00
Mike Frysinger
b38673fb9f make the build system puuuuuuuuuuurty 2006-02-02 01:41:53 +00:00
"Vladimir N. Oleynik"
dfe6e74157 changed strange mix signed<->unsigned 2006-01-31 09:44:04 +00:00
Eric Andersen
a68ea1cb93 fix up yet more annoying signed/unsigned and mixed type errors 2006-01-30 22:48:39 +00:00
Eric Andersen
5e678873f9 clean up yet more annoying signed/unsigned mismatches and fixup
yet more incorrect types
2006-01-30 19:48:23 +00:00
"Vladimir N. Oleynik"
cd473dd0c1 removed warning "comparison between signed and unsigned". Added ATTRIBUTE_UNUSED. Whitespace 2006-01-30 13:41:53 +00:00
Tim Riker
c1ef7bdd8d just whitespace 2006-01-25 00:08:53 +00:00
Bernhard Reutner-Fischer
86f5c9906b - add platform.h.
- use shorter boilerplate while at it.
2006-01-22 22:55:11 +00:00
Bernhard Reutner-Fischer
7ca61b6f33 - shared libbusybox.
- IMA compilation option (aka IPO, IPA,..)
Please holler if i broke something..
2006-01-15 14:04:57 +00:00
Rob Landley
5184336647 Bug 112, return value of awk should be /256. In reality, we should probably
be using WEXITSTATUS(), but until I can figure out why the heck that would
want to do (*(int *) &(status)) on the value, I'm happy just fixing the bug we
actually see.
2006-01-09 05:26:58 +00:00
Paul Fox
d957b9537e fix bug #474:
0000474: vi crashes often

problem was that the buffer used for "." command ("last_modifying_cmd")
wasn't being maintined correctly -- the recording code was walking back
over the front of that buffer when a repeatable insert command
included backspacing (e.g. "i\b\b\bfoo").  the fix is to simply
record the backspaces along with the rest of the command.
    
also, cleaned up start_new_cmd_q() slightly.
2005-11-28 18:07:53 +00:00
Rob Landley
fae1dc8620 Support # comments after s/// option list. 2005-11-20 07:44:35 +00:00
Rob Landley
c63fe9137f \0 is a synonym for &. Our own "make allbaseconfig" breaks without this. 2005-10-30 10:08:13 +00:00
Bernhard Reutner-Fischer
ee9cf48620 - correct boilerplate
- use bb_xgetlarg for the patch_level to catch invalid arguments.
2005-10-27 06:59:05 +00:00
"Vladimir N. Oleynik"
5cf9a03b3f more const, attribute_noreturn saved 200 bytes 2005-10-19 09:21:51 +00:00
Bernhard Reutner-Fischer
bb20462cb3 - consume space between functionname and opening brackets
Fixes Rob's issue using busybox awk for building gcc-4_0 optionlist (http://busybox.net/lists/busybox/2005-October/016659.html)
2005-10-17 14:21:06 +00:00
"Vladimir N. Oleynik"
6f347ef9dc common BUFSIZ BSS buffer, small reduce code, data and bss 2005-10-15 10:23:55 +00:00
Bernhard Reutner-Fischer
554a9ff7ea - do not use bb_xgetularg10_bnd as a lower value of -1 doesn't work due to lowe
being unsigned.
- minor correction: use stdin only when no file was given via -i.
- use shorter boilerplate.
2005-10-10 13:34:19 +00:00
Paul Fox
61e45dbb2f catch and report errors from file_write() 2005-10-09 14:43:22 +00:00
Paul Fox
90372ed51a make Hit_Return() available when CONFIG_FEATURE_VI_COLON is off. it's
needed elsewhere as well now.
2005-10-09 14:26:26 +00:00
"Vladimir N. Oleynik"
ba248206fe change strange depend to libbb.h, but require busybox.h 2005-10-06 15:18:09 +00:00
Mike Frysinger
f87b3e30a7 as pointed out in Bug 17, use uint32_t instead of unsigned long since the code expects the size of the info variables to be 32bits and sizeof(long) on 64bit hosts is not 32bits 2005-09-27 04:16:22 +00:00
Mike Frysinger
de2b93859c eat misappropriated whitespace 2005-09-27 03:18:00 +00:00
Mike Frysinger
10a11e23ba uncuddle function scope brackets 2005-09-27 02:23:02 +00:00
Mike Frysinger
62f18e1f20 use the shorter license header 2005-09-24 07:16:29 +00:00
Mike Frysinger
0d4ee68be5 use brief license line 2005-09-24 06:01:57 +00:00
Paul Fox
c350485b18 initialize a couple of vars whose warnings were suppressed because
i was building w/ debug on before, which suppresses optimization.
2005-09-16 12:48:18 +00:00
Paul Fox
8552aec7fd some combinations of status line and screen refresh don't give a
correct screen, and bug 215 reports trouble with the status line
on small screens.

with this change a) the status line should always be refreshed
properly, b) the status line is a little shorter than it used to
be ("I" instead of "--INSERT--"), c) the status line will be
truncated if it doesn't fit on the screen, and d) if the screen
is too narrow for an error or transient status message (from
psb() or psbs()), then that message will be followed by a "Hit
Return" prompt.  (it wasn't until i did this last bit that the
size grew.  with this, these changes add about 150 bytes.)

- pgf
2005-09-16 12:20:05 +00:00
"Vladimir N. Oleynik"
23f62fc6f3 split libbb: moved xregcomp separatelly for speed up recompile 2005-09-14 16:59:11 +00:00
"Vladimir N. Oleynik"
b4f3cff6f5 removed strange extern void xregcomp(... from some applets, but declared from libbb.h 2005-09-14 16:22:50 +00:00
Paul Fox
f2de0b7ae4 allow either backspace or DEL, in addition to the user's erase
char, to be used in get_input_line()
2005-09-13 22:20:37 +00:00
Rob Landley
babd3fbba6 Missing break was screwing up 'y//' command. Bug #248. 2005-09-02 00:10:06 +00:00
Rob Landley
078bacf1e9 Patch -i support from Berhnard Fischer. 2005-09-01 03:02:23 +00:00
Mike Frysinger
4d00896d05 use toplevel ARFLAGS and update default ARFLAGS to be quiet 2005-07-27 01:09:24 +00:00
Paul Fox
18433aadf6 applying fix for:
0000118: vi join command does not mark file as modified for certain lines.
2005-07-20 17:39:52 +00:00
Paul Fox
d13b90b9e8 allow both ^H and DEL to backspace in insert mode (bug #23) 2005-07-18 22:17:25 +00:00
Eric Andersen
0ef24c672a Fix vi so that error messages, insert mode messages, etc are
all actually displayed in the status line as expected
2005-07-18 10:32:59 +00:00
Rob Landley
ed830e8693 Patch from Dmitry Zakharov:
Charlie Brady wrote:
> Here's another awk parsing problem - unary post increment - pre is fine:
>
>bash-2.05a$ echo 2,3 | gawk -F , '{ $2++ }'
>bash-2.05a$ echo 2,3 | /tmp/busybox/busybox awk -F , '{ $2++ }'
>awk: cmd. line:1: Unexpected token
>
Here's a fix for this. There is another problem with constructions like 
"print (A+B) ++C", I don't
know whether somebody uses such constructions (fixing both these 
problems would require very
serious change in awk code).
2005-06-07 02:43:52 +00:00
Rob Landley
93850a56b2 Patch from Colin Watson (mangled slightly by Rob Landley):
This patch implements the 'T' command in sed. This is a GNU extension,
but one of the udev hotplug scripts uses it, so I need it in busybox
anyway.

Includes a test; 'svn add testsuite/sed/sed-branch-conditional-inverted'
after applying.
2005-05-18 06:34:37 +00:00
Rob Landley
5797c7f0ef Doug Swarin pointed out a security bug in the -i option of sed.
While the permissions on the temp file are correct to prevent it from being 
maliciously mangled by passing strangers, (created with 600, opened O_EXCL, 
etc), the permissions on the _directory_ might not be, and we re-open the 
file to convert the filehandle to a FILE * (and automatically get an error 
message and exit if the directory's read-only or out of space or some such).

This opens a potential race condition if somebody's using dnotify on the 
directory, deletes/renames the tempfile, and drops a symlink or something 
there.  Somebody running sed -i as root in a world writeable directory could 
do damage.

I dug up notes on an earlier discussion where we looked at the security 
implications of this (unfortunately on the #uclibc channel rather than email; 
I don't have a transcript, just notes-to-self) which pointed out that if the 
permissions on the directory allow other people's files to be deleted/renamed 
then the original file is vulnerable to sabotage anyway.  However, there are 
two cases that discussion apparently didn't take into account:

1) Using another user's permissions to damage files in other directories you 
can't access (standard symlink attack).

2) Reading data another user couldn't otherwise access by having the new file 
belong to that other user.

This patch uses fdopen to convert the filehandle into a FILE *, rather than
reopening the file.
2005-05-18 05:56:16 +00:00
Eric Andersen
14f5c8d764 Patch from Bernhard Fischer to make a bunch of symbols static
which were otherwise cluttering the global namespace.
2005-04-16 19:39:00 +00:00
Mike Frysinger
4e5936ef95 In Bug 208, bernhardf writes:
On machines with only ANSI compliant compilers, not explitily delcaring
an empty parameter list 'void' causes failure.
2005-04-16 04:30:38 +00:00
Rob Landley
dcc286607c Hiroshi found another bug. Currently sed's $ triggers at end of every file,
and with multiple files SuSv3 says it should only trigger at the end of the
LAST file.

The trivial fix I tried first broke if the last file is empty.  Fixing this
properly required restructuring things to create a file list (actually a
FILE * list), and then processing it all in one go.  (There's probably a
smaller way to do this, merging with append_list perhaps.  But let's get
the behavior correct first.)

Note that editing files in place (-i) needs the _old_ behavior, with $
triggering at the end of each file.

Here's a test of all the things this patch fixed.  gnu and busybox seds produce
the same results with this patch, and different without it.

echo -n -e "1one\n1two\n1three" > ../test1
echo -n > ../test2
echo -e "3one\n3two\n3three" > ../test3
sed -n "$ p" ../test1 ../test2 ../test3
sed -n "$ p" ../test1 ../test2
sed -i -n "$ p" ../test1 ../test2 ../test3
2004-11-25 07:21:47 +00:00
Rob Landley
ce4f0e982b Hiroshi Ito found some bugs. The 'c' command (cut and paste) was hardwired
to not put a newline at the end (which was backwards, it should have been
hardwired _to_ put a newline at the end, whether or not the input line
ended with a newline).  Test case for that:

echo | sed -e '$ctest'

And then this would segfault:

echo | sed -e 'g'

Because pattern_space got freed but the dead pointer was only overwritten
in an if statement that didn't trigger if the hold space was empty.  Oops.

While debugging it, I found out that the hold space is persistent between
multiple input files, so I promoted it to a global and added it to the
memory cleanup.  The relevant test case (to compare with That Other Sed) is:

echo -n woo > woo
sed -e h -e g woo
echo "fish" | sed -e '/woo/h' -e "izap" -e 's/woo/thingy/' -e '/fish/g' woo -

And somebody gratuitously stuck in a c99 int8_t type for something that's just
a flag, so I grouped the darn ints.
2004-10-30 06:54:19 +00:00
Eric Andersen
7daa076d3e egor duda writes:
Hi!

I've created a patch to busybox' build system to allow building it in
separate tree in a manner similar to kbuild from kernel version 2.6.

That is, one runs command like
'make O=/build/some/where/for/specific/target/and/options'
and everything is built in this exact directory, provided that it exists.

I understand that applyingc such invasive changes during 'release
candidates' stage of development is at best unwise. So, i'm currently
asking for comments about this patch, starting from whether such thing
is needed at all to whether it coded properly.

'make check' should work now, and one make creates Makefile in build
directory, so one can run 'make' in build directory after that.

One possible caveat is that if we build in some directory other than
source one, the source directory should be 'distclean'ed first.

egor
2004-10-08 07:46:08 +00:00
Glenn L McGrath
ca29ffc206 Patch from Dmitry Zakharov to fix a bug triggered by freeswan's scripts. 2004-09-24 09:24:27 +00:00
Eric Andersen
a9eb33ddc7 regularly update the status line display
-Erik
2004-08-19 19:15:06 +00:00
Eric Andersen
67776bef59 Simon Poole reports that awk segfaults when environment variables
with no value exist, i.e.

	$ export BOB=''
	% ./busybox awk
	Segmentation fault

This patch teaches awk to not blow chunks on empty env variables.
 -Erik
2004-07-30 23:52:08 +00:00
Glenn L McGrath
1fbc909570 Patch from Dmitry Zakharov to fix a bug discovered via the freeswap
script.
2004-07-23 02:11:25 +00:00
Eric Andersen
165e8cbf34 Assign 'forced' before the goto to avoid a warning 2004-07-20 06:44:46 +00:00
Eric Andersen
9855548a77 Rob Landley writes:
add sed -r support.

I bumped into a couple of things that want to use extended regular expressions
in sed, and it really isn't that hard to add.  Can't say I've extensively
tested it, but it's small and isn't going to break anything that doesn't use
it, so...

Rob
2004-05-26 10:03:33 +00:00
Glenn L McGrath
21d7d61de1 Use int instead of char for return type, in theory avoiding a cast 2004-05-16 02:35:49 +00:00
Glenn L McGrath
5d2edbf16d Fix for debian bug #248106, should use int for returned getopt value. 2004-05-10 08:59:17 +00:00
Glenn L McGrath
c6992feee3 Update my email address, document some of my tasks in the AUTHORS file 2004-04-25 05:11:19 +00:00
Eric Andersen
b94669543d This sed patch can only be described as "duh". Stat the source file, chmod
the _destination_ file.  (Ah hah!  That works _much_ better...)  I
implemented the behavior, I just forgot to test this corner of it.  My fault,
sorry...

No, gnu sed -i doesn't preverve ownership information.  I checked.
Permissions, yes, ownership info, no.

Rob
2004-04-21 00:57:14 +00:00
Eric Andersen
faa7d863fc So I'm building a linux from scratch system, using a working script to do this
that the _only_ change to is that gnu sed has been replaced with busybox sed.
And ncurses' install phase hangs.  I trace it down, and it's trying to run
gawk.  (Insert obligatory doubletake, but this is FSF code we're talking
about, so...)

It turns out gawk shells out to sed, ala "sed -f /tmp/blah file.h".  The
/tmp/blah file is basically empty (it contains one character, a newline).  So
basically, gawk is using sed as "cat".  With gnu sed, it works like cat,
anyway.

With busybox sed, it tests if its command list is empty after parsing the
command line, and if the list is empty it takes the first file argument as a
sed command string, and if that leaves the file list empty it tries to read
the data to operate on from stdin.  (Hence the hang, since nothing's coming
in on stdin...)

It _should_ be testing whether there were any instances of -f or -e, not
whether it actually got any commands.  Using sed as cat may be kind of
stupid, but it's valid and gawk relies on this behavior.

Here's a patch to fix it, turning a couple of ints into chars in hopes of
saving a bit of the space this adds.  Comments?

Rob
2004-04-21 00:56:22 +00:00
Eric Andersen
aff114c33d Larry Doolittle writes:
This is a bulk spelling fix patch against busybox-1.00-pre10.
If anyone gets a corrupted copy (and cares), let me know and
I will make alternate arrangements.

Erik - please apply.

Authors - please check that I didn't corrupt any meaning.

Package importers - see if any of these changes should be
passed to the upstream authors.

I glossed over lots of sloppy capitalizations, missing apostrophes,
mixed American/British spellings, and German-style compound words.

What is "pretect redefined for test" in cmdedit.c?

Good luck on the 1.00 release!

      - Larry
2004-04-14 17:51:38 +00:00
Rob Landley
25d82397f7 The last patch broke:
sed -i "/^boo/a fred" ipsec.conf

Which works in gnu sed.  (And is _supposed_ to strip all the whitespace before
"fred".)

It also broke:
sed -i -e "/^boo/a \\" -e "   fred" ipsec.conf

I.E. there can legally be spaces between the a and the backslash at the end of
the line.

And strangely enough, gnu sed accepts the following syntax as well:
sed -i "/^boo/a \\  fred" ipsec.conf

Which is a way of having the significant whitespace at the start of the line,
all on one line.  (But notice that the whitespace BEFORE the slash is still
stripped, as is the slash itself.  And notice that the naieve placement of
"\n" there doesn't work, it puts an n at the start of the appended line.  The
double slashing is for shell escapes because you could escape the quote, you
see.  It's turned into a single backslash.  But \n there is _not_ turned into
a newline by the shell.  So there.)

This makes all three syntaxes work in my tests.  I should probably start
writing better documentation at some point.  I posted my current sedtests.py
file to the list, which needs a lot more tests added as well...
2004-04-01 09:23:30 +00:00
Eric Andersen
46390ed829 Junio Hamano, junio at twinsun dot com writes:
The sed command in busybox 1.0.0-pre8 loses leading whitespace
in 'a' command ('i' and 'c' commands are also affected).  A
patch to fix this is attached at the end of this message.

The following is a transcript that reproduces the problem.  The
first run uses busybox 1.0.0-pre3 as "/bin/sed" command, which
gets the expected result.  Later in the test, /bin/sed symlink
is changed to point at busybox 1.0.0-pre8 and the test script is
run again, which shows the failure.

=== reproduction recipe ===
* Part 1.  Use busybox 1.0.0-pre3 as sed; this works.

root# cd /tmp
root# cat 1.sh
#!/bin/sh

cd /tmp
rm -f ipsec.conf ipsec.conf+
cat >ipsec.conf <<\EOF
version 2.0

config setup
        klipsdebug=none
        plutodebug=none
        plutostderrlog=/dev/null

conn %default
        keyingtries=1
        ...
EOF
sed -e '/^config setup/a\
	nat_traversal=yes' ipsec.conf >ipsec.conf+
mv -f ipsec.conf+ ipsec.conf
root# sh -x 1.sh
+ cd /tmp
+ rm -f ipsec.conf ipsec.conf+
+ cat
+ sed -e /^config setup/a\
        nat_traversal=yes ipsec.conf
+ mv -f ipsec.conf+ ipsec.conf
root# cat ipsec.conf
version 2.0

config setup
        nat_traversal=yes
        klipsdebug=none
        plutodebug=none
        plutostderrlog=/dev/null

conn %default
        keyingtries=1
        ...
root# sed --version
sed: invalid option -- -
BusyBox v1.00-pre3 (2004.02.26-18:47+0000) multi-call binary

Usage: sed [-nef] pattern [files...]

* Part 2.  Continuing from the above, use busybox 1.0.0-pre8
  as sed; this fails.

root# ln -s busybox-pre8 /bin/sed-8
root# mv /bin/sed-8 /bin/sed
root# sed --version
This is not GNU sed version 4.0
root# sed --
BusyBox v1.00-pre8 (2004.03.30-02:44+0000) multi-call binary

Usage: sed [-nef] pattern [files...]
root# sh -x 1.sh
+ cd /tmp
+ rm -f ipsec.conf ipsec.conf+
+ cat
+ sed -e /^config setup/a\
        nat_traversal=yes ipsec.conf
+ mv -f ipsec.conf+ ipsec.conf
root# cat ipsec.conf
version 2.0

config setup
nat_traversal=yes
        klipsdebug=none
        plutodebug=none
        plutostderrlog=/dev/null

conn %default
        keyingtries=1
        ...
root#
=== reproduction recipe ends here ===

This problem was introduced in 1.0.0-pre4.  The problem is that
the command argument parsing code strips leading whitespaces too
aggressively.  When running the above example, the piece of code
in question gets "\n\tnat_traversal=yes" as its argument in
cmdstr variable (shown part in the following patch).  What it
needs to do at this point is to strip the first newline and
nothing else, but it instead strips all the leading whitespaces
at the beginning of the string, thus losing the tab character.
The following patch fixes this.
2004-03-31 11:42:40 +00:00
Eric Andersen
90fb65f7a6 Patch from Thomas Winkler -- vi -R did not work 2004-03-31 11:12:51 +00:00
Eric Andersen
c7bda1ce65 Remove trailing whitespace. Update copyright to include 2004. 2004-03-15 08:29:22 +00:00
Glenn L McGrath
4bded58207 Patch from Dmitry Zakharov, this line was missedfrom the last patch 2004-02-22 11:55:09 +00:00
Rob Landley
53302f80da Add -i option to sed, to edit files in-place. 2004-02-18 09:54:15 +00:00
Eric Andersen
5cc90eade5 Richard Kojedzinszky writes:
Hi All,

I aplogoize for the mistake, but i have just recognized that somehow the
last patch I sent in was wrong, and a '0' was instead of a '-1'. Because
of this, vi does behave the wrong way. So again, it should be the last
patch for vi. This is for pre7.
2004-02-06 10:36:08 +00:00
Eric Andersen
aeea32ca69 Richard Kojedzinszky writes:
Hi,

I've noticed the bug also, and here is another patch for it. I hope it'll
not introduce more bugs. Not too nice, but works for me.

Here it is for busybox-1.00-pre6
2004-02-04 11:19:44 +00:00
Eric Andersen
c06f568dda Rob Landley writes:
While building glibc with busybox as part of the development environment, I
found a bug in glibc's regexec can throw sed into an endless loop.  This
fixes it.  Should I put an #ifdef around it or something?  (Note, this patch
also contains the "this is not gnu sed 4.0" hack I posted earlier, which is
also needed to build glibc...)
2004-02-04 10:57:46 +00:00
Glenn L McGrath
ee829065cb Patch by Richard Kojedzinszky, when using END at end of lines it was
skipping to next line, cw command was leaving one char in buffer
2004-01-21 10:59:45 +00:00
Rob Landley
40ec4aeb8e Thinko in s//options. (Whitespace skipping in the wrong place.) 2004-01-04 06:42:14 +00:00
Eric Andersen
d10f36fe2e Match changes made to cmdedit 2003-12-23 20:45:14 +00:00
Eric Andersen
52a3c2726e Patch from Matt Kraai:
sed is broken:

 busybox sed -n '/^a/,/^a/p' >output <<EOF
 a
 b
 a
 b
 EOF
 cmp -s output - <<EOF
 a
 b
 a
 EOF

The attached patch fixes it.
2003-12-23 08:53:51 +00:00
Glenn L McGrath
00ed36fd52 Patch from Dmitry Zakharov,
Fixes two bugs:
- END block didn't execute after an exit() call
- huge memory consumption and performance degradation on large input
(now performance is comparable to gawk)
2003-10-30 13:36:39 +00:00
Eric Andersen
88c916bdec Andreas Mohr writes:
the busybox menuconfig triggered my "inacceptable number of spelling mistakes"
upper level, so I decided to make a patch ;-)

I also improved some wording to describe some things in a better way.

Many thanks for an incredible piece of software!

Andreas Mohr, random OSS developer
2003-10-22 09:58:56 +00:00
Eric Andersen
638da75f4b Fix some warnings that have crept in recently 2003-10-09 08:18:36 +00:00
Glenn L McGrath
586d86cc8c Comaptability with gcc-2.95 2003-10-09 07:22:59 +00:00
Glenn L McGrath
42c25735e6 Patch from Rob Landley;
Moving on to building diffutils, busybox sed needs this patch to get
past the first problem.  (Passing it a multi-line command line argument
with -e works, but if you don't use -e it doesn't break up the multiple
lines...)
2003-10-04 05:27:56 +00:00
Glenn L McGrath
0ad4daa54e Patch from Rob Landley to fix backrefs 2003-10-01 10:26:23 +00:00
Glenn L McGrath
738fb33994 Patch by Rob Landley, fix "newline after edit command" 2003-10-01 06:45:11 +00:00
Glenn L McGrath
aa5a602689 Patch by Rob Landley, work in progress update, fixes lots of bugs,
introduces a few others (but they are being worked on)
2003-10-01 03:06:16 +00:00
Glenn L McGrath
761ec20f81 Fix some typo's, remove some extra free statements 2003-09-24 10:23:39 +00:00
Glenn L McGrath
2570b43e82 Configuration option to define wether to follows GNU sed's behaviour
or the posix standard.
Put the cleanup code back the way it was.
2003-09-16 05:25:43 +00:00
Glenn L McGrath
204ff1cea4 Fix a bug that creapt in recently with substitution subprinting, and add
a test for it.
2003-09-16 01:46:36 +00:00