[Pcre-svn] [161] code/trunk: Tidy up API for pcre2_config.

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [161] code/trunk: Tidy up API for pcre2_config.
Revision: 161
          http://www.exim.org/viewvc/pcre2?view=rev&revision=161
Author:   ph10
Date:     2014-11-25 11:55:07 +0000 (Tue, 25 Nov 2014)


Log Message:
-----------
Tidy up API for pcre2_config.

Modified Paths:
--------------
    code/trunk/doc/pcre2_config.3
    code/trunk/doc/pcre2_pattern_info.3
    code/trunk/doc/pcre2api.3
    code/trunk/src/pcre2.h.in
    code/trunk/src/pcre2_config.c
    code/trunk/src/pcre2_internal.h
    code/trunk/src/pcre2_string_utils.c
    code/trunk/src/pcre2test.c


Modified: code/trunk/doc/pcre2_config.3
===================================================================
--- code/trunk/doc/pcre2_config.3    2014-11-25 09:06:27 UTC (rev 160)
+++ code/trunk/doc/pcre2_config.3    2014-11-25 11:55:07 UTC (rev 161)
@@ -25,14 +25,12 @@
 .P
 If \fBwhere\fP is not NULL, for PCRE2_CONFIG_JITTARGET,
 PCRE2_CONFIG_UNICODE_VERSION, and PCRE2_CONFIG_VERSION it must point to a
-buffer that is large enough to hold the string. For PCRE2_CONFIG_MATCHLIMIT,
-PCRE2_CONFIG_PARENSLIMIT, and PCRE2_CONFIG_RECURSIONLIMIT it must point to an
-unsigned long int variable, and for all other codes to an int variable. The
-available codes are:
+buffer that is large enough to hold the string. For all other codes it must
+point to a uint32_t integer variable. The available codes are:
 .sp
   PCRE2_CONFIG_BSR             Indicates what \eR matches by default:
-                                 0    all Unicode line endings
-                                 1    CR, LF, or CRLF only
+                                 PCRE2_BSR_UNICODE
+                                 PCRE2_BSR_ANYCRLF
   PCRE2_CONFIG_JIT             Availability of just-in-time compiler
                                 support (1=yes 0=no)
   PCRE2_CONFIG_JITTARGET       Information about the target archi-
@@ -40,11 +38,11 @@
   PCRE2_CONFIG_LINKSIZE        Configured internal link size (2, 3, 4)
   PCRE2_CONFIG_MATCHLIMIT      Default internal resource limit
   PCRE2_CONFIG_NEWLINE         Code for the default newline sequence:
-                                 1    for CR
-                                 2    for LF
-                                 3    for CRLF
-                                 4    for ANY
-                                 5    for ANYCRLF
+                                 PCRE2_NEWLINE_CR
+                                 PCRE2_NEWLINE_LF
+                                 PCRE2_NEWLINE_CRLF
+                                 PCRE2_NEWLINE_ANY
+                                 PCRE2_NEWLINE_ANYCRLF
   PCRE2_CONFIG_PARENSLIMIT     Default parentheses nesting limit
   PCRE2_CONFIG_RECURSIONLIMIT  Internal recursion depth limit
   PCRE2_CONFIG_STACKRECURSE    Recursion implementation (1=stack


Modified: code/trunk/doc/pcre2_pattern_info.3
===================================================================
--- code/trunk/doc/pcre2_pattern_info.3    2014-11-25 09:06:27 UTC (rev 160)
+++ code/trunk/doc/pcre2_pattern_info.3    2014-11-25 11:55:07 UTC (rev 161)
@@ -66,7 +66,7 @@
 The \fIwhere\fP argument must point to an unsigned 32-bit integer (uint32_t
 variable), except for the following \fIwhat\fP values:
 .sp
-  PCRE2_INFO_FIRSTBITMAP     const uint8_t
+  PCRE2_INFO_FIRSTBITMAP     const uint8_t *
   PCRE2_INFO_JITSIZE         size_t
   PCRE2_INFO_NAMETABLE       PCRE2_SPTR
   PCRE2_INFO_SIZE            size_t


Modified: code/trunk/doc/pcre2api.3
===================================================================
--- code/trunk/doc/pcre2api.3    2014-11-25 09:06:27 UTC (rev 160)
+++ code/trunk/doc/pcre2api.3    2014-11-25 11:55:07 UTC (rev 161)
@@ -1,4 +1,4 @@
-.TH PCRE2API 3 "23 November 2014" "PCRE2 10.00"
+.TH PCRE2API 3 "25 November 2014" "PCRE2 10.00"
 .SH NAME
 PCRE2 - Perl-compatible regular expressions (revised API)
 .sp
@@ -780,15 +780,15 @@
 .sp
   PCRE2_CONFIG_BSR
 .sp
-The output is an integer whose value indicates what character sequences the \eR
-escape sequence matches by default. A value of PCRE2_BSR_UNICODE means that \eR
-matches any Unicode line ending sequence; a value of PCRE2_BSR_ANYCRLF means
-that \eR matches only CR, LF, or CRLF. The default can be overridden when a
-pattern is compiled.
+The output is a uint32_t integer whose value indicates what character
+sequences the \eR escape sequence matches by default. A value of
+PCRE2_BSR_UNICODE means that \eR matches any Unicode line ending sequence; a
+value of PCRE2_BSR_ANYCRLF means that \eR matches only CR, LF, or CRLF. The
+default can be overridden when a pattern is compiled.
 .sp
   PCRE2_CONFIG_JIT
 .sp
-The output is an integer that is set to one if support for just-in-time
+The output is a uint32_t integer that is set to one if support for just-in-time
 compiling is available; otherwise it is set to zero.
 .sp
   PCRE2_CONFIG_JITTARGET
@@ -804,12 +804,13 @@
 .sp
   PCRE2_CONFIG_LINKSIZE
 .sp
-The output is an integer that contains the number of bytes used for internal
-linkage in compiled regular expressions. When PCRE2 is configured, the value
-can be set to 2, 3, or 4, with the default being 2. This is the value that is
-returned by \fBpcre2_config()\fP. However, when the 16-bit library is compiled,
-a value of 3 is rounded up to 4, and when the 32-bit library is compiled,
-internal linkages always use 4 bytes, so the configured value is not relevant.
+The output is a uint32_t integer that contains the number of bytes used for
+internal linkage in compiled regular expressions. When PCRE2 is configured, the
+value can be set to 2, 3, or 4, with the default being 2. This is the value
+that is returned by \fBpcre2_config()\fP. However, when the 16-bit library is
+compiled, a value of 3 is rounded up to 4, and when the 32-bit library is
+compiled, internal linkages always use 4 bytes, so the configured value is not
+relevant.
 .P
 The default value of 2 for the 8-bit and 16-bit libraries is sufficient for all
 but the most massive patterns, since it allows the size of the compiled pattern
@@ -818,14 +819,14 @@
 .sp
   PCRE2_CONFIG_MATCHLIMIT
 .sp
-The output is an unsigned long integer that gives the default limit for the
-number of internal matching function calls in a \fBpcre2_match()\fP execution.
-Further details are given with \fBpcre2_match()\fP below.
+The output is a uint32_t integer that gives the default limit for the number of
+internal matching function calls in a \fBpcre2_match()\fP execution. Further
+details are given with \fBpcre2_match()\fP below.
 .sp
   PCRE2_CONFIG_NEWLINE
 .sp
-The output is an integer whose value specifies the default character sequence
-that is recognized as meaning "newline". The values are:
+The output is a uint32_t integer whose value specifies the default character
+sequence that is recognized as meaning "newline". The values are:
 .sp
   PCRE2_NEWLINE_CR       Carriage return (CR)
   PCRE2_NEWLINE_LF       Linefeed (LF)
@@ -838,7 +839,7 @@
 .sp
   PCRE2_CONFIG_PARENSLIMIT
 .sp
-The output is an unsigned long integer that gives the maximum depth of nesting
+The output is a uint32_t integer that gives the maximum depth of nesting
 of parentheses (of any kind) in a pattern. This limit is imposed to cap the
 amount of system stack used when a pattern is compiled. It is specified when
 PCRE2 is built; the default is 250. This limit does not take into account the
@@ -847,16 +848,15 @@
 .sp
   PCRE2_CONFIG_RECURSIONLIMIT
 .sp
-The output is an unsigned long integer that gives the default limit for the
-depth of recursion when calling the internal matching function in a
-\fBpcre2_match()\fP execution. Further details are given with
-\fBpcre2_match()\fP below.
+The output is a uint32_t integer that gives the default limit for the depth of
+recursion when calling the internal matching function in a \fBpcre2_match()\fP
+execution. Further details are given with \fBpcre2_match()\fP below.
 .sp
   PCRE2_CONFIG_STACKRECURSE
 .sp
-The output is an integer that is set to one if internal recursion when running
-\fBpcre2_match()\fP is implemented by recursive function calls that use the
-system stack to remember their state. This is the usual way that PCRE2 is
+The output is a uint32_t integer that is set to one if internal recursion when
+running \fBpcre2_match()\fP is implemented by recursive function calls that use
+the system stack to remember their state. This is the usual way that PCRE2 is
 compiled. The output is zero if PCRE2 was compiled to use blocks of data on the
 heap instead of recursive function calls.
 .sp
@@ -872,8 +872,8 @@
 .sp
   PCRE2_CONFIG_UNICODE
 .sp
-The output is an integer that is set to one if Unicode support is available;
-otherwise it is set to zero. Unicode support implies UTF support.
+The output is a uint32_t integer that is set to one if Unicode support is
+available; otherwise it is set to zero. Unicode support implies UTF support.
 .sp
   PCRE2_CONFIG_VERSION
 .sp
@@ -2714,6 +2714,6 @@
 .rs
 .sp
 .nf
-Last updated: 23 November 2014
+Last updated: 25 November 2014
 Copyright (c) 1997-2014 University of Cambridge.
 .fi


Modified: code/trunk/src/pcre2.h.in
===================================================================
--- code/trunk/src/pcre2.h.in    2014-11-25 09:06:27 UTC (rev 160)
+++ code/trunk/src/pcre2.h.in    2014-11-25 11:55:07 UTC (rev 161)
@@ -259,9 +259,9 @@
 #define PCRE2_CONFIG_JITTARGET               2
 #define PCRE2_CONFIG_LINKSIZE                3
 #define PCRE2_CONFIG_MATCHLIMIT              4
-#define PCRE2_CONFIG_NEWLINE                 6
-#define PCRE2_CONFIG_PARENSLIMIT             7
-#define PCRE2_CONFIG_RECURSIONLIMIT          5
+#define PCRE2_CONFIG_NEWLINE                 5
+#define PCRE2_CONFIG_PARENSLIMIT             6
+#define PCRE2_CONFIG_RECURSIONLIMIT          7
 #define PCRE2_CONFIG_STACKRECURSE            8
 #define PCRE2_CONFIG_UNICODE                 9
 #define PCRE2_CONFIG_UNICODE_VERSION        10


Modified: code/trunk/src/pcre2_config.c
===================================================================
--- code/trunk/src/pcre2_config.c    2014-11-25 09:06:27 UTC (rev 160)
+++ code/trunk/src/pcre2_config.c    2014-11-25 11:55:07 UTC (rev 161)
@@ -85,16 +85,14 @@
     case PCRE2_CONFIG_BSR:
     case PCRE2_CONFIG_JIT:
     case PCRE2_CONFIG_LINKSIZE:
+    case PCRE2_CONFIG_MATCHLIMIT:
     case PCRE2_CONFIG_NEWLINE:
+    case PCRE2_CONFIG_PARENSLIMIT:
+    case PCRE2_CONFIG_RECURSIONLIMIT:
     case PCRE2_CONFIG_STACKRECURSE:
     case PCRE2_CONFIG_UNICODE:
-    return sizeof(int);
+    return sizeof(uint32_t);


-    case PCRE2_CONFIG_MATCHLIMIT:
-    case PCRE2_CONFIG_PARENSLIMIT:
-    case PCRE2_CONFIG_RECURSIONLIMIT:
-    return sizeof(long int);
-
     /* These are handled below */


     case PCRE2_CONFIG_JITTARGET:
@@ -111,17 +109,17 @@


case PCRE2_CONFIG_BSR:
#ifdef BSR_ANYCRLF
- *((int *)where) = 1;
+ *((uint32_t *)where) = PCRE2_BSR_ANYCRLF;
#else
- *((int *)where) = 0;
+ *((uint32_t *)where) = PCRE2_BSR_UNICODE;
#endif
break;

case PCRE2_CONFIG_JIT:
#ifdef SUPPORT_JIT
- *((int *)where) = 1;
+ *((uint32_t *)where) = 1;
#else
- *((int *)where) = 0;
+ *((uint32_t *)where) = 0;
#endif
break;

@@ -130,37 +128,37 @@
     {
     const char *v = PRIV(jit_get_target)();
     return 1 + ((where == NULL)?
-      (int)strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
+      strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
     }
 #else
   return PCRE2_ERROR_BADOPTION;
 #endif


case PCRE2_CONFIG_LINKSIZE:
- *((int *)where) = configured_link_size;
+ *((uint32_t *)where) = configured_link_size;
break;

case PCRE2_CONFIG_MATCHLIMIT:
- *((unsigned long int *)where) = MATCH_LIMIT;
+ *((uint32_t *)where) = MATCH_LIMIT;
break;

case PCRE2_CONFIG_NEWLINE:
- *((int *)where) = NEWLINE_DEFAULT;
+ *((uint32_t *)where) = NEWLINE_DEFAULT;
break;

case PCRE2_CONFIG_PARENSLIMIT:
- *((unsigned long int *)where) = PARENS_NEST_LIMIT;
+ *((uint32_t *)where) = PARENS_NEST_LIMIT;
break;

case PCRE2_CONFIG_RECURSIONLIMIT:
- *((unsigned long int *)where) = MATCH_LIMIT_RECURSION;
+ *((uint32_t *)where) = MATCH_LIMIT_RECURSION;
break;

case PCRE2_CONFIG_STACKRECURSE:
#ifdef HEAP_MATCH_RECURSE
- *((int *)where) = 0;
+ *((uint32_t *)where) = 0;
#else
- *((int *)where) = 1;
+ *((uint32_t *)where) = 1;
#endif
break;

@@ -172,15 +170,15 @@
     const char *v = "Unicode not supported";
 #endif
     return 1 + ((where == NULL)?
-      (int)strlen(v): PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
+      strlen(v): PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
    }
   break;


case PCRE2_CONFIG_UNICODE:
#if defined SUPPORT_UNICODE
- *((int *)where) = 1;
+ *((uint32_t *)where) = 1;
#else
- *((int *)where) = 0;
+ *((uint32_t *)where) = 0;
#endif
break;

@@ -209,7 +207,7 @@
       XSTRING(PCRE2_MAJOR.PCRE2_MINOR PCRE2_DATE) :
       XSTRING(PCRE2_MAJOR.PCRE2_MINOR) XSTRING(PCRE2_PRERELEASE PCRE2_DATE);
     return 1 + ((where == NULL)?
-      (int)strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
+      strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
     }
   }



Modified: code/trunk/src/pcre2_internal.h
===================================================================
--- code/trunk/src/pcre2_internal.h    2014-11-25 09:06:27 UTC (rev 160)
+++ code/trunk/src/pcre2_internal.h    2014-11-25 11:55:07 UTC (rev 161)
@@ -1877,26 +1877,27 @@
 #define _pcre2_was_newline           PCRE2_SUFFIX(_pcre2_was_newline_)
 #define _pcre2_xclass                PCRE2_SUFFIX(_pcre2_xclass_)


-extern void  _pcre2_auto_possessify(PCRE2_UCHAR *, BOOL, const compile_block *);
-extern PCRE2_SPTR _pcre2_find_bracket(PCRE2_SPTR, BOOL, int);
-extern BOOL  _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, uint32_t *,
-               BOOL);
-extern void  _pcre2_jit_free(void *, pcre2_memctl *);
-extern size_t _pcre2_jit_get_size(void *);
-const char*  _pcre2_jit_get_target(void);
-extern void  *_pcre2_memctl_malloc(size_t, pcre2_memctl *);
+extern void         _pcre2_auto_possessify(PCRE2_UCHAR *, BOOL, 
+                      const compile_block *);
+extern PCRE2_SPTR   _pcre2_find_bracket(PCRE2_SPTR, BOOL, int);
+extern BOOL         _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, 
+                      uint32_t *, BOOL);
+extern void         _pcre2_jit_free(void *, pcre2_memctl *);
+extern size_t       _pcre2_jit_get_size(void *);
+const char *        _pcre2_jit_get_target(void);
+extern void *       _pcre2_memctl_malloc(size_t, pcre2_memctl *);
 extern unsigned int _pcre2_ord2utf(uint32_t, PCRE2_UCHAR *);
-extern int   _pcre2_strcmp(PCRE2_SPTR, PCRE2_SPTR);
-extern int   _pcre2_strcmp_c8(PCRE2_SPTR, const char *);
-extern int   _pcre2_strcpy_c8(PCRE2_UCHAR *, const char *);
-extern int   _pcre2_strlen(PCRE2_SPTR);
-extern int   _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t);
-extern int   _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t);
-extern int   _pcre2_study(pcre2_real_code *);
-extern int   _pcre2_valid_utf(PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE *);
-extern BOOL  _pcre2_was_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, uint32_t *,
-               BOOL);
-extern BOOL  _pcre2_xclass(uint32_t, PCRE2_SPTR, BOOL);
+extern int          _pcre2_strcmp(PCRE2_SPTR, PCRE2_SPTR);
+extern int          _pcre2_strcmp_c8(PCRE2_SPTR, const char *);
+extern PCRE2_SIZE   _pcre2_strcpy_c8(PCRE2_UCHAR *, const char *);
+extern PCRE2_SIZE   _pcre2_strlen(PCRE2_SPTR);
+extern int          _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t);
+extern int          _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t);
+extern int          _pcre2_study(pcre2_real_code *);
+extern int          _pcre2_valid_utf(PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE *);
+extern BOOL         _pcre2_was_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, 
+                      uint32_t *, BOOL);
+extern BOOL         _pcre2_xclass(uint32_t, PCRE2_SPTR, BOOL);
 #endif  /* PCRE2_CODE_UNIT_WIDTH */


/* End of pcre2_internal.h */

Modified: code/trunk/src/pcre2_string_utils.c
===================================================================
--- code/trunk/src/pcre2_string_utils.c    2014-11-25 09:06:27 UTC (rev 160)
+++ code/trunk/src/pcre2_string_utils.c    2014-11-25 11:55:07 UTC (rev 161)
@@ -169,10 +169,10 @@
 Returns:     the length
 */


-int
+PCRE2_SIZE
PRIV(strlen)(PCRE2_SPTR str)
{
-int c = 0;
+PCRE2_SIZE c = 0;
while (*str++ != 0) c++;
return c;
}
@@ -189,7 +189,7 @@
Returns: the number of code units used (excluding trailing zero)
*/

-int
+PCRE2_SIZE
PRIV(strcpy_c8)(PCRE2_UCHAR *str1, const char *str2)
{
PCRE2_UCHAR *t = str1;

Modified: code/trunk/src/pcre2test.c
===================================================================
--- code/trunk/src/pcre2test.c    2014-11-25 09:06:27 UTC (rev 160)
+++ code/trunk/src/pcre2test.c    2014-11-25 11:55:07 UTC (rev 161)
@@ -5934,8 +5934,8 @@
     PCRE2_CONFIG(PCRE2_CONFIG_JITTARGET, NULL) !=
     PCRE2_CONFIG(PCRE2_CONFIG_JITTARGET, jittarget) ||


-    PCRE2_CONFIG(PCRE2_CONFIG_UNICODE, NULL) != sizeof(int) ||
-    PCRE2_CONFIG(PCRE2_CONFIG_MATCHLIMIT, NULL) != sizeof(long int))
+    PCRE2_CONFIG(PCRE2_CONFIG_UNICODE, NULL) != sizeof(uint32_t) ||
+    PCRE2_CONFIG(PCRE2_CONFIG_MATCHLIMIT, NULL) != sizeof(uint32_t))
   {
   fprintf(stderr, "** Error in pcre2_config(): bad length\n");
   return 1;