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:
12
expr.c
12
expr.c
@ -1,7 +1,8 @@
|
||||
/* $OpenBSD: expr.c,v 1.21 2009/06/01 19:00:57 deraadt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
||||
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
* 2011, 2012
|
||||
* Thorsten Glaser <tg@mirbsd.org>
|
||||
*
|
||||
* Provided that these terms and disclaimer and all copyright notices
|
||||
@ -22,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.53 2011/12/31 02:04:18 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.54 2012/03/29 19:22:58 tg Exp $");
|
||||
|
||||
/* The order of these enums is constrained by the order of opinfo[] */
|
||||
enum token {
|
||||
@ -368,10 +369,11 @@ evalexpr(Expr_state *es, int prec)
|
||||
case O_DIVASN:
|
||||
#if !HAVE_SILENT_IDIVWRAPV
|
||||
if (!es->natural && vr->val.i == -1 &&
|
||||
vl->val.i == ((mksh_ari_t)1 << 31)) {
|
||||
vl->val.i == ((mksh_ari_t)-2147483648)) {
|
||||
/* -2147483648 / -1 = 2147483648 */
|
||||
/* this ^ is really (1 << 31) though */
|
||||
/* 80000000 / FFFFFFFF = 80000000 */
|
||||
res = ((mksh_ari_t)1 << 31);
|
||||
res = ((mksh_ari_t)-2147483648);
|
||||
} else
|
||||
#endif
|
||||
res = bivui(vl, /, vr);
|
||||
@ -380,7 +382,7 @@ evalexpr(Expr_state *es, int prec)
|
||||
case O_MODASN:
|
||||
#if !HAVE_SILENT_IDIVWRAPV
|
||||
if (!es->natural && vr->val.i == -1 &&
|
||||
vl->val.i == ((mksh_ari_t)1 << 31)) {
|
||||
vl->val.i == ((mksh_ari_t)-2147483648)) {
|
||||
/* -2147483648 % -1 = 0 */
|
||||
res = 0;
|
||||
} else
|
||||
|
Reference in New Issue
Block a user