diff options
author | James Tirta Halim <tirtajames45@gmail.com> | 2024-06-03 11:00:20 +0700 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-06-04 09:42:19 +0100 |
commit | a18982cb839d7f05e32b1026bbd99b8aa34ad189 (patch) | |
tree | a2fcf7096210519d2f1397ab22b0200598350578 /src | |
parent | 2f5b8a009280eba995aecf67d1e8d99b7c72c51c (diff) | |
download | rneovim-a18982cb839d7f05e32b1026bbd99b8aa34ad189.tar.gz rneovim-a18982cb839d7f05e32b1026bbd99b8aa34ad189.tar.bz2 rneovim-a18982cb839d7f05e32b1026bbd99b8aa34ad189.zip |
refactor: replace '\0' with NUL
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/base64.c | 3 | ||||
-rw-r--r-- | src/nvim/buffer.c | 2 | ||||
-rw-r--r-- | src/nvim/charset.c | 4 | ||||
-rw-r--r-- | src/nvim/cmdexpand.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 2 | ||||
-rw-r--r-- | src/nvim/file_search.c | 2 | ||||
-rw-r--r-- | src/nvim/fileio.c | 4 | ||||
-rw-r--r-- | src/nvim/help.c | 4 | ||||
-rw-r--r-- | src/nvim/highlight_group.c | 4 | ||||
-rw-r--r-- | src/nvim/linematch.c | 3 | ||||
-rw-r--r-- | src/nvim/log.c | 10 | ||||
-rw-r--r-- | src/nvim/mbyte.c | 4 | ||||
-rw-r--r-- | src/nvim/memory.c | 16 | ||||
-rw-r--r-- | src/nvim/message.c | 2 | ||||
-rw-r--r-- | src/nvim/ops.c | 2 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 2 | ||||
-rw-r--r-- | src/nvim/regexp.c | 4 | ||||
-rw-r--r-- | src/nvim/sha256.c | 5 | ||||
-rw-r--r-- | src/nvim/sign.c | 16 | ||||
-rw-r--r-- | src/nvim/strings.c | 26 | ||||
-rw-r--r-- | src/nvim/terminal.c | 2 | ||||
-rw-r--r-- | src/nvim/usercmd.c | 6 |
23 files changed, 65 insertions, 62 deletions
diff --git a/src/nvim/base64.c b/src/nvim/base64.c index a645c64fe3..39e4ec4872 100644 --- a/src/nvim/base64.c +++ b/src/nvim/base64.c @@ -4,6 +4,7 @@ #include <string.h> #include "auto/config.h" // IWYU pragma: keep +#include "nvim/ascii_defs.h" #include "nvim/base64.h" #include "nvim/memory.h" @@ -125,7 +126,7 @@ char *base64_encode(const char *src, size_t src_len) dest[out_i] = '='; } - dest[out_len] = '\0'; + dest[out_len] = NUL; return dest; } diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 5d0cd66133..c0fbc36787 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -4208,7 +4208,7 @@ int buf_open_scratch(handle_T bufnr, char *bufname) bool buf_is_empty(buf_T *buf) { - return buf->b_ml.ml_line_count == 1 && *ml_get_buf(buf, 1) == '\0'; + return buf->b_ml.ml_line_count == 1 && *ml_get_buf(buf, 1) == NUL; } /// Increment b:changedtick value diff --git a/src/nvim/charset.c b/src/nvim/charset.c index c611d4cfd6..430f6b15fe 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1470,7 +1470,7 @@ start: *dst++ = *p++; } } - *dst = '\0'; + *dst = NUL; } } @@ -1492,6 +1492,6 @@ char *backslash_halve_save(const char *p) *dst++ = *p++; } } - *dst = '\0'; + *dst = NUL; return res; } diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index bb85620ce6..0b88e2be11 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -3075,7 +3075,7 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T typval_T args[4]; const sctx_T save_current_sctx = current_sctx; - if (xp->xp_arg == NULL || xp->xp_arg[0] == '\0' || xp->xp_line == NULL) { + if (xp->xp_arg == NULL || xp->xp_arg[0] == NUL || xp->xp_line == NULL) { return NULL; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a8778b9489..a4680b62ab 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8910,7 +8910,7 @@ bool eval_has_provider(const char *feat, bool throw_if_fast) char name[32]; // Normalized: "python3_compiled" => "python3". snprintf(name, sizeof(name), "%s", feat); - strchrsub(name, '_', '\0'); // Chop any "_xx" suffix. + strchrsub(name, '_', NUL); // Chop any "_xx" suffix. char buf[256]; typval_T tv; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 028ee8f6ae..2f54aa511b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4118,7 +4118,7 @@ static char *getargcmd(char **argp) if (*arg == '+') { // +[command] arg++; - if (ascii_isspace(*arg) || *arg == '\0') { + if (ascii_isspace(*arg) || *arg == NUL) { command = dollar_command; } else { command = arg; diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index a8b0dbddee..51bea3111c 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -510,7 +510,7 @@ char *vim_findfile_stopdir(char *buf) while (*r_ptr != NUL && *r_ptr != ';') { if (r_ptr[0] == '\\' && r_ptr[1] == ';') { // Overwrite the escape char, - // use strlen(r_ptr) to move the trailing '\0'. + // use strlen(r_ptr) to move the trailing NUL. STRMOVE(r_ptr, r_ptr + 1); r_ptr++; } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 05c9114554..3078f00fbb 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2419,7 +2419,7 @@ char *modname(const char *fname, const char *ext, bool prepend_dot) // the file name has at most BASENAMELEN characters. if (strlen(ptr) > BASENAMELEN) { - ptr[BASENAMELEN] = '\0'; + ptr[BASENAMELEN] = NUL; } char *s = ptr + strlen(ptr); @@ -3330,7 +3330,7 @@ static void vim_mktempdir(void) #endif // If our "root" tempdir is invalid or fails, proceed without "<user>/". // Else user1 could break user2 by creating "/tmp/nvim.user2/". - tmp[strlen(tmp) - strlen(user)] = '\0'; + tmp[strlen(tmp) - strlen(user)] = NUL; } // Now try to create "/tmp/nvim.<user>/XXXXXX". diff --git a/src/nvim/help.c b/src/nvim/help.c index d28f195c00..0da846bb9f 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -958,8 +958,8 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool if (s == p2 && (p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t') && (vim_strchr(" \t\n\r", (uint8_t)s[1]) != NULL - || s[1] == '\0')) { - *p2 = '\0'; + || s[1] == NUL)) { + *p2 = NUL; p1++; size_t s_len = (size_t)(p2 - p1) + strlen(fname) + 2; s = xmalloc(s_len); diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index b5e62e7f31..c32e1f9657 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -1174,7 +1174,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) break; } vim_memcpy_up(key, key_start, key_len); - key[key_len] = '\0'; + key[key_len] = NUL; linep = skipwhite(linep); if (strcmp(key, "NONE") == 0) { @@ -1967,7 +1967,7 @@ int syn_name2id_len(const char *name, size_t len) // Avoid using stricmp() too much, it's slow on some systems // Avoid alloc()/free(), these are slow too. vim_memcpy_up(name_u, name, len); - name_u[len] = '\0'; + name_u[len] = NUL; // map_get(..., int) returns 0 when no key is present, which is // the expected value for missing highlight group. diff --git a/src/nvim/linematch.c b/src/nvim/linematch.c index c34b303193..24b2c82381 100644 --- a/src/nvim/linematch.c +++ b/src/nvim/linematch.c @@ -5,6 +5,7 @@ #include <stdint.h> #include <string.h> +#include "nvim/ascii_defs.h" #include "nvim/linematch.h" #include "nvim/macros_defs.h" #include "nvim/memory.h" @@ -61,7 +62,7 @@ static int matching_chars_iwhite(const char *s1, const char *s2) d++; } } - strsproc[k][i] = '\0'; + strsproc[k][i] = NUL; } int matching = matching_chars(strsproc[0], strsproc[1]); xfree(strsproc[0]); diff --git a/src/nvim/log.c b/src/nvim/log.c index fbb3e0385a..774f1c956d 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -46,7 +46,7 @@ static uv_mutex_t mutex; static bool log_try_create(char *fname) { - if (fname == NULL || fname[0] == '\0') { + if (fname == NULL || fname[0] == NUL) { return false; } FILE *log_file = fopen(fname, "a"); @@ -67,7 +67,7 @@ static void log_path_init(void) size_t size = sizeof(log_file_path); expand_env("$" ENV_LOGFILE, log_file_path, (int)size - 1); if (strequal("$" ENV_LOGFILE, log_file_path) - || log_file_path[0] == '\0' + || log_file_path[0] == NUL || os_isdir(log_file_path) || !log_try_create(log_file_path)) { // Make $XDG_STATE_HOME if it does not exist. @@ -88,7 +88,7 @@ static void log_path_init(void) } // Fall back to stderr if (len >= size || !log_try_create(log_file_path)) { - log_file_path[0] = '\0'; + log_file_path[0] = NUL; return; } os_setenv(ENV_LOGFILE, log_file_path, true); @@ -324,7 +324,7 @@ static bool v_do_log_to_file(FILE *log_file, int log_level, const char *context, // Get a name for this Nvim instance. // TODO(justinmk): expose this as v:name ? - if (name[0] == '\0') { + if (name[0] == NUL) { // Parent servername. const char *parent = path_tail(os_getenv(ENV_NVIM)); // Servername. Empty until starting=false. @@ -350,7 +350,7 @@ static bool v_do_log_to_file(FILE *log_file, int log_level, const char *context, func_name, line_num); if (name[0] == '?') { // No v:servername yet. Clear `name` so that the next log can try again. - name[0] = '\0'; + name[0] = NUL; } if (rv < 0) { diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 23fdd5eb16..07c0c846ed 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1500,7 +1500,7 @@ int utf8_to_utf16(const char *utf8, int utf8len, wchar_t **utf16) return uv_translate_sys_error(GetLastError()); } - (*utf16)[bufsize] = L'\0'; + (*utf16)[bufsize] = LNUL; return 0; } @@ -1546,7 +1546,7 @@ int utf16_to_utf8(const wchar_t *utf16, int utf16len, char **utf8) return uv_translate_sys_error(GetLastError()); } - (*utf8)[bufsize] = '\0'; + (*utf8)[bufsize] = NUL; return 0; } diff --git a/src/nvim/memory.c b/src/nvim/memory.c index c4774d68f3..50860c69d0 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -203,7 +203,7 @@ void *xmallocz(size_t size) } void *ret = xmalloc(total_size); - ((char *)ret)[size] = '\0'; + ((char *)ret)[size] = NUL; return ret; } @@ -233,7 +233,7 @@ void *xmemcpyz(void *dst, const void *src, size_t len) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET { memcpy(dst, src, len); - ((char *)dst)[len] = '\0'; + ((char *)dst)[len] = NUL; return dst; } @@ -241,7 +241,7 @@ void *xmemcpyz(void *dst, const void *src, size_t len) size_t xstrnlen(const char *s, size_t n) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE { - const char *end = memchr(s, '\0', n); + const char *end = memchr(s, NUL, n); if (end == NULL) { return n; } @@ -288,7 +288,7 @@ void *xmemscan(const void *addr, char c, size_t size) void strchrsub(char *str, char c, char x) FUNC_ATTR_NONNULL_ALL { - assert(c != '\0'); + assert(c != NUL); while ((str = strchr(str, c))) { *str++ = x; } @@ -388,7 +388,7 @@ char *xstpcpy(char *restrict dst, const char *restrict src) char *xstpncpy(char *restrict dst, const char *restrict src, size_t maxlen) FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - const char *p = memchr(src, '\0', maxlen); + const char *p = memchr(src, NUL, maxlen); if (p) { size_t srclen = (size_t)(p - src); memcpy(dst, src, srclen); @@ -420,7 +420,7 @@ size_t xstrlcpy(char *restrict dst, const char *restrict src, size_t dsize) if (dsize) { size_t len = MIN(slen, dsize - 1); memcpy(dst, src, len); - dst[len] = '\0'; + dst[len] = NUL; } return slen; // Does not include NUL. @@ -450,7 +450,7 @@ size_t xstrlcat(char *const dst, const char *const src, const size_t dsize) if (slen > dsize - dlen - 1) { memmove(dst + dlen, src, dsize - dlen - 1); - dst[dsize - 1] = '\0'; + dst[dsize - 1] = NUL; } else { memmove(dst + dlen, src, slen + 1); } @@ -510,7 +510,7 @@ char *xstrndup(const char *str, size_t len) FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL { - char *p = memchr(str, '\0', len); + char *p = memchr(str, NUL, len); return xmemdupz(str, p ? (size_t)(p - str) : len); } diff --git a/src/nvim/message.c b/src/nvim/message.c index 9941dcb254..73712489ad 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2690,7 +2690,7 @@ static void msg_puts_printf(const char *str, const ptrdiff_t maxlen) *p++ = '\r'; } memcpy(p, s, (size_t)len); - *(p + len) = '\0'; + *(p + len) = NUL; if (info_message) { printf("%s", buf); } else { diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 74c6e83495..1448896146 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4725,7 +4725,7 @@ bool do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) buf2[i++] = ((n >> --bits) & 0x1) ? '1' : '0'; } - buf2[i] = '\0'; + buf2[i] = NUL; } else if (pre == 0) { vim_snprintf(buf2, ARRAY_SIZE(buf2), "%" PRIu64, (uint64_t)n); } else if (pre == '0') { diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index e1d35ab9d5..be2f41da14 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -724,7 +724,7 @@ static int qf_get_next_str_line(qfstate_T *state) state->linelen = len; } memcpy(state->linebuf, p_str, state->linelen); - state->linebuf[state->linelen] = '\0'; + state->linebuf[state->linelen] = NUL; // Increment using len in order to discard the rest of the line if it // exceeds LINE_MAXLEN. diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index b743664b69..2ff4dbee70 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -11495,7 +11495,7 @@ static void nfa_print_state(FILE *debugf, nfa_state_T *state) garray_T indent; ga_init(&indent, 1, 64); - ga_append(&indent, '\0'); + ga_append(&indent, NUL); nfa_print_state2(debugf, state, &indent); ga_clear(&indent); } @@ -14801,7 +14801,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm } case NFA_ANY: - // Any char except '\0', (end of input) does not match. + // Any char except NUL, (end of input) does not match. if (curc > 0) { add_state = t->state->out; add_off = clen; diff --git a/src/nvim/sha256.c b/src/nvim/sha256.c index d49224a987..5e0aac3f69 100644 --- a/src/nvim/sha256.c +++ b/src/nvim/sha256.c @@ -15,6 +15,7 @@ #include <stdio.h> #include <string.h> +#include "nvim/ascii_defs.h" #include "nvim/memory.h" #include "nvim/sha256.h" @@ -279,7 +280,7 @@ const char *sha256_bytes(const uint8_t *restrict buf, size_t buf_len, const uin for (size_t j = 0; j < SHA256_SUM_SIZE; j++) { snprintf(hexit + j * SHA_STEP, SHA_STEP + 1, "%02x", sha256sum[j]); } - hexit[sizeof(hexit) - 1] = '\0'; + hexit[sizeof(hexit) - 1] = NUL; return hexit; } @@ -340,7 +341,7 @@ bool sha256_self_test(void) if (memcmp(output, sha_self_test_vector[i], SHA256_BUFFER_SIZE) != 0) { failures = true; - output[sizeof(output) - 1] = '\0'; + output[sizeof(output) - 1] = NUL; // printf("sha256_self_test %d failed %s\n", i, output); } diff --git a/src/nvim/sign.c b/src/nvim/sign.c index be207f58b0..496913f9bf 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -292,8 +292,8 @@ static void sign_list_placed(buf_T *rbuf, char *group) qsort((void *)&kv_A(signs, 0), kv_size(signs), sizeof(MTKey), sign_row_cmp); for (size_t i = 0; i < kv_size(signs); i++) { - namebuf[0] = '\0'; - groupbuf[0] = '\0'; + namebuf[0] = NUL; + groupbuf[0] = NUL; MTKey mark = kv_A(signs, i); DecorSignHighlight *sh = decor_find_sign(mt_decor(mark)); @@ -498,7 +498,7 @@ static void sign_list_by_name(char *name) static int sign_place(uint32_t *id, char *group, char *name, buf_T *buf, linenr_T lnum, int prio) { // Check for reserved character '*' in group name - if (group != NULL && (*group == '*' || *group == '\0')) { + if (group != NULL && (*group == '*' || *group == NUL)) { return FAIL; } @@ -649,14 +649,14 @@ static void sign_place_cmd(buf_T *buf, linenr_T lnum, char *name, int id, char * // :sign place // :sign place group={group} // :sign place group=* - if (lnum >= 0 || name != NULL || (group != NULL && *group == '\0')) { + if (lnum >= 0 || name != NULL || (group != NULL && *group == NUL)) { emsg(_(e_invarg)); } else { sign_list_placed(buf, group); } } else { // Place a new sign - if (name == NULL || buf == NULL || (group != NULL && *group == '\0')) { + if (name == NULL || buf == NULL || (group != NULL && *group == NUL)) { emsg(_(e_invarg)); return; } @@ -668,7 +668,7 @@ static void sign_place_cmd(buf_T *buf, linenr_T lnum, char *name, int id, char * /// ":sign unplace" command static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, const char *name, int id, char *group) { - if (lnum >= 0 || name != NULL || (group != NULL && *group == '\0')) { + if (lnum >= 0 || name != NULL || (group != NULL && *group == NUL)) { emsg(_(e_invarg)); return; } @@ -695,7 +695,7 @@ static void sign_jump_cmd(buf_T *buf, linenr_T lnum, const char *name, int id, c return; } - if (buf == NULL || (group != NULL && *group == '\0') || lnum >= 0 || name != NULL) { + if (buf == NULL || (group != NULL && *group == NUL) || lnum >= 0 || name != NULL) { // File or buffer is not specified or an empty group is used // or a line number or a sign name is specified. emsg(_(e_invarg)); @@ -1316,7 +1316,7 @@ void f_sign_getplaced(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (group == NULL) { return; } - if (*group == '\0') { // empty string means global group + if (*group == NUL) { // empty string means global group group = NULL; } } diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 329b66cea1..bf7af40a38 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -333,7 +333,7 @@ void vim_strcpy_up(char *restrict dst, const char *restrict src) while ((c = (uint8_t)(*src++)) != NUL) { *dst++ = (char)(uint8_t)(c < 'a' || c > 'z' ? c : c - 0x20); } - *dst = '\0'; + *dst = NUL; } // strncpy (NUL-terminated) plus vim_strup. @@ -344,7 +344,7 @@ void vim_strncpy_up(char *restrict dst, const char *restrict src, size_t n) while (n-- && (c = (uint8_t)(*src++)) != NUL) { *dst++ = (char)(uint8_t)(c < 'a' || c > 'z' ? c : c - 0x20); } - *dst = '\0'; + *dst = NUL; } // memcpy (does not NUL-terminate) plus vim_strup. @@ -794,10 +794,10 @@ static int format_typeof(const char *type) FUNC_ATTR_NONNULL_ALL { // allowed values: \0, h, l, L - char length_modifier = '\0'; + char length_modifier = NUL; // current conversion specifier character - char fmt_spec = '\0'; + char fmt_spec = NUL; // parse 'h', 'l', 'll' and 'z' length modifiers if (*type == 'h' || *type == 'l' || *type == 'z') { @@ -865,7 +865,7 @@ static int format_typeof(const char *type) } else if (fmt_spec == 'd') { // signed switch (length_modifier) { - case '\0': + case NUL: case 'h': // char and short arguments are passed as int. return TYPE_INT; @@ -879,7 +879,7 @@ static int format_typeof(const char *type) } else { // unsigned switch (length_modifier) { - case '\0': + case NUL: case 'h': return TYPE_UNSIGNEDINT; case 'l': @@ -1050,7 +1050,7 @@ static int parse_fmt_types(const char ***ap_types, int *num_posarg, const char * p += n; } else { // allowed values: \0, h, l, L - char length_modifier = '\0'; + char length_modifier = NUL; // variable for positional arg int pos_arg = -1; @@ -1441,7 +1441,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st int space_for_positive = 1; // allowed values: \0, h, l, 2 (for ll), z, L - char length_modifier = '\0'; + char length_modifier = NUL; // temporary buffer for simple numeric->string conversion #define TMP_LEN 350 // 1e308 seems reasonable as the maximum printable @@ -1466,7 +1466,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st size_t zero_padding_insertion_ind = 0; // current conversion specifier character - char fmt_spec = '\0'; + char fmt_spec = NUL; // buffer for 's' and 'S' specs char *tofree = NULL; @@ -1669,7 +1669,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st case 'o': case 'x': case 'X': - if (tvs && length_modifier == '\0') { + if (tvs && length_modifier == NUL) { length_modifier = 'L'; } } @@ -1790,7 +1790,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st } else if (fmt_spec == 'd') { // signed switch (length_modifier) { - case '\0': + case NUL: arg = (tvs ? (int)tv_nr(tvs, &arg_idx) : (skip_to_arg(ap_types, ap_start, &ap, &arg_idx, @@ -1836,7 +1836,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st } else { // unsigned switch (length_modifier) { - case '\0': + case NUL: uarg = (tvs ? (unsigned)tv_nr(tvs, &arg_idx) : (skip_to_arg(ap_types, ap_start, &ap, &arg_idx, @@ -2223,7 +2223,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap_st if (str_m > 0) { // make sure the string is nul-terminated even at the expense of // overwriting the last character (shouldn't happen, but just in case) - str[str_l <= str_m - 1 ? str_l : str_m - 1] = '\0'; + str[str_l <= str_m - 1 ? str_l : str_m - 1] = NUL; } if (tvs != NULL diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 2b05a8047e..2738eb874d 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -845,7 +845,7 @@ void terminal_paste(int count, char **y_array, size_t y_size) } char *dst = buff; char *src = y_array[j]; - while (*src != '\0') { + while (*src != NUL) { len = (size_t)utf_ptr2len(src); int c = utf_ptr2char(src); if (!is_filter_char(c)) { diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index e3d9dc5f54..79f897f020 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -580,7 +580,7 @@ static void uc_list(char *name, size_t name_len) IObuff[len++] = ' '; } while ((int64_t)len < 25 - over); - IObuff[len] = '\0'; + IObuff[len] = NUL; msg_outtrans(IObuff, 0); if (cmd->uc_luaref != LUA_NOREF) { @@ -831,7 +831,7 @@ invalid_count: } } else { char ch = attr[len]; - attr[len] = '\0'; + attr[len] = NUL; semsg(_("E181: Invalid attribute: %s"), attr); attr[len] = ch; return FAIL; @@ -1364,7 +1364,7 @@ size_t uc_mods(char *buf, const cmdmod_T *cmod, bool quote) if (quote) { *buf++ = '"'; } - *buf = '\0'; + *buf = NUL; } // the modifiers that are simple flags |