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
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 @@ available codes are:
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

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
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

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
PCRE2 - Perl-compatible regular expressions (revised API)
.sp
@ -780,15 +780,15 @@ available:
.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 @@ for the terminating zero.
.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 @@ be compiled by those two libraries, but at the expense of slower matching.
.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 @@ operating system.
.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 @@ over compilation stack usage, see \fBpcre2_set_compile_recursion_guard()\fP.
.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 @@ string plus one unit for the terminating zero.
.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 @@ Cambridge, England.
.rs
.sp
.nf
Last updated: 23 November 2014
Last updated: 25 November 2014
Copyright (c) 1997-2014 University of Cambridge.
.fi

View File

@ -259,9 +259,9 @@ context functions. */
#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

View File

@ -85,15 +85,13 @@ if (where == NULL) /* Requests a length */
case PCRE2_CONFIG_BSR:
case PCRE2_CONFIG_JIT:
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_NEWLINE:
case PCRE2_CONFIG_PARENSLIMIT:
case PCRE2_CONFIG_RECURSIONLIMIT:
return sizeof(long int);
case PCRE2_CONFIG_STACKRECURSE:
case PCRE2_CONFIG_UNICODE:
return sizeof(uint32_t);
/* These are handled below */
@ -111,17 +109,17 @@ switch (what)
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 @@ switch (what)
{
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 @@ switch (what)
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 @@ switch (what)
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));
}
}

View File

@ -1877,25 +1877,26 @@ is available. */
#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 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 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 *);
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 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_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 */

View File

@ -169,10 +169,10 @@ Argument: the string
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 @@ return c;
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;

View File

@ -5934,8 +5934,8 @@ if (PCRE2_CONFIG(PCRE2_CONFIG_VERSION, NULL) !=
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;