Package: dash Version: 0.5.3-9 Severity: normal Tags: patch Please consider attached test cases and patch set (with additional size/speed optimizations).
Thanks. -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (776, 'unstable'), (775, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.18-4-amd64 (SMP w/1 CPU core) Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Shell: /bin/sh linked to /bin/dash Versions of packages dash depends on: ii libc6 2.5-11 GNU C Library: Shared libraries dash recommends no packages. -- debconf information: * dash/sh: true
>From [EMAIL PROTECTED] Sun Jul 01 16:05:29 2007 Subject: [patch 01/03] dash, test: whitespace cleanup (as done by default by emacs) Content-Disposition: inline; filename=dash-test-bltin-whitespace-cleanup-by-emacs.patch Status: RO Content-Length: 1300 Lines: 62 Some trailing whitespace was killed or tabified. -- -o--=O`C #oo'L O <___=E M --- src/bltin/test.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) Index: dash-0.5.3/src/bltin/test.c =================================================================== --- dash-0.5.3.orig/src/bltin/test.c 2005-11-26 04:17:55.000000000 +0100 +++ dash-0.5.3/src/bltin/test.c 2007-07-01 15:16:58.979656750 +0200 @@ -250,7 +250,7 @@ if (t_lex(t_wp[1]), t_wp_op && t_wp_op->op_type == BINOP) { return binop(); - } + } return strlen(*t_wp) > 0; } @@ -267,7 +267,7 @@ if ((opnd2 = *++t_wp) == (char *)0) syntax(op->op_text, "argument expected"); - + switch (op->op_num) { default: #ifdef DEBUG @@ -389,8 +389,8 @@ return 0; while (op->op_text) { if (strcmp(s, op->op_text) == 0) - return op->op_type == BINOP && - (t[0] != ')' || t[1] != '\0'); + return op->op_type == BINOP && + (t[0] != ')' || t[1] != '\0'); op++; } return 0; @@ -407,13 +407,13 @@ r = strtol(s, &p, 10); if (errno != 0) - error("%s: out of range", s); + error("%s: out of range", s); while (isspace((unsigned char)*p)) p++; - + if (*p) - error("%s: bad number", s); + error("%s: bad number", s); return (int) r; } -- >From [EMAIL PROTECTED] Sun Jul 01 16:05:29 2007 Subject: [patch 02/03] dash, test: little size and speed optimizations Content-Disposition: inline; filename=dash-test-bltin-optimize-size.patch Status: O Content-Length: 1831 Lines: 71 * Speed up (libc=glibc): deen:debian/src/dash-0.5.3# echo $(((7853+8631+7529+9777+9161+7552)/6)) 8417,8250 # this patch deen:/mnt/work/debian/src/dash-0.5.3# echo $(((9553+7789+9450+9925+7595+9590)/6)) 8983 # short deen:debian/src/dash-0.5.3# echo $(( (9655+7853+9733+7826+9618+10053)/6 )) 9123 # '[' ']' deen:debian/src/dash-0.5.3# deen:debian/src/dash-0.5.3# echo $(((9231+9423+9365+9650+8883+8291)/6)) 9140 # unpatched deen:debian/src/dash-0.5.3# * Size down: [EMAIL PROTECTED]:/mnt/debian/src/dash-0.5.3$ size src/test.o # this patchset text data bss dec hex filename 4142 0 16 4158 103e src/test.o [EMAIL PROTECTED]:/mnt/debian/src/dash-0.5.3$ size src/test.o text data bss dec hex filename 4209 0 16 4225 1081 src/test.o [EMAIL PROTECTED]:/mnt/debian/src/dash-0.5.3$ -- -o--=O`C #oo'L O <___=E M --- src/bltin/test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) Index: dash-0.5.3/src/bltin/test.c =================================================================== --- dash-0.5.3.orig/src/bltin/test.c 2007-07-01 07:05:08.884380750 +0200 +++ dash-0.5.3/src/bltin/test.c 2007-07-01 15:16:54.715390250 +0200 @@ -157,8 +157,8 @@ { int res; - if (strcmp(argv[0], "[") == 0) { - if (strcmp(argv[--argc], "]")) + if (*argv[0] == '[') { + if (*argv[--argc] != ']') error("missing ]"); argv[argc] = NULL; } @@ -259,16 +259,16 @@ binop(void) { const char *opnd1, *opnd2; - struct t_op const *op; + short op_num; opnd1 = *t_wp; (void) t_lex(*++t_wp); - op = t_wp_op; if ((opnd2 = *++t_wp) == (char *)0) - syntax(op->op_text, "argument expected"); + syntax(t_wp_op->op_text, "argument expected"); - switch (op->op_num) { + op_num = t_wp_op->op_num; + switch (op_num) { default: #ifdef DEBUG abort(); -- >From [EMAIL PROTECTED] Sun Jul 01 16:05:29 2007 Subject: [patch 03/03] dash, test: recognize NULL argument as not a number Content-Disposition: inline; filename=dash-test-bltin-integer-null-arg-check-fix.patch Status: O Content-Length: 1605 Lines: 64 * NULL as a number argument: [EMAIL PROTECTED]:/mnt/debian/src/dash-0.5.3$ time src/dash tst-01.sh test: 20: `': bad number `' eq 0: 2 must be >1, Not A Number test: 20: `': bad number `' ne 0: 2 must be >1, Not A Number test: 20: `': bad number `' gt 0: 2 must be >1, Not A Number test: 20: `': bad number `' ge 0: 2 must be >1, Not A Number test: 20: `': bad number `' lt 0: 2 must be >1, Not A Number test: 20: `': bad number `' le 0: 2 must be >1, Not A Number /usr/bin/test: invalid integer `' `' eq 0: 2 must be >1, Not A Number /usr/bin/test: invalid integer `' `' ne 0: 2 must be >1, Not A Number /usr/bin/test: invalid integer `' `' gt 0: 2 must be >1, Not A Number /usr/bin/test: invalid integer `' `' ge 0: 2 must be >1, Not A Number /usr/bin/test: invalid integer `' `' lt 0: 2 must be >1, Not A Number /usr/bin/test: invalid integer `' `' le 0: 2 must be >1, Not A Number -- -o--=O`C #oo'L O <___=E M --- src/bltin/test.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) Index: dash-0.5.3/src/bltin/test.c =================================================================== --- dash-0.5.3.orig/src/bltin/test.c 2007-07-01 07:05:08.932383750 +0200 +++ dash-0.5.3/src/bltin/test.c 2007-07-01 15:16:48.579006750 +0200 @@ -409,13 +409,14 @@ if (errno != 0) error("%s: out of range", s); - while (isspace((unsigned char)*p)) - p++; - - if (*p) - error("%s: bad number", s); - - return (int) r; + if (p != s) { + while (isspace((unsigned char)*p)) + p++; + + if (!*p) + return (int) r; + } + error("`%s': bad number", s); } static int --
#!/usr/bin/printf This not executable script%c\n test_arithm() { for aop in eq ne gt ge lt le do "$1" 0 -$aop "$NOTHING" echo "\`' $aop 0:" $? " must be >1, Not A Number" done } # opengroup.org/onlinepubs/000095399/utilites/test.html (nothing about long): test_arithm test test_arithm /usr/bin/test # shend
#!/usr/bin/printf This not executable script%c\n i=512512 while test $i != 0 do i=$(($i-1)) test 214748364 -lt 1214748364 done # shend