Replace index_in_[sub]str_array with index_in_[sub]strings,
which scans thru "abc\0def\0123\0\0" type strings. Saves 250 bytes.
text data bss dec hex filename
781266 1328 11844 794438 c1f46 busybox_old
781010 1328 11844 794182 c1e46 busybox_unstripped
diff --git a/networking/slattach.c b/networking/slattach.c
index 1a4423b..4bac879 100644
--- a/networking/slattach.c
+++ b/networking/slattach.c
@@ -16,16 +16,6 @@
#include "libbb.h"
#include "libiproute/utils.h" /* invarg() */
-/* Line discipline code table */
-static const char *const proto_names[] = {
- "cslip"+1, /* 0 */
- "cslip", /* 1 */
- "cslip6"+1, /* 2 */
- "cslip6", /* 3 */
- "adaptive", /* 8 */
- NULL
-};
-
struct globals {
int handle;
int saved_disc;
@@ -132,6 +122,15 @@
int slattach_main(int argc, char **argv);
int slattach_main(int argc, char **argv)
{
+ /* Line discipline code table */
+ static const char proto_names[] =
+ "slip\0" /* 0 */
+ "cslip\0" /* 1 */
+ "slip6\0" /* 2 */
+ "cslip6\0" /* 3 */
+ "adaptive\0" /* 8 */
+ ;
+
int i, encap, opt;
struct termios state;
const char *proto = "cslip";
@@ -160,7 +159,7 @@
if (!*argv)
bb_show_usage();
- encap = index_in_str_array(proto_names, proto);
+ encap = index_in_strings(proto_names, proto);
if (encap < 0)
invarg(proto, "protocol");