Changeset 588 for trunk/src/sh_string.c
- Timestamp:
- Oct 26, 2025, 12:17:47 PM (16 hours ago)
- File:
-
- 1 edited
-
trunk/src/sh_string.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_string.c
r587 r588 546 546 * of field, offset of first char after field (this is how 547 547 * the pcre library does it). 548 */ 548 */ 549 #define IS_PCRE2_UNSET (~(size_t)0) 550 549 551 sh_string * sh_string_replace(const sh_string * s, 550 const int * ovector, int ovecnum,552 const size_t * ovector, int ovecnum, 551 553 const char * replacement, size_t rlen) 552 554 { … … 604 606 for (i = 0; i < ovecnum; ++i) 605 607 { 606 if (ovector[2*i] >= 0)608 if (ovector[2*i] != IS_PCRE2_UNSET) 607 609 { 608 610 curr = 2*i; … … 611 613 } 612 614 613 if (r && ovecnum > 0 && ovector[curr] >= 0)615 if (r && ovecnum > 0 && ovector[curr] != IS_PCRE2_UNSET) 614 616 { 615 617 r->len = 0; r->str[0] = '\0'; p = r->str; … … 617 619 /* First part, until start of first replacement 618 620 */ 619 if (r->siz > (unsigned int)ovector[curr]) {620 memcpy(p, s->str, (size_t)ovector[curr]);621 if (r->siz > ovector[curr]) { 622 memcpy(p, s->str, ovector[curr]); 621 623 p += ovector[curr]; 622 624 r->len += ovector[curr]; … … 633 635 for (i = 1; i < ovecnum; ++i) 634 636 { 635 if (ovector[2*i] < 0)637 if (ovector[2*i] == IS_PCRE2_UNSET) 636 638 continue; 637 639 … … 704 706 size_t lengths[16]; 705 707 unsigned int iarr; 706 int ovector[16];708 size_t ovector[16]; 707 709 int ovecnum; 708 710
Note:
See TracChangeset
for help on using the changeset viewer.