optimise an if away, and possibly even the function bodies…

This commit is contained in:
tg 2011-07-20 23:47:29 +00:00
parent 6ce68e906f
commit a7566387cf
3 changed files with 22 additions and 22 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.477 2011/07/18 00:35:44 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.478 2011/07/20 23:47:26 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh # http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R40 2011/07/17 @(#)MIRBSD KSH R40 2011/07/20
description: description:
Check version of shell. Check version of shell.
stdin: stdin:

35
funcs.c
View File

@ -38,7 +38,7 @@
#endif #endif
#endif #endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.193 2011/07/05 20:12:18 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.194 2011/07/20 23:47:28 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -57,13 +57,25 @@ __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.193 2011/07/05 20:12:18 tg Exp $");
#endif #endif
#ifdef MKSH_NO_LIMITS #ifdef MKSH_NO_LIMITS
#define c_ulimit c_label #define c_ulimit c_true
#endif #endif
#if defined(ANDROID) #if defined(ANDROID)
static int c_android_lsmod(const char **); static int c_android_lsmod(const char **);
#endif #endif
static int
c_true(const char **wp MKSH_A_UNUSED)
{
return (0);
}
static int
c_false(const char **wp MKSH_A_UNUSED)
{
return (1);
}
/* /*
* A leading = means assignments before command are kept; * A leading = means assignments before command are kept;
* a leading * means a POSIX special builtin; * a leading * means a POSIX special builtin;
@ -72,7 +84,7 @@ static int c_android_lsmod(const char **);
*/ */
const struct builtin mkshbuiltins[] = { const struct builtin mkshbuiltins[] = {
{"*=.", c_dot}, {"*=.", c_dot},
{"*=:", c_label}, {"*=:", c_true},
{"[", c_test}, {"[", c_test},
{"*=break", c_brkcont}, {"*=break", c_brkcont},
{T_gbuiltin, c_builtin}, {T_gbuiltin, c_builtin},
@ -80,7 +92,7 @@ const struct builtin mkshbuiltins[] = {
{"*=eval", c_eval}, {"*=eval", c_eval},
{"*=exec", c_exec}, {"*=exec", c_exec},
{"*=exit", c_exitreturn}, {"*=exit", c_exitreturn},
{"+false", c_label}, {"+false", c_false},
{"*=return", c_exitreturn}, {"*=return", c_exitreturn},
{T_sgset, c_set}, {T_sgset, c_set},
{"*=shift", c_shift}, {"*=shift", c_shift},
@ -89,7 +101,7 @@ const struct builtin mkshbuiltins[] = {
{"+=wait", c_wait}, {"+=wait", c_wait},
{"+read", c_read}, {"+read", c_read},
{"test", c_test}, {"test", c_test},
{"+true", c_label}, {"+true", c_true},
{"ulimit", c_ulimit}, {"ulimit", c_ulimit},
{"+umask", c_umask}, {"+umask", c_umask},
{"*=unset", c_unset}, {"*=unset", c_unset},
@ -132,7 +144,7 @@ const struct builtin mkshbuiltins[] = {
#endif #endif
#ifdef __MirBSD__ #ifdef __MirBSD__
/* alias to "true" for historical reasons */ /* alias to "true" for historical reasons */
{"domainname", c_label}, {"domainname", c_true},
#endif #endif
#if defined(ANDROID) #if defined(ANDROID)
{"lsmod", c_android_lsmod}, {"lsmod", c_android_lsmod},
@ -1522,17 +1534,6 @@ c_bind(const char **wp)
return (rv); return (rv);
} }
/**
* :, false and true
* ulimit if MKSH_NO_LIMITS
* domainname on MirBSD (hysterical raisins, just don't ask)
*/
int
c_label(const char **wp)
{
return (wp[0][0] == 'f' ? 1 : 0);
}
int int
c_shift(const char **wp) c_shift(const char **wp)
{ {

5
sh.h
View File

@ -151,9 +151,9 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.488 2011/07/18 00:35:46 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.489 2011/07/20 23:47:29 tg Exp $");
#endif #endif
#define MKSH_VERSION "R40 2011/07/17" #define MKSH_VERSION "R40 2011/07/20"
#ifndef MKSH_INCLUDES_ONLY #ifndef MKSH_INCLUDES_ONLY
@ -1595,7 +1595,6 @@ int c_kill(const char **);
void getopts_reset(int); void getopts_reset(int);
int c_getopts(const char **); int c_getopts(const char **);
int c_bind(const char **); int c_bind(const char **);
int c_label(const char **);
int c_shift(const char **); int c_shift(const char **);
int c_umask(const char **); int c_umask(const char **);
int c_dot(const char **); int c_dot(const char **);