Various changes to reduce fish's compiled code size

OS X release build executable size dropped from 672k to 511k
This commit is contained in:
ridiculousfish 2012-07-17 12:47:01 -07:00
parent 977a4477f6
commit d06d6c6964
17 changed files with 323 additions and 273 deletions

View file

@ -986,8 +986,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_CXX_LIBRARY = "compiler-default";
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_CPP_EXCEPTIONS = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"LOCALEDIR=\\\"/usr/local/share/locale\\\"",
@ -1011,8 +1013,11 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_CXX_LIBRARY = "compiler-default";
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_CPP_EXCEPTIONS = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
"LOCALEDIR=\\\"/usr/local/share/locale\\\"",
"PREFIX=L\\\"/usr/local\\\"",

View file

@ -214,12 +214,14 @@ unsigned char rgb_color_t::to_term256_index() const {
}
unsigned char rgb_color_t::to_name_index() const {
assert(type == type_named || type == type_rgb);
if (type == type_named) {
return data.name_idx;
} else if (type == type_rgb) {
return term8_color_for_rgb(data.rgb);
} else {
throw "Bad type for to_name_index";
/* This is an error */
return -1;
}
}

View file

@ -126,16 +126,6 @@ void show_stackframe()
}
}
wcstring_list_t completions_to_wcstring_list( const std::vector<completion_t> &list )
{
wcstring_list_t strings;
strings.reserve(list.size());
for (std::vector<completion_t>::const_iterator iter = list.begin(); iter != list.end(); ++iter) {
strings.push_back(iter->completion);
}
return strings;
}
int fgetws2(wcstring *s, FILE *f)
{
int i=0;
@ -240,10 +230,6 @@ void sort_strings( std::vector<wcstring> &strings)
std::sort(strings.begin(), strings.end(), string_sort_predicate);
}
void sort_completions( std::vector<completion_t> &completions)
{
std::sort(completions.begin(), completions.end());
}
wchar_t *str2wcs( const char *in )
{
wchar_t *out;
@ -693,34 +679,54 @@ ssize_t read_loop(int fd, void *buff, size_t count)
return result;
}
void debug( int level, const wchar_t *msg, ... )
static bool should_debug(int level)
{
if( level > debug_level )
return false;
/* Hack to not print error messages in the tests */
if ( program_name && ! wcscmp(program_name, L"(ignore)") )
return;
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);
return false;
return true;
}
static void debug_shared( const wcstring &msg )
{
const wcstring sb = wcstring(program_name) + L": " + msg;
wcstring sb2;
write_screen( sb, sb2 );
fwprintf( stderr, L"%ls", sb2.c_str() );
errno = errno_old;
}
void debug( int level, const wchar_t *msg, ... )
{
if (! should_debug(level))
return;
int errno_old = errno;
va_list va;
va_start(va, msg);
wcstring local_msg = vformat_string(msg, va);
va_end(va);
debug_shared(local_msg);
errno = errno_old;
}
void debug( int level, const char *msg, ... )
{
if (! should_debug(level))
return;
int errno_old = errno;
char local_msg[512];
va_list va;
va_start(va, msg);
vsnprintf(local_msg, sizeof local_msg, msg, va);
va_end(va);
debug_shared(str2wcstring(local_msg));
errno = errno_old;
}
void debug_safe(int level, const char *msg, const char *param1, const char *param2, const char *param3, const char *param4, const char *param5, const char *param6, const char *param7, const char *param8, const char *param9, const char *param10, const char *param11, const char *param12)
{
const char * const params[] = {param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12};

View file

@ -122,7 +122,7 @@ extern const wchar_t *program_name;
if( !(arg) ) \
{ \
debug( 0, \
_( L"function %s called with null value for argument %s. " ), \
"function %s called with null value for argument %s. ", \
__func__, \
#arg ); \
bugreport(); \
@ -162,7 +162,7 @@ extern const wchar_t *program_name;
if( signal_is_blocked() ) \
{ \
debug( 0, \
_( L"function %s called while blocking signals. " ), \
"function %s called while blocking signals. ", \
__func__); \
bugreport(); \
show_stackframe(); \
@ -191,8 +191,6 @@ extern const wchar_t *program_name;
void show_stackframe();
wcstring_list_t completions_to_wcstring_list( const std::vector<completion_t> &completions );
/**
Read a line from the stream f into the buffer buff of length len. If
buff is to small, it will be reallocated, and both buff and len will
@ -211,8 +209,6 @@ int fgetws2(wcstring *s, FILE *f);
void sort_strings( std::vector<wcstring> &strings);
void sort_completions( std::vector<completion_t> &strings);
/**
Returns a newly allocated wide character string equivalent of the
specified multibyte character string
@ -635,6 +631,7 @@ ssize_t read_loop(int fd, void *buff, size_t count);
will print the string 'fish: Pi = 3.141', given that debug_level is 1 or higher, and that program_name is 'fish'.
*/
void debug( int level, const char *msg, ... );
void debug( int level, const wchar_t *msg, ... );
/**

View file

@ -251,6 +251,41 @@ const wcstring &completion_entry_t::get_short_opt_str() const {
return short_opt_str;
}
/* completion_t functions */
completion_t::completion_t(const wcstring &comp, const wcstring &desc, int flags_val) : completion(comp), description(desc), flags(flags_val)
{
}
completion_t::completion_t(const completion_t &him) : completion(him.completion), description(him.description), flags(him.flags)
{
}
completion_t &completion_t::operator=(const completion_t &him)
{
if (this != &him)
{
this->completion = him.completion;
this->description = him.description;
this->flags = him.flags;
}
return *this;
}
wcstring_list_t completions_to_wcstring_list( const std::vector<completion_t> &list )
{
wcstring_list_t strings;
strings.reserve(list.size());
for (std::vector<completion_t>::const_iterator iter = list.begin(); iter != list.end(); ++iter) {
strings.push_back(iter->completion);
}
return strings;
}
void sort_completions( std::vector<completion_t> &completions)
{
std::sort(completions.begin(), completions.end());
}
/** Class representing an attempt to compute completions */
class completer_t {
const complete_type_t type;
@ -347,7 +382,7 @@ void completion_autoload_t::command_removed(const wcstring &cmd) {
Create a new completion entry
*/
void completion_allocate(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc, complete_flags_t flags)
void append_completion(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc, complete_flags_t flags)
{
completions.push_back(completion_t(comp, desc, flags));
}
@ -1413,7 +1448,7 @@ bool completer_t::complete_param( const wcstring &scmd_orig, const wcstring &spo
completion[0] = o->short_opt;
completion[1] = 0;
completion_allocate( this->completions, completion, desc, 0 );
append_completion( this->completions, completion, desc, 0 );
}
@ -1465,14 +1500,14 @@ bool completer_t::complete_param( const wcstring &scmd_orig, const wcstring &spo
homebrew getopt-like functions.
*/
wcstring completion = format_string(L"%ls=", whole_opt.c_str()+offset);
completion_allocate( this->completions,
append_completion( this->completions,
completion,
C_(o->desc.c_str()),
flags );
}
completion_allocate( this->completions,
append_completion( this->completions,
whole_opt.c_str() + offset,
C_(o->desc.c_str()),
flags );
@ -1582,7 +1617,7 @@ bool completer_t::complete_variable(const wcstring &str, int start_offset)
desc = format_string(COMPLETE_VAR_DESC_VAL, value.c_str());
}
completion_allocate( this->completions, comp.c_str(), desc.c_str(), flags );
append_completion( this->completions, comp.c_str(), desc.c_str(), flags );
res =1;
}
@ -1657,7 +1692,7 @@ bool completer_t::try_complete_user( const wcstring &str )
if( wcsncmp( user_name, pw_name, name_len )==0 )
{
wcstring desc = format_string(COMPLETE_USER_DESC, pw_name);
completion_allocate( this->completions,
append_completion( this->completions,
&pw_name[name_len],
desc,
COMPLETE_NO_SPACE );
@ -1669,7 +1704,7 @@ bool completer_t::try_complete_user( const wcstring &str )
wcstring name = format_string(L"~%ls", pw_name);
wcstring desc = format_string(COMPLETE_USER_DESC, pw_name);
completion_allocate( this->completions,
append_completion( this->completions,
name,
desc,
COMPLETE_NO_CASE | COMPLETE_DONT_ESCAPE | COMPLETE_NO_SPACE );

View file

@ -134,17 +134,12 @@ public:
*/
int flags;
completion_t(const wcstring &comp, const wcstring &desc = L"", int flags_val = 0) : completion(comp), description(desc), flags(flags_val) {
if( flags & COMPLETE_AUTO_SPACE )
{
flags = flags & ~COMPLETE_AUTO_SPACE;
size_t len = completion.size();
if (len > 0 && ( wcschr( L"/=@:", comp.at(len-1)) != 0 ))
flags |= COMPLETE_NO_SPACE;
}
}
/* Construction. Note: defining these so that they are not inlined reduces the executable size. */
completion_t(const wcstring &comp, const wcstring &desc = L"", int flags_val = 0);
completion_t(const completion_t &);
completion_t &operator=(const completion_t &);
/* The following are needed for sorting and uniquing completions */
bool operator < (const completion_t& rhs) const { return this->completion < rhs.completion; }
bool operator == (const completion_t& rhs) const { return this->completion == rhs.completion; }
bool operator != (const completion_t& rhs) const { return ! (*this == rhs); }
@ -155,6 +150,12 @@ enum complete_type_t {
COMPLETE_AUTOSUGGEST
};
/** Given a list of completions, returns a list of their completion fields */
wcstring_list_t completions_to_wcstring_list( const std::vector<completion_t> &completions );
/** Sorts a list of completions */
void sort_completions( std::vector<completion_t> &completions);
/**
Add a completion.
@ -270,7 +271,7 @@ void complete_load( const wcstring &cmd, bool reload );
\param flags completion flags
*/
void completion_allocate(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc, int flags);
void append_completion(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc = L"", int flags = 0);
#endif

View file

@ -106,7 +106,8 @@ static void parse_message( wchar_t *msg,
/**
The table of all universal variables
*/
std::map<wcstring, var_uni_entry_t*> env_universal_var;
typedef std::map<wcstring, var_uni_entry_t*> env_var_table_t;
env_var_table_t env_universal_var;
/**
Callback function, should be called on all events
@ -412,7 +413,7 @@ void env_universal_common_init( void (*cb)(int type, const wchar_t *key, const w
void env_universal_common_destroy()
{
std::map<wcstring, var_uni_entry_t*>::iterator iter;
env_var_table_t::iterator iter;
for(iter = env_universal_var.begin(); iter != env_universal_var.end(); ++iter)
{
@ -545,7 +546,7 @@ void read_message( connection_t *src )
*/
void env_universal_common_remove( const wcstring &name )
{
std::map<wcstring, var_uni_entry_t*>::iterator result = env_universal_var.find(name);
env_var_table_t::iterator result = env_universal_var.find(name);
if (result != env_universal_var.end())
{
var_uni_entry_t* v = result->second;
@ -900,7 +901,7 @@ void env_universal_common_get_names( wcstring_list_t &lst,
int show_exported,
int show_unexported )
{
std::map<wcstring, var_uni_entry_t*>::const_iterator iter;
env_var_table_t::const_iterator iter;
for (iter = env_universal_var.begin(); iter != env_universal_var.end(); ++iter)
{
const wcstring& key = iter->first;
@ -918,7 +919,7 @@ void env_universal_common_get_names( wcstring_list_t &lst,
wchar_t *env_universal_common_get( const wcstring &name )
{
std::map<wcstring, var_uni_entry_t*>::const_iterator result = env_universal_var.find(name);
env_var_table_t::const_iterator result = env_universal_var.find(name);
if (result != env_universal_var.end() )
{
@ -932,7 +933,7 @@ wchar_t *env_universal_common_get( const wcstring &name )
int env_universal_common_get_export( const wcstring &name )
{
std::map<wcstring, var_uni_entry_t*>::const_iterator result = env_universal_var.find(name);
env_var_table_t::const_iterator result = env_universal_var.find(name);
if (result != env_universal_var.end() )
{
const var_uni_entry_t *e = result->second;
@ -944,7 +945,7 @@ int env_universal_common_get_export( const wcstring &name )
void enqueue_all( connection_t *c )
{
std::map<wcstring, var_uni_entry_t*>::const_iterator iter;
env_var_table_t::const_iterator iter;
for (iter = env_universal_var.begin(); iter != env_universal_var.end(); ++iter)
{

View file

@ -24,7 +24,6 @@
#include <dirent.h>
#include <time.h>
#include <vector>
#include <deque>
#include <algorithm>
#include <memory>

View file

@ -589,7 +589,7 @@ static int find_process( const wchar_t *proc,
if( wcsncmp( proc, jid, wcslen(proc ) )==0 )
{
wcstring desc_buff = format_string(COMPLETE_JOB_DESC_VAL, j->command_wcstr());
completion_allocate( out,
append_completion( out,
jid+wcslen(proc),
desc_buff,
0 );
@ -610,10 +610,8 @@ static int find_process( const wchar_t *proc,
j = job_get( jid );
if( (j != 0) && (j->command_wcstr() != 0 ) )
{
{
wcstring result = to_string((long)j->pgid);
out.push_back(completion_t(result));
append_completion(out, to_string<long>(j->pgid));
found = 1;
}
}
@ -635,15 +633,14 @@ static int find_process( const wchar_t *proc,
{
if( flags & ACCEPT_INCOMPLETE )
{
completion_allocate( out,
append_completion( out,
j->command_wcstr() + offset + wcslen(proc),
COMPLETE_JOB_DESC,
0 );
}
else
{
wcstring result = to_string((long)j->pgid);
out.push_back(completion_t(result));
append_completion(out, to_string<long>(j->pgid));
found = 1;
}
}
@ -671,15 +668,17 @@ static int find_process( const wchar_t *proc,
{
if( flags & ACCEPT_INCOMPLETE )
{
completion_allocate( out,
append_completion( out,
p->actual_cmd + offset + wcslen(proc),
COMPLETE_CHILD_PROCESS_DESC,
0 );
}
else
{
wcstring result = to_string<int>(p->pid);
out.push_back(completion_t(result));
append_completion (out,
to_string<long>(p->pid),
L"",
0);
found = 1;
}
}
@ -703,14 +702,14 @@ static int find_process( const wchar_t *proc,
{
if( flags & ACCEPT_INCOMPLETE )
{
completion_allocate( out,
append_completion( out,
process_name.c_str() + offset + wcslen(proc),
COMPLETE_PROCESS_DESC,
0 );
}
else
{
out.push_back(completion_t(to_string((long)process_pid)));
append_completion(out, to_string<long>(process_pid));
}
}
}
@ -732,7 +731,7 @@ static int expand_pid( const wcstring &instr_with_sep,
if( instr.empty() || instr.at(0) != PROCESS_EXPAND )
{
out.push_back(completion_t(instr));
append_completion(out, instr);
return 1;
}
@ -742,14 +741,14 @@ static int expand_pid( const wcstring &instr_with_sep,
{
if( wcsncmp( in+1, SELF_STR, wcslen(in+1) )==0 )
{
completion_allocate( out,
append_completion( out,
SELF_STR+wcslen(in+1),
COMPLETE_SELF_DESC,
0 );
}
else if( wcsncmp( in+1, LAST_STR, wcslen(in+1) )==0 )
{
completion_allocate( out,
append_completion( out,
LAST_STR+wcslen(in+1),
COMPLETE_LAST_DESC,
0 );
@ -760,8 +759,7 @@ static int expand_pid( const wcstring &instr_with_sep,
if( wcscmp( (in+1), SELF_STR )==0 )
{
const wcstring pid_str = to_string<int>(getpid());
out.push_back(completion_t(pid_str));
append_completion(out, to_string<long>(getpid()));
return 1;
}
@ -769,8 +767,7 @@ static int expand_pid( const wcstring &instr_with_sep,
{
if( proc_last_bg_pid > 0 )
{
const wcstring pid_str = to_string<int>(proc_last_bg_pid);
out.push_back( completion_t(pid_str));
append_completion(out, to_string<long>(proc_last_bg_pid));
}
return 1;
@ -1090,7 +1087,7 @@ static int expand_variables_internal( parser_t &parser, wchar_t * const in, std:
const wcstring &next = var_item_list.at(j);
if( is_ok && (i == 0) && (!in[stop_pos]) )
{
out.push_back(completion_t(next));
append_completion(out, next);
}
else
{
@ -1152,7 +1149,7 @@ static int expand_variables_internal( parser_t &parser, wchar_t * const in, std:
if( !empty )
{
out.push_back(completion_t(in));
append_completion(out, in);
}
return is_ok;
@ -1247,7 +1244,7 @@ static int expand_brackets(parser_t &parser, const wchar_t *in, int flags, std::
if( bracket_begin == 0 )
{
out.push_back(completion_t(in));
append_completion(out, in);
return 1;
}

View file

@ -1274,7 +1274,7 @@ void highlight_shell( const wcstring &buff, std::vector<int> &color, int pos, wc
const size_t length = buff.size();
assert(buff.size() == color.size());
if( length == 0 )
return;

View file

@ -495,7 +495,7 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
/* Append old items */
load_old_if_needed();
for (std::deque<size_t>::const_reverse_iterator iter = old_item_offsets.rbegin(); iter != old_item_offsets.rend(); ++iter) {
for (std::vector<size_t>::const_reverse_iterator iter = old_item_offsets.rbegin(); iter != old_item_offsets.rend(); ++iter) {
size_t offset = *iter;
const history_item_t item = history_t::decode_item(mmap_start + offset, mmap_length - offset, mmap_type);
if (! first)
@ -927,7 +927,7 @@ wcstring history_search_t::current_string() const {
}
bool history_search_t::match_already_made(const wcstring &match) const {
for (std::deque<prev_match_t>::const_iterator iter = prev_matches.begin(); iter != prev_matches.end(); ++iter) {
for (std::vector<prev_match_t>::const_iterator iter = prev_matches.begin(); iter != prev_matches.end(); ++iter) {
if (iter->second.str() == match)
return true;
}

View file

@ -9,7 +9,6 @@
#include "common.h"
#include "pthread.h"
#include <vector>
#include <deque>
#include <utility>
#include <list>
#include <tr1/memory>
@ -123,7 +122,7 @@ private:
void populate_from_mmap(void);
/** List of old items, as offsets into out mmap data */
std::deque<size_t> old_item_offsets;
std::vector<size_t> old_item_offsets;
/** Whether we've loaded old items */
bool loaded_old;
@ -186,7 +185,7 @@ class history_search_t {
/** Our list of previous matches as index, value. The end is the current match. */
typedef std::pair<size_t, history_item_t> prev_match_t;
std::deque<prev_match_t> prev_matches;
std::vector<prev_match_t> prev_matches;
/** Returns yes if a given term is in prev_matches. */
bool match_already_made(const wcstring &match) const;

312
input.cpp
View file

@ -224,14 +224,7 @@ static std::vector<input_mapping_t> mapping_list;
/* Terminfo map list */
static std::vector<terminfo_mapping_t> terminfo_mappings;
/** Add a new terminfo mapping */
static inline void terminfo_add(const wchar_t *name, const char *seq)
{
terminfo_mapping_t mapping = {name, seq};
terminfo_mappings.push_back(mapping);
}
#define TERMINFO_ADD(key) do { terminfo_add((L ## #key)+4, key); } while (0)
#define TERMINFO_ADD(key) { (L ## #key) + 4, key }
/**
@ -614,52 +607,53 @@ bool input_mapping_get( const wcstring &sequence, wcstring &cmd )
*/
static void input_terminfo_init()
{
TERMINFO_ADD(key_a1);
TERMINFO_ADD(key_a3);
TERMINFO_ADD(key_b2);
TERMINFO_ADD(key_backspace);
TERMINFO_ADD(key_beg);
TERMINFO_ADD(key_btab);
TERMINFO_ADD(key_c1);
TERMINFO_ADD(key_c3);
TERMINFO_ADD(key_cancel);
TERMINFO_ADD(key_catab);
TERMINFO_ADD(key_clear);
TERMINFO_ADD(key_close);
TERMINFO_ADD(key_command);
TERMINFO_ADD(key_copy);
TERMINFO_ADD(key_create);
TERMINFO_ADD(key_ctab);
TERMINFO_ADD(key_dc);
TERMINFO_ADD(key_dl);
TERMINFO_ADD(key_down);
TERMINFO_ADD(key_eic);
TERMINFO_ADD(key_end);
TERMINFO_ADD(key_enter);
TERMINFO_ADD(key_eol);
TERMINFO_ADD(key_eos);
TERMINFO_ADD(key_exit);
TERMINFO_ADD(key_f0);
TERMINFO_ADD(key_f1);
TERMINFO_ADD(key_f2);
TERMINFO_ADD(key_f3);
TERMINFO_ADD(key_f4);
TERMINFO_ADD(key_f5);
TERMINFO_ADD(key_f6);
TERMINFO_ADD(key_f7);
TERMINFO_ADD(key_f8);
TERMINFO_ADD(key_f9);
TERMINFO_ADD(key_f10);
TERMINFO_ADD(key_f11);
TERMINFO_ADD(key_f12);
TERMINFO_ADD(key_f13);
TERMINFO_ADD(key_f14);
TERMINFO_ADD(key_f15);
TERMINFO_ADD(key_f16);
TERMINFO_ADD(key_f17);
TERMINFO_ADD(key_f18);
TERMINFO_ADD(key_f19);
TERMINFO_ADD(key_f20);
const terminfo_mapping_t tinfos[] = {
TERMINFO_ADD(key_a1),
TERMINFO_ADD(key_a3),
TERMINFO_ADD(key_b2),
TERMINFO_ADD(key_backspace),
TERMINFO_ADD(key_beg),
TERMINFO_ADD(key_btab),
TERMINFO_ADD(key_c1),
TERMINFO_ADD(key_c3),
TERMINFO_ADD(key_cancel),
TERMINFO_ADD(key_catab),
TERMINFO_ADD(key_clear),
TERMINFO_ADD(key_close),
TERMINFO_ADD(key_command),
TERMINFO_ADD(key_copy),
TERMINFO_ADD(key_create),
TERMINFO_ADD(key_ctab),
TERMINFO_ADD(key_dc),
TERMINFO_ADD(key_dl),
TERMINFO_ADD(key_down),
TERMINFO_ADD(key_eic),
TERMINFO_ADD(key_end),
TERMINFO_ADD(key_enter),
TERMINFO_ADD(key_eol),
TERMINFO_ADD(key_eos),
TERMINFO_ADD(key_exit),
TERMINFO_ADD(key_f0),
TERMINFO_ADD(key_f1),
TERMINFO_ADD(key_f2),
TERMINFO_ADD(key_f3),
TERMINFO_ADD(key_f4),
TERMINFO_ADD(key_f5),
TERMINFO_ADD(key_f6),
TERMINFO_ADD(key_f7),
TERMINFO_ADD(key_f8),
TERMINFO_ADD(key_f9),
TERMINFO_ADD(key_f10),
TERMINFO_ADD(key_f11),
TERMINFO_ADD(key_f12),
TERMINFO_ADD(key_f13),
TERMINFO_ADD(key_f14),
TERMINFO_ADD(key_f15),
TERMINFO_ADD(key_f16),
TERMINFO_ADD(key_f17),
TERMINFO_ADD(key_f18),
TERMINFO_ADD(key_f19),
TERMINFO_ADD(key_f20),
/*
I know of no keyboard with more than 20 function keys, so
adding the rest here makes very little sense, since it will
@ -667,109 +661,113 @@ static void input_terminfo_init()
but with no benefit.
*/
/*
TERMINFO_ADD(key_f21);
TERMINFO_ADD(key_f22);
TERMINFO_ADD(key_f23);
TERMINFO_ADD(key_f24);
TERMINFO_ADD(key_f25);
TERMINFO_ADD(key_f26);
TERMINFO_ADD(key_f27);
TERMINFO_ADD(key_f28);
TERMINFO_ADD(key_f29);
TERMINFO_ADD(key_f30);
TERMINFO_ADD(key_f31);
TERMINFO_ADD(key_f32);
TERMINFO_ADD(key_f33);
TERMINFO_ADD(key_f34);
TERMINFO_ADD(key_f35);
TERMINFO_ADD(key_f36);
TERMINFO_ADD(key_f37);
TERMINFO_ADD(key_f38);
TERMINFO_ADD(key_f39);
TERMINFO_ADD(key_f40);
TERMINFO_ADD(key_f41);
TERMINFO_ADD(key_f42);
TERMINFO_ADD(key_f43);
TERMINFO_ADD(key_f44);
TERMINFO_ADD(key_f45);
TERMINFO_ADD(key_f46);
TERMINFO_ADD(key_f47);
TERMINFO_ADD(key_f48);
TERMINFO_ADD(key_f49);
TERMINFO_ADD(key_f50);
TERMINFO_ADD(key_f51);
TERMINFO_ADD(key_f52);
TERMINFO_ADD(key_f53);
TERMINFO_ADD(key_f54);
TERMINFO_ADD(key_f55);
TERMINFO_ADD(key_f56);
TERMINFO_ADD(key_f57);
TERMINFO_ADD(key_f58);
TERMINFO_ADD(key_f59);
TERMINFO_ADD(key_f60);
TERMINFO_ADD(key_f61);
TERMINFO_ADD(key_f62);
TERMINFO_ADD(key_f63);*/
TERMINFO_ADD(key_find);
TERMINFO_ADD(key_help);
TERMINFO_ADD(key_home);
TERMINFO_ADD(key_ic);
TERMINFO_ADD(key_il);
TERMINFO_ADD(key_left);
TERMINFO_ADD(key_ll);
TERMINFO_ADD(key_mark);
TERMINFO_ADD(key_message);
TERMINFO_ADD(key_move);
TERMINFO_ADD(key_next);
TERMINFO_ADD(key_npage);
TERMINFO_ADD(key_open);
TERMINFO_ADD(key_options);
TERMINFO_ADD(key_ppage);
TERMINFO_ADD(key_previous);
TERMINFO_ADD(key_print);
TERMINFO_ADD(key_redo);
TERMINFO_ADD(key_reference);
TERMINFO_ADD(key_refresh);
TERMINFO_ADD(key_replace);
TERMINFO_ADD(key_restart);
TERMINFO_ADD(key_resume);
TERMINFO_ADD(key_right);
TERMINFO_ADD(key_save);
TERMINFO_ADD(key_sbeg);
TERMINFO_ADD(key_scancel);
TERMINFO_ADD(key_scommand);
TERMINFO_ADD(key_scopy);
TERMINFO_ADD(key_screate);
TERMINFO_ADD(key_sdc);
TERMINFO_ADD(key_sdl);
TERMINFO_ADD(key_select);
TERMINFO_ADD(key_send);
TERMINFO_ADD(key_seol);
TERMINFO_ADD(key_sexit);
TERMINFO_ADD(key_sf);
TERMINFO_ADD(key_sfind);
TERMINFO_ADD(key_shelp);
TERMINFO_ADD(key_shome);
TERMINFO_ADD(key_sic);
TERMINFO_ADD(key_sleft);
TERMINFO_ADD(key_smessage);
TERMINFO_ADD(key_smove);
TERMINFO_ADD(key_snext);
TERMINFO_ADD(key_soptions);
TERMINFO_ADD(key_sprevious);
TERMINFO_ADD(key_sprint);
TERMINFO_ADD(key_sr);
TERMINFO_ADD(key_sredo);
TERMINFO_ADD(key_sreplace);
TERMINFO_ADD(key_sright);
TERMINFO_ADD(key_srsume);
TERMINFO_ADD(key_ssave);
TERMINFO_ADD(key_ssuspend);
TERMINFO_ADD(key_stab);
TERMINFO_ADD(key_sundo);
TERMINFO_ADD(key_suspend);
TERMINFO_ADD(key_undo);
TERMINFO_ADD(key_up);
TERMINFO_ADD(key_f21),
TERMINFO_ADD(key_f22),
TERMINFO_ADD(key_f23),
TERMINFO_ADD(key_f24),
TERMINFO_ADD(key_f25),
TERMINFO_ADD(key_f26),
TERMINFO_ADD(key_f27),
TERMINFO_ADD(key_f28),
TERMINFO_ADD(key_f29),
TERMINFO_ADD(key_f30),
TERMINFO_ADD(key_f31),
TERMINFO_ADD(key_f32),
TERMINFO_ADD(key_f33),
TERMINFO_ADD(key_f34),
TERMINFO_ADD(key_f35),
TERMINFO_ADD(key_f36),
TERMINFO_ADD(key_f37),
TERMINFO_ADD(key_f38),
TERMINFO_ADD(key_f39),
TERMINFO_ADD(key_f40),
TERMINFO_ADD(key_f41),
TERMINFO_ADD(key_f42),
TERMINFO_ADD(key_f43),
TERMINFO_ADD(key_f44),
TERMINFO_ADD(key_f45),
TERMINFO_ADD(key_f46),
TERMINFO_ADD(key_f47),
TERMINFO_ADD(key_f48),
TERMINFO_ADD(key_f49),
TERMINFO_ADD(key_f50),
TERMINFO_ADD(key_f51),
TERMINFO_ADD(key_f52),
TERMINFO_ADD(key_f53),
TERMINFO_ADD(key_f54),
TERMINFO_ADD(key_f55),
TERMINFO_ADD(key_f56),
TERMINFO_ADD(key_f57),
TERMINFO_ADD(key_f58),
TERMINFO_ADD(key_f59),
TERMINFO_ADD(key_f60),
TERMINFO_ADD(key_f61),
TERMINFO_ADD(key_f62),
TERMINFO_ADD(key_f63),*/
TERMINFO_ADD(key_find),
TERMINFO_ADD(key_help),
TERMINFO_ADD(key_home),
TERMINFO_ADD(key_ic),
TERMINFO_ADD(key_il),
TERMINFO_ADD(key_left),
TERMINFO_ADD(key_ll),
TERMINFO_ADD(key_mark),
TERMINFO_ADD(key_message),
TERMINFO_ADD(key_move),
TERMINFO_ADD(key_next),
TERMINFO_ADD(key_npage),
TERMINFO_ADD(key_open),
TERMINFO_ADD(key_options),
TERMINFO_ADD(key_ppage),
TERMINFO_ADD(key_previous),
TERMINFO_ADD(key_print),
TERMINFO_ADD(key_redo),
TERMINFO_ADD(key_reference),
TERMINFO_ADD(key_refresh),
TERMINFO_ADD(key_replace),
TERMINFO_ADD(key_restart),
TERMINFO_ADD(key_resume),
TERMINFO_ADD(key_right),
TERMINFO_ADD(key_save),
TERMINFO_ADD(key_sbeg),
TERMINFO_ADD(key_scancel),
TERMINFO_ADD(key_scommand),
TERMINFO_ADD(key_scopy),
TERMINFO_ADD(key_screate),
TERMINFO_ADD(key_sdc),
TERMINFO_ADD(key_sdl),
TERMINFO_ADD(key_select),
TERMINFO_ADD(key_send),
TERMINFO_ADD(key_seol),
TERMINFO_ADD(key_sexit),
TERMINFO_ADD(key_sf),
TERMINFO_ADD(key_sfind),
TERMINFO_ADD(key_shelp),
TERMINFO_ADD(key_shome),
TERMINFO_ADD(key_sic),
TERMINFO_ADD(key_sleft),
TERMINFO_ADD(key_smessage),
TERMINFO_ADD(key_smove),
TERMINFO_ADD(key_snext),
TERMINFO_ADD(key_soptions),
TERMINFO_ADD(key_sprevious),
TERMINFO_ADD(key_sprint),
TERMINFO_ADD(key_sr),
TERMINFO_ADD(key_sredo),
TERMINFO_ADD(key_sreplace),
TERMINFO_ADD(key_sright),
TERMINFO_ADD(key_srsume),
TERMINFO_ADD(key_ssave),
TERMINFO_ADD(key_ssuspend),
TERMINFO_ADD(key_stab),
TERMINFO_ADD(key_sundo),
TERMINFO_ADD(key_suspend),
TERMINFO_ADD(key_undo),
TERMINFO_ADD(key_up)
};
const size_t count = sizeof tinfos / sizeof *tinfos;
terminfo_mappings.reserve(terminfo_mappings.size() + count);
terminfo_mappings.insert(terminfo_mappings.end(), tinfos, tinfos + count);
}
const wchar_t *input_terminfo_get_sequence( const wchar_t *name )

View file

@ -11,7 +11,6 @@
#include <wchar.h>
#include <unistd.h>
#include <set>
#include <deque>
#include <algorithm>
#include "fallback.h"
@ -29,14 +28,14 @@ class string_table_compare_t {
}
};
/* A sorted deque ends up being a little more memory efficient than a std::set for the intern'd string table */
/* A sorted vector ends up being a little more memory efficient than a std::set for the intern'd string table */
#define USE_SET 0
#if USE_SET
/** The table of intern'd strings */
typedef std::set<const wchar_t *, string_table_compare_t> string_table_t;
#else
/** The table of intern'd strings */
typedef std::deque<const wchar_t *> string_table_t;
typedef std::vector<const wchar_t *> string_table_t;
#endif
static string_table_t string_table;

View file

@ -72,7 +72,6 @@ Some of the code in this file is based on code from the Glibc manual.
#include "signal.h"
#include "event.h"
#include <deque>
#include "output.h"
/**
@ -153,7 +152,7 @@ static event_t event(0);
/**
A stack containing the values of is_interactive. Used by proc_push_interactive and proc_pop_interactive.
*/
static std::deque<int> interactive_stack;
static std::vector<int> interactive_stack;
void proc_init()
{

View file

@ -306,6 +306,25 @@ class reader_data_t
/** Whether the a screen reset is needed after a repaint. */
bool screen_reset_needed;
/** Constructor */
reader_data_t() :
suppress_autosuggestion(0),
history(0),
token_history_pos(0),
search_pos(0),
buff_pos(0),
complete_func(0),
highlight_function(0),
test_func(0),
end_loop(0),
prev_end_loop(0),
next(0),
search_mode(0),
repaint_needed(0),
screen_reset_needed(0)
{
}
};
/**
@ -530,8 +549,8 @@ void reader_data_t::command_line_changed() {
/** Remove any duplicate completions in the list. This relies on the list first beeing sorted. */
static void remove_duplicates(std::vector<completion_t> &l) {
static void remove_duplicates(std::vector<completion_t> &l)
{
l.erase(std::unique( l.begin(), l.end()), l.end());
}
@ -2100,9 +2119,7 @@ static int default_test( const wchar_t *b )
void reader_push( const wchar_t *name )
{
// use something nasty which guarantees value initialization (that is, all fields zero)
const reader_data_t zerod = {};
reader_data_t *n = new reader_data_t(zerod);
reader_data_t *n = new reader_data_t();
n->history = & history_t::history_with_name(name);
n->app_name = name;

View file

@ -142,13 +142,10 @@ int wildcard_has( const wchar_t *str, int internal )
\param wc The wildcard.
\param is_first Whether files beginning with dots should not be matched against wildcards.
*/
static int wildcard_match2( const wcstring &str_str,
const wcstring &wc_str,
static int wildcard_match2( const wchar_t *str,
const wchar_t *wc,
int is_first )
{
const wchar_t *str = str_str.c_str();
const wchar_t *wc = wc_str.c_str();
if( *str == 0 && *wc==0 )
return 1;
@ -254,7 +251,7 @@ static bool wildcard_complete_internal(const wcstring &orig,
if (! out_completion.empty())
{
completion_allocate( out,
append_completion( out,
out_completion,
out_desc,
flags );
@ -312,7 +309,7 @@ bool wildcard_complete(const wcstring &str,
int wildcard_match( const wcstring &str, const wcstring &wc )
{
return wildcard_match2( str, wc, 1 );
return wildcard_match2( str.c_str(), wc.c_str(), 1 );
}
/**
@ -424,7 +421,7 @@ static wcstring complete_get_desc_suffix( const wchar_t *suff_orig )
\param err The errno value after a failed stat call on the file.
*/
static wcstring file_get_desc( const wchar_t *filename,
static wcstring file_get_desc( const wcstring &filename,
int lstat_res,
struct stat lbuf,
int stat_res,
@ -433,8 +430,6 @@ static wcstring file_get_desc( const wchar_t *filename,
{
const wchar_t *suffix;
CHECK( filename, 0 );
if( !lstat_res )
{
if( S_ISLNK(lbuf.st_mode))
@ -535,7 +530,7 @@ static wcstring file_get_desc( const wchar_t *filename,
}
}
suffix = wcsrchr( filename, L'.' );
suffix = wcsrchr( filename.c_str(), L'.' );
if( suffix != 0 && !wcsrchr( suffix, L'/' ) )
{
return complete_get_desc_suffix( suffix );