• no longer use <stdbool.h> even if it’s available
• ensure that bool/true/false are cpp macros, overriding any pre-defined • document the requirement that tobool(x) must map any-type 'x' into bool • document the requirement that a bool must only be true or false, and that it (tobool() rather) must have an identity mapping to 'short' • possibly fix ksh_func for/and fpFUNCTf – maybe spotted by cnuke@
This commit is contained in:
parent
2dbf82a737
commit
d57a033057
3
Build.sh
3
Build.sh
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.475 2011/03/28 21:15:04 tg Exp $'
|
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.476 2011/04/09 15:14:51 tg Exp $'
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
||||||
# Thorsten Glaser <tg@mirbsd.org>
|
# Thorsten Glaser <tg@mirbsd.org>
|
||||||
|
@ -1098,7 +1098,6 @@ ac_header grp.h sys/types.h
|
||||||
ac_header libgen.h
|
ac_header libgen.h
|
||||||
ac_header libutil.h sys/types.h
|
ac_header libutil.h sys/types.h
|
||||||
ac_header paths.h
|
ac_header paths.h
|
||||||
ac_header stdbool.h
|
|
||||||
ac_header stdint.h stdarg.h
|
ac_header stdint.h stdarg.h
|
||||||
# include strings.h only if compatible with string.h
|
# include strings.h only if compatible with string.h
|
||||||
ac_header strings.h sys/types.h string.h
|
ac_header strings.h sys/types.h string.h
|
||||||
|
|
5
funcs.c
5
funcs.c
|
@ -38,7 +38,7 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.182 2011/03/27 18:50:04 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.183 2011/04/09 15:14:52 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
|
@ -794,7 +794,8 @@ c_typeset(const char **wp)
|
||||||
f->flag |= fset;
|
f->flag |= fset;
|
||||||
f->flag &= ~fclr;
|
f->flag &= ~fclr;
|
||||||
} else {
|
} else {
|
||||||
fpFUNCTf(shl_stdout, 0, f->flag & FKSH,
|
fpFUNCTf(shl_stdout, 0,
|
||||||
|
tobool(f->flag & FKSH),
|
||||||
wp[i], f->val.t);
|
wp[i], f->val.t);
|
||||||
shf_putc('\n', shl_stdout);
|
shf_putc('\n', shl_stdout);
|
||||||
}
|
}
|
||||||
|
|
35
sh.h
35
sh.h
|
@ -68,9 +68,6 @@
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#if HAVE_STDBOOL_H
|
|
||||||
#include <stdbool.h>
|
|
||||||
#endif
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#if HAVE_STDINT_H
|
#if HAVE_STDINT_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -154,7 +151,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.459 2011/04/09 14:58:53 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.460 2011/04/09 15:14:53 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R39 2011/04/01"
|
#define MKSH_VERSION "R39 2011/04/01"
|
||||||
|
|
||||||
|
@ -185,20 +182,6 @@ typedef long rlim_t;
|
||||||
typedef void (*sig_t)(int);
|
typedef void (*sig_t)(int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAVE_STDBOOL_H
|
|
||||||
/* kludge, but enough for mksh */
|
|
||||||
typedef unsigned char mksh_bool;
|
|
||||||
#define bool mksh_bool
|
|
||||||
#define false 0
|
|
||||||
#define true 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* choose the one that is optimised on most platforms? */
|
|
||||||
#define tobool(cond) ((cond) ? true : false)
|
|
||||||
/*#define tobool(cond) (!!(cond))*/
|
|
||||||
/* the following only with <stdbool.h> and even then sometimes buggy */
|
|
||||||
/*#define tobool(cond) ((bool)(cond))*/
|
|
||||||
|
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
#if !HAVE_CAN_UCBINTS
|
#if !HAVE_CAN_UCBINTS
|
||||||
typedef signed int int32_t;
|
typedef signed int int32_t;
|
||||||
|
@ -367,6 +350,19 @@ typedef int32_t Tflag;
|
||||||
typedef int32_t mksh_ari_t;
|
typedef int32_t mksh_ari_t;
|
||||||
typedef uint32_t mksh_uari_t;
|
typedef uint32_t mksh_uari_t;
|
||||||
|
|
||||||
|
/* boolean type (no <stdbool.h> deliberately) */
|
||||||
|
typedef unsigned char mksh_bool;
|
||||||
|
#undef bool
|
||||||
|
#undef false
|
||||||
|
#undef true
|
||||||
|
/* access macros for boolean type */
|
||||||
|
#define bool mksh_bool
|
||||||
|
/* values must have identity mapping between mksh_bool and short */
|
||||||
|
#define false 0
|
||||||
|
#define true 1
|
||||||
|
/* make any-type into bool or short */
|
||||||
|
#define tobool(cond) ((cond) ? true : false)
|
||||||
|
|
||||||
/* these shall be smaller than 100 */
|
/* these shall be smaller than 100 */
|
||||||
#ifdef MKSH_CONSERVATIVE_FDS
|
#ifdef MKSH_CONSERVATIVE_FDS
|
||||||
#define NUFILE 32 /* Number of user-accessible files */
|
#define NUFILE 32 /* Number of user-accessible files */
|
||||||
|
@ -1115,7 +1111,8 @@ struct op {
|
||||||
*/
|
*/
|
||||||
int lineno; /* TCOM/TFUNC: LINENO for this */
|
int lineno; /* TCOM/TFUNC: LINENO for this */
|
||||||
short type; /* operation type, see below */
|
short type; /* operation type, see below */
|
||||||
union { /* WARNING: newtp(), tcopy() use evalflags = 0 to clear union */
|
union {
|
||||||
|
/* WARNING: newtp(), tcopy() use evalflags = 0 to clear union */
|
||||||
short evalflags; /* TCOM: arg expansion eval() flags */
|
short evalflags; /* TCOM: arg expansion eval() flags */
|
||||||
short ksh_func; /* TFUNC: function x (vs x()) */
|
short ksh_func; /* TFUNC: function x (vs x()) */
|
||||||
} u;
|
} u;
|
||||||
|
|
4
syn.c
4
syn.c
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.59 2011/03/26 15:32:37 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.60 2011/04/09 15:14:54 tg Exp $");
|
||||||
|
|
||||||
extern short subshell_nesting_level;
|
extern short subshell_nesting_level;
|
||||||
|
|
||||||
|
@ -665,7 +665,7 @@ function_body(char *name,
|
||||||
|
|
||||||
t = newtp(TFUNCT);
|
t = newtp(TFUNCT);
|
||||||
t->str = sname;
|
t->str = sname;
|
||||||
t->u.ksh_func = ksh_func;
|
t->u.ksh_func = tobool(ksh_func);
|
||||||
t->lineno = source->line;
|
t->lineno = source->line;
|
||||||
|
|
||||||
old_func_parse = e->flags & EF_FUNC_PARSE;
|
old_func_parse = e->flags & EF_FUNC_PARSE;
|
||||||
|
|
4
tree.c
4
tree.c
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.42 2011/04/09 15:05:44 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.43 2011/04/09 15:14:55 tg Exp $");
|
||||||
|
|
||||||
#define INDENT 8
|
#define INDENT 8
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ ptree(struct op *t, int indent, struct shf *shf)
|
||||||
prevent_semicolon = true;
|
prevent_semicolon = true;
|
||||||
break;
|
break;
|
||||||
case TFUNCT:
|
case TFUNCT:
|
||||||
fpFUNCTf(shf, indent, t->u.ksh_func, t->str, t->left);
|
fpFUNCTf(shf, indent, tobool(t->u.ksh_func), t->str, t->left);
|
||||||
break;
|
break;
|
||||||
case TTIME:
|
case TTIME:
|
||||||
fptreef(shf, indent, "%s %T", "time", t->left);
|
fptreef(shf, indent, "%s %T", "time", t->left);
|
||||||
|
|
Loading…
Reference in New Issue