Alexandre Julliard : makedep: Add a helper function to check if a string exists in an array.
Module: wine Branch: master Commit: 299ce6f9f04224f72161ff7d6698de129eacb919 URL: http://source.winehq.org/git/wine.git/?a=commit;h=299ce6f9f04224f72161ff7d66... Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Apr 10 13:15:13 2014 +0200 makedep: Add a helper function to check if a string exists in an array. --- tools/makedep.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/makedep.c b/tools/makedep.c index a83320f..63b4de9 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -343,14 +343,23 @@ static void strarray_addall( struct strarray *array, struct strarray added ) /******************************************************************* - * strarray_add_uniq + * strarray_exists */ -static void strarray_add_uniq( struct strarray *array, const char *str ) +static int strarray_exists( struct strarray *array, const char *str ) { unsigned int i; - for (i = 0; i < array->count; i++) if (!strcmp( array->str[i], str )) return; - strarray_add( array, str ); + for (i = 0; i < array->count; i++) if (!strcmp( array->str[i], str )) return 1; + return 0; +} + + +/******************************************************************* + * strarray_add_uniq + */ +static void strarray_add_uniq( struct strarray *array, const char *str ) +{ + if (!strarray_exists( array, str )) strarray_add( array, str ); } @@ -2417,16 +2426,12 @@ static void update_makefile( const char *path ) if (make->module && strendswith( make->module, ".a" )) make->staticlib = make->module; - make->use_msvcrt = 0; - for (i = 0; i < make->appmode.count && !make->use_msvcrt; i++) - make->use_msvcrt = !strcmp( make->appmode.str[i], "-mno-cygwin" ); + make->is_win16 = strarray_exists( &make->extradllflags, "-m16" ); + make->use_msvcrt = strarray_exists( &make->appmode, "-mno-cygwin" ); + for (i = 0; i < make->imports.count && !make->use_msvcrt; i++) make->use_msvcrt = !strncmp( make->imports.str[i], "msvcr", 5 ); - make->is_win16 = 0; - for (i = 0; i < make->extradllflags.count && !make->is_win16; i++) - if (!strcmp( make->extradllflags.str[i], "-m16" )) make->is_win16 = 1; - make->include_args = empty_strarray; make->define_args = empty_strarray; strarray_add( &make->define_args, "-D__WINESRC__" );
participants (1)
-
Alexandre Julliard