예제 #1
0
/*! \brief converts windows path to unix path
 *
 */
int windows_to_unix_path(LPCWSTR win_path, char * unix_path, size_t unix_path_len)
{
	LPWSTR win_path_dup = xwcsdup(win_path);
	int rv = windows_to_unix_path_no_const(win_path_dup, unix_path, unix_path_len);
	xfree(win_path_dup);
	return rv;
}
예제 #2
0
파일: macro.c 프로젝트: andy-js/shinymake
static void
add_macro_to_global_list(name_t *macro_to_add)
{
	macro_list_t *ml;
	wchar_t *name_on_list = NULL, *value_on_list = NULL;
	wchar_t *name_to_add = macro_to_add->n_key;
	wchar_t *value_to_add = NULL;
	property_t *prop;
	macro_t *macro = NULL;
       
	prop = get_prop(macro_to_add->n_prop, PT_MACRO);
	if (prop != NULL)
		macro = (macro_t *)prop->p_body;

	if (macro != NULL && macro->m_value != NULL) {
		value_to_add = macro->m_value->n_key;
	} else {
		value_to_add = L"";
	}

	/*
	 * Check if this macro is already on list; if so, do nothing.
	 */
	for (ml = cond_macro_list; ml != NULL; ml = ml->ml_next) {
		name_on_list = ml->ml_macro_name;
		value_on_list = ml->ml_value;

		if (wcscmp(name_on_list, name_to_add) == 0 &&
		    wcscmp(value_on_list, value_to_add) == 0) {
			return;
		}
	}

	/*
	 * Otherwise, put it at the head of the list:
	 */
	ml = xmalloc(sizeof (*ml));
	ml->ml_macro_name = xwcsdup(name_to_add);
	ml->ml_value = xwcsdup(value_to_add);
	ml->ml_next = cond_macro_list;
	cond_macro_list = ml;
}
예제 #3
0
파일: bindings.c 프로젝트: dmilith/ekg2-bsd
static void add_to_history() {
    if (history[0] != line)
        xfree(history[0]);

    history[0] = lines ? wcs_array_join(lines, TEXT("\015")) : xwcsdup(line);

    xfree(history[HISTORY_MAX - 1]);
    memmove(&history[1], &history[0], sizeof(history) - sizeof(history[0]));

    history[0] = line;
    history_index = 0;
}
예제 #4
0
파일: bindings.c 프로젝트: dmilith/ekg2-bsd
static BINDING_FUNCTION(binding_line_discard)
{
    if (!ncurses_noecho) { /* we don't want to yank passwords */
        xfree(yanked);
        yanked = xwcsdup(line);
    }
    *line = 0;
    line_adjust();

    if (lines && lines_index < array_count((char **) lines) - 1) {
        int i;

        xfree(lines[lines_index]);

        for (i = lines_index; i < array_count((char **) lines); i++)
            lines[i] = lines[i + 1];

        lines = xrealloc(lines, (array_count((char **) lines) + 1) * sizeof(CHAR_T *));

        lines_adjust();
    }
}
예제 #5
0
파일: bindings.c 프로젝트: dmilith/ekg2-bsd
static BINDING_FUNCTION(binding_accept_line)
{
    char *p, *txt;

    if (ncurses_noecho) { /* we are running ui-password-input */
        ncurses_noecho = 0;
        ncurses_passbuf = xwcsdup(line);
        line[0] = 0;
        line_adjust();
        return;
    }

    if (lines) {
        int i;

        lines = xrealloc(lines, (array_count((char **) lines) + 2) * sizeof(CHAR_T *));

        for (i = array_count((char **) lines); i > lines_index; i--)
            lines[i + 1] = lines[i];

        lines[lines_index + 1] = xmalloc(LINE_MAXLEN*sizeof(CHAR_T));
        xwcscpy(lines[lines_index + 1], line + line_index);
        line[line_index] = 0;

        line_index = 0;
        line_start = 0;
        lines_index++;

        lines_adjust();

        return;
    }
    if (arg != BINDING_HISTORY_NOEXEC) {
        txt = wcs_to_normal(line);
        for (p=txt; *p && isspace(*p); p++);
        if (*p || config_send_white_lines)
            command_exec(window_current->target, window_current->session, txt, 0);
        free_utf(txt);
    }

    if (ncurses_plugin_destroyed)
        return;
    if (!line[0] || line[0] == '/' || !window_current->target) /* if empty or command, just mark as modified */
        ncurses_typing_mod		= 1;
    else { /* if message, assume that its' handler has already disabled <composing/> */
        ncurses_typing_win		= NULL;
        window_current->out_active	= 1; /* but also remember that it should have set <active/> chatstate */
    }

    if (xwcscmp(line, TEXT(""))) {
        if (config_history_savedups || xwcscmp(line, history[1]))
            add_to_history();
    } else {
        if (config_enter_scrolls)
            print("none", "");
    }

    history[0] = line;
    history_index = 0;
    *line = 0;
    line_adjust();
}
예제 #6
0
파일: macro.c 프로젝트: andy-js/shinymake
static void
_parse_percent_subst(wchar_t *colon, replacement_t *rpl)
{
	wchar_t *eq = NULL, *percent = NULL;

	if ((eq = (wchar_t *) wcschr(colon + 1, L'=')) == NULL) {
		fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 121,
		    "= missing from replacement macro reference"));
	}

	if ((percent = (wchar_t *) wcschr(colon + 1, L'%')) == NULL) {
		fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 122,
		    "%% missing from replacement macro reference"));
	}

	if (eq < percent) {
		fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 123,
		    "%% missing from replacement macro reference"));
	}

	free(rpl->rpl_left_head);
	if (percent > (colon + 1)) {
		int tmp_len = percent - colon;

		rpl->rpl_left_head = wchar_alloc(tmp_len);
		(void) wcsncpy(rpl->rpl_left_head, colon + 1,
		    percent - colon - 1);
		rpl->rpl_left_head[percent - colon - 1] = L'\0';
		rpl->rpl_left_head_len = percent - colon - 1;
	} else {
		rpl->rpl_left_head = NULL;
		rpl->rpl_left_head_len = 0;
	}

	free(rpl->rpl_left_tail);
	if (eq > percent + 1) {
		int tmp_len = eq - percent;

		rpl->rpl_left_tail = wchar_alloc(tmp_len);
		(void) wcsncpy(rpl->rpl_left_tail, percent + 1, eq - percent - 1);
		rpl->rpl_left_tail[eq - percent - 1] = L'\0';
		rpl->rpl_left_tail_len = eq - percent - 1;
	} else {
		rpl->rpl_left_tail = NULL;
		rpl->rpl_left_tail_len = 0;
	}

	eq++;
	if ((percent = wcschr(eq, L'%')) == NULL) {
		rpl->rpl_right_hand[0] = wchar_alloc(wcslen(eq) + 1);
		rpl->rpl_right_hand[1] = NULL;
		(void) wcscpy(rpl->rpl_right_hand[0], eq);
	} else {
		int i = 0;
		do {
			rpl->rpl_right_hand[i] = wchar_alloc(percent - eq + 1);
			(void) wsncpy(rpl->rpl_right_hand[i], eq, percent - eq);
			rpl->rpl_right_hand[i][percent - eq] = L'\0';

			if (i++ >= REPLACEMENT_RIGHT_HAND_SIZE) {
				fatal_mksh(catgets(libmksdmsi18n_catd, 1, 124,
				    "Too many %% in pattern"));
			}

			eq = percent + 1;
			if (eq[0] == L'\0') {
				rpl->rpl_right_hand[i] = xwcsdup(L"");
				i++;
				break;
			}
		} while ((percent = wcschr(eq, L'%')) != NULL);
		if (eq[0] != (int) nul_char) {
			rpl->rpl_right_hand[i] = xwcsdup(eq);
			i++;
		}
		rpl->rpl_right_hand[i] = NULL;
	}
	rpl->rpl_type = RT_PATTERN;
}