Changeset 588 for trunk/src/sh_string.c


Ignore:
Timestamp:
Oct 26, 2025, 12:17:47 PM (16 hours ago)
Author:
katerina
Message:

Fix for ticket #476 (move logfile monitoring module from PCRE to PCRE2).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_string.c

    r587 r588  
    546546 * of field, offset of first char after field (this is how
    547547 * the pcre library does it).
    548  */ 
     548 */
     549#define IS_PCRE2_UNSET           (~(size_t)0)
     550
    549551sh_string * sh_string_replace(const sh_string * s,
    550                               const int * ovector, int ovecnum,
     552                              const size_t * ovector, int ovecnum,
    551553                              const char * replacement, size_t rlen)
    552554{
     
    604606  for (i = 0; i < ovecnum; ++i)
    605607    {
    606       if (ovector[2*i] >= 0)
     608      if (ovector[2*i] != IS_PCRE2_UNSET)
    607609        {
    608610          curr = 2*i;
     
    611613    }
    612614 
    613   if (r && ovecnum > 0 && ovector[curr] >= 0)
     615  if (r && ovecnum > 0 && ovector[curr] != IS_PCRE2_UNSET)
    614616    {
    615617      r->len = 0; r->str[0] = '\0'; p = r->str;
     
    617619      /* First part, until start of first replacement
    618620       */
    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]);
    621623        p += ovector[curr];
    622624        r->len += ovector[curr];
     
    633635      for (i = 1; i < ovecnum; ++i)
    634636        {
    635           if (ovector[2*i] < 0)
     637          if (ovector[2*i] == IS_PCRE2_UNSET)
    636638            continue;
    637639
     
    704706  size_t lengths[16];
    705707  unsigned int iarr;
    706   int ovector[16];
     708  size_t ovector[16];
    707709  int ovecnum;
    708710
Note: See TracChangeset for help on using the changeset viewer.