[Pcre-svn] [654] code/trunk: Minor tidies to pcre2grep.

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [654] code/trunk: Minor tidies to pcre2grep.
Revision: 654
          http://www.exim.org/viewvc/pcre2?view=rev&revision=654
Author:   ph10
Date:     2017-01-16 15:06:57 +0000 (Mon, 16 Jan 2017)
Log Message:
-----------
Minor tidies to pcre2grep.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2grep.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2017-01-12 16:35:43 UTC (rev 653)
+++ code/trunk/ChangeLog    2017-01-16 15:06:57 UTC (rev 654)
@@ -329,7 +329,15 @@
 AC_USE_SYSTEM_EXTENSIONS macro and to test for functions used by the JIT 
 modules.


+52. Minor fixed to pcre2grep from Jason Hood:
+    * fixes some spacing;
+    * Windows doesn't usually use single quotes, so I've added a define
+      to use appropriate quotes [in an example];
+    * LC_ALL was displayed as "LCC_ALL";
+    * numbers 11, 12 & 13 should end in "th".
+    * use double quotes in usage message 


+
Version 10.22 29-July-2016
--------------------------


Modified: code/trunk/src/pcre2grep.c
===================================================================
--- code/trunk/src/pcre2grep.c    2017-01-12 16:35:43 UTC (rev 653)
+++ code/trunk/src/pcre2grep.c    2017-01-16 15:06:57 UTC (rev 654)
@@ -141,12 +141,15 @@
 /* Under Windows, we have to set stdout to be binary, so that it does not
 convert \r\n at the ends of output lines to \r\r\n. However, that means that
 any messages written to stdout must have \r\n as their line terminator. This is
-handled by using STDOUT_NL as the newline string. */
+handled by using STDOUT_NL as the newline string. We also use a normal double
+quote for the example, as single quotes aren't usually available. */


 #ifdef WIN32
 #define STDOUT_NL  "\r\n"
+#define QUOT       "\""
 #else
 #define STDOUT_NL  "\n"
+#define QUOT       "'"
 #endif



@@ -1038,7 +1041,7 @@
if (op->one_char > 0) fprintf(stderr, "%c", op->one_char);
}
fprintf(stderr, "] [long options] [pattern] [files]\n");
-fprintf(stderr, "Type `pcre2grep --help' for more information and the long "
+fprintf(stderr, "Type \"pcre2grep --help\" for more information and the long "
"options.\n");
return rc;
}
@@ -1080,7 +1083,7 @@
printf("All files are read as plain files, without any interpretation." STDOUT_NL STDOUT_NL);
#endif

-printf("Example: pcre2grep -i 'hello.*world' menu.h main.c" STDOUT_NL STDOUT_NL);
+printf("Example: pcre2grep -i " QUOT "hello.*world" QUOT " menu.h main.c" STDOUT_NL STDOUT_NL);
printf("Options:" STDOUT_NL);

 for (op = optionlist; op->one_char != 0; op++)
@@ -2516,7 +2519,6 @@
         lastmatchnumber > 0 &&
         lastmatchrestart < main_buffer + bufthird)
       {
-
       do_after_lines(lastmatchnumber, lastmatchrestart, endptr, printname);
       lastmatchnumber = 0;  /* Indicates no after lines pending */
       }
@@ -2945,6 +2947,8 @@
 char *p = buffer;
 sprintf(p, "%d", n);
 while (*p != 0) p++;
+n %= 100;
+if (n >= 11 && n <= 13) n = 0;
 switch (n%10)
   {
   case 1: strcpy(p, "st"); break;
@@ -3161,7 +3165,7 @@
 must use STDOUT_NL to terminate lines. */


#ifdef WIN32
-_setmode( _fileno(stdout), _O_BINARY);
+_setmode(_fileno(stdout), _O_BINARY);
#endif

/* Set up a default compile and match contexts and a match data block. */
@@ -3525,7 +3529,7 @@
if (locale == NULL)
{
locale = getenv("LC_ALL");
- locale_from = "LCC_ALL";
+ locale_from = "LC_ALL";
}

if (locale == NULL)