예제 #1
0
파일: input.c 프로젝트: DSMan195276/cmips
void run_input_loop(void)
{
    char *line = NULL;

    if (cmips_arg_state.cmd_script) {
        run_script(cmips_arg_state.cmd_script);
        return ;
    }

    rl_attempted_completion_function = complete_line;

    do {
        line = readline(prompt);
        if (line && *line)
            add_history(line);
        else
            continue;

        run_cmd(line);

        if (line)
            free(line);
    } while (!exit_inp_loop);

    clear_history();
}
예제 #2
0
파일: posty.c 프로젝트: falconindy/posty
int main(int argc, char *argv[]) {
  char *buf, line[BUFSIZ + 1];

  if (argc > 1 && strcmp(argv[1], "-v") == 0) {
    fprintf(stderr, "::Stack dumps enabled::\n");
    verbose = 2;
  }

  stackptr = &opstack[0]; /* initialize stack */

  /* If stdin has data, hit it and quit it */
  if (!isatty(fileno(stdin))) {
    fgets(line, BUFSIZ, stdin);
    parse_expression(line);
    freopen(ctermid(NULL), "r", stdin);
    return 0;
  }

  /* going interactive. fire up readline */
  using_history();

  while ((buf = readline("> ")) != NULL) {
    add_history(buf);
    strcpy(line, buf);
    parse_expression(line);
    stack_reset();
    free(buf);
  }
  putchar('\n');

  clear_history();

  return 0;
}
예제 #3
0
파일: abook_rl.c 프로젝트: braph/abook
static void
abook_rl_init(bool use_completion)
{
	rl_readline_name = RL_READLINE_NAME;

#if RL_VERSION_MAJOR >= 4
	rl_already_prompted = 1;
#endif
	rl_catch_sigwinch = 0;
	rl_erase_empty_line = 0;

	rl_redisplay_function = rline_update;
	rl_completion_display_matches_hook = rline_compdisp;
	rl_prep_term_function = rline_prep_terminal;
	rl_deprep_term_function = rline_deprep_terminal;

	rl_unbind_function_in_map(rl_clear_screen, rl_get_keymap());
	rl_unbind_function_in_map(rl_reverse_search_history, rl_get_keymap());
	rl_unbind_function_in_map(rl_re_read_init_file, rl_get_keymap());

	if(use_completion) {
		rl_bind_key('\t', rl_menu_complete);
	} else {
		rl_unbind_function_in_map(rl_complete, rl_get_keymap());
		rl_unbind_function_in_map(rl_menu_complete, rl_get_keymap());
	}

	rl_bind_key('g' & 31, rl_cancel); /* C-g */

	clear_history();

	rl_cancelled = FALSE;
}
예제 #4
0
파일: firm.c 프로젝트: bashrc/econ
void firm_init(Firm * f)
{
    firm_init_process(f);
    f->location = (unsigned int)(rand()%LOCATIONS);
    f->labour.wage_rate = MIN_WAGE +
        ((rand()%10000/10000.0f)*(MAX_WAGE - MIN_WAGE));
    f->labour.productivity = MIN_PRODUCTIVITY +
        ((rand()%10000/10000.0f)*(MAX_PRODUCTIVITY - MIN_PRODUCTIVITY));
    f->labour.workers = INITIAL_WORKERS;
    f->labour.is_recruiting = 0;
    f->labour.days_per_week =
        (unsigned int)(MIN_DAYS_PER_WEEK +
                       ((rand()%10000/10000.0f)*
                        (MAX_DAYS_PER_WEEK - MIN_DAYS_PER_WEEK)));
    f->labour.time_total =
        MIN_WORKING_DAY +
        ((rand()%10000/10000.0f)*(MAX_WORKING_DAY - MIN_WORKING_DAY));
    f->labour.time_necessary = f->labour.time_total/2;
    f->capital.savings_rate = MIN_SAVINGS_RATE +
        ((rand()%10000/10000.0f)*(MAX_SAVINGS_RATE - MIN_SAVINGS_RATE));
    f->capital.repayment_per_month = 0;
    f->capital.variable = 0;
    f->capital.constant = 10;
    f->capital.fictitious = INITIAL_DEPOSIT;
    f->capital.surplus = 0;
    f->sale_value = 1.50f;
    clear_history(&f->capital);
}
예제 #5
0
void UndoRedo::_process_operation_list(List<Operation>::Element *E) {

	for (;E;E=E->next()) {

		Operation &op=E->get();

		Object *obj = ObjectDB::get_instance(op.object);
		if (!obj) {
			//corruption
			clear_history();
			ERR_FAIL_COND(!obj);

		}
		switch(op.type) {

			case Operation::TYPE_METHOD: {

				obj->call(op.name,VARIANT_ARGS_FROM_ARRAY(op.args));
			} break;
			case Operation::TYPE_PROPERTY: {

				obj->set(op.name,op.args[0]);
			} break;
			case Operation::TYPE_REFERENCE: {
				//do nothing
			} break;

		}
	}
}
예제 #6
0
void XYVirtualKeyboard::switchLanguage()
{
    XYPushButton::chinese = !XYPushButton::chinese;
    languageChanged();
    switchLanguageBtn->update();
    clear_history();
}
예제 #7
0
static int load_history(const char *fname)
{
	history_t hist;

	_dprintf("%s: fname=%s\n", __FUNCTION__, fname);

	if ((decomp(fname, &hist, sizeof(hist), 1) != 1) || (hist.id != CURRENT_ID)) {
		history_v0_t v0;

		if ((decomp(fname, &v0, sizeof(v0), 1) != 1) || (v0.id != ID_V0)) {
			_dprintf("%s: load failed\n", __FUNCTION__);
			return 0;
		}
		else {
			// --- temp conversion ---
			clear_history();

			// V0 -> V1
			history.id = CURRENT_ID;
			memcpy(history.daily, v0.daily, sizeof(history.daily));
			history.dailyp = v0.dailyp;
			memcpy(history.monthly, v0.monthly, sizeof(v0.monthly));	// v0 is just shorter
			history.monthlyp = v0.monthlyp;
		}
	}
	else {
		memcpy(&history, &hist, sizeof(history));
	}

	_dprintf("%s: dailyp=%d monthlyp=%d\n", __FUNCTION__, history.dailyp, history.monthlyp);
	return 1;
}
예제 #8
0
void init_arrays()
{
    init_distance();
    clear_history();
    mvv_lva_init();
    zobrist_init();
}
예제 #9
0
파일: bank.c 프로젝트: bashrc/econ
void bank_init(Bank * b)
{
    unsigned int i;

    b->tax_location = (unsigned int)(rand()%LOCATIONS);
    b->capital.repayment_per_month = 0;
    b->capital.variable = 0;
    b->capital.constant = 0;
    b->capital.surplus = 0;
    b->capital.fictitious = INITIAL_BANK_DEPOSIT;
    b->interest_deposit =
        MIN_BANK_INTEREST +
        ((rand()%10000/10000.0)*(MAX_BANK_INTEREST - MIN_BANK_INTEREST));
    b->interest_loan =
        b->interest_deposit +
        ((rand()%10000/10000.0)*(MAX_LOAN_INTEREST - b->interest_deposit));
    b->active_accounts = 0;
    for (i = 0; i < MAX_ACCOUNTS; i++) {
        b->account[i].entity_type = ENTITY_NONE;
        b->account[i].entity_index = 0;
        b->account[i].balance = 0;
        b->account[i].loan = 0;
        b->account[i].loan_interest_rate = 0;
        b->account[i].loan_elapsed_days = 0;
        b->account[i].loan_repaid = 0;
        b->account[i].loan_repayment_per_month = 0;
    }
    clear_history(&b->capital);
}
예제 #10
0
파일: readline.c 프로젝트: svinota/cx
static PyObject *
py_clear_history(PyObject *self, PyObject *noarg)
{
	clear_history();
	Py_INCREF(Py_None);
	return Py_None;
}
예제 #11
0
void float_filter_update(float_filter_t *filter)
{
	float frequency = filter->definition.frequency;
	float q = filter->definition.q;

	float w0 = 2.0f * M_PI * frequency / (float)SYSTEM_SAMPLE_RATE;
	float cos_w0	= cosf(w0);
	float sin_w0	= sinf(w0);
	float alpha		= sin_w0 / (q + q);

	float a[3];
	float b[3];

	switch(filter->definition.type)
	{
		case FILTER_LPF:
		{
			float tmp = 1.0f - cos_w0;
			b[0] = tmp * 0.5f;
			b[1] = tmp;
			b[2] = tmp * 0.5f;

			a[0] = 1.0f + alpha;
			a[1] = -2.0f * cos_w0;
			a[2] = 1.0f - alpha;
			break;
		}

		case FILTER_HPF:
		{
			float tmp = 1.0f + cos_w0;
			b[0] = tmp * 0.5f;
			b[1] = -tmp;
			b[2] = tmp * 0.5f;

			a[0] = 1.0f + alpha;
			a[1] = -2.0f * cos_w0;
			a[2] = 1.0f - alpha;
			break;
		}

		default:
		{
			b[0] = a[0] = 1.0f;
			a[1] = a[2] = 0.0f;
			b[1] = b[2] = 0.0f;
			break;
		}
	}

	filter->state.input_coeff[0] = b[0] / a[0];
	filter->state.input_coeff[1] = b[1] / a[0];
	filter->state.input_coeff[2] = b[2] / a[0];

	filter->state.output_coeff[0] = a[1] / a[0];
	filter->state.output_coeff[1] = a[2] / a[0];

	clear_history(filter);
}
예제 #12
0
static bool HHVM_FUNCTION(readline_clear_history) {
#ifdef USE_EDITLINE
  // libedit needs this to ensure correct allocation
  using_history();
#endif
  clear_history();
  return true;
}
예제 #13
0
void ssc_input_clear_history(void)
{
#if USE_READLINE
  clear_history ();
#else
  /* nop */
#endif
}
예제 #14
0
void terminate(char *line) {
#ifdef USE_GNU_READLINE
    /* rl_clear_history() does not exist yet in centOS 6 */
    clear_history();
#endif
    if (line)
        free(line);
    printf("exit\n");
    exit(0);
}
예제 #15
0
Zobrist::Zobrist()
{
  zob_key = 0;
  zob_side = genrand64_int64();
  for(int i = 0; i < MAXSIZE2; i++){
    zob_points [0][i] = genrand64_int64();
    zob_points [1][i] = genrand64_int64();
    zob_ko[i] = genrand64_int64();
  }
  clear_history();
}
예제 #16
0
파일: history.c 프로젝트: toddsdk/chessdbot
/* (re)Initialize the history of boards and moves */
void init_history(void) {
    clear_history();
    history.size = 0;
    history.max_size = HISTORY_PAGE_SIZE;
    history.board = (board_t *) malloc(history.max_size * sizeof(board_t));
    if(history.board == NULL)
        quit("Error: Could not create history log!\n");
    history.move = (move_t *) malloc(history.max_size * sizeof(move_t));
    if(history.move == NULL)
        quit("Error: Could not create history log!\n");
}
예제 #17
0
bool XYVirtualKeyboard::backspace_clicked()
{
#ifdef XYINPUT
    if (!alreadyInputLetters.isEmpty())
    {
        alreadyInputLetters = alreadyInputLetters.left(alreadyInputLetters.size() - 1);
        if (!alreadyInputLetters.isEmpty())
        {
            search_begin(alreadyInputLetters);
        }
        else
        {
            clear_history();
        }
    }
#else
    if (letterLabel->text().isEmpty())
    {
        return false;
    }

    unsigned cand_num;
    int already_cand_num = alreadySelectTranslates.size();

    if (already_cand_num > 0) {
        // remove last choose
        alreadySelectTranslates.removeLast();

        cand_num = googlePinyin->unchoose();

    } else {
        // remove last input key
        int spell_len = alreadyInputLetters.length();
        alreadyInputLetters.truncate(spell_len - 1);

        cand_num = googlePinyin->del_search(spell_len - 1);
    }

    if (cand_num == 0) {
        search_closure();
    } else {
        translateHView->dataStrings.clear();
        for (unsigned i = 0; i < cand_num; i++) {
            QString str = googlePinyin->get_candidate(i);
            translateHView->dataStrings.append(str);
        }
        translateHView->move(0, 0);
        translateHView->update();
    }
    loadLetterLabel();
#endif
    return true;
}
예제 #18
0
bool XYVirtualKeyboard::enter_clicked()
{
    if (letterLabel->text().isEmpty())
    {
        return false;
    }

    emit send_commit(letterLabel->text());
    clear_history();

    return true;
}
/* Clear the board and history for a new game */
void new_game(unsigned int size)
{
        tree_view_clear(1);
        clear_history(0);
        set_board_size(size);
        board = NULL;
        go_to_move(0);
        board->moves_left = start_q;
        board->turn = PIECE_BLACK;
        draw_board();
        stop_ai();
        setup_move();
}
예제 #20
0
int main(int argc, char *argv[])
{
	GOptionContext *context;
	GError *err = NULL;
	struct sigaction sa;
	GIOChannel *io;
	GObexTransportType transport;

	context = g_option_context_new(NULL);
	g_option_context_add_main_entries(context, options, NULL);

	g_option_context_parse(context, &argc, &argv, &err);
	if (err != NULL) {
		g_printerr("%s\n", err->message);
		g_error_free(err);
		g_option_context_free(context);
		exit(EXIT_FAILURE);
	}

	if (option_packet)
		transport = G_OBEX_TRANSPORT_PACKET;
	else
		transport = G_OBEX_TRANSPORT_STREAM;

	if (option_bluetooth)
		io = bluetooth_connect(transport);
	else
		io = unix_connect(transport);

	if (io == NULL) {
		g_option_context_free(context);
		exit(EXIT_FAILURE);
	}

	memset(&sa, 0, sizeof(sa));
	sa.sa_handler = sig_term;
	sigaction(SIGINT, &sa, NULL);
	sigaction(SIGTERM, &sa, NULL);

	main_loop = g_main_loop_new(NULL, FALSE);

	g_main_loop_run(main_loop);

	rl_callback_handler_remove();
	clear_history();
	g_obex_unref(obex);
	g_option_context_free(context);
	g_main_loop_unref(main_loop);

	exit(EXIT_SUCCESS);
}
예제 #21
0
void shell_loop(void)
{
#ifdef READLINE

    char* input;// shell_prompt[100];
    char **args;
    // Configure readline to auto-complete paths when the tab key is hit.
    rl_bind_key('\t', rl_complete);
    rl_attempted_completion_function = command_completion;

    printf("Bienvenue dans le simulateur MIPS32. N'hésitez pas à utiliser la commande help.\n");
    uint8_t status = 0;
    do {
        input = readline("simips > ");
        if (!input)
            break;
        if (strcmp(input, "") != 0) {
            add_history(input);
        }
        args = shell_split_line(input);
        status = shell_exec(args);
        if (status != OK && status != EMPTY_LINE) {
            printf("%s\n", err_msgs[status]);
        }

        free(input);
        free(args);
    } while (status != QUIT);
    clear_history();
#else
    char *line;
    char **args;

    printf("Bienvenue dans le simulateur MIPS32. N'hésitez pas à utiliser la commande help.\n");
    uint8_t status = 0;
    do {
        printf("simips > ");
        line = shell_read_line();
        args = shell_split_line(line);
        status = shell_exec(args);
        if (status != OK) {
            printf("%s\n", err_msgs[status]);
        }
        free(line);
        free(args);
    } while (status != QUIT);
#endif


}
예제 #22
0
void UndoRedo::_process_operation_list(List<Operation>::Element *E) {

	for (;E;E=E->next()) {

		Operation &op=E->get();

		Object *obj = ObjectDB::get_instance(op.object);
		if (!obj) {
			//corruption
			clear_history();
			ERR_FAIL_COND(!obj);

		}

		switch(op.type) {

			case Operation::TYPE_METHOD: {

				obj->call(op.name,VARIANT_ARGS_FROM_ARRAY(op.args));				
#ifdef TOOLS_ENABLED
				Resource* res = obj->cast_to<Resource>();
				if (res)
					res->set_edited(true);

#endif

				if (method_callback) {
					method_callback(method_callbck_ud,obj,op.name,VARIANT_ARGS_FROM_ARRAY(op.args));
				}
			} break;
			case Operation::TYPE_PROPERTY: {

				obj->set(op.name,op.args[0]);
#ifdef TOOLS_ENABLED
				Resource* res = obj->cast_to<Resource>();
				if (res)
					res->set_edited(true);
#endif
				if (property_callback) {
					property_callback(prop_callback_ud,obj,op.name,op.args[0]);
				}
			} break;
			case Operation::TYPE_REFERENCE: {
				//do nothing
			} break;

		}
	}
}
예제 #23
0
// clear_history wrapper
tb_int_t xm_readline_clear_history(lua_State* lua)
{
    // check
    tb_assert_and_check_return_val(lua, 0);

#ifdef TB_CONFIG_OS_MACOSX
    // call clear_history (will crash on macOS)
    for (tb_int_t i = history_length - 1; i >= 0; --i)
        remove_history(i);
#else
    clear_history();
#endif

    // ok
    return 0;
}
예제 #24
0
파일: cmd.c 프로젝트: julien-f/shelldon
int
cmd_history (Shell *shell, void *args)
{
	if (array_is_empty (args))
	{
		fprintf (stderr, "The command history expects at least one argument.\n");
		return -1;
	}
	const char *opt = array_get (args, 0);
	if (0 == strcmp ("-c", opt))
	{
		clear_history ();
		return 0;
	}
	return -1;
}
예제 #25
0
/*      OPEN routine called by kernel-interface code
 */
int _ftape_open(void)
{
	TRACE_FUN(8, "_ftape_open");
	int result;
	static int new_tape = 1;

	result = fdc_init();
	if (result >= 0) {
		result = ftape_activate_drive(&drive_type);
		if (result < 0) {
			fdc_disable();
			fdc_release_irq_and_dma();

		} else {
			result = ftape_get_drive_status(&new_tape, &no_tape, &write_protected);
			if (result < 0) {
				ftape_detach_drive();
			} else {
				if (drive_type.vendor_id == UNKNOWN_VENDOR) {
					ftape_log_vendor_id();
				}
				if (no_tape) {
					ftape_offline = 1;
				} else if (new_tape) {
					ftape_offline = 0;
					init_drive_needed = 1;
					read_only = 0;	/* enable writes again */
				}
				if (!ftape_offline && init_drive_needed) {
					result = ftape_init_drive(&formatted);
					if (result >= 0) {
						new_tape = 0;
					} else {
						ftape_detach_drive();
					}
				}
				if (result >= 0) {
					clear_history();
				}
			}
		}
	}
	TRACE_EXIT;
	return result;
}
예제 #26
0
ViewReaction * Calculator::proceed_to_next_state(INPUT_TYPES input_type, OPERATION_MODE operation_mode, int number)
{
    switch (input_type)
    {
        case INPUT_TYPES::OPERAND_CHARACTER:
            on_character_insertion(input_type);
            break;
        case INPUT_TYPES::OPERATOR:
            execute_operation(operation_mode, number, input_type);
            break;
        case INPUT_TYPES::MEMORY_SAVE:
            save_in_memory(number, input_type);
            break;
        case INPUT_TYPES::MEMORY_READ:
            read_from_memory(input_type);
            break;
        case INPUT_TYPES::CLEAR_HISTORY:
            clear_history(input_type);
            break;
    }
}
예제 #27
0
void	builtin_history(t_cmd *cmd, t_fds *fd, t_sh *shell)
{
  if (cmd->argv[1] == NULL)
    {
      exec_process(cmd, fd, shell,  &view_history);
      return ;
    }
  if (cmd->argv[1] != NULL && str_cmp(cmd->argv[1], "-c") == 1)
    {
      clear_history((shell->history));
      shell->history = NULL;
      return ;
    }
  if (cmd->argv[1] != NULL && str_cmp(cmd->argv[1], "-d") == 1 &&
      cmd->argv[2] != NULL)
    {
      rm_history_d(&(shell->history), my_getnbr(cmd->argv[2]));
      return ;
    }
  my_putstr("history: usage: history [-c] [-d offset]\n", 1, -1);
}
예제 #28
0
파일: sys-std.c 프로젝트: lovmoy/r-source
void attribute_hidden Rstd_loadhistory(SEXP call, SEXP op, SEXP args, SEXP env)
{
    SEXP sfile;
    char file[PATH_MAX];
    const char *p;

    sfile = CAR(args);
    if (!isString(sfile) || LENGTH(sfile) < 1)
	errorcall(call, _("invalid '%s' argument"), "file");
    p = R_ExpandFileName(translateChar(STRING_ELT(sfile, 0)));
    if(strlen(p) > PATH_MAX - 1)
	errorcall(call, _("'file' argument is too long"));
    strcpy(file, p);
#if defined(HAVE_LIBREADLINE) && defined(HAVE_READLINE_HISTORY_H)
    if(R_Interactive && UsingReadline) {
	clear_history();
	read_history(file);
    } else errorcall(call, _("no history mechanism available"));
#else
    errorcall(call, _("no history mechanism available"));
#endif
}
예제 #29
0
UndoRedo::~UndoRedo() {

	clear_history();
}
예제 #30
0
파일: readline.c 프로젝트: 1310701102/sl4a
static PyObject *
py_clear_history(PyObject *self, PyObject *noarg)
{
	clear_history();
	Py_RETURN_NONE;
}