Only in diffutils-2.8.7-include/lib: RCS Only in diffutils-2.8.7-include/src: .diff.c.swp Only in diffutils-2.8.7-include/src: RCS diff -r -u --include='*.[ch]' diffutils-2.8.7/src/diff.c diffutils-2.8.7-include/src/diff.c --- diffutils-2.8.7/src/diff.c 2004-04-12 03:44:35.000000000 -0400 +++ diffutils-2.8.7-include/src/diff.c 2006-10-26 02:26:25.379608883 -0400 @@ -95,6 +95,47 @@ Normally nothing is output when that happens. */ static bool report_identical_files; +/* deal with when we match include patterns + */ +static char const **include_patterns; +static int include_count = 0; /* number of patterns */ + + +/* return 0 if a good file, 1 if it is no good */ +static int +included_filename(const char *f) +{ + int i; + const char *p; + + + if(include_count == 0) + return 1; /* match anything */ + + p = rindex(f, '/'); + if(p) + p++; + else p = f; + + for(i = 0; i < include_count; i++) { + if(fnmatch(include_patterns[i], p, 0) == 0) + return 1; + } + return 0; /* no match */ + +} + +static void +add_include(const char *pattern) +{ + char *p; + include_patterns = xrealloc(include_patterns, (include_count + 1) * sizeof(char *)); + p = strdup(pattern); + include_patterns[include_count] = p; + include_count++; +} + + /* Return a string containing the command options with which diff was invoked. Spaces appear between what were separate ARGV-elements. @@ -157,6 +198,7 @@ SUPPRESS_COMMON_LINES_OPTION, TABSIZE_OPTION, TO_FILE_OPTION, + INCLUDE_PATTERN, /* These options must be in sequence. */ UNCHANGED_LINE_FORMAT_OPTION, @@ -194,6 +236,7 @@ {"ed", 0, 0, 'e'}, {"exclude", 1, 0, 'x'}, {"exclude-from", 1, 0, 'X'}, + {"include", 1, 0, INCLUDE_PATTERN }, {"expand-tabs", 0, 0, 't'}, {"forward-ed", 0, 0, 'f'}, {"from-file", 1, 0, FROM_FILE_OPTION}, @@ -481,6 +524,10 @@ case 'x': add_exclude (excluded, optarg, exclude_options ()); break; + + case INCLUDE_PATTERN: + add_include ( optarg ); + break; case 'X': if (add_exclude_file (add_exclude, excluded, optarg, @@ -917,6 +964,7 @@ N_("-s --report-identical-files Report when two files are the same."), N_("-x PAT --exclude=PAT Exclude files that match PAT."), N_("-X FILE --exclude-from=FILE Exclude files that match any pattern in FILE."), + N_(" --include=PAT Include files that match PAT."), N_("-S FILE --starting-file=FILE Start with FILE when comparing directories."), N_("--from-file=FILE1 Compare FILE1 to all operands. FILE1 can be a directory."), N_("--to-file=FILE2 Compare all operands to FILE2. FILE2 can be a directory."), @@ -1281,6 +1329,20 @@ /* Open the files and record their descriptors. */ + if(recursive && include_count > 0) { + /* file[0] and file[1] must be the same file names -- see if we want to exclude them */ + + /* if we don't want to include them, don't even both comparing them */ + if(included_filename(cmp.file[0].name) == 0) { + status = EXIT_SUCCESS; +#if 0 + printf("ignoring %s\n", cmp.file[0].name); +#endif + goto ignore_files; /* bail out */ + } + } + + if (cmp.file[0].desc == UNOPENED) if ((cmp.file[0].desc = open (cmp.file[0].name, O_RDONLY, 0)) < 0) { @@ -1344,6 +1406,7 @@ pfatal_with_name (_("standard output")); } +ignore_files: if (free0) free (free0); if (free1) Only in diffutils-2.8.7-include/src: diff.c.patch