couple of minor/cosmetic fixes from RT’s compile farm:
• promote SCO OpenServer and UnixWare to !oswarn • omit trying -O2/-O on OpenServer 5 and USL C • cast mksh_ari_t to int, mksh_uari_t to unsigned int for printf • skip ulimit-1 on syllable (which is still too broken) • write ((mksh_ari_t)-2147483648) ipv UB ((mksh_ari_t)1 << 31) and add a comment that that is actually meant • rewrite functions returning !void ending in NOTREACHED so they’ve got a jump target returning an error at the end, to aid older compilers and just to be safe • cast struct stat.st_size to off_t or size_t explicitly when needed • shorten struct env by two bytes and an alignment, at least also, optimise control flow and fix more paren matching cases
This commit is contained in:
24
funcs.c
24
funcs.c
@ -5,7 +5,7 @@
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||
* 2010, 2011
|
||||
* 2010, 2011, 2012
|
||||
* Thorsten Glaser <tg@mirbsd.org>
|
||||
*
|
||||
* Provided that these terms and disclaimer and all copyright notices
|
||||
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.210 2012/03/26 21:10:42 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.211 2012/03/29 19:22:58 tg Exp $");
|
||||
|
||||
#if HAVE_KILLPG
|
||||
/*
|
||||
@ -2253,7 +2253,7 @@ c_exitreturn(const char **wp)
|
||||
const char *arg;
|
||||
|
||||
if (ksh_getopt(wp, &builtin_opt, null) == '?')
|
||||
return (1);
|
||||
goto c_exitreturn_err;
|
||||
arg = wp[builtin_opt.optind];
|
||||
|
||||
if (arg) {
|
||||
@ -2288,6 +2288,9 @@ c_exitreturn(const char **wp)
|
||||
quitenv(NULL);
|
||||
unwind(how);
|
||||
/* NOTREACHED */
|
||||
|
||||
c_exitreturn_err:
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
@ -2298,19 +2301,19 @@ c_brkcont(const char **wp)
|
||||
const char *arg;
|
||||
|
||||
if (ksh_getopt(wp, &builtin_opt, null) == '?')
|
||||
return (1);
|
||||
goto c_brkcont_err;
|
||||
arg = wp[builtin_opt.optind];
|
||||
|
||||
if (!arg)
|
||||
n = 1;
|
||||
else if (!bi_getn(arg, &n))
|
||||
return (1);
|
||||
quit = n;
|
||||
if (quit <= 0) {
|
||||
goto c_brkcont_err;
|
||||
if (n <= 0) {
|
||||
/* AT&T ksh does this for non-interactive shells only - weird */
|
||||
bi_errorf("%s: %s", arg, "bad value");
|
||||
return (1);
|
||||
goto c_brkcont_err;
|
||||
}
|
||||
quit = n;
|
||||
|
||||
/* Stop at E_NONE, E_PARSE, E_FUNC, or E_INCL */
|
||||
for (ep = e; ep && !STOP_BRKCONT(ep->type); ep = ep->oenv)
|
||||
@ -2344,6 +2347,9 @@ c_brkcont(const char **wp)
|
||||
|
||||
unwind(*wp[0] == 'b' ? LBREAK : LCONTIN);
|
||||
/* NOTREACHED */
|
||||
|
||||
c_brkcont_err:
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
@ -2974,7 +2980,7 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
|
||||
|
||||
/* -s */
|
||||
case TO_FILGZ:
|
||||
return (stat(opnd1, &b1) == 0 && b1.st_size > 0L);
|
||||
return (stat(opnd1, &b1) == 0 && (off_t)b1.st_size > (off_t)0);
|
||||
|
||||
/* -t */
|
||||
case TO_FILTT:
|
||||
|
Reference in New Issue
Block a user