Beispiel #1
0
/* nap_exit: cleans up and leaves */
void nap_exit (int really_quit, char *reason, char *format, ...)
{
	if (dead == 1) {
		kill_all_threads();
		exit(1);
	}
	else if (dead == 2) {
		kill_all_threads();
		_exit(1);
	}
	else if (dead == 3) {
		kill_all_threads();
		kill(getpid(), SIGKILL);
	}
	dead++;

	set_lastlog_size(NULL, NULL, 0);
	set_history_size(NULL, NULL, 0);

	if (really_quit)
	{
		kill_all_threads();
		say("Signon time  :    %s", my_ctime(start_time));
		say("Signoff time :    %s", my_ctime(now));
		say("Total uptime :    %s", convert_time(now - start_time));
	}
	do_hook(EXIT_LIST, "%s", reason ? reason : empty_string);
	if (reason)
		say("%s", reason);

	close_all_servers();
	close_all_sockets();
	if (term_initialized)
	{
		cursor_to_input();
		term_cr();
		term_clear_to_eol();
		term_reset();
	}

	remove_bindings();
	clear_variables();
	delete_all_windows();
	destroy_call_stack();		
	write_unfinished_list();
	
	debug_cleanup();
	fprintf(stdout, "\r");
	fflush(stdout);
	if (really_quit)
		exit(0);

	kill_all_threads();
	my_signal(SIGABRT, SIG_DFL, 0);
	kill(getpid(), SIGABRT);
	kill(getpid(), SIGQUIT);
	exit(1);
}
Beispiel #2
0
static void
test_envvar_remove_on_clear(void)
{
	assert_true(getenv(VAR_NAME) == NULL);
	assert_int_equal(0, let_variable("$" VAR_NAME "='VAL'"));
	assert_true(getenv(VAR_NAME) != NULL);

	clear_variables();

	assert_true(getenv(VAR_NAME) == NULL);
}
Beispiel #3
0
void parse_script()
{
	// check for valid rover
	if(rover < current_script->data || 
		rover > current_script->data+current_script->len)
    {
		script_error("parse_script: trying to continue from point outside script!\n");
		return;
    }
	
	trigger_obj = current_script->trigger;  // set trigger
	
	parse_data(current_script->data,
		current_script->data+current_script->len);
	
	// dont clear global vars!
	if(current_script->scriptnum != -1)
		clear_variables(current_script);        // free variables
	
	// haleyjd
	current_script->lastiftrue = false;
}
Beispiel #4
0
static void
test_envvar_reset_on_clear(void)
{
	assert_true(getenv("VAR_A") != NULL);
	if(getenv("VAR_A") != NULL)
	{
		assert_string_equal("VAL_A", getenv("VAR_A"));
	}

	assert_int_equal(0, let_variable("$VAR_A='VAL_2'"));
	assert_true(getenv("VAR_A") != NULL);
	if(getenv("VAR_A") != NULL)
	{
		assert_string_equal("VAL_2", getenv("VAR_A"));
	}

	clear_variables();

	assert_true(getenv("VAR_A") != NULL);
	if(getenv("VAR_A") != NULL)
	{
		assert_string_equal("VAL_A", getenv("VAR_A"));
	}
}
/**
 * Delete all variables.
 */
void cmd_clear(char *) {
  clear_variables();
  print_ready();
}
Beispiel #6
0
/**
 * reverse polish calculator\
 * 1 2 - 4 5 + * == (1 - 2) * (4 + 5)
 */
int main (void) {
	int type;
	double op2;
	char s[MAXOP];
	/** signal that we`ve printed last variable and don`t want to show pop() */
	int last_var_printed = 0;

	clear_variables();
	while (_getline(line, MAXLINE) != 0) {
		line_index = 0;
//		while ((type = getop(s)) != EOF) {
		while ((type = getop(s)) != '\0') {
			switch(type) {
				case NUMBER:
					push(atof(s));
					break;
				case FUNCTION_OR_VARIABLE:
					process_function_or_variable(s);
					break;
				case ENDSTRING:
					break;
				case '+':
					push(pop() + pop());
					break;
				case '*':
					push(pop() * pop());
					break;
				case '-':
					/** first pop second operand*/
					op2 = pop();
					push(pop() - op2);
					break;
				case '/':
					op2 = pop();
					if (op2 != 0.0)
						push(pop() / op2);
					else
						printf("error: division by zero\n");
					break;
				case '%':
					op2 = pop();
					if (op2 != 0.0)
						push(fmod(pop(), op2));
					else
						printf("error: division by zero\n");
					break;
				case '?':
					stack_show();
					break;
				case '#':
					stack_duplicate();
					break;				
				case '~':
					stack_swap();
					break;
				case '!':
					stack_clear();
					break;
				case '=':
					/** get '=' from stack - it`s not used */
					pop();
					/** next get real value */
					variables[var_pos].value = pop();
					last_var.value = variables[var_pos].value;
					push(last_var.value);
					break;
				case '$':
					printf("last added value: %s = %f\n", last_var.name, last_var.value);
					last_var_printed = 1;
					break;
				case '\n':
					if (last_var_printed == 0)
						printf("\t%.8f\n", pop());
					else
						last_var_printed = 0;
					break;
				default:
					printf("error1: unknown command \'%s\'\n", s);
					break;
			}
		}
	}
	return 0;
}
Beispiel #7
0
void stack_clear(void) {
	sp = 0;
	clear_variables();
}
Beispiel #8
0
static void
teardown(void)
{
	clear_variables();
	reset_completion();
}
Beispiel #9
0
Integer DAESolver::update_internal_state(Real a_step_interval)
{
    const VariableArray::size_type a_size(the_system_size_);

    the_state_flag_ = false;
    Real const a_previous_step_interval(get_step_interval());

    clear_variables();

    the_rejected_step_flag_ = false;

    for (FunctionArray::size_type c(the_function_differential_size_);
        c < the_system_size_; c++)
    {
        const FunctionArray::size_type an_index(
            c - the_function_differential_size_);

        the_activity_algebraic_buffer_[an_index] 
            = (*the_function_[c])(the_value_differential_,
                the_value_algebraic_, the_current_time_);
    }

    set_variable_velocity(the_taylor_series_[3]);

    if (the_jacobian_calculate_flag_)
    {
        calculate_jacobian();
        set_jacobian_matrix(a_step_interval);
    }
    else
    {
        if (a_previous_step_interval != a_step_interval)
        {
            set_jacobian_matrix(a_step_interval);
        }
    }

    UnsignedInteger count(0);
    for (;;)
    {
        std::pair< bool, Real > a_result(calculate_radauIIA(
            a_step_interval, a_previous_step_interval));

        if (a_result.first)
        {
            break;
        }

        if (++count >= 3)
        {
            break;
        }

        //comment: E-Cell3では
        //aStepInterval = a_result.first;
        //となっていたものを修正
        a_step_interval = a_result.second;

        the_rejected_step_flag_ = true;

        if (!the_jacobian_calculate_flag_)
        {
            calculate_jacobian();
            the_jacobian_calculate_flag_ = true;
        }

        set_jacobian_matrix(a_step_interval);
    }

    the_tolerable_step_interval_ = a_step_interval;


    // the_w_ will already be transformed to Z-form

    for (VariableArray::size_type c(0); c < a_size; ++c)
    {
        the_taylor_series_[3][c] = the_w_[c + a_size * 2];
        the_taylor_series_[3][c] /= a_step_interval;

        if (c < the_function_differential_size_)
        {
            the_value_differential_[c] = the_value_differential_buffer_[c];
        }
        else
        {
            const VariableArray::size_type an_index(
                c - the_function_differential_size_);
            the_value_algebraic_[an_index]
                = the_value_algebraic_buffer_[an_index];
        }
    }

    for (VariableArray::size_type c(0); c < a_size; c++)
    {
        const Real z1(the_w_[c]);
        const Real z2(the_w_[c + a_size]);
        const Real z3(the_w_[c + a_size * 2]);

        the_taylor_series_[0][c] = (13.0 + 7.0 * SQRT6) / 3.0 * z1
            + (13.0 - 7.0 * SQRT6) / 3.0 * z2
            + 1.0 / 3.0 * z3;
        the_taylor_series_[1][c] = - (23.0 + 22.0 * SQRT6) / 3.0 * z1
            + (-23.0 + 22.0 * SQRT6) / 3.0 * z2
            - 8.0 / 3.0 * z3;
        the_taylor_series_[2][c] = (10.0 + 15.0 * SQRT6) / 3.0 * z1 
            + (10.0 - 15.0 * SQRT6) / 3.0 * z2
            + 10.0 / 3.0 * z3;

        the_taylor_series_[0][c] /= a_step_interval;
        the_taylor_series_[1][c] /= a_step_interval;
        the_taylor_series_[2][c] /= a_step_interval;
    }

    the_state_flag_ = true;

    update_internal_state_differential_stepper(a_step_interval);

    //20100224追加
    return get_status_code();

}