aboutsummaryrefslogtreecommitdiff
path: root/coreutils/tr.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-07-24 15:54:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-07-24 15:54:42 +0000
commit990d0f63eeb502c8762076e5c5499196e09cba55 (patch)
tree30a2091a8159b1694d65f9952e2aba2667d7dc11 /coreutils/tr.c
parentbcb66ec22e82f6b1ab93f3aec917269393a5b464 (diff)
downloadbusybox-w32-990d0f63eeb502c8762076e5c5499196e09cba55.tar.gz
busybox-w32-990d0f63eeb502c8762076e5c5499196e09cba55.tar.bz2
busybox-w32-990d0f63eeb502c8762076e5c5499196e09cba55.zip
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
Diffstat (limited to 'coreutils/tr.c')
-rw-r--r--coreutils/tr.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/coreutils/tr.c b/coreutils/tr.c
index c0d0dfacb..594571833 100644
--- a/coreutils/tr.c
+++ b/coreutils/tr.c
@@ -51,11 +51,10 @@ static unsigned int expand(const char *arg, char *buffer)
51 char *buffer_start = buffer; 51 char *buffer_start = buffer;
52 unsigned i; /* XXX: FIXME: use unsigned char? */ 52 unsigned i; /* XXX: FIXME: use unsigned char? */
53 unsigned char ac; 53 unsigned char ac;
54#define CLO ":]" 54#define CLO ":]\0"
55 static const char * const classes[] = { 55 static const char classes[] =
56 "alpha"CLO, "alnum"CLO, "digit"CLO, "lower"CLO, "upper"CLO, "space"CLO, 56 "alpha"CLO "alnum"CLO "digit"CLO "lower"CLO "upper"CLO "space"CLO
57 "blank"CLO, "punct"CLO, "cntrl"CLO, NULL 57 "blank"CLO "punct"CLO "cntrl"CLO;
58 };
59#define CLASS_invalid 0 /* we increment the retval */ 58#define CLASS_invalid 0 /* we increment the retval */
60#define CLASS_alpha 1 59#define CLASS_alpha 1
61#define CLASS_alnum 2 60#define CLASS_alnum 2
@@ -90,7 +89,7 @@ static unsigned int expand(const char *arg, char *buffer)
90 smalluint j; 89 smalluint j;
91 { /* not really pretty.. */ 90 { /* not really pretty.. */
92 char *tmp = xstrndup(arg, 7); // warning: xdigit needs 8, not 7 91 char *tmp = xstrndup(arg, 7); // warning: xdigit needs 8, not 7
93 j = index_in_str_array(classes, tmp) + 1; 92 j = index_in_strings(classes, tmp) + 1;
94 free(tmp); 93 free(tmp);
95 } 94 }
96 if (j == CLASS_alnum || j == CLASS_digit) { 95 if (j == CLASS_alnum || j == CLASS_digit) {