comparison src/xdiff/xdiffi.c @ 14730:193471015e1a v8.1.0377

patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions commit https://github.com/vim/vim/commit/42335f50bc6fac444a8af74c81df8369d722a6fb Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 13 15:33:43 2018 +0200 patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions Problem: Xdiff doesn't use the Vim memory allocation functions. Solution: Change the xdl_ defines. Check for out-of-memory. Rename "ignored" to "vim_ignored".
author Christian Brabandt <cb@256bit.org>
date Thu, 13 Sep 2018 15:45:05 +0200
parents 195e8b1fcbbf
children 3be01cf0a632
comparison
equal deleted inserted replaced
14729:7cb784c3b08f 14730:193471015e1a
390 rec2->ptr, rec2->size, 390 rec2->ptr, rec2->size,
391 flags)); 391 flags));
392 } 392 }
393 393
394 /* 394 /*
395 * If a line is indented more than this, get_indent() just returns this value. 395 * If a line is indented more than this, xget_indent() just returns this value.
396 * This avoids having to do absurd amounts of work for data that are not 396 * This avoids having to do absurd amounts of work for data that are not
397 * human-readable text, and also ensures that the output of get_indent fits within 397 * human-readable text, and also ensures that the output of xget_indent fits within
398 * an int. 398 * an int.
399 */ 399 */
400 #define MAX_INDENT 200 400 #define MAX_INDENT 200
401 401
402 /* 402 /*
403 * Return the amount of indentation of the specified line, treating TAB as 8 403 * Return the amount of indentation of the specified line, treating TAB as 8
404 * columns. Return -1 if line is empty or contains only whitespace. Clamp the 404 * columns. Return -1 if line is empty or contains only whitespace. Clamp the
405 * output value at MAX_INDENT. 405 * output value at MAX_INDENT.
406 */ 406 */
407 static int get_indent(xrecord_t *rec) 407 static int xget_indent(xrecord_t *rec)
408 { 408 {
409 long i; 409 long i;
410 int ret = 0; 410 int ret = 0;
411 411
412 for (i = 0; i < rec->size; i++) { 412 for (i = 0; i < rec->size; i++) {
490 if (split >= xdf->nrec) { 490 if (split >= xdf->nrec) {
491 m->end_of_file = 1; 491 m->end_of_file = 1;
492 m->indent = -1; 492 m->indent = -1;
493 } else { 493 } else {
494 m->end_of_file = 0; 494 m->end_of_file = 0;
495 m->indent = get_indent(xdf->recs[split]); 495 m->indent = xget_indent(xdf->recs[split]);
496 } 496 }
497 497
498 m->pre_blank = 0; 498 m->pre_blank = 0;
499 m->pre_indent = -1; 499 m->pre_indent = -1;
500 for (i = split - 1; i >= 0; i--) { 500 for (i = split - 1; i >= 0; i--) {
501 m->pre_indent = get_indent(xdf->recs[i]); 501 m->pre_indent = xget_indent(xdf->recs[i]);
502 if (m->pre_indent != -1) 502 if (m->pre_indent != -1)
503 break; 503 break;
504 m->pre_blank += 1; 504 m->pre_blank += 1;
505 if (m->pre_blank == MAX_BLANKS) { 505 if (m->pre_blank == MAX_BLANKS) {
506 m->pre_indent = 0; 506 m->pre_indent = 0;
509 } 509 }
510 510
511 m->post_blank = 0; 511 m->post_blank = 0;
512 m->post_indent = -1; 512 m->post_indent = -1;
513 for (i = split + 1; i < xdf->nrec; i++) { 513 for (i = split + 1; i < xdf->nrec; i++) {
514 m->post_indent = get_indent(xdf->recs[i]); 514 m->post_indent = xget_indent(xdf->recs[i]);
515 if (m->post_indent != -1) 515 if (m->post_indent != -1)
516 break; 516 break;
517 m->post_blank += 1; 517 m->post_blank += 1;
518 if (m->post_blank == MAX_BLANKS) { 518 if (m->post_blank == MAX_BLANKS) {
519 m->post_indent = 0; 519 m->post_indent = 0;