diff options
author | James <89495599+IAKOBVS@users.noreply.github.com> | 2024-06-11 22:40:24 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-11 16:40:24 +0100 |
commit | c37695a5d5f2e8914fff86f3581bed70b4c85d3c (patch) | |
tree | 89c5f523768f3fe31a938e497fb7ff9657049e4b /src/nvim/diff.c | |
parent | 44410d063ad23544f87d1c8a553de336ae7939d8 (diff) | |
download | rneovim-c37695a5d5f2e8914fff86f3581bed70b4c85d3c.tar.gz rneovim-c37695a5d5f2e8914fff86f3581bed70b4c85d3c.tar.bz2 rneovim-c37695a5d5f2e8914fff86f3581bed70b4c85d3c.zip |
refactor: use S_LEN(s) instead of s, n (#29219)
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r-- | src/nvim/diff.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 54335fc93e..e24c39e60c 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("line1\n", 6, 1, fd) != 1) { + if (fwrite(S_LEN("line1\n"), 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("line2\n", 6, 1, fd) != 1) { + if (fwrite(S_LEN("line2\n"), 1, fd) != 1) { io_error = true; } fclose(fd); @@ -1050,8 +1050,8 @@ static int check_external_diff(diffio_T *diffio) break; } - if (strncmp(linebuf, "1c1", 3) == 0 - || strncmp(linebuf, "@@ -1 +1 @@", 11) == 0) { + if (strncmp(linebuf, S_LEN("1c1")) == 0 + || strncmp(linebuf, S_LEN("@@ -1 +1 @@")) == 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, "@@ ", 3) == 0)) { + } else if ((strncmp(line, S_LEN("@@ ")) == 0)) { *diffstyle = DIFF_UNIFIED; - } else if ((strncmp(line, "--- ", 4) == 0) + } else if ((strncmp(line, S_LEN("--- ")) == 0) && (vim_fgets(line, LBUFLEN, fd) == 0) - && (strncmp(line, "+++ ", 4) == 0) + && (strncmp(line, S_LEN("+++ ")) == 0) && (vim_fgets(line, LBUFLEN, fd) == 0) - && (strncmp(line, "@@ ", 3) == 0)) { + && (strncmp(line, S_LEN("@@ ")) == 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, "@@ ", 3) != 0) { + if (strncmp(line, S_LEN("@@ ")) != 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, "filler", 6) == 0) { + if (strncmp(p, S_LEN("filler")) == 0) { p += 6; diff_flags_new |= DIFF_FILLER; - } else if ((strncmp(p, "context:", 8) == 0) && ascii_isdigit(p[8])) { + } else if ((strncmp(p, S_LEN("context:")) == 0) && ascii_isdigit(p[8])) { p += 8; diff_context_new = getdigits_int(&p, false, diff_context_new); - } else if (strncmp(p, "iblank", 6) == 0) { + } else if (strncmp(p, S_LEN("iblank")) == 0) { p += 6; diff_flags_new |= DIFF_IBLANK; - } else if (strncmp(p, "icase", 5) == 0) { + } else if (strncmp(p, S_LEN("icase")) == 0) { p += 5; diff_flags_new |= DIFF_ICASE; - } else if (strncmp(p, "iwhiteall", 9) == 0) { + } else if (strncmp(p, S_LEN("iwhiteall")) == 0) { p += 9; diff_flags_new |= DIFF_IWHITEALL; - } else if (strncmp(p, "iwhiteeol", 9) == 0) { + } else if (strncmp(p, S_LEN("iwhiteeol")) == 0) { p += 9; diff_flags_new |= DIFF_IWHITEEOL; - } else if (strncmp(p, "iwhite", 6) == 0) { + } else if (strncmp(p, S_LEN("iwhite")) == 0) { p += 6; diff_flags_new |= DIFF_IWHITE; - } else if (strncmp(p, "horizontal", 10) == 0) { + } else if (strncmp(p, S_LEN("horizontal")) == 0) { p += 10; diff_flags_new |= DIFF_HORIZONTAL; - } else if (strncmp(p, "vertical", 8) == 0) { + } else if (strncmp(p, S_LEN("vertical")) == 0) { p += 8; diff_flags_new |= DIFF_VERTICAL; - } else if ((strncmp(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) { + } else if ((strncmp(p, S_LEN("foldcolumn:")) == 0) && ascii_isdigit(p[11])) { p += 11; diff_foldcolumn_new = getdigits_int(&p, false, diff_foldcolumn_new); - } else if (strncmp(p, "hiddenoff", 9) == 0) { + } else if (strncmp(p, S_LEN("hiddenoff")) == 0) { p += 9; diff_flags_new |= DIFF_HIDDEN_OFF; - } else if (strncmp(p, "closeoff", 8) == 0) { + } else if (strncmp(p, S_LEN("closeoff")) == 0) { p += 8; diff_flags_new |= DIFF_CLOSE_OFF; - } else if (strncmp(p, "followwrap", 10) == 0) { + } else if (strncmp(p, S_LEN("followwrap")) == 0) { p += 10; diff_flags_new |= DIFF_FOLLOWWRAP; - } else if (strncmp(p, "indent-heuristic", 16) == 0) { + } else if (strncmp(p, S_LEN("indent-heuristic")) == 0) { p += 16; diff_indent_heuristic = XDF_INDENT_HEURISTIC; - } else if (strncmp(p, "internal", 8) == 0) { + } else if (strncmp(p, S_LEN("internal")) == 0) { p += 8; diff_flags_new |= DIFF_INTERNAL; - } else if (strncmp(p, "algorithm:", 10) == 0) { + } else if (strncmp(p, S_LEN("algorithm:")) == 0) { // Note: Keep this in sync with p_dip_algorithm_values. p += 10; - if (strncmp(p, "myers", 5) == 0) { + if (strncmp(p, S_LEN("myers")) == 0) { p += 5; diff_algorithm_new = 0; - } else if (strncmp(p, "minimal", 7) == 0) { + } else if (strncmp(p, S_LEN("minimal")) == 0) { p += 7; diff_algorithm_new = XDF_NEED_MINIMAL; - } else if (strncmp(p, "patience", 8) == 0) { + } else if (strncmp(p, S_LEN("patience")) == 0) { p += 8; diff_algorithm_new = XDF_PATIENCE_DIFF; - } else if (strncmp(p, "histogram", 9) == 0) { + } else if (strncmp(p, S_LEN("histogram")) == 0) { p += 9; diff_algorithm_new = XDF_HISTOGRAM_DIFF; } else { return FAIL; } - } else if ((strncmp(p, "linematch:", 10) == 0) && ascii_isdigit(p[10])) { + } else if ((strncmp(p, S_LEN("linematch:")) == 0) && ascii_isdigit(p[10])) { p += 10; linematch_lines_new = getdigits_int(&p, false, linematch_lines_new); diff_flags_new |= DIFF_LINEMATCH; |