optimise an if away, and possibly even the function bodies…
This commit is contained in:
		
							
								
								
									
										4
									
								
								check.t
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								check.t
									
									
									
									
									
								
							@@ -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: 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 $
 | 
			
		||||
@@ -25,7 +25,7 @@
 | 
			
		||||
# http://www.research.att.com/~gsf/public/ifs.sh
 | 
			
		||||
 | 
			
		||||
expected-stdout:
 | 
			
		||||
	@(#)MIRBSD KSH R40 2011/07/17
 | 
			
		||||
	@(#)MIRBSD KSH R40 2011/07/20
 | 
			
		||||
description:
 | 
			
		||||
	Check version of shell.
 | 
			
		||||
stdin:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										35
									
								
								funcs.c
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								funcs.c
									
									
									
									
									
								
							@@ -38,7 +38,7 @@
 | 
			
		||||
#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
 | 
			
		||||
/*
 | 
			
		||||
@@ -57,13 +57,25 @@ __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.193 2011/07/05 20:12:18 tg Exp $");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef MKSH_NO_LIMITS
 | 
			
		||||
#define c_ulimit c_label
 | 
			
		||||
#define c_ulimit c_true
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(ANDROID)
 | 
			
		||||
static int c_android_lsmod(const char **);
 | 
			
		||||
#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 a POSIX special builtin;
 | 
			
		||||
@@ -72,7 +84,7 @@ static int c_android_lsmod(const char **);
 | 
			
		||||
 */
 | 
			
		||||
const struct builtin mkshbuiltins[] = {
 | 
			
		||||
	{"*=.", c_dot},
 | 
			
		||||
	{"*=:", c_label},
 | 
			
		||||
	{"*=:", c_true},
 | 
			
		||||
	{"[", c_test},
 | 
			
		||||
	{"*=break", c_brkcont},
 | 
			
		||||
	{T_gbuiltin, c_builtin},
 | 
			
		||||
@@ -80,7 +92,7 @@ const struct builtin mkshbuiltins[] = {
 | 
			
		||||
	{"*=eval", c_eval},
 | 
			
		||||
	{"*=exec", c_exec},
 | 
			
		||||
	{"*=exit", c_exitreturn},
 | 
			
		||||
	{"+false", c_label},
 | 
			
		||||
	{"+false", c_false},
 | 
			
		||||
	{"*=return", c_exitreturn},
 | 
			
		||||
	{T_sgset, c_set},
 | 
			
		||||
	{"*=shift", c_shift},
 | 
			
		||||
@@ -89,7 +101,7 @@ const struct builtin mkshbuiltins[] = {
 | 
			
		||||
	{"+=wait", c_wait},
 | 
			
		||||
	{"+read", c_read},
 | 
			
		||||
	{"test", c_test},
 | 
			
		||||
	{"+true", c_label},
 | 
			
		||||
	{"+true", c_true},
 | 
			
		||||
	{"ulimit", c_ulimit},
 | 
			
		||||
	{"+umask", c_umask},
 | 
			
		||||
	{"*=unset", c_unset},
 | 
			
		||||
@@ -132,7 +144,7 @@ const struct builtin mkshbuiltins[] = {
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef __MirBSD__
 | 
			
		||||
	/* alias to "true" for historical reasons */
 | 
			
		||||
	{"domainname", c_label},
 | 
			
		||||
	{"domainname", c_true},
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(ANDROID)
 | 
			
		||||
	{"lsmod", c_android_lsmod},
 | 
			
		||||
@@ -1522,17 +1534,6 @@ c_bind(const char **wp)
 | 
			
		||||
	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
 | 
			
		||||
c_shift(const char **wp)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								sh.h
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								sh.h
									
									
									
									
									
								
							@@ -151,9 +151,9 @@
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
#define MKSH_VERSION "R40 2011/07/17"
 | 
			
		||||
#define MKSH_VERSION "R40 2011/07/20"
 | 
			
		||||
 | 
			
		||||
#ifndef MKSH_INCLUDES_ONLY
 | 
			
		||||
 | 
			
		||||
@@ -1595,7 +1595,6 @@ int c_kill(const char **);
 | 
			
		||||
void getopts_reset(int);
 | 
			
		||||
int c_getopts(const char **);
 | 
			
		||||
int c_bind(const char **);
 | 
			
		||||
int c_label(const char **);
 | 
			
		||||
int c_shift(const char **);
 | 
			
		||||
int c_umask(const char **);
 | 
			
		||||
int c_dot(const char **);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user