[Pcre-svn] [571] code/trunk: Rename --{in, ex}clude_dir wit…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [571] code/trunk: Rename --{in, ex}clude_dir with hyphen instead of underscore in pcregrep, but
Revision: 571
          http://vcs.pcre.org/viewvc?view=rev&revision=571
Author:   ph10
Date:     2010-11-16 17:51:37 +0000 (Tue, 16 Nov 2010)


Log Message:
-----------
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.)

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/RunGrepTest
    code/trunk/doc/pcregrep.1
    code/trunk/pcregrep.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2010-11-07 16:25:12 UTC (rev 570)
+++ code/trunk/ChangeLog    2010-11-16 17:51:37 UTC (rev 571)
@@ -95,6 +95,13 @@


 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

Modified: code/trunk/RunGrepTest
===================================================================
--- code/trunk/RunGrepTest    2010-11-07 16:25:12 UTC (rev 570)
+++ code/trunk/RunGrepTest    2010-11-16 17:51:37 UTC (rev 571)
@@ -187,7 +187,7 @@
 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

Modified: code/trunk/doc/pcregrep.1
===================================================================
--- code/trunk/doc/pcregrep.1    2010-11-07 16:25:12 UTC (rev 570)
+++ code/trunk/doc/pcregrep.1    2010-11-16 17:51:37 UTC (rev 571)
@@ -182,19 +182,19 @@
 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 @@
 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 @@
 .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 @@
 .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 @@
 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 @@
 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 @@
 .rs
 .sp
 .nf
-Last updated: 31 October 2010
+Last updated: 16 November 2010
 Copyright (c) 1997-2010 University of Cambridge.
 .fi


Modified: code/trunk/pcregrep.c
===================================================================
--- code/trunk/pcregrep.c    2010-11-07 16:25:12 UTC (rev 570)
+++ code/trunk/pcregrep.c    2010-11-16 17:51:37 UTC (rev 571)
@@ -249,8 +249,17 @@
   { 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 @@
   {
   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");