Tidy up API for pcre2_config.

This commit is contained in:
Philip.Hazel 2014-11-25 11:55:07 +00:00
parent bb6bf69a6e
commit d13f52c1c4
8 changed files with 87 additions and 90 deletions

View File

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

View File

@ -66,7 +66,7 @@ the requested information, in bytes. The following information is available:
The \fIwhere\fP argument must point to an unsigned 32-bit integer (uint32_t The \fIwhere\fP argument must point to an unsigned 32-bit integer (uint32_t
variable), except for the following \fIwhat\fP values: variable), except for the following \fIwhat\fP values:
.sp .sp
PCRE2_INFO_FIRSTBITMAP const uint8_t PCRE2_INFO_FIRSTBITMAP const uint8_t *
PCRE2_INFO_JITSIZE size_t PCRE2_INFO_JITSIZE size_t
PCRE2_INFO_NAMETABLE PCRE2_SPTR PCRE2_INFO_NAMETABLE PCRE2_SPTR
PCRE2_INFO_SIZE size_t PCRE2_INFO_SIZE size_t

View File

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

View File

@ -259,9 +259,9 @@ context functions. */
#define PCRE2_CONFIG_JITTARGET 2 #define PCRE2_CONFIG_JITTARGET 2
#define PCRE2_CONFIG_LINKSIZE 3 #define PCRE2_CONFIG_LINKSIZE 3
#define PCRE2_CONFIG_MATCHLIMIT 4 #define PCRE2_CONFIG_MATCHLIMIT 4
#define PCRE2_CONFIG_NEWLINE 6 #define PCRE2_CONFIG_NEWLINE 5
#define PCRE2_CONFIG_PARENSLIMIT 7 #define PCRE2_CONFIG_PARENSLIMIT 6
#define PCRE2_CONFIG_RECURSIONLIMIT 5 #define PCRE2_CONFIG_RECURSIONLIMIT 7
#define PCRE2_CONFIG_STACKRECURSE 8 #define PCRE2_CONFIG_STACKRECURSE 8
#define PCRE2_CONFIG_UNICODE 9 #define PCRE2_CONFIG_UNICODE 9
#define PCRE2_CONFIG_UNICODE_VERSION 10 #define PCRE2_CONFIG_UNICODE_VERSION 10

View File

@ -85,15 +85,13 @@ if (where == NULL) /* Requests a length */
case PCRE2_CONFIG_BSR: case PCRE2_CONFIG_BSR:
case PCRE2_CONFIG_JIT: case PCRE2_CONFIG_JIT:
case PCRE2_CONFIG_LINKSIZE: case PCRE2_CONFIG_LINKSIZE:
case PCRE2_CONFIG_NEWLINE:
case PCRE2_CONFIG_STACKRECURSE:
case PCRE2_CONFIG_UNICODE:
return sizeof(int);
case PCRE2_CONFIG_MATCHLIMIT: case PCRE2_CONFIG_MATCHLIMIT:
case PCRE2_CONFIG_NEWLINE:
case PCRE2_CONFIG_PARENSLIMIT: case PCRE2_CONFIG_PARENSLIMIT:
case PCRE2_CONFIG_RECURSIONLIMIT: case PCRE2_CONFIG_RECURSIONLIMIT:
return sizeof(long int); case PCRE2_CONFIG_STACKRECURSE:
case PCRE2_CONFIG_UNICODE:
return sizeof(uint32_t);
/* These are handled below */ /* These are handled below */
@ -111,17 +109,17 @@ switch (what)
case PCRE2_CONFIG_BSR: case PCRE2_CONFIG_BSR:
#ifdef BSR_ANYCRLF #ifdef BSR_ANYCRLF
*((int *)where) = 1; *((uint32_t *)where) = PCRE2_BSR_ANYCRLF;
#else #else
*((int *)where) = 0; *((uint32_t *)where) = PCRE2_BSR_UNICODE;
#endif #endif
break; break;
case PCRE2_CONFIG_JIT: case PCRE2_CONFIG_JIT:
#ifdef SUPPORT_JIT #ifdef SUPPORT_JIT
*((int *)where) = 1; *((uint32_t *)where) = 1;
#else #else
*((int *)where) = 0; *((uint32_t *)where) = 0;
#endif #endif
break; break;
@ -130,37 +128,37 @@ switch (what)
{ {
const char *v = PRIV(jit_get_target)(); const char *v = PRIV(jit_get_target)();
return 1 + ((where == NULL)? return 1 + ((where == NULL)?
(int)strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v)); strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
} }
#else #else
return PCRE2_ERROR_BADOPTION; return PCRE2_ERROR_BADOPTION;
#endif #endif
case PCRE2_CONFIG_LINKSIZE: case PCRE2_CONFIG_LINKSIZE:
*((int *)where) = configured_link_size; *((uint32_t *)where) = configured_link_size;
break; break;
case PCRE2_CONFIG_MATCHLIMIT: case PCRE2_CONFIG_MATCHLIMIT:
*((unsigned long int *)where) = MATCH_LIMIT; *((uint32_t *)where) = MATCH_LIMIT;
break; break;
case PCRE2_CONFIG_NEWLINE: case PCRE2_CONFIG_NEWLINE:
*((int *)where) = NEWLINE_DEFAULT; *((uint32_t *)where) = NEWLINE_DEFAULT;
break; break;
case PCRE2_CONFIG_PARENSLIMIT: case PCRE2_CONFIG_PARENSLIMIT:
*((unsigned long int *)where) = PARENS_NEST_LIMIT; *((uint32_t *)where) = PARENS_NEST_LIMIT;
break; break;
case PCRE2_CONFIG_RECURSIONLIMIT: case PCRE2_CONFIG_RECURSIONLIMIT:
*((unsigned long int *)where) = MATCH_LIMIT_RECURSION; *((uint32_t *)where) = MATCH_LIMIT_RECURSION;
break; break;
case PCRE2_CONFIG_STACKRECURSE: case PCRE2_CONFIG_STACKRECURSE:
#ifdef HEAP_MATCH_RECURSE #ifdef HEAP_MATCH_RECURSE
*((int *)where) = 0; *((uint32_t *)where) = 0;
#else #else
*((int *)where) = 1; *((uint32_t *)where) = 1;
#endif #endif
break; break;
@ -172,15 +170,15 @@ switch (what)
const char *v = "Unicode not supported"; const char *v = "Unicode not supported";
#endif #endif
return 1 + ((where == NULL)? return 1 + ((where == NULL)?
(int)strlen(v): PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v)); strlen(v): PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
} }
break; break;
case PCRE2_CONFIG_UNICODE: case PCRE2_CONFIG_UNICODE:
#if defined SUPPORT_UNICODE #if defined SUPPORT_UNICODE
*((int *)where) = 1; *((uint32_t *)where) = 1;
#else #else
*((int *)where) = 0; *((uint32_t *)where) = 0;
#endif #endif
break; break;
@ -209,7 +207,7 @@ switch (what)
XSTRING(PCRE2_MAJOR.PCRE2_MINOR PCRE2_DATE) : XSTRING(PCRE2_MAJOR.PCRE2_MINOR PCRE2_DATE) :
XSTRING(PCRE2_MAJOR.PCRE2_MINOR) XSTRING(PCRE2_PRERELEASE PCRE2_DATE); XSTRING(PCRE2_MAJOR.PCRE2_MINOR) XSTRING(PCRE2_PRERELEASE PCRE2_DATE);
return 1 + ((where == NULL)? return 1 + ((where == NULL)?
(int)strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v)); strlen(v) : PRIV(strcpy_c8)((PCRE2_UCHAR *)where, v));
} }
} }

View File

@ -1877,26 +1877,27 @@ is available. */
#define _pcre2_was_newline PCRE2_SUFFIX(_pcre2_was_newline_) #define _pcre2_was_newline PCRE2_SUFFIX(_pcre2_was_newline_)
#define _pcre2_xclass PCRE2_SUFFIX(_pcre2_xclass_) #define _pcre2_xclass PCRE2_SUFFIX(_pcre2_xclass_)
extern void _pcre2_auto_possessify(PCRE2_UCHAR *, BOOL, const compile_block *); extern void _pcre2_auto_possessify(PCRE2_UCHAR *, BOOL,
extern PCRE2_SPTR _pcre2_find_bracket(PCRE2_SPTR, BOOL, int); const compile_block *);
extern BOOL _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, uint32_t *, extern PCRE2_SPTR _pcre2_find_bracket(PCRE2_SPTR, BOOL, int);
BOOL); extern BOOL _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR,
extern void _pcre2_jit_free(void *, pcre2_memctl *); uint32_t *, BOOL);
extern size_t _pcre2_jit_get_size(void *); extern void _pcre2_jit_free(void *, pcre2_memctl *);
const char* _pcre2_jit_get_target(void); extern size_t _pcre2_jit_get_size(void *);
extern void *_pcre2_memctl_malloc(size_t, pcre2_memctl *); 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 unsigned int _pcre2_ord2utf(uint32_t, PCRE2_UCHAR *);
extern int _pcre2_strcmp(PCRE2_SPTR, PCRE2_SPTR); extern int _pcre2_strcmp(PCRE2_SPTR, PCRE2_SPTR);
extern int _pcre2_strcmp_c8(PCRE2_SPTR, const char *); extern int _pcre2_strcmp_c8(PCRE2_SPTR, const char *);
extern int _pcre2_strcpy_c8(PCRE2_UCHAR *, const char *); extern PCRE2_SIZE _pcre2_strcpy_c8(PCRE2_UCHAR *, const char *);
extern int _pcre2_strlen(PCRE2_SPTR); extern PCRE2_SIZE _pcre2_strlen(PCRE2_SPTR);
extern int _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t); extern int _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t);
extern int _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t); extern int _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t);
extern int _pcre2_study(pcre2_real_code *); extern int _pcre2_study(pcre2_real_code *);
extern int _pcre2_valid_utf(PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE *); extern int _pcre2_valid_utf(PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE *);
extern BOOL _pcre2_was_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, uint32_t *, extern BOOL _pcre2_was_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR,
BOOL); uint32_t *, BOOL);
extern BOOL _pcre2_xclass(uint32_t, PCRE2_SPTR, BOOL); extern BOOL _pcre2_xclass(uint32_t, PCRE2_SPTR, BOOL);
#endif /* PCRE2_CODE_UNIT_WIDTH */ #endif /* PCRE2_CODE_UNIT_WIDTH */
/* End of pcre2_internal.h */ /* End of pcre2_internal.h */

View File

@ -169,10 +169,10 @@ Argument: the string
Returns: the length Returns: the length
*/ */
int PCRE2_SIZE
PRIV(strlen)(PCRE2_SPTR str) PRIV(strlen)(PCRE2_SPTR str)
{ {
int c = 0; PCRE2_SIZE c = 0;
while (*str++ != 0) c++; while (*str++ != 0) c++;
return c; return c;
} }
@ -189,7 +189,7 @@ return c;
Returns: the number of code units used (excluding trailing zero) Returns: the number of code units used (excluding trailing zero)
*/ */
int PCRE2_SIZE
PRIV(strcpy_c8)(PCRE2_UCHAR *str1, const char *str2) PRIV(strcpy_c8)(PCRE2_UCHAR *str1, const char *str2)
{ {
PCRE2_UCHAR *t = str1; PCRE2_UCHAR *t = str1;

View File

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