mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 11:22:52 +08:00
Remove a bunch of dead code identified by cppcheck
This commit is contained in:
parent
a529fc9d83
commit
7ac593273e
|
@ -1588,14 +1588,14 @@ bool completer_t::complete_param(const wcstring &scmd_orig, const wcstring &spop
|
|||
wcstring completion = format_string(L"%ls=", whole_opt.c_str()+offset);
|
||||
append_completion(this->completions,
|
||||
completion,
|
||||
C_(o->desc.c_str()),
|
||||
C_(o->desc),
|
||||
flags);
|
||||
|
||||
}
|
||||
|
||||
append_completion(this->completions,
|
||||
whole_opt.c_str() + offset,
|
||||
C_(o->desc.c_str()),
|
||||
C_(o->desc),
|
||||
flags);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,24 +79,6 @@ static wcstring default_vars_path()
|
|||
return str2wcstring(machine_id_path);
|
||||
}
|
||||
|
||||
/**
|
||||
The table of all universal variables
|
||||
*/
|
||||
static env_universal_t &default_universal_vars()
|
||||
{
|
||||
static env_universal_t s_default_vars(L"");
|
||||
return s_default_vars;
|
||||
}
|
||||
|
||||
static void (*callback)(fish_message_type_t type,
|
||||
const wchar_t *key,
|
||||
const wchar_t *val);
|
||||
|
||||
void env_universal_common_init(void (*cb)(fish_message_type_t type, const wchar_t *key, const wchar_t *val))
|
||||
{
|
||||
callback = cb;
|
||||
}
|
||||
|
||||
/**
|
||||
Test if the message msg contains the command cmd
|
||||
*/
|
||||
|
@ -1614,24 +1596,6 @@ static bool bool_from_env_var(const char *name, bool default_value)
|
|||
return var ? from_string<bool>(var) : default_value;
|
||||
}
|
||||
|
||||
static bool initialize_synchronizes_via_fishd()
|
||||
{
|
||||
if (program_name && ! wcscmp(program_name, L"fishd"))
|
||||
{
|
||||
/* fishd always wants to use fishd */
|
||||
return true;
|
||||
}
|
||||
|
||||
return bool_from_env_var(UNIVERSAL_USE_FISHD, false);
|
||||
}
|
||||
|
||||
bool synchronizes_via_fishd()
|
||||
{
|
||||
/* Note that in general we can't change this once it's been set, so we only load it once */
|
||||
static bool result = initialize_synchronizes_via_fishd();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool universal_log_enabled()
|
||||
{
|
||||
return bool_from_env_var(UNIVERSAL_LOGGING_ENV_NAME, false);
|
||||
|
|
|
@ -656,7 +656,7 @@ void history_t::set_valid_file_paths(const wcstring_list_t &valid_file_paths, hi
|
|||
scoped_lock locker(lock);
|
||||
|
||||
/* Look for an item with the given identifier. It is likely to be at the end of new_items */
|
||||
for (history_item_list_t::reverse_iterator iter = new_items.rbegin(); iter != new_items.rend(); iter++)
|
||||
for (history_item_list_t::reverse_iterator iter = new_items.rbegin(); iter != new_items.rend(); ++iter)
|
||||
{
|
||||
if (iter->identifier == ident)
|
||||
{
|
||||
|
@ -1565,12 +1565,6 @@ void history_t::save(void)
|
|||
this->save_internal(false);
|
||||
}
|
||||
|
||||
void history_t::save_and_vacuum(void)
|
||||
{
|
||||
scoped_lock locker(lock);
|
||||
this->save_internal(true);
|
||||
}
|
||||
|
||||
void history_t::disable_automatic_saving()
|
||||
{
|
||||
scoped_lock locker(lock);
|
||||
|
|
|
@ -220,9 +220,6 @@ public:
|
|||
/** Saves history */
|
||||
void save();
|
||||
|
||||
/** Performs a full (non-incremental) save */
|
||||
void save_and_vacuum();
|
||||
|
||||
/** Enable / disable automatic saving. Main thread only! */
|
||||
void disable_automatic_saving();
|
||||
void enable_automatic_saving();
|
||||
|
|
|
@ -608,7 +608,7 @@ static void input_mapping_execute(const input_mapping_t &m, bool allow_commands)
|
|||
}
|
||||
}
|
||||
|
||||
input_set_bind_mode(m.sets_mode.c_str());
|
||||
input_set_bind_mode(m.sets_mode);
|
||||
}
|
||||
|
||||
|
||||
|
|
128
output.cpp
128
output.cpp
|
@ -527,134 +527,6 @@ void writestr(const wchar_t *str)
|
|||
delete[] buffer;
|
||||
}
|
||||
|
||||
|
||||
void writestr_ellipsis(const wchar_t *str, int max_width)
|
||||
{
|
||||
int written=0;
|
||||
int tot;
|
||||
|
||||
CHECK(str,);
|
||||
|
||||
tot = fish_wcswidth(str);
|
||||
|
||||
if (tot <= max_width)
|
||||
{
|
||||
writestr(str);
|
||||
return;
|
||||
}
|
||||
|
||||
while (*str != 0)
|
||||
{
|
||||
int w = fish_wcwidth(*str);
|
||||
if (written+w+fish_wcwidth(ellipsis_char)>max_width)
|
||||
{
|
||||
break;
|
||||
}
|
||||
written+=w;
|
||||
writech(*(str++));
|
||||
}
|
||||
|
||||
written += fish_wcwidth(ellipsis_char);
|
||||
writech(ellipsis_char);
|
||||
|
||||
while (written < max_width)
|
||||
{
|
||||
written++;
|
||||
writestr(L" ");
|
||||
}
|
||||
}
|
||||
|
||||
int write_escaped_str(const wchar_t *str, int max_len)
|
||||
{
|
||||
|
||||
int i;
|
||||
int written=0;
|
||||
|
||||
CHECK(str, 0);
|
||||
|
||||
wcstring out = escape(str, ESCAPE_ALL);
|
||||
int len = fish_wcswidth(out);
|
||||
|
||||
if (max_len && (max_len < len))
|
||||
{
|
||||
for (i=0; (written+fish_wcwidth(out[i]))<=(max_len-1); i++)
|
||||
{
|
||||
writech(out[i]);
|
||||
written += fish_wcwidth(out[i]);
|
||||
}
|
||||
writech(ellipsis_char);
|
||||
written += fish_wcwidth(ellipsis_char);
|
||||
|
||||
for (i=written; i<max_len; i++)
|
||||
{
|
||||
writech(L' ');
|
||||
written++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
written = len;
|
||||
writestr(out.c_str());
|
||||
}
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
|
||||
int output_color_code(const wcstring &val, bool is_background)
|
||||
{
|
||||
size_t i;
|
||||
int color=FISH_COLOR_NORMAL;
|
||||
int is_bold=0;
|
||||
int is_underline=0;
|
||||
|
||||
if (val.empty())
|
||||
return FISH_COLOR_NORMAL;
|
||||
|
||||
wcstring_list_t el;
|
||||
tokenize_variable_array(val, el);
|
||||
|
||||
for (size_t j=0; j < el.size(); j++)
|
||||
{
|
||||
const wcstring &next = el.at(j);
|
||||
wcstring color_name;
|
||||
if (is_background)
|
||||
{
|
||||
// look for something like "--background=red"
|
||||
const wcstring prefix = L"--background=";
|
||||
if (string_prefixes_string(prefix, next))
|
||||
{
|
||||
color_name = wcstring(next, prefix.size());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (next == L"--bold" || next == L"-o")
|
||||
is_bold = true;
|
||||
else if (next == L"--underline" || next == L"-u")
|
||||
is_underline = true;
|
||||
else
|
||||
color_name = next;
|
||||
}
|
||||
|
||||
if (! color_name.empty())
|
||||
{
|
||||
for (i=0; i<FISH_COLORS; i++)
|
||||
{
|
||||
if (wcscasecmp(col[i], color_name.c_str()) == 0)
|
||||
{
|
||||
color = col_idx[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return color | (is_bold?FISH_COLOR_BOLD:0) | (is_underline?FISH_COLOR_UNDERLINE:0);
|
||||
}
|
||||
|
||||
rgb_color_t parse_color(const wcstring &val, bool is_background)
|
||||
{
|
||||
int is_bold=0;
|
||||
|
|
12
output.h
12
output.h
|
@ -91,21 +91,9 @@ int writech(wint_t ch);
|
|||
*/
|
||||
void writestr(const wchar_t *str);
|
||||
|
||||
/**
|
||||
Write a wide character string to FD 1. If the string is wider than
|
||||
the specified maximum, truncate and ellipsize it.
|
||||
*/
|
||||
void writestr_ellipsis(const wchar_t *str, int max_width);
|
||||
|
||||
/**
|
||||
Escape and write a string to fd 1
|
||||
*/
|
||||
int write_escaped_str(const wchar_t *str, int max_len);
|
||||
|
||||
/**
|
||||
Return the internal color code representing the specified color
|
||||
*/
|
||||
int output_color_code(const wcstring &val, bool is_background);
|
||||
rgb_color_t parse_color(const wcstring &val, bool is_background);
|
||||
|
||||
/**
|
||||
|
|
2
pager.h
2
pager.h
|
@ -98,8 +98,6 @@ private:
|
|||
|
||||
wcstring prefix;
|
||||
|
||||
void note_selection_changed();
|
||||
|
||||
bool completion_try_print(size_t cols, const wcstring &prefix, const comp_info_list_t &lst, page_rendering_t *rendering, size_t suggested_start_row) const;
|
||||
|
||||
void recalc_min_widths(comp_info_list_t * lst) const;
|
||||
|
|
|
@ -559,11 +559,6 @@ class parse_ll_t
|
|||
return nodes.at(top_symbol.node_idx);
|
||||
}
|
||||
|
||||
parse_token_type_t stack_top_type() const
|
||||
{
|
||||
return symbol_stack.back().type;
|
||||
}
|
||||
|
||||
// Pop from the top of the symbol stack, then push the given production, updating node counts. Note that production_t has type "pointer to array" so some care is required.
|
||||
inline void symbol_stack_pop_push_production(const production_t *production)
|
||||
{
|
||||
|
|
|
@ -288,11 +288,6 @@ int parse_util_locate_cmdsubst_range(const wcstring &str, size_t *inout_cursor_o
|
|||
return parse_util_locate_brackets_range(str, inout_cursor_offset, out_contents, out_start, out_end, accept_incomplete, L'(', L')');
|
||||
}
|
||||
|
||||
int parse_util_locate_slice_range(const wcstring &str, size_t *inout_cursor_offset, wcstring *out_contents, size_t *out_start, size_t *out_end, bool accept_incomplete)
|
||||
{
|
||||
return parse_util_locate_brackets_range(str, inout_cursor_offset, out_contents, out_start, out_end, accept_incomplete, L'[', L']');
|
||||
}
|
||||
|
||||
void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wchar_t **a, const wchar_t **b)
|
||||
{
|
||||
const wchar_t * const cursor = buff + cursor_pos;
|
||||
|
|
|
@ -1075,7 +1075,7 @@ block_t::block_t(block_type_t t) :
|
|||
skip(),
|
||||
tok_pos(),
|
||||
node_offset(NODE_OFFSET_INVALID),
|
||||
loop_status(),
|
||||
loop_status(LOOP_NORMAL),
|
||||
job(),
|
||||
src_filename(),
|
||||
src_lineno(),
|
||||
|
|
21
parser.h
21
parser.h
|
@ -66,6 +66,14 @@ enum block_type_t
|
|||
BREAKPOINT, /**< Breakpoint block */
|
||||
};
|
||||
|
||||
/** Possible states for a loop */
|
||||
enum loop_status_t
|
||||
{
|
||||
LOOP_NORMAL, /**< Current loop block executed as normal */
|
||||
LOOP_BREAK, /**< Current loop block should be removed */
|
||||
LOOP_CONTINUE, /**< Current loop block should be skipped */
|
||||
};
|
||||
|
||||
/**
|
||||
block_t represents a block of commands.
|
||||
*/
|
||||
|
@ -93,7 +101,7 @@ public:
|
|||
node_offset_t node_offset; /* Offset of the node */
|
||||
|
||||
/** Status for the current loop block. Can be any of the values from the loop_status enum. */
|
||||
int loop_status;
|
||||
enum loop_status_t loop_status;
|
||||
|
||||
/** The job that is currently evaluated in the specified block. */
|
||||
job_t *job;
|
||||
|
@ -168,17 +176,6 @@ struct breakpoint_block_t : public block_t
|
|||
breakpoint_block_t();
|
||||
};
|
||||
|
||||
/**
|
||||
Possible states for a loop
|
||||
*/
|
||||
enum loop_status
|
||||
{
|
||||
LOOP_NORMAL, /**< Current loop block executed as normal */
|
||||
LOOP_BREAK, /**< Current loop block should be removed */
|
||||
LOOP_CONTINUE, /**< Current loop block should be skipped */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Errors that can be generated by the parser
|
||||
*/
|
||||
|
|
|
@ -13,23 +13,6 @@ Functions having to do with parser keywords, like testing if a function is a blo
|
|||
#include "common.h"
|
||||
#include "parser_keywords.h"
|
||||
|
||||
|
||||
bool parser_keywords_is_switch(const wcstring &cmd)
|
||||
{
|
||||
if (cmd == L"--")
|
||||
{
|
||||
return ARG_SKIP;
|
||||
}
|
||||
else if (! cmd.empty() && cmd.at(0) == L'-')
|
||||
{
|
||||
return ARG_SWITCH;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ARG_NON_SWITCH;
|
||||
}
|
||||
}
|
||||
|
||||
bool parser_keywords_skip_arguments(const wcstring &cmd)
|
||||
{
|
||||
return contains(cmd,
|
||||
|
|
|
@ -6,25 +6,6 @@ Functions having to do with parser keywords, like testing if a function is a blo
|
|||
#ifndef FISH_PARSER_KEYWORD_H
|
||||
#define FISH_PARSER_KEYWORD_H
|
||||
|
||||
/**
|
||||
Return values for parser_keywords_is_switch()
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ARG_NON_SWITCH,
|
||||
ARG_SWITCH,
|
||||
ARG_SKIP
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Check if the specified argument is a switch. Return ARG_SWITCH if yes,
|
||||
ARG_NON_SWITCH if no and ARG_SKIP if the argument is '--'
|
||||
*/
|
||||
bool parser_keywords_is_switch(const wcstring &cmd);
|
||||
|
||||
|
||||
/**
|
||||
Tests if the specified commands parameters should be interpreted as another command, which will be true if the command is either 'command', 'exec', 'if', 'while', or 'builtin'. This does not handle "else if" which is more complicated.
|
||||
|
||||
|
|
79
path.cpp
79
path.cpp
|
@ -141,85 +141,6 @@ bool path_get_path(const wcstring &cmd, wcstring *out_path)
|
|||
return path_get_path_core(cmd, out_path, env_get_string(L"PATH"));
|
||||
}
|
||||
|
||||
bool path_get_cdpath_string(const wcstring &dir_str, wcstring &result, const env_var_t &cdpath)
|
||||
{
|
||||
wchar_t *res = 0;
|
||||
int err = ENOENT;
|
||||
bool success = false;
|
||||
|
||||
const wchar_t *const dir = dir_str.c_str();
|
||||
if (dir[0] == L'/'|| (wcsncmp(dir, L"./", 2)==0))
|
||||
{
|
||||
struct stat buf;
|
||||
if (wstat(dir, &buf) == 0)
|
||||
{
|
||||
if (S_ISDIR(buf.st_mode))
|
||||
{
|
||||
result = dir_str;
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = ENOTDIR;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
wcstring path = L".";
|
||||
|
||||
// Respect CDPATH
|
||||
env_var_t cdpath = env_get_string(L"CDPATH");
|
||||
if (! cdpath.missing_or_empty())
|
||||
{
|
||||
path = cdpath.c_str();
|
||||
}
|
||||
|
||||
wcstokenizer tokenizer(path, ARRAY_SEP_STR);
|
||||
wcstring next_path;
|
||||
while (tokenizer.next(next_path))
|
||||
{
|
||||
expand_tilde(next_path);
|
||||
if (next_path.size() == 0) continue;
|
||||
|
||||
wcstring whole_path = next_path;
|
||||
append_path_component(whole_path, dir);
|
||||
|
||||
struct stat buf;
|
||||
if (wstat(whole_path, &buf) == 0)
|
||||
{
|
||||
if (S_ISDIR(buf.st_mode))
|
||||
{
|
||||
result = whole_path;
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = ENOTDIR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lwstat(whole_path, &buf) == 0)
|
||||
{
|
||||
err = EROTTEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!success)
|
||||
{
|
||||
errno = err;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool path_get_cdpath(const wcstring &dir, wcstring *out, const wchar_t *wd, const env_vars_snapshot_t &env_vars)
|
||||
{
|
||||
int err = ENOENT;
|
||||
|
|
31
reader.cpp
31
reader.cpp
|
@ -1608,7 +1608,6 @@ static void clear_pager()
|
|||
static void select_completion_in_direction(enum selection_direction_t dir)
|
||||
{
|
||||
assert(data != NULL);
|
||||
/* Note: this will probably trigger reader_selected_completion_changed, which will cause us to update stuff */
|
||||
bool selection_changed = data->pager.select_next_completion_in_direction(dir, data->current_page_rendering);
|
||||
if (selection_changed)
|
||||
{
|
||||
|
@ -4151,36 +4150,6 @@ int reader_has_pager_contents()
|
|||
return ! data->current_page_rendering.screen_data.empty();
|
||||
}
|
||||
|
||||
void reader_selected_completion_changed(pager_t *pager)
|
||||
{
|
||||
/* Only interested in the top level pager */
|
||||
if (data == NULL || pager != &data->pager)
|
||||
return;
|
||||
|
||||
const completion_t *completion = pager->selected_completion(data->current_page_rendering);
|
||||
|
||||
/* Update the cursor and command line */
|
||||
size_t cursor_pos = data->cycle_cursor_pos;
|
||||
wcstring new_cmd_line;
|
||||
|
||||
if (completion == NULL)
|
||||
{
|
||||
new_cmd_line = data->cycle_command_line;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_cmd_line = completion_apply_to_command_line(completion->completion, completion->flags, data->cycle_command_line, &cursor_pos, false);
|
||||
}
|
||||
reader_set_buffer_maintaining_pager(new_cmd_line, cursor_pos);
|
||||
|
||||
/* Since we just inserted a completion, don't immediately do a new autosuggestion */
|
||||
data->suppress_autosuggestion = true;
|
||||
|
||||
/* Trigger repaint (see #765) */
|
||||
reader_repaint_needed();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read non-interactively. Read input from stdin without displaying
|
||||
the prompt, using syntax highlighting. This is used for reading
|
||||
|
|
|
@ -542,13 +542,6 @@ int oflags_for_redirection_type(enum token_type type)
|
|||
}
|
||||
}
|
||||
|
||||
wchar_t tok_last_quote(tokenizer_t *tok)
|
||||
{
|
||||
CHECK(tok, 0);
|
||||
|
||||
return tok->last_quote;
|
||||
}
|
||||
|
||||
/**
|
||||
Test if a character is whitespace. Differs from iswspace in that it
|
||||
does not consider a newline to be whitespace.
|
||||
|
@ -706,36 +699,6 @@ void tok_next(tokenizer_t *tok)
|
|||
|
||||
}
|
||||
|
||||
enum token_type tok_peek_next(tokenizer_t *tok, wcstring *out_next_string)
|
||||
{
|
||||
if (out_next_string != NULL)
|
||||
{
|
||||
out_next_string->clear();
|
||||
}
|
||||
|
||||
enum token_type result = TOK_END;
|
||||
if (tok_has_next(tok))
|
||||
{
|
||||
int saved = tok_get_pos(tok);
|
||||
tok_next(tok);
|
||||
result = tok_last_type(tok);
|
||||
|
||||
if (out_next_string != NULL)
|
||||
{
|
||||
const wchar_t *last = tok_last(tok);
|
||||
out_next_string->assign(last ? last : L"");
|
||||
}
|
||||
|
||||
tok_set_pos(tok, saved);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const wchar_t *tok_string(tokenizer_t *tok)
|
||||
{
|
||||
return tok?tok->orig_buff:0;
|
||||
}
|
||||
|
||||
wcstring tok_first(const wchar_t *str)
|
||||
{
|
||||
wcstring result;
|
||||
|
|
13
tokenizer.h
13
tokenizer.h
|
@ -126,11 +126,6 @@ enum token_type tok_last_type(tokenizer_t *tok);
|
|||
*/
|
||||
const wchar_t *tok_last(tokenizer_t *tok);
|
||||
|
||||
/**
|
||||
Returns the type of quote from the last TOK_QSTRING
|
||||
*/
|
||||
wchar_t tok_last_quote(tokenizer_t *tok);
|
||||
|
||||
/**
|
||||
Returns true as long as there are more tokens left
|
||||
*/
|
||||
|
@ -144,14 +139,6 @@ int tok_get_pos(const tokenizer_t *tok);
|
|||
/** Returns the extent of the current token */
|
||||
size_t tok_get_extent(const tokenizer_t *tok);
|
||||
|
||||
/** Returns the token type after the current one, without adjusting the position. Optionally returns the next string by reference. */
|
||||
enum token_type tok_peek_next(tokenizer_t *tok, wcstring *out_next_string);
|
||||
|
||||
/**
|
||||
Returns the original string to tokenizer
|
||||
*/
|
||||
const wchar_t *tok_string(tokenizer_t *tok);
|
||||
|
||||
/**
|
||||
Returns only the first token from the specified string. This is a
|
||||
convenience function, used to retrieve the first token of a
|
||||
|
|
35
wutil.cpp
35
wutil.cpp
|
@ -188,12 +188,6 @@ FILE *wfopen(const wcstring &path, const char *mode)
|
|||
return result;
|
||||
}
|
||||
|
||||
FILE *wfreopen(const wcstring &path, const char *mode, FILE *stream)
|
||||
{
|
||||
cstring tmp = wcs2string(path);
|
||||
return freopen(tmp.c_str(), mode, stream);
|
||||
}
|
||||
|
||||
bool set_cloexec(int fd)
|
||||
{
|
||||
int flags = fcntl(fd, F_GETFD, 0);
|
||||
|
@ -232,26 +226,12 @@ static int wopen_internal(const wcstring &pathname, int flags, mode_t mode, bool
|
|||
return fd;
|
||||
|
||||
}
|
||||
int wopen(const wcstring &pathname, int flags, mode_t mode)
|
||||
{
|
||||
// off the main thread, always use wopen_cloexec
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
ASSERT_IS_NOT_FORKED_CHILD();
|
||||
return wopen_internal(pathname, flags, mode, false);
|
||||
}
|
||||
|
||||
int wopen_cloexec(const wcstring &pathname, int flags, mode_t mode)
|
||||
{
|
||||
return wopen_internal(pathname, flags, mode, true);
|
||||
}
|
||||
|
||||
|
||||
int wcreat(const wcstring &pathname, mode_t mode)
|
||||
{
|
||||
const cstring tmp = wcs2string(pathname);
|
||||
return creat(tmp.c_str(), mode);
|
||||
}
|
||||
|
||||
DIR *wopendir(const wcstring &name)
|
||||
{
|
||||
const cstring tmp = wcs2string(name);
|
||||
|
@ -488,21 +468,6 @@ const wchar_t *wgettext(const wchar_t *in)
|
|||
return val->c_str(); //looks dangerous but is safe, since the string is stored in the map
|
||||
}
|
||||
|
||||
const wchar_t *wgetenv(const wcstring &name)
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
cstring name_narrow = wcs2string(name);
|
||||
char *res_narrow = getenv(name_narrow.c_str());
|
||||
static wcstring out;
|
||||
|
||||
if (!res_narrow)
|
||||
return 0;
|
||||
|
||||
out = format_string(L"%s", res_narrow);
|
||||
return out.c_str();
|
||||
|
||||
}
|
||||
|
||||
int wmkdir(const wcstring &name, int mode)
|
||||
{
|
||||
cstring name_narrow = wcs2string(name);
|
||||
|
|
17
wutil.h
17
wutil.h
|
@ -38,14 +38,6 @@ FILE *wfopen(const wcstring &path, const char *mode);
|
|||
/** Sets CLO_EXEC on a given fd */
|
||||
bool set_cloexec(int fd);
|
||||
|
||||
/**
|
||||
Wide character version of freopen().
|
||||
*/
|
||||
FILE *wfreopen(const wcstring &path, const char *mode, FILE *stream);
|
||||
|
||||
/** Wide character version of open(). */
|
||||
int wopen(const wcstring &pathname, int flags, mode_t mode = 0);
|
||||
|
||||
/** Wide character version of open() that also sets the close-on-exec flag (atomically when possible). */
|
||||
int wopen_cloexec(const wcstring &pathname, int flags, mode_t mode = 0);
|
||||
|
||||
|
@ -55,10 +47,6 @@ int make_fd_nonblocking(int fd);
|
|||
/** Mark an fd as blocking; returns errno or 0 on success */
|
||||
int make_fd_blocking(int fd);
|
||||
|
||||
/** Wide character version of creat(). */
|
||||
int wcreat(const wcstring &pathname, mode_t mode);
|
||||
|
||||
|
||||
/** Wide character version of opendir(). Note that opendir() is guaranteed to set close-on-exec by POSIX (hooray). */
|
||||
DIR *wopendir(const wcstring &name);
|
||||
|
||||
|
@ -141,11 +129,6 @@ std::wstring wbasename(const std::wstring &path);
|
|||
*/
|
||||
const wchar_t *wgettext(const wchar_t *in);
|
||||
|
||||
/**
|
||||
Wide character version of getenv
|
||||
*/
|
||||
const wchar_t *wgetenv(const wcstring &name);
|
||||
|
||||
/**
|
||||
Wide character version of mkdir
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user