*** grep-2.4.2/src/grep.c Wed Feb 2 08:49:07 2000 --- grep-2.4.2.my/src/grep.c Tue Mar 27 02:51:40 2001 *************** *** 61,65 **** /* Short options. */ static char const short_options[] = ! "0123456789A:B:C::EFGHIUVX:abcd:e:f:hiLlnqrsuvwxyZz"; /* Non-boolean long options that have no corresponding short equivalents. */ --- 61,65 ---- /* Short options. */ static char const short_options[] = ! "0123456789A:B:C::DEFGHIUVX:abcd:e:f:hiLlnqrsuvwxyZz"; /* Non-boolean long options that have no corresponding short equivalents. */ *************** *** 82,85 **** --- 82,86 ---- {"extended-regexp", no_argument, NULL, 'E'}, {"file", required_argument, NULL, 'f'}, + {"filename-once", no_argument, NULL, 'D' }, {"files-with-matches", no_argument, NULL, 'l'}, {"files-without-match", no_argument, NULL, 'L'}, *************** *** 486,489 **** --- 487,491 ---- static int no_filenames; /* Suppress file names. */ static int suppress_errors; /* Suppress diagnostics. */ + static int filename_once; /* Show filename once after "--" */ /* Internal variables to keep track of byte count, context, etc. */ *************** *** 597,603 **** while (p > bp && p[-1] != eol); /* We only print the "--" separator if our output is discontiguous from the last output in the file. */ ! if ((out_before || out_after) && used && p != lastout) puts ("--"); --- 599,609 ---- while (p > bp && p[-1] != eol); + /* We only print the "-- filename:" if our output is + discontiguous from the last output in the file :-) */ + if((out_before || out_after) && p != lastout && filename_once) + printf ("-- %s:\n", filename); /* We only print the "--" separator if our output is discontiguous from the last output in the file. */ ! else if ((out_before || out_after) && used && p != lastout) puts ("--"); *************** *** 992,995 **** --- 998,1002 ---- -C, --context[=NUM] print NUM (default 2) lines of output context\n\ unless overridden by -A or -B\n\ + -D, --filename-once print \"-- filename:\" instead of \"--\" -NUM same as --context=NUM\n\ -U, --binary do not strip CR characters at EOL (MSDOS)\n\ *************** *** 1221,1224 **** --- 1228,1236 ---- else default_context = 2; + break; + case 'D': + /* Using with -A, -B or -C print "-- filename:" intead of "--" */ + filename_once = 1; + no_filenames = 1; break; case 'E':