mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
More const and signed correctness. Warnings now fit on one page!
This commit is contained in:
parent
9b133a978d
commit
60d1ac4fec
@ -390,7 +390,7 @@ static void daemonize()
|
|||||||
/**
|
/**
|
||||||
Get environment variable value. The resulting string needs to be free'd.
|
Get environment variable value. The resulting string needs to be free'd.
|
||||||
*/
|
*/
|
||||||
static wchar_t *fishd_env_get( wchar_t *key )
|
static wchar_t *fishd_env_get( const wchar_t *key )
|
||||||
{
|
{
|
||||||
char *nres, *nkey;
|
char *nres, *nkey;
|
||||||
wchar_t *res;
|
wchar_t *res;
|
||||||
|
2
path.cpp
2
path.cpp
@ -130,8 +130,6 @@ bool path_get_path_string(const wcstring &cmd_str, wcstring &output, const env_v
|
|||||||
|
|
||||||
wchar_t *path_get_path( void *context, const wchar_t *cmd )
|
wchar_t *path_get_path( void *context, const wchar_t *cmd )
|
||||||
{
|
{
|
||||||
const wchar_t *path;
|
|
||||||
|
|
||||||
int err = ENOENT;
|
int err = ENOENT;
|
||||||
|
|
||||||
CHECK( cmd, 0 );
|
CHECK( cmd, 0 );
|
||||||
|
@ -464,7 +464,7 @@ static void reader_kill( wchar_t *begin, int length, int mode, int newv )
|
|||||||
free( old );
|
free( old );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( data->buff_pos > (begin-data->buff) )
|
if( data->buff_pos > (size_t)(begin-data->buff) )
|
||||||
{
|
{
|
||||||
data->buff_pos = maxi( begin-data->buff, data->buff_pos-length );
|
data->buff_pos = maxi( begin-data->buff, data->buff_pos-length );
|
||||||
}
|
}
|
||||||
@ -1292,9 +1292,7 @@ static void reader_flash()
|
|||||||
{
|
{
|
||||||
struct timespec pollint;
|
struct timespec pollint;
|
||||||
|
|
||||||
int i;
|
for( size_t i=0; i<data->buff_pos; i++ )
|
||||||
|
|
||||||
for( i=0; i<data->buff_pos; i++ )
|
|
||||||
{
|
{
|
||||||
data->color[i] = HIGHLIGHT_SEARCH_MATCH<<16;
|
data->color[i] = HIGHLIGHT_SEARCH_MATCH<<16;
|
||||||
}
|
}
|
||||||
@ -1976,7 +1974,7 @@ static void handle_token_history( int forward, int reset )
|
|||||||
*/
|
*/
|
||||||
static void move_word( int dir, int erase, int newv )
|
static void move_word( int dir, int erase, int newv )
|
||||||
{
|
{
|
||||||
int end_buff_pos=data->buff_pos;
|
size_t end_buff_pos=data->buff_pos;
|
||||||
int step = dir?1:-1;
|
int step = dir?1:-1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
22
screen.cpp
22
screen.cpp
@ -109,7 +109,7 @@ static int next_tab_stop( int in )
|
|||||||
static int calc_prompt_width( const wchar_t *prompt )
|
static int calc_prompt_width( const wchar_t *prompt )
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
int j, k;
|
size_t j, k;
|
||||||
|
|
||||||
for( j=0; prompt[j]; j++ )
|
for( j=0; prompt[j]; j++ )
|
||||||
{
|
{
|
||||||
@ -118,7 +118,7 @@ static int calc_prompt_width( const wchar_t *prompt )
|
|||||||
/*
|
/*
|
||||||
This is the start of an escape code. Try to guess it's width.
|
This is the start of an escape code. Try to guess it's width.
|
||||||
*/
|
*/
|
||||||
int l;
|
size_t p;
|
||||||
int len=0;
|
int len=0;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
@ -164,14 +164,14 @@ static int calc_prompt_width( const wchar_t *prompt )
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
for( l=0; l < (sizeof(esc)/sizeof(char *)) && !found; l++ )
|
for( p=0; p < (sizeof(esc)/sizeof(char *)) && !found; p++ )
|
||||||
{
|
{
|
||||||
if( !esc[l] )
|
if( !esc[p] )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for( k=0; k<8; k++ )
|
for( k=0; k<8; k++ )
|
||||||
{
|
{
|
||||||
len = try_sequence( tparm(esc[l],k), &prompt[j] );
|
len = try_sequence( tparm(esc[p],k), &prompt[j] );
|
||||||
if( len )
|
if( len )
|
||||||
{
|
{
|
||||||
j += (len-1);
|
j += (len-1);
|
||||||
@ -181,17 +181,17 @@ static int calc_prompt_width( const wchar_t *prompt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( l=0; l < (sizeof(esc2)/sizeof(char *)) && !found; l++ )
|
for( p=0; p < (sizeof(esc2)/sizeof(char *)) && !found; p++ )
|
||||||
{
|
{
|
||||||
if( !esc2[l] )
|
if( !esc2[p] )
|
||||||
continue;
|
continue;
|
||||||
/*
|
/*
|
||||||
Test both padded and unpadded version, just to
|
Test both padded and unpadded version, just to
|
||||||
be safe. Most versions of tparm don't actually
|
be safe. Most versions of tparm don't actually
|
||||||
seem to do anything these days.
|
seem to do anything these days.
|
||||||
*/
|
*/
|
||||||
len = maxi( try_sequence( tparm(esc2[l]), &prompt[j] ),
|
len = maxi( try_sequence( tparm(esc2[p]), &prompt[j] ),
|
||||||
try_sequence( esc2[l], &prompt[j] ));
|
try_sequence( esc2[p], &prompt[j] ));
|
||||||
|
|
||||||
if( len )
|
if( len )
|
||||||
{
|
{
|
||||||
@ -590,7 +590,7 @@ static void s_write_str( buffer_t *b, const wchar_t *s )
|
|||||||
*/
|
*/
|
||||||
static void s_update( screen_t *scr, const wchar_t *prompt )
|
static void s_update( screen_t *scr, const wchar_t *prompt )
|
||||||
{
|
{
|
||||||
int i, j, k;
|
size_t i, j;
|
||||||
int prompt_width = calc_prompt_width( prompt );
|
int prompt_width = calc_prompt_width( prompt );
|
||||||
int current_width=0;
|
int current_width=0;
|
||||||
int screen_width = common_get_width();
|
int screen_width = common_get_width();
|
||||||
@ -662,7 +662,7 @@ static void s_update( screen_t *scr, const wchar_t *prompt )
|
|||||||
|
|
||||||
s_line.create_entry(current_width).text = o;
|
s_line.create_entry(current_width).text = o;
|
||||||
s_line.create_entry(current_width).color = o_c;
|
s_line.create_entry(current_width).color = o_c;
|
||||||
for( k=1; k<wcwidth(o); k++ )
|
for( int k=1; k<wcwidth(o); k++ )
|
||||||
s_line.create_entry(current_width+k).text = L'\0';
|
s_line.create_entry(current_width+k).text = L'\0';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -507,7 +507,7 @@ static int my_iswspace( wchar_t c )
|
|||||||
|
|
||||||
const wchar_t *tok_get_desc( int type )
|
const wchar_t *tok_get_desc( int type )
|
||||||
{
|
{
|
||||||
if( type < 0 || type >= sizeof( tok_desc ) )
|
if( type < 0 || (size_t)type >= sizeof( tok_desc ) )
|
||||||
{
|
{
|
||||||
return _(L"Invalid token type");
|
return _(L"Invalid token type");
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ typedef struct
|
|||||||
/** Type of last token*/
|
/** Type of last token*/
|
||||||
int last_type;
|
int last_type;
|
||||||
/** Length of last token*/
|
/** Length of last token*/
|
||||||
int last_len;
|
size_t last_len;
|
||||||
/** Offset of last token*/
|
/** Offset of last token*/
|
||||||
int last_pos;
|
int last_pos;
|
||||||
/** Whether there are more tokens*/
|
/** Whether there are more tokens*/
|
||||||
|
3
util.cpp
3
util.cpp
@ -108,7 +108,6 @@ void hash_init2( hash_table_t *h,
|
|||||||
int (*compare_func)(void *key1, void *key2),
|
int (*compare_func)(void *key1, void *key2),
|
||||||
size_t capacity)
|
size_t capacity)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
size_t sz = 32;
|
size_t sz = 32;
|
||||||
while( sz < (capacity*4/3) )
|
while( sz < (capacity*4/3) )
|
||||||
sz*=2;
|
sz*=2;
|
||||||
@ -127,7 +126,7 @@ void hash_init2( hash_table_t *h,
|
|||||||
}
|
}
|
||||||
|
|
||||||
h->size = sz;
|
h->size = sz;
|
||||||
for( i=0; i< sz; i++ )
|
for( size_t i=0; i< sz; i++ )
|
||||||
h->arr[i].key = 0;
|
h->arr[i].key = 0;
|
||||||
h->count=0;
|
h->count=0;
|
||||||
h->hash_func = hash_func;
|
h->hash_func = hash_func;
|
||||||
|
@ -1087,10 +1087,10 @@ static int wildcard_expand_internal( const wchar_t *wc,
|
|||||||
*/
|
*/
|
||||||
if( whole_match )
|
if( whole_match )
|
||||||
{
|
{
|
||||||
wchar_t *new_wc = L"";
|
const wchar_t *new_wc = L"";
|
||||||
if( wc_end )
|
if( wc_end )
|
||||||
{
|
{
|
||||||
new_wc=const_cast<wchar_t*>(wc_end+1);
|
new_wc=wc_end+1;
|
||||||
/*
|
/*
|
||||||
Accept multiple '/' as a single direcotry separator
|
Accept multiple '/' as a single direcotry separator
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user