From: Herman Semenov GermanAizek@yandex.ru
--- tools/sfnt2fon/sfnt2fon.c | 5 +++-- tools/widl/typegen.c | 6 +++++- tools/widl/typetree.c | 3 ++- tools/winebuild/import.c | 10 ++++++---- tools/winedump/search.c | 7 ++++--- tools/winegcc/winegcc.c | 9 ++++++--- 6 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/tools/sfnt2fon/sfnt2fon.c b/tools/sfnt2fon/sfnt2fon.c index bf31124aa25..4b13806a706 100644 --- a/tools/sfnt2fon/sfnt2fon.c +++ b/tools/sfnt2fon/sfnt2fon.c @@ -887,8 +887,9 @@ int main(int argc, char **argv) name, info[i]->hdr.fi.dfPoints ); strcpy(resident_name, name); } else { - snprintf(non_resident_name + strlen(non_resident_name), - sizeof(non_resident_name) - strlen(non_resident_name), + size_t len_n_res_name = strlen(non_resident_name); + snprintf(non_resident_name + len_n_res_name, + sizeof(non_resident_name) - len_n_res_name, ",%d", info[i]->hdr.fi.dfPoints ); } } diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index c29bbba1c1c..c0c247486fe 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -1270,7 +1270,11 @@ static unsigned int write_new_procformatstring_type(FILE *file, int indent, cons if (flags & IsBasetype) strcat( buffer, " base type," ); if (flags & IsByValue) strcat( buffer, " by value," ); if (flags & IsSimpleRef) strcat( buffer, " simple ref," ); - if (flags >> 13) snprintf( buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), " srv size=%u,", (flags >> 13) * 8 ); + if (flags >> 13) + { + size_t len_buf = strlen(buffer); + snprintf( buffer + len_buf, sizeof(buffer) - len_buf, " srv size=%u,", (flags >> 13) * 8 ); + } strcpy( buffer + strlen( buffer ) - 1, " */" ); print_file( file, indent, "NdrFcShort(0x%hx),\t%s\n", flags, buffer ); print_file( file, indent, "NdrFcShort(0x%x), /* stack offset = %u */\n", diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index af41906c42b..719d0afbe52 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -327,10 +327,11 @@ static char *format_parameterized_type_c_name(type_t *type, typeref_list_t *para else pos += append_namespaces(&buf, &len, pos, type->namespace, "_", "__C", type->name, NULL); }
+ size_t len_ns_prefix = strlen(ns_prefix); for (i = 0; i < ARRAY_SIZE(parameterized_type_shorthands); ++i) { if ((tmp = strstr(buf, parameterized_type_shorthands[i][0])) && - (tmp - buf) == strlen(ns_prefix) + (abi_prefix ? 5 : 0)) + (tmp - buf) == len_ns_prefix + (abi_prefix ? 5 : 0)) { tmp += strlen(parameterized_type_shorthands[i][0]); strcpy(buf, parameterized_type_shorthands[i][1]); diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 6aee0fa98f8..77349142c12 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -569,6 +569,8 @@ void read_undef_symbols( DLLSPEC *spec, struct strarray files ) if (!(f = popen( cmd, "r" ))) fatal_error( "Cannot execute '%s'\n", cmd );
+ size_t len_import_ord = strlen( import_ord_prefix ); + size_t len_import_func = strlen( import_func_prefix ); while (fgets( buffer, sizeof(buffer), f )) { char *p = buffer + strlen(buffer) - 1; @@ -578,10 +580,10 @@ void read_undef_symbols( DLLSPEC *spec, struct strarray files ) while (*p == ' ') p++; if (p[0] == 'U' && p[1] == ' ' && p[2]) p += 2; if (prefix_len && !strncmp( p, name_prefix, prefix_len )) p += prefix_len; - if (!strncmp( p, import_func_prefix, strlen(import_func_prefix) )) - add_undef_import( p + strlen( import_func_prefix ), 0 ); - else if (!strncmp( p, import_ord_prefix, strlen(import_ord_prefix) )) - add_undef_import( p + strlen( import_ord_prefix ), 1 ); + if (!strncmp( p, import_func_prefix, len_import_func )) + add_undef_import( p + len_import_func, 0 ); + else if (!strncmp( p, import_ord_prefix, len_import_ord )) + add_undef_import( p + len_import_ord, 1 ); else if (use_msvcrt || !find_name( p, stdc_functions )) strarray_add( &undef_symbols, xstrdup( p )); } diff --git a/tools/winedump/search.c b/tools/winedump/search.c index 632d5de7aae..cc09ad104f1 100644 --- a/tools/winedump/search.c +++ b/tools/winedump/search.c @@ -119,11 +119,12 @@ BOOL symbol_search (parsed_symbol *sym) if (VERBOSE) puts (grep_buff);
+ size_t len_sym = strlen (sym->symbol); while ((iter = strstr (iter, sym->symbol))) { if (iter > grep_buff && (iter[-1] == ' ' || iter[-1] == '*') && - (iter[strlen (sym->symbol)] == ' ' || - iter[strlen (sym->symbol)] == '(')) + (iter[len_sym] == ' ' || + iter[len_sym] == '(')) { if (VERBOSE) printf ("Prototype '%s' looks OK, processing\n", grep_buff); @@ -138,7 +139,7 @@ BOOL symbol_search (parsed_symbol *sym) puts ("Failed, trying next"); } else - iter += strlen (sym->symbol); + iter += len_sym; } } pclose (f_grep); diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 5b60c57daf7..bfcc00a1d2c 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -541,6 +541,8 @@ static char *get_lib_dir( struct options *opts ) build_len = strlen( build_multiarch ); target_len = strlen( target_multiarch );
+ size_t len_path = strlen("/arm-linux-gnueabi"); + size_t len_winecrt = strlen(winecrt0); for (i = 0; i < ARRAY_SIZE(stdlibpath); i++) { const char *root = (i && opts->sysroot) ? opts->sysroot : ""; @@ -548,7 +550,7 @@ static char *get_lib_dir( struct options *opts )
if (!stdlibpath[i]) continue; buffer = xmalloc( strlen(root) + strlen(stdlibpath[i]) + - strlen("/arm-linux-gnueabi") + strlen(winecrt0) + 1 ); + len_path + len_winecrt + 1 ); strcpy( buffer, root ); strcat( buffer, stdlibpath[i] ); p = buffer + strlen(buffer); @@ -1473,9 +1475,10 @@ static int is_option( struct options *opts, int i, const char *option, const cha *option_arg = opts->args.str[i + 1]; return 1; } - if (!strncmp( opts->args.str[i], option, strlen(option) ) && opts->args.str[i][strlen(option)] == '=') + size_t len_opt = strlen(option); + if (!strncmp( opts->args.str[i], option, len_opt ) && opts->args.str[i][len_opt] == '=') { - *option_arg = opts->args.str[i] + strlen(option) + 1; + *option_arg = opts->args.str[i] + len_opt + 1; return 1; } return 0;