[Pcre-svn] [388] code/trunk: Added REG_NOTEMPTY to the POSIX…

Página Inicial
Delete this message
Autor: Subversion repository
Data:  
Para: pcre-svn
Assunto: [Pcre-svn] [388] code/trunk: Added REG_NOTEMPTY to the POSIX wrapper.
Revision: 388
          http://vcs.pcre.org/viewvc?view=rev&revision=388
Author:   ph10
Date:     2009-03-11 17:03:17 +0000 (Wed, 11 Mar 2009)


Log Message:
-----------
Added REG_NOTEMPTY to the POSIX wrapper.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/doc/pcreposix.3
    code/trunk/pcreposix.c
    code/trunk/pcreposix.h
    code/trunk/pcretest.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2009-03-10 11:51:36 UTC (rev 387)
+++ code/trunk/ChangeLog    2009-03-11 17:03:17 UTC (rev 388)
@@ -52,6 +52,8 @@
     characters (bytes) greater than 127 when not in UTF-8 mode.


12. Added the -M command line option to pcretest.
+
+14. Added the non-standard REG_NOTEMPTY option to the POSIX interface.


Version 7.8 05-Sep-08

Modified: code/trunk/doc/pcreposix.3
===================================================================
--- code/trunk/doc/pcreposix.3    2009-03-10 11:51:36 UTC (rev 387)
+++ code/trunk/doc/pcreposix.3    2009-03-11 17:03:17 UTC (rev 388)
@@ -39,11 +39,11 @@
 command for linking an application that uses them. Because the POSIX functions
 call the native ones, it is also necessary to add \fB-lpcre\fP.
 .P
-I have implemented only those option bits that can be reasonably mapped to PCRE
-native options. In addition, the option REG_EXTENDED is defined with the value
-zero. This has no effect, but since programs that are written to the POSIX
-interface often use it, this makes it easier to slot in PCRE as a replacement
-library. Other POSIX options are not even defined.
+I have implemented only those POSIX option bits that can be reasonably mapped
+to PCRE native options. In addition, the option REG_EXTENDED is defined with
+the value zero. This has no effect, but since programs that are written to the
+POSIX interface often use it, this makes it easier to slot in PCRE as a
+replacement library. Other POSIX options are not even defined.
 .P
 When PCRE is called via these functions, it is only the API that is POSIX-like
 in style. The syntax and semantics of the regular expressions themselves are
@@ -166,6 +166,12 @@
 The PCRE_NOTBOL option is set when calling the underlying PCRE matching
 function.
 .sp
+  REG_NOTEMPTY
+.sp   
+The PCRE_NOTEMPTY option is set when calling the underlying PCRE matching
+function. Note that REG_NOTEMPTY is not part of the POSIX standard. However, 
+setting this option can give more POSIX-like behaviour in some situations.
+.sp
   REG_NOTEOL
 .sp
 The PCRE_NOTEOL option is set when calling the underlying PCRE matching
@@ -233,6 +239,6 @@
 .rs
 .sp
 .nf
-Last updated: 05 April 2008
-Copyright (c) 1997-2008 University of Cambridge.
+Last updated: 11 March 2009
+Copyright (c) 1997-2009 University of Cambridge.
 .fi


Modified: code/trunk/pcreposix.c
===================================================================
--- code/trunk/pcreposix.c    2009-03-10 11:51:36 UTC (rev 387)
+++ code/trunk/pcreposix.c    2009-03-11 17:03:17 UTC (rev 388)
@@ -6,7 +6,7 @@
 and semantics are as close as possible to those of the Perl 5 language.


                        Written by Philip Hazel
-           Copyright (c) 1997-2008 University of Cambridge
+           Copyright (c) 1997-2009 University of Cambridge


-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -274,6 +274,7 @@

if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
+if ((eflags & REG_NOTEMPTY) != 0) options |= PCRE_NOTEMPTY;

((regex_t *)preg)->re_erroffset = (size_t)(-1); /* Only has meaning after compile */


Modified: code/trunk/pcreposix.h
===================================================================
--- code/trunk/pcreposix.h    2009-03-10 11:51:36 UTC (rev 387)
+++ code/trunk/pcreposix.h    2009-03-11 17:03:17 UTC (rev 388)
@@ -9,7 +9,7 @@
 Compatible Regular Expression library. It defines the things POSIX says should
 be there. I hope.


-            Copyright (c) 1997-2008 University of Cambridge
+            Copyright (c) 1997-2009 University of Cambridge


 -----------------------------------------------------------------------------
 Redistribution and use in source and binary forms, with or without
@@ -60,6 +60,7 @@
 #define REG_NOSUB     0x0020
 #define REG_UTF8      0x0040   /* NOT defined by POSIX. */
 #define REG_STARTEND  0x0080   /* BSD feature: pass subject string by so,eo */
+#define REG_NOTEMPTY  0x0100   /* NOT defined by POSIX. */


/* This is not used by PCRE, but by defining it we make it easier
to slot PCRE into existing programs that make POSIX calls. */

Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c    2009-03-10 11:51:36 UTC (rev 387)
+++ code/trunk/pcretest.c    2009-03-11 17:03:17 UTC (rev 388)
@@ -2068,6 +2068,7 @@
         pmatch = (regmatch_t *)malloc(sizeof(regmatch_t) * use_size_offsets);
       if ((options & PCRE_NOTBOL) != 0) eflags |= REG_NOTBOL;
       if ((options & PCRE_NOTEOL) != 0) eflags |= REG_NOTEOL;
+      if ((options & PCRE_NOTEMPTY) != 0) eflags |= REG_NOTEMPTY; 


       rc = regexec(&preg, (const char *)bptr, use_size_offsets, pmatch, eflags);



Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2009-03-10 11:51:36 UTC (rev 387)
+++ code/trunk/testdata/testinput2    2009-03-11 17:03:17 UTC (rev 388)
@@ -2734,4 +2734,9 @@


/(?(?=.*b).*b|^d)/I

+/a?|b?/P
+    abc
+    ** Failers
+    ddd\N   
+
 / End of testinput2 /


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2009-03-10 11:51:36 UTC (rev 387)
+++ code/trunk/testdata/testoutput2    2009-03-11 17:03:17 UTC (rev 388)
@@ -9690,4 +9690,12 @@
 First char at start or follows newline
 No need char


+/a?|b?/P
+    abc
+ 0: a
+    ** Failers
+ 0: 
+    ddd\N   
+No match: POSIX code 17: match failed
+
 / End of testinput2 /