Exemplo n.º 1
0
void shellouch (void) {
	
	/*
	ouch in response to a keystroke -- unless it was a repeat key
	*/
	
	if (!flouchlocked) {
		
		ouch ();
		
		flouchlocked = true;
		}	
	} /*shellouch*/
Exemplo n.º 2
0
Arquivo: eval.c Projeto: certik/nwcc
static int op_prec(int op)
{
	switch (op) {
	case LNOT:
	case NOT:
	case UPLUS:
	case UMINUS:
		return 13;
	case STAR:
	case SLASH:
	case PCT:
		return 12;
	case PLUS:
	case MINUS:
		return 11;
	case LSH:
	case RSH:
		return 10;
	case LT:
	case LEQ:
	case GT:
	case GEQ:
		return 9;
	case SAME:
	case NEQ:
		return 8;
	case AND:
		return 7;
	case CIRC:
		return 6;
	case OR:
		return 5;
	case LAND:
		return 4;
	case LOR:
		return 3;
	case QUEST:
		return 2;
	case COMMA:
		return 1;
	}
#ifdef AUDIT
	ouch("an unknown species should have a higher precedence");
#endif
	return 666;
}
Exemplo n.º 3
0
void test() {
    ouch();
    putString("Please input the row number: ");
    char *input = getString();
    int row = parseString(0, (int)input);
    putString("Please input the col number: ");
    getString();
    int col = parseString(0, (int)input);
    putString("Please input a string: ");
    getString();
    upperCase(0, (int)input);
    putString("UpperCase: ");
    putString(input);
    putString("\n");
    lowerCase(0, (int)input);
    putString("lowerCase: ");
    putString(input);
    putString("\n");
    absPutString(row, col, 0, (int)input);
}
Exemplo n.º 4
0
Arquivo: eval.c Projeto: certik/nwcc
static void z_error(int type)
{
	switch (type) {
	case ARITH_EXCEP_SLASH_D:
		error(eval_line, "division by 0");
		break;
	case ARITH_EXCEP_SLASH_O:
		error(eval_line, "overflow on division");
		break;
	case ARITH_EXCEP_PCT_D:
		error(eval_line, "division by 0 on modulus operator");
		break;
	case ARITH_EXCEP_CONST_O:
		error(eval_line, "constant too large for destination type");
		break;
#ifdef AUDIT
	default:
		ouch("erroneous integer error: %d", type);
#endif
	}
	throw(eval_exception);
}
Exemplo n.º 5
0
NS_EXPORT bool Crash(int how)
{
  switch (how) {
  case CRASH_NULL_POINTER_DEREF: {
    int* foo = (int *)NULL;
    *foo = 5; // boom
    break;
  }
  case CRASH_NULL_POINTER_FNCALL: {
    typedef void (*fn)(void);
    fn ouch = NULL;
    ouch();
    break;
  }
  case CRASH_DIVIDE_BY_ZERO: {
    volatile int foo = 0;
    foo = 5 / foo;
    break;
  }
  case CRASH_STACK_OVERFLOW:
    Crash(CRASH_STACK_OVERFLOW);
    break;
  case CRASH_PURE_VIRTUAL_CALL:
    return callAccessory("crashme_crash_pure_virtual");
  case CRASH_INVALID_CRT_PARAM:
    return callAccessory("crashme_crash_invalid_parameter");
  case CRASH_OBJC_EXCEPTION: {
#ifdef XP_MACOSX
    ThrowObjCException();
    break;
#else
    return false;
#endif
  }
  }

  return true; // not reached
}
Exemplo n.º 6
0
Arquivo: eval.c Projeto: certik/nwcc
static ppval eval_opbin(int op, ppval v1, ppval v2)
{
	ppval r;
	int iv2 = 0;

	switch (op) {
	case STAR:	case SLASH:	case PCT:
	case PLUS:	case MINUS:	case AND:
	case CIRC:	case OR:
		/* promote operands, adjust signedness of result */
		if (!v1.sign || !v2.sign) {
			if (v1.sign) {
				v1.u.uv = big_s_to_u(v1.u.sv);
				v1.sign = 0;
			} else if (v2.sign) {
				v2.u.uv = big_s_to_u(v2.u.sv);
				v2.sign = 0;
			}
			r.sign = 0;
		} else {
			r.sign = 1;
		}
		break;
	case LT:	case LEQ:	case GT:
	case GEQ:	case SAME:	case NEQ:
		/* promote operands */
		if (!v1.sign || !v2.sign) {
			if (v1.sign) {
				v1.u.uv = big_s_to_u(v1.u.sv);
				v1.sign = 0;
			} else if (v2.sign) {
				v2.u.uv = big_s_to_u(v2.u.sv);
				v2.sign = 0;
			}
		}
		/* fall through */
	case LAND:
	case LOR:
		/* result is signed anyway */
		r.sign = 1;
		break;
	case LSH:
	case RSH:
		/* result is as signed as left operand; convert right
		   operand to int */
		r.sign = v1.sign;
		if (v2.sign) {
			iv2 = big_s_toint(v2.u.sv);
		} else {
			iv2 = big_u_toint(v2.u.uv);
		}
		break;
	case COMMA:
		if (emit_eval_warnings) {
			warning(eval_line, "ISO C forbids evaluated comma "
				"operators in #if expressions");
		}
		r.sign = v2.sign;
		break;
#ifdef AUDIT
	default: ouch("a good operator is a dead operator");
#endif
	}

#define SBINOP(x)	if (r.sign) r.u.sv = big_s_ ## x (v1.u.sv, v2.u.sv); \
			else r.u.uv = big_u_ ## x (v1.u.uv, v2.u.uv);

#define NSSBINOP(x)	if (v1.sign) r.u.sv = big_s_fromint(big_s_ ## x \
			(v1.u.sv, v2.u.sv)); else r.u.sv = big_s_fromint( \
			big_u_ ## x (v1.u.uv, v2.u.uv));

#define LBINOP(x)	if (v1.sign) r.u.sv = big_s_fromint( \
			big_s_lval(v1.u.sv) x big_s_lval(v2.u.sv)); \
			else r.u.sv = big_s_fromint( \
			big_u_lval(v1.u.uv) x big_u_lval(v2.u.uv));

#define ABINOP(x)	if (r.sign) r.u.sv = big_s_ ## x (v1.u.sv, iv2); \
			else r.u.uv = big_u_ ## x (v1.u.uv, iv2);

	switch (op) {
	case STAR: SBINOP(star); break;
	case SLASH: SBINOP(slash); break;
	case PCT: SBINOP(pct); break;
	case PLUS: SBINOP(plus); break;
	case MINUS: SBINOP(minus); break;
	case LSH: ABINOP(lsh); break;
	case RSH: ABINOP(rsh); break;
	case LT: NSSBINOP(lt); break;
	case LEQ: NSSBINOP(leq); break;
	case GT: NSSBINOP(gt); break;
	case GEQ: NSSBINOP(geq); break;
	case SAME: NSSBINOP(same); break;
	case NEQ: NSSBINOP(neq); break;
	case AND: SBINOP(and); break;
	case CIRC: SBINOP(xor); break;
	case OR: SBINOP(or); break;
	case LAND: LBINOP(&&); break;
	case LOR: LBINOP(||); break;
	case COMMA: r = v2; break;
	}
	return r;
}
Exemplo n.º 7
0
Arquivo: eval.c Projeto: certik/nwcc
static void z_warn(int type)
{
	switch (type) {
	case ARITH_EXCEP_CONV_O:
		warning(eval_line, "overflow on integer conversion");
		break;
	case ARITH_EXCEP_NEG_O:
		warning(eval_line, "overflow on unary minus");
		break;
	case ARITH_EXCEP_NOT_T:
		warning(eval_line,
			"bitwise inversion yields trap representation");
		break;
	case ARITH_EXCEP_PLUS_O:
		warning(eval_line, "overflow on addition");
		break;
	case ARITH_EXCEP_PLUS_U:
		warning(eval_line, "underflow on addition");
		break;
	case ARITH_EXCEP_MINUS_O:
		warning(eval_line, "overflow on subtraction");
		break;
	case ARITH_EXCEP_MINUS_U:
		warning(eval_line, "underflow on subtraction");
		break;
	case ARITH_EXCEP_AND_T:
		warning(eval_line,
			"bitwise AND yields trap representation");
		break;
	case ARITH_EXCEP_XOR_T:
		warning(eval_line,
			"bitwise XOR yields trap representation");
		break;
	case ARITH_EXCEP_OR_T:
		warning(eval_line,
			"bitwise OR yields trap representation");
		break;
	case ARITH_EXCEP_LSH_W:
		warning(eval_line, "left shift count greater than "
			"or equal to type width");
		break;
	case ARITH_EXCEP_LSH_C:
		warning(eval_line, "left shift count negative");
		break;
	case ARITH_EXCEP_LSH_O:
		warning(eval_line, "overflow on left shift");
		break;
	case ARITH_EXCEP_RSH_W:
		warning(eval_line, "right shift count greater than "
			"or equal to type width");
		break;
	case ARITH_EXCEP_RSH_C:
		warning(eval_line, "right shift count negative");
		break;
	case ARITH_EXCEP_RSH_N:
		warning(eval_line, "right shift of negative value");
		break;
	case ARITH_EXCEP_STAR_O:
		warning(eval_line, "overflow on multiplication");
		break;
	case ARITH_EXCEP_STAR_U:
		warning(eval_line, "underflow on multiplication");
		break;
#ifdef AUDIT
	default:
		ouch("erroneous integer warning: %d", type);
#endif
	}
}
Exemplo n.º 8
0
void shellwindowmenuselect (short ixmenu) {
	
	/*
	implemented using a side-effect we programmed into the update process for
	the window menu.
	
	as the menu is being built pushwindowmenuvisit watches for the indicated
	item number, when found it sets the global hsearch.  that's the one we
	want to bring to the front.
	
	5.0a2 dmb: new hidewindow item
	
	7.0b44 PBS: Minimize Window item on Mac OS X.
	*/
	
	boolean flcommand = false;
	
	flwindowmenudirty = true; /*force update*/
	
	if (ixmenu == hidewindowitem) {
		hdlwindowinfo hinfo;
		
		if (getfrontwindowinfo (&hinfo))
			shellhidewindow (hinfo);
		}
	else {
	
		#if TARGET_API_MAC_CARBON == 1
		
			if (ixmenu == minimizewindowitem) {
				
				hdlwindowinfo hinfo;
		
				flcommand = true;
							
				if (getfrontwindowinfo (&hinfo))
				
					CollapseWindow ((**hinfo).macwindow, true);				
				} /*if*/
			
			if (ixmenu == bringalltofrontwindowitem) {
				
				activateapplication (nil); /*nil means self*/
				
				flcommand = true;
				} /*if*/
				
		#endif
		
		if (!flcommand) {

			ixsearch = ixmenu; /*set global*/
			
			hsearch = nil; /*indicate it wasn't found*/
			
			shellupdatewindowmenu (); /*for side-effect*/
			
			if (hsearch != nil) /*it was found*/
				shellbringtofront (hsearch);
			else
				ouch ();
			} /*if*/
		}
	} /*shellwindowmenuselect*/