diff --git a/src/pcre2.h.in b/src/pcre2.h.in index fd41f08..8659e38 100644 --- a/src/pcre2.h.in +++ b/src/pcre2.h.in @@ -271,7 +271,7 @@ typedef const PCRE2_UCHAR8 *PCRE2_SPTR8; typedef const PCRE2_UCHAR16 *PCRE2_SPTR16; typedef const PCRE2_UCHAR32 *PCRE2_SPTR32; -/* The PCRE2_SIZE type is used for all string lengths and offsets in PCRE22, +/* The PCRE2_SIZE type is used for all string lengths and offsets in PCRE2, including pattern offsets for errors and subject offsets after a match. We define special values to indicate zero-terminated strings and unset offsets in the offset vector (ovector). */ @@ -435,18 +435,18 @@ PCRE2_EXP_DECL PCRE2_SIZE pcre2_get_startchar(pcre2_match_data *); #define PCRE2_SUBSTRING_FUNCTIONS \ PCRE2_EXP_DECL int pcre2_substring_copy_byname(pcre2_match_data *, \ - PCRE2_SPTR, PCRE2_UCHAR *, size_t); \ + PCRE2_SPTR, PCRE2_UCHAR *, PCRE2_SIZE *); \ PCRE2_EXP_DECL int pcre2_substring_copy_bynumber(pcre2_match_data *, \ - int, PCRE2_UCHAR *, size_t); \ + int, PCRE2_UCHAR *, PCRE2_SIZE *); \ PCRE2_EXP_DECL void pcre2_substring_free(PCRE2_UCHAR *); \ PCRE2_EXP_DECL int pcre2_substring_get_byname(pcre2_match_data *, \ - PCRE2_SPTR, PCRE2_UCHAR **); \ + PCRE2_SPTR, PCRE2_UCHAR **, PCRE2_SIZE *); \ PCRE2_EXP_DECL int pcre2_substring_get_bynumber(pcre2_match_data *, \ - int, PCRE2_UCHAR **); \ + int, PCRE2_UCHAR **, PCRE2_SIZE *); \ PCRE2_EXP_DECL int pcre2_substring_length_byname(pcre2_match_data *, \ - PCRE2_SPTR); \ + PCRE2_SPTR, PCRE2_SIZE *); \ PCRE2_EXP_DECL int pcre2_substring_length_bynumber(pcre2_match_data *, \ - int); \ + int, PCRE2_SIZE *); \ PCRE2_EXP_DECL int pcre2_substring_nametable_scan(const pcre2_code *, \ PCRE2_SPTR, PCRE2_SPTR *, PCRE2_SPTR *); \ PCRE2_EXP_DECL int pcre2_substring_number_from_name(\ diff --git a/src/pcre2_substring.c b/src/pcre2_substring.c index c7f06ad..bbaf47e 100644 --- a/src/pcre2_substring.c +++ b/src/pcre2_substring.c @@ -59,11 +59,9 @@ Arguments: match_data points to the match data stringname the name of the required substring buffer where to put the substring - size the size of the buffer + sizeptr the size of the buffer, updated to the size of the substring -Returns: if successful: - the length of the copied string, not including the zero - that is put on the end; can be zero +Returns: if successful: zero if not successful, a negative error code: PCRE2_ERROR_NOMEMORY: buffer too small PCRE2_ERROR_NOSUBSTRING: no such captured substring @@ -71,19 +69,19 @@ Returns: if successful: PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_substring_copy_byname(pcre2_match_data *match_data, PCRE2_SPTR stringname, - PCRE2_UCHAR *buffer, size_t size) + PCRE2_UCHAR *buffer, PCRE2_SIZE *sizeptr) { PCRE2_SPTR first; PCRE2_SPTR last; PCRE2_SPTR entry; int entrysize = pcre2_substring_nametable_scan(match_data->code, stringname, &first, &last); -if (entrysize <= 0) return entrysize; +if (entrysize < 0) return entrysize; for (entry = first; entry <= last; entry += entrysize) { uint16_t n = GET2(entry, 0); if (n < match_data->oveccount && match_data->ovector[n*2] != PCRE2_UNSET) - return pcre2_substring_copy_bynumber(match_data, n, buffer, size); + return pcre2_substring_copy_bynumber(match_data, n, buffer, sizeptr); } return PCRE2_ERROR_NOSUBSTRING; } @@ -101,11 +99,9 @@ Arguments: match_data points to the match data stringnumber the number of the required substring buffer where to put the substring - size the size of the buffer + sizeptr the size of the buffer, updated to the size of the substring -Returns: if successful: - the length of the copied string, not including the zero - that is put on the end; can be zero +Returns: if successful: 0 if not successful, a negative error code: PCRE2_ERROR_NOMEMORY: buffer too small PCRE2_ERROR_NOSUBSTRING: no such captured substring @@ -113,20 +109,21 @@ Returns: if successful: PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_substring_copy_bynumber(pcre2_match_data *match_data, int stringnumber, - PCRE2_UCHAR *buffer, size_t size) + PCRE2_UCHAR *buffer, PCRE2_SIZE *sizeptr) { -size_t left, right; -size_t p = 0; +PCRE2_SIZE left, right; +PCRE2_SIZE p = 0; PCRE2_SPTR subject = match_data->subject; if (stringnumber >= match_data->oveccount || stringnumber > match_data->code->top_bracket || (left = match_data->ovector[stringnumber*2]) == PCRE2_UNSET) return PCRE2_ERROR_NOSUBSTRING; right = match_data->ovector[stringnumber*2+1]; -if (right - left + 1 > size) return PCRE2_ERROR_NOMEMORY; +if (right - left + 1 > *sizeptr) return PCRE2_ERROR_NOMEMORY; while (left < right) buffer[p++] = subject[left++]; buffer[p] = 0; -return p; +*sizeptr = p; +return 0; } @@ -143,10 +140,9 @@ Arguments: match_data pointer to match_data stringname the name of the required substring stringptr where to put the pointer to the new memory + sizeptr where to put the length of the substring -Returns: if successful: - the length of the copied string, not including the zero - that is put on the end; can be zero +Returns: if successful: zero if not successful, a negative value: PCRE2_ERROR_NOMEMORY: couldn't get memory PCRE2_ERROR_NOSUBSTRING: no such captured substring @@ -154,19 +150,19 @@ Returns: if successful: PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_substring_get_byname(pcre2_match_data *match_data, - PCRE2_SPTR stringname, PCRE2_UCHAR **stringptr) + PCRE2_SPTR stringname, PCRE2_UCHAR **stringptr, PCRE2_SIZE *sizeptr) { PCRE2_SPTR first; PCRE2_SPTR last; PCRE2_SPTR entry; int entrysize = pcre2_substring_nametable_scan(match_data->code, stringname, &first, &last); -if (entrysize <= 0) return entrysize; +if (entrysize < 0) return entrysize; for (entry = first; entry <= last; entry += entrysize) { uint16_t n = GET2(entry, 0); if (n < match_data->oveccount && match_data->ovector[n*2] != PCRE2_UNSET) - return pcre2_substring_get_bynumber(match_data, n, stringptr); + return pcre2_substring_get_bynumber(match_data, n, stringptr, sizeptr); } return PCRE2_ERROR_NOSUBSTRING; } @@ -184,10 +180,9 @@ Arguments: match_data points to match data stringnumber the number of the required substring stringptr where to put a pointer to the new memory + sizeptr where to put the size of the substring -Returns: if successful: - the length of the string, not including the zero that - is put on the end; can be zero +Returns: if successful: zero if not successful a negative error code: PCRE2_ERROR_NOMEMORY: failed to get memory PCRE2_ERROR_NOSUBSTRING: substring not present @@ -195,10 +190,10 @@ Returns: if successful: PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_substring_get_bynumber(pcre2_match_data *match_data, int stringnumber, - PCRE2_UCHAR **stringptr) + PCRE2_UCHAR **stringptr, PCRE2_SIZE *sizeptr) { -size_t left, right; -size_t p = 0; +PCRE2_SIZE left, right; +PCRE2_SIZE p = 0; void *block; PCRE2_UCHAR *yield; @@ -217,7 +212,8 @@ yield = (PCRE2_UCHAR *)((char *)block + sizeof(pcre2_memctl)); while (left < right) yield[p++] = subject[left++]; yield[p] = 0; *stringptr = yield; -return p; +*sizeptr = p; +return 0; } @@ -250,14 +246,14 @@ permits duplicate names, the first substring that is set is chosen. Arguments: match_data pointer to match data stringname the name of the required substring + sizeptr where to put the length -Returns: a non-negative length if successful - a negative error code otherwise +Returns: 0 if successful, else a negative error number */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_substring_length_byname(pcre2_match_data *match_data, - PCRE2_SPTR stringname) + PCRE2_SPTR stringname, PCRE2_SIZE *sizeptr) { PCRE2_SPTR first; PCRE2_SPTR last; @@ -269,7 +265,7 @@ for (entry = first; entry <= last; entry += entrysize) { uint16_t n = GET2(entry, 0); if (n < match_data->oveccount && match_data->ovector[n*2] != PCRE2_UNSET) - return pcre2_substring_length_bynumber(match_data, n); + return pcre2_substring_length_bynumber(match_data, n, sizeptr); } return PCRE2_ERROR_NOSUBSTRING; } @@ -285,21 +281,22 @@ return PCRE2_ERROR_NOSUBSTRING; Arguments: match_data pointer to match data stringnumber the number of the required substring + sizeptr where to put the length -Returns: a non-negative length if successful - a negative error code otherwise +Returns: 0 if successful, else a negative error number */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_substring_length_bynumber(pcre2_match_data *match_data, - int stringnumber) + int stringnumber, PCRE2_SIZE *sizeptr) { if (stringnumber >= match_data->oveccount || stringnumber > match_data->code->top_bracket || match_data->ovector[stringnumber*2] == PCRE2_UNSET) return PCRE2_ERROR_NOSUBSTRING; -return match_data->ovector[stringnumber*2 + 1] - - match_data->ovector[stringnumber*2]; +*sizeptr = match_data->ovector[stringnumber*2 + 1] - + match_data->ovector[stringnumber*2]; +return 0; } @@ -327,11 +324,11 @@ Returns: if successful: 0 PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_substring_list_get(pcre2_match_data *match_data, PCRE2_UCHAR ***listptr, - size_t **lengthsptr) + PCRE2_SIZE **lengthsptr) { int i, count, count2; -size_t size; -size_t *lensp; +PCRE2_SIZE size; +PCRE2_SIZE *lensp; pcre2_memctl *memp; PCRE2_UCHAR **listp; PCRE2_UCHAR *sp; @@ -341,8 +338,8 @@ if ((count = match_data->rc) < 0) return count; count2 = 2*count; ovector = match_data->ovector; -size = sizeof(pcre2_memctl) + sizeof(PCRE2_UCHAR *); /* For final NULL */ -if (lengthsptr != NULL) size += sizeof(size_t) * count; /* For lengths */ +size = sizeof(pcre2_memctl) + sizeof(PCRE2_UCHAR *); /* For final NULL */ +if (lengthsptr != NULL) size += sizeof(PCRE2_SIZE) * count; /* For lengths */ for (i = 0; i < count2; i += 2) size += sizeof(PCRE2_UCHAR *) + CU2BYTES(ovector[i+1] - ovector[i] + 1); @@ -350,7 +347,7 @@ memp = PRIV(memctl_malloc)(size, (pcre2_memctl *)match_data); if (memp == NULL) return PCRE2_ERROR_NOMEMORY; *listptr = listp = (PCRE2_UCHAR **)((char *)memp + sizeof(pcre2_memctl)); -lensp = (size_t *)((char *)listp + sizeof(PCRE2_UCHAR *) * (count + 1)); +lensp = (PCRE2_SIZE *)((char *)listp + sizeof(PCRE2_UCHAR *) * (count + 1)); if (lengthsptr == NULL) { @@ -360,7 +357,7 @@ if (lengthsptr == NULL) else { *lengthsptr = lensp; - sp = (PCRE2_UCHAR *)((char *)lensp + sizeof(size_t) * count); + sp = (PCRE2_UCHAR *)((char *)lensp + sizeof(PCRE2_SIZE) * count); } for (i = 0; i < count2; i += 2) diff --git a/src/pcre2test.c b/src/pcre2test.c index 5776bbf..954407a 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -877,21 +877,21 @@ are supported. */ pcre2_substring_free_16((PCRE2_UCHAR16 *)a); \ else pcre2_substring_free_32((PCRE2_UCHAR32 *)a) -#define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d) \ +#define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d,e) \ if (test_mode == PCRE8_MODE) \ - a = pcre2_substring_get_byname_8(G(b,8),G(c,8),(PCRE2_UCHAR8 **)d); \ + a = pcre2_substring_get_byname_8(G(b,8),G(c,8),(PCRE2_UCHAR8 **)d,e); \ else if (test_mode == PCRE16_MODE) \ - a = pcre2_substring_get_byname_16(G(b,16),G(c,16),(PCRE2_UCHAR16 **)d); \ + a = pcre2_substring_get_byname_16(G(b,16),G(c,16),(PCRE2_UCHAR16 **)d,e); \ else \ - a = pcre2_substring_get_byname_32(G(b,32),G(c,32),(PCRE2_UCHAR32 **)d) + a = pcre2_substring_get_byname_32(G(b,32),G(c,32),(PCRE2_UCHAR32 **)d,e) -#define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d) \ +#define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d,e) \ if (test_mode == PCRE8_MODE) \ - a = pcre2_substring_get_bynumber_8(G(b,8),c,(PCRE2_UCHAR8 **)d); \ + a = pcre2_substring_get_bynumber_8(G(b,8),c,(PCRE2_UCHAR8 **)d,e); \ else if (test_mode == PCRE16_MODE) \ - a = pcre2_substring_get_bynumber_16(G(b,16),c,(PCRE2_UCHAR16 **)d); \ + a = pcre2_substring_get_bynumber_16(G(b,16),c,(PCRE2_UCHAR16 **)d,e); \ else \ - a = pcre2_substring_get_bynumber_32(G(b,32),c,(PCRE2_UCHAR32 **)d) + a = pcre2_substring_get_bynumber_32(G(b,32),c,(PCRE2_UCHAR32 **)d,e) #define PCRE2_SUBSTRING_LIST_GET(a,b,c,d) \ if (test_mode == PCRE8_MODE) \ @@ -1149,21 +1149,21 @@ the three different cases. */ G(pcre2_substring_free_,BITONE)((G(PCRE2_UCHAR,BITONE) *)a); \ else G(pcre2_substring_free_,BITTWO)((G(PCRE2_UCHAR,BITTWO) *)a) -#define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d) \ +#define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d,e) \ if (test_mode == G(G(PCRE,BITONE),_MODE)) \ a = G(pcre2_substring_get_byname_,BITONE)(G(b,BITONE),G(c,BITONE),\ - (G(PCRE2_UCHAR,BITONE) **)d); \ + (G(PCRE2_UCHAR,BITONE) **)d,e); \ else \ a = G(pcre2_substring_get_byname_,BITTWO)(G(b,BITTWO),G(c,BITTWO),\ - (G(PCRE2_UCHAR,BITTWO) **)d) + (G(PCRE2_UCHAR,BITTWO) **)d,e) -#define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d) \ +#define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d,e) \ if (test_mode == G(G(PCRE,BITONE),_MODE)) \ a = G(pcre2_substring_get_bynumber_,BITONE)(G(b,BITONE),c,\ - (G(PCRE2_UCHAR,BITONE) **)d); \ + (G(PCRE2_UCHAR,BITONE) **)d,e); \ else \ a = G(pcre2_substring_get_bynumber_,BITTWO)(G(b,BITTWO),c,\ - (G(PCRE2_UCHAR,BITTWO) **)d) + (G(PCRE2_UCHAR,BITTWO) **)d,e) #define PCRE2_SUBSTRING_LIST_GET(a,b,c,d) \ if (test_mode == G(G(PCRE,BITONE),_MODE)) \ @@ -1270,10 +1270,10 @@ the three different cases. */ #define PCRE2_SUBSTRING_COPY_BYNUMBER(a,b,c,d,e) \ a = pcre2_substring_copy_bynumber_8(G(b,8),c,(PCRE2_UCHAR8 *)d,e) #define PCRE2_SUBSTRING_FREE(a) pcre2_substring_free_8((PCRE2_UCHAR8 *)a) -#define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d) \ - a = pcre2_substring_get_byname_8(G(b,8),G(c,8),(PCRE2_UCHAR8 **)d) -#define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d) \ - a = pcre2_substring_get_bynumber_8(G(b,8),c,(PCRE2_UCHAR8 **)d) +#define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d,e) \ + a = pcre2_substring_get_byname_8(G(b,8),G(c,8),(PCRE2_UCHAR8 **)d,e) +#define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d,e) \ + a = pcre2_substring_get_bynumber_8(G(b,8),c,(PCRE2_UCHAR8 **)d,e) #define PCRE2_SUBSTRING_LIST_GET(a,b,c,d) \ a = pcre2_substring_list_get_8(G(b,8),(PCRE2_UCHAR8 ***)c,d) #define PCRE2_SUBSTRING_LIST_FREE(a) \ @@ -1329,10 +1329,10 @@ the three different cases. */ #define PCRE2_SUBSTRING_COPY_BYNUMBER(a,b,c,d,e) \ a = pcre2_substring_copy_bynumber_16(G(b,16),c,(PCRE2_UCHAR16 *)d,e) #define PCRE2_SUBSTRING_FREE(a) pcre2_substring_free_16((PCRE2_UCHAR16 *)a) -#define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d) \ - a = pcre2_substring_get_byname_16(G(b,16),G(c,16),(PCRE2_UCHAR16 **)d) -#define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d) \ - a = pcre2_substring_get_bynumber_16(G(b,16),c,(PCRE2_UCHAR16 **)d) +#define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d,e) \ + a = pcre2_substring_get_byname_16(G(b,16),G(c,16),(PCRE2_UCHAR16 **)d,e) +#define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d,e) \ + a = pcre2_substring_get_bynumber_16(G(b,16),c,(PCRE2_UCHAR16 **)d,e) #define PCRE2_SUBSTRING_LIST_GET(a,b,c,d) \ a = pcre2_substring_list_get_16(G(b,16),(PCRE2_UCHAR16 ***)c,d) #define PCRE2_SUBSTRING_LIST_FREE(a) \ @@ -1388,11 +1388,11 @@ the three different cases. */ #define PCRE2_SUBSTRING_COPY_BYNUMBER(a,b,c,d,e) \ a = pcre2_substring_copy_bynumber_32(G(b,32),c,(PCRE2_UCHAR32 *)d,e); #define PCRE2_SUBSTRING_FREE(a) pcre2_substring_free_32((PCRE2_UCHAR32 *)a) -##define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d) \ - a = pcre2_substring_get_byname_32(G(b,32),G(c,32),(PCRE2_UCHAR32 **)d) -define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d) \ +##define PCRE2_SUBSTRING_GET_BYNAME(a,b,c,d,e) \ + a = pcre2_substring_get_byname_32(G(b,32),G(c,32),(PCRE2_UCHAR32 **)d,e) +define PCRE2_SUBSTRING_GET_BYNUMBER(a,b,c,d,e) \ a = pcre2_substring_get_bynumber_32(G(b,32),c,(PCRE2_UCHAR32 **)d) -#define PCRE2_SUBSTRING_LIST_GET(a,b,c,d) \ +#define PCRE2_SUBSTRING_LIST_GET(a,b,c,d,e) \ a = pcre2_substring_list_get_32(G(b,32),(PCRE2_UCHAR32 ***)c,d) #define PCRE2_SUBSTRING_LIST_FREE(a) \ pcre2_substring_list_free_32((PCRE2_SPTR32 *)a) @@ -4543,10 +4543,11 @@ for (gmatched = 0;; gmatched++) for (i = 0; i < MAXCPYGET && dat_datctl.copy_numbers[i] >= 0; i++) { int rc; + PCRE2_SIZE length; uint32_t copybuffer[256]; uint32_t n = (uint32_t)(dat_datctl.copy_numbers[i]); - PCRE2_SUBSTRING_COPY_BYNUMBER(rc, match_data, n, copybuffer, - sizeof(copybuffer)/code_unit_size); + length = sizeof(copybuffer)/code_unit_size; + PCRE2_SUBSTRING_COPY_BYNUMBER(rc, match_data, n, copybuffer, &length); if (rc < 0) { fprintf(outfile, "copy substring %d failed (%d): ", n, rc); @@ -4557,8 +4558,8 @@ for (gmatched = 0;; gmatched++) else { fprintf(outfile, "%2dC ", n); - PCHARSV(copybuffer, 0, rc, utf, outfile); - fprintf(outfile, " (%d)\n", rc); + PCHARSV(copybuffer, 0, length, utf, outfile); + fprintf(outfile, " (%lu)\n", (unsigned long)length); } } @@ -4569,6 +4570,7 @@ for (gmatched = 0;; gmatched++) { int rc; PCRE2_SIZE cnl; + PCRE2_SIZE length; uint32_t copybuffer[256]; int namelen = strlen((const char *)nptr); if (namelen == 0) break; @@ -4584,8 +4586,8 @@ for (gmatched = 0;; gmatched++) if (test_mode == PCRE32_MODE)(void)to32(nptr, utf, &cnl); #endif - PCRE2_SUBSTRING_COPY_BYNAME(rc, match_data, pbuffer, - copybuffer, sizeof(copybuffer)/code_unit_size); + length = sizeof(copybuffer)/code_unit_size; + PCRE2_SUBSTRING_COPY_BYNAME(rc, match_data, pbuffer, copybuffer, &length); if (rc < 0) { fprintf(outfile, "copy substring '%s' failed (%d): ", nptr, rc); @@ -4596,8 +4598,8 @@ for (gmatched = 0;; gmatched++) else { fprintf(outfile, " C "); - PCHARSV(copybuffer, 0, rc, utf, outfile); - fprintf(outfile, " (%d) %s\n", rc, nptr); + PCHARSV(copybuffer, 0, length, utf, outfile); + fprintf(outfile, " (%lu) %s\n", (unsigned long)length, nptr); } nptr += namelen + 1; } @@ -4607,9 +4609,10 @@ for (gmatched = 0;; gmatched++) for (i = 0; i < MAXCPYGET && dat_datctl.get_numbers[i] >= 0; i++) { int rc; + PCRE2_SIZE length; void *gotbuffer; uint32_t n = (uint32_t)(dat_datctl.get_numbers[i]); - PCRE2_SUBSTRING_GET_BYNUMBER(rc, match_data, n, &gotbuffer); + PCRE2_SUBSTRING_GET_BYNUMBER(rc, match_data, n, &gotbuffer, &length); if (rc < 0) { fprintf(outfile, "get substring %d failed (%d): ", n, rc); @@ -4620,8 +4623,8 @@ for (gmatched = 0;; gmatched++) else { fprintf(outfile, "%2dG ", n); - PCHARSV(gotbuffer, 0, rc, utf, outfile); - fprintf(outfile, " (%d)\n", rc); + PCHARSV(gotbuffer, 0, length, utf, outfile); + fprintf(outfile, " (%lu)\n", (unsigned long)length); PCRE2_SUBSTRING_FREE(gotbuffer); } } @@ -4632,6 +4635,7 @@ for (gmatched = 0;; gmatched++) for (;;) { PCRE2_SIZE cnl; + PCRE2_SIZE length; void *gotbuffer; int rc; int namelen = strlen((const char *)nptr); @@ -4648,7 +4652,7 @@ for (gmatched = 0;; gmatched++) if (test_mode == PCRE32_MODE)(void)to32(nptr, utf, &cnl); #endif - PCRE2_SUBSTRING_GET_BYNAME(rc, match_data, pbuffer, &gotbuffer); + PCRE2_SUBSTRING_GET_BYNAME(rc, match_data, pbuffer, &gotbuffer, &length); if (rc < 0) { fprintf(outfile, "get substring '%s' failed (%d): ", nptr, rc); @@ -4659,8 +4663,8 @@ for (gmatched = 0;; gmatched++) else { fprintf(outfile, " G "); - PCHARSV(gotbuffer, 0, rc, utf, outfile); - fprintf(outfile, " (%d) %s\n", rc, nptr); + PCHARSV(gotbuffer, 0, length, utf, outfile); + fprintf(outfile, " (%lu) %s\n", (unsigned long)length, nptr); PCRE2_SUBSTRING_FREE(gotbuffer); } nptr += namelen + 1; @@ -4672,7 +4676,7 @@ for (gmatched = 0;; gmatched++) { int rc; void **stringlist; - size_t *lengths; + PCRE2_SIZE *lengths; PCRE2_SUBSTRING_LIST_GET(rc, match_data, &stringlist, &lengths); if (rc < 0) {