[BACK]Return to regsub.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/regsub.c between version 1.3 and 1.4

version 1.3, 2019/11/24 18:37:23 version 1.4, 2019/11/27 20:54:30
Line 77 
Line 77 
         end = strlen(text);          end = strlen(text);
   
         while (start <= end) {          while (start <= end) {
                 m[0].rm_so = start;                  if (regexec(&r, text + start, nitems(m), m, 0) != 0) {
                 m[0].rm_eo = end;  
   
                 if (regexec(&r, text, nitems(m), m, REG_STARTEND) != 0) {  
                         regsub_copy(&buf, &len, text, start, end);                          regsub_copy(&buf, &len, text, start, end);
                         break;                          break;
                 }                  }
Line 89 
Line 86 
                  * Append any text not part of this match (from the end of the                   * Append any text not part of this match (from the end of the
                  * last match).                   * last match).
                  */                   */
                 regsub_copy(&buf, &len, text, last, m[0].rm_so);                  regsub_copy(&buf, &len, text, last, m[0].rm_so + start);
   
                 /*                  /*
                  * If the last match was empty and this one isn't (it is either                   * If the last match was empty and this one isn't (it is either
                  * later or has matched text), expand this match. If it is                   * later or has matched text), expand this match. If it is
                  * empty, move on one character and try again from there.                   * empty, move on one character and try again from there.
                  */                   */
                 if (empty || m[0].rm_so != last || m[0].rm_so != m[0].rm_eo) {                  if (empty ||
                         regsub_expand(&buf, &len, with, text, m, nitems(m));                      start + m[0].rm_so != last ||
                       m[0].rm_so != m[0].rm_eo) {
                           regsub_expand(&buf, &len, with, text + start, m,
                               nitems(m));
   
                         last = m[0].rm_eo;                          last = start + m[0].rm_eo;
                         start = m[0].rm_eo;                          start += m[0].rm_eo;
                         empty = 0;                          empty = 0;
                 } else {                  } else {
                         last = m[0].rm_eo;                          last = start + m[0].rm_eo;
                         start = m[0].rm_eo + 1;                          start += m[0].rm_eo + 1;
                         empty = 1;                          empty = 1;
                 }                  }
   

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4