aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/diff.c
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-06-13 22:20:06 +0100
committerGitHub <noreply@github.com>2024-06-14 05:20:06 +0800
commit43d8435cf84468e776e0a6a98d05ae7bd62583b7 (patch)
treea298243e08d6a29961464e52167d7736a875f477 /src/nvim/diff.c
parent6589d058943405a688b9a3bba11d1869a7d318f8 (diff)
downloadrneovim-43d8435cf84468e776e0a6a98d05ae7bd62583b7.tar.gz
rneovim-43d8435cf84468e776e0a6a98d05ae7bd62583b7.tar.bz2
rneovim-43d8435cf84468e776e0a6a98d05ae7bd62583b7.zip
revert: "refactor: use S_LEN macro" (#29319)
revert: "refactor: use S_LEN(s) instead of s, n (#29219)" This reverts commit c37695a5d5f2e8914fff86f3581bed70b4c85d3c.
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r--src/nvim/diff.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 750f0c3525..0fe1729029 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1020,7 +1020,7 @@ static int check_external_diff(diffio_T *diffio)
if (fd == NULL) {
io_error = true;
} else {
- if (fwrite(S_LEN("line1\n"), 1, fd) != 1) {
+ if (fwrite("line1\n", 6, 1, fd) != 1) {
io_error = true;
}
fclose(fd);
@@ -1029,7 +1029,7 @@ static int check_external_diff(diffio_T *diffio)
if (fd == NULL) {
io_error = true;
} else {
- if (fwrite(S_LEN("line2\n"), 1, fd) != 1) {
+ if (fwrite("line2\n", 6, 1, fd) != 1) {
io_error = true;
}
fclose(fd);
@@ -1050,8 +1050,8 @@ static int check_external_diff(diffio_T *diffio)
break;
}
- if (strncmp(linebuf, S_LEN("1c1")) == 0
- || strncmp(linebuf, S_LEN("@@ -1 +1 @@")) == 0) {
+ if (strncmp(linebuf, "1c1", 3) == 0
+ || strncmp(linebuf, "@@ -1 +1 @@", 11) == 0) {
ok = kTrue;
}
}
@@ -1583,13 +1583,13 @@ static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle)
// @@ -1,3 +1,5 @@
if (isdigit((uint8_t)(*line))) {
*diffstyle = DIFF_ED;
- } else if ((strncmp(line, S_LEN("@@ ")) == 0)) {
+ } else if ((strncmp(line, "@@ ", 3) == 0)) {
*diffstyle = DIFF_UNIFIED;
- } else if ((strncmp(line, S_LEN("--- ")) == 0)
+ } else if ((strncmp(line, "--- ", 4) == 0)
&& (vim_fgets(line, LBUFLEN, fd) == 0)
- && (strncmp(line, S_LEN("+++ ")) == 0)
+ && (strncmp(line, "+++ ", 4) == 0)
&& (vim_fgets(line, LBUFLEN, fd) == 0)
- && (strncmp(line, S_LEN("@@ ")) == 0)) {
+ && (strncmp(line, "@@ ", 3) == 0)) {
*diffstyle = DIFF_UNIFIED;
} else {
// Format not recognized yet, skip over this line. Cygwin diff
@@ -1607,7 +1607,7 @@ static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle)
}
} else {
assert(*diffstyle == DIFF_UNIFIED);
- if (strncmp(line, S_LEN("@@ ")) != 0) {
+ if (strncmp(line, "@@ ", 3) != 0) {
continue; // not the start of a diff block
}
if (parse_diff_unified(line, hunk) == FAIL) {
@@ -2473,70 +2473,70 @@ int diffopt_changed(void)
char *p = p_dip;
while (*p != NUL) {
// Note: Keep this in sync with p_dip_values
- if (strncmp(p, S_LEN("filler")) == 0) {
+ if (strncmp(p, "filler", 6) == 0) {
p += 6;
diff_flags_new |= DIFF_FILLER;
- } else if ((strncmp(p, S_LEN("context:")) == 0) && ascii_isdigit(p[8])) {
+ } else if ((strncmp(p, "context:", 8) == 0) && ascii_isdigit(p[8])) {
p += 8;
diff_context_new = getdigits_int(&p, false, diff_context_new);
- } else if (strncmp(p, S_LEN("iblank")) == 0) {
+ } else if (strncmp(p, "iblank", 6) == 0) {
p += 6;
diff_flags_new |= DIFF_IBLANK;
- } else if (strncmp(p, S_LEN("icase")) == 0) {
+ } else if (strncmp(p, "icase", 5) == 0) {
p += 5;
diff_flags_new |= DIFF_ICASE;
- } else if (strncmp(p, S_LEN("iwhiteall")) == 0) {
+ } else if (strncmp(p, "iwhiteall", 9) == 0) {
p += 9;
diff_flags_new |= DIFF_IWHITEALL;
- } else if (strncmp(p, S_LEN("iwhiteeol")) == 0) {
+ } else if (strncmp(p, "iwhiteeol", 9) == 0) {
p += 9;
diff_flags_new |= DIFF_IWHITEEOL;
- } else if (strncmp(p, S_LEN("iwhite")) == 0) {
+ } else if (strncmp(p, "iwhite", 6) == 0) {
p += 6;
diff_flags_new |= DIFF_IWHITE;
- } else if (strncmp(p, S_LEN("horizontal")) == 0) {
+ } else if (strncmp(p, "horizontal", 10) == 0) {
p += 10;
diff_flags_new |= DIFF_HORIZONTAL;
- } else if (strncmp(p, S_LEN("vertical")) == 0) {
+ } else if (strncmp(p, "vertical", 8) == 0) {
p += 8;
diff_flags_new |= DIFF_VERTICAL;
- } else if ((strncmp(p, S_LEN("foldcolumn:")) == 0) && ascii_isdigit(p[11])) {
+ } else if ((strncmp(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) {
p += 11;
diff_foldcolumn_new = getdigits_int(&p, false, diff_foldcolumn_new);
- } else if (strncmp(p, S_LEN("hiddenoff")) == 0) {
+ } else if (strncmp(p, "hiddenoff", 9) == 0) {
p += 9;
diff_flags_new |= DIFF_HIDDEN_OFF;
- } else if (strncmp(p, S_LEN("closeoff")) == 0) {
+ } else if (strncmp(p, "closeoff", 8) == 0) {
p += 8;
diff_flags_new |= DIFF_CLOSE_OFF;
- } else if (strncmp(p, S_LEN("followwrap")) == 0) {
+ } else if (strncmp(p, "followwrap", 10) == 0) {
p += 10;
diff_flags_new |= DIFF_FOLLOWWRAP;
- } else if (strncmp(p, S_LEN("indent-heuristic")) == 0) {
+ } else if (strncmp(p, "indent-heuristic", 16) == 0) {
p += 16;
diff_indent_heuristic = XDF_INDENT_HEURISTIC;
- } else if (strncmp(p, S_LEN("internal")) == 0) {
+ } else if (strncmp(p, "internal", 8) == 0) {
p += 8;
diff_flags_new |= DIFF_INTERNAL;
- } else if (strncmp(p, S_LEN("algorithm:")) == 0) {
+ } else if (strncmp(p, "algorithm:", 10) == 0) {
// Note: Keep this in sync with p_dip_algorithm_values.
p += 10;
- if (strncmp(p, S_LEN("myers")) == 0) {
+ if (strncmp(p, "myers", 5) == 0) {
p += 5;
diff_algorithm_new = 0;
- } else if (strncmp(p, S_LEN("minimal")) == 0) {
+ } else if (strncmp(p, "minimal", 7) == 0) {
p += 7;
diff_algorithm_new = XDF_NEED_MINIMAL;
- } else if (strncmp(p, S_LEN("patience")) == 0) {
+ } else if (strncmp(p, "patience", 8) == 0) {
p += 8;
diff_algorithm_new = XDF_PATIENCE_DIFF;
- } else if (strncmp(p, S_LEN("histogram")) == 0) {
+ } else if (strncmp(p, "histogram", 9) == 0) {
p += 9;
diff_algorithm_new = XDF_HISTOGRAM_DIFF;
} else {
return FAIL;
}
- } else if ((strncmp(p, S_LEN("linematch:")) == 0) && ascii_isdigit(p[10])) {
+ } else if ((strncmp(p, "linematch:", 10) == 0) && ascii_isdigit(p[10])) {
p += 10;
linematch_lines_new = getdigits_int(&p, false, linematch_lines_new);
diff_flags_new |= DIFF_LINEMATCH;