diff --git a/common.cpp b/common.cpp index 90f965dab..388f68cc9 100644 --- a/common.cpp +++ b/common.cpp @@ -1866,7 +1866,7 @@ void bugreport() void sb_format_size( string_buffer_t *sb, long long sz ) { - wchar_t *sz_name[]= + const wchar_t *sz_name[]= { L"kB", L"MB", L"GB", L"TB", L"PB", L"EB", L"ZB", L"YB", 0 } diff --git a/exec.cpp b/exec.cpp index 6a8e463e0..f82e66e3a 100644 --- a/exec.cpp +++ b/exec.cpp @@ -543,8 +543,9 @@ static void launch_process( process_t *p ) count++; res = (wchar_t **)malloc( sizeof(wchar_t*)*(count+2)); - - res[0] = L"/bin/sh"; + wchar_t sh_command[] = L"/bin/sh"; + + res[0] = sh_command; res[1] = p->actual_cmd; for( i=1; p->argv[i]; i++ ){ @@ -553,7 +554,7 @@ static void launch_process( process_t *p ) res[i+1] = 0; p->argv = res; - p->actual_cmd = L"/bin/sh"; + p->actual_cmd = sh_command; res_real = wcsv2strv( (const wchar_t **) res); diff --git a/fish.cpp b/fish.cpp index b7daa8a89..118652559 100644 --- a/fish.cpp +++ b/fish.cpp @@ -110,7 +110,7 @@ static int read_init() Parse the argument list, return the index of the first non-switch arguments. */ -static int fish_parse_opt( int argc, char **argv, char **cmd_ptr ) +static int fish_parse_opt( int argc, char **argv, const char **cmd_ptr ) { int my_optind; int force_interactive=0; @@ -280,7 +280,7 @@ int main( int argc, char **argv ) { struct stat tmp; int res=1; - char *cmd=0; + const char *cmd=0; int my_optind=0; halloc_util_init(); diff --git a/highlight.cpp b/highlight.cpp index 002dbc704..c9f0d7ef2 100644 --- a/highlight.cpp +++ b/highlight.cpp @@ -1039,7 +1039,7 @@ static void highlight_universal_internal( const wchar_t * buff, int pos ) { - if( (pos >= 0) && (pos < wcslen(buff)) ) + if( (pos >= 0) && ((size_t)pos < wcslen(buff)) ) { /* diff --git a/highlight.h b/highlight.h index 7f2bff6d7..f7ec88770 100644 --- a/highlight.h +++ b/highlight.h @@ -73,7 +73,7 @@ \param pos the cursor position. Used for quote matching, etc. \param error a list in which a description of each error will be inserted. May be 0, in whcich case no error descriptions will be generated. */ -void highlight_shell( const wchar_t *, int *, int, array_list_t *, const env_vars &vars ); +void highlight_shell( const wchar_t *buff, int *color, int pos, array_list_t *error, const env_vars &vars ); /** Perform syntax highlighting for the text in buff. Matching quotes and paranthesis are highlighted. The result is @@ -85,7 +85,7 @@ void highlight_shell( const wchar_t *, int *, int, array_list_t *, const env_var \param pos the cursor position. Used for quote matching, etc. \param error a list in which a description of each error will be inserted. May be 0, in whcich case no error descriptions will be generated. */ -void highlight_universal( const wchar_t *, int *, int, array_list_t *, const env_vars &vars ); +void highlight_universal( const wchar_t *buff, int *color, int pos, array_list_t *error, const env_vars &vars ); /** Translate from HIGHLIGHT_* to FISH_COLOR_* according to environment diff --git a/mimedb.cpp b/mimedb.cpp index d0187b284..3adc70e2e 100644 --- a/mimedb.cpp +++ b/mimedb.cpp @@ -295,7 +295,7 @@ static char *file_exists( const char *dir, const char *in ) \param all If zero, then stop after the first filename. \return The number of filenames added to the list. */ -static int append_filenames( array_list_t *list, char *f, int all ) +static int append_filenames( array_list_t *list, const char *f, int all ) { int prev_count = al_get_count( list ); char *result; diff --git a/output.cpp b/output.cpp index 0d2490abb..b46cd2b1a 100644 --- a/output.cpp +++ b/output.cpp @@ -382,7 +382,7 @@ int writembs_internal( char *str ) int writech( wint_t ch ) { mbstate_t state; - int i; + size_t i; char buff[MB_LEN_MAX+1]; size_t bytes; @@ -548,20 +548,20 @@ int write_escaped_str( const wchar_t *str, int max_len ) int output_color_code( const wchar_t *val ) { - int j, i, color=FISH_COLOR_NORMAL; - array_list_t el; + size_t i; + int color=FISH_COLOR_NORMAL; int is_bold=0; int is_underline=0; if( !val ) return FISH_COLOR_NORMAL; - al_init( &el ); - tokenize_variable_array( val, &el ); + wcstring_list_t el; + tokenize_variable_array2( val, el ); - for( j=0; j=3; is_bold |= wcscmp( next, L"-o" ) == 0; @@ -580,9 +580,6 @@ int output_color_code( const wchar_t *val ) } - al_foreach( &el, &free ); - al_destroy( &el ); - return color | (is_bold?FISH_COLOR_BOLD:0) | (is_underline?FISH_COLOR_UNDERLINE:0); } diff --git a/proc.h b/proc.h index e9c87da89..46fb3ea74 100644 --- a/proc.h +++ b/proc.h @@ -240,7 +240,7 @@ typedef struct job job. It is used for displaying messages about job status on the terminal. */ - wchar_t *command; + const wchar_t *command; /** A linked list of all the processes in this job. diff --git a/set_color.cpp b/set_color.cpp index 8def213e8..61c6312f5 100644 --- a/set_color.cpp +++ b/set_color.cpp @@ -63,7 +63,7 @@ #define _(string) (string) #endif -char *col[]= +const char *col[]= { "black", "red", @@ -79,7 +79,7 @@ char *col[]= } ; -int col_idx[]= +const int col_idx[]= { 0, 1, @@ -108,7 +108,7 @@ int translate_color( char *str ) if( *endptr || color<0 || errno ) { - int i; + size_t i; color = -1; for( i=0; i= 0) && (pos < l->pos) ) + if( (pos >= 0) && ((size_t)pos < l->pos) ) res = l->arr[pos]; return res; diff --git a/xdgmimemagic.cpp b/xdgmimemagic.cpp index 3d2602edf..d6ee9424b 100644 --- a/xdgmimemagic.cpp +++ b/xdgmimemagic.cpp @@ -315,7 +315,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file, int c; int end_of_file; int indent = 0; - int bytes_read; + size_t bytes_read; assert (magic_file != NULL); @@ -460,7 +460,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file, _xdg_mime_magic_matchlet_free (matchlet); return XDG_MIME_MAGIC_EOF; } - if (matchlet->range_length == -1) + if (matchlet->range_length == (unsigned int)-1) { _xdg_mime_magic_matchlet_free (matchlet); return XDG_MIME_MAGIC_ERROR; @@ -474,7 +474,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file, /* We clean up the matchlet, byte swapping if needed */ if (matchlet->word_size > 1) { - int i; + size_t i; if (matchlet->value_length % matchlet->word_size != 0) { _xdg_mime_magic_matchlet_free (matchlet); @@ -519,7 +519,7 @@ _xdg_mime_magic_matchlet_compare_to_data (XdgMimeMagicMatchlet *matchlet, const void *data, size_t len) { - int i, j; + size_t i, j; for (i = matchlet->offset; i <= matchlet->offset + matchlet->range_length; i++) {