[Eolfix-cvs] eolfix eolfix.c,1.1.1.1,1.2
Brought to you by:
rossta
|
From: Ross S. <ro...@us...> - 2006-01-04 11:44:20
|
Update of /cvsroot/eolfix/eolfix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12538 Modified Files: eolfix.c Log Message: Cleaned up ignore_case logic Index: eolfix.c =================================================================== RCS file: /cvsroot/eolfix/eolfix/eolfix.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- eolfix.c 4 Jan 2006 10:58:05 -0000 1.1.1.1 +++ eolfix.c 4 Jan 2006 11:44:09 -0000 1.2 @@ -385,7 +385,7 @@ bool recursive; char temp_dir[PATH_MAX]; int verbose; - int ignore_case; + bool ignore_case; bool std_in; bool std_out; @@ -416,8 +416,11 @@ false, /* recursive */ "", /* temp_dir */ 0, /* verbose */ - -1, /* ignore_case (-1 == undefined) */ - +#ifdef IS_CASE_INSENSITIVE_FILESYSTEM + true, /* ignore_case */ +#else + false, +#endif false, /* stdin */ false, /* stdout */ false, /* wildcard_found */ @@ -1461,7 +1464,6 @@ char *p; void *data; List *node = *head; - int (__cdecl *)(const void *, const void *) strcmp_ptr; if (dont_alloc) p = filespec; @@ -1473,16 +1475,17 @@ opt.wildcards_used = true; } -#ifdef IS_CASE_INSENSITIVE_FILESYSTEM -# define FILENAME_COMPARE stricmp -#else -# define FILENAME_COMPARE strcmp -#endif - while (node) { File *data = (File *) node->data; - - if (FILENAME_COMPARE(data->filespec, filespec) == 0) { + bool filespecs_equal; + + if (opt.ignore_case) { + filespecs_equal = stricmp(data->filespec, filespec) == 0; + } else { + filespecs_equal = strcmp(data->filespec, filespec) == 0; + } + + if (filespecs_equal) { /* free(data->filespec); */ data->filespec = p; data->include = include; @@ -1828,18 +1831,10 @@ return 1; } - switch (opt.ignore_case) { - case 0: /* false */ - fnmatch_flags &= ~FNM_CASEFOLD; - break; - case 1: /* true */ - fnmatch_flags |= FNM_CASEFOLD; - break; - default: /* undefined (-1) */ -#ifdef IS_CASE_INSENSITIVE_FILESYSTEM - fnmatch_flags |= FNM_CASEFOLD; -#endif - break; + if (opt.ignore_case) { + fnmatch_flags |= FNM_CASEFOLD; + } else { + fnmatch_flags &= ~FNM_CASEFOLD; } for (;;) { @@ -2425,7 +2420,7 @@ opt.dry_run = true; break; case 'z': /* --ignore_case */ - opt.ignore_case = 1; + opt.ignore_case = true; break; case '?': /* --help */ if (optopt != '?') { @@ -2487,7 +2482,7 @@ opt.dry_run = false; break; case 'Z': /* --no-ignore_case */ - opt.ignore_case = 0; + opt.ignore_case = false; break; #ifdef CONV_SUPPORT_ENABLED case OPT_AUTO: /* --auto */ |