From ddd2dac47ddc0724d39c3aa7c0f81f23596e84ee Mon Sep 17 00:00:00 2001 From: tg Date: Wed, 17 Jan 2007 22:51:47 +0000 Subject: [PATCH] =?UTF-8?q?*=20support=20old=20environments=20without=20li?= =?UTF-8?q?bgen.h=20(ancient=20GNU/Linux)=20=20=20and=20stdbool.h=20(ancie?= =?UTF-8?q?nt=20GNU/Linux;=20NetBSD=C2=AE=201.6.1)=20*=20=5F=5Fdead=20must?= =?UTF-8?q?=20come=20after,=20not=20before,=20to=20accomodate=20gcc=202.7.?= =?UTF-8?q?2.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Build.sh | 12 +++++++++++- Makefile | 5 +++-- exec.c | 5 +++-- expr.c | 5 +++-- sh.h | 24 ++++++++++++++++++------ syn.c | 8 +++++--- 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/Build.sh b/Build.sh index 78a3c76..61b5274 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $MirOS: src/bin/mksh/Build.sh,v 1.127 2007/01/17 22:35:09 tg Exp $ +# $MirOS: src/bin/mksh/Build.sh,v 1.128 2007/01/17 22:51:45 tg Exp $ #- # Environment: CC, CFLAGS, CPP, CPPFLAGS, LDFLAGS, LIBS, NOWARN, NROFF # With -x (cross compile): TARGET_OS (default: uname -s) @@ -297,6 +297,16 @@ ac_test sys_param_h '' '' <<'EOF' int main(void) { return (0); } EOF +ac_test libgen_h '' '' <<'EOF' + #include + int main(void) { return (0); } +EOF + +ac_test stdbool_h '' '' <<'EOF' + #include + int main(void) { return (0); } +EOF + # # Environment: signals # diff --git a/Makefile b/Makefile index ac28b5d..544bd23 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ -# $MirOS: src/bin/mksh/Makefile,v 1.23 2007/01/17 21:42:23 tg Exp $ +# $MirOS: src/bin/mksh/Makefile,v 1.24 2007/01/17 22:51:46 tg Exp $ PROG= mksh SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \ jobs.c lex.c main.c misc.c shf.c syn.c tree.c var.c CPPFLAGS+= -DHAVE_ATTRIBUTE -DHAVE_ATTRIBUTE_BOUNDED -DHAVE_ATTRIBUTE_USED -CPPFLAGS+= -DHAVE_SYS_PARAM_H -DHAVE_SYS_SIGNAME -DHAVE_SYS_SIGLIST +CPPFLAGS+= -DHAVE_SYS_PARAM_H -DHAVE_LIBGEN_H -DHAVE_STDBOOL_H +CPPFLAGS+= -DHAVE_SYS_SIGNAME -DHAVE_SYS_SIGLIST CPPFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_ARC4RANDOM_PUSH -DHAVE_SETLOCALE_CTYPE CPPFLAGS+= -DHAVE_LANGINFO_CODESET -DHAVE_SETMODE -DHAVE_SETRESUGID CPPFLAGS+= -DHAVE_SETGROUPS -DHAVE_STRCASESTR -DHAVE_STRLCPY diff --git a/exec.c b/exec.c index 06c5be0..abab4e1 100644 --- a/exec.c +++ b/exec.c @@ -2,11 +2,12 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.23 2007/01/15 00:18:47 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.24 2007/01/17 22:51:46 tg Exp $"); static int comexec(struct op *, struct tbl *volatile, char **, int volatile); -static __dead void scriptexec(struct op *, char **); +static void scriptexec(struct op *, char **) + __attribute__((noreturn)); static int call_builtin(struct tbl *, char **); static int iosetup(struct ioword *, struct tbl *); static int herein(const char *, int); diff --git a/expr.c b/expr.c index d6fcef8..35b513e 100644 --- a/expr.c +++ b/expr.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.7 2007/01/12 01:49:27 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.8 2007/01/17 22:51:46 tg Exp $"); /* The order of these enums is constrained by the order of opinfo[] */ enum token { @@ -126,7 +126,8 @@ enum error_type { ET_LVALUE, ET_RDONLY, ET_STR }; -static __dead void evalerr(Expr_state *, enum error_type, const char *); +static void evalerr(Expr_state *, enum error_type, const char *) + __attribute__((noreturn)); static struct tbl *evalexpr(Expr_state *, enum prec); static void token(Expr_state *); static struct tbl *do_ppmm(Expr_state *, enum token, struct tbl *, bool); diff --git a/sh.h b/sh.h index 89b8d7c..1218d61 100644 --- a/sh.h +++ b/sh.h @@ -8,7 +8,7 @@ /* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */ -#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.100 2007/01/17 21:42:23 tg Exp $" +#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.101 2007/01/17 22:51:46 tg Exp $" #define MKSH_VERSION "R29 2007/01/17" #if HAVE_SYS_PARAM_H @@ -48,7 +48,9 @@ #include #include #include +#if HAVE_LIBGEN_H #include +#endif #include #if !defined(__sun__) #include @@ -57,7 +59,9 @@ #include #include #include +#if HAVE_STDBOOL_H #include +#endif #include #include #include @@ -78,6 +82,13 @@ #include #endif +#if !HAVE_STDBOOL_H +/* kludge, but enough for mksh */ +typedef int bool; +#define false 0 +#define true 1 +#endif + /* extra macros */ #ifndef timeradd @@ -119,8 +130,6 @@ #else #define __attribute__(x) /* nothing */ #endif -#undef __dead -#define __dead __attribute__((noreturn)) #undef __unused #define __unused __attribute__((unused)) @@ -1200,7 +1209,8 @@ pid_t j_async(void); int j_stopped_running(void); /* lex.c */ int yylex(int); -__dead void yyerror(const char *, ...) +void yyerror(const char *, ...) + __attribute__((noreturn)) __attribute__((format (printf, 1, 2))); Source *pushs(int, Area *); void set_prompt(int, Source *); @@ -1210,12 +1220,14 @@ int promptlen(const char *); int include(const char *, int, char **, int); int command(const char *); int shell(Source *volatile, int volatile); -__dead void unwind(int); +void unwind(int) + __attribute__((noreturn)); void newenv(int); void quitenv(struct shf *); void cleanup_parents_env(void); void cleanup_proc_env(void); -__dead void errorf(const char *, ...) +void errorf(const char *, ...) + __attribute__((noreturn)) __attribute__((format (printf, 1, 2))); void warningf(bool, const char *, ...) __attribute__((format (printf, 2, 3))); diff --git a/syn.c b/syn.c index d3125ff..041f669 100644 --- a/syn.c +++ b/syn.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.9 2007/01/12 01:49:29 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.10 2007/01/17 22:51:47 tg Exp $"); struct nesting_state { int start_token; /* token than began nesting (eg, FOR) */ @@ -26,7 +26,8 @@ static struct op *function_body(char *, int); static char **wordlist(void); static struct op *block(int, struct op *, struct op *, char **); static struct op *newtp(int); -static __dead void syntaxerr(const char *); +static void syntaxerr(const char *) + __attribute__((noreturn)); static void nesting_push(struct nesting_state *, int); static void nesting_pop(struct nesting_state *); static int assign_command(char *); @@ -35,7 +36,8 @@ static int dbtestp_isa(Test_env *, Test_meta); static const char *dbtestp_getopnd(Test_env *, Test_op, int); static int dbtestp_eval(Test_env *, Test_op, const char *, const char *, int); -static __dead void dbtestp_error(Test_env *, int, const char *); +static void dbtestp_error(Test_env *, int, const char *) + __attribute__((noreturn)); static struct op *outtree; /* yyparse output */ static struct nesting_state nesting; /* \n changed to ; */