Refactor pcre2posix.c so as not to #include pcre2_internal.h.
This commit is contained in:
parent
517cd43ff6
commit
8f4e7c84b4
|
@ -102,6 +102,10 @@ additions).
|
|||
|
||||
23. RunTest.bat was missing a "set type" line for test 22.
|
||||
|
||||
24. The pcre2posix.c file was including pcre2_internal.h, and using some
|
||||
"private" knowledge of the data structures. This is unnecessary; the code has
|
||||
been re-factored and no longer includes pcre2_internal.h.
|
||||
|
||||
|
||||
Version 10.21 12-January-2016
|
||||
-----------------------------
|
||||
|
|
|
@ -242,8 +242,15 @@ Unicode doesn't go beyond 0x0010ffff. */
|
|||
|
||||
#define MAX_UTF_CODE_POINT 0x10ffff
|
||||
|
||||
/* Compile-time errors are added to this value. As they are documented, it
|
||||
should probably never be changed. */
|
||||
/* Compile-time positive error numbers (all except UTF errors, which are
|
||||
negative) start at this value. It should probably never be changed, in case
|
||||
some application is checking for specific numbers. There is a copy of this
|
||||
#define in pcre2posix.c (which now no longer includes this file). Ideally, a
|
||||
way of having a single definition should be found, but as the number is
|
||||
unlikely to change, this is not a pressing issue. The original reason for
|
||||
having a base other than 0 was to keep the absolute values of compile-time and
|
||||
run-time error numbers numerically different, but in the event the code does
|
||||
not rely on this. */
|
||||
|
||||
#define COMPILE_ERROR_BASE 100
|
||||
|
||||
|
|
|
@ -58,16 +58,41 @@ previously been set. */
|
|||
# define PCRE2POSIX_EXP_DEFN __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
/* We include pcre2.h before pcre2_internal.h so that the PCRE2 library
|
||||
functions are declared as "import" for Windows by defining PCRE2_EXP_DECL as
|
||||
"import". This is needed even though pcre2_internal.h itself includes pcre2.h,
|
||||
because it does so after it has set PCRE2_EXP_DECL to "export" if it is not
|
||||
already set. */
|
||||
|
||||
/* Compile-time error numbers start at this value. It should probably never be
|
||||
changed. This #define is a copy of the one in pcre2_internal.h. */
|
||||
|
||||
#define COMPILE_ERROR_BASE 100
|
||||
|
||||
|
||||
/* Standard C headers */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* PCRE2 headers */
|
||||
|
||||
#include "pcre2.h"
|
||||
#include "pcre2_internal.h"
|
||||
#include "pcre2posix.h"
|
||||
|
||||
/* When compiling with the MSVC compiler, it is sometimes necessary to include
|
||||
a "calling convention" before exported function names. (This is secondhand
|
||||
information; I know nothing about MSVC myself). For example, something like
|
||||
|
||||
void __cdecl function(....)
|
||||
|
||||
might be needed. In order so make this easy, all the exported functions have
|
||||
PCRE2_CALL_CONVENTION just before their names. It is rarely needed; if not
|
||||
set, we ensure here that it has no effect. */
|
||||
|
||||
#ifndef PCRE2_CALL_CONVENTION
|
||||
#define PCRE2_CALL_CONVENTION
|
||||
#endif
|
||||
|
||||
/* Table to translate PCRE2 compile time error codes into POSIX error codes.
|
||||
Only a few PCRE2 errors with a value greater than 23 turn into special POSIX
|
||||
codes: most go to REG_BADPAT. The second table lists, in pairs, those that
|
||||
|
@ -302,11 +327,12 @@ rc = pcre2_match((const pcre2_code *)preg->re_pcre2_code,
|
|||
if (rc >= 0)
|
||||
{
|
||||
size_t i;
|
||||
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(md);
|
||||
if ((size_t)rc > nmatch) rc = (int)nmatch;
|
||||
for (i = 0; i < (size_t)rc; i++)
|
||||
{
|
||||
pmatch[i].rm_so = md->ovector[i*2];
|
||||
pmatch[i].rm_eo = md->ovector[i*2+1];
|
||||
pmatch[i].rm_so = ovector[i*2];
|
||||
pmatch[i].rm_eo = ovector[i*2+1];
|
||||
}
|
||||
for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue