diff --git a/Makefile.in b/Makefile.in index 179d2c18b..7f57ca36f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -168,7 +168,7 @@ GENERATED_INTERN_SCRIPT_FILES := builtin_scripts.h builtin_scripts.cpp # Use a pattern rule so that Make knows to only issue one invocation # per http://www.gnu.org/software/make/manual/make.html#Pattern-Intro builtin%scripts.h builtin%scripts.cpp: internalize_scripts.py - ./internalize_scripts.py share/functions/*.fish + ./internalize_scripts.py share/functions/*.fish share/completions/*.fish # @@ -889,6 +889,7 @@ distclean: clean clean: rm -f *.o doc.h doc.tmp doc_src/*.doxygen doc_src/*.cpp doc_src/*.o doc_src/commands.hdr + rm -f $(GENERATED_INTERN_SCRIPT_FILES) rm -f tests/tmp.err tests/tmp.out tests/tmp.status tests/foo.txt rm -f $(PROGRAMS) fish_tests tokenizer_test key_reader rm -f share/config.fish etc/config.fish doc_src/index.hdr doc_src/commands.hdr diff --git a/common.cpp b/common.cpp index b0aca0fcf..a8b422728 100644 --- a/common.cpp +++ b/common.cpp @@ -1888,7 +1888,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/complete.cpp b/complete.cpp index 2dcaecd97..0784da786 100644 --- a/complete.cpp +++ b/complete.cpp @@ -612,7 +612,8 @@ static void parse_cmd_string( void *context, int complete_is_valid_option( const wchar_t *str, const wchar_t *opt, - array_list_t *errors ) + array_list_t *errors, + bool allow_autoload ) { complete_entry_t *i; complete_entry_opt_t *o; @@ -698,7 +699,7 @@ int complete_is_valid_option( const wchar_t *str, /* Make sure completions are loaded for the specified command */ - complete_load( cmd, 0 ); + if (allow_autoload) complete_load( cmd, 0 ); for( i=first_entry; i; i=i->next ) { @@ -847,8 +848,7 @@ int complete_is_valid_option( const wchar_t *str, hash_destroy( &gnu_match_hash ); halloc_free( context ); - - return (authoritative && found_match)?opt_found:1; + return (authoritative && found_match)?opt_found:1; } int complete_is_valid_argument( const wchar_t *str, diff --git a/complete.h b/complete.h index dcd5d9021..3c85253f8 100644 --- a/complete.h +++ b/complete.h @@ -229,7 +229,8 @@ void complete_print( string_buffer_t *out ); */ int complete_is_valid_option( const wchar_t *str, const wchar_t *opt, - array_list_t *errors ); + array_list_t *errors, + bool allow_autoload ); /** Tests if the specified argument is valid for the specified option diff --git a/env_universal_common.cpp b/env_universal_common.cpp index 5fa6ebe58..2672e5891 100644 --- a/env_universal_common.cpp +++ b/env_universal_common.cpp @@ -127,7 +127,7 @@ static int get_names_show_unexported; /** List of names for the UTF-8 character set. */ -static char *iconv_utf8_names[]= +static const char *iconv_utf8_names[]= { "utf-8", "UTF-8", "utf8", "UTF8", @@ -138,7 +138,7 @@ static char *iconv_utf8_names[]= /** List of wide character names, undefined byte length. */ -static char *iconv_wide_names_unknown[]= +static const char *iconv_wide_names_unknown[]= { "wchar_t", "WCHAR_T", "wchar", "WCHAR", @@ -149,7 +149,7 @@ static char *iconv_wide_names_unknown[]= /** List of wide character names, 4 bytes long. */ -static char *iconv_wide_names_4[]= +static const char *iconv_wide_names_4[]= { "wchar_t", "WCHAR_T", "wchar", "WCHAR", @@ -164,7 +164,7 @@ static char *iconv_wide_names_4[]= /** List of wide character names, 2 bytes long. */ -static char *iconv_wide_names_2[]= +static const char *iconv_wide_names_2[]= { "wchar_t", "WCHAR_T", "wchar", "WCHAR", @@ -192,7 +192,7 @@ static wchar_t *utf2wcs( const char *in ) really the character set used by wchar_t, but it is the best assumption we can make. */ - char **to_name=0; + const char **to_name=0; switch (sizeof (wchar_t)) { @@ -214,7 +214,7 @@ static wchar_t *utf2wcs( const char *in ) /* The line protocol fish uses is always utf-8. */ - char **from_name = iconv_utf8_names; + const char **from_name = iconv_utf8_names; size_t in_len = strlen( in ); size_t out_len = sizeof( wchar_t )*(in_len+2); @@ -306,7 +306,7 @@ static char *wcs2utf( const wchar_t *in ) really the character set used by wchar_t, but it is the best assumption we can make. */ - char **from_name=0; + const char **from_name=0; switch (sizeof (wchar_t)) { @@ -324,7 +324,7 @@ static char *wcs2utf( const wchar_t *in ) break; } - char **to_name = iconv_utf8_names; + const char **to_name = iconv_utf8_names; size_t in_len = wcslen( in ); size_t out_len = sizeof( char )*( (MAX_UTF8_BYTES*in_len)+1); 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/fish_pager.cpp b/fish_pager.cpp index b054b818c..4f9c8223d 100644 --- a/fish_pager.cpp +++ b/fish_pager.cpp @@ -146,7 +146,7 @@ static buffer_t *pager_buffer; The environment variables used to specify the color of different tokens. */ -static wchar_t *hightlight_var[] = +static const wchar_t *hightlight_var[] = { L"fish_pager_color_prefix", L"fish_pager_color_completion", @@ -247,7 +247,7 @@ static void recalc_width( array_list_t *l, const wchar_t *prefix ) Test if the specified character sequence has been entered on the keyboard */ -static int try_sequence( char *seq ) +static int try_sequence( const char *seq ) { int j, k; wint_t c=0; @@ -277,7 +277,7 @@ static wint_t readch() { struct mapping { - char *seq; + const char *seq; wint_t bnd; } ; diff --git a/fishd.cpp b/fishd.cpp index 3177106e1..cd38cfdf9 100644 --- a/fishd.cpp +++ b/fishd.cpp @@ -147,7 +147,7 @@ static int quit=0; static char *get_socket_filename() { char *name; - char *dir = getenv( "FISHD_SOCKET_DIR" ); + const char *dir = getenv( "FISHD_SOCKET_DIR" ); char *uname = getenv( "USER" ); if( dir == NULL ) @@ -390,7 +390,7 @@ static void daemonize() /** 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; wchar_t *res; diff --git a/highlight.cpp b/highlight.cpp index 002dbc704..a618078db 100644 --- a/highlight.cpp +++ b/highlight.cpp @@ -588,7 +588,7 @@ void tokenize( const wchar_t * const buff, int * const color, const int pos, arr } else if( accept_switches ) { - if( complete_is_valid_option( last_cmd, param, error ) ) + if( complete_is_valid_option( last_cmd, param, error, false /* no autoload */ ) ) color[ tok_get_pos( &tok ) ] = HIGHLIGHT_PARAM; else color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR; @@ -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/internalize_scripts.py b/internalize_scripts.py index 9d9770f1c..68a2f6480 100755 --- a/internalize_scripts.py +++ b/internalize_scripts.py @@ -1,5 +1,6 @@ #!/usr/bin/python + import string, sys, os.path escapes = {} @@ -11,7 +12,7 @@ escapes['\r'] = r'\r' #escapes['\t'] = r'\t' # Let's replace tabs with four spaces # so the text looks nicely indented in the C source -escapes['\t'] = r' ' +escapes['\t'] = r' ' escapes['\v'] = r'\v' # escapes['\''] = r'\'' escapes['\"'] = r'\"' @@ -19,21 +20,28 @@ escapes['\\'] = r'\\' def escape(c): if c in escapes: - return escapes[c] + return (escapes[c], False) elif c not in string.printable: - return "\\x%x" % ord(c) + return ("\\x%x" % ord(c), True) else: - return c + return (c, False) def stringize(line): newline = '"' + was_escape = False for c in line: - newline += escape(c) + # Avoid an issue where characters after a hexadecimal escape are treated as part of that escape + # by adding two quotes + if was_escape and c in string.hexdigits: + newline += '""' + chars, was_escape = escape(c) + newline += chars newline += '"' return newline class cfunc: - def __init__(self, name, lines): + def __init__(self, type, name, lines): + self.type = type self.name = name self.lines = lines @@ -45,22 +53,36 @@ class cfunc: return result def cfunc_name(self): - munged_name = string.replace(self.name, '-', '_') - return "function_%s" % munged_name + # Translate - and . to underscore + translator = string.maketrans('-.', '__') + munged_name = string.translate(self.name, translator) + return "%s_%s" % (self.type, munged_name) -funcs = [] +TYPES = ['function', 'completion'] +type_to_funcs = dict((t, []) for t in TYPES) for file in sys.argv[1:]: fd = open(file, 'r') newlines = [] for line in fd: newlines.append(stringize(line)) fd.close() + dirname = os.path.dirname(file) + + # Try to figure out the file type (completion or function) + matches = [dir in dirname for dir in TYPES] + if matches.count(True) is not 1: + print "Cannot determine the type of the file at path %s" % file + sys.exit(-1) + type = TYPES[matches.index(True)] + name = os.path.basename(file) name, ext = os.path.splitext(name) - funcs.append(cfunc(name, newlines)) + newfunc = cfunc(type, name, newlines) + type_to_funcs[type].append(newfunc) # Sort our functions by name -funcs.sort(key=cfunc.cfunc_name) +for funcs in type_to_funcs.itervalues(): + funcs.sort(key=cfunc.cfunc_name) # Output our header fd = open('builtin_scripts.h', 'w') @@ -71,22 +93,29 @@ fd.write("""struct builtin_script_t { };""") fd.write('\n') -fd.write('\n') -fd.write('extern const struct builtin_script_t internal_function_scripts[%d];\n' % len(funcs)) -fd.write('\n') + +for type in TYPES: + funcs = type_to_funcs[type] + fd.write('\n') + fd.write('extern const struct builtin_script_t internal_%s_scripts[%d];' % (type, len(funcs))) + fd.write('\n') fd.close() # Output the function definitions fd = open('builtin_scripts.cpp', 'w') fd.write('/* This file is generated by internalize_scripts.py */\n\n') fd.write('#include "builtin_scripts.h"\n\n') -for func in funcs: - fd.write(func.cdef()) - fd.write('\n') +for type in TYPES: + for func in type_to_funcs[type]: + fd.write(func.cdef()) + fd.write('\n') # Output the refs -func_refs = ["{L%s, %s}" % (stringize(func.name), func.cfunc_name()) for func in funcs] -fd.write('const struct builtin_script_t internal_function_scripts[%d] =\n' % len(funcs)) -fd.write('{\n\t') -fd.write(',\n\t'.join(func_refs)) -fd.write('\n};\n') +for type in TYPES: + funcs = type_to_funcs[type] + func_refs = ["{L%s, %s}" % (stringize(func.name), func.cfunc_name()) for func in funcs] + fd.write('const struct builtin_script_t internal_%s_scripts[%d] =\n' % (type, len(funcs))) + fd.write('{\n\t') + fd.write(',\n\t'.join(func_refs)) + fd.write('\n};\n') +fd.close() 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 8902628ac..b46cd2b1a 100644 --- a/output.cpp +++ b/output.cpp @@ -67,7 +67,7 @@ static int writeb_internal( char c ); /** Names of different colors. */ -static wchar_t *col[]= +static const wchar_t *col[]= { L"black", L"red", @@ -89,7 +89,7 @@ static wchar_t *col[]= in highlight.h. Non-ANSI terminals will display the wrong colors, since they use a different mapping. */ -static int col_idx[]= +static const int col_idx[]= { 0, 1, @@ -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/parse_util.cpp b/parse_util.cpp index 00dd75d6b..8ddf1a904 100644 --- a/parse_util.cpp +++ b/parse_util.cpp @@ -870,10 +870,12 @@ int parse_util_load( const wcstring &cmd, /* Figure out which builtin-scripts array to search (if any) */ const builtin_script_t *builtins = NULL; size_t builtin_count = 0; - if (path_var_name == L"fish_function_path") - { + if (path_var_name == L"fish_function_path") { builtins = internal_function_scripts; builtin_count = sizeof internal_function_scripts / sizeof *internal_function_scripts; + } else if (path_var_name == L"fish_complete_path") { + builtins = internal_completion_scripts; + builtin_count = sizeof internal_completion_scripts / sizeof *internal_completion_scripts; } /* diff --git a/parser.cpp b/parser.cpp index ad205bcf2..89a32e02f 100644 --- a/parser.cpp +++ b/parser.cpp @@ -1125,7 +1125,7 @@ static int printed_width( const wchar_t *str, int len ) } -wchar_t *parser_current_line() +const wchar_t *parser_current_line() { int lineno=1; diff --git a/parser.h b/parser.h index 17e22eaf7..8ae18a9bb 100644 --- a/parser.h +++ b/parser.h @@ -228,7 +228,7 @@ void error( int ec, int p, const wchar_t *str, ... ); init.fish (line 127): ls|grep pancake */ -wchar_t *parser_current_line(); +const wchar_t *parser_current_line(); /** Returns the current line number diff --git a/path.cpp b/path.cpp index ef4b212ed..53c4274dd 100644 --- a/path.cpp +++ b/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 ) { - const wchar_t *path; - int err = ENOENT; CHECK( cmd, 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/reader.cpp b/reader.cpp index 39020bb81..552dd7fe3 100644 --- a/reader.cpp +++ b/reader.cpp @@ -465,7 +465,7 @@ static void reader_kill( wchar_t *begin, int length, int mode, int newv ) 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 ); } @@ -669,7 +669,7 @@ void reader_write_title() proc_push_interactive(0); if( exec_subshell2( title, lst ) != -1 ) { - int i; + size_t i; if( lst.size() > 0 ) { writestr( L"\x1b]2;" ); @@ -795,7 +795,7 @@ static void remove_backward() static int insert_str(const wchar_t *str) { int len = wcslen( str ); - int old_len = data->buff_len; + size_t old_len = data->buff_len; assert( data->buff_pos >= 0 ); assert( data->buff_pos <= data->buff_len ); @@ -1307,9 +1307,7 @@ static void reader_flash() { struct timespec pollint; - int i; - - for( i=0; ibuff_pos; i++ ) + for( size_t i=0; ibuff_pos; i++ ) { data->color[i] = HIGHLIGHT_SEARCH_MATCH<<16; } @@ -1991,7 +1989,7 @@ static void handle_token_history( int forward, int reset ) */ 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; /* diff --git a/screen.cpp b/screen.cpp index eb8bcc827..9e785d510 100644 --- a/screen.cpp +++ b/screen.cpp @@ -109,7 +109,7 @@ static int next_tab_stop( int in ) static int calc_prompt_width( const wchar_t *prompt ) { int res = 0; - int j, k; + size_t j, k; 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. */ - int l; + size_t p; int len=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; 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 ) { 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; /* Test both padded and unpadded version, just to be safe. Most versions of tparm don't actually seem to do anything these days. */ - len = maxi( try_sequence( tparm(esc2[l]), &prompt[j] ), - try_sequence( esc2[l], &prompt[j] )); + len = maxi( try_sequence( tparm(esc2[p]), &prompt[j] ), + try_sequence( esc2[p], &prompt[j] )); 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 ) { - int i, j, k; + size_t i, j; int prompt_width = calc_prompt_width( prompt ); int current_width=0; 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).color = o_c; - for( k=1; k= sizeof( tok_desc ) ) + if( type < 0 || (size_t)type >= sizeof( tok_desc ) ) { return _(L"Invalid token type"); } diff --git a/tokenizer.h b/tokenizer.h index 3954cc481..ad683d7e5 100644 --- a/tokenizer.h +++ b/tokenizer.h @@ -74,7 +74,7 @@ typedef struct /** Type of last token*/ int last_type; /** Length of last token*/ - int last_len; + size_t last_len; /** Offset of last token*/ int last_pos; /** Whether there are more tokens*/ diff --git a/util.cpp b/util.cpp index 9ebf60270..ef0b3cd1e 100644 --- a/util.cpp +++ b/util.cpp @@ -108,7 +108,6 @@ void hash_init2( hash_table_t *h, int (*compare_func)(void *key1, void *key2), size_t capacity) { - int i; size_t sz = 32; while( sz < (capacity*4/3) ) sz*=2; @@ -127,7 +126,7 @@ void hash_init2( hash_table_t *h, } h->size = sz; - for( i=0; i< sz; i++ ) + for( size_t i=0; i< sz; i++ ) h->arr[i].key = 0; h->count=0; h->hash_func = hash_func; @@ -751,7 +750,7 @@ static anything_t al_get_generic( array_list_t *l, int pos ) anything_t res; res.ptr_val=0; - if( (pos >= 0) && (pos < l->pos) ) + if( (pos >= 0) && ((size_t)pos < l->pos) ) res = l->arr[pos]; return res; diff --git a/wildcard.cpp b/wildcard.cpp index a53e47983..a23294a2b 100644 --- a/wildcard.cpp +++ b/wildcard.cpp @@ -1092,10 +1092,10 @@ static int wildcard_expand_internal( const wchar_t *wc, */ if( whole_match ) { - wchar_t *new_wc = L""; + const wchar_t *new_wc = L""; if( wc_end ) { - new_wc=const_cast(wc_end+1); + new_wc=wc_end+1; /* Accept multiple '/' as a single direcotry separator */ 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++) {