summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-11-16 17:51:37 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-11-16 17:51:37 +0000
commit5074457046234fb2ab52c28c5f811fabead33b45 (patch)
treefeb760f98d87fa398b273f78b03c718b0ce9c206
parent2f9b835c16d58d3b5aaa05b177d884335dddaee1 (diff)
downloadpcre-5074457046234fb2ab52c28c5f811fabead33b45.tar.gz
Rename --{in,ex}clude_dir with hyphen instead of underscore in pcregrep, but
leave the old versions as undocumented synonyms. (In GNU grep, hyphens are used.) git-svn-id: svn://vcs.exim.org/pcre/code/trunk@571 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog7
-rwxr-xr-xRunGrepTest2
-rw-r--r--doc/pcregrep.152
-rw-r--r--pcregrep.c24
4 files changed, 64 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 29f0dba..e0938ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -95,6 +95,13 @@ Version 8.11 10-Oct-2010
16. Added PCRE_ERROR_SHORTUTF8 to make it possible to distinguish between a
bad UTF-8 sequence and one that is incomplete.
+
+17. Nobody had reported that the --include_dir option, which was added in
+ release 7.7 should have been called --include-dir (hyphen, not underscore)
+ for compatibility with GNU grep. I have changed it to --include-dir, but
+ left --include_dir as an undocumented synonym, and the same for
+ --exclude-dir, though that is not available in GNU grep, at least as of
+ release 2.5.4.
Version 8.10 25-Jun-2010
diff --git a/RunGrepTest b/RunGrepTest
index 7ba0141..0b310af 100755
--- a/RunGrepTest
+++ b/RunGrepTest
@@ -187,7 +187,7 @@ echo "---------------------------- Test 34 -----------------------------" >>test
echo "RC=$?" >>testtry
echo "---------------------------- Test 35 -----------------------------" >>testtry
-(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --exclude_dir='^\.' 'fox' ./testdata) >>testtry
+(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinputx --exclude-dir='^\.' 'fox' ./testdata) >>testtry
echo "RC=$?" >>testtry
echo "---------------------------- Test 36 -----------------------------" >>testtry
diff --git a/doc/pcregrep.1 b/doc/pcregrep.1
index c08ddff..ad6e992 100644
--- a/doc/pcregrep.1
+++ b/doc/pcregrep.1
@@ -182,19 +182,19 @@ that matched.
When \fBpcregrep\fP is searching the files in a directory as a consequence of
the \fB-r\fP (recursive search) option, any regular files whose names match the
pattern are excluded. Subdirectories are not excluded by this option; they are
-searched recursively, subject to the \fB--exclude_dir\fP and
+searched recursively, subject to the \fB--exclude-dir\fP and
\fB--include_dir\fP options. The pattern is a PCRE regular expression, and is
matched against the final component of the file name (not the entire path). If
a file name matches both \fB--include\fP and \fB--exclude\fP, it is excluded.
There is no short form for this option.
.TP
-\fB--exclude_dir\fP=\fIpattern\fP
+\fB--exclude-dir\fP=\fIpattern\fP
When \fBpcregrep\fP is searching the contents of a directory as a consequence
of the \fB-r\fP (recursive search) option, any subdirectories whose names match
the pattern are excluded. (Note that the \fP--exclude\fP option does not affect
subdirectories.) The pattern is a PCRE regular expression, and is matched
against the final component of the name (not the entire path). If a
-subdirectory name matches both \fB--include_dir\fP and \fB--exclude_dir\fP, it
+subdirectory name matches both \fB--include-dir\fP and \fB--exclude-dir\fP, it
is excluded. There is no short form for this option.
.TP
\fB-F\fP, \fB--fixed-strings\fP
@@ -248,19 +248,19 @@ Ignore upper/lower case distinctions during comparisons.
When \fBpcregrep\fP is searching the files in a directory as a consequence of
the \fB-r\fP (recursive search) option, only those regular files whose names
match the pattern are included. Subdirectories are always included and searched
-recursively, subject to the \fP--include_dir\fP and \fB--exclude_dir\fP
+recursively, subject to the \fP--include-dir\fP and \fB--exclude-dir\fP
options. The pattern is a PCRE regular expression, and is matched against the
final component of the file name (not the entire path). If a file name matches
both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no short
form for this option.
.TP
-\fB--include_dir\fP=\fIpattern\fP
+\fB--include-dir\fP=\fIpattern\fP
When \fBpcregrep\fP is searching the contents of a directory as a consequence
of the \fB-r\fP (recursive search) option, only those subdirectories whose
names match the pattern are included. (Note that the \fB--include\fP option
does not affect subdirectories.) The pattern is a PCRE regular expression, and
is matched against the final component of the name (not the entire path). If a
-subdirectory name matches both \fB--include_dir\fP and \fB--exclude_dir\fP, it
+subdirectory name matches both \fB--include-dir\fP and \fB--exclude-dir\fP, it
is excluded. There is no short form for this option.
.TP
\fB-L\fP, \fB--files-without-match\fP
@@ -458,11 +458,18 @@ convert this to an appropriate sequence if the output is sent to a file.
.SH "OPTIONS COMPATIBILITY"
.rs
.sp
-The majority of short and long forms of \fBpcregrep\fP's options are the same
-as in the GNU \fBgrep\fP program. Any long option of the form
+Many of the short and long forms of \fBpcregrep\fP's options are the same
+as in the GNU \fBgrep\fP program (version 2.5.4). Any long option of the form
\fB--xxx-regexp\fP (GNU terminology) is also available as \fB--xxx-regex\fP
-(PCRE terminology). However, the \fB--locale\fP, \fB-M\fP, \fB--multiline\fP,
-\fB-u\fP, and \fB--utf-8\fP options are specific to \fBpcregrep\fP. If both the
+(PCRE terminology). However, the \fB--file-offsets\fP, \fB--include-dir\fP,
+\fB--line-offsets\fP, \fB--locale\fP, \fB--match-limit\fP, \fB-M\fP,
+\fB--multiline\fP, \fB-N\fP, \fB--newline\fP, \fB--recursion-limit\fP,
+\fB-u\fP, and \fB--utf-8\fP options are specific to \fBpcregrep\fP, as is the
+use of the \fB--only-matching\fP option with a capturing parentheses number.
+.P
+Although most of the common options work the same way, a few are different in
+\fBpcregrep\fP. For example, the \fB--include\fP option's argument is a glob
+for GNU \fBgrep\fP, but a regular expression for \fBpcregrep\fP. If both the
\fB-c\fP and \fB-l\fP options are given, GNU grep lists only file names,
without counts, but \fBpcregrep\fP gives the counts.
.
@@ -471,14 +478,18 @@ without counts, but \fBpcregrep\fP gives the counts.
.rs
.sp
There are four different ways in which an option with data can be specified.
-If a short form option is used, the data may follow immediately, or in the next
-command line item. For example:
+If a short form option is used, the data may follow immediately, or (with one
+exception) in the next command line item. For example:
.sp
-f/some/file
-f /some/file
.sp
+The exception is the \fB-o\fP option, which may appear with or without data.
+Because of this, if data is present, it must follow immediately in the same
+item, for example -o3.
+.P
If a long form option is used, the data may appear in the same command line
-item, separated by an equals character, or (with one exception) it may appear
+item, separated by an equals character, or (with two exceptions) it may appear
in the next command line item. For example:
.sp
--file=/some/file
@@ -489,10 +500,10 @@ in a shell command, and have the shell expand ~ to a home directory, you must
separate the file name from the option, because the shell does not treat ~
specially unless it is at the start of an item.
.P
-The exception to the above is the \fB--colour\fP (or \fB--color\fP) option,
-for which the data is optional. If this option does have data, it must be given
-in the first form, using an equals character. Otherwise it will be assumed that
-it has no data.
+The exceptions to the above are the \fB--colour\fP (or \fB--color\fP) and
+\fB--only-matching\fP options, for which the data is optional. If one of these
+options does have data, it must be given in the first form, using an equals
+character. Otherwise \fBpcregrep\P will assume that it has no data.
.
.
.SH "MATCHING ERRORS"
@@ -505,6 +516,11 @@ digit. The PCRE matching function has a resource limit that causes it to abort
in these circumstances. If this happens, \fBpcregrep\fP outputs an error
message and the line that caused the problem to the standard error stream. If
there are more than 20 such errors, \fBpcregrep\fP gives up.
+.P
+The \fB--match-limit\fP option of \fBpcregrep\fP can be used to set the overall
+resource limit; there is a second option called \fB--recursion-limit\fP that
+sets a limit on the amount of memory (usually stack) that is used (see the
+discussion of these options above).
.
.
.SH DIAGNOSTICS
@@ -537,6 +553,6 @@ Cambridge CB2 3QH, England.
.rs
.sp
.nf
-Last updated: 31 October 2010
+Last updated: 16 November 2010
Copyright (c) 1997-2010 University of Cambridge.
.fi
diff --git a/pcregrep.c b/pcregrep.c
index 610757d..7a123a9 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -249,8 +249,17 @@ static option_item optionlist[] = {
{ OP_NODATA, 'r', NULL, "recursive", "recursively scan sub-directories" },
{ OP_STRING, N_EXCLUDE,&exclude_pattern, "exclude=pattern","exclude matching files when recursing" },
{ OP_STRING, N_INCLUDE,&include_pattern, "include=pattern","include matching files when recursing" },
+ { OP_STRING, N_EXCLUDE_DIR,&exclude_dir_pattern, "exclude-dir=pattern","exclude matching directories when recursing" },
+ { OP_STRING, N_INCLUDE_DIR,&include_dir_pattern, "include-dir=pattern","include matching directories when recursing" },
+
+ /* These two were accidentally implemented with underscores instead of
+ hyphens in the option names. As this was not discovered for several releases,
+ the incorrect versions are left in the table for compatibility. However, the
+ --help function misses out any option that has an underscore in its name. */
+
{ OP_STRING, N_EXCLUDE_DIR,&exclude_dir_pattern, "exclude_dir=pattern","exclude matching directories when recursing" },
{ OP_STRING, N_INCLUDE_DIR,&include_dir_pattern, "include_dir=pattern","include matching directories when recursing" },
+
#ifdef JFRIEDL_DEBUG
{ OP_OP_NUMBER, 'S', &S_arg, "jeffS", "replace matched (sub)string with X" },
#endif
@@ -1782,10 +1791,21 @@ for (op = optionlist; op->one_char != 0; op++)
{
int n;
char s[4];
+
+ /* Two options were accidentally implemented and documented with underscores
+ instead of hyphens in their names, something that was not noticed for quite a
+ few releases. When fixing this, I left the underscored versions in the list
+ in case people were using them. However, we don't want to display them in the
+ help data. There are no other options that contain underscores, and we do not
+ expect ever to implement such options. Therefore, just omit any option that
+ contains an underscore. */
+
+ if (strchr(op->long_name, '_') != NULL) continue;
+
if (op->one_char > 0) sprintf(s, "-%c,", op->one_char); else strcpy(s, " ");
- n = 30 - printf(" %s --%s", s, op->long_name);
+ n = 31 - printf(" %s --%s", s, op->long_name);
if (n < 1) n = 1;
- printf("%.*s%s\n", n, " ", op->help_text);
+ printf("%.*s%s\n", n, " ", op->help_text);
}
printf("\nWhen reading patterns from a file instead of using a command line option,\n");