]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
Merge branch 'xdiff-new' into xdiff-upstream-v2.52.0
authorYee Cheng Chin <ychin.git@gmail.com>
Tue, 18 Nov 2025 00:26:15 +0000 (16:26 -0800)
committerYee Cheng Chin <ychin.git@gmail.com>
Tue, 18 Nov 2025 05:00:22 +0000 (21:00 -0800)
1  2 
src/xdiff/xdiff.h
src/xdiff/xdiffi.c
src/xdiff/xdiffi.h
src/xdiff/xemit.c
src/xdiff/xhistogram.c
src/xdiff/xinclude.h
src/xdiff/xpatience.c
src/xdiff/xprepare.c
src/xdiff/xtypes.h
src/xdiff/xutils.c
src/xdiff/xutils.h

index a9169d30ce96964900d943e740290ec13ec5adda,2cecde5afe5da1623a5ddb0e6affb7cea259b5c7..1f8681b456bb23e1335063856eaa7b07a4878907
@@@ -82,12 -82,10 +82,12 @@@ typedef struct s_xpparam 
        unsigned long flags;
  
        /* -I<regex> */
 + #if 0  // unused by Vim
        regex_t **ignore_regex;
        size_t ignore_regex_nr;
 +#endif
  
-       /* See Documentation/diff-options.txt. */
+       /* See Documentation/diff-options.adoc. */
        char **anchors;
        size_t anchors_nr;
  } xpparam_t;
index 5a6f0cdcd3a13b6f667093d8bf9afdf5e4dcc1b8,6f3998ee54c01e9ed2572877cff2244620b70930..fe6b5cda6f390ee447be23095b28817a64c1dcf2
@@@ -497,13 -489,13 +489,13 @@@ static void measure_split(const xdfile_
                m->indent = -1;
        } else {
                m->end_of_file = 0;
-               m->indent = xget_indent(xdf->recs[split]);
 -              m->indent = get_indent(&xdf->recs[split]);
++              m->indent = xget_indent(&xdf->recs[split]);
        }
  
        m->pre_blank = 0;
        m->pre_indent = -1;
        for (i = split - 1; i >= 0; i--) {
-               m->pre_indent = xget_indent(xdf->recs[i]);
 -              m->pre_indent = get_indent(&xdf->recs[i]);
++              m->pre_indent = xget_indent(&xdf->recs[i]);
                if (m->pre_indent != -1)
                        break;
                m->pre_blank += 1;
        m->post_blank = 0;
        m->post_indent = -1;
        for (i = split + 1; i < xdf->nrec; i++) {
-               m->post_indent = xget_indent(xdf->recs[i]);
 -              m->post_indent = get_indent(&xdf->recs[i]);
++              m->post_indent = xget_indent(&xdf->recs[i]);
                if (m->post_indent != -1)
                        break;
                m->post_blank += 1;
@@@ -794,12 -786,6 +786,12 @@@ static int group_slide_up(xdfile_t *xdf
        }
  }
  
- static void xdl_bug(const char *msg)
++void xdl_bug(const char *msg)
 +{
 +      fprintf(stderr, "BUG: %s\n", msg);
 +      exit(1);
 +}
 +
  /*
   * Move back and forward change groups for a consistent and pretty diff output.
   * This also helps in finding joinable change groups and reducing the diff
@@@ -1017,10 -1003,9 +1009,10 @@@ static void xdl_mark_ignorable_lines(xd
        }
  }
  
 +#if 0 // unused by Vim
  static int record_matches_regex(xrecord_t *rec, xpparam_t const *xpp) {
        regmatch_t regmatch;
-       int i;
+       size_t i;
  
        for (i = 0; i < xpp->ignore_regex_nr; i++)
                if (!regexec_buf(xpp->ignore_regex[i], rec->ptr, rec->size, 1,
Simple merge
index 585ca541354aa9a9c9c0e25fb310ec77a3796aeb,b2f1f30cd36eef9aede1d7c208145c7f02476793..94d61a96157734be96c230b2ea368e51955a9c6a
  
  #include "xinclude.h"
  
- static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec) {
  
-       *rec = xdf->recs[ri]->ptr;
-       return xdf->recs[ri]->size;
- }
- static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb) {
-       long size, psize = (long)strlen(pre);
-       char const *rec;
-       size = xdl_get_rec(xdf, ri, &rec);
-       if (xdl_emit_diffrec(rec, size, pre, psize, ecb) < 0) {
+ static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb)
+ {
+       xrecord_t *rec = &xdf->recs[ri];
  
 -      if (xdl_emit_diffrec(rec->ptr, rec->size, pre, strlen(pre), ecb) < 0)
++      if (xdl_emit_diffrec(rec->ptr, rec->size, pre, (long)strlen(pre), ecb) < 0)
                return -1;
-       }
  
        return 0;
  }
  
++#define signed_add_overflows(a, b) \
++    ((b) > LONG_MAX - (a))
++
+ static long saturating_add(long a, long b)
+ {
+       return signed_add_overflows(a, b) ? LONG_MAX : a + b;
+ }
++#undef signed_add_overflows
 +
  /*
   * Starting at the passed change atom, find the latest change atom to be included
   * inside the differential hunk according to the specified configuration.
@@@ -117,15 -110,13 +118,15 @@@ static long def_ff(const char *rec, lon
  static long match_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri,
                           char *buf, long sz)
  {
-       const char *rec;
-       long len = xdl_get_rec(xdf, ri, &rec);
+       xrecord_t *rec = &xdf->recs[ri];
        if (!xecfg->find_func)
-               return def_ff(rec, len, buf, sz);
-       return xecfg->find_func(rec, len, buf, sz, xecfg->find_func_priv);
+               return def_ff(rec->ptr, rec->size, buf, sz);
+       return xecfg->find_func(rec->ptr, rec->size, buf, sz, xecfg->find_func_priv);
  }
 +#endif
  
 +#if 0
  static int is_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri)
  {
        char dummy[1];
@@@ -158,21 -147,16 +159,19 @@@ static long get_func_line(xdfenv_t *xe
        }
        return -1;
  }
 +#endif
  
 +#if 0
  static int is_empty_rec(xdfile_t *xdf, long ri)
  {
-       const char *rec;
-       long len = xdl_get_rec(xdf, ri, &rec);
+       xrecord_t *rec = &xdf->recs[ri];
+       long i = 0;
  
-       while (len > 0 && XDL_ISSPACE(*rec)) {
-               rec++;
-               len--;
-       }
-       return !len;
+       for (; i < rec->size && XDL_ISSPACE(rec->ptr[i]); i++);
+       return i == rec->size;
  }
 +#endif
  
  int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
                  xdemitconf_t const *xecfg) {
Simple merge
index 1e0fbbaaa80342630e3e5c7c35d3bf2a972e24f5,a4285ac0eb2840fb3d128b81ab4e19ca3fa673ae..776cb5e13ef9fe0c044b3823964c5d8ee75d0083
   *
   */
  
 +// The following includes come from Vim:
 +
 +// defines HAVE_ATTRIBUTE_UNUSED
 +#ifdef HAVE_CONFIG_H
 +# ifdef VMS
 +#  include "config.h"
 +# else
 +#  include "../auto/config.h"
 +# endif
 +#endif
 +
 +// Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter
 +// can be used to check for mistakes.
 +#if defined(HAVE_ATTRIBUTE_UNUSED) || defined(__MINGW32__)
 +# define UNUSED __attribute__((unused))
 +#else
 +# define UNUSED
 +#endif
 +
 +#if defined(_MSC_VER)
 +# define inline __inline
 +#endif
 +
++// Vim replacement for BUG()
++void xdl_bug(const char *msg);
++
  #if !defined(XINCLUDE_H)
  #define XINCLUDE_H
  
Simple merge
index c84549f6c5089ea08c7bc1daad3ef57dd3fceb77,192334f1b72e630dba7e9400dc4741d2c07cff9a..7f6c80f348296ac4b6dc55762ad3e0154cbad41c
@@@ -317,40 -210,47 +210,47 @@@ static bool xdl_clean_mmatch(uint8_t co
  
        /*
         * Scans the lines before 'i' to find a run of lines that either
-        * have no match (dis[j] == 0) or have multiple matches (dis[j] > 1).
-        * Note that we always call this function with dis[i] > 1, so the
-        * current line (i) is already a multimatch line.
+        * have no match (action[j] == DISCARD) or have multiple matches
+        * (action[j] == INVESTIGATE). Note that we always call this
+        * function with action[i] == INVESTIGATE, so the current line
+        * (i) is already a multimatch line.
         */
        for (r = 1, rdis0 = 0, rpdis0 = 1; (i - r) >= s; r++) {
-               if (!dis[i - r])
+               if (action[i - r] == DISCARD)
                        rdis0++;
-               else if (dis[i - r] == 2)
+               else if (action[i - r] == INVESTIGATE)
                        rpdis0++;
-               else
+               else if (action[i - r] == KEEP)
                        break;
 -                      BUG("Illegal value for action[i - r]");
+               else
++                      xdl_bug("Illegal value for action[i - r]");
        }
        /*
-        * If the run before the line 'i' found only multimatch lines, we
-        * return 0 and hence we don't make the current line (i) discarded.
-        * We want to discard multimatch lines only when they appear in the
-        * middle of runs with nomatch lines (dis[j] == 0).
+        * If the run before the line 'i' found only multimatch lines,
+        * we return false and hence we don't make the current line (i)
+        * discarded. We want to discard multimatch lines only when
+        * they appear in the middle of runs with nomatch lines
+        * (action[j] == DISCARD).
         */
        if (rdis0 == 0)
                return 0;
        for (r = 1, rdis1 = 0, rpdis1 = 1; (i + r) <= e; r++) {
-               if (!dis[i + r])
+               if (action[i + r] == DISCARD)
                        rdis1++;
-               else if (dis[i + r] == 2)
+               else if (action[i + r] == INVESTIGATE)
                        rpdis1++;
-               else
+               else if (action[i + r] == KEEP)
                        break;
 -                      BUG("Illegal value for action[i + r]");
+               else
++                      xdl_bug("Illegal value for action[i + r]");
        }
        /*
-        * If the run after the line 'i' found only multimatch lines, we
-        * return 0 and hence we don't make the current line (i) discarded.
+        * If the run after the line 'i' found only multimatch lines,
+        * we return false and hence we don't make the current line (i)
+        * discarded.
         */
        if (rdis1 == 0)
-               return 0;
+               return false;
        rdis1 += rdis0;
        rpdis1 += rpdis0;
  
Simple merge
Simple merge
Simple merge