re-vamp __attribute__ handling; let this pass on HP-UX bundled compiler

as well as HP aCC
This commit is contained in:
tg 2009-12-12 22:27:10 +00:00
parent 0c3acb2374
commit 769e222586
11 changed files with 212 additions and 150 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.432 2009/12/12 21:17:25 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.433 2009/12/12 22:27:02 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Thorsten Glaser <tg@mirbsd.org>
@ -161,6 +161,8 @@ ac_testn() {
fi
test ugcc=$phase$ct && $CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c \
$LIBS 2>&1 | grep 'unrecogni[sz]ed' >/dev/null 2>&1 && fv=$fr
test uhpcc=$phase$ct && $CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c \
$LIBS 2>&1 | grep 'unsupported' >/dev/null 2>&1 && fv=$fr
rm -f scn.c scn.o ${tcfn}*
ac_testdone
}
@ -785,7 +787,9 @@ test x"$i" = x"" && if test $ct = sunpro; then
ac_flags - 1 otwo -xO2 <x
rm -f x
elif test $ct = hpcc; then
phase=u
ac_flags 1 otwo +O2
phase=x
elif test $ct = xlc; then
ac_flags 1 othree "-O3 -qstrict"
test 1 = $HAVE_CAN_OTHREE || ac_flags 1 otwo -O2
@ -816,8 +820,10 @@ elif test $ct = sunpro; then
ac_flags 1 v -v
ac_flags 1 xc99 -xc99 'for support of ISO C99'
elif test $ct = hpcc; then
phase=u
ac_flags 1 agcc -Agcc 'for support of GCC extensions'
ac_flags 1 ac99 -AC99 'for support of ISO C99'
phase=x
elif test $ct = dec; then
ac_flags 0 verb -verbose
ac_flags 1 rodata -readonly_strings
@ -873,7 +879,50 @@ NOWARN=$DOWARN
#
# Compiler: check for stuff that only generates warnings
#
ac_test attribute '' 'for basic __attribute__((...)) support' <<-'EOF'
ac_test attribute_bounded '' 'for __attribute__((bounded))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
#include <string.h>
#undef __attribute__
int xcopy(const void *, void *, size_t)
__attribute__((bounded (buffer, 1, 3)))
__attribute__((bounded (buffer, 2, 3)));
int main(int ac, char *av[]) { return (xcopy(av[0], av[--ac], 1)); }
int xcopy(const void *s, void *d, size_t n) {
memmove(d, s, n); return ((int)n);
}
#endif
EOF
ac_test attribute_format '' 'for __attribute__((format))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
#include <stdio.h>
#undef __attribute__
#undef printf
extern int printf(const char *format, ...)
__attribute__((format (printf, 1, 2)));
int main(int ac, char **av) { return (printf("%s%d", *av, ac)); }
#endif
EOF
ac_test attribute_nonnull '' 'for __attribute__((nonnull))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
int foo(char *s1, char *s2) __attribute__((nonnull));
int bar(char *s1, char *s2) __attribute__((nonnull (1, 2)));
int baz(char *s) __attribute__((nonnull (1)));
int foo(char *s1, char *s2) { return (bar(s2, s1)); }
int bar(char *s1, char *s2) { return (baz(s1) - baz(s2)); }
int baz(char *s) { return (*s); }
int main(int ac, char **av) { return (ac == foo(av[0], av[ac-1])); }
#endif
EOF
ac_test attribute_noreturn '' 'for __attribute__((noreturn))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
@ -885,22 +934,23 @@ ac_test attribute '' 'for basic __attribute__((...)) support' <<-'EOF'
void fnord(void) { exit(0); }
#endif
EOF
ac_test attribute_bounded attribute 0 'for __attribute__((bounded))' <<-'EOF'
#include <string.h>
#undef __attribute__
int xcopy(const void *, void *, size_t)
__attribute__((bounded (buffer, 1, 3)))
__attribute__((bounded (buffer, 2, 3)));
int main(int ac, char *av[]) { return (xcopy(av[0], av[--ac], 1)); }
int xcopy(const void *s, void *d, size_t n) {
memmove(d, s, n); return ((int)n);
}
ac_test attribute_unused '' 'for __attribute__((unused))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
int main(int ac __attribute__((unused)), char **av
__attribute__((unused))) { return (0); }
#endif
EOF
ac_test attribute_used attribute 0 'for __attribute__((used))' <<-'EOF'
ac_test attribute_used '' 'for __attribute__((used))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
static const char fnord[] __attribute__((used)) = "42";
int main(void) { return (0); }
#endif
EOF
# End of tests run with -Werror

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/Makefile,v 1.78 2009/08/27 16:52:12 tg Exp $
# $MirOS: src/bin/mksh/Makefile,v 1.79 2009/12/12 22:27:03 tg Exp $
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Thorsten Glaser <tg@mirbsd.org>
@ -27,9 +27,10 @@ SRCS= edit.c eval.c exec.c expr.c funcs.c histrap.c jobs.c \
lalloc.c lex.c main.c misc.c shf.c syn.c tree.c var.c
.if !make(test-build)
CPPFLAGS+= -DMKSH_ASSUME_UTF8 \
-DHAVE_ATTRIBUTE=1 -DHAVE_ATTRIBUTE_BOUNDED=1 \
-DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_PARAM_H=1 \
-DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 \
-DHAVE_ATTRIBUTE_BOUNDED=1 -DHAVE_ATTRIBUTE_FORMAT=1 \
-DHAVE_ATTRIBUTE_NONNULL=1 -DHAVE_ATTRIBUTE_NORETURN=1 \
-DHAVE_ATTRIBUTE_UNUSED=1 -DHAVE_ATTRIBUTE_USED=1 \
-DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 \
-DHAVE_SYS_SYSMACROS_H=0 -DHAVE_LIBGEN_H=1 -DHAVE_LIBUTIL_H=0 \
-DHAVE_PATHS_H=1 -DHAVE_STDBOOL_H=1 -DHAVE_STRINGS_H=1 \
-DHAVE_GRP_H=1 -DHAVE_ULIMIT_H=0 -DHAVE_VALUES_H=0 \
@ -37,11 +38,10 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 \
-DHAVE_SYS_SIGNAME=1 -DHAVE_SYS_SIGLIST=1 -DHAVE_STRSIGNAL=0 \
-DHAVE_ARC4RANDOM=1 -DHAVE_ARC4RANDOM_PUSHB=1 \
-DHAVE_GETRUSAGE=1 -DHAVE_KILLPG=1 -DHAVE_MKNOD=1 \
-DHAVE_MKSTEMP=1 -DHAVE_NICE=1 -DHAVE_REALPATH=1 \
-DHAVE_REVOKE=1 -DHAVE_SETLOCALE_CTYPE=0 \
-DHAVE_LANGINFO_CODESET=0 -DHAVE_SETMODE=1 \
-DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 \
-DHAVE_STRLCPY=1 -DHAVE_ARC4RANDOM_DECL=1 \
-DHAVE_MKSTEMP=1 -DHAVE_NICE=1 -DHAVE_REVOKE=1 \
-DHAVE_SETLOCALE_CTYPE=0 -DHAVE_LANGINFO_CODESET=0 \
-DHAVE_SETMODE=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 \
-DHAVE_STRCASESTR=1 -DHAVE_STRLCPY=1 -DHAVE_ARC4RANDOM_DECL=1 \
-DHAVE_ARC4RANDOM_PUSHB_DECL=1 -DHAVE_FLOCK_DECL=1 \
-DHAVE_REVOKE_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
-DHAVE_PERSISTENT_HISTORY=1

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.348 2009/12/05 17:43:43 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.349 2009/12/12 22:27:03 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 R39 2009/12/05
@(#)MIRBSD KSH R39 2009/12/12
description:
Check version of shell.
stdin:

128
edit.c
View File

@ -25,7 +25,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.186 2009/12/05 22:19:41 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.187 2009/12/12 22:27:05 tg Exp $");
/* tty driver characters we are interested in */
typedef struct {
@ -71,16 +71,16 @@ static int x_vi(char *, size_t);
static int path_order_cmp(const void *aa, const void *bb);
static char *add_glob(const char *, int)
__attribute__((nonnull (1)))
__bound_att__((bounded (string, 1, 2)));
MKSH_A_NONNULL((nonnull (1)))
MKSH_A_BOUNDED(string, 1, 2);
static void glob_table(const char *, XPtrV *, struct table *);
static void glob_path(int flags, const char *, XPtrV *, const char *);
static int x_file_glob(int, const char *, int, char ***)
__attribute__((nonnull (2)))
__bound_att__((bounded (string, 2, 3)));
MKSH_A_NONNULL((nonnull (2)))
MKSH_A_BOUNDED(string, 2, 3);
static int x_command_glob(int, const char *, int, char ***)
__attribute__((nonnull (2)))
__bound_att__((bounded (string, 2, 3)));
MKSH_A_NONNULL((nonnull (2)))
MKSH_A_BOUNDED(string, 2, 3);
static int x_locate_word(const char *, int, int, int *, bool *);
static int x_e_getmbc(char *);
@ -254,7 +254,7 @@ x_print_expansions(int nwords, char * const *words, bool is_command)
* - returns number of matching strings
*/
static int
x_file_glob(int flags __unused, const char *str, int slen, char ***wordsp)
x_file_glob(int flags MKSH_A_UNUSED, const char *str, int slen, char ***wordsp)
{
char *toglob, **words;
int nwords, i, idx;
@ -861,12 +861,12 @@ int x_bind(const char *, const char *, bool, bool)
#else
int x_bind(const char *, const char *, bool)
#endif
__attribute__((nonnull (1, 2)));
MKSH_A_NONNULL((nonnull (1, 2)));
static int x_match(char *, char *);
static void x_redraw(int);
static void x_push(int);
static char *x_mapin(const char *, Area *)
__attribute__((nonnull (1)));
MKSH_A_NONNULL((nonnull (1)));
static char *x_mapout(int);
static void x_mapout2(int, char **);
static void x_print(int, int);
@ -1252,7 +1252,7 @@ x_ins(const char *s)
}
static int
x_del_back(int c __unused)
x_del_back(int c MKSH_A_UNUSED)
{
int i = 0;
@ -1268,7 +1268,7 @@ x_del_back(int c __unused)
}
static int
x_del_char(int c __unused)
x_del_char(int c MKSH_A_UNUSED)
{
char *cp, *cp2;
int i = 0;
@ -1360,28 +1360,28 @@ x_delete(int nc, int push)
}
static int
x_del_bword(int c __unused)
x_del_bword(int c MKSH_A_UNUSED)
{
x_delete(x_bword(), true);
return (KSTD);
}
static int
x_mv_bword(int c __unused)
x_mv_bword(int c MKSH_A_UNUSED)
{
x_bword();
return (KSTD);
}
static int
x_mv_fword(int c __unused)
x_mv_fword(int c MKSH_A_UNUSED)
{
x_fword(1);
return (KSTD);
}
static int
x_del_fword(int c __unused)
x_del_fword(int c MKSH_A_UNUSED)
{
x_delete(x_fword(0), true);
return (KSTD);
@ -1536,7 +1536,7 @@ x_zotc3(char **cp)
}
static int
x_mv_back(int c __unused)
x_mv_back(int c MKSH_A_UNUSED)
{
if (xcp == xbuf) {
x_e_putc2(7);
@ -1551,7 +1551,7 @@ x_mv_back(int c __unused)
}
static int
x_mv_forw(int c __unused)
x_mv_forw(int c MKSH_A_UNUSED)
{
char *cp = xcp, *cp2;
@ -1570,7 +1570,7 @@ x_mv_forw(int c __unused)
}
static int
x_search_char_forw(int c __unused)
x_search_char_forw(int c MKSH_A_UNUSED)
{
char *cp = xcp;
char tmp[4];
@ -1592,7 +1592,7 @@ x_search_char_forw(int c __unused)
}
static int
x_search_char_back(int c __unused)
x_search_char_back(int c MKSH_A_UNUSED)
{
char *cp = xcp, *p, tmp[4];
bool b;
@ -1627,7 +1627,7 @@ x_search_char_back(int c __unused)
}
static int
x_newline(int c __unused)
x_newline(int c MKSH_A_UNUSED)
{
x_e_putc2('\r');
x_e_putc2('\n');
@ -1637,7 +1637,7 @@ x_newline(int c __unused)
}
static int
x_end_of_text(int c __unused)
x_end_of_text(int c MKSH_A_UNUSED)
{
x_zotc2(edchars.eof);
x_putc('\r');
@ -1647,28 +1647,28 @@ x_end_of_text(int c __unused)
}
static int
x_beg_hist(int c __unused)
x_beg_hist(int c MKSH_A_UNUSED)
{
x_load_hist(history);
return (KSTD);
}
static int
x_end_hist(int c __unused)
x_end_hist(int c MKSH_A_UNUSED)
{
x_load_hist(histptr);
return (KSTD);
}
static int
x_prev_com(int c __unused)
x_prev_com(int c MKSH_A_UNUSED)
{
x_load_hist(x_histp - x_arg);
return (KSTD);
}
static int
x_next_com(int c __unused)
x_next_com(int c MKSH_A_UNUSED)
{
x_load_hist(x_histp + x_arg);
return (KSTD);
@ -1679,7 +1679,7 @@ x_next_com(int c __unused)
* want so we'll simply go to the oldest one.
*/
static int
x_goto_hist(int c __unused)
x_goto_hist(int c MKSH_A_UNUSED)
{
if (x_arg_defaulted)
x_load_hist(history);
@ -1719,7 +1719,7 @@ x_load_hist(char **hp)
}
static int
x_nl_next_com(int c __unused)
x_nl_next_com(int c MKSH_A_UNUSED)
{
x_nextcmd = source->line - (histptr - x_histp) + 1;
return (x_newline('\n'));
@ -1842,14 +1842,14 @@ x_search(char *pat, int sameline, int offset)
#ifndef MKSH_SMALL
/* anchored search up from current line */
static int
x_search_hist_up(int c __unused)
x_search_hist_up(int c MKSH_A_UNUSED)
{
return (x_search_dir(-1));
}
/* anchored search down from current line */
static int
x_search_hist_dn(int c __unused)
x_search_hist_dn(int c MKSH_A_UNUSED)
{
return (x_search_dir(1));
}
@ -1886,7 +1886,7 @@ x_match(char *str, char *pat)
}
static int
x_del_line(int c __unused)
x_del_line(int c MKSH_A_UNUSED)
{
int i, j;
@ -1905,28 +1905,28 @@ x_del_line(int c __unused)
}
static int
x_mv_end(int c __unused)
x_mv_end(int c MKSH_A_UNUSED)
{
x_goto(xep);
return (KSTD);
}
static int
x_mv_begin(int c __unused)
x_mv_begin(int c MKSH_A_UNUSED)
{
x_goto(xbuf);
return (KSTD);
}
static int
x_draw_line(int c __unused)
x_draw_line(int c MKSH_A_UNUSED)
{
x_redraw(-1);
return (KSTD);
}
static int
x_cls(int c __unused)
x_cls(int c MKSH_A_UNUSED)
{
/*
* in later versions we might use libtermcap for this, but since external
@ -2018,7 +2018,7 @@ x_redraw(int limit)
}
static int
x_transpose(int c __unused)
x_transpose(int c MKSH_A_UNUSED)
{
unsigned int tmpa, tmpb;
@ -2083,28 +2083,28 @@ x_transpose(int c __unused)
}
static int
x_literal(int c __unused)
x_literal(int c MKSH_A_UNUSED)
{
x_curprefix = -1;
return (KSTD);
}
static int
x_meta1(int c __unused)
x_meta1(int c MKSH_A_UNUSED)
{
x_curprefix = 1;
return (KSTD);
}
static int
x_meta2(int c __unused)
x_meta2(int c MKSH_A_UNUSED)
{
x_curprefix = 2;
return (KSTD);
}
static int
x_kill(int c __unused)
x_kill(int c MKSH_A_UNUSED)
{
int col = xcp - xbuf;
int lastcol = xep - xbuf;
@ -2136,7 +2136,7 @@ x_push(int nchars)
}
static int
x_yank(int c __unused)
x_yank(int c MKSH_A_UNUSED)
{
if (killsp == 0)
killtp = KILLSIZE;
@ -2154,7 +2154,7 @@ x_yank(int c __unused)
}
static int
x_meta_yank(int c __unused)
x_meta_yank(int c MKSH_A_UNUSED)
{
int len;
@ -2179,7 +2179,7 @@ x_meta_yank(int c __unused)
}
static int
x_abort(int c __unused)
x_abort(int c MKSH_A_UNUSED)
{
/* x_zotc(c); */
xlp = xep = xcp = xbp = xbuf;
@ -2190,7 +2190,7 @@ x_abort(int c __unused)
}
static int
x_error(int c __unused)
x_error(int c MKSH_A_UNUSED)
{
x_e_putc2(7);
return (KSTD);
@ -2466,14 +2466,14 @@ bind_if_not_bound(int p, int k, int func)
}
static int
x_set_mark(int c __unused)
x_set_mark(int c MKSH_A_UNUSED)
{
xmp = xcp;
return (KSTD);
}
static int
x_kill_region(int c __unused)
x_kill_region(int c MKSH_A_UNUSED)
{
int rsize;
char *xr;
@ -2496,7 +2496,7 @@ x_kill_region(int c __unused)
}
static int
x_xchg_point_mark(int c __unused)
x_xchg_point_mark(int c MKSH_A_UNUSED)
{
char *tmp;
@ -2511,7 +2511,7 @@ x_xchg_point_mark(int c __unused)
}
static int
x_noop(int c __unused)
x_noop(int c MKSH_A_UNUSED)
{
return (KSTD);
}
@ -2520,56 +2520,56 @@ x_noop(int c __unused)
* File/command name completion routines
*/
static int
x_comp_comm(int c __unused)
x_comp_comm(int c MKSH_A_UNUSED)
{
do_complete(XCF_COMMAND, CT_COMPLETE);
return (KSTD);
}
static int
x_list_comm(int c __unused)
x_list_comm(int c MKSH_A_UNUSED)
{
do_complete(XCF_COMMAND, CT_LIST);
return (KSTD);
}
static int
x_complete(int c __unused)
x_complete(int c MKSH_A_UNUSED)
{
do_complete(XCF_COMMAND_FILE, CT_COMPLETE);
return (KSTD);
}
static int
x_enumerate(int c __unused)
x_enumerate(int c MKSH_A_UNUSED)
{
do_complete(XCF_COMMAND_FILE, CT_LIST);
return (KSTD);
}
static int
x_comp_file(int c __unused)
x_comp_file(int c MKSH_A_UNUSED)
{
do_complete(XCF_FILE, CT_COMPLETE);
return (KSTD);
}
static int
x_list_file(int c __unused)
x_list_file(int c MKSH_A_UNUSED)
{
do_complete(XCF_FILE, CT_LIST);
return (KSTD);
}
static int
x_comp_list(int c __unused)
x_comp_list(int c MKSH_A_UNUSED)
{
do_complete(XCF_COMMAND_FILE, CT_COMPLIST);
return (KSTD);
}
static int
x_expand(int c __unused)
x_expand(int c MKSH_A_UNUSED)
{
char **words;
int start, end, nwords, i;
@ -2818,7 +2818,7 @@ x_set_arg(int c)
/* Comment or uncomment the current line. */
static int
x_comment(int c __unused)
x_comment(int c MKSH_A_UNUSED)
{
int oldsize = x_size_str(xbuf);
int len = xep - xbuf;
@ -2839,7 +2839,7 @@ x_comment(int c __unused)
}
static int
x_version(int c __unused)
x_version(int c MKSH_A_UNUSED)
{
char *o_xbuf = xbuf, *o_xend = xend;
char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp;
@ -2873,7 +2873,7 @@ x_version(int c __unused)
#ifndef MKSH_SMALL
static int
x_edit_line(int c __unused)
x_edit_line(int c MKSH_A_UNUSED)
{
if (x_arg_defaulted) {
if (xep == xbuf) {
@ -2914,7 +2914,7 @@ x_edit_line(int c __unused)
* KSTD
*/
static int
x_prev_histword(int c __unused)
x_prev_histword(int c MKSH_A_UNUSED)
{
char *rcp, *cp;
char **xhp;
@ -2972,21 +2972,21 @@ x_prev_histword(int c __unused)
#ifndef MKSH_SMALL
/* Uppercase N(1) words */
static int
x_fold_upper(int c __unused)
x_fold_upper(int c MKSH_A_UNUSED)
{
return (x_fold_case('U'));
}
/* Lowercase N(1) words */
static int
x_fold_lower(int c __unused)
x_fold_lower(int c MKSH_A_UNUSED)
{
return (x_fold_case('L'));
}
/* Lowercase N(1) words */
static int
x_fold_capitalise(int c __unused)
x_fold_capitalise(int c MKSH_A_UNUSED)
{
return (x_fold_case('C'));
}
@ -5168,7 +5168,7 @@ complete_word(int cmd, int count)
}
static int
print_expansions(struct edstate *est, int cmd __unused)
print_expansions(struct edstate *est, int cmd MKSH_A_UNUSED)
{
int start, end, nwords;
char **words;

5
exec.c
View File

@ -22,12 +22,11 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.71 2009/12/05 17:43:46 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.72 2009/12/12 22:27:06 tg Exp $");
static int comexec(struct op *, struct tbl *volatile, const char **,
int volatile, volatile int *);
static void scriptexec(struct op *, const char **)
__attribute__((noreturn));
static void scriptexec(struct op *, const char **) MKSH_A_NORETURN;
static int call_builtin(struct tbl *, const char **);
static int iosetup(struct ioword *, struct tbl *);
static int herein(const char *, int);

4
expr.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.41 2009/12/08 19:23:34 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.42 2009/12/12 22:27:06 tg Exp $");
/* The order of these enums is constrained by the order of opinfo[] */
enum token {
@ -160,7 +160,7 @@ enum error_type {
};
static void evalerr(Expr_state *, enum error_type, const char *)
__attribute__((noreturn));
MKSH_A_NORETURN;
static struct tbl *evalexpr(Expr_state *, int);
static void exprtoken(Expr_state *);
static struct tbl *do_ppmm(Expr_state *, enum token, struct tbl *, bool);

15
funcs.c
View File

@ -25,7 +25,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.146 2009/12/05 17:43:46 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.147 2009/12/12 22:27:07 tg Exp $");
#if HAVE_KILLPG
/*
@ -173,7 +173,8 @@ static const char *ptest_getopnd(Test_env *, Test_op, bool);
static void ptest_error(Test_env *, int, const char *);
static char *kill_fmt_entry(char *, int, int, const void *);
static void p_time(struct shf *, bool, long, int, int,
const char *, const char *) __attribute__((nonnull (6, 7)));
const char *, const char *)
MKSH_A_NONNULL((nonnull (6, 7)));
static char *do_realpath(const char *);
static char *
@ -723,7 +724,7 @@ s_get(void)
}
static void
s_put(int c __unused)
s_put(int c MKSH_A_UNUSED)
{
--s_ptr;
}
@ -2422,7 +2423,7 @@ p_time(struct shf *shf, bool posix, long tv_sec, int tv_usec, int width,
}
int
c_times(const char **wp __unused)
c_times(const char **wp MKSH_A_UNUSED)
{
struct rusage usage;
@ -2548,7 +2549,7 @@ timex_hook(struct op *t, char **volatile *app)
/* exec with no args - args case is taken care of in comexec() */
int
c_exec(const char **wp __unused)
c_exec(const char **wp MKSH_A_UNUSED)
{
int i;
@ -2658,7 +2659,7 @@ c_mknod(const char **wp)
/* dummy function, special case in comexec() */
int
c_builtin(const char **wp __unused)
c_builtin(const char **wp MKSH_A_UNUSED)
{
return (0);
}
@ -3075,7 +3076,7 @@ ptest_isa(Test_env *te, Test_meta meta)
}
static const char *
ptest_getopnd(Test_env *te, Test_op op, bool do_eval __unused)
ptest_getopnd(Test_env *te, Test_op op, bool do_eval MKSH_A_UNUSED)
{
if (te->pos.wp >= te->wp_end)
return (op == TO_FILTT ? "1" : NULL);

View File

@ -26,7 +26,7 @@
#include <sys/file.h>
#endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.89 2009/10/02 18:08:33 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.90 2009/12/12 22:27:08 tg Exp $");
/*-
* MirOS: This is the default mapping type, and need not be specified.
@ -597,7 +597,7 @@ init_histvec(void)
* save command in history
*/
void
histsave(int *lnp, const char *cmd, bool dowrite __unused, bool ignoredups)
histsave(int *lnp, const char *cmd, bool dowrite MKSH_A_UNUSED, bool ignoredups)
{
char **hp;
char *c, *cp;
@ -1088,7 +1088,7 @@ alarm_init(void)
/* ARGSUSED */
static void
alarm_catcher(int sig __unused)
alarm_catcher(int sig MKSH_A_UNUSED)
{
int errno_ = errno;

4
jobs.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.65 2009/12/12 17:45:42 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.66 2009/12/12 22:27:08 tg Exp $");
#if HAVE_KILLPG
#define mksh_killpg killpg
@ -1103,7 +1103,7 @@ j_waitj(Job *j,
*/
/* ARGSUSED */
static void
j_sigchld(int sig __unused)
j_sigchld(int sig MKSH_A_UNUSED)
{
int errno_ = errno;
Job *j;

81
sh.h
View File

@ -91,22 +91,36 @@
#include <values.h>
#endif
#if HAVE_ATTRIBUTE
#undef __attribute__
#else
#define __attribute__(x) /* nothing */
#endif
#undef __unused
#define __unused __attribute__((unused))
#if HAVE_ATTRIBUTE_BOUNDED
#define __bound_att__(x) __attribute__(x)
#define MKSH_A_BOUNDED(x,y,z) __attribute__((bounded (x, y, z)))
#else
#define __bound_att__(x) /* nothing */
#define MKSH_A_BOUNDED(x,y,z) /* nothing */
#endif
#if HAVE_ATTRIBUTE_FORMAT
#define MKSH_A_FORMAT(x,y,z) __attribute__((format (x, y, z)))
#else
#define MKSH_A_FORMAT(x,y,z) /* nothing */
#endif
#if HAVE_ATTRIBUTE_NONNULL
#define MKSH_A_NONNULL(a) __attribute__(a)
#else
#define MKSH_A_NONNULL(a) /* nothing */
#endif
#if HAVE_ATTRIBUTE_NORETURN
#define MKSH_A_NORETURN __attribute__((noreturn))
#else
#define MKSH_A_NORETURN /* nothing */
#endif
#if HAVE_ATTRIBUTE_UNUSED
#define MKSH_A_UNUSED __attribute__((unused))
#else
#define MKSH_A_UNUSED /* nothing */
#endif
#if HAVE_ATTRIBUTE_USED
#define __attribute____used__ __attribute__((used))
#define MKSH_A_USED __attribute__((used))
#else
#define __attribute____used__ /* nothing */
#define MKSH_A_USED /* nothing */
#endif
#if (defined(MirBSD) && (MirBSD >= 0x09A1))
@ -127,16 +141,16 @@
#define __IDSTRING_EXPAND(l,p) __IDSTRING_CONCAT(l,p)
#define __IDSTRING(prefix, string) \
static const char __IDSTRING_EXPAND(__LINE__,prefix) [] \
__attribute____used__ = "@(""#)" #prefix ": " string
MKSH_A_USED = "@(""#)" #prefix ": " string
#define __COPYRIGHT(x) __IDSTRING(copyright,x)
#define __RCSID(x) __IDSTRING(rcsid,x)
#define __SCCSID(x) __IDSTRING(sccsid,x)
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.369 2009/12/05 22:19:42 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.370 2009/12/12 22:27:09 tg Exp $");
#endif
#define MKSH_VERSION "R39 2009/12/05"
#define MKSH_VERSION "R39 2009/12/12"
#ifndef MKSH_INCLUDES_ONLY
@ -263,7 +277,7 @@ typedef int bool;
#if !HAVE_ARC4RANDOM_DECL
extern u_int32_t arc4random(void);
extern void arc4random_addrandom(unsigned char *, int)
__bound_att__((bounded (string, 1, 2)));
MKSH_A_BOUNDED(string, 1, 2);
#endif
#if !HAVE_ARC4RANDOM_PUSHB_DECL
@ -1469,8 +1483,8 @@ int j_stopped_running(void);
/* lex.c */
int yylex(int);
void yyerror(const char *, ...)
__attribute__((noreturn))
__attribute__((format (printf, 1, 2)));
MKSH_A_NORETURN
MKSH_A_FORMAT(printf, 1, 2);
Source *pushs(int, Area *);
void set_prompt(int, Source *);
void pprompt(const char *, int);
@ -1479,33 +1493,32 @@ int promptlen(const char *);
int include(const char *, int, const char **, int);
int command(const char *);
int shell(Source *volatile, int volatile);
void unwind(int)
__attribute__((noreturn));
void unwind(int) MKSH_A_NORETURN;
void newenv(int);
void quitenv(struct shf *);
void cleanup_parents_env(void);
void cleanup_proc_env(void);
void errorf(const char *, ...)
__attribute__((noreturn))
__attribute__((format (printf, 1, 2)));
MKSH_A_NORETURN
MKSH_A_FORMAT(printf, 1, 2);
void warningf(bool, const char *, ...)
__attribute__((format (printf, 2, 3)));
MKSH_A_FORMAT(printf, 2, 3);
void bi_errorf(const char *, ...)
__attribute__((format (printf, 1, 2)));
MKSH_A_FORMAT(printf, 1, 2);
#define errorfz() errorf("\1")
#define bi_errorfz() bi_errorf("\1")
void internal_verrorf(const char *, va_list)
__attribute__((format (printf, 1, 0)));
MKSH_A_FORMAT(printf, 1, 0);
void internal_errorf(const char *, ...)
__attribute__((noreturn))
__attribute__((format (printf, 1, 2)));
MKSH_A_NORETURN
MKSH_A_FORMAT(printf, 1, 2);
void internal_warningf(const char *, ...)
__attribute__((format (printf, 1, 2)));
MKSH_A_FORMAT(printf, 1, 2);
void error_prefix(bool);
void shellf(const char *, ...)
__attribute__((format (printf, 1, 2)));
MKSH_A_FORMAT(printf, 1, 2);
void shprintf(const char *, ...)
__attribute__((format (printf, 1, 2)));
MKSH_A_FORMAT(printf, 1, 2);
int can_seek(int);
void initio(void);
int ksh_dup2(int, int, bool);
@ -1553,7 +1566,7 @@ void print_columns(struct shf *, int,
const void *, int, int, bool);
void strip_nuls(char *, int);
int blocking_read(int, char *, int)
__bound_att__((bounded (buffer, 2, 3)));
MKSH_A_BOUNDED(buffer, 2, 3);
int reset_nonblock(int);
char *ksh_get_wd(size_t *);
int make_path(const char *, const char *, char **, XString *, int *);
@ -1581,14 +1594,14 @@ int shf_putchar(int, struct shf *);
int shf_puts(const char *, struct shf *);
int shf_write(const char *, int, struct shf *);
int shf_fprintf(struct shf *, const char *, ...)
__attribute__((format (printf, 2, 3)));
MKSH_A_FORMAT(printf, 2, 3);
int shf_snprintf(char *, int, const char *, ...)
__attribute__((format (printf, 3, 4)))
__bound_att__((bounded (string, 1, 2)));
MKSH_A_FORMAT(printf, 3, 4)
MKSH_A_BOUNDED(string, 1, 2);
char *shf_smprintf(const char *, ...)
__attribute__((format (printf, 1, 2)));
MKSH_A_FORMAT(printf, 1, 2);
int shf_vfprintf(struct shf *, const char *, va_list)
__attribute__((format (printf, 2, 0)));
MKSH_A_FORMAT(printf, 2, 0);
/* syn.c */
void initkeywords(void);
struct op *compile(Source *);

17
syn.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.47 2009/10/30 00:57:39 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.48 2009/12/12 22:27:10 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@ -45,8 +45,7 @@ static struct op *function_body(char *, bool);
static char **wordlist(void);
static struct op *block(int, struct op *, struct op *, char **);
static struct op *newtp(int);
static void syntaxerr(const char *)
__attribute__((noreturn));
static void syntaxerr(const char *) MKSH_A_NORETURN;
static void nesting_push(struct nesting_state *, int);
static void nesting_pop(struct nesting_state *);
static int assign_command(char *);
@ -55,8 +54,7 @@ static int dbtestp_isa(Test_env *, Test_meta);
static const char *dbtestp_getopnd(Test_env *, Test_op, bool);
static int dbtestp_eval(Test_env *, Test_op, const char *,
const char *, bool);
static void dbtestp_error(Test_env *, int, const char *)
__attribute__((noreturn));
static void dbtestp_error(Test_env *, int, const char *) MKSH_A_NORETURN;
static struct op *outtree; /* yyparse output */
static struct nesting_state nesting; /* \n changed to ; */
@ -965,7 +963,8 @@ dbtestp_isa(Test_env *te, Test_meta meta)
}
static const char *
dbtestp_getopnd(Test_env *te, Test_op op __unused, bool do_eval __unused)
dbtestp_getopnd(Test_env *te, Test_op op MKSH_A_UNUSED,
bool do_eval MKSH_A_UNUSED)
{
int c = tpeek(ARRAYVAR);
@ -979,9 +978,9 @@ dbtestp_getopnd(Test_env *te, Test_op op __unused, bool do_eval __unused)
}
static int
dbtestp_eval(Test_env *te __unused, Test_op op __unused,
const char *opnd1 __unused, const char *opnd2 __unused,
bool do_eval __unused)
dbtestp_eval(Test_env *te MKSH_A_UNUSED, Test_op op MKSH_A_UNUSED,
const char *opnd1 MKSH_A_UNUSED, const char *opnd2 MKSH_A_UNUSED,
bool do_eval MKSH_A_UNUSED)
{
return (1);
}