Ron Yorston | 29 May 18:22 2015

[PATCH] lineedit: skip non-executables when tab-completing commands

Of course, on *nix systems there are probably very few non-executables
in directories on PATH.

Signed-off-by: Ron Yorston <rmy <at> pobox.com>
---
 libbb/lineedit.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 2ddb2b6..1fd0dbc 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
 <at>  <at>  -817,6 +817,9  <at>  <at>  static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
 			if (stat(found, &st) && lstat(found, &st))
 				goto cont; /* hmm, remove in progress? */

+			if (type == FIND_EXE_ONLY && !file_is_executable(found))
+				goto cont;
+
 			/* Save only name */
 			len = strlen(name_found);
 			found = xrealloc(found, len + 2); /* +2: for slash and NUL */
--

-- 
2.1.0
Ron Yorston | 29 May 12:32 2015

[PATCH] which: search applet table in standalone shell mode

function                                             old     new   delta
which_main                                           245     276     +31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 31/0)               Total: 31 bytes

Signed-off-by: Ron Yorston <rmy <at> pobox.com>
---
 debianutils/which.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/debianutils/which.c b/debianutils/which.c
index d50e7a0..c00453b 100644
--- a/debianutils/which.c
+++ b/debianutils/which.c
 <at>  <at>  -16,6 +16,7  <at>  <at> 
 //usage:       "/bin/login\n"

 #include "libbb.h"
+#include "NUM_APPLETS.h"

 int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int which_main(int argc UNUSED_PARAM, char **argv)
 <at>  <at>  -34,6 +35,15  <at>  <at>  int which_main(int argc UNUSED_PARAM, char **argv)
 	do {
 		int missing = 1;

+#if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1
+		if ( find_applet_by_name(*argv) >= 0 ) {
+			missing = 0;
+			puts(*argv);
(Continue reading)

Ron Yorston | 29 May 12:31 2015

[PATCH] lineedit: search applets as well as PATH for tab completion

In standalone shell mode search the applet table as well as PATH
when tab completing a command.

Use a stupid linear search:  we're also about to read all the
directories on PATH so efficiency isn't a big concern.

function                                             old     new   delta
add_match                                              -      53     +53
complete_cmd_dir_file                                687     724     +37
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 90/0)               Total: 90 bytes

Signed-off-by: Ron Yorston <rmy <at> pobox.com>
---
 libbb/lineedit.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index a83e07c..2ddb2b6 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
 <at>  <at>  -47,7 +47,8  <at>  <at> 
  * It stems from simplistic "cmdedit_y = cmdedit_prmt_len / cmdedit_termw"
  * calculation of how many lines the prompt takes.
  */
-#include "libbb.h"
+#include "busybox.h"
+#include "NUM_APPLETS.h"
 #include "unicode.h"
 #ifndef _POSIX_VDISABLE
(Continue reading)

Bartosz Golaszewski | 29 May 12:11 2015
Picon

[PATCH v3 0/4] i2c-tools fixes

This series fixes one major issue and two smaller bugs in i2cdetect and
reworks i2cdump_main().

v3:
- drop the check for COMMON_BUFSIZE < block buffer size as it's highly
  unlikely, isn't it?

v2:
- added i2cdump code rework to the series
- fixed an unneeded indentation in i2cdetect

Bartosz Golaszewski (4):
  i2cdetect: don't die on addresses already in use by drivers
  i2cdetect: don't scan non-regular addresses without the '-a' option
  i2cdetect: add a check for (mode == DETECT_MODE_AUTO)
  i2cdump: code rework

 miscutils/i2c_tools.c | 355 +++++++++++++++++++++++++++-----------------------
 1 file changed, 192 insertions(+), 163 deletions(-)

--

-- 
2.1.4
Natanael Copa | 29 May 10:08 2015

[PATCH] lineedit: trivial codeshrink for vi-mode

Introduce and use BB_isalnum_or_underscore().

bloatcheck on x86_64:
function                                             old     new   delta
BB_isalnum_or_underscore                               -      46     +46
vi_end_motion                                        176     166     -10
vi_back_motion                                       169     155     -14
vi_word_motion                                       190     172     -18
BB_isalnum                                            39       -     -39
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/3 up/down: 46/-81)            Total: -35
bytes

Signed-off-by: Natanael Copa <ncopa <at> alpinelinux.org>
---
 libbb/lineedit.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index a83e07c..507b829 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
 <at>  <at>  -81,6 +81,9  <at>  <at> 
 static bool BB_isspace(CHAR_T c) { return ((unsigned)c < 256 && isspace(c)); }
 # if ENABLE_FEATURE_EDITING_VI
 static bool BB_isalnum(CHAR_T c) { return ((unsigned)c < 256 && isalnum(c)); }
+static bool BB_isalnum_or_underscore(CHAR_T c) {
+	return (BB_isalnum(c) || c == '_');
+}
 # endif
(Continue reading)

Bartosz Golaszewski | 27 May 16:21 2015
Picon

[PATCH v2 0/4] i2c-tools fixes

This series fixes one major issue and two smaller bugs in i2cdetect and
reworks i2cdump_main().

v2:
- added i2cdump code rework to the series
- fixed an unneeded indentation in i2cdetect

Bartosz Golaszewski (4):
  i2cdetect: don't die on addresses already in use by drivers
  i2cdetect: don't scan non-regular addresses without the '-a' option
  i2cdetect: add a check for (mode == DETECT_MODE_AUTO)
  i2cdump: code rework

 miscutils/i2c_tools.c | 368 ++++++++++++++++++++++++++++----------------------
 1 file changed, 205 insertions(+), 163 deletions(-)

--

-- 
2.1.4
Maninder Singh | 27 May 06:20 2015

[PATCH 1/1] Removes stray empty line from code.

From: Maninder Singh <maninder1.s <at> samsung.com>

This patch removes stray empty line from busybox code
reported by script find_stray_empty_lines

Signed-off-by: Maninder Singh <maninder1.s <at> samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k <at> samsung.com>
---
 archival/cpio.c                             |    1 -
 archival/gzip.c                             |    3 ---
 archival/libarchive/bz/compress.c           |    1 -
 archival/libarchive/decompress_uncompress.c |    1 -
 archival/libarchive/lzo1x_9x.c              |    1 -
 archival/libarchive/unxz/xz_dec_lzma2.c     |    3 ---
 archival/libarchive/unxz/xz_dec_stream.c    |    2 --
 archival/unzip.c                            |    2 --
 console-tools/showkey.c                     |    1 -
 coreutils/ln.c                              |    1 -
 editors/awk.c                               |   12 ------------
 editors/ed.c                                |    1 -
 editors/vi.c                                |    1 -
 libbb/appletlib.c                           |    1 -
 libbb/in_ether.c                            |    1 -
 libbb/procps.c                              |    1 -
 libbb/xfuncs.c                              |    1 -
 mailutils/reformime.c                       |    1 -
 miscutils/crontab.c                         |    1 -
 networking/arp.c                            |    1 -
 networking/ntpd.c                           |    1 -
 networking/tftp.c                           |    1 -
(Continue reading)

Bartosz Golaszewski | 25 May 12:40 2015
Picon

[PATCH 0/3] i2cdetect fixes

Please disregard the separate patch I sent earlier - there are more issues
that need fixing with i2cdetect.

This series fixes one major issue and two smaller bugs.

Bartosz Golaszewski (3):
  i2cdetect: don't die on addresses already in use by drivers
  i2cdetect: don't scan non-regular addresses without the '-a' option
  i2cdetect: add a check for (mode == DETECT_MODE_AUTO)

 miscutils/i2c_tools.c | 39 +++++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 14 deletions(-)

--

-- 
2.1.4
Bartosz Golaszewski | 25 May 11:14 2015
Picon

[PATCH] i2cdetect: don't die on addresses already in use by drivers

We can't use i2c_set_slave_addr() in i2cdetect, as we have to check for
EBUSY after calling ioctl(I2C_SLAVE) and print 'UU' on busy addresses
instead of bailing-out.

While we're at it: reorder definitions of local vars in i2cdetect_main().

function                                             old     new   delta
i2cdetect_main                                       703     744     +41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 41/0)               Total: 41 bytes
   text	   data	    bss	    dec	    hex	filename
 826097	   4164	   9584	 839845	  cd0a5	busybox_old
 826145	   4164	   9584	 839893	  cd0d5	busybox_unstripped

Signed-off-by: Bartosz Golaszewski <bartekgola <at> gmail.com>
---
 miscutils/i2c_tools.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index 7034dc9..b05968b 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
 <at>  <at>  -355,6 +355,13  <at>  <at>  static void i2c_set_pec(int fd, int pec)
 				itoptr(pec ? 1 : 0),
 				"can't set PEC");
 }
+
+static void i2c_set_slave_addr(int fd, int addr, int force)
+{
(Continue reading)

bifferos | 24 May 13:17 2015
Picon

Bug in miscutils/dc.c


bash-4.2$ ./dc p
2.122e-313
(on my x86 machine)

Attempting to print the last value off a non-existent stack should probably error, just like a pop().

My trivial fix is here:
https://github.com/bifferos/bb/commit/4a06b0e0541a7049c4b4dc93c252c4d988af1b21

regards,
Biff.
bifferos | 23 May 23:41 2015
Picon

How to compare two floats?

I'm trying to write a thermostat using busybox shell, however the only way I could think to compare two float temperatures (without adding awk) was to multiply them up in dc and then compare as integers.

In the end I modified dc to add a comparison operator, which probably breaks the spirit of dc somewhat.  I'm interested if I missed a trick somewhere.  Is there another way to do this?  Is this considered a heinous thing to do to dc?

Thanks,
Biff.

--- a/miscutils/dc.c
+++ b/miscutils/dc.c
<at> <at> -103,6 +103,18 <at> <at> static void divide(void)
        push(pop() / divisor);
 }
 
+static void gt(void)
+{
+       double rhs = pop();
+       push((pop() > rhs) ? 1 : 0);
+}
+
+static void ge(void)
+{
+       double rhs = pop();
+       push((pop() >= rhs) ? 1 : 0);
+}
+
 static void mod(void)
 {
        data_t d = pop();
<at> <at> -204,6 +216,8 <at> <at> static const struct op operators[] = {
        {"mul", mul},
        {"/",   divide},
        {"div", divide},
+       {"gt", gt},
+       {"ge", ge},
 #if ENABLE_FEATURE_DC_LIBM
        {"**",  power},
        {"exp", power},


_______________________________________________
busybox mailing list
busybox <at> busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Gmane