コード例 #1
0
ファイル: common.cpp プロジェクト: berdario/fish-shell
wcstring format_string(const wchar_t *format, ...)
{
	va_list va;
	va_start( va, format );
    wcstring result = vformat_string(format, va);
	va_end( va );
    return result;
}
コード例 #2
0
void builtin_printf_state_t::append_format_output(const wchar_t *fmt, ...) {
    // Don't output if we're done.
    if (early_exit) return;

    va_list va;
    va_start(va, fmt);
    wcstring tmp = vformat_string(fmt, va);
    va_end(va);
    streams.out.append(tmp);
}
コード例 #3
0
ファイル: common.cpp プロジェクト: berdario/fish-shell
void append_format(wcstring &str, const wchar_t *format, ...)
{
    /* Preserve errno across this call since it likes to stomp on it */
    int err = errno;
	va_list va;
	va_start( va, format );
    str.append(vformat_string(format, va));
	va_end( va );
    errno = err;
}
コード例 #4
0
static void report_error(int err_code, const wchar_t *err_format, ...)
{
    va_list va;
    va_start(va, err_format);
    const wcstring err_text = vformat_string(err_format, va);
    va_end(va);
    
    if (! err_text.empty())
    {
        fwprintf(stderr, L"%ls: ", err_text.c_str());
    }
    fwprintf(stderr, L"%s\n", strerror(err_code));
}
コード例 #5
0
void builtin_printf_state_t::fatal_error(const wchar_t *fmt, ...) {
    // Don't error twice.
    if (early_exit) return;

    va_list va;
    va_start(va, fmt);
    wcstring errstr = vformat_string(fmt, va);
    va_end(va);
    streams.err.append(errstr);
    if (!string_suffixes_string(L"\n", errstr)) streams.err.push_back(L'\n');

    this->exit_code = STATUS_CMD_ERROR;
    this->early_exit = true;
}
コード例 #6
0
ファイル: parse_util.cpp プロジェクト: FUNK88/fish-shell
/* Append a syntax error to the given error list */
static bool append_syntax_error(parse_error_list_t *errors, const parse_node_t &node, const wchar_t *fmt, ...)
{
    parse_error_t error;
    error.source_start = node.source_start;
    error.source_length = node.source_length;
    error.code = parse_error_syntax;

    va_list va;
    va_start(va, fmt);
    error.text = vformat_string(fmt, va);
    va_end(va);

    errors->push_back(error);
    return true;
}
コード例 #7
0
void builtin_printf_state_t::nonfatal_error(const wchar_t *fmt, ...) {
    // Don't error twice.
    if (early_exit) return;

    va_list va;
    va_start(va, fmt);
    wcstring errstr = vformat_string(fmt, va);
    va_end(va);
    streams.err.append(errstr);
    if (!string_suffixes_string(L"\n", errstr)) streams.err.push_back(L'\n');

    // We set the exit code to error, because one occured,
    // but we don't do an early exit so we still print what we can.
    this->exit_code = STATUS_CMD_ERROR;
}
コード例 #8
0
ファイル: expand.cpp プロジェクト: raichoo/fish-shell
/// Append a syntax error to the given error list.
static void append_syntax_error(parse_error_list_t *errors, size_t source_start, const wchar_t *fmt,
                                ...) {
    if (!errors) return;

    parse_error_t error;
    error.source_start = source_start;
    error.source_length = 0;
    error.code = parse_error_syntax;

    va_list va;
    va_start(va, fmt);
    error.text = vformat_string(fmt, va);
    va_end(va);

    errors->push_back(error);
}
コード例 #9
0
ファイル: common.cpp プロジェクト: berdario/fish-shell
void debug( int level, const wchar_t *msg, ... )
{
	va_list va;

	wcstring sb;

	int errno_old = errno;
	
	if( level > debug_level )
		return;

	CHECK( msg, );
		
	sb = format_string(L"%ls: ", program_name);
	va_start(va, msg);
	sb.append(vformat_string(msg, va));
	va_end(va);

	wcstring sb2;
	write_screen( sb, sb2 );
	fwprintf( stderr, L"%ls", sb2.c_str() );	

	errno = errno_old;
}