Tidy some comments; change several PCRE2_INFO fields to uint32_t instead of

int.
This commit is contained in:
Philip.Hazel 2014-08-15 09:55:18 +00:00
parent 8397209c5b
commit 415cf1a40e
6 changed files with 33 additions and 39 deletions

View File

@ -45,9 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "pcre2_internal.h"
/* FIXME: check out the errors */
#define STRING(a) # a
#define XSTRING(s) STRING(s)

View File

@ -38,8 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* FIXME: this file is incomplete, being gradually built. */
/* We do not support both EBCDIC and UTF at the same time. The "configure"
script prevents both being selected, but not everybody uses "configure". */

View File

@ -543,7 +543,7 @@ These are all no-ops since all UTF-32 characters fit into one pcre_uchar. */
/* NOTE: All these structures *must* start with a pcre2_memctl structure. The
code that uses them is simpler because it assumes this. */
/* The real general context structure. At present it hold only data for custom
/* The real general context structure. At present it holds only data for custom
memory control. */
typedef struct pcre2_real_general_context {

View File

@ -59,7 +59,7 @@ Arguments:
Returns: 0 if data returned, negative on error
*/
/* FIXME: this is currently incomplete. Also, check int vs uint32_t */
/* FIXME: Remove BADENDIANNESS if saving/restoring is not to be implemented. */
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_pattern_info(const pcre2_code *code, uint32_t what, void *where)
@ -85,15 +85,15 @@ if ((re->flags & (PCRE2_CODE_UNIT_WIDTH/8)) == 0)
switch(what)
{
case PCRE2_INFO_ALLOPTIONS:
*((int *)where) = re->overall_options;
*((uint32_t *)where) = re->overall_options;
break;
case PCRE2_INFO_ARGOPTIONS:
*((int *)where) = re->compile_options;
*((uint32_t *)where) = re->compile_options;
break;
case PCRE2_INFO_BACKREFMAX:
*((int *)where) = re->top_backref;
*((uint32_t *)where) = re->top_backref;
break;
case PCRE2_INFO_BSR:
@ -101,11 +101,11 @@ switch(what)
break;
case PCRE2_INFO_CAPTURECOUNT:
*((int *)where) = re->top_bracket;
*((uint32_t *)where) = re->top_bracket;
break;
case PCRE2_INFO_FIRSTCODETYPE:
*((int *)where) = ((re->flags & PCRE2_FIRSTSET) != 0)? 1 :
*((uint32_t *)where) = ((re->flags & PCRE2_FIRSTSET) != 0)? 1 :
((re->flags & PCRE2_STARTLINE) != 0)? 2 : 0;
break;
@ -120,11 +120,11 @@ switch(what)
break;
case PCRE2_INFO_HASCRORLF:
*((int *)where) = (re->flags & PCRE2_HASCRORLF) != 0;
*((uint32_t *)where) = (re->flags & PCRE2_HASCRORLF) != 0;
break;
case PCRE2_INFO_JCHANGED:
*((int *)where) = (re->flags & PCRE2_JCHANGED) != 0;
*((uint32_t *)where) = (re->flags & PCRE2_JCHANGED) != 0;
break;
case PCRE2_INFO_JITSIZE:
@ -137,7 +137,7 @@ switch(what)
break;
case PCRE2_INFO_LASTCODETYPE:
*((int *)where) = ((re->flags & PCRE2_LASTSET) != 0)? 1 : 0;
*((uint32_t *)where) = ((re->flags & PCRE2_LASTSET) != 0)? 1 : 0;
break;
case PCRE2_INFO_LASTCODEUNIT:
@ -146,7 +146,7 @@ switch(what)
break;
case PCRE2_INFO_MATCHEMPTY:
*((int *)where) = (re->flags & PCRE2_MATCH_EMPTY) != 0;
*((uint32_t *)where) = (re->flags & PCRE2_MATCH_EMPTY) != 0;
break;
case PCRE2_INFO_MATCHLIMIT:
@ -154,19 +154,19 @@ switch(what)
break;
case PCRE2_INFO_MAXLOOKBEHIND:
*((int *)where) = re->max_lookbehind;
*((uint32_t *)where) = re->max_lookbehind;
break;
case PCRE2_INFO_MINLENGTH:
*((int *)where) = re->minlength;
*((uint32_t *)where) = re->minlength;
break;
case PCRE2_INFO_NAMEENTRYSIZE:
*((int *)where) = re->name_entry_size;
*((uint32_t *)where) = re->name_entry_size;
break;
case PCRE2_INFO_NAMECOUNT:
*((int *)where) = re->name_count;
*((uint32_t *)where) = re->name_count;
break;
case PCRE2_INFO_NAMETABLE:

View File

@ -49,8 +49,6 @@ functions work only on 8-bit data. */
#include "pcre2_internal.h"
/* FIXME: this module is incomplete */
/*************************************************
* Compare two zero-terminated PCRE2 strings *
@ -82,7 +80,9 @@ return 0;
* Compare zero-terminated PCRE2 & 8-bit strings *
*************************************************/
/*
/* As the 8-bit string is almost always a literal, its type is specified as
const char *.
Arguments:
str1 first string
str2 second string
@ -136,7 +136,7 @@ return 0;
*************************************************/
/* As the 8-bit string is almost always a literal, its type is specified as
'const char *'.
const char *.
Arguments:
str1 first string
@ -162,7 +162,7 @@ return 0;
/*************************************************
* Find the length of a string *
* Find the length of a PCRE2 string *
*************************************************/
/*

View File

@ -3010,18 +3010,16 @@ if ((pat_patctl.control & CTL_INFO) != 0)
{
const void *nametable;
const uint8_t *start_bits;
int count, backrefmax, first_ctype, last_ctype, jchanged,
hascrorlf, maxlookbehind, match_empty, minlength;
int nameentrysize, namecount;
uint32_t bsr_convention, newline_convention;
uint32_t first_cunit, last_cunit;
uint32_t match_limit, recursion_limit;
uint32_t backrefmax, bsr_convention, capture_count, first_ctype, first_cunit,
hascrorlf, jchanged, last_ctype, last_cunit, match_empty, match_limit,
maxlookbehind, minlength, nameentrysize, namecount, newline_convention,
recursion_limit;
/* These info requests should always succeed. */
if (pattern_info(PCRE2_INFO_BACKREFMAX, &backrefmax) +
pattern_info(PCRE2_INFO_BSR, &bsr_convention) +
pattern_info(PCRE2_INFO_CAPTURECOUNT, &count) +
pattern_info(PCRE2_INFO_CAPTURECOUNT, &capture_count) +
pattern_info(PCRE2_INFO_FIRSTBITMAP, &start_bits) +
pattern_info(PCRE2_INFO_FIRSTCODEUNIT, &first_cunit) +
pattern_info(PCRE2_INFO_FIRSTCODETYPE, &first_ctype) +
@ -3041,7 +3039,7 @@ if ((pat_patctl.control & CTL_INFO) != 0)
!= 0)
return PR_ABEND;
fprintf(outfile, "Capturing subpattern count = %d\n", count);
fprintf(outfile, "Capturing subpattern count = %d\n", capture_count);
if (backrefmax > 0)
fprintf(outfile, "Max back reference = %d\n", backrefmax);
@ -3061,7 +3059,7 @@ if ((pat_patctl.control & CTL_INFO) != 0)
while (namecount-- > 0)
{
int imm2_size = test_mode == PCRE8_MODE ? 2 : 1;
int length = (int)STRLEN(nametable + imm2_size);
uint32_t length = (uint32_t)STRLEN(nametable + imm2_size);
fprintf(outfile, " ");
PCHARSV(nametable, imm2_size, length, FALSE, outfile);
while (length++ < nameentrysize - imm2_size) putc(' ', outfile);
@ -3592,8 +3590,8 @@ if (pat_patctl.jit != 0)
if ((pat_patctl.control & CTL_MEMORY) != 0)
{
int name_count;
size_t size, cblock_size, name_entry_size;
uint32_t name_count, name_entry_size;
size_t size, cblock_size;
#ifdef SUPPORT_PCRE8
if (test_mode == 8) cblock_size = sizeof(pcre2_real_code_8);
@ -4428,9 +4426,10 @@ for (gmatched = 0;; gmatched++)
if ((dat_datctl.control & CTL_ALLCAPTURES) != 0)
{
if (pattern_info(PCRE2_INFO_CAPTURECOUNT, &capcount) < 0)
uint32_t maxcapcount;
if (pattern_info(PCRE2_INFO_CAPTURECOUNT, &maxcapcount) < 0)
return PR_SKIP;
capcount++; /* Allow for full match */
capcount = maxcapcount + 1; /* Allow for full match */
if (capcount > (int)dat_datctl.oveccount) capcount = dat_datctl.oveccount;
}