diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arabic.c | 4 | ||||
-rw-r--r-- | src/ascii.h | 1 | ||||
-rw-r--r-- | src/blowfish.c | 2 | ||||
-rw-r--r-- | src/buffer.c | 62 | ||||
-rw-r--r-- | src/charset.c | 72 | ||||
-rw-r--r-- | src/crypt.c | 10 | ||||
-rw-r--r-- | src/cursor_shape.c | 2 | ||||
-rw-r--r-- | src/diff.c | 24 | ||||
-rw-r--r-- | src/digraph.c | 20 | ||||
-rw-r--r-- | src/edit.c | 254 | ||||
-rw-r--r-- | src/eval.c | 382 | ||||
-rw-r--r-- | src/ex_cmds.c | 208 | ||||
-rw-r--r-- | src/ex_cmds2.c | 60 | ||||
-rw-r--r-- | src/ex_docmd.c | 274 | ||||
-rw-r--r-- | src/ex_eval.c | 32 | ||||
-rw-r--r-- | src/ex_getln.c | 132 | ||||
-rw-r--r-- | src/farsi.c | 4 | ||||
-rw-r--r-- | src/file_search.c | 56 | ||||
-rw-r--r-- | src/fileio.c | 166 | ||||
-rw-r--r-- | src/fold.c | 18 | ||||
-rw-r--r-- | src/garray.c | 2 | ||||
-rw-r--r-- | src/getchar.c | 150 | ||||
-rw-r--r-- | src/globals.h | 14 | ||||
-rw-r--r-- | src/hardcopy.c | 36 | ||||
-rw-r--r-- | src/hashtab.c | 2 | ||||
-rw-r--r-- | src/if_cscope.c | 22 | ||||
-rw-r--r-- | src/indent.c | 18 | ||||
-rw-r--r-- | src/indent_c.c | 80 | ||||
-rw-r--r-- | src/keymap.c | 20 | ||||
-rw-r--r-- | src/keymap.h | 4 | ||||
-rw-r--r-- | src/macros.h | 4 | ||||
-rw-r--r-- | src/main.c | 22 | ||||
-rw-r--r-- | src/mark.c | 30 | ||||
-rw-r--r-- | src/mbyte.c | 100 | ||||
-rw-r--r-- | src/memfile.c | 6 | ||||
-rw-r--r-- | src/memline.c | 60 | ||||
-rw-r--r-- | src/menu.c | 104 | ||||
-rw-r--r-- | src/message.c | 100 | ||||
-rw-r--r-- | src/misc1.c | 134 | ||||
-rw-r--r-- | src/misc2.c | 72 | ||||
-rw-r--r-- | src/move.c | 2 | ||||
-rw-r--r-- | src/msgpack_rpc.c | 2 | ||||
-rw-r--r-- | src/normal.c | 160 | ||||
-rw-r--r-- | src/ops.c | 192 | ||||
-rw-r--r-- | src/option.c | 250 | ||||
-rw-r--r-- | src/os/env.c | 2 | ||||
-rw-r--r-- | src/os/fs.c | 2 | ||||
-rw-r--r-- | src/os/shell.c | 8 | ||||
-rw-r--r-- | src/os/users.c | 2 | ||||
-rw-r--r-- | src/os_unix.c | 56 | ||||
-rw-r--r-- | src/path.c | 112 | ||||
-rw-r--r-- | src/popupmnu.c | 8 | ||||
-rw-r--r-- | src/quickfix.c | 98 | ||||
-rw-r--r-- | src/regexp.c | 160 | ||||
-rw-r--r-- | src/regexp_nfa.c | 62 | ||||
-rw-r--r-- | src/screen.c | 192 | ||||
-rw-r--r-- | src/search.c | 140 | ||||
-rw-r--r-- | src/sha256.c | 2 | ||||
-rw-r--r-- | src/spell.c | 520 | ||||
-rw-r--r-- | src/syntax.c | 96 | ||||
-rw-r--r-- | src/tag.c | 78 | ||||
-rw-r--r-- | src/term.c | 128 | ||||
-rw-r--r-- | src/ui.c | 2 | ||||
-rw-r--r-- | src/undo.c | 18 | ||||
-rw-r--r-- | src/version.c | 18 | ||||
-rw-r--r-- | src/window.c | 14 |
66 files changed, 2543 insertions, 2544 deletions
diff --git a/src/arabic.c b/src/arabic.c index 54f88f8757..f62a1a9c05 100644 --- a/src/arabic.c +++ b/src/arabic.c @@ -1418,7 +1418,7 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, /* Sanity check -- curr_c should, in the future, never be 0. * We should, in the future, insert a fatal error here. */ - if (curr_c == NUL) { + if (curr_c == '\0') { curr_c = c; } @@ -1467,7 +1467,7 @@ int arabic_maycombine(int two) */ static int A_firstc_laa(int c, int c1) { - if ((c1 != NUL) && (c == a_LAM) && !A_is_harakat(c1)) { + if ((c1 != '\0') && (c == a_LAM) && !A_is_harakat(c1)) { return c1; } return 0; diff --git a/src/ascii.h b/src/ascii.h index cf488c56a7..e63bdb2fde 100644 --- a/src/ascii.h +++ b/src/ascii.h @@ -22,7 +22,6 @@ #define CharOrdUp(x) ((x) - 'A') #define ROT13(c, a) (((((c) - (a)) + 13) % 26) + (a)) -#define NUL '\000' #define BELL '\007' #define BS '\010' #define TAB '\011' diff --git a/src/blowfish.c b/src/blowfish.c index 67712a2fbc..707d3e53ee 100644 --- a/src/blowfish.c +++ b/src/blowfish.c @@ -567,7 +567,7 @@ void bf_crypt_decode(char_u *ptr, long len) void bf_crypt_init_keys(char_u *passwd) { char_u *p; - for (p = passwd; *p != NUL; p++) { + for (p = passwd; *p != '\0'; p++) { BF_CFB_UPDATE(*p); } } diff --git a/src/buffer.c b/src/buffer.c index 8723e31be3..c4455bfe8e 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -747,7 +747,7 @@ do_bufdel ( break; } else { /* addr_count == 1 */ arg = skipwhite(arg); - if (*arg == NUL) + if (*arg == '\0') break; if (!VIM_ISDIGIT(*arg)) { p = skiptowhite_esc(arg); @@ -1232,7 +1232,7 @@ void enter_buffer(buf_T *buf) /* If there is no filetype, allow for detecting one. Esp. useful for * ":ball" used in a autocommand. If there already is a filetype we * might prefer to keep it. */ - if (*curbuf->b_p_ft == NUL) + if (*curbuf->b_p_ft == '\0') did_filetype = FALSE; open_buffer(FALSE, NULL, 0); @@ -1265,7 +1265,7 @@ void enter_buffer(buf_T *buf) (void)keymap_init(); /* May need to set the spell language. Can only do this after the buffer * has been properly setup. */ - if (!curbuf->b_help && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) + if (!curbuf->b_help && curwin->w_p_spell && *curwin->w_s->b_p_spl != '\0') (void)did_set_spelllang(curwin); redraw_later(NOT_VALID); @@ -1768,7 +1768,7 @@ buflist_findpat ( for (attempt = 0; attempt <= 3; ++attempt) { /* may add '^' and '$' */ if (toggledollar) - *patend = (attempt < 2) ? NUL : '$'; /* add/remove '$' */ + *patend = (attempt < 2) ? '\0' : '$'; /* add/remove '$' */ p = pat; if (*p == '^' && !(attempt & 1)) /* add/remove '^' */ ++p; @@ -2227,7 +2227,7 @@ setfname ( struct stat st; #endif - if (ffname == NULL || *ffname == NUL) { + if (ffname == NULL || *ffname == '\0') { /* Removing the name. */ vim_free(buf->b_ffname); vim_free(buf->b_sfname); @@ -2443,7 +2443,7 @@ static int otherfile_buf(buf_T *buf, char_u *ffname ) { /* no name is different */ - if (ffname == NULL || *ffname == NUL || buf->b_ffname == NULL) + if (ffname == NULL || *ffname == '\0' || buf->b_ffname == NULL) return TRUE; if (fnamecmp(ffname, buf->b_ffname) == 0) return FALSE; @@ -2653,7 +2653,7 @@ void maketitle(void) } t_str = buf; - if (*p_titlestring != NUL) { + if (*p_titlestring != '\0') { if (stl_syntax & STL_IN_TITLE) { int use_sandbox = FALSE; int save_called_emsg = called_emsg; @@ -2714,7 +2714,7 @@ void maketitle(void) vim_strncpy(buf + off, (char_u *)_("help"), (size_t)(SPACE_FOR_DIR - off - 1)); else - *p = NUL; + *p = '\0'; /* Translate unprintable chars and concatenate. Keep some * room for the server name. When there is no room (very long @@ -2745,7 +2745,7 @@ void maketitle(void) if (p_icon) { i_str = buf; - if (*p_iconstring != NUL) { + if (*p_iconstring != '\0') { if (stl_syntax & STL_IN_ICON) { int use_sandbox = FALSE; int save_called_emsg = called_emsg; @@ -2766,7 +2766,7 @@ void maketitle(void) i_name = buf_spname(curbuf); else /* use file name only in icon */ i_name = path_tail(curbuf->b_ffname); - *i_str = NUL; + *i_str = '\0'; /* Truncate name at 100 bytes. */ len = (int)STRLEN(i_name); if (len > 100) { @@ -2914,7 +2914,7 @@ build_stl_str_hl ( /* Get line & check if empty (cursorpos will show "0-1"). Note that * p will become invalid when getting another buffer line. */ p = ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE); - empty_line = (*p == NUL); + empty_line = (*p == '\0'); /* Get the byte value now, in case we need it below. This is more * efficient than making a copy of the line. */ @@ -2939,22 +2939,22 @@ build_stl_str_hl ( break; } - if (*s != NUL && *s != '%') + if (*s != '\0' && *s != '%') prevchar_isflag = prevchar_isitem = FALSE; /* * Handle up to the next '%' or the end. */ - while (*s != NUL && *s != '%' && p + 1 < out + outlen) + while (*s != '\0' && *s != '%' && p + 1 < out + outlen) *p++ = *s++; - if (*s == NUL || p + 1 >= out + outlen) + if (*s == '\0' || p + 1 >= out + outlen) break; /* * Handle one '%' item. */ s++; - if (*s == NUL) /* ignore trailing % */ + if (*s == '\0') /* ignore trailing % */ break; if (*s == '%') { if (p + 1 >= out + outlen) @@ -2984,7 +2984,7 @@ build_stl_str_hl ( groupdepth--; t = item[groupitem[groupdepth]].start; - *p = NUL; + *p = '\0'; l = vim_strsize(t); if (curitem > groupitem[groupdepth] + 1 && item[groupitem[groupdepth]].minwid == 0) { @@ -3144,7 +3144,7 @@ build_stl_str_hl ( case STL_VIM_EXPR: /* '{' */ itemisflag = TRUE; t = p; - while (*s != '}' && *s != NUL && p + 1 < out + outlen) + while (*s != '}' && *s != '\0' && p + 1 < out + outlen) *p++ = *s++; if (*s != '}') /* missing '}' or out of space */ break; @@ -3167,7 +3167,7 @@ build_stl_str_hl ( do_unlet((char_u *)"g:actual_curbuf", TRUE); if (str != NULL && *str != 0) { - if (*skipdigits(str) == NUL) { + if (*skipdigits(str) == '\0') { num = atoi((char *)str); vim_free(str); str = NULL; @@ -3194,7 +3194,7 @@ build_stl_str_hl ( case STL_VIRTCOL_ALT: /* In list mode virtcol needs to be recomputed */ virtcol = wp->w_virtcol; - if (wp->w_p_list && lcs_tab1 == NUL) { + if (wp->w_p_list && lcs_tab1 == '\0') { wp->w_p_list = FALSE; getvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL); wp->w_p_list = TRUE; @@ -3273,7 +3273,7 @@ build_stl_str_hl ( break; case STL_FILETYPE: - if (*wp->w_buffer->b_p_ft != NUL + if (*wp->w_buffer->b_p_ft != '\0' && STRLEN(wp->w_buffer->b_p_ft) < TMPLEN - 3) { vim_snprintf((char *)tmp, sizeof(tmp), "[%s]", wp->w_buffer->b_p_ft); @@ -3283,7 +3283,7 @@ build_stl_str_hl ( case STL_FILETYPE_ALT: itemisflag = TRUE; - if (*wp->w_buffer->b_p_ft != NUL + if (*wp->w_buffer->b_p_ft != '\0' && STRLEN(wp->w_buffer->b_p_ft) < TMPLEN - 2) { vim_snprintf((char *)tmp, sizeof(tmp), ",%s", wp->w_buffer->b_p_ft); @@ -3325,7 +3325,7 @@ build_stl_str_hl ( case STL_HIGHLIGHT: t = s; - while (*s != '#' && *s != NUL) + while (*s != '#' && *s != '\0') ++s; if (*s == '#') { item[curitem].type = Highlight; @@ -3333,7 +3333,7 @@ build_stl_str_hl ( item[curitem].minwid = -syn_namen2id(t, (int)(s - t)); curitem++; } - if (*s != NUL) + if (*s != '\0') ++s; continue; } @@ -3432,7 +3432,7 @@ build_stl_str_hl ( prevchar_isflag = FALSE; /* Item not NULL, but not a flag */ curitem++; } - *p = NUL; + *p = '\0'; itemcnt = curitem; if (usefmt != fmt) @@ -3497,7 +3497,7 @@ build_stl_str_hl ( while (++width < maxwidth) { s = s + STRLEN(s); *s++ = fillchar; - *s = NUL; + *s = '\0'; } --n; /* count the '<' */ @@ -4131,7 +4131,7 @@ chk_modeline ( scid_T save_SID; prev = -1; - for (s = ml_get(lnum); *s != NUL; ++s) { + for (s = ml_get(lnum); *s != '\0'; ++s) { if (prev == -1 || vim_isspace(prev)) { if ((prev != -1 && STRNCMP(s, "ex:", (size_t)3) == 0) || STRNCMP(s, "vi:", (size_t)3) == 0) @@ -4174,17 +4174,17 @@ chk_modeline ( end = FALSE; while (end == FALSE) { s = skipwhite(s); - if (*s == NUL) + if (*s == '\0') break; /* * Find end of set command: ':' or end of line. * Skip over "\:", replacing it with ":". */ - for (e = s; *e != ':' && *e != NUL; ++e) + for (e = s; *e != ':' && *e != '\0'; ++e) if (e[0] == '\\' && e[1] == ':') STRMOVE(e, e + 1); - if (*e == NUL) + if (*e == '\0') end = TRUE; /* @@ -4201,9 +4201,9 @@ chk_modeline ( end = TRUE; s = vim_strchr(s, ' ') + 1; } - *e = NUL; /* truncate the set command */ + *e = '\0'; /* truncate the set command */ - if (*s != NUL) { /* skip over an empty "::" */ + if (*s != '\0') { /* skip over an empty "::" */ save_SID = current_SID; current_SID = SID_MODELINE; retval = do_set(s, OPT_MODELINE | OPT_LOCAL | flags); diff --git a/src/charset.c b/src/charset.c index 89ce5d38eb..a77a442499 100644 --- a/src/charset.c +++ b/src/charset.c @@ -169,7 +169,7 @@ int buf_init_chartab(buf_T *buf, int global) tilde = FALSE; do_isalpha = FALSE; - if ((*p == '^') && (p[1] != NUL)) { + if ((*p == '^') && (p[1] != '\0')) { tilde = TRUE; ++p; } @@ -183,7 +183,7 @@ int buf_init_chartab(buf_T *buf, int global) } c2 = -1; - if ((*p == '-') && (p[1] != NUL)) { + if ((*p == '-') && (p[1] != '\0')) { ++p; if (VIM_ISDIGIT(*p)) { @@ -199,7 +199,7 @@ int buf_init_chartab(buf_T *buf, int global) || (c >= 256) || ((c2 < c) && (c2 != -1)) || (c2 >= 256) - || !((*p == NUL) || (*p == ','))) { + || !((*p == '\0') || (*p == ','))) { return FAIL; } @@ -271,7 +271,7 @@ int buf_init_chartab(buf_T *buf, int global) c = *p; p = skip_to_option_part(p); - if ((c == ',') && (*p == NUL)) { + if ((c == ',') && (*p == '\0')) { // Trailing comma is not allowed. return FAIL; } @@ -344,7 +344,7 @@ char_u *transstr(char_u *s) len = 0; p = s; - while (*p != NUL) { + while (*p != '\0') { if ((l = (*mb_ptr2len)(p)) > 1) { c = (*mb_ptr2char)(p); p += l; @@ -371,10 +371,10 @@ char_u *transstr(char_u *s) res = alloc((unsigned)(vim_strsize(s) + 1)); } - *res = NUL; + *res = '\0'; p = s; - while (*p != NUL) { + while (*p != '\0') { if (has_mbyte && ((l = (*mb_ptr2len)(p)) > 1)) { c = (*mb_ptr2char)(p); @@ -435,14 +435,14 @@ char_u* str_foldcase(char_u *str, int orglen, char_u *buf, int buflen) } if (buf == NULL) { - GA_CHAR(len) = NUL; + GA_CHAR(len) = '\0'; } else { - buf[len] = NUL; + buf[len] = '\0'; } // Make each character lower case. i = 0; - while (STR_CHAR(i) != NUL) { + while (STR_CHAR(i) != '\0') { if (enc_utf8 || (has_mbyte && (MB_BYTE2LEN(STR_CHAR(i)) > 1))) { if (enc_utf8) { int c = utf_ptr2char(STR_PTR(i)); @@ -530,7 +530,7 @@ char_u* transchar(int c) || ((c < 256) && vim_isprintc_strict(c))) { // printable character transchar_buf[i] = c; - transchar_buf[i + 1] = NUL; + transchar_buf[i + 1] = '\0'; } else { transchar_nonprint(transchar_buf + i, c); } @@ -562,7 +562,7 @@ void transchar_nonprint(char_u *buf, int c) { if (c == NL) { // we use newline in place of a NUL - c = NUL; + c = '\0'; } else if ((c == CAR) && (get_fileformat(curbuf) == EOL_MAC)) { // we use CR in place of NL in this case c = NL; @@ -577,14 +577,14 @@ void transchar_nonprint(char_u *buf, int c) // DEL displayed as ^? buf[1] = c ^ 0x40; - buf[2] = NUL; + buf[2] = '\0'; } else if (enc_utf8 && (c >= 0x80)) { transchar_hex(buf, c); } else if ((c >= ' ' + 0x80) && (c <= '~' + 0x80)) { // 0xa0 - 0xfe buf[0] = '|'; buf[1] = c - 0x80; - buf[2] = NUL; + buf[2] = '\0'; } else { // 0x80 - 0x9f and 0xff // TODO: EBCDIC I don't know what to do with this chars, so I display @@ -592,7 +592,7 @@ void transchar_nonprint(char_u *buf, int c) buf[0] = '~'; buf[1] = (c - 0x80) ^ 0x40; // 0xff displayed as ~? - buf[2] = NUL; + buf[2] = '\0'; } } @@ -612,7 +612,7 @@ void transchar_hex(char_u *buf, int c) buf[++i] = nr2hex((unsigned)c >> 4); buf[++i] = nr2hex((unsigned)c); buf[++i] = '>'; - buf[++i] = NUL; + buf[++i] = '\0'; } /// Convert the lower 4 bits of byte "c" to its hex character. @@ -724,7 +724,7 @@ int vim_strnsize(char_u *s, int len) { assert(s != NULL); int size = 0; - while (*s != NUL && --len >= 0) { + while (*s != '\0' && --len >= 0) { if (has_mbyte) { int l = (*mb_ptr2len)(s); size += ptr2cells(s); @@ -794,7 +794,7 @@ int linetabsize_col(int startcol, char_u *s) { colnr_T col = startcol; - while (*s != NUL) { + while (*s != '\0') { col += lbr_chartabsize_adv(&s, col); } return (int)col; @@ -812,7 +812,7 @@ int win_linetabsize(win_T *wp, char_u *p, colnr_T len) colnr_T col = 0; char_u *s; - for (s = p; *s != NUL && (len == MAXCOL || s < p + len); mb_ptr_adv(s)) { + for (s = p; *s != '\0' && (len == MAXCOL || s < p + len); mb_ptr_adv(s)) { col += win_lbr_chartabsize(wp, s, col, NULL); } return (int)col; @@ -901,7 +901,7 @@ int vim_isfilec_or_wc(int c) { char_u buf[2]; buf[0] = (char_u)c; - buf[1] = NUL; + buf[1] = '\0'; return vim_isfilec(c) || c == ']' || mch_has_wildcard(buf); } @@ -946,7 +946,7 @@ int vim_isprintc_strict(int c) /// @return The number of characters taken up on the screen. int lbr_chartabsize(unsigned char *s, colnr_T col) { - if (!curwin->w_p_lbr && (*p_sbr == NUL)) { + if (!curwin->w_p_lbr && (*p_sbr == '\0')) { if (curwin->w_p_wrap) { return win_nolbr_chartabsize(curwin, s, col, NULL); } @@ -994,7 +994,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp) int n; // No 'linebreak' and 'showbreak': return quickly. - if (!wp->w_p_lbr && (*p_sbr == NUL)) { + if (!wp->w_p_lbr && (*p_sbr == '\0')) { if (wp->w_p_wrap) { return win_nolbr_chartabsize(wp, s, col, headp); } @@ -1032,7 +1032,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp) mb_ptr_adv(s); c = *s; - if (!((c != NUL) + if (!((c != '\0') && (vim_isbreak(c) || (!vim_isbreak(c) && ((col2 == col) || !vim_isbreak(*ps)))))) { @@ -1061,7 +1061,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp) // Set *headp to the size of what we add. added = 0; - if ((*p_sbr != NUL) && wp->w_p_wrap && (col != 0)) { + if ((*p_sbr != '\0') && wp->w_p_wrap && (col != 0)) { numberextra = win_col_off(wp); col += numberextra + mb_added; @@ -1193,15 +1193,15 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, // This function is used very often, do some speed optimizations. // When 'list', 'linebreak' and 'showbreak' are not set use a simple loop. // Also use this when 'list' is set but tabs take their normal size. - if ((!wp->w_p_list || (lcs_tab1 != NUL)) + if ((!wp->w_p_list || (lcs_tab1 != '\0')) && !wp->w_p_lbr - && (*p_sbr == NUL)) { + && (*p_sbr == '\0')) { for (;;) { head = 0; c = *ptr; // make sure we don't go past the end of the line - if (c == NUL) { + if (c == '\0') { // NUL at end of line only takes one column incr = 1; break; @@ -1250,7 +1250,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, incr = win_lbr_chartabsize(wp, ptr, vcol, &head); // make sure we don't go past the end of the line - if (*ptr == NUL) { + if (*ptr == '\0') { // NUL at end of line only takes one column incr = 1; break; @@ -1455,7 +1455,7 @@ char_u* skiphex(char_u *q) char_u* skiptodigit(char_u *q) { char_u *p = q; - while (*p != NUL && !VIM_ISDIGIT(*p)) { + while (*p != '\0' && !VIM_ISDIGIT(*p)) { // skip to next digit p++; } @@ -1470,7 +1470,7 @@ char_u* skiptodigit(char_u *q) char_u* skiptohex(char_u *q) { char_u *p = q; - while (*p != NUL && !vim_isxdigit(*p)) { + while (*p != '\0' && !vim_isxdigit(*p)) { // skip to next digit p++; } @@ -1654,7 +1654,7 @@ int vim_tolower(int c) /// @return Pointer to the next whitespace or NUL character. char_u* skiptowhite(char_u *p) { - while (*p != ' ' && *p != '\t' && *p != NUL) { + while (*p != ' ' && *p != '\t' && *p != '\0') { p++; } return p; @@ -1666,8 +1666,8 @@ char_u* skiptowhite(char_u *p) /// /// @return Pointer to the next whitespace character. char_u* skiptowhite_esc(char_u *p) { - while (*p != ' ' && *p != '\t' && *p != NUL) { - if (((*p == '\\') || (*p == Ctrl_V)) && (*(p + 1) != NUL)) { + while (*p != ' ' && *p != '\t' && *p != '\0') { + if (((*p == '\\') || (*p == Ctrl_V)) && (*(p + 1) != '\0')) { ++p; } ++p; @@ -1705,7 +1705,7 @@ long getdigits(char_u **pp) int vim_isblankline(char_u *lbuf) { char_u *p = skipwhite(lbuf); - return *p == NUL || *p == '\r' || *p == '\n'; + return *p == '\0' || *p == '\r' || *p == '\n'; } /// Convert a string into a long and/or unsigned long, taking care of @@ -1880,13 +1880,13 @@ int rem_backslash(char_u *str) return str[0] == '\\' && str[1] < 0x80 && (str[1] == ' ' - || (str[1] != NUL + || (str[1] != '\0' && str[1] != '*' && str[1] != '?' && !vim_isfilec(str[1]))); #else // ifdef BACKSLASH_IN_FILENAME - return str[0] == '\\' && str[1] != NUL; + return str[0] == '\\' && str[1] != '\0'; #endif // ifdef BACKSLASH_IN_FILENAME } diff --git a/src/crypt.c b/src/crypt.c index 72d4a89c63..09c67d527d 100644 --- a/src/crypt.c +++ b/src/crypt.c @@ -75,7 +75,7 @@ int crypt_method_from_string(char_u *s) int get_crypt_method(buf_T *buf) { - return crypt_method_from_string(*buf->b_p_cm == NUL ? p_cm : buf->b_p_cm); + return crypt_method_from_string(*buf->b_p_cm == '\0' ? p_cm : buf->b_p_cm); } void set_crypt_method(buf_T *buf, int method) @@ -156,7 +156,7 @@ void crypt_decode(char_u *ptr, long len) void crypt_init_keys(char_u *passwd) { - if ((passwd != NULL) && (*passwd != NUL)) { + if ((passwd != NULL) && (*passwd != '\0')) { if (use_crypt_method == 0) { char_u *p; @@ -165,7 +165,7 @@ void crypt_init_keys(char_u *passwd) keys[1] = 591751049L; keys[2] = 878082192L; - for (p = passwd; *p != NUL; p++) { + for (p = passwd; *p != '\0'; ++p) { UPDATE_KEYS_ZIP((int)*p); } } else { @@ -179,7 +179,7 @@ void free_crypt_key(char_u *key) char_u *p; if (key != NULL) { - for (p = key; *p != NUL; p++) { + for (p = key; *p != '\0'; ++p) { *p = 0; } free(key); @@ -198,7 +198,7 @@ char_u *get_crypt_key(int store, int twice) char_u *prompt = (round == 0) ? (char_u *) _("Enter encryption key: ") : (char_u *) _("Enter same key again: "); - p1 = getcmdline_prompt(NUL, prompt, 0, EXPAND_NOTHING, NULL); + p1 = getcmdline_prompt('\0', prompt, 0, EXPAND_NOTHING, NULL); cmdline_star = FALSE; if (p1 == NULL) { break; diff --git a/src/cursor_shape.c b/src/cursor_shape.c index 05d51e1c9d..14f22c5a6f 100644 --- a/src/cursor_shape.c +++ b/src/cursor_shape.c @@ -61,7 +61,7 @@ char_u *parse_shape_opt(int what) * Repeat for all comma separated parts. */ modep = p_guicursor; - while (*modep != NUL) { + while (*modep != '\0') { colonp = vim_strchr(modep, ':'); if (colonp == NULL) return (char_u *)N_("E545: Missing colon"); diff --git a/src/diff.c b/src/diff.c index 74e145f96c..e06f2612a3 100644 --- a/src/diff.c +++ b/src/diff.c @@ -735,7 +735,7 @@ void ex_diffupdate(exarg_T *eap) } // When using 'diffexpr' break here. - if (*p_dex != NUL) { + if (*p_dex != '\0') { break; } @@ -813,7 +813,7 @@ theend: /// @param tmp_diff static void diff_file(char_u *tmp_orig, char_u *tmp_new, char_u *tmp_diff) { - if (*p_dex != NUL) { + if (*p_dex != '\0') { // Use 'diffexpr' to generate the diff file. eval_diff(tmp_orig, tmp_new, tmp_diff); } else { @@ -906,7 +906,7 @@ void ex_diffpatch(exarg_T *eap) // return to the current. if ((os_dirname(dirbuf, MAXPATHL) != OK) || (os_chdir((char *)dirbuf) != 0)) { - dirbuf[0] = NUL; + dirbuf[0] = '\0'; } else { # ifdef TEMPDIRNAMES if (vim_tempdir != NULL) { @@ -921,7 +921,7 @@ void ex_diffpatch(exarg_T *eap) } #endif // ifdef UNIX - if (*p_pex != NUL) { + if (*p_pex != '\0') { // Use 'patchexpr' to generate the new file. #ifdef UNIX eval_patch(tmp_orig, fullname != NULL ? fullname : eap->arg, tmp_new); @@ -945,7 +945,7 @@ void ex_diffpatch(exarg_T *eap) } #ifdef UNIX - if (dirbuf[0] != NUL) { + if (dirbuf[0] != '\0') { if (os_chdir((char *)dirbuf) != 0) { EMSG(_(e_prev_dir)); } @@ -1614,7 +1614,7 @@ static int diff_cmp(char_u *s1, char_u *s2) char_u *p1 = s1; char_u *p2 = s2; - while (*p1 != NUL && *p2 != NUL) { + while (*p1 != '\0' && *p2 != '\0') { if (vim_iswhite(*p1) && vim_iswhite(*p2)) { p1 = skipwhite(p1); p2 = skipwhite(p2); @@ -1650,7 +1650,7 @@ static int diff_cmp(char_u *s1, char_u *s2) p1 = skipwhite(p1); p2 = skipwhite(p2); - if ((*p1 != NUL) || (*p2 != NUL)) { + if ((*p1 != '\0') || (*p2 != '\0')) { return 1; } return 0; @@ -1802,7 +1802,7 @@ int diffopt_changed(void) int diff_foldcolumn_new = 2; char_u *p = p_dip; - while (*p != NUL) { + while (*p != '\0') { if (STRNCMP(p, "filler", 6) == 0) { p += 6; diff_flags_new |= DIFF_FILLER; @@ -1826,7 +1826,7 @@ int diffopt_changed(void) diff_foldcolumn_new = getdigits(&p); } - if ((*p != ',') && (*p != NUL)) { + if ((*p != ',') && (*p != '\0')) { return FAIL; } @@ -1924,7 +1924,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) // Search for start of difference si_org = si_new = 0; - while (line_org[si_org] != NUL) { + while (line_org[si_org] != '\0') { if ((diff_flags & DIFF_IWHITE) && vim_iswhite(line_org[si_org]) && vim_iswhite(line_new[si_new])) { @@ -1951,7 +1951,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) } // Search for end of difference, if any. - if ((line_org[si_org] != NUL) || (line_new[si_new] != NUL)) { + if ((line_org[si_org] != '\0') || (line_new[si_new] != '\0')) { ei_org = (int)STRLEN(line_org); ei_new = (int)STRLEN(line_new); @@ -2094,7 +2094,7 @@ void ex_diffgetput(exarg_T *eap) return; } - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { // No argument: Find the other buffer in the list of diff buffers. for (idx_other = 0; idx_other < DB_COUNT; ++idx_other) { if ((curtab->tp_diffbuf[idx_other] != curbuf) diff --git a/src/digraph.c b/src/digraph.c index 88f183be4f..f4f8e2a711 100644 --- a/src/digraph.c +++ b/src/digraph.c @@ -1400,7 +1400,7 @@ static digr_T digraphdefault[] = { 'u', '^', 251 }, // û { 'y', '"', 255 }, // x XX - { NUL, NUL, NUL } + { '\0', '\0', '\0' } }; /// handle digraphs after typing a character @@ -1469,7 +1469,7 @@ int get_digraph(int cmdline) return getdigraph(c, cc, TRUE); } } - return NUL; + return '\0'; } /// Lookup the pair "char1", "char2" in the digraph tables. @@ -1579,10 +1579,10 @@ void putdigraph(char_u *str) int i; digr_T *dp; - while (*str != NUL) { + while (*str != '\0') { str = skipwhite(str); - if (*str == NUL) { + if (*str == '\0') { return; } char1 = *str++; @@ -1637,7 +1637,7 @@ void listdigraphs(void) dp = digraphdefault; - for (i = 0; dp->char1 != NUL && !got_int; ++i) { + for (i = 0; dp->char1 != '\0' && !got_int; ++i) { digr_T tmp; // May need to convert the result to 'encoding'. @@ -1731,7 +1731,7 @@ char_u* keymap_init(void) { curbuf->b_kmap_state &= ~KEYMAP_INIT; - if (*curbuf->b_p_keymap == NUL) { + if (*curbuf->b_p_keymap == '\0') { // Stop any active keymap and clear the table. Also remove // b:keymap_name, as no keymap is active now. keymap_unload(); @@ -1808,7 +1808,7 @@ void ex_loadkeymap(exarg_T *eap) p = skipwhite(line); - if ((*p != '"') && (*p != NUL)) { + if ((*p != '"') && (*p != '\0')) { ga_grow(&curbuf->b_kmap_ga, 1); kp = (kmap_T *)curbuf->b_kmap_ga.ga_data + curbuf->b_kmap_ga.ga_len; s = skiptowhite(p); @@ -1820,9 +1820,9 @@ void ex_loadkeymap(exarg_T *eap) if ((kp->from == NULL) || (kp->to == NULL) || (STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN) - || (*kp->from == NUL) - || (*kp->to == NUL)) { - if ((kp->to != NULL) && (*kp->to == NUL)) { + || (*kp->from == '\0') + || (*kp->to == '\0')) { + if ((kp->to != NULL) && (*kp->to == '\0')) { EMSG(_("E791: Empty keymap entry")); } vim_free(kp->from); diff --git a/src/edit.c b/src/edit.c index 702d117580..c2b0ead2eb 100644 --- a/src/edit.c +++ b/src/edit.c @@ -400,7 +400,7 @@ edit ( * line number is still valid (lines may have been deleted). * Do not restore if v:char was set to a non-empty string. */ if (!equalpos(curwin->w_cursor, save_cursor) - && *get_vim_var_str(VV_CHAR) == NUL + && *get_vim_var_str(VV_CHAR) == '\0' && save_cursor.lnum <= curbuf->b_ml.ml_line_count) { int save_state = State; @@ -431,7 +431,7 @@ edit ( if (!did_ai) ai_col = 0; - if (cmdchar != NUL && restart_edit == 0) { + if (cmdchar != '\0' && restart_edit == 0) { ResetRedobuff(); AppendNumberToRedobuff(count); if (cmdchar == 'V' || cmdchar == 'v') { @@ -519,12 +519,12 @@ edit ( update_curswant(); if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum) || curwin->w_curswant > curwin->w_virtcol) - && *(ptr = ml_get_curline() + curwin->w_cursor.col) != NUL) { - if (ptr[1] == NUL) + && *(ptr = ml_get_curline() + curwin->w_cursor.col) != '\0') { + if (ptr[1] == '\0') ++curwin->w_cursor.col; else if (has_mbyte) { i = (*mb_ptr2len)(ptr); - if (ptr[i] == NUL) + if (ptr[i] == '\0') curwin->w_cursor.col += i; } } @@ -708,7 +708,7 @@ edit ( /* BS: Delete one character from "compl_leader". */ if ((c == K_BS || c == Ctrl_H) && curwin->w_cursor.col > compl_col - && (c = ins_compl_bs()) == NUL) + && (c = ins_compl_bs()) == '\0') continue; /* When no match was selected or it was edited. */ @@ -732,7 +732,7 @@ edit ( char_u *p; if (str != NULL) { - for (p = str; *p != NUL; mb_ptr_adv(p)) + for (p = str; *p != '\0'; mb_ptr_adv(p)) ins_compl_addleader(PTR2CHAR(p)); vim_free(str); } else @@ -864,7 +864,7 @@ doESCkey: */ /* Always update o_lnum, so that a "CTRL-O ." that adds a line * still puts the cursor back after the inserted text. */ - if (ins_at_eol && gchar_cursor() == NUL) + if (ins_at_eol && gchar_cursor() == '\0') o_lnum = curwin->w_cursor.lnum; if (ins_esc(&count, cmdchar, nomove)) { @@ -917,11 +917,11 @@ doESCkey: case K_ZERO: /* Insert the previously inserted text. */ - case NUL: + case '\0': case Ctrl_A: /* For ^@ the trailing ESC will end the insert, unless there is an * error. */ - if (stuff_inserted(NUL, 1L, (c == Ctrl_A)) == FAIL + if (stuff_inserted('\0', 1L, (c == Ctrl_A)) == FAIL && c != Ctrl_A && !p_im) goto doESCkey; /* quit insert mode */ inserted_space = FALSE; @@ -1155,7 +1155,7 @@ doESCkey: break; } c = ins_digraph(); - if (c == NUL) + if (c == '\0') break; goto normalchar; @@ -1195,7 +1195,7 @@ doESCkey: case Ctrl_N: /* if 'complete' is empty then plain ^P is no longer special, * but it is under other ^X modes */ - if (*curbuf->b_p_cpt == NUL + if (*curbuf->b_p_cpt == '\0' && ctrl_x_mode != 0 && !(compl_cont_status & CONT_LOCAL)) goto normalchar; @@ -1228,9 +1228,9 @@ normalchar: char_u *p; if (str != NULL) { - if (*str != NUL && stop_arrow() != FAIL) { + if (*str != '\0' && stop_arrow() != FAIL) { /* Insert the new value of v:char literally. */ - for (p = str; *p != NUL; mb_ptr_adv(p)) { + for (p = str; *p != '\0'; mb_ptr_adv(p)) { c = PTR2CHAR(p); if (c == CAR || c == K_KENTER || c == NL) ins_eol(c); @@ -1240,12 +1240,12 @@ normalchar: AppendToRedobuffLit(str, -1); } vim_free(str); - c = NUL; + c = '\0'; } /* If the new value is already inserted or an empty string * then don't insert any character. */ - if (c == NUL) + if (c == '\0') break; } /* Try to perform smart-indenting. */ @@ -1654,7 +1654,7 @@ change_indent ( i = (int)curwin->w_virtcol - vcol; ptr = alloc((unsigned)(i + 1)); new_cursor_col += i; - ptr[i] = NUL; + ptr[i] = '\0'; while (--i >= 0) ptr[i] = ' '; ins_str(ptr); @@ -1706,10 +1706,10 @@ change_indent ( --start_col; } while (start_col < (int)curwin->w_cursor.col || replaced) { - replace_push(NUL); + replace_push('\0'); if (replaced) { replace_push(replaced); - replaced = NUL; + replaced = '\0'; } ++start_col; } @@ -1732,7 +1732,7 @@ change_indent ( return; /* We only put back the new line up to the cursor */ - new_line[curwin->w_cursor.col] = NUL; + new_line[curwin->w_cursor.col] = '\0'; /* Put back original line */ ml_replace(curwin->w_cursor.lnum, orig_line, FALSE); @@ -1762,7 +1762,7 @@ void truncate_spaces(char_u *line) if (State & REPLACE_FLAG) replace_join(0); /* remove a NUL from the replace stack */ } - line[i + 1] = NUL; + line[i + 1] = '\0'; } #if defined(FEAT_VREPLACE) || defined(FEAT_INS_EXPAND) \ @@ -1806,7 +1806,7 @@ static int del_char_after_col(int limit_col) break; curwin->w_cursor.col += l; } - if (*ml_get_cursor() == NUL || curwin->w_cursor.col == ecol) + if (*ml_get_cursor() == '\0' || curwin->w_cursor.col == ecol) return FALSE; del_bytes((long)((int)ecol - curwin->w_cursor.col), FALSE, TRUE); } else @@ -1841,10 +1841,10 @@ static void ins_ctrl_x(void) */ static int has_compl_option(int dict_opt) { - if (dict_opt ? (*curbuf->b_p_dict == NUL && *p_dict == NUL + if (dict_opt ? (*curbuf->b_p_dict == '\0' && *p_dict == '\0' && !curwin->w_p_spell ) - : (*curbuf->b_p_tsr == NUL && *p_tsr == NUL)) { + : (*curbuf->b_p_tsr == '\0' && *p_tsr == '\0')) { ctrl_x_mode = 0; edit_submode = NULL; msg_attr(dict_opt ? (char_u *)_("'dictionary' option is empty") @@ -1970,7 +1970,7 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int if (has_mbyte) { p = str; actual_len = 0; - while (*p != NUL) { + while (*p != '\0') { mb_ptr_adv(p); ++actual_len; } @@ -1981,7 +1981,7 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int if (has_mbyte) { p = compl_orig_text; actual_compl_length = 0; - while (*p != NUL) { + while (*p != '\0') { mb_ptr_adv(p); ++actual_compl_length; } @@ -2067,7 +2067,7 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int p += (*mb_char2bytes)(wca[i++], p); else *(p++) = wca[i++]; - *p = NUL; + *p = '\0'; vim_free(wca); @@ -2112,7 +2112,7 @@ ins_compl_add ( do { if ( !(match->cp_flags & ORIGINAL_TEXT) && STRNCMP(match->cp_str, str, len) == 0 - && match->cp_str[len] == NUL) + && match->cp_str[len] == '\0') return NOTDONE; match = match->cp_next; } while (match != NULL && match != compl_first_match); @@ -2155,7 +2155,7 @@ ins_compl_add ( int i; for (i = 0; i < CPT_COUNT; ++i) - if (cptext[i] != NULL && *cptext[i] != NUL) + if (cptext[i] != NULL && *cptext[i] != '\0') match->cp_text[i] = vim_strsave(cptext[i]); } @@ -2227,7 +2227,7 @@ static void ins_compl_longest_match(compl_T *match) /* Reduce the text if this match differs from compl_leader. */ p = compl_leader; s = match->cp_str; - while (*p != NUL) { + while (*p != '\0') { if (has_mbyte) { c1 = mb_ptr2char(p); c2 = mb_ptr2char(s); @@ -2247,9 +2247,9 @@ static void ins_compl_longest_match(compl_T *match) } } - if (*p != NUL) { + if (*p != '\0') { /* Leader was shortened, need to change the inserted text. */ - *p = NUL; + *p = '\0'; had_match = (curwin->w_cursor.col > compl_col); ins_compl_delete(); ins_bytes(compl_leader + ins_compl_len()); @@ -2567,7 +2567,7 @@ ins_compl_dictionaries ( int save_p_scs; int dir = compl_direction; - if (*dict == NUL) { + if (*dict == '\0') { /* When 'dictionary' is empty and spell checking is enabled use * "spell". */ if (!thesaurus && curwin->w_p_spell) @@ -2607,7 +2607,7 @@ ins_compl_dictionaries ( /* ignore case depends on 'ignorecase', 'smartcase' and "pat" */ regmatch.rm_ic = ignorecase(pat); - while (*dict != NUL && !got_int && !compl_interrupted) { + while (*dict != '\0' && !got_int && !compl_interrupted) { /* copy one dictionary file name into buf */ if (flags == DICT_EXACT) { count = 1; @@ -2692,7 +2692,7 @@ static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, /* Find start of the next word. Skip white * space and punctuation. */ ptr = find_word_start(ptr); - if (*ptr == NUL || *ptr == NL) + if (*ptr == '\0' || *ptr == NL) break; wstart = ptr; @@ -2701,7 +2701,7 @@ static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, /* Japanese words may have characters in * different classes, only separate words * with single-byte non-word characters. */ - while (*ptr != NUL) { + while (*ptr != '\0') { int l = (*mb_ptr2len)(ptr); if (l < 2 && !vim_iswordc(*ptr)) @@ -2743,10 +2743,10 @@ static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, char_u *find_word_start(char_u *ptr) { if (has_mbyte) - while (*ptr != NUL && *ptr != '\n' && mb_get_class(ptr) <= 1) + while (*ptr != '\0' && *ptr != '\n' && mb_get_class(ptr) <= 1) ptr += (*mb_ptr2len)(ptr); else - while (*ptr != NUL && *ptr != '\n' && !vim_iswordc(*ptr)) + while (*ptr != '\0' && *ptr != '\n' && !vim_iswordc(*ptr)) ++ptr; return ptr; } @@ -2762,7 +2762,7 @@ char_u *find_word_end(char_u *ptr) if (has_mbyte) { start_class = mb_get_class(ptr); if (start_class > 1) - while (*ptr != NUL) { + while (*ptr != '\0') { ptr += (*mb_ptr2len)(ptr); if (mb_get_class(ptr) != start_class) break; @@ -2880,7 +2880,7 @@ static int ins_compl_bs(void) if (compl_shown_match != NULL) /* Make sure current match is not a hidden item. */ compl_curr_match = compl_shown_match; - return NUL; + return '\0'; } return K_BS; } @@ -2961,7 +2961,7 @@ static void ins_compl_addleader(int c) char_u buf[MB_MAXBYTES + 1]; (*mb_char2bytes)(c, buf); - buf[cc] = NUL; + buf[cc] = '\0'; ins_char_bytes(buf, cc); if (compl_opt_refresh_always) AppendToRedobuff(buf); @@ -3233,9 +3233,9 @@ static int ins_compl_prep(int c) if (prev_col > 0) dec_cursor(); if (stop_arrow() == OK) - insertchar(NUL, 0, -1); + insertchar('\0', 0, -1); if (prev_col > 0 - && ml_get_curline()[curwin->w_cursor.col] != NUL) + && ml_get_curline()[curwin->w_cursor.col] != '\0') inc_cursor(); } @@ -3313,11 +3313,11 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg) } if (compl_orig_text != NULL) { p = compl_orig_text; - for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len) + for (len = 0; p[len] != '\0' && p[len] == ptr[len]; ++len) ; if (len > 0) len -= (*mb_head_off)(p, p + len); - for (p += len; *p != NUL; mb_ptr_adv(p)) + for (p += len; *p != '\0'; mb_ptr_adv(p)) AppendCharToRedobuff(K_BS); } else len = 0; @@ -3380,7 +3380,7 @@ expand_by_function ( typval_T rettv; funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu; - if (*funcname == NUL) + if (*funcname == '\0') return; /* Call 'completefunc' to obtain the list of matches. */ @@ -3506,7 +3506,7 @@ int ins_compl_add_tv(typval_T *tv, int dir) word = get_tv_string_chk(tv); memset(cptext, 0, sizeof(cptext)); } - if (word == NULL || (!aempty && *word == NUL)) + if (word == NULL || (!aempty && *word == '\0')) return FAIL; return ins_compl_add(word, -1, icase, NULL, cptext, dir, 0, adup); } @@ -3607,7 +3607,7 @@ static int ins_compl_get_exp(pos_T *ini) ? ins_buf->b_fname : ins_buf->b_sfname); (void)msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R)); - } else if (*e_cpt == NUL) + } else if (*e_cpt == '\0') break; else { if (ctrl_x_mode == CTRL_X_WHOLE_LINE) @@ -3617,7 +3617,7 @@ static int ins_compl_get_exp(pos_T *ini) type = CTRL_X_DICTIONARY; else type = CTRL_X_THESAURUS; - if (*++e_cpt != ',' && *e_cpt != NUL) { + if (*++e_cpt != ',' && *e_cpt != '\0') { dict = e_cpt; dict_f = DICT_FIRST; } @@ -3659,10 +3659,10 @@ static int ins_compl_get_exp(pos_T *ini) ins_compl_dictionaries( dict != NULL ? dict : (type == CTRL_X_THESAURUS - ? (*curbuf->b_p_tsr == NUL + ? (*curbuf->b_p_tsr == '\0' ? p_tsr : curbuf->b_p_tsr) - : (*curbuf->b_p_dict == NUL + : (*curbuf->b_p_dict == '\0' ? p_dict : curbuf->b_p_dict)), compl_pattern, @@ -3830,7 +3830,7 @@ static int ins_compl_get_exp(pos_T *ini) len += (int)(tmp_ptr - ptr); flags |= CONT_S_IPOS; } - IObuff[len] = NUL; + IObuff[len] = '\0'; ptr = IObuff; } if (len == compl_length) @@ -3878,7 +3878,7 @@ static int ins_compl_get_exp(pos_T *ini) compl_started = TRUE; if ((ctrl_x_mode == 0 || ctrl_x_mode == CTRL_X_WHOLE_LINE) - && *e_cpt == NUL) /* Got to end of 'complete' */ + && *e_cpt == '\0') /* Got to end of 'complete' */ found_new_match = FAIL; i = -1; /* total of matches, unknown */ @@ -4137,7 +4137,7 @@ void ins_compl_check_keys(int frequency) /* Check for a typed key. Do use mappings, otherwise vim_is_ctrl_x_key() * can't do its work correctly. */ c = vpeekc_any(); - if (c != NUL) { + if (c != '\0') { if (vim_is_ctrl_x_key(c) && c != Ctrl_X && c != Ctrl_R) { c = safe_vgetc(); /* Eat the character */ compl_shows_dir = ins_compl_key2dir(c); @@ -4463,7 +4463,7 @@ static int ins_complete(int c) * string */ funcname = ctrl_x_mode == CTRL_X_FUNCTION ? curbuf->b_p_cfu : curbuf->b_p_ofu; - if (*funcname == NUL) { + if (*funcname == '\0') { EMSG2(_(e_notset), ctrl_x_mode == CTRL_X_FUNCTION ? "completefunc" : "omnifunc"); return FAIL; @@ -4795,7 +4795,7 @@ static unsigned quote_meta(char_u *dest, char_u *src, int len) } } if (dest != NULL) - *dest = NUL; + *dest = '\0'; return m; } @@ -4921,7 +4921,7 @@ insert_special ( if (len > 2) { if (stop_arrow() == FAIL) return; - p[len - 1] = NUL; + p[len - 1] = '\0'; ins_str(p); AppendToRedobuffLit(p, -1); ctrlv = FALSE; @@ -4990,7 +4990,7 @@ insertchar ( || (!vim_iswhite(c) && !((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG) - && *ml_get_cursor() != NUL) + && *ml_get_cursor() != '\0') && (curwin->w_cursor.lnum != Insstart.lnum || ((!has_format_option(FO_INS_LONG) || Insstart_textlen <= (colnr_T)textwidth) @@ -5001,17 +5001,17 @@ insertchar ( * when 'formatexpr' isn't set or it returns non-zero. */ int do_internal = TRUE; - if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0) { + if (*curbuf->b_p_fex != '\0' && (flags & INSCHAR_NO_FEX) == 0) { do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0); /* It may be required to save for undo again, e.g. when setline() * was called. */ ins_need_undo = TRUE; } if (do_internal) - internal_format(textwidth, second_indent, flags, c == NUL, c); + internal_format(textwidth, second_indent, flags, c == '\0', c); } - if (c == NUL) /* only formatting was wanted */ + if (c == '\0') /* only formatting was wanted */ return; /* Check whether this character should end a comment. */ @@ -5062,7 +5062,7 @@ insertchar ( } } } - end_comment_pending = NUL; + end_comment_pending = '\0'; did_ai = FALSE; did_si = FALSE; @@ -5084,7 +5084,7 @@ insertchar ( if ( !ISSPECIAL(c) && (!has_mbyte || (*mb_char2len)(c) == 1) - && vpeekc() != NUL + && vpeekc() != '\0' && !(State & REPLACE_FLAG) && !cindent_on() && !p_ri @@ -5107,7 +5107,7 @@ insertchar ( * - running into the 'textwidth' boundary * - need to check for abbreviation: A non-word char after a word-char */ - while ( (c = vpeekc()) != NUL + while ( (c = vpeekc()) != '\0' && !ISSPECIAL(c) && (!has_mbyte || MB_BYTE2LEN_CHECK(c) == 1) && i < INPUT_BUFLEN @@ -5124,14 +5124,14 @@ insertchar ( do_digraph(-1); /* clear digraphs */ do_digraph(buf[i-1]); /* may be the start of a digraph */ - buf[i] = NUL; + buf[i] = '\0'; ins_str(buf); if (flags & INSCHAR_CTRLV) { redo_literal(*buf); i = 1; } else i = 0; - if (buf[i] != NUL) + if (buf[i] != '\0') AppendToRedobuffLit(buf + i, -1); } else { int cc; @@ -5140,7 +5140,7 @@ insertchar ( char_u buf[MB_MAXBYTES + 1]; (*mb_char2bytes)(c, buf); - buf[cc] = NUL; + buf[cc] = '\0'; ins_char_bytes(buf, cc); AppendCharToRedobuff(c); } else { @@ -5169,7 +5169,7 @@ internal_format ( ) { int cc; - int save_char = NUL; + int save_char = '\0'; int haveto_redraw = FALSE; int fo_ins_blank = has_format_option(FO_INS_BLANK); int fo_multibyte = has_format_option(FO_MBYTE_BREAK); @@ -5209,7 +5209,7 @@ internal_format ( colnr_T end_col; virtcol = get_nolist_virtcol() - + char2cells(c != NUL ? c : gchar_cursor()); + + char2cells(c != '\0' ? c : gchar_cursor()); if (virtcol <= (colnr_T)textwidth) break; @@ -5254,7 +5254,7 @@ internal_format ( || (flags & INSCHAR_FORMAT) || curwin->w_cursor.lnum != Insstart.lnum || curwin->w_cursor.col >= Insstart.col) { - if (curwin->w_cursor.col == startcol && c != NUL) + if (curwin->w_cursor.col == startcol && c != '\0') cc = c; else cc = gchar_cursor(); @@ -5377,7 +5377,7 @@ internal_format ( curwin->w_cursor.col = orig_col; if (saved_text == NULL) break; /* Can't do it, out of memory */ - saved_text[startcol] = NUL; + saved_text[startcol] = '\0'; /* Backspace over characters that will move to the next line */ if (!fo_white_par) @@ -5416,7 +5416,7 @@ internal_format ( if (second_indent >= 0) { if (State & VREPLACE_FLAG) change_indent(INDENT_SET, second_indent, - FALSE, NUL, TRUE); + FALSE, '\0', TRUE); else if (leader_len > 0 && second_indent - leader_len > 0) { int i; int padding = second_indent - leader_len; @@ -5466,7 +5466,7 @@ internal_format ( line_breakcheck(); } - if (save_char != NUL) /* put back space after cursor */ + if (save_char != '\0') /* put back space after cursor */ pchar_cursor(save_char); if (!format_only && haveto_redraw) { @@ -5510,7 +5510,7 @@ auto_format ( * Otherwise the line would be broken and when typing another non-white * next they are not joined back together. */ wasatend = (pos.col == (colnr_T)STRLEN(old)); - if (*old != NUL && !trailblank && wasatend) { + if (*old != '\0' && !trailblank && wasatend) { dec_cursor(); cc = gchar_cursor(); if (!WHITECHAR(cc) && curwin->w_cursor.col > 0 @@ -5567,7 +5567,7 @@ auto_format ( if (curwin->w_cursor.col == len) { pnew = vim_strnsave(new, len + 2); pnew[len] = ' '; - pnew[len + 1] = NUL; + pnew[len + 1] = '\0'; ml_replace(curwin->w_cursor.lnum, pnew, FALSE); /* remove the space later */ did_add_space = TRUE; @@ -5603,7 +5603,7 @@ check_auto_format ( c = gchar_cursor(); dec_cursor(); } - if (c != NUL) { + if (c != '\0') { /* The space is no longer at the end of the line, delete it. */ del_char(FALSE); did_add_space = FALSE; @@ -5789,7 +5789,7 @@ stop_insert ( * formatting will move it to the following word. Avoid that by * moving the cursor onto the space. */ cc = 'x'; - if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL) { + if (curwin->w_cursor.col > 0 && gchar_cursor() == '\0') { dec_cursor(); cc = gchar_cursor(); if (!vim_iswhite(cc)) @@ -5799,11 +5799,11 @@ stop_insert ( auto_format(TRUE, FALSE); if (vim_iswhite(cc)) { - if (gchar_cursor() != NUL) + if (gchar_cursor() != '\0') inc_cursor(); /* If the cursor is still at the same character, also keep * the "coladd". */ - if (gchar_cursor() == NUL + if (gchar_cursor() == '\0' && curwin->w_cursor.lnum == tpos.lnum && curwin->w_cursor.col == tpos.col) curwin->w_cursor.coladd = tpos.coladd; @@ -5827,7 +5827,7 @@ stop_insert ( curwin->w_cursor = *end_insert_pos; check_cursor_col(); /* make sure it is not past the line */ for (;; ) { - if (gchar_cursor() == NUL && curwin->w_cursor.col > 0) + if (gchar_cursor() == '\0' && curwin->w_cursor.col > 0) --curwin->w_cursor.col; cc = gchar_cursor(); if (!vim_iswhite(cc)) @@ -5837,7 +5837,7 @@ stop_insert ( } if (curwin->w_cursor.lnum != tpos.lnum) curwin->w_cursor = tpos; - else if (cc != NUL) + else if (cc != '\0') ++curwin->w_cursor.col; /* put cursor back on the NUL */ /* <C-S-Right> may have started Visual mode, adjust the position for @@ -5882,7 +5882,7 @@ void set_last_insert(int c) *s++ = Ctrl_V; s = add_char2buf(c, s); *s++ = ESC; - *s++ = NUL; + *s++ = '\0'; last_insert_skip = 0; } @@ -5941,7 +5941,7 @@ void beginline(int flags) char_u *ptr; for (ptr = ml_get_curline(); vim_iswhite(*ptr) - && !((flags & BL_FIX) && ptr[1] == NUL); ++ptr) + && !((flags & BL_FIX) && ptr[1] == '\0'); ++ptr) ++curwin->w_cursor.col; } curwin->w_set_curswant = TRUE; @@ -5977,7 +5977,7 @@ int oneright(void) } ptr = ml_get_cursor(); - if (*ptr == NUL) + if (*ptr == '\0') return FAIL; /* already at the very end */ if (has_mbyte) @@ -5987,7 +5987,7 @@ int oneright(void) /* move "l" bytes right, but don't end up on the NUL, unless 'virtualedit' * contains "onemore". */ - if (ptr[l] == NUL + if (ptr[l] == '\0' && (ve_flags & VE_ONEMORE) == 0 ) return FAIL; @@ -6012,7 +6012,7 @@ int oneleft(void) coladvance(v - width); /* getviscol() is slow, skip it when 'showbreak' is empty and * there are no multi-byte characters */ - if ((*p_sbr == NUL + if ((*p_sbr == '\0' && !has_mbyte ) || getviscol() < v) break; @@ -6163,7 +6163,7 @@ stuff_inserted ( char_u *esc_ptr; char_u *ptr; char_u *last_ptr; - char_u last = NUL; + char_u last = '\0'; ptr = get_last_insert(); if (ptr == NULL) { @@ -6172,10 +6172,10 @@ stuff_inserted ( } /* may want to stuff the command character, to start Insert mode */ - if (c != NUL) + if (c != '\0') stuffcharReadbuff(c); if ((esc_ptr = (char_u *)vim_strrchr(ptr, ESC)) != NULL) - *esc_ptr = NUL; /* remove the ESC */ + *esc_ptr = '\0'; /* remove the ESC */ /* when the last char is either "0" or "^" it will be quoted if no ESC * comes after it OR if it will inserted more than once and "ptr" @@ -6185,7 +6185,7 @@ stuff_inserted ( if (last_ptr >= ptr && (*last_ptr == '0' || *last_ptr == '^') && (no_esc || (*ptr == Ctrl_D && count > 1))) { last = *last_ptr; - *last_ptr = NUL; + *last_ptr = '\0'; } do { @@ -6232,7 +6232,7 @@ char_u *get_last_insert_save(void) if (s != NULL) { len = (int)STRLEN(s); if (len > 0 && s[len - 1] == ESC) /* remove trailing ESC */ - s[len - 1] = NUL; + s[len - 1] = '\0'; } return s; } @@ -6342,7 +6342,7 @@ replace_join ( int i; for (i = replace_stack_nr; --i >= 0; ) - if (replace_stack[i] == NUL && off-- <= 0) { + if (replace_stack[i] == '\0' && off-- <= 0) { --replace_stack_nr; memmove(replace_stack + i, replace_stack + i + 1, (size_t)(replace_stack_nr - i)); @@ -6496,7 +6496,7 @@ static void replace_do_bs(int limit_col) */ static int cindent_on(void) { return !p_paste && (curbuf->b_p_cin - || *curbuf->b_p_inde != NUL + || *curbuf->b_p_inde != '\0' ); } @@ -6547,11 +6547,11 @@ int in_cinkeys(int keytyped, int when, int line_is_empty) int icase; int i; - if (keytyped == NUL) + if (keytyped == '\0') /* Can happen with CTRL-Y and CTRL-E on a short line. */ return FALSE; - if (*curbuf->b_p_inde != NUL) + if (*curbuf->b_p_inde != '\0') look = curbuf->b_p_indk; /* 'indentexpr' set: use 'indentkeys' */ else look = curbuf->b_p_cink; /* 'indentexpr' empty: use 'cinkeys' */ @@ -6667,7 +6667,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty) /* * Is it a word: "=word"? */ - else if (*look == '=' && look[1] != ',' && look[1] != NUL) { + else if (*look == '=' && look[1] != ',' && look[1] != '\0') { ++look; if (*look == '~') { icase = TRUE; @@ -6873,7 +6873,7 @@ static void ins_reg(void) im_set_active(TRUE); # endif } - if (regname == NUL || !valid_yank_reg(regname, FALSE)) { + if (regname == '\0' || !valid_yank_reg(regname, FALSE)) { vim_beep(); need_redraw = TRUE; /* remove the '"' */ } else { @@ -7051,7 +7051,7 @@ ins_esc ( /* When an autoindent was removed, curswant stays after the * indent */ - if (restart_edit == NUL && (colnr_T)temp == curwin->w_cursor.col) + if (restart_edit == '\0' && (colnr_T)temp == curwin->w_cursor.col) curwin->w_set_curswant = TRUE; /* Remember the last Insert position in the '^ mark. */ @@ -7066,15 +7066,15 @@ ins_esc ( && (curwin->w_cursor.col != 0 || curwin->w_cursor.coladd > 0 ) - && (restart_edit == NUL - || (gchar_cursor() == NUL + && (restart_edit == '\0' + || (gchar_cursor() == '\0' && !VIsual_active )) && !revins_on ) { if (curwin->w_cursor.coladd > 0 || ve_flags == VE_ALL) { oneleft(); - if (restart_edit != NUL) + if (restart_edit != '\0') ++curwin->w_cursor.coladd; } else { --curwin->w_cursor.col; @@ -7104,7 +7104,7 @@ ins_esc ( * When recording or for CTRL-O, need to display the new mode. * Otherwise remove the mode message. */ - if (Recording || restart_edit != NUL) + if (Recording || restart_edit != '\0') showmode(); else if (p_smd) MSG(""); @@ -7119,7 +7119,7 @@ ins_esc ( static void ins_ctrl_(void) { if (revins_on && revins_chars && revins_scol >= 0) { - while (gchar_cursor() != NUL && revins_chars--) + while (gchar_cursor() != '\0' && revins_chars--) ++curwin->w_cursor.col; } p_ri = !p_ri; @@ -7182,7 +7182,7 @@ static int ins_start_select(int c) buf[0] = K_SPECIAL; buf[1] = KS_MODIFIER; buf[2] = mod_mask; - buf[3] = NUL; + buf[3] = '\0'; stuffReadbuff(buf); } stuffcharReadbuff(c); @@ -7230,7 +7230,7 @@ static void ins_ctrl_o(void) if (virtual_active()) ins_at_eol = FALSE; /* cursor always keeps its column */ else - ins_at_eol = (gchar_cursor() == NUL); + ins_at_eol = (gchar_cursor() == '\0'); } /* @@ -7262,7 +7262,7 @@ static void ins_shift(int c, int lastc) } else change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE); - if (did_ai && *skipwhite(ml_get_curline()) != NUL) + if (did_ai && *skipwhite(ml_get_curline()) != '\0') did_ai = FALSE; did_si = FALSE; can_si = FALSE; @@ -7276,7 +7276,7 @@ static void ins_del(void) if (stop_arrow() == FAIL) return; - if (gchar_cursor() == NUL) { /* delete newline */ + if (gchar_cursor() == '\0') { /* delete newline */ temp = curwin->w_cursor.col; if (!can_bs(BS_EOL) /* only if "eol" included */ || do_join(2, FALSE, TRUE, FALSE) == FAIL) @@ -7353,7 +7353,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p) in_indent = inindent(0); if (in_indent) can_cindent = FALSE; - end_comment_pending = NUL; /* After BS, don't auto-end comment */ + end_comment_pending = '\0'; /* After BS, don't auto-end comment */ if (revins_on) /* put cursor after last inserted char */ inc_cursor(); @@ -7418,11 +7418,11 @@ static int ins_bs(int c, int mode, int *inserted_space_p) len = (int)STRLEN(ptr); if (len > 0 && ptr[len - 1] == ' ') - ptr[len - 1] = NUL; + ptr[len - 1] = '\0'; } (void)do_join(2, FALSE, FALSE, FALSE); - if (temp == NUL && gchar_cursor() != NUL) + if (temp == '\0' && gchar_cursor() != '\0') inc_cursor(); } else dec_cursor(); @@ -7526,7 +7526,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p) else { ins_str((char_u *)" "); if ((State & REPLACE_FLAG)) - replace_push(NUL); + replace_push('\0'); } getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); } @@ -7569,13 +7569,13 @@ static int ins_bs(int c, int mode, int *inserted_space_p) * move the cursor back. Don't back up before the base * character. */ - if (enc_utf8 && p_deco && cpc[0] != NUL) + if (enc_utf8 && p_deco && cpc[0] != '\0') inc_cursor(); if (revins_chars) { revins_chars--; revins_legal++; } - if (revins_on && gchar_cursor() == NUL) + if (revins_on && gchar_cursor() == '\0') break; } /* Just a single backspace?: */ @@ -7790,7 +7790,7 @@ static void ins_right(void) if ((fdo_flags & FDO_HOR) && KeyTyped) foldOpenCursor(); undisplay_dollar(); - if (gchar_cursor() != NUL + if (gchar_cursor() != '\0' || virtual_active() ) { start_arrow(&curwin->w_cursor); @@ -7826,7 +7826,7 @@ static void ins_s_right(void) foldOpenCursor(); undisplay_dollar(); if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count - || gchar_cursor() != NUL) { + || gchar_cursor() != '\0') { start_arrow(&curwin->w_cursor); (void)fwd_word(1L, FALSE, 0); curwin->w_set_curswant = TRUE; @@ -7984,7 +7984,7 @@ static int ins_tab(void) else { ins_str((char_u *)" "); if (State & REPLACE_FLAG) /* no char replaced */ - replace_push(NUL); + replace_push('\0'); } } @@ -8135,7 +8135,7 @@ static int ins_eol(int c) if ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG) ) - replace_push(NUL); + replace_push('\0'); /* * In VREPLACE mode, a NL replaces the rest of the line, and starts @@ -8208,7 +8208,7 @@ static int ins_digraph(void) if (IS_SPECIAL(c) || mod_mask) { /* special key */ clear_showcmd(); insert_special(c, TRUE, FALSE); - return NUL; + return '\0'; } if (c != ESC) { did_putchar = FALSE; @@ -8240,7 +8240,7 @@ static int ins_digraph(void) } } clear_showcmd(); - return NUL; + return '\0'; } /* @@ -8255,7 +8255,7 @@ int ins_copychar(linenr_T lnum) if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) { vim_beep(); - return NUL; + return '\0'; } /* try to advance to the cursor column */ @@ -8263,7 +8263,7 @@ int ins_copychar(linenr_T lnum) ptr = ml_get(lnum); prev_ptr = ptr; validate_virtcol(); - while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL) { + while ((colnr_T)temp < curwin->w_virtcol && *ptr != '\0') { prev_ptr = ptr; temp += lbr_chartabsize_adv(&ptr, (colnr_T)temp); } @@ -8271,7 +8271,7 @@ int ins_copychar(linenr_T lnum) ptr = prev_ptr; c = (*mb_ptr2char)(ptr); - if (c == NUL) + if (c == '\0') vim_beep(); return c; } @@ -8291,7 +8291,7 @@ static int ins_ctrl_ey(int tc) redraw_later(VALID); } else { c = ins_copychar(curwin->w_cursor.lnum + (c == Ctrl_Y ? -1 : 1)); - if (c != NUL) { + if (c != '\0') { long tw_save; /* The character must be taken literally, insert like it @@ -8352,7 +8352,7 @@ static void ins_try_si(int c) i = get_indent(); curwin->w_cursor = old_pos; if (State & VREPLACE_FLAG) - change_indent(INDENT_SET, i, FALSE, NUL, TRUE); + change_indent(INDENT_SET, i, FALSE, '\0', TRUE); else (void)set_indent(i, SIN_CHANGED); } else if (curwin->w_cursor.col > 0) { @@ -8368,7 +8368,7 @@ static void ins_try_si(int c) ptr = skipwhite(ml_get(--(curwin->w_cursor.lnum))); /* ignore empty lines and lines starting with '#'. */ - if (*ptr != '#' && *ptr != NUL) + if (*ptr != '#' && *ptr != '\0') break; } if (get_indent() >= i) @@ -8422,10 +8422,10 @@ static char_u *do_insert_char_pre(int c) return NULL; if (has_mbyte) - buf[(*mb_char2bytes)(c, buf)] = NUL; + buf[(*mb_char2bytes)(c, buf)] = '\0'; else { buf[0] = c; - buf[1] = NUL; + buf[1] = '\0'; } /* Lock the text to avoid weird things from happening. */ diff --git a/src/eval.c b/src/eval.c index 93d33a2c96..c237a90b74 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1051,9 +1051,9 @@ var_redir_start ( redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, 0, FNE_CHECK_START); if (redir_endp == NULL || redir_lval->ll_name == NULL || *redir_endp != - NUL) { + '\0') { clear_lval(redir_lval); - if (redir_endp != NULL && *redir_endp != NUL) + if (redir_endp != NULL && *redir_endp != '\0') /* Trailing characters are present after the variable name */ EMSG(_(e_trailing)); else @@ -1122,7 +1122,7 @@ void var_redir_stop(void) if (redir_lval != NULL) { /* If there was no error: assign the text to the variable. */ if (redir_endp != NULL) { - ga_append(&redir_ga, NUL); /* Append the trailing NUL. */ + ga_append(&redir_ga, '\0'); /* Append the trailing NUL. */ tv.v_type = VAR_STRING; tv.vval.v_string = redir_ga.ga_data; /* Call get_lval() again, if it's inside a Dict or List it may @@ -1306,7 +1306,7 @@ char_u *eval_to_string(char_u *arg, char_u **nextcmd, int convert) if (tv.vval.v_list->lv_len > 0) ga_append(&ga, NL); } - ga_append(&ga, NUL); + ga_append(&ga, '\0'); retval = (char_u *)ga.ga_data; } else if (convert && tv.v_type == VAR_FLOAT) { vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv.vval.v_float); @@ -1498,7 +1498,7 @@ call_vim_function ( for (i = 0; i < argc; i++) { /* Pass a NULL or empty argument as an empty string */ - if (argv[i] == NULL || *argv[i] == NUL) { + if (argv[i] == NULL || *argv[i] == '\0') { argvars[i].v_type = VAR_STRING; argvars[i].vval.v_string = (char_u *)""; continue; @@ -1689,7 +1689,7 @@ int eval_foldexpr(char_u *arg, int *cp) if (use_sandbox) ++sandbox; ++textlock; - *cp = NUL; + *cp = '\0'; if (eval0(arg, &tv, NULL, TRUE) == FAIL) retval = 0; else { @@ -1764,7 +1764,7 @@ void ex_let(exarg_T *eap) eap->nextcmd = check_nextcmd(arg); } else { op[0] = '='; - op[1] = NUL; + op[1] = '\0'; if (*expr != '=') { if (vim_strchr((char_u *)"+-.", *expr) != NULL) { op[0] = *expr; // +=, -=, .= @@ -1928,7 +1928,7 @@ static char_u *skip_var_list(char_u *arg, int *var_count, int *semicolon) */ static char_u *skip_var_one(char_u *arg) { - if (*arg == '@' && arg[1] != NUL) + if (*arg == '@' && arg[1] != '\0') return arg + 2; return find_name_end(*arg == '$' || *arg == '&' ? arg + 1 : arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START); @@ -2090,7 +2090,7 @@ static char_u *list_arg_vars(exarg_T *eap, char_u *arg, int *first) s = echo_string(&tv, &tf, numbuf, 0); c = *arg; - *arg = NUL; + *arg = '\0'; list_one_var_a((char_u *)"", arg == arg_subsc ? name : name_start, tv.v_type, @@ -2153,7 +2153,7 @@ ex_let_one ( EMSG(_(e_letunexp)); else if (!check_secure()) { c1 = name[len]; - name[len] = NUL; + name[len] = '\0'; p = get_tv_string_chk(tv); if (p != NULL && op != NULL && *op == '.') { int mustfree = FALSE; @@ -2200,7 +2200,7 @@ ex_let_one ( char_u *s; c1 = *p; - *p = NUL; + *p = '\0'; n = get_tv_number(tv); s = get_tv_string_chk(tv); /* != NULL if number or string */ @@ -2376,7 +2376,7 @@ get_lval ( return p; cc = *p; - *p = NUL; + *p = '\0'; v = find_var(lp->ll_name, &ht, flags & GLV_NO_AUTOLOAD); if (v == NULL && !quiet) EMSG2(_(e_undefvar), lp->ll_name); @@ -2486,7 +2486,7 @@ get_lval ( if (len == -1) { /* "[key]": get key from "var1" */ key = get_tv_string(&var1); /* is number or string */ - if (*key == NUL) { + if (*key == '\0') { if (!quiet) EMSG(_(e_emptykey)); clear_tv(&var1); @@ -2506,7 +2506,7 @@ get_lval ( if (len != -1) { prevval = key[len]; - key[len] = NUL; + key[len] = '\0'; } else prevval = 0; /* avoid compiler warning */ wrong = (lp->ll_dict->dv_scope == VAR_DEF_SCOPE @@ -2637,7 +2637,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch if (lp->ll_tv == NULL) { if (!check_changedtick(lp->ll_name)) { cc = *endp; - *endp = NUL; + *endp = '\0'; if (op != NULL && *op != '=') { typval_T tv; @@ -2986,13 +2986,13 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) break; } else if (cmdidx != CMD_let || got_eq) { if (c == '"') { /* string */ - while ((c = *++xp->xp_pattern) != NUL && c != '"') - if (c == '\\' && xp->xp_pattern[1] != NUL) + while ((c = *++xp->xp_pattern) != '\0' && c != '"') + if (c == '\\' && xp->xp_pattern[1] != '\0') ++xp->xp_pattern; xp->xp_context = EXPAND_NOTHING; } else if (c == '\'') { /* literal string */ /* Trick: '' is like stopping and starting a literal string. */ - while ((c = *++xp->xp_pattern) != NUL && c != '\'') + while ((c = *++xp->xp_pattern) != '\0' && c != '\'') /* skip */; xp->xp_context = EXPAND_NOTHING; } else if (c == '|') { @@ -3008,8 +3008,8 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) * anyway. */ xp->xp_context = EXPAND_EXPRESSION; arg = xp->xp_pattern; - if (*arg != NUL) - while ((c = *++arg) != NUL && (c == ' ' || c == '\t')) + if (*arg != '\0') + while ((c = *++arg) != '\0' && (c == ' ' || c == '\t')) /* skip */; } xp->xp_pattern = arg; @@ -3210,7 +3210,7 @@ static int do_unlet_var(lval_T *lp, char_u *name_end, int forceit) if (lp->ll_tv == NULL) { cc = *name_end; - *name_end = NUL; + *name_end = '\0'; /* Normal name or expanded name. */ if (check_changedtick(lp->ll_name)) @@ -3254,7 +3254,7 @@ int do_unlet(char_u *name, int forceit) dictitem_T *di; ht = find_var_ht(name, &varname); - if (ht != NULL && *varname != NUL) { + if (ht != NULL && *varname != '\0') { hi = hash_find(ht, varname); if (!HASHITEM_EMPTY(hi)) { di = HI2DI(hi); @@ -3287,7 +3287,7 @@ static int do_lock_var(lval_T *lp, char_u *name_end, int deep, int lock) if (lp->ll_tv == NULL) { cc = *name_end; - *name_end = NUL; + *name_end = '\0'; /* Normal name or expanded name. */ if (check_changedtick(lp->ll_name)) @@ -4471,7 +4471,7 @@ eval7 ( rettv->v_type = VAR_STRING; rettv->vval.v_string = get_reg_contents(**arg, TRUE, TRUE); } - if (**arg != NUL) + if (**arg != '\0') ++*arg; break; @@ -4788,7 +4788,7 @@ eval_index ( if (len == -1) { key = get_tv_string(&var1); - if (*key == NUL) { + if (*key == '\0') { if (verbose) EMSG(_(e_emptykey)); clear_tv(&var1); @@ -4854,7 +4854,7 @@ get_option_tv ( } c = *option_end; - *option_end = NUL; + *option_end = '\0'; opt_type = get_option_value(*arg, &numval, rettv == NULL ? NULL : &stringval, opt_flags); @@ -4898,8 +4898,8 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) /* * Find the end of the string, skipping backslashed characters. */ - for (p = *arg + 1; *p != NUL && *p != '"'; mb_ptr_adv(p)) { - if (*p == '\\' && p[1] != NUL) { + for (p = *arg + 1; *p != '\0' && *p != '"'; mb_ptr_adv(p)) { + if (*p == '\\' && p[1] != '\0') { ++p; /* A "\<x>" form occupies at least 4 characters, and produces up * to 6 characters: reserve space for 2 extra */ @@ -4929,7 +4929,7 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) rettv->v_type = VAR_STRING; rettv->vval.v_string = name; - for (p = *arg + 1; *p != NUL && *p != '"'; ) { + for (p = *arg + 1; *p != '\0' && *p != '"'; ) { if (*p == '\\') { switch (*++p) { case 'b': *name++ = BS; ++p; break; @@ -4998,7 +4998,7 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) MB_COPY_CHAR(p, name); } - *name = NUL; + *name = '\0'; *arg = p + 1; return OK; @@ -5017,7 +5017,7 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate) /* * Find the end of the string, skipping ''. */ - for (p = *arg + 1; *p != NUL; mb_ptr_adv(p)) { + for (p = *arg + 1; *p != '\0'; mb_ptr_adv(p)) { if (*p == '\'') { if (p[1] != '\'') break; @@ -5046,7 +5046,7 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate) rettv->v_type = VAR_STRING; rettv->vval.v_string = str; - for (p = *arg + 1; *p != NUL; ) { + for (p = *arg + 1; *p != '\0'; ) { if (*p == '\'') { if (p[1] != '\'') break; @@ -5054,7 +5054,7 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate) } MB_COPY_CHAR(p, str); } - *str = NUL; + *str = '\0'; *arg = p + 1; return OK; @@ -5077,7 +5077,7 @@ static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate) } *arg = skipwhite(*arg + 1); - while (**arg != ']' && **arg != NUL) { + while (**arg != ']' && **arg != '\0') { if (eval1(arg, &tv, evaluate) == FAIL) /* recursive! */ goto failret; if (evaluate) { @@ -5730,7 +5730,7 @@ static char_u *list2string(typval_T *tv, int copyID) return NULL; } ga_append(&ga, ']'); - ga_append(&ga, NUL); + ga_append(&ga, '\0'); return (char_u *)ga.ga_data; } @@ -6444,7 +6444,7 @@ static char_u *dict2string(typval_T *tv, int copyID) } ga_append(&ga, '}'); - ga_append(&ga, NUL); + ga_append(&ga, '\0'); return (char_u *)ga.ga_data; } @@ -6485,7 +6485,7 @@ static int get_dict_tv(char_u **arg, typval_T *rettv, int evaluate) tv.v_type = VAR_UNKNOWN; *arg = skipwhite(*arg + 1); - while (**arg != '}' && **arg != NUL) { + while (**arg != '}' && **arg != '\0') { if (eval1(arg, &tvkey, evaluate) == FAIL) /* recursive! */ goto failret; if (**arg != ':') { @@ -6495,7 +6495,7 @@ static int get_dict_tv(char_u **arg, typval_T *rettv, int evaluate) } if (evaluate) { key = get_tv_string_buf_chk(&tvkey, buf); - if (key == NULL || *key == NUL) { + if (key == NULL || *key == '\0') { /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */ if (key != NULL) EMSG(_(e_emptykey)); @@ -6673,7 +6673,7 @@ static char_u *string_quote(char_u *str, int function) len = (function ? 13 : 3); if (str != NULL) { len += (unsigned)STRLEN(str); - for (p = str; *p != NUL; mb_ptr_adv(p)) + for (p = str; *p != '\0'; mb_ptr_adv(p)) if (*p == '\'') ++len; } @@ -6685,7 +6685,7 @@ static char_u *string_quote(char_u *str, int function) } else *r++ = '\''; if (str != NULL) - for (p = str; *p != NUL; ) { + for (p = str; *p != '\0'; ) { if (*p == '\'') *r++ = '\''; MB_COPY_CHAR(p, r); @@ -6693,7 +6693,7 @@ static char_u *string_quote(char_u *str, int function) *r++ = '\''; if (function) *r++ = ')'; - *r++ = NUL; + *r++ = '\0'; } return s; } @@ -6738,10 +6738,10 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate) if (evaluate) { if (len != 0) { cc = name[len]; - name[len] = NUL; + name[len] = '\0'; /* first try vim_getenv(), fast for normal environment vars */ string = vim_getenv(name, &mustfree); - if (string != NULL && *string != NUL) { + if (string != NULL && *string != '\0') { if (!mustfree) string = vim_strsave(string); } else { @@ -7136,7 +7136,7 @@ static char_u *deref_func_name(char_u *name, int *lenp, int no_autoload) int cc; cc = name[*lenp]; - name[*lenp] = NUL; + name[*lenp] = '\0'; v = find_var(name, NULL, no_autoload); name[*lenp] = cc; if (v != NULL && v->di_tv.v_type == VAR_FUNC) { @@ -7179,7 +7179,7 @@ get_func_tv ( argp = *arg; while (argcount < MAX_FUNC_ARGS) { argp = skipwhite(argp + 1); /* skip the '(' or ',' */ - if (*argp == ')' || *argp == ',' || *argp == NUL) + if (*argp == ')' || *argp == ',' || *argp == '\0') break; if (eval1(&argp, &argvars[argcount], evaluate) == FAIL) { ret = FAIL; @@ -7447,7 +7447,7 @@ static int non_zero_arg(typval_T *argvars) && argvars[0].vval.v_number != 0) || (argvars[0].v_type == VAR_STRING && argvars[0].vval.v_string != NULL - && *argvars[0].vval.v_string != NUL); + && *argvars[0].vval.v_string != '\0'); } /********************************************* @@ -7765,9 +7765,9 @@ static buf_T *get_buf_tv(typval_T *tv, int curtab_only) return buflist_findnr((int)tv->vval.v_number); if (tv->v_type != VAR_STRING) return NULL; - if (name == NULL || *name == NUL) + if (name == NULL || *name == '\0') return curbuf; - if (name[0] == '$' && name[1] == NUL) + if (name[0] == '$' && name[1] == '\0') return lastbuf; /* Ignore 'magic' and 'cpoptions' here to make scripts portable */ @@ -7887,7 +7887,7 @@ static void byteidx(typval_T *argvars, typval_T *rettv, int comp) t = str; for (; idx > 0; idx--) { - if (*t == NUL) /* EOL reached */ + if (*t == '\0') /* EOL reached */ return; if (enc_utf8 && comp) t += utf_ptr2len(t); @@ -7964,7 +7964,7 @@ static void f_call(typval_T *argvars, typval_T *rettv) func = argvars[0].vval.v_string; else func = get_tv_string(&argvars[0]); - if (*func == NUL) + if (*func == '\0') return; /* type error or empty name */ if (argvars[2].v_type != VAR_UNKNOWN) { @@ -8073,7 +8073,7 @@ static void f_col(typval_T *argvars, typval_T *rettv) curwin->w_virtcol - curwin->w_cursor.coladd)) { int l; - if (*p != NUL && p[(l = (*mb_ptr2len)(p))] == NUL) + if (*p != '\0' && p[(l = (*mb_ptr2len)(p))] == '\0') col += l; } } @@ -8172,7 +8172,7 @@ static void f_confirm(typval_T *argvars, typval_T *rettv) } } - if (buttons == NULL || *buttons == NUL) + if (buttons == NULL || *buttons == '\0') buttons = (char_u *)_("&Ok"); if (!error) @@ -8452,7 +8452,7 @@ static void f_empty(typval_T *argvars, typval_T *rettv) case VAR_STRING: case VAR_FUNC: n = argvars[0].vval.v_string == NULL - || *argvars[0].vval.v_string == NUL; + || *argvars[0].vval.v_string == '\0'; break; case VAR_NUMBER: n = argvars[0].vval.v_number == 0; @@ -8502,7 +8502,7 @@ static void f_eval(typval_T *argvars, typval_T *rettv) if (s == NULL || eval1(&s, rettv, TRUE) == FAIL) { rettv->v_type = VAR_NUMBER; rettv->vval.v_number = 0; - } else if (*s != NUL) + } else if (*s != '\0') EMSG(_(e_trailing)); } @@ -8546,7 +8546,7 @@ static void f_exists(typval_T *argvars, typval_T *rettv) } } else if (*p == '&' || *p == '+') { /* option */ n = (get_option_tv(&p, NULL, TRUE) == OK); - if (*skipwhite(p) != NUL) + if (*skipwhite(p) != '\0') n = FALSE; /* trailing garbage */ } else if (*p == '*') { /* internal or user defined function */ n = function_exists(p + 1); @@ -8575,7 +8575,7 @@ static void f_exists(typval_T *argvars, typval_T *rettv) clear_tv(&tv); } } - if (*p != NUL) + if (*p != '\0') n = FALSE; vim_free(tofree); @@ -8794,10 +8794,10 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv) return; keys = get_tv_string(&argvars[0]); - if (*keys != NUL) { + if (*keys != '\0') { if (argvars[1].v_type != VAR_UNKNOWN) { flags = get_tv_string_buf(&argvars[1], nbuf); - for (; *flags != NUL; ++flags) { + for (; *flags != '\0'; ++flags) { switch (*flags) { case 'n': remap = FALSE; break; case 'm': remap = TRUE; break; @@ -8859,7 +8859,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) { char_u *fname; char_u *fresult = NULL; - char_u *path = *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path; + char_u *path = *curbuf->b_p_path == '\0' ? p_path : curbuf->b_p_path; char_u *p; char_u pathbuf[NUMBUFLEN]; int count = 1; @@ -8876,7 +8876,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) if (p == NULL) error = TRUE; else { - if (*p != NUL) + if (*p != '\0') path = p; if (argvars[2].v_type != VAR_UNKNOWN) @@ -8888,7 +8888,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) rettv_list_alloc(rettv); } - if (*fname != NUL && !error) { + if (*fname != '\0' && !error) { do { if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST) vim_free(fresult); @@ -9023,7 +9023,7 @@ static int filter_map_one(typval_T *tv, char_u *expr, int map, int *remp) s = expr; if (eval1(&s, &rettv, TRUE) == FAIL) goto theend; - if (*s != NUL) { /* check for trailing chars after expr */ + if (*s != '\0') { /* check for trailing chars after expr */ EMSG2(_(e_invexpr2), s); goto theend; } @@ -9239,7 +9239,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv) /* skip C comment-start */ if (s[0] == '/' && (s[1] == '*' || s[1] == '/')) { s = skipwhite(s + 2); - if (*skipwhite(s) == NUL + if (*skipwhite(s) == '\0' && lnum + 1 < (linenr_T)vimvars[VV_FOLDEND].vv_nr) { s = skipwhite(ml_get(lnum + 1)); if (*s == '*') @@ -9306,7 +9306,7 @@ static void f_function(typval_T *argvars, typval_T *rettv) char_u *s; s = get_tv_string(&argvars[0]); - if (s == NULL || *s == NUL || VIM_ISDIGIT(*s)) + if (s == NULL || *s == '\0' || VIM_ISDIGIT(*s)) EMSG2(_(e_invarg2), s); /* Don't check an autoload name for existence here. */ else if (vim_strchr(s, AUTOLOAD_CHAR) == NULL && !function_exists(s)) @@ -9521,7 +9521,7 @@ static void f_getchar(typval_T *argvars, typval_T *rettv) else if (get_tv_number_chk(&argvars[0], &error) == 1) /* getchar(1): only check if char avail */ n = vpeekc(); - else if (error || vpeekc() == NUL) + else if (error || vpeekc() == '\0') /* illegal argument or getchar(0) and no char avail: return zero */ n = 0; else @@ -9557,7 +9557,7 @@ static void f_getchar(typval_T *argvars, typval_T *rettv) i += (*mb_char2bytes)(n, temp + i); else temp[i++] = n; - temp[i++] = NUL; + temp[i++] = '\0'; rettv->v_type = VAR_STRING; rettv->vval.v_string = vim_strsave(temp); @@ -9618,7 +9618,7 @@ static void f_getcmdtype(typval_T *argvars, typval_T *rettv) rettv->vval.v_string = alloc(2); if (rettv->vval.v_string != NULL) { rettv->vval.v_string[0] = get_cmdline_type(); - rettv->vval.v_string[1] = NUL; + rettv->vval.v_string[1] = '\0'; } } @@ -9933,8 +9933,8 @@ static void f_getregtype(typval_T *argvars, typval_T *rettv) if (regname == 0) regname = '"'; - buf[0] = NUL; - buf[1] = NUL; + buf[0] = '\0'; + buf[1] = '\0'; switch (get_reg_type(regname, ®len)) { case MLINE: buf[0] = 'V'; break; case MCHAR: buf[0] = 'v'; break; @@ -10408,9 +10408,9 @@ static void f_histadd(typval_T *argvars, typval_T *rettv) histype = str != NULL ? get_histtype(str) : -1; if (histype >= 0) { str = get_tv_string_buf(&argvars[1], buf); - if (*str != NUL) { + if (*str != '\0') { init_history(); - add_to_history(histype, str, FALSE, NUL); + add_to_history(histype, str, FALSE, '\0'); rettv->vval.v_number = TRUE; return; } @@ -10636,7 +10636,7 @@ static void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog) else { ++p; c = *p; - *p = NUL; + *p = '\0'; msg_start(); msg_clr_eos(); msg_puts_attr(prompt, echo_attr); @@ -10675,7 +10675,7 @@ static void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog) int save_ex_normal_busy = ex_normal_busy; ex_normal_busy = 0; rettv->vval.v_string = - getcmdline_prompt(inputsecret_flag ? NUL : '@', p, echo_attr, + getcmdline_prompt(inputsecret_flag ? '\0' : '@', p, echo_attr, xp_type, xp_arg); ex_normal_busy = save_ex_normal_busy; } @@ -10856,7 +10856,7 @@ static void f_islocked(typval_T *argvars, typval_T *rettv) end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE, GLV_NO_AUTOLOAD, FNE_CHECK_START); if (end != NULL && lv.ll_name != NULL) { - if (*end != NUL) + if (*end != '\0') EMSG(_(e_trailing)); else { if (lv.ll_tv == NULL) { @@ -11127,7 +11127,7 @@ static void f_join(typval_T *argvars, typval_T *rettv) if (sep != NULL) { ga_init(&ga, (int)sizeof(char), 80); list_join(&ga, argvars[0].vval.v_list, sep, TRUE, 0); - ga_append(&ga, NUL); + ga_append(&ga, '\0'); rettv->vval.v_string = (char_u *)ga.ga_data; } else rettv->vval.v_string = NULL; @@ -11311,7 +11311,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) rettv->vval.v_string = NULL; keys = get_tv_string(&argvars[0]); - if (*keys == NUL) + if (*keys == '\0') return; if (argvars[1].v_type != VAR_UNKNOWN) { @@ -11776,12 +11776,12 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv) return; dir = get_tv_string_buf(&argvars[0], buf); - if (*dir == NUL) + if (*dir == '\0') rettv->vval.v_number = FAIL; else { - if (*path_tail(dir) == NUL) + if (*path_tail(dir) == '\0') /* remove trailing slashes */ - *path_tail_with_sep(dir) = NUL; + *path_tail_with_sep(dir) = '\0'; if (argvars[1].v_type != VAR_UNKNOWN) { if (argvars[2].v_type != VAR_UNKNOWN) @@ -11800,8 +11800,8 @@ static void f_mode(typval_T *argvars, typval_T *rettv) { char_u buf[3]; - buf[1] = NUL; - buf[2] = NUL; + buf[1] = '\0'; + buf[2] = '\0'; if (VIsual_active) { if (VIsual_select) @@ -11841,7 +11841,7 @@ static void f_mode(typval_T *argvars, typval_T *rettv) /* Clear out the minor mode when the argument is not a non-zero number or * non-empty string. */ if (!non_zero_arg(&argvars[0])) - buf[1] = NUL; + buf[1] = '\0'; rettv->vval.v_string = vim_strsave(buf); rettv->v_type = VAR_STRING; @@ -11860,7 +11860,7 @@ static void f_nextnonblank(typval_T *argvars, typval_T *rettv) lnum = 0; break; } - if (*skipwhite(ml_get(lnum)) != NUL) + if (*skipwhite(ml_get(lnum)) != '\0') break; } rettv->vval.v_number = lnum; @@ -11879,12 +11879,12 @@ static void f_nr2char(typval_T *argvars, typval_T *rettv) if (argvars[1].v_type != VAR_UNKNOWN) utf8 = get_tv_number_chk(&argvars[1], NULL); if (utf8) - buf[(*utf_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL; + buf[(*utf_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = '\0'; else - buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL; + buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = '\0'; } else { buf[0] = (char_u)get_tv_number(&argvars[0]); - buf[1] = NUL; + buf[1] = '\0'; } rettv->v_type = VAR_STRING; rettv->vval.v_string = vim_strsave(buf); @@ -11944,7 +11944,7 @@ static void f_prevnonblank(typval_T *argvars, typval_T *rettv) if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) lnum = 0; else - while (lnum >= 1 && *skipwhite(ml_get(lnum)) == NUL) + while (lnum >= 1 && *skipwhite(ml_get(lnum)) == '\0') --lnum; rettv->vval.v_number = lnum; } @@ -12062,8 +12062,8 @@ static void f_readfile(typval_T *argvars, typval_T *rettv) /* Always open the file in binary mode, library functions have a mind of * their own about CR-LF conversion. */ fname = get_tv_string(&argvars[0]); - if (*fname == NUL || (fd = mch_fopen((char *)fname, READBIN)) == NULL) { - EMSG2(_(e_notopen), *fname == NUL ? (char_u *)_("<empty>") : fname); + if (*fname == '\0' || (fd = mch_fopen((char *)fname, READBIN)) == NULL) { + EMSG2(_(e_notopen), *fname == '\0' ? (char_u *)_("<empty>") : fname); return; } @@ -12100,7 +12100,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv) * allocated only once. */ if ((s = xrealloc(prev, prevlen + len + 1)) != NULL) { memmove(s + prevlen, start, len); - s[prevlen + len] = NUL; + s[prevlen + len] = '\0'; prev = NULL; /* the list will own the string */ prevlen = prevsize = 0; } @@ -12124,7 +12124,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv) start = p + 1; /* step over newline */ if ((++cnt >= maxline && maxline >= 0) || readlen <= 0) break; - } else if (*p == NUL) + } else if (*p == '\0') *p = '\n'; /* Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this * when finding the BF and check the previous two bytes. */ @@ -12132,10 +12132,10 @@ static void f_readfile(typval_T *argvars, typval_T *rettv) /* Find the two bytes before the 0xbf. If p is at buf, or buf * + 1, these may be in the "prev" string. */ char_u back1 = p >= buf + 1 ? p[-1] - : prevlen >= 1 ? prev[prevlen - 1] : NUL; + : prevlen >= 1 ? prev[prevlen - 1] : '\0'; char_u back2 = p >= buf + 2 ? p[-2] : p == buf + 1 && prevlen >= 1 ? prev[prevlen - 1] - : prevlen >= 2 ? prev[prevlen - 2] : NUL; + : prevlen >= 2 ? prev[prevlen - 2] : '\0'; if (back2 == 0xef && back1 == 0xbb) { char_u *dest = p - 2; @@ -12456,7 +12456,7 @@ static void f_repeat(typval_T *argvars, typval_T *rettv) if (r != NULL) { for (i = 0; i < n; i++) memmove(r + i * slen, p, (size_t)slen); - r[len] = NUL; + r[len] = '\0'; } rettv->vval.v_string = r; @@ -12504,15 +12504,15 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) len = STRLEN(p); if (len > 0 && after_pathsep(p, p + len)) { has_trailing_pathsep = TRUE; - p[len - 1] = NUL; /* the trailing slash breaks readlink() */ + p[len - 1] = '\0'; /* the trailing slash breaks readlink() */ } q = path_next_component(p); - if (*q != NUL) { + if (*q != '\0') { /* Separate the first path component in "p", and keep the * remainder (beginning with the path separator). */ remain = vim_strsave(q - 1); - q[-1] = NUL; + q[-1] = '\0'; } buf = alloc(MAXPATHL + 1); @@ -12524,7 +12524,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) len = readlink((char *)p, (char *)buf, MAXPATHL); if (len <= 0) break; - buf[len] = NUL; + buf[len] = '\0'; if (limit-- == 0) { vim_free(p); @@ -12542,7 +12542,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) /* Separate the first path component in the link value and * concatenate the remainders. */ q = path_next_component(vim_ispathsep(*buf) ? buf + 1 : buf); - if (*q != NUL) { + if (*q != '\0') { if (remain == NULL) remain = vim_strsave(q - 1); else { @@ -12552,13 +12552,13 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) remain = cpy; } } - q[-1] = NUL; + q[-1] = '\0'; } q = path_tail(p); - if (q > p && *q == NUL) { + if (q > p && *q == '\0') { /* Ignore trailing path separator. */ - q[-1] = NUL; + q[-1] = '\0'; q = path_tail(p); } if (q > p && !path_is_absolute_path(buf)) { @@ -12581,7 +12581,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) /* Append the first path component of "remain" to "p". */ q = path_next_component(remain + 1); - len = q - remain - (*q != NUL); + len = q - remain - (*q != '\0'); cpy = vim_strnsave(p, STRLEN(p) + len); if (cpy != NULL) { STRNCAT(cpy, remain, len); @@ -12589,7 +12589,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) p = cpy; } /* Shorten "remain". */ - if (*q != NUL) + if (*q != '\0') STRMOVE(remain, q - 1); else { vim_free(remain); @@ -12601,12 +12601,12 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) * the current directory if and only if the argument had this form. */ if (!vim_ispathsep(*p)) { if (is_relative_to_current - && *p != NUL + && *p != '\0' && !(p[0] == '.' - && (p[1] == NUL + && (p[1] == '\0' || vim_ispathsep(p[1]) || (p[1] == '.' - && (p[2] == NUL + && (p[2] == '\0' || vim_ispathsep(p[2])))))) { /* Prepend "./". */ cpy = concat_str((char_u *)"./", p); @@ -12629,7 +12629,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) if (!has_trailing_pathsep) { q = p + STRLEN(p); if (after_pathsep(p, q)) - *path_tail_with_sep(p) = NUL; + *path_tail_with_sep(p) = '\0'; } rettv->vval.v_string = p; @@ -12701,7 +12701,7 @@ static int get_search_arg(typval_T *varp, int *flagsp) flags = get_tv_string_buf_chk(varp, nbuf); if (flags == NULL) return 0; /* type error; errmsg already given */ - while (*flags != NUL) { + while (*flags != '\0') { switch (*flags) { case 'b': dir = BACKWARD; break; case 'w': p_ws = TRUE; break; @@ -13082,7 +13082,7 @@ do_searchpair ( if (pat2 == NULL || pat3 == NULL) goto theend; sprintf((char *)pat2, "\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat); - if (*mpat == NUL) + if (*mpat == '\0') STRCPY(pat3, pat2); else sprintf((char *)pat3, "\\(%s\\m\\)\\|\\(%s\\m\\)\\|\\(%s\\m\\)", @@ -13119,7 +13119,7 @@ do_searchpair ( options &= ~SEARCH_START; /* If the skip pattern matches, ignore this match. */ - if (*skip != NUL) { + if (*skip != '\0') { save_pos = curwin->w_cursor; curwin->w_cursor = pos; r = eval_to_bool(skip, &err, NULL, FALSE); @@ -13455,7 +13455,7 @@ static void f_setpos(typval_T *argvars, typval_T *rettv) if (list2fpos(&argvars[1], &pos, &fnum) == OK) { if (--pos.col < 0) pos.col = 0; - if (name[0] == '.' && name[1] == NUL) { + if (name[0] == '.' && name[1] == '\0') { /* set cursor */ if (fnum == curbuf->b_fnum) { curwin->w_cursor = pos; @@ -13463,7 +13463,7 @@ static void f_setpos(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = 0; } else EMSG(_(e_invarg)); - } else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL) { + } else if (name[0] == '\'' && name[1] != '\0' && name[2] == '\0') { /* set mark */ if (setmark_pos(name[1], &pos, fnum) == OK) rettv->vval.v_number = 0; @@ -13513,7 +13513,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv) stropt = get_tv_string_chk(&argvars[2]); if (stropt == NULL) return; /* type error */ - for (; *stropt != NUL; ++stropt) + for (; *stropt != '\0'; ++stropt) switch (*stropt) { case 'a': case 'A': /* append */ append = TRUE; @@ -13959,13 +13959,13 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv) len = spell_move_to(curwin, FORWARD, TRUE, TRUE, &attr); if (len != 0) word = ml_get_cursor(); - } else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != NUL) { + } else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != '\0') { char_u *str = get_tv_string_chk(&argvars[0]); int capcol = -1; if (str != NULL) { /* Check the argument for spelling. */ - while (*str != NUL) { + while (*str != '\0') { len = spell_check(curwin, str, &attr, &capcol, FALSE); if (attr != HLF_COUNT) { word = str; @@ -14000,7 +14000,7 @@ static void f_spellsuggest(typval_T *argvars, typval_T *rettv) rettv_list_alloc(rettv); - if (curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) { + if (curwin->w_p_spell && *curwin->w_s->b_p_spl != '\0') { str = get_tv_string(&argvars[0]); if (argvars[1].v_type != VAR_UNKNOWN) { maxcount = get_tv_number_chk(&argvars[1], &typeerr); @@ -14058,7 +14058,7 @@ static void f_split(typval_T *argvars, typval_T *rettv) if (argvars[2].v_type != VAR_UNKNOWN) keepempty = get_tv_number_chk(&argvars[2], &typeerr); } - if (pat == NULL || *pat == NUL) + if (pat == NULL || *pat == '\0') pat = (char_u *)"[\\x01- ]\\+"; rettv_list_alloc(rettv); @@ -14069,8 +14069,8 @@ static void f_split(typval_T *argvars, typval_T *rettv) regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { regmatch.rm_ic = FALSE; - while (*str != NUL || keepempty) { - if (*str == NUL) + while (*str != '\0' || keepempty) { + if (*str == '\0') match = FALSE; /* empty item at the end */ else match = vim_regexec_nl(®match, str, col); @@ -14079,7 +14079,7 @@ static void f_split(typval_T *argvars, typval_T *rettv) else end = str + STRLEN(str); if (keepempty || end > str || (rettv->vval.v_list->lv_len > 0 - && *str != NUL && match && end < + && *str != '\0' && match && end < regmatch.endp[0])) { list_append_string(rettv->vval.v_list, str, (int)(end - str)); } @@ -14186,7 +14186,7 @@ static void f_strftime(typval_T *argvars, typval_T *rettv) (void)strftime((char *)result_buf, sizeof(result_buf), (char *)p, curtime); else - result_buf[0] = NUL; + result_buf[0] = '\0'; if (conv.vc_type != CONV_NONE) vim_free(p); @@ -14267,7 +14267,7 @@ static void f_strchars(typval_T *argvars, typval_T *rettv) char_u *s = get_tv_string(&argvars[0]); varnumber_T len = 0; - while (*s != NUL) { + while (*s != '\0') { mb_cptr2char_adv(&s); ++len; } @@ -14368,7 +14368,7 @@ static void f_strridx(typval_T *argvars, typval_T *rettv) } else end_idx = haystack_len; - if (*needle == NUL) { + if (*needle == '\0') { /* Empty string matches past the end. */ lastmatch = haystack + end_idx; } else { @@ -14579,7 +14579,7 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv) lnum = get_tv_lnum(argvars); /* -1 on type error */ col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */ - memset(str, NUL, sizeof(str)); + memset(str, '\0', sizeof(str)); rettv_list_alloc(rettv); if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0 @@ -14590,10 +14590,10 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv) // get the conceal character if ((syntax_flags & HL_CONCEAL) && curwin->w_p_cole < 3) { cchar = syn_get_sub_char(); - if (cchar == NUL && curwin->w_p_cole == 1 && lcs_conceal != NUL) { + if (cchar == '\0' && curwin->w_p_cole == 1 && lcs_conceal != '\0') { cchar = lcs_conceal; } - if (cchar != NUL) { + if (cchar != '\0') { if (has_mbyte) (*mb_char2bytes)(cchar, str); else @@ -14707,7 +14707,7 @@ static void f_system(typval_T *argvars, typval_T *rettv) ++s; *d++ = *s; } - *d = NUL; + *d = '\0'; } # endif #endif @@ -14859,7 +14859,7 @@ static void f_taglist(typval_T *argvars, typval_T *rettv) tag_pattern = get_tv_string(&argvars[0]); rettv->vval.v_number = FALSE; - if (*tag_pattern == NUL) + if (*tag_pattern == '\0') return; rettv_list_alloc(rettv); @@ -14937,7 +14937,7 @@ static void f_tolower(typval_T *argvars, typval_T *rettv) rettv->vval.v_string = p; if (p != NULL) - while (*p != NUL) { + while (*p != '\0') { int l; if (enc_utf8) { @@ -15009,16 +15009,16 @@ error: } /* fromstr and tostr have to contain the same number of chars */ - while (*in_str != NUL) { + while (*in_str != '\0') { if (has_mbyte) { inlen = (*mb_ptr2len)(in_str); cpstr = in_str; cplen = inlen; idx = 0; - for (p = fromstr; *p != NUL; p += fromlen) { + for (p = fromstr; *p != '\0'; p += fromlen) { fromlen = (*mb_ptr2len)(p); if (fromlen == inlen && STRNCMP(in_str, p, inlen) == 0) { - for (p = tostr; *p != NUL; p += tolen) { + for (p = tostr; *p != '\0'; p += tolen) { tolen = (*mb_ptr2len)(p); if (idx-- == 0) { cplen = tolen; @@ -15026,7 +15026,7 @@ error: break; } } - if (*p == NUL) /* tostr is shorter than fromstr */ + if (*p == '\0') /* tostr is shorter than fromstr */ goto error; break; } @@ -15038,7 +15038,7 @@ error: * (multi-byte) characters. Done only once when a character * of in_str doesn't appear in fromstr. */ first = FALSE; - for (p = tostr; *p != NUL; p += tolen) { + for (p = tostr; *p != '\0'; p += tolen) { tolen = (*mb_ptr2len)(p); --idx; } @@ -15064,7 +15064,7 @@ error: /* add a terminating NUL */ ga_grow(&ga, 1); - ga_append(&ga, NUL); + ga_append(&ga, '\0'); rettv->vval.v_string = ga.ga_data; } @@ -15112,7 +15112,7 @@ static void f_undofile(typval_T *argvars, typval_T *rettv) { char_u *fname = get_tv_string(&argvars[0]); - if (*fname == NUL) { + if (*fname == '\0') { /* If there is no file name there will be no undo file. */ rettv->vval.v_string = NULL; } else { @@ -15186,12 +15186,12 @@ static void f_visualmode(typval_T *argvars, typval_T *rettv) rettv->v_type = VAR_STRING; str[0] = curbuf->b_visual_mode_eval; - str[1] = NUL; + str[1] = '\0'; rettv->vval.v_string = vim_strsave(str); /* A non-zero number or non-empty string argument: reset mode. */ if (non_zero_arg(&argvars[0])) - curbuf->b_visual_mode_eval = NUL; + curbuf->b_visual_mode_eval = '\0'; } /* @@ -15278,7 +15278,7 @@ static void f_winrestcmd(typval_T *argvars, typval_T *rettv) ga_concat(&ga, buf); ++winnr; } - ga_append(&ga, NUL); + ga_append(&ga, '\0'); rettv->vval.v_string = ga.ga_data; rettv->v_type = VAR_STRING; @@ -15386,15 +15386,15 @@ static void f_writefile(typval_T *argvars, typval_T *rettv) /* Always open the file in binary mode, library functions have a mind of * their own about CR-LF conversion. */ fname = get_tv_string(&argvars[1]); - if (*fname == NUL || (fd = mch_fopen((char *)fname, WRITEBIN)) == NULL) { - EMSG2(_(e_notcreate), *fname == NUL ? (char_u *)_("<empty>") : fname); + if (*fname == '\0' || (fd = mch_fopen((char *)fname, WRITEBIN)) == NULL) { + EMSG2(_(e_notcreate), *fname == '\0' ? (char_u *)_("<empty>") : fname); ret = -1; } else { for (li = argvars[0].vval.v_list->lv_first; li != NULL; li = li->li_next) { - for (s = get_tv_string(&li->li_tv); *s != NUL; ++s) { + for (s = get_tv_string(&li->li_tv); *s != '\0'; ++s) { if (*s == '\n') - c = putc(NUL, fd); + c = putc('\0', fd); else c = putc(*s, fd); if (c == EOF) { @@ -15490,7 +15490,7 @@ var2fpos ( return NULL; if (name[0] == '.') /* cursor */ return &curwin->w_cursor; - if (name[0] == 'v' && name[1] == NUL) { /* Visual start */ + if (name[0] == 'v' && name[1] == '\0') { /* Visual start */ if (VIsual_active) return &VIsual; return &curwin->w_cursor; @@ -15706,7 +15706,7 @@ static char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end if ((flags & FNE_CHECK_START) && !eval_isnamec1(*arg) && *arg != '{') return arg; - for (p = arg; *p != NUL + for (p = arg; *p != '\0' && (eval_isnamec(*p) || *p == '{' || ((flags & FNE_INCL_BR) && (*p == '[' || *p == '.')) @@ -15714,16 +15714,16 @@ static char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end || br_nest != 0); mb_ptr_adv(p)) { if (*p == '\'') { /* skip over 'string' to avoid counting [ and ] inside it. */ - for (p = p + 1; *p != NUL && *p != '\''; mb_ptr_adv(p)) + for (p = p + 1; *p != '\0' && *p != '\''; mb_ptr_adv(p)) ; - if (*p == NUL) + if (*p == '\0') break; } else if (*p == '"') { /* skip over "str\"ing" to avoid counting [ and ] inside it. */ - for (p = p + 1; *p != NUL && *p != '"'; mb_ptr_adv(p)) - if (*p == '\\' && p[1] != NUL) + for (p = p + 1; *p != '\0' && *p != '"'; mb_ptr_adv(p)) + if (*p == '\\' && p[1] != '\0') ++p; - if (*p == NUL) + if (*p == '\0') break; } @@ -15772,10 +15772,10 @@ static char_u *make_expanded_name(char_u *in_start, char_u *expr_start, char_u * if (expr_end == NULL || in_end == NULL) return NULL; - *expr_start = NUL; - *expr_end = NUL; + *expr_start = '\0'; + *expr_end = '\0'; c1 = *in_end; - *in_end = NUL; + *in_end = '\0'; temp_result = eval_to_string(expr_start + 1, &nextcmd, FALSE); if (temp_result != NULL && nextcmd == NULL) { @@ -15866,10 +15866,10 @@ void set_vim_var_char(int c) char_u buf[MB_MAXBYTES + 1]; if (has_mbyte) - buf[(*mb_char2bytes)(c, buf)] = NUL; + buf[(*mb_char2bytes)(c, buf)] = '\0'; else { buf[0] = c; - buf[1] = NUL; + buf[1] = '\0'; } set_vim_var_string(VV_CHAR, buf, -1); } @@ -16011,7 +16011,7 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg) else if (eap->force_bin == FORCE_NOBIN) sprintf((char *)newval, " ++nobin"); else - *newval = NUL; + *newval = '\0'; if (eap->read_edit) STRCAT(newval, " ++edit"); @@ -16053,7 +16053,7 @@ get_var_tv ( /* truncate the name, so that we can use strcmp() */ cc = name[len]; - name[len] = NUL; + name[len] = '\0'; /* * Check for "b:changedtick". @@ -16405,7 +16405,7 @@ static dictitem_T *find_var_in_ht(hashtab_T *ht, int htname, char_u *varname, in { hashitem_T *hi; - if (*varname == NUL) { + if (*varname == '\0') { /* Must be something like "s:", otherwise "ht" would be NULL. */ switch (htname) { case 's': return &SCRIPT_SV(current_SID)->sv_var; @@ -16551,7 +16551,7 @@ void init_var_dict(dict_T *dict, dictitem_T *dict_var, int scope) dict_var->di_tv.v_type = VAR_DICT; dict_var->di_tv.v_lock = VAR_FIXED; dict_var->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX; - dict_var->di_key[0] = NUL; + dict_var->di_key[0] = '\0'; } /* @@ -16691,7 +16691,7 @@ set_var ( hashtab_T *ht; ht = find_var_ht(name, &varname); - if (ht == NULL || *varname == NUL) { + if (ht == NULL || *varname == '\0') { EMSG2(_(e_illvar), name); return; } @@ -16821,7 +16821,7 @@ var_check_func_name ( ) { if (!(vim_strchr((char_u *)"wbs", name[0]) != NULL && name[1] == ':') - && !ASCII_ISUPPER((name[0] != NUL && name[1] == ':') + && !ASCII_ISUPPER((name[0] != '\0' && name[1] == ':') ? name[2] : name[0])) { EMSG2(_("E704: Funcref variable name must start with a capital: %s"), name); @@ -16846,7 +16846,7 @@ static int valid_varname(char_u *varname) { char_u *p; - for (p = varname; *p != NUL; ++p) + for (p = varname; *p != '\0'; ++p) if (!eval_isnamec1(*p) && (p == varname || !VIM_ISDIGIT(*p)) && *p != AUTOLOAD_CHAR) { EMSG2(_(e_illvar), varname); @@ -17002,7 +17002,7 @@ void ex_echo(exarg_T *eap) if (eap->skip) ++emsg_skip; - while (*arg != NUL && *arg != '|' && *arg != '\n' && !got_int) { + while (*arg != '\0' && *arg != '|' && *arg != '\n' && !got_int) { /* If eval1() causes an error message the text from the command may * still need to be cleared. E.g., "echo 22,44". */ need_clr_eos = needclr; @@ -17038,7 +17038,7 @@ void ex_echo(exarg_T *eap) current_copyID += COPYID_INC; p = echo_string(&rettv, &tofree, numbuf, current_copyID); if (p != NULL) - for (; *p != NUL && !got_int; ++p) { + for (; *p != '\0' && !got_int; ++p) { if (*p == '\n' || *p == '\r' || *p == TAB) { if (*p != TAB && needclr) { /* remove any text still there from the command */ @@ -17109,7 +17109,7 @@ void ex_execute(exarg_T *eap) if (eap->skip) ++emsg_skip; - while (*arg != NUL && *arg != '|' && *arg != '\n') { + while (*arg != '\0' && *arg != '|' && *arg != '\n') { p = arg; if (eval1(&arg, &rettv, !eap->skip) == FAIL) { /* @@ -17184,7 +17184,7 @@ static char_u *find_option_end(char_u **arg, int *opt_flags) return NULL; *arg = p; - if (p[0] == 't' && p[1] == '_' && p[2] != NUL && p[3] != NUL) + if (p[0] == 't' && p[1] == '_' && p[2] != '\0' && p[3] != '\0') p += 4; /* termcap option */ else while (ASCII_ISALPHA(*p)) @@ -17253,7 +17253,7 @@ void ex_function(exarg_T *eap) regmatch_T regmatch; c = *p; - *p = NUL; + *p = '\0'; regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC); *p = c; if (regmatch.regprog != NULL) { @@ -17325,7 +17325,7 @@ void ex_function(exarg_T *eap) } eap->nextcmd = check_nextcmd(p); if (eap->nextcmd != NULL) - *p = NUL; + *p = '\0'; if (!eap->skip && !got_int) { fp = find_func(name); if (fp != NULL) { @@ -17384,10 +17384,10 @@ void ex_function(exarg_T *eap) j = 3; else j = 0; - while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j]) + while (arg[j] != '\0' && (j == 0 ? eval_isnamec1(arg[j]) : eval_isnamec(arg[j]))) ++j; - if (arg[j] != NUL) + if (arg[j] != '\0') emsg_funcname((char *)e_invarg2, arg); } /* Disallow using the g: dict. */ @@ -17416,7 +17416,7 @@ void ex_function(exarg_T *eap) } ga_grow(&newargs, 1); c = *p; - *p = NUL; + *p = '\0'; arg = vim_strsave(arg); if (arg == NULL) goto erret; @@ -17466,7 +17466,7 @@ void ex_function(exarg_T *eap) * Makes 'exe "func Test()\n...\nendfunc"' work. */ if (*p == '\n') line_arg = p + 1; - else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg) + else if (*p != '\0' && *p != '"' && !eap->skip && !did_emsg) EMSG(_(e_trailing)); /* @@ -17507,7 +17507,7 @@ void ex_function(exarg_T *eap) if (p == NULL) line_arg += STRLEN(line_arg); else { - *p = NUL; + *p = '\0'; line_arg = p + 1; } } else if (eap->getline == NULL) @@ -17597,7 +17597,7 @@ void ex_function(exarg_T *eap) )) { /* ":python <<" continues until a dot, like ":append" */ p = skipwhite(arg + 2); - if (*p == NUL) + if (*p == '\0') skip_until = vim_strsave((char_u *)"."); else skip_until = vim_strsave(p); @@ -17625,7 +17625,7 @@ void ex_function(exarg_T *eap) ((char_u **)(newlines.ga_data))[newlines.ga_len++] = NULL; /* Check for end of eap->arg. */ - if (line_arg != NULL && *line_arg == NUL) + if (line_arg != NULL && *line_arg == '\0') line_arg = NULL; } @@ -17955,7 +17955,7 @@ trans_function_name ( STRCPY(name + 3, sid_buf); } memmove(name + lead, lv.ll_name, (size_t)len); - name[lead + len] = NUL; + name[lead + len] = '\0'; } *pp = end; @@ -18081,7 +18081,7 @@ static int function_exists(char_u *name) /* Only accept "funcname", "funcname ", "funcname (..." and * "funcname(...", not "funcname!...". */ - if (p != NULL && (*nm == NUL || *nm == '(')) + if (p != NULL && (*nm == '\0' || *nm == '(')) n = translated_function_exists(p); vim_free(p); return n; @@ -18094,7 +18094,7 @@ char_u *get_expanded_name(char_u *name, int check) p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL); - if (p != NULL && *nm == NUL) + if (p != NULL && *nm == '\0') if (!check || translated_function_exists(p)) return p; @@ -18349,7 +18349,7 @@ static char_u *autoload_name(char_u *name) return FALSE; STRCPY(scriptname, "autoload/"); STRCAT(scriptname, name); - *vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL; + *vim_strrchr(scriptname, AUTOLOAD_CHAR) = '\0'; STRCAT(scriptname, ".vim"); while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL) *p = '/'; @@ -18435,7 +18435,7 @@ void ex_delfunction(exarg_T *eap) } eap->nextcmd = check_nextcmd(p); if (eap->nextcmd != NULL) - *p = NUL; + *p = '\0'; if (!eap->skip) fp = find_func(name); @@ -18918,7 +18918,7 @@ void ex_return(exarg_T *eap) ++emsg_skip; eap->nextcmd = NULL; - if ((*arg != NUL && *arg != '|' && *arg != '\n') + if ((*arg != '\0' && *arg != '|' && *arg != '\n') && eval0(arg, &rettv, &eap->nextcmd, !eap->skip) != FAIL) { if (!eap->skip) returning = do_return(eap, FALSE, TRUE, &rettv); @@ -19321,7 +19321,7 @@ int store_session_globals(FILE *fd) (char_u *)"\\\"\n\r"); if (p == NULL) /* out of memory */ break; - for (t = p; *t != NUL; ++t) + for (t = p; *t != '\0'; ++t) if (*t == '\n') *t = 'n'; else if (*t == '\r') @@ -19447,7 +19447,7 @@ repeat: # ifdef BACKSLASH_IN_FILENAME || (*fnamep)[1] == '\\' # endif - || (*fnamep)[1] == NUL) + || (*fnamep)[1] == '\0') #endif ) { @@ -19459,19 +19459,19 @@ repeat: } /* When "/." or "/.." is used: force expansion to get rid of it. */ - for (p = *fnamep; *p != NUL; mb_ptr_adv(p)) { + for (p = *fnamep; *p != '\0'; mb_ptr_adv(p)) { if (vim_ispathsep(*p) && p[1] == '.' - && (p[2] == NUL + && (p[2] == '\0' || vim_ispathsep(p[2]) || (p[2] == '.' - && (p[3] == NUL || vim_ispathsep(p[3]))))) + && (p[3] == '\0' || vim_ispathsep(p[3]))))) break; } /* FullName_save() is slow, don't use it when not needed. */ - if (*p != NUL || !vim_isAbsName(*fnamep)) { - *fnamep = FullName_save(*fnamep, *p != NUL); + if (*p != '\0' || !vim_isAbsName(*fnamep)) { + *fnamep = FullName_save(*fnamep, *p != '\0'); vim_free(*bufp); /* free any allocated file name */ *bufp = *fnamep; if (*fnamep == NULL) @@ -19732,7 +19732,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags) + ga.ga_len + i, TRUE, TRUE, FALSE); ga.ga_len += i + sublen - 1; tail = regmatch.endp[0]; - if (*tail == NUL) + if (*tail == '\0') break; if (!do_all) break; @@ -19781,7 +19781,7 @@ static void on_job_data(RStream *rstream, void *data, bool eof, char *type) char *str = xmalloc(read_count + 1); rstream_read(rstream, str, read_count); - str[read_count] = NUL; + str[read_count] = '\0'; apply_job_autocmds(job, job_data(job), type, str); } diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 0cbd4faccb..2986ab6dc5 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -92,15 +92,15 @@ void do_ascii(exarg_T *eap) c = utfc_ptr2char(ml_get_cursor(), cc); else c = gchar_cursor(); - if (c == NUL) { - MSG("NUL"); + if (c == '\0') { + MSG("'\0'"); return; } - IObuff[0] = NUL; + IObuff[0] = '\0'; if (!has_mbyte || (enc_dbcs != 0 && c < 0x100) || c < 0x80) { - if (c == NL) /* NUL is stored as NL */ - c = NUL; + if (c == NL) /* '\0' is stored as NL */ + c = '\0'; if (c == CAR && get_fileformat(curbuf) == EOL_MAC) cval = NL; /* NL is stored as CR */ else @@ -111,12 +111,12 @@ void do_ascii(exarg_T *eap) transchar_nonprint(buf3, c); vim_snprintf(buf1, sizeof(buf1), " <%s>", (char *)buf3); } else - buf1[0] = NUL; + buf1[0] = '\0'; if (c >= 0x80) vim_snprintf(buf2, sizeof(buf2), " <M-%s>", (char *)transchar(c & 0x7f)); else - buf2[0] = NUL; + buf2[0] = '\0'; vim_snprintf((char *)IObuff, IOSIZE, _("<%s>%s%s %d, Hex %02x, Octal %03o"), transchar(c), buf1, buf2, cval, cval, cval); @@ -264,7 +264,7 @@ static int linelen(int *has_tab) last > first && vim_iswhite(last[-1]); --last) ; save = *last; - *last = NUL; + *last = '\0'; len = linetabsize(line); /* get line length */ if (has_tab != NULL) /* check for embedded TAB */ *has_tab = (vim_strrchr(first, TAB) != NULL); @@ -373,7 +373,7 @@ void ex_sort(exarg_T *eap) sort_abort = sort_ic = sort_rx = sort_nr = sort_oct = sort_hex = 0; - for (p = eap->arg; *p != NUL; ++p) { + for (p = eap->arg; *p != '\0'; ++p) { if (vim_iswhite(*p)) ; else if (*p == 'i') @@ -399,7 +399,7 @@ void ex_sort(exarg_T *eap) EMSG(_(e_invalpat)); goto sortend; } - *s = NUL; + *s = '\0'; /* Use last search pattern if sort pattern is empty. */ if (s == p + 1) { if (last_search_pat() == NULL) { @@ -458,7 +458,7 @@ void ex_sort(exarg_T *eap) * of the match, by temporarily terminating the string there */ s2 = s + end_col; c = *s2; - *s2 = NUL; + *s2 = '\0'; /* Sorting on number: Store the number itself. */ p = s + start_col; if (sort_hex) @@ -467,7 +467,7 @@ void ex_sort(exarg_T *eap) s = skiptodigit(p); if (s > p && s[-1] == '-') --s; /* include preceding negative sign */ - if (*s == NUL) + if (*s == '\0') /* empty line should sort before any number */ nrs[lnum - eap->line1].start_col_nr = -MAXLNUM; else @@ -647,7 +647,7 @@ void ex_retab(exarg_T *eap) got_tab = FALSE; num_spaces = 0; } - if (ptr[col] == NUL) + if (ptr[col] == '\0') break; vcol += chartabsize(ptr + col, (colnr_T)vcol); if (has_mbyte) @@ -896,7 +896,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out) vim_free(newcmd); return; } - *t = NUL; + *t = '\0'; if (newcmd != NULL) STRCAT(t, newcmd); if (ins_prevcmd) @@ -917,7 +917,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out) STRMOVE(p - 1, p); else { trailarg = p; - *trailarg++ = NUL; + *trailarg++ = '\0'; ins_prevcmd = TRUE; break; } @@ -943,7 +943,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out) /* * Add quotes around the command, for shells that need them. */ - if (*p_shq != NUL) { + if (*p_shq != '\0') { newcmd = alloc((unsigned)(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1)); if (newcmd == NULL) return; @@ -1006,7 +1006,7 @@ do_filter ( buf_T *old_curbuf = curbuf; int shell_flags = 0; - if (*cmd == NUL) /* no filter command */ + if (*cmd == '\0') /* no filter command */ return; @@ -1376,14 +1376,14 @@ make_filter_cmd ( * Don't do this when 'shellquote' is not empty, otherwise the * redirection would be inside the quotes. */ - if (*p_shq == NUL) { + if (*p_shq == '\0') { p = vim_strchr(buf, '|'); if (p != NULL) - *p = NUL; + *p = '\0'; } STRCAT(buf, " < "); STRCAT(buf, itmp); - if (*p_shq == NUL) { + if (*p_shq == '\0') { p = vim_strchr(cmd, '|'); if (p != NULL) { STRCAT(buf, " "); /* insert a space before the '|' for DOS */ @@ -1448,7 +1448,7 @@ int viminfo_error(char *errnum, char *message, char_u *line) errnum, message); STRNCAT(IObuff, line, IOSIZE - STRLEN(IObuff) - 1); if (IObuff[STRLEN(IObuff) - 1] == '\n') - IObuff[STRLEN(IObuff) - 1] = NUL; + IObuff[STRLEN(IObuff) - 1] = '\0'; emsg(IObuff); if (++viminfo_errcnt >= 10) { EMSG(_("E136: viminfo: Too many errors, skipping rest of file")); @@ -1737,10 +1737,10 @@ end: */ static char_u *viminfo_filename(char_u *file) { - if (file == NULL || *file == NUL) { + if (file == NULL || *file == '\0') { if (use_viminfo != NULL) file = use_viminfo; - else if ((file = find_viminfo_parameter('n')) == NULL || *file == NUL) { + else if ((file = find_viminfo_parameter('n')) == NULL || *file == '\0') { #ifdef VIMINFO_FILE2 /* don't use $HOME when not defined (turned into "c:/"!). */ if (os_getenv((char_u *)"HOME") == NULL) { @@ -1831,7 +1831,7 @@ static int read_viminfo_up_to_marks(vir_T *virp, int forceit, int writing) case '^': /* to be defined */ case '<': /* long line - ignored */ /* A comment or empty line. */ - case NUL: + case '\0': case '\r': case '\n': case '#': @@ -1905,7 +1905,7 @@ static int viminfo_encoding(vir_T *virp) ++p; for (i = 0; vim_isprintc(p[i]); ++i) ; - p[i] = NUL; + p[i] = '\0'; convert_setup(&virp->vir_conv, p, p_enc); } @@ -1962,8 +1962,8 @@ viminfo_readstring ( /* Change CTRL-V CTRL-V to CTRL-V and CTRL-V n to \n in-place. */ d = retval; - while (*s != NUL && *s != '\n') { - if (s[0] == Ctrl_V && s[1] != NUL) { + while (*s != '\0' && *s != '\n') { + if (s[0] == Ctrl_V && s[1] != '\0') { if (s[1] == 'n') *d++ = '\n'; else @@ -1972,9 +1972,9 @@ viminfo_readstring ( } else *d++ = *s++; } - *d = NUL; + *d = '\0'; - if (convert && virp->vir_conv.vc_type != CONV_NONE && *retval != NUL) { + if (convert && virp->vir_conv.vc_type != CONV_NONE && *retval != '\0') { d = string_convert(&virp->vir_conv, retval, NULL); if (d != NULL) { vim_free(retval); @@ -2001,7 +2001,7 @@ void viminfo_writestring(FILE *fd, char_u *p) char_u *s; int len = 0; - for (s = p; *s != NUL; ++s) { + for (s = p; *s != '\0'; ++s) { if (*s == Ctrl_V || *s == '\n') ++len; ++len; @@ -2014,7 +2014,7 @@ void viminfo_writestring(FILE *fd, char_u *p) if (len > LSIZE / 2) fprintf(fd, IF_EB("\026%d\n<", CTRL_V_STR "%d\n<"), len + 3); - while ((c = *p++) != NUL) { + while ((c = *p++) != '\0') { if (c == Ctrl_V || c == '\n') { putc(Ctrl_V, fd); if (c == '\n') @@ -2102,7 +2102,7 @@ int rename_buffer(char_u *new_fname) return FAIL; } curbuf->b_flags |= BF_NOTEDITED; - if (xfname != NULL && *xfname != NUL) { + if (xfname != NULL && *xfname != '\0') { buf = buflist_new(fname, xfname, curwin->w_cursor.lnum, 0); if (buf != NULL && !cmdmod.keepalt) curwin->w_alt_fnum = buf->b_fnum; @@ -2123,14 +2123,14 @@ void ex_file(exarg_T *eap) /* ":0file" removes the file name. Check for illegal uses ":3file", * "0file name", etc. */ if (eap->addr_count > 0 - && (*eap->arg != NUL + && (*eap->arg != '\0' || eap->line2 > 0 || eap->addr_count > 1)) { EMSG(_(e_invarg)); return; } - if (*eap->arg != NUL || eap->addr_count == 1) { + if (*eap->arg != '\0' || eap->addr_count == 1) { if (rename_buffer(eap->arg) == FAIL) return; } @@ -2179,7 +2179,7 @@ int do_write(exarg_T *eap) return FAIL; ffname = eap->arg; - if (*ffname == NUL) { + if (*ffname == '\0') { if (eap->cmdidx == CMD_saveas) { EMSG(_(e_argreq)); goto theend; @@ -2286,7 +2286,7 @@ int do_write(exarg_T *eap) } /* If 'filetype' was empty try detecting it now. */ - if (*curbuf->b_p_ft == NUL) { + if (*curbuf->b_p_ft == '\0') { if (au_has_group((char_u *)"filetypedetect")) (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE); @@ -2377,7 +2377,7 @@ check_overwrite ( * will probably fail anyway. * Use 'shortname' of the current buffer, since there is no buffer * for the written file. */ - if (*p_dir == NUL) { + if (*p_dir == '\0') { dir = alloc(5); if (dir == NULL) return FAIL; @@ -2680,16 +2680,16 @@ do_ecmd ( fname_case(sfname, 0); /* set correct case for sfname */ #endif - if ((flags & ECMD_ADDBUF) && (ffname == NULL || *ffname == NUL)) + if ((flags & ECMD_ADDBUF) && (ffname == NULL || *ffname == '\0')) goto theend; if (ffname == NULL) other_file = TRUE; /* there is no file name */ - else if (*ffname == NUL && curbuf->b_ffname == NULL) + else if (*ffname == '\0' && curbuf->b_ffname == NULL) other_file = FALSE; else { - if (*ffname == NUL) { /* re-edit with same file name */ + if (*ffname == '\0') { /* re-edit with same file name */ ffname = curbuf->b_ffname; sfname = curbuf->b_fname; } @@ -2724,7 +2724,7 @@ do_ecmd ( reset_VIsual(); if ((command != NULL || newlnum > (linenr_T)0) - && *get_vim_var_str(VV_SWAPCOMMAND) == NUL) { + && *get_vim_var_str(VV_SWAPCOMMAND) == '\0') { int len; char_u *p; @@ -3121,7 +3121,7 @@ do_ecmd ( /* If the window options were changed may need to set the spell language. * Can only do this after the buffer has been properly setup. */ - if (did_get_winopts && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) + if (did_get_winopts && curwin->w_p_spell && *curwin->w_s->b_p_spl != '\0') (void)did_set_spelllang(curwin); if (command == NULL) { @@ -3261,19 +3261,19 @@ void ex_append(exarg_T *eap) if (eap->getline == NULL) { /* No getline() function, use the lines that follow. This ends * when there is no more. */ - if (eap->nextcmd == NULL || *eap->nextcmd == NUL) + if (eap->nextcmd == NULL || *eap->nextcmd == '\0') break; p = vim_strchr(eap->nextcmd, NL); if (p == NULL) p = eap->nextcmd + STRLEN(eap->nextcmd); theline = vim_strnsave(eap->nextcmd, (int)(p - eap->nextcmd)); - if (*p != NUL) + if (*p != '\0') ++p; eap->nextcmd = p; } else theline = eap->getline( eap->cstack->cs_looplevel > 0 ? -1 : - NUL, eap->cookie, indent); + '\0', eap->cookie, indent); lines_left = Rows - 1; if (theline == NULL) break; @@ -3292,7 +3292,7 @@ void ex_append(exarg_T *eap) else break; } - if ((p[0] == '.' && p[1] == NUL) + if ((p[0] == '.' && p[1] == '\0') || (!did_undo && u_save(lnum, lnum + 1 + (empty ? 1 : 0)) == FAIL)) { vim_free(theline); @@ -3300,8 +3300,8 @@ void ex_append(exarg_T *eap) } /* don't use autoindent if nothing was typed. */ - if (p[0] == NUL) - theline[0] = NUL; + if (p[0] == '\0') + theline[0] = '\0'; did_undo = TRUE; ml_append(lnum, theline, (colnr_T)0, FALSE); @@ -3581,7 +3581,7 @@ void do_sub(exarg_T *eap) which_pat = RE_SUBST; /* use last substitute regexp */ /* new pattern and substitution */ - if (eap->cmd[0] == 's' && *cmd != NUL && !vim_iswhite(*cmd) + if (eap->cmd[0] == 's' && *cmd != '\0' && !vim_iswhite(*cmd) && vim_strchr((char_u *)"0123456789cegriIp|\"", *cmd) == NULL) { /* don't accept alphanumeric for separator */ if (isalpha(*cmd)) { @@ -3611,7 +3611,7 @@ void do_sub(exarg_T *eap) pat = cmd; /* remember start of search pat */ cmd = skip_regexp(cmd, delimiter, p_magic, &eap->arg); if (cmd[0] == delimiter) /* end delimiter found */ - *cmd++ = NUL; /* replace it with a NUL */ + *cmd++ = '\0'; /* replace it with a NUL */ } /* @@ -3622,7 +3622,7 @@ void do_sub(exarg_T *eap) while (cmd[0]) { if (cmd[0] == delimiter) { /* end delimiter found */ - *cmd++ = NUL; /* replace it with a NUL */ + *cmd++ = '\0'; /* replace it with a NUL */ break; } if (cmd[0] == '\\' && cmd[1] != 0) /* skip escaped characters */ @@ -3663,8 +3663,8 @@ void do_sub(exarg_T *eap) // efficient, avoid allocating a string that grows in size. if (pat != NULL && strcmp((const char *)pat, "\\n") == 0 - && *sub == NUL - && (*cmd == NUL || (cmd[1] == NUL + && *sub == '\0' + && (*cmd == '\0' || (cmd[1] == '\0' && (*cmd == 'g' || *cmd == 'l' || *cmd == 'p' @@ -3915,7 +3915,7 @@ void do_sub(exarg_T *eap) if (matchcol == prev_matchcol && regmatch.endpos[0].lnum == 0 && matchcol == regmatch.endpos[0].col) { - if (sub_firstline[matchcol] == NUL) + if (sub_firstline[matchcol] == '\0') /* We already were at the end of the line. Don't look * for a match in this line again. */ skip_match = TRUE; @@ -4182,7 +4182,7 @@ void do_sub(exarg_T *eap) */ new_start_len = needed_len + 50; new_start = (char_u *)xmalloc((size_t)new_start_len); - *new_start = NUL; + *new_start = '\0'; new_end = new_start; } else { /* @@ -4251,11 +4251,11 @@ void do_sub(exarg_T *eap) * That is Vi compatible. */ for (p1 = new_end; *p1; ++p1) { - if (p1[0] == '\\' && p1[1] != NUL) /* remove backslash */ + if (p1[0] == '\\' && p1[1] != '\0') /* remove backslash */ STRMOVE(p1, p1 + 1); else if (*p1 == CAR) { if (u_inssub(lnum) == OK) { /* prepare for undo */ - *p1 = NUL; /* truncate up to the CR */ + *p1 = '\0'; /* truncate up to the CR */ ml_append(lnum - 1, new_start, (colnr_T)(p1 - new_start + 1), FALSE); mark_adjust(lnum + 1, (linenr_T)MAXLNUM, 1L, 0L); @@ -4297,7 +4297,7 @@ skip: || got_quit || lnum > line2 || !(do_all || do_again) - || (sub_firstline[matchcol] == NUL && nmatch <= 1 + || (sub_firstline[matchcol] == '\0' && nmatch <= 1 && !re_multiline(regmatch.regprog))); nmatch = -1; @@ -4474,7 +4474,7 @@ do_sub_msg ( if (got_int) STRCPY(msg_buf, _("(Interrupted) ")); else - *msg_buf = NUL; + *msg_buf = '\0'; if (sub_nsubs == 1) vim_snprintf_add((char *)msg_buf, sizeof(msg_buf), "%s", count_only ? _("1 match") : _("1 substitution")); @@ -4559,7 +4559,7 @@ void ex_global(exarg_T *eap) which_pat = RE_SEARCH; /* use previous search pattern */ ++cmd; pat = (char_u *)""; - } else if (*cmd == NUL) { + } else if (*cmd == '\0') { EMSG(_("E148: Regular expression missing from global")); return; } else { @@ -4569,7 +4569,7 @@ void ex_global(exarg_T *eap) pat = cmd; /* remember start of pattern */ cmd = skip_regexp(cmd, delim, p_magic, &eap->arg); if (cmd[0] == delim) /* end delimiter found */ - *cmd++ = NUL; /* replace it with a NUL */ + *cmd++ = '\0'; /* replace it with a NUL */ } if (p_altkeymap && curwin->w_p_rl) @@ -4638,7 +4638,7 @@ void global_exe(char_u *cmd) while (!got_int && (lnum = ml_firstmarked()) != 0 && global_busy == 1) { curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = 0; - if (*cmd == NUL || *cmd == '\n') + if (*cmd == '\0' || *cmd == '\n') do_cmdline((char_u *)"p", NULL, NULL, DOCMD_NOWAIT); else do_cmdline(cmd, NULL, NULL, DOCMD_NOWAIT); @@ -4763,15 +4763,15 @@ void ex_help(exarg_T *eap) */ for (arg = eap->arg; *arg; ++arg) { if (*arg == '\n' || *arg == '\r' - || (*arg == '|' && arg[1] != NUL && arg[1] != '|')) { - *arg++ = NUL; + || (*arg == '|' && arg[1] != '\0' && arg[1] != '|')) { + *arg++ = '\0'; eap->nextcmd = arg; break; } } arg = eap->arg; - if (eap->forceit && *arg == NUL && !curbuf->b_help) { + if (eap->forceit && *arg == '\0' && !curbuf->b_help) { EMSG(_("E478: Don't panic!")); return; } @@ -4784,13 +4784,13 @@ void ex_help(exarg_T *eap) /* remove trailing blanks */ p = arg + STRLEN(arg) - 1; while (p > arg && vim_iswhite(*p) && p[-1] != '\\') - *p-- = NUL; + *p-- = '\0'; /* Check for a specified language */ lang = check_help_lang(arg); /* When no argument given go to the index. */ - if (*arg == NUL) + if (*arg == '\0') arg = (char_u *)"help.txt"; /* @@ -4917,7 +4917,7 @@ char_u *check_help_lang(char_u *arg) if (len >= 3 && arg[len - 3] == '@' && ASCII_ISALPHA(arg[len - 2]) && ASCII_ISALPHA(arg[len - 1])) { - arg[len - 3] = NUL; /* remove the '@' */ + arg[len - 3] = '\0'; /* remove the '@' */ return arg + len - 2; } return NULL; @@ -4967,7 +4967,7 @@ help_heuristic ( offset += 5000; /* Features are less interesting than the subjects themselves, but "+" * alone is not a feature. */ - if (matched_string[0] == '+' && matched_string[1] != NUL) + if (matched_string[0] == '+' && matched_string[1] != '\0') offset += 100; return (int)(100 * num_letters + STRLEN(matched_string) + offset); } @@ -5035,9 +5035,9 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la * Also "\@<", "\@=", "\@<=", etc. * And also "\_$" and "\_^". */ if (arg[0] == '\\' - && ((arg[1] != NUL && arg[2] == NUL) + && ((arg[1] != '\0' && arg[2] == '\0') || (vim_strchr((char_u *)"%_z@", arg[1]) != NULL - && arg[2] != NUL))) { + && arg[2] != '\0'))) { STRCPY(d, "/\\\\"); STRCPY(d + 3, arg + 1); /* Check for "/\\_$", should be "/\\_\$" */ @@ -5101,7 +5101,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la *d++ = '\\'; /* double a backslash */ } else *d++ = *++s; - if (s[1] != NUL && s[1] != '_') + if (s[1] != '\0' && s[1] != '_') *d++ = '_'; /* append a '_' */ continue; } else if (*s == '^') /* "^" or "CTRL-^" or "^_" */ @@ -5132,22 +5132,22 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la if (*s == '\'' && s > arg && *arg == '\'') break; } - *d = NUL; + *d = '\0'; if (*IObuff == '`') { if (d > IObuff + 2 && d[-1] == '`') { /* remove the backticks from `command` */ memmove(IObuff, IObuff + 1, STRLEN(IObuff)); - d[-2] = NUL; + d[-2] = '\0'; } else if (d > IObuff + 3 && d[-2] == '`' && d[-1] == ',') { /* remove the backticks and comma from `command`, */ memmove(IObuff, IObuff + 1, STRLEN(IObuff)); - d[-3] = NUL; + d[-3] = '\0'; } else if (d > IObuff + 4 && d[-3] == '`' && d[-2] == '\\' && d[-1] == '.') { /* remove the backticks and dot from `command`\. */ memmove(IObuff, IObuff + 1, STRLEN(IObuff)); - d[-4] = NUL; + d[-4] = '\0'; } } } @@ -5227,7 +5227,7 @@ void fix_help_buffer(void) && ASCII_ISALPHA(fname[5]) && ASCII_ISALPHA(fname[6]) && TOLOWER_ASC(fname[7]) == 'x' - && fname[8] == NUL) + && fname[8] == '\0') ) { for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum) { line = ml_get_buf(curbuf, lnum, FALSE); @@ -5237,7 +5237,7 @@ void fix_help_buffer(void) /* Go through all directories in 'runtimepath', skipping * $VIMRUNTIME. */ p = p_rtp; - while (*p != NUL) { + while (*p != '\0') { copy_option_part(&p, NameBuff, MAXPATHL, ","); mustfree = FALSE; rt = vim_getenv((char_u *)"VIMRUNTIME", &mustfree); @@ -5279,7 +5279,7 @@ void fix_help_buffer(void) continue; e1 = vim_strrchr(t1, '.'); e2 = vim_strrchr(path_tail(f2), '.'); - if (e1 == NUL || e2 == NUL) + if (e1 == '\0' || e2 == '\0') continue; if (fnamecmp(e1, ".txt") != 0 && fnamecmp(e1, fname + 4) != 0) { @@ -5312,9 +5312,9 @@ void fix_help_buffer(void) * reference and remove <CR>/<NL>. */ IObuff[0] = '|'; *s = '|'; - while (*s != NUL) { + while (*s != '\0') { if (*s == '\r' || *s == '\n') - *s = NUL; + *s = '\0'; /* The text is utf-8 when a byte * above 127 is found and no * illegal byte sequence is found. @@ -5474,7 +5474,7 @@ void ex_helptags(exarg_T *eap) fname[6] = ((char_u *)ga.ga_data)[j + 1]; if (fname[5] == 'e' && fname[6] == 'n') { /* English is an exception: use ".txt" and "tags". */ - fname[4] = NUL; + fname[4] = '\0'; STRCPY(ext, ".txt"); } else { /* Language "ab" uses ".abx" and "tags-ab". */ @@ -5574,7 +5574,7 @@ helptags_one ( if (firstline) { /* Detect utf-8 file by a non-ASCII char in the first line. */ this_utf8 = MAYBE; - for (s = IObuff; *s != NUL; ++s) + for (s = IObuff; *s != '\0'; ++s) if (*s >= 0x80) { int l; @@ -5660,7 +5660,7 @@ helptags_one ( p2 = ((char_u **)ga.ga_data)[i]; while (*p1 == *p2) { if (*p2 == '\t') { - *p2 = NUL; + *p2 = '\0'; vim_snprintf((char *)NameBuff, MAXPATHL, _("E154: Duplicate tag \"%s\" in file %s/%s"), ((char_u **)ga.ga_data)[i], dir, p2 + 1); @@ -5757,7 +5757,7 @@ static int sign_cmd_idx( int idx; char save = *end_cmd; - *end_cmd = NUL; + *end_cmd = '\0'; for (idx = 0; ; ++idx) { if (cmds[idx] == NULL || STRCMP(begin_cmd, cmds[idx]) == 0) { break; @@ -5794,22 +5794,22 @@ void ex_sign(exarg_T *eap) /* * Define, undefine or list signs. */ - if (idx == SIGNCMD_LIST && *arg == NUL) + if (idx == SIGNCMD_LIST && *arg == '\0') { /* ":sign list": list all defined signs */ for (sp = first_sign; sp != NULL && !got_int; sp = sp->sn_next) sign_list_defined(sp); } - else if (*arg == NUL) + else if (*arg == '\0') EMSG(_("E156: Missing sign name")); else { /* Isolate the sign name. If it's a number skip leading zeroes, * so that "099" and "99" are the same sign. But keep "0". */ p = skiptowhite(arg); - if (*p != NUL) - *p++ = NUL; - while (arg[0] == '0' && arg[1] != NUL) + if (*p != '\0') + *p++ = '\0'; + while (arg[0] == '0' && arg[1] != '\0') ++arg; sp_prev = NULL; @@ -5874,7 +5874,7 @@ void ex_sign(exarg_T *eap) for (;;) { arg = skipwhite(p); - if (*arg == NUL) + if (*arg == '\0') break; p = skiptowhite_esc(arg); if (STRNCMP(arg, "icon=", 5) == 0) @@ -5914,7 +5914,7 @@ void ex_sign(exarg_T *eap) /* Currently must be one or two display cells */ if (s != p || cells < 1 || cells > 2) { - *p = NUL; + *p = '\0'; EMSG2(_("E239: Invalid sign text: %s"), arg); return; } @@ -5962,7 +5962,7 @@ void ex_sign(exarg_T *eap) char_u *sign_name = NULL; char_u *arg1; - if (*arg == NUL) + if (*arg == '\0') { if (idx == SIGNCMD_PLACE) { @@ -5986,7 +5986,7 @@ void ex_sign(exarg_T *eap) return; } - if (idx == SIGNCMD_UNPLACE && arg[0] == '*' && arg[1] == NUL) + if (idx == SIGNCMD_UNPLACE && arg[0] == '*' && arg[1] == '\0') { /* ":sign unplace *": remove all placed signs */ buf_delete_all_signs(); @@ -5998,7 +5998,7 @@ void ex_sign(exarg_T *eap) if (VIM_ISDIGIT(*arg)) { id = getdigits(&arg); - if (!vim_iswhite(*arg) && *arg != NUL) + if (!vim_iswhite(*arg) && *arg != '\0') { id = -1; arg = arg1; @@ -6006,7 +6006,7 @@ void ex_sign(exarg_T *eap) else { arg = skipwhite(arg); - if (idx == SIGNCMD_UNPLACE && *arg == NUL) + if (idx == SIGNCMD_UNPLACE && *arg == '\0') { /* ":sign unplace {id}": remove placed sign by number */ for (buf = firstbuf; buf != NULL; buf = buf->b_next) @@ -6044,9 +6044,9 @@ void ex_sign(exarg_T *eap) arg += 5; sign_name = arg; arg = skiptowhite(arg); - if (*arg != NUL) - *arg++ = NUL; - while (sign_name[0] == '0' && sign_name[1] != NUL) + if (*arg != '\0') + *arg++ = '\0'; + while (sign_name[0] == '0' && sign_name[1] != '\0') ++sign_name; } else if (STRNCMP(arg, "file=", 5) == 0) @@ -6059,7 +6059,7 @@ void ex_sign(exarg_T *eap) { arg += 7; buf = buflist_findnr((int)getdigits(&arg)); - if (*skipwhite(arg) != NUL) + if (*skipwhite(arg) != '\0') EMSG(_(e_trailing)); break; } @@ -6363,7 +6363,7 @@ set_context_in_sign_cmd(xp, arg) xp->xp_pattern = arg; end_subcmd = skiptowhite(arg); - if (*end_subcmd == NUL) + if (*end_subcmd == '\0') /* expand subcmd name * :sign {subcmd}<CTRL-D>*/ return; @@ -6375,7 +6375,7 @@ set_context_in_sign_cmd(xp, arg) * begin_subcmd_args */ begin_subcmd_args = skipwhite(end_subcmd); p = skiptowhite(begin_subcmd_args); - if (*p == NUL) + if (*p == '\0') { /* * Expand first argument of subcmd when possible. @@ -6409,14 +6409,14 @@ set_context_in_sign_cmd(xp, arg) p = skipwhite(p); last = p; p = skiptowhite(p); - } while (*p != NUL); + } while (*p != '\0'); p = vim_strchr(last, '='); /* :sign define {name} {args}... {last}= * | | * last p */ - if (p == NUL) + if (p == '\0') { /* Expand last argument name (before equal sign). */ xp->xp_pattern = last; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 0148a7b6b2..c071b7b021 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -179,7 +179,7 @@ void do_debug(char_u *cmd) * If not, reset "last_cmd". * For a blank line use previous command. */ p = skipwhite(cmdline); - if (*p != NUL) { + if (*p != '\0') { switch (*p) { case 'c': last_cmd = CMD_CONT; tail = "ont"; @@ -204,7 +204,7 @@ void do_debug(char_u *cmd) if (last_cmd != 0) { /* Check that the tail matches. */ ++p; - while (*p != NUL && *p == *tail) { + while (*p != '\0' && *p == *tail) { ++p; ++tail; } @@ -322,7 +322,7 @@ void dbg_check_breakpoint(exarg_T *eap) p = (char_u *)""; smsg((char_u *)_("Breakpoint in \"%s%s\" line %" PRId64), p, - debug_breakpoint_name + (*p == NUL ? 0 : 3), + debug_breakpoint_name + (*p == '\0' ? 0 : 3), (int64_t)debug_breakpoint_lnum); debug_breakpoint_name = NULL; do_debug(eap->cmd); @@ -448,8 +448,8 @@ dbg_parsearg ( bp->dbg_lnum = 0; /* Find the function or file name. Don't accept a function name with (). */ - if ((!here && *p == NUL) - || (here && *p != NUL) + if ((!here && *p == '\0') + || (here && *p != '\0') || (bp->dbg_type == DBG_FUNC && strstr((char *)p, "()") != NULL)) { EMSG2(_(e_invarg2), arg); return FAIL; @@ -937,7 +937,7 @@ void ex_profile(exarg_T *eap) len = (int)(e - eap->arg); e = skipwhite(e); - if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != NUL) { + if (len == 5 && STRNCMP(eap->arg, "start", 5) == 0 && *e != '\0') { vim_free(profile_fname); profile_fname = vim_strsave(e); do_profiling = PROF_YES; @@ -1010,7 +1010,7 @@ void set_context_in_profile_cmd(expand_T *xp, char_u *arg) xp->xp_pattern = arg; end_subcmd = skiptowhite(arg); - if (*end_subcmd == NUL) + if (*end_subcmd == '\0') return; if (end_subcmd - arg == 5 && STRNCMP(arg, "start", 5) == 0) { @@ -1529,7 +1529,7 @@ static char_u *do_one_arg(char_u *str) } } str = skipwhite(str); - *p = NUL; + *p = '\0'; return str; } @@ -1541,7 +1541,7 @@ static char_u *do_one_arg(char_u *str) void get_arglist(garray_T *gap, char_u *str) { ga_init(gap, (int)sizeof(char_u *), 20); - while (*str != NUL) { + while (*str != '\0') { ga_grow(gap, 1); ((char_u **)gap->ga_data)[gap->ga_len++] = str; @@ -1898,7 +1898,7 @@ void ex_next(exarg_T *eap) || !check_changed(curbuf, CCGD_AW | (eap->forceit ? CCGD_FORCEIT : 0) | CCGD_EXCMD)) { - if (*eap->arg != NUL) { /* redefine file list */ + if (*eap->arg != '\0') { /* redefine file list */ if (do_arglist(eap->arg, AL_SET, 0) == FAIL) return; i = 0; @@ -1963,7 +1963,7 @@ void ex_argdelete(exarg_T *eap) if (eap->line2 > ARGCOUNT) eap->line2 = ARGCOUNT; n = eap->line2 - eap->line1 + 1; - if (*eap->arg != NUL || n <= 0) + if (*eap->arg != '\0' || n <= 0) EMSG(_(e_invarg)); else { for (i = eap->line1; i <= eap->line2; ++i) @@ -1976,7 +1976,7 @@ void ex_argdelete(exarg_T *eap) else if (curwin->w_arg_idx > eap->line1) curwin->w_arg_idx = eap->line1; } - } else if (*eap->arg == NUL) + } else if (*eap->arg == '\0') EMSG(_(e_argreq)); else do_arglist(eap->arg, AL_DEL, 0); @@ -2153,7 +2153,7 @@ void ex_compiler(exarg_T *eap) char_u *old_cur_comp = NULL; char_u *p; - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { /* List all compiler scripts. */ do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')"); /* ) keep the indenter happy... */ @@ -2272,7 +2272,7 @@ void *cookie; /* Loop over all entries in 'runtimepath'. */ rtp = rtp_copy; - while (*rtp != NUL && (all || !did_one)) { + while (*rtp != '\0' && (all || !did_one)) { /* Copy the path from 'runtimepath' to buf[]. */ copy_option_part(&rtp, buf, MAXPATHL, ","); if (name == NULL) { @@ -2285,7 +2285,7 @@ void *cookie; /* Loop over all patterns in "name" */ np = name; - while (*np != NUL && (all || !did_one)) { + while (*np != '\0' && (all || !did_one)) { /* Append the pattern from "name" to buf[]. */ copy_option_part(&np, tail, (int)(MAXPATHL - (tail - buf)), "\t "); @@ -2341,7 +2341,7 @@ void ex_source(exarg_T *eap) static void cmd_source(char_u *fname, exarg_T *eap) { - if (*fname == NUL) + if (*fname == '\0') EMSG(_(e_argreq)); else if (eap != NULL && eap->forceit) @@ -2560,7 +2560,7 @@ do_source ( #ifdef USE_CRNL /* If no automatic file format: Set default to CR-NL. */ - if (*p_ffs == NUL) + if (*p_ffs == '\0') cookie.fileformat = EOL_DOS; else cookie.fileformat = EOL_UNKNOWN; @@ -2569,7 +2569,7 @@ do_source ( #ifdef USE_CR /* If no automatic file format: Set default to CR. */ - if (*p_ffs == NUL) + if (*p_ffs == '\0') cookie.fileformat = EOL_MAC; else cookie.fileformat = EOL_UNKNOWN; @@ -2914,7 +2914,7 @@ char_u *getsourceline(int c, void *cookie, int indent) } ga_concat(&ga, p + 1); } - ga_append(&ga, NUL); + ga_append(&ga, '\0'); vim_free(line); line = ga.ga_data; } @@ -2985,7 +2985,7 @@ static char_u *get_one_sourceline(struct source_cookie *sp) if ( (len == 1 || (len >= 2 && buf[len - 2] == '\n')) && sp->fileformat == EOL_DOS && buf[len - 1] == Ctrl_Z) { - buf[len - 1] = NUL; + buf[len - 1] = '\0'; break; } #endif @@ -3056,7 +3056,7 @@ static char_u *get_one_sourceline(struct source_cookie *sp) continue; } - buf[len - 1] = NUL; /* remove the NL */ + buf[len - 1] = '\0'; /* remove the NL */ } /* @@ -3162,7 +3162,7 @@ void ex_scriptencoding(exarg_T *eap) return; } - if (*eap->arg != NUL) { + if (*eap->arg != '\0') { name = enc_canonize(eap->arg); if (name == NULL) /* out of memory */ return; @@ -3290,9 +3290,9 @@ char_u *get_mess_lang(void) # endif # else p = os_getenv((char_u *)"LC_ALL"); - if (p == NULL || *p == NUL) { + if (p == NULL || *p == '\0') { p = os_getenv((char_u *)"LC_MESSAGES"); - if (p == NULL || *p == NUL) + if (p == NULL || *p == '\0') p = os_getenv((char_u *)"LANG"); } # endif @@ -3311,14 +3311,14 @@ static char_u *get_mess_env(void) char_u *p; p = (char_u *)os_getenv("LC_ALL"); - if (p == NULL || *p == NUL) { + if (p == NULL || *p == '\0') { p = (char_u *)os_getenv("LC_MESSAGES"); - if (p == NULL || *p == NUL) { + if (p == NULL || *p == '\0') { p = (char_u *)os_getenv("LANG"); if (p != NULL && VIM_ISDIGIT(*p)) p = NULL; /* ignore something like "1043" */ # ifdef HAVE_GET_LOCALE_VAL - if (p == NULL || *p == NUL) + if (p == NULL || *p == '\0') p = (char_u *)get_locale_val(LC_CTYPE); # endif } @@ -3383,7 +3383,7 @@ void ex_language(exarg_T *eap) * Allow abbreviation, but require at least 3 characters to avoid * confusion with a two letter language name "me" or "ct". */ p = skiptowhite(eap->arg); - if ((*p == NUL || vim_iswhite(*p)) && p - eap->arg >= 3) { + if ((*p == '\0' || vim_iswhite(*p)) && p - eap->arg >= 3) { if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) { what = VIM_LC_MESSAGES; name = skipwhite(p); @@ -3399,14 +3399,14 @@ void ex_language(exarg_T *eap) } } - if (*name == NUL) { + if (*name == '\0') { #ifdef HAVE_WORKING_LIBINTL if (what == VIM_LC_MESSAGES) p = get_mess_env(); else #endif p = (char_u *)setlocale(what, NULL); - if (p == NULL || *p == NUL) + if (p == NULL || *p == '\0') p = (char_u *)"Unknown"; smsg((char_u *)_("Current %slanguage: \"%s\""), whatstr, p); } else { diff --git a/src/ex_docmd.c b/src/ex_docmd.c index ff1ebeb2f5..12efbe2582 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -1317,7 +1317,7 @@ void *cookie; /*argument for fgetline() */ ++ea.cmd; /* in ex mode, an empty line works like :+ */ - if (*ea.cmd == NUL && exmode_active + if (*ea.cmd == '\0' && exmode_active && (getline_equal(fgetline, cookie, getexmodeline) || getline_equal(fgetline, cookie, getexline)) && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { @@ -1328,7 +1328,7 @@ void *cookie; /*argument for fgetline() */ /* ignore comment and empty lines */ if (*ea.cmd == '"') goto doend; - if (*ea.cmd == NUL) { + if (*ea.cmd == '\0') { ex_pressedreturn = TRUE; goto doend; } @@ -1382,7 +1382,7 @@ void *cookie; /*argument for fgetline() */ /* ":hide" and ":hide | cmd" are not modifiers */ case 'h': if (p != ea.cmd || !checkforcmd(&p, "hide", 3) - || *p == NUL || ends_excmd(*p)) + || *p == '\0' || ends_excmd(*p)) break; ea.cmd = p; cmdmod.hide = TRUE; @@ -1587,7 +1587,7 @@ void *cookie; /*argument for fgetline() */ * If we got a line, but no command, then go to the line. * If we find a '|' or '\n' we set ea.nextcmd. */ - if (*ea.cmd == NUL || *ea.cmd == '"' || + if (*ea.cmd == '\0' || *ea.cmd == '"' || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) { /* * strange vi behaviour: @@ -1855,7 +1855,7 @@ void *cookie; /*argument for fgetline() */ STRMOVE(p, p + 1); else if (*p == '\n') { ea.nextcmd = p + 1; - *p = NUL; + *p = '\0'; break; } } @@ -1868,7 +1868,7 @@ void *cookie; /*argument for fgetline() */ /* accept numbered register only when no count allowed (:put) */ if ( (ea.argt & REGSTR) - && *ea.arg != NUL + && *ea.arg != '\0' /* Do not allow register = for user commands */ && (!USER_CMDIDX(ea.cmdidx) || *ea.arg != '=') && !((ea.argt & COUNT) && VIM_ISDIGIT(*ea.arg))) { @@ -1883,7 +1883,7 @@ void *cookie; /*argument for fgetline() */ ) { ea.regname = *ea.arg++; /* for '=' register: accept the rest of the line as an expression */ - if (ea.arg[-1] == '=' && ea.arg[0] != NUL) { + if (ea.arg[-1] == '=' && ea.arg[0] != '\0') { set_expr_line(vim_strsave(ea.arg)); ea.arg += STRLEN(ea.arg); } @@ -1896,7 +1896,7 @@ void *cookie; /*argument for fgetline() */ * count, it's a buffer name. */ if ((ea.argt & COUNT) && VIM_ISDIGIT(*ea.arg) - && (!(ea.argt & BUFNAME) || *(p = skipdigits(ea.arg)) == NUL + && (!(ea.argt & BUFNAME) || *(p = skipdigits(ea.arg)) == '\0' || vim_iswhite(*p))) { n = getdigits(&ea.arg); ea.arg = skipwhite(ea.arg); @@ -1926,13 +1926,13 @@ void *cookie; /*argument for fgetline() */ if (ea.argt & EXFLAGS) get_flags(&ea); /* no arguments allowed */ - if (!ni && !(ea.argt & EXTRA) && *ea.arg != NUL + if (!ni && !(ea.argt & EXTRA) && *ea.arg != '\0' && *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & TRLBAR) == 0)) { errormsg = (char_u *)_(e_trailing); goto doend; } - if (!ni && (ea.argt & NEEDARG) && *ea.arg == NUL) { + if (!ni && (ea.argt & NEEDARG) && *ea.arg == '\0') { errormsg = (char_u *)_(e_argreq); goto doend; } @@ -2028,7 +2028,7 @@ void *cookie; /*argument for fgetline() */ * Accept buffer name. Cannot be used at the same time with a buffer * number. Don't do this for a user command. */ - if ((ea.argt & BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 + if ((ea.argt & BUFNAME) && *ea.arg != '\0' && ea.addr_count == 0 && !USER_CMDIDX(ea.cmdidx) ) { /* @@ -2099,7 +2099,7 @@ doend: if (curwin->w_cursor.lnum == 0) /* can happen with zero line number */ curwin->w_cursor.lnum = 1; - if (errormsg != NULL && *errormsg != NUL && !did_emsg) { + if (errormsg != NULL && *errormsg != '\0' && !did_emsg) { if (sourcing) { if (errormsg != IObuff) { STRCPY(IObuff, errormsg); @@ -2148,7 +2148,7 @@ doend: --sandbox; #endif - if (ea.nextcmd && *ea.nextcmd == NUL) /* not really a next command */ + if (ea.nextcmd && *ea.nextcmd == '\0') /* not really a next command */ ea.nextcmd = NULL; --ex_nesting_level; @@ -2169,7 +2169,7 @@ checkforcmd ( { int i; - for (i = 0; cmd[i] != NUL; ++i) + for (i = 0; cmd[i] != '\0'; ++i) if (((char_u *)cmd)[i] != (*pp)[i]) break; if (i >= len && !isalpha((*pp)[i])) { @@ -2191,7 +2191,7 @@ static void append_command(char_u *cmd) STRCAT(IObuff, ": "); d = IObuff + STRLEN(IObuff); - while (*s != NUL && d - IObuff < IOSIZE - 7) { + while (*s != '\0' && d - IObuff < IOSIZE - 7) { if ( enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0) { @@ -2203,7 +2203,7 @@ static void append_command(char_u *cmd) } else MB_COPY_CHAR(s, d); } - *d = NUL; + *d = '\0'; } /* @@ -2278,7 +2278,7 @@ static char_u *find_command(exarg_T *eap, int *full) if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, (size_t)len) == 0) { if (full != NULL - && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL) + && cmdnames[(int)eap->cmdidx].cmd_name[len] == '\0') *full = TRUE; break; } @@ -2334,19 +2334,19 @@ find_ucmd ( cp = eap->cmd; np = uc->uc_name; k = 0; - while (k < len && *np != NUL && *cp++ == *np++) + while (k < len && *np != '\0' && *cp++ == *np++) k++; - if (k == len || (*np == NUL && vim_isdigit(eap->cmd[k]))) { + if (k == len || (*np == '\0' && vim_isdigit(eap->cmd[k]))) { /* If finding a second match, the command is ambiguous. But * not if a buffer-local command wasn't a full match and a * global command is a full match. */ - if (k == len && found && *np != NUL) { + if (k == len && found && *np != '\0') { if (gap == &ucmds) return NULL; amb_local = TRUE; } - if (!found || (k == len && *np == NUL)) { + if (!found || (k == len && *np == '\0')) { /* If we matched up to a digit, then there could * be another command including the digit that we * should use instead. @@ -2372,7 +2372,7 @@ find_ucmd ( /* Do not search for further abbreviations * if this is an exact match. */ matchlen = k; - if (k == len && *np == NUL) { + if (k == len && *np == '\0') { if (full != NULL) *full = TRUE; amb_local = FALSE; @@ -2443,7 +2443,7 @@ int modifier_len(char_u *cmd) if (VIM_ISDIGIT(*cmd)) p = skipwhite(skipdigits(cmd)); for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) { - for (j = 0; p[j] != NUL; ++j) + for (j = 0; p[j] != '\0'; ++j) if (p[j] != cmdmods[i].name[j]) break; if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen @@ -2468,11 +2468,11 @@ int cmd_exists(char_u *name) /* Check command modifiers. */ for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) { - for (j = 0; name[j] != NUL; ++j) + for (j = 0; name[j] != '\0'; ++j) if (name[j] != cmdmods[i].name[j]) break; - if (name[j] == NUL && j >= cmdmods[i].minlen) - return cmdmods[i].name[j] == NUL ? 2 : 1; + if (name[j] == '\0' && j >= cmdmods[i].minlen) + return cmdmods[i].name[j] == '\0' ? 2 : 1; } /* Check built-in commands and user defined commands. @@ -2484,7 +2484,7 @@ int cmd_exists(char_u *name) return 3; if (vim_isdigit(*name) && ea.cmdidx != CMD_match) return 0; - if (*skipwhite(p) != NUL) + if (*skipwhite(p) != '\0') return 0; /* trailing garbage */ return ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1); } @@ -2523,7 +2523,7 @@ set_one_cmd_context ( ; xp->xp_pattern = cmd; - if (*cmd == NUL) + if (*cmd == '\0') return NULL; if (*cmd == '"') { /* ignore comment lines */ xp->xp_context = EXPAND_NOTHING; @@ -2539,7 +2539,7 @@ set_one_cmd_context ( * 4. parse command */ xp->xp_pattern = cmd; - if (*cmd == NUL) + if (*cmd == '\0') return NULL; if (*cmd == '"') { xp->xp_context = EXPAND_NOTHING; @@ -2593,7 +2593,7 @@ set_one_cmd_context ( * If the cursor is touching the command, and it ends in an alpha-numeric * character, complete the command name. */ - if (*p == NUL && ASCII_ISALNUM(p[-1])) + if (*p == '\0' && ASCII_ISALNUM(p[-1])) return NULL; if (ea.cmdidx == CMD_SIZE) { @@ -2662,7 +2662,7 @@ set_one_cmd_context ( arg = skip_cmd_arg(arg, FALSE); /* Still touching the command after '+'? */ - if (*arg == NUL) + if (*arg == '\0') return p; /* Skip space(s) after +command to get to the real argument */ @@ -2680,7 +2680,7 @@ set_one_cmd_context ( p += 2; while (*p) { if (*p == Ctrl_V) { - if (p[1] != NUL) + if (p[1] != '\0') ++p; } else if ( (*p == '"' && !(ea.argt & NOTRLCOM)) || *p == '|' || *p == '\n') { @@ -2695,7 +2695,7 @@ set_one_cmd_context ( } /* no arguments allowed */ - if (!(ea.argt & EXTRA) && *arg != NUL && + if (!(ea.argt & EXTRA) && *arg != '\0' && vim_strchr((char_u *)"|\"", *arg) == NULL) return NULL; @@ -2708,7 +2708,7 @@ set_one_cmd_context ( /* argument starts after a space */ xp->xp_pattern = ++p; } else { - if (*p == '\\' && *(p + 1) != NUL) + if (*p == '\\' && *(p + 1) != '\0') ++p; /* skip over escaped character */ mb_ptr_adv(p); } @@ -2725,12 +2725,12 @@ set_one_cmd_context ( */ xp->xp_pattern = skipwhite(arg); p = xp->xp_pattern; - while (*p != NUL) { + while (*p != '\0') { if (has_mbyte) c = mb_ptr2char(p); else c = *p; - if (c == '\\' && p[1] != NUL) + if (c == '\\' && p[1] != '\0') ++p; else if (c == '`') { if (!in_quote) { @@ -2748,7 +2748,7 @@ set_one_cmd_context ( #endif )) { len = 0; /* avoid getting stuck when space is in 'isfname' */ - while (*p != NUL) { + while (*p != '\0') { if (has_mbyte) c = mb_ptr2char(p); else @@ -2791,10 +2791,10 @@ set_one_cmd_context ( /* Check for environment variable */ if (*xp->xp_pattern == '$' ) { - for (p = xp->xp_pattern + 1; *p != NUL; ++p) + for (p = xp->xp_pattern + 1; *p != '\0'; ++p) if (!vim_isIDc(*p)) break; - if (*p == NUL) { + if (*p == '\0') { xp->xp_context = EXPAND_ENV_VARS; ++xp->xp_pattern; /* Avoid that the assignment uses EXPAND_FILES again. */ @@ -2804,12 +2804,12 @@ set_one_cmd_context ( } /* Check for user names */ if (*xp->xp_pattern == '~') { - for (p = xp->xp_pattern + 1; *p != NUL && *p != '/'; ++p) + for (p = xp->xp_pattern + 1; *p != '\0' && *p != '/'; ++p) ; /* Complete ~user only if it partially matches a user name. * A full match ~user<Tab> will be replaced by user's home * directory i.e. something like ~user<Tab> -> /home/user/ */ - if (*p == NUL && p > xp->xp_pattern + 1 + if (*p == '\0' && p > xp->xp_pattern + 1 && match_user(xp->xp_pattern + 1) == 1) { xp->xp_context = EXPAND_USER; ++xp->xp_pattern; @@ -2872,11 +2872,11 @@ set_one_cmd_context ( return arg; case CMD_match: - if (*arg == NUL || !ends_excmd(*arg)) { + if (*arg == '\0' || !ends_excmd(*arg)) { /* also complete "None" */ set_context_in_echohl_cmd(xp, arg); arg = skipwhite(skiptowhite(arg)); - if (*arg != NUL) { + if (*arg != '\0') { xp->xp_context = EXPAND_NOTHING; arg = skip_regexp(arg + 1, *arg, p_magic, NULL); } @@ -2892,7 +2892,7 @@ set_one_cmd_context ( while (*arg == '-') { arg++; /* Skip "-" */ p = skiptowhite(arg); - if (*p == NUL) { + if (*p == '\0') { /* Cursor is still in the attribute */ p = vim_strchr(arg, '='); if (p == NULL) { @@ -2921,7 +2921,7 @@ set_one_cmd_context ( /* After the attributes comes the new command name */ p = skiptowhite(arg); - if (*p == NUL) { + if (*p == '\0') { xp->xp_context = EXPAND_USER_COMMANDS; xp->xp_pattern = arg; break; @@ -2941,12 +2941,12 @@ set_one_cmd_context ( if (delim) ++arg; /* skip delimiter if there is one */ - while (arg[0] != NUL && arg[0] != delim) { - if (arg[0] == '\\' && arg[1] != NUL) + while (arg[0] != '\0' && arg[0] != delim) { + if (arg[0] == '\\' && arg[1] != '\0') ++arg; ++arg; } - if (arg[0] != NUL) + if (arg[0] != '\0') return arg + 1; break; case CMD_and: @@ -2958,16 +2958,16 @@ set_one_cmd_context ( arg = skip_regexp(arg, delim, p_magic, NULL); } /* skip "to" part */ - while (arg[0] != NUL && arg[0] != delim) { - if (arg[0] == '\\' && arg[1] != NUL) + while (arg[0] != '\0' && arg[0] != delim) { + if (arg[0] == '\\' && arg[1] != '\0') ++arg; ++arg; } - if (arg[0] != NUL) /* skip delimiter */ + if (arg[0] != '\0') /* skip delimiter */ ++arg; while (arg[0] && vim_strchr((char_u *)"|\"#", arg[0]) == NULL) ++arg; - if (arg[0] != NUL) + if (arg[0] != '\0') return arg; break; case CMD_isearch: @@ -2982,7 +2982,7 @@ set_one_cmd_context ( arg = skipwhite(skipdigits(arg)); /* skip count */ if (*arg == '/') { /* Match regexp, not just whole words */ for (++arg; *arg && *arg != '/'; arg++) - if (*arg == '\\' && arg[1] != NUL) + if (*arg == '\\' && arg[1] != '\0') arg++; if (*arg) { arg = skipwhite(arg + 1); @@ -3020,7 +3020,7 @@ set_one_cmd_context ( case CMD_tjump: case CMD_stjump: case CMD_ptjump: - if (*p_wop != NUL) + if (*p_wop != '\0') xp->xp_context = EXPAND_TAGS_LISTFILES; else xp->xp_context = EXPAND_TAGS; @@ -3105,7 +3105,7 @@ set_one_cmd_context ( if (*p == ' ') /* argument starts after a space */ arg = p + 1; - else if (*p == '\\' && *(p + 1) != NUL) + else if (*p == '\\' && *(p + 1) != '\0') ++p; /* skip over escaped character */ mb_ptr_adv(p); } @@ -3180,7 +3180,7 @@ set_one_cmd_context ( #ifdef HAVE_WORKING_LIBINTL case CMD_language: p = skiptowhite(arg); - if (*p == NUL) { + if (*p == '\0') { xp->xp_context = EXPAND_LANGUAGE; xp->xp_pattern = arg; } else { @@ -3237,17 +3237,17 @@ skip_range ( while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;", *cmd) != NULL) { if (*cmd == '\'') { - if (*++cmd == NUL && ctx != NULL) + if (*++cmd == '\0' && ctx != NULL) *ctx = EXPAND_NOTHING; } else if (*cmd == '/' || *cmd == '?') { delim = *cmd++; - while (*cmd != NUL && *cmd != delim) - if (*cmd++ == '\\' && *cmd != NUL) + while (*cmd != '\0' && *cmd != delim) + if (*cmd++ == '\\' && *cmd != '\0') ++cmd; - if (*cmd == NUL && ctx != NULL) + if (*cmd == '\0' && ctx != NULL) *ctx = EXPAND_NOTHING; } - if (*cmd != NUL) + if (*cmd != '\0') ++cmd; } @@ -3296,7 +3296,7 @@ get_address ( break; case '\'': /* ''' - mark */ - if (*++cmd == NUL) { + if (*++cmd == '\0') { cmd = NULL; goto error; } @@ -3305,7 +3305,7 @@ get_address ( else { /* Only accept a mark in another file when it is * used by itself: ":'M". */ - fp = getmark(*cmd, to_other_file && cmd[1] == NUL); + fp = getmark(*cmd, to_other_file && cmd[1] == '\0'); ++cmd; if (fp == (pos_T *)-1) /* Jumped to another file. */ @@ -3516,7 +3516,7 @@ static char_u *skip_grep_pat(exarg_T *eap) { char_u *p = eap->arg; - if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep + if (*p != '\0' && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep || eap->cmdidx == CMD_vimgrepadd || eap->cmdidx == CMD_lvimgrepadd || grep_internal(eap->cmdidx))) { @@ -3550,12 +3550,12 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) && !grep_internal(eap->cmdidx)) { if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) { - if (*curbuf->b_p_gp == NUL) + if (*curbuf->b_p_gp == '\0') program = p_gp; else program = curbuf->b_p_gp; } else { - if (*curbuf->b_p_mp == NUL) + if (*curbuf->b_p_mp == '\0') program = p_mp; else program = curbuf->b_p_mp; @@ -3621,7 +3621,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp) * (it will be expanded anyway if there is a wildcard before replacing). */ has_wildcards = mch_has_wildcard(p); - while (*p != NUL) { + while (*p != '\0') { /* Skip over `=expr`, wildcards in it are not expanded. */ if (p[0] == '`' && p[1] == '=') { p += 2; @@ -3876,7 +3876,7 @@ void separate_nextcmd(exarg_T *eap) else /* remove CTRL-V and skip next char */ STRMOVE(p, p + 1); - if (*p == NUL) /* stop at NUL after CTRL-V */ + if (*p == '\0') /* stop at NUL after CTRL-V */ break; } /* Skip over `=expr` when wildcards are expanded. */ @@ -3903,7 +3903,7 @@ void separate_nextcmd(exarg_T *eap) --p; } else { eap->nextcmd = check_nextcmd(p); - *p = NUL; + *p = '\0'; break; } } @@ -3928,8 +3928,8 @@ static char_u *getargcmd(char_u **argp) else { command = arg; arg = skip_cmd_arg(command, TRUE); - if (*arg != NUL) - *arg++ = NUL; /* terminate command with NUL */ + if (*arg != '\0') + *arg++ = '\0'; /* terminate command with NUL */ } arg = skipwhite(arg); /* skip over spaces */ @@ -3948,7 +3948,7 @@ skip_cmd_arg ( ) { while (*p && !vim_isspace(*p)) { - if (*p == '\\' && p[1] != NUL) { + if (*p == '\\' && p[1] != '\0') { if (rembs) STRMOVE(p, p + 1); else @@ -4014,14 +4014,14 @@ static int getargopt(exarg_T *eap) *pp = (int)(arg - eap->cmd); arg = skip_cmd_arg(arg, FALSE); eap->arg = skipwhite(arg); - *arg = NUL; + *arg = '\0'; if (pp == &eap->force_ff) { if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) return FAIL; } else if (pp == &eap->force_enc) { /* Make 'fileencoding' lower case. */ - for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) + for (p = eap->cmd + eap->force_enc; *p != '\0'; ++p) *p = TOLOWER_ASC(*p); } else { /* Check ++bad= argument. Must be a single-byte character, "keep" or @@ -4031,7 +4031,7 @@ static int getargopt(exarg_T *eap) eap->bad_char = BAD_KEEP; else if (STRICMP(p, "drop") == 0) eap->bad_char = BAD_DROP; - else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL) + else if (MB_BYTE2LEN(*p) == 1 && p[1] == '\0') eap->bad_char = *p; else return FAIL; @@ -4198,7 +4198,7 @@ static void ex_blast(exarg_T *eap) int ends_excmd(int c) { - return c == NUL || c == '|' || c == '"' || c == '\n'; + return c == '\0' || c == '|' || c == '"' || c == '\n'; } #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \ @@ -4210,7 +4210,7 @@ int ends_excmd(int c) char_u *find_nextcmd(char_u *p) { while (*p != '|' && *p != '\n') { - if (*p == NUL) + if (*p == '\0') return NULL; ++p; } @@ -4813,7 +4813,7 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp) p += 1; } else if (vim_iswhite(*p)) { p = skipwhite(p); - if (*p == NUL) + if (*p == '\0') break; len += 3; /* "," */ } else { @@ -4845,7 +4845,7 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp) *q++ = *p++; } else if (vim_iswhite(*p)) { p = skipwhite(p); - if (*p == NUL) + if (*p == '\0') break; *q++ = '"'; *q++ = ','; @@ -4915,7 +4915,7 @@ uc_check_code ( switch (type) { case ct_ARGS: /* Simple case first */ - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { if (quote == 1) { result = 2; if (buf != NULL) @@ -5086,7 +5086,7 @@ static void do_ucmd(exarg_T *eap) if (start != NULL) end = vim_strchr(start + 1, '>'); if (buf != NULL) { - for (ksp = p; *ksp != NUL && *ksp != K_SPECIAL; ++ksp) + for (ksp = p; *ksp != '\0' && *ksp != K_SPECIAL; ++ksp) ; if (*ksp == K_SPECIAL && (start == NULL || ksp < start || end == NULL) @@ -5272,7 +5272,7 @@ int parse_compl_arg(char_u *value, int vallen, int *complp, long *argt, char_u * static void ex_colorscheme(exarg_T *eap) { - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { char_u *expr = vim_strsave((char_u *)"g:colors_name"); char_u *p = NULL; @@ -5293,7 +5293,7 @@ static void ex_colorscheme(exarg_T *eap) static void ex_highlight(exarg_T *eap) { - if (*eap->arg == NUL && eap->cmd[2] == '!') + if (*eap->arg == '\0' && eap->cmd[2] == '!') MSG(_("Greetings, Vim user!")); do_highlight(eap->arg, eap->forceit, FALSE); } @@ -5576,7 +5576,7 @@ void ex_all(exarg_T *eap) static void ex_hide(exarg_T *eap) { - if (*eap->arg != NUL && check_nextcmd(eap->arg) == NULL) + if (*eap->arg != '\0' && check_nextcmd(eap->arg) == NULL) eap->errmsg = e_invarg; else { /* ":hide" or ":hide | cmd": hide current window */ @@ -5954,7 +5954,7 @@ static void ex_recover(exarg_T *eap) | (eap->forceit ? CCGD_FORCEIT : 0) | CCGD_EXCMD) - && (*eap->arg == NUL + && (*eap->arg == '\0' || setfname(curbuf, eap->arg, NULL, TRUE) == OK)) ml_recover(); recoverymode = FALSE; @@ -6027,7 +6027,7 @@ void ex_splitview(exarg_T *eap) *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL) { /* Reset 'scrollbind' when editing another file, but keep it when * doing ":split" without arguments. */ - if (*eap->arg != NUL + if (*eap->arg != '\0' ) { RESET_BINDING(curwin); } else @@ -6084,7 +6084,7 @@ static void ex_tabmove(exarg_T *eap) { int tab_number = 9999; - if (eap->arg && *eap->arg != NUL) { + if (eap->arg && *eap->arg != '\0') { char_u *p = eap->arg; int relative = 0; /* argument +N/-N means: move N places to the * right/left relative to the current position. */ @@ -6160,7 +6160,7 @@ static void ex_tabs(exarg_T *eap) */ static void ex_mode(exarg_T *eap) { - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { shell_resized(); } else { EMSG(_(e_screenmode)); @@ -6186,13 +6186,13 @@ static void ex_resize(exarg_T *eap) if (cmdmod.split & WSP_VERT) { if (*eap->arg == '-' || *eap->arg == '+') n += W_WIDTH(curwin); - else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */ + else if (n == 0 && eap->arg[0] == '\0') /* default is very wide */ n = 9999; win_setwidth_win((int)n, wp); } else { if (*eap->arg == '-' || *eap->arg == '+') n += curwin->w_height; - else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */ + else if (n == 0 && eap->arg[0] == '\0') /* default is very wide */ n = 9999; win_setheight_win((int)n, wp); } @@ -6240,7 +6240,7 @@ static void ex_open(exarg_T *eap) /* ":open /pattern/": put cursor in column found with pattern */ ++eap->arg; p = skip_regexp(eap->arg, '/', p_magic, NULL); - *p = NUL; + *p = '\0'; regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); if (regmatch.regprog != NULL) { regmatch.rm_ic = p_ic; @@ -6287,7 +6287,7 @@ do_exedit ( if (exmode_active && (eap->cmdidx == CMD_visual || eap->cmdidx == CMD_view)) { exmode_active = FALSE; - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { /* Special case: ":global/pat/visual\NLvi-commands" */ if (global_busy) { int rd = RedrawingDisabled; @@ -6321,7 +6321,7 @@ do_exedit ( || eap->cmdidx == CMD_tabnew || eap->cmdidx == CMD_tabedit || eap->cmdidx == CMD_vnew - ) && *eap->arg == NUL) { + ) && *eap->arg == '\0') { /* ":new" or ":tabnew" without argument: edit an new empty buffer */ setpcmark(); (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, @@ -6330,11 +6330,11 @@ do_exedit ( } else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit ) - || *eap->arg != NUL + || *eap->arg != '\0' ) { /* Can't edit another file when "curbuf_lock" is set. Only ":edit" * can bring us here, others are stopped earlier. */ - if (*eap->arg != NUL && curbuf_locked()) + if (*eap->arg != '\0' && curbuf_locked()) return; n = readonlymode; if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) @@ -6346,7 +6346,7 @@ do_exedit ( if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), NULL, eap, /* ":edit" goes to first line if Vi compatible */ - (*eap->arg == NUL && eap->do_ecmd_lnum == 0 + (*eap->arg == '\0' && eap->do_ecmd_lnum == 0 && vim_strchr(p_cpo, CPO_GOTO1) != NULL) ? ECMD_ONE : eap->do_ecmd_lnum, (P_HID(curbuf) ? ECMD_HIDE : 0) @@ -6394,7 +6394,7 @@ do_exedit ( * file */ if (old_curwin != NULL - && *eap->arg != NUL + && *eap->arg != '\0' && curwin != old_curwin && win_valid(old_curwin) && old_curwin->w_buffer != curbuf @@ -6502,7 +6502,7 @@ static void ex_read(exarg_T *eap) if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) return; - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { if (check_fname() == FAIL) /* check for no file name */ return; i = readfile(curbuf->b_ffname, curbuf->b_fname, @@ -6525,7 +6525,7 @@ static void ex_read(exarg_T *eap) lnum = curbuf->b_ml.ml_line_count; else lnum = 1; - if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) { + if (*ml_get(lnum) == '\0' && u_savedel(lnum, 1L) == OK) { ml_delete(lnum, FALSE); if (curwin->w_cursor.lnum > 1 && curwin->w_cursor.lnum >= lnum) @@ -6590,7 +6590,7 @@ void ex_cd(exarg_T *eap) new_dir = eap->arg; #if !defined(UNIX) /* for non-UNIX ":cd" means: print current directory */ - if (*new_dir == NUL) + if (*new_dir == '\0') ex_pwd(NULL); else #endif @@ -6622,7 +6622,7 @@ void ex_cd(exarg_T *eap) #if defined(UNIX) /* for UNIX ":cd" means: go to home directory */ - if (*new_dir == NUL) { + if (*new_dir == '\0') { /* use NameBuff for home directory name */ expand_env((char_u *)"$HOME", NameBuff, MAXPATHL); new_dir = NameBuff; @@ -6678,7 +6678,7 @@ static void ex_sleep(exarg_T *eap) len = eap->line2; switch (*eap->arg) { case 'm': break; - case NUL: len *= 1000L; break; + case '\0': len *= 1000L; break; default: EMSG2(_(e_invarg2), eap->arg); return; } do_sleep(len); @@ -6729,7 +6729,7 @@ static void ex_winsize(exarg_T *eap) arg = skipwhite(arg); p = arg; h = getdigits(&arg); - if (*p != NUL && *arg == NUL) + if (*p != '\0' && *arg == '\0') set_shellsize(w, h, TRUE); else EMSG(_("E465: :winsize requires two number arguments")); @@ -6737,12 +6737,12 @@ static void ex_winsize(exarg_T *eap) static void ex_wincmd(exarg_T *eap) { - int xchar = NUL; + int xchar = '\0'; char_u *p; if (*eap->arg == 'g' || *eap->arg == Ctrl_G) { /* CTRL-W g and CTRL-W CTRL-G have an extra command character */ - if (eap->arg[1] == NUL) { + if (eap->arg[1] == '\0') { EMSG(_(e_invarg)); return; } @@ -6753,7 +6753,7 @@ static void ex_wincmd(exarg_T *eap) eap->nextcmd = check_nextcmd(p); p = skipwhite(p); - if (*p != NUL && *p != '"' && eap->nextcmd == NULL) + if (*p != '\0' && *p != '"' && eap->nextcmd == NULL) EMSG(_(e_invarg)); else if (!eap->skip) { /* Pass flags on for ":vertical wincmd ]". */ @@ -6776,14 +6776,14 @@ exarg_T *eap; char_u *arg = eap->arg; char_u *p; - if (*arg == NUL) { + if (*arg == '\0') { EMSG(_("E188: Obtaining window position not implemented for this platform")); } else { x = getdigits(&arg); arg = skipwhite(arg); p = arg; y = getdigits(&arg); - if (*p == NUL || *arg != NUL) { + if (*p == '\0' || *arg != '\0') { EMSG(_("E466: :winpos requires two number arguments")); return; } @@ -6950,7 +6950,7 @@ static void ex_at(exarg_T *eap) /* get the register name. No name means to use the previous one */ c = *eap->arg; - if (c == NUL || (c == '*' && *eap->cmd == '*')) + if (c == '\0' || (c == '*' && *eap->cmd == '*')) c = '@'; /* Put the register in the typeahead buffer with the "silent" flag. */ if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) @@ -7026,7 +7026,7 @@ static void ex_later(exarg_T *eap) int file = FALSE; char_u *p = eap->arg; - if (*p == NUL) + if (*p == '\0') count = 1; else if (isdigit(*p)) { count = getdigits(&p); @@ -7039,7 +7039,7 @@ static void ex_later(exarg_T *eap) } } - if (*p != NUL) + if (*p != '\0') EMSG2(_(e_invarg2), eap->arg); else undo_time(eap->cmdidx == CMD_earlier ? -count : count, @@ -7091,11 +7091,11 @@ static void ex_redir(exarg_T *eap) arg++; /* Make register empty when not using @A-@Z and the * command is valid. */ - if (*arg == NUL && !isupper(redir_reg)) + if (*arg == '\0' && !isupper(redir_reg)) write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); } } - if (*arg != NUL) { + if (*arg != '\0') { redir_reg = 0; EMSG2(_(e_invarg2), eap->arg); } @@ -7220,15 +7220,15 @@ static void ex_mkrc(exarg_T *eap) /* ":mkview" or ":mkview 9": generate file name with 'viewdir' */ if (eap->cmdidx == CMD_mkview - && (*eap->arg == NUL - || (vim_isdigit(*eap->arg) && eap->arg[1] == NUL))) { + && (*eap->arg == '\0' + || (vim_isdigit(*eap->arg) && eap->arg[1] == '\0'))) { eap->forceit = TRUE; fname = get_view_file(*eap->arg); if (fname == NULL) return; viewFile = fname; using_vdir = TRUE; - } else if (*eap->arg != NUL) + } else if (*eap->arg != '\0') fname = eap->arg; else if (eap->cmdidx == CMD_mkvimrc) fname = (char_u *)VIMRC_FILE; @@ -7296,11 +7296,11 @@ static void ex_mkrc(exarg_T *eap) */ if (os_dirname(dirnow, MAXPATHL) == FAIL || os_chdir((char *)dirnow) != 0) - *dirnow = NUL; - if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) { + *dirnow = '\0'; + if (*dirnow != '\0' && (ssop_flags & SSOP_SESDIR)) { if (vim_chdirfile(fname) == OK) shorten_fnames(TRUE); - } else if (*dirnow != NUL + } else if (*dirnow != '\0' && (ssop_flags & SSOP_CURDIR) && globaldir != NULL) { if (os_chdir((char *)globaldir) == 0) shorten_fnames(TRUE); @@ -7309,7 +7309,7 @@ static void ex_mkrc(exarg_T *eap) failed |= (makeopens(fd, dirnow) == FAIL); /* restore original dir */ - if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR) + if (*dirnow != '\0' && ((ssop_flags & SSOP_SESDIR) || ((ssop_flags & SSOP_CURDIR) && globaldir != NULL))) { if (os_chdir((char *)dirnow) != 0) @@ -7405,9 +7405,9 @@ static void ex_mark(exarg_T *eap) { pos_T pos; - if (*eap->arg == NUL) /* No argument? */ + if (*eap->arg == '\0') /* No argument? */ EMSG(_(e_argreq)); - else if (eap->arg[1] != NUL) /* more than one character? */ + else if (eap->arg[1] != '\0') /* more than one character? */ EMSG(_(e_trailing)); else { pos = curwin->w_cursor; /* save curwin->w_cursor */ @@ -7471,7 +7471,7 @@ static void ex_normal(exarg_T *eap) int len = 0; /* Count the number of characters to be escaped. */ - for (p = eap->arg; *p != NUL; ++p) { + for (p = eap->arg; *p != '\0'; ++p) { for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) if (*++p == K_SPECIAL /* trailbyte K_SPECIAL or CSI */ ) @@ -7481,7 +7481,7 @@ static void ex_normal(exarg_T *eap) arg = alloc((unsigned)(STRLEN(eap->arg) + len + 1)); if (arg != NULL) { len = 0; - for (p = eap->arg; *p != NUL; ++p) { + for (p = eap->arg; *p != '\0'; ++p) { arg[len++] = *p; for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) { arg[len++] = *++p; @@ -7490,7 +7490,7 @@ static void ex_normal(exarg_T *eap) arg[len++] = KE_FILLER; } } - arg[len] = NUL; + arg[len] = '\0'; } } } @@ -7653,7 +7653,7 @@ static void ex_findpat(exarg_T *eap) ++eap->arg; p = skip_regexp(eap->arg, '/', p_magic, NULL); if (*p) { - *p++ = NUL; + *p++ = '\0'; p = skipwhite(p); /* Check for trailing illegal characters */ @@ -7745,7 +7745,7 @@ static void ex_tag_cmd(exarg_T *eap, char_u *name) case 'l': cmd = DT_LAST; /* ":tlast" */ break; default: /* ":tag" */ - if (p_cst && *eap->arg != NUL) { + if (p_cst && *eap->arg != '\0') { do_cstag(eap); return; } @@ -8063,7 +8063,7 @@ static char_u *arg_all(void) retval[len] = ' '; ++len; } - for (; *p != NUL; ++p) { + for (; *p != '\0'; ++p) { if (*p == ' ' || *p == '\\') { /* insert a backslash */ if (retval != NULL) @@ -8079,7 +8079,7 @@ static char_u *arg_all(void) /* second time: break here */ if (retval != NULL) { - retval[len] = NUL; + retval[len] = '\0'; break; } @@ -8678,7 +8678,7 @@ put_view ( */ if ((*flagp & SSOP_FOLDS) && wp->w_buffer->b_ffname != NULL - && (*wp->w_buffer->b_p_bt == NUL || wp->w_buffer->b_help) + && (*wp->w_buffer->b_p_bt == '\0' || wp->w_buffer->b_help) ) { if (put_folds(fd, wp) == FAIL) return FAIL; @@ -8839,7 +8839,7 @@ static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp) if (*flagp & SSOP_SLASH) { /* change all backslashes to forward slashes */ - for (p = sname; *p != NUL; mb_ptr_adv(p)) + for (p = sname; *p != '\0'; mb_ptr_adv(p)) if (*p == '\\') *p = '/'; } @@ -8968,7 +8968,7 @@ static void ex_viminfo(exarg_T *eap) char_u *save_viminfo; save_viminfo = p_viminfo; - if (*p_viminfo == NUL) + if (*p_viminfo == '\0') p_viminfo = (char_u *)"'100"; if (eap->cmdidx == CMD_rviminfo) { if (read_viminfo(eap->arg, VIF_WANT_INFO | VIF_WANT_MARKS @@ -9042,7 +9042,7 @@ static void ex_filetype(exarg_T *eap) int plugin = FALSE; int indent = FALSE; - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { /* Print current status. */ smsg((char_u *)"filetype detection:%s plugin:%s indent:%s", filetype_detect ? "ON" : "OFF", @@ -9111,7 +9111,7 @@ static void ex_setfiletype(exarg_T *eap) static void ex_digraphs(exarg_T *eap) { - if (*eap->arg != NUL) + if (*eap->arg != '\0') putdigraph(eap->arg); else listdigraphs(); @@ -9171,14 +9171,14 @@ static void ex_match(exarg_T *eap) if (!eap->skip) g = vim_strnsave(eap->arg, (int)(p - eap->arg)); p = skipwhite(p); - if (*p == NUL) { + if (*p == '\0') { /* There must be two arguments. */ EMSG2(_(e_invarg2), eap->arg); return; } end = skip_regexp(p + 1, *p, TRUE, NULL); if (!eap->skip) { - if (*end != NUL && !ends_excmd(*skipwhite(end + 1))) { + if (*end != '\0' && !ends_excmd(*skipwhite(end + 1))) { eap->errmsg = e_trailing; return; } @@ -9188,7 +9188,7 @@ static void ex_match(exarg_T *eap) } c = *end; - *end = NUL; + *end = '\0'; match_add(curwin, g, p + 1, 10, id); vim_free(g); *end = c; diff --git a/src/ex_eval.c b/src/ex_eval.c index 14226438e6..0cecdc505c 100644 --- a/src/ex_eval.c +++ b/src/ex_eval.c @@ -397,7 +397,7 @@ char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should if (type == ET_ERROR) { *should_free = FALSE; mesg = ((struct msglist *)value)->throw_msg; - if (cmdname != NULL && *cmdname != NUL) { + if (cmdname != NULL && *cmdname != '\0') { cmdlen = (int)STRLEN(cmdname); ret = vim_strnsave((char_u *)"Vim(", 4 + cmdlen + 2 + (int)STRLEN(mesg)); @@ -417,7 +417,7 @@ char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should * name in quotes. In the exception value, put the file name in * parentheses and move it to the end. */ for (p = mesg;; p++) { - if (*p == NUL + if (*p == '\0' || (*p == 'E' && VIM_ISDIGIT(p[1]) && (p[2] == ':' @@ -425,7 +425,7 @@ char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should && (p[3] == ':' || (VIM_ISDIGIT(p[3]) && p[4] == ':')))))) { - if (*p == NUL || p == mesg) + if (*p == '\0' || p == mesg) STRCAT(val, mesg); /* 'E123' missing or at beginning */ else { /* '"filename" E123: message text' */ @@ -435,7 +435,7 @@ char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should continue; STRCAT(val, p); - p[-2] = NUL; + p[-2] = '\0'; sprintf((char *)(val + STRLEN(p)), " (%s)", &mesg[1]); p[-2] = '"'; } @@ -469,7 +469,7 @@ static int throw_exception(void *value, int type, char_u *cmdname) */ if (type == ET_USER) { if (STRNCMP((char_u *)value, "Vim", 3) == 0 - && (((char_u *)value)[3] == NUL || ((char_u *)value)[3] == ':' + && (((char_u *)value)[3] == '\0' || ((char_u *)value)[3] == ':' || ((char_u *)value)[3] == '(')) { EMSG(_("E608: Cannot :throw exceptions with 'Vim' prefix")); goto fail; @@ -507,13 +507,13 @@ static int throw_exception(void *value, int type, char_u *cmdname) else verbose_enter(); ++no_wait_return; - if (debug_break_level > 0 || *p_vfile == NUL) + if (debug_break_level > 0 || *p_vfile == '\0') msg_scroll = TRUE; /* always scroll up, don't overwrite */ smsg((char_u *)_("Exception thrown: %s"), excp->value); msg_puts((char_u *)"\n"); /* don't overwrite this either */ - if (debug_break_level > 0 || *p_vfile == NUL) + if (debug_break_level > 0 || *p_vfile == '\0') cmdline_row = msg_row; --no_wait_return; if (debug_break_level > 0) @@ -556,14 +556,14 @@ static void discard_exception(except_T *excp, int was_finished) else verbose_enter(); ++no_wait_return; - if (debug_break_level > 0 || *p_vfile == NUL) + if (debug_break_level > 0 || *p_vfile == '\0') msg_scroll = TRUE; /* always scroll up, don't overwrite */ smsg(was_finished ? (char_u *)_("Exception finished: %s") : (char_u *)_("Exception discarded: %s"), excp->value); msg_puts((char_u *)"\n"); /* don't overwrite this either */ - if (debug_break_level > 0 || *p_vfile == NUL) + if (debug_break_level > 0 || *p_vfile == '\0') cmdline_row = msg_row; --no_wait_return; if (debug_break_level > 0) @@ -600,7 +600,7 @@ static void catch_exception(except_T *excp) excp->caught = caught_stack; caught_stack = excp; set_vim_var_string(VV_EXCEPTION, excp->value, -1); - if (*excp->throw_name != NUL) { + if (*excp->throw_name != '\0') { if (excp->throw_lnum != 0) vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %" PRId64), excp->throw_name, (int64_t)excp->throw_lnum); @@ -619,13 +619,13 @@ static void catch_exception(except_T *excp) else verbose_enter(); ++no_wait_return; - if (debug_break_level > 0 || *p_vfile == NUL) + if (debug_break_level > 0 || *p_vfile == '\0') msg_scroll = TRUE; /* always scroll up, don't overwrite */ smsg((char_u *)_("Exception caught: %s"), excp->value); msg_puts((char_u *)"\n"); /* don't overwrite this either */ - if (debug_break_level > 0 || *p_vfile == NUL) + if (debug_break_level > 0 || *p_vfile == '\0') cmdline_row = msg_row; --no_wait_return; if (debug_break_level > 0) @@ -645,7 +645,7 @@ static void finish_exception(except_T *excp) caught_stack = caught_stack->caught; if (caught_stack != NULL) { set_vim_var_string(VV_EXCEPTION, caught_stack->value, -1); - if (*caught_stack->throw_name != NUL) { + if (*caught_stack->throw_name != '\0') { if (caught_stack->throw_lnum != 0) vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %" PRId64), caught_stack->throw_name, @@ -1173,7 +1173,7 @@ void ex_throw(exarg_T *eap) char_u *arg = eap->arg; char_u *value; - if (*arg != NUL && *arg != '|' && *arg != '\n') + if (*arg != '\0' && *arg != '|' && *arg != '\n') value = eval_to_string_skip(arg, &eap->nextcmd, eap->skip); else { EMSG(_(e_argreq)); @@ -1384,7 +1384,7 @@ void ex_catch(exarg_T *eap) */ if (!skip && (cstack->cs_flags[idx] & CSF_THROWN) && !(cstack->cs_flags[idx] & CSF_CAUGHT)) { - if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) { + if (end != NULL && *end != '\0' && !ends_excmd(*skipwhite(end + 1))) { EMSG(_(e_trailing)); return; } @@ -1401,7 +1401,7 @@ void ex_catch(exarg_T *eap) * while compiling it. */ if (end != NULL) { save_char = *end; - *end = NUL; + *end = '\0'; } save_cpo = p_cpo; p_cpo = (char_u *)""; diff --git a/src/ex_getln.c b/src/ex_getln.c index f07b8c1ce0..d64aa18414 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -208,7 +208,7 @@ getcmdline ( struct cmdline_info save_ccline; if (firstc == -1) { - firstc = NUL; + firstc = '\0'; break_ctrl_c = TRUE; } /* start without Hebrew mapping for a command line */ @@ -234,12 +234,12 @@ getcmdline ( if (ccline.cmdbuff == NULL) return NULL; /* out of memory */ ccline.cmdlen = ccline.cmdpos = 0; - ccline.cmdbuff[0] = NUL; + ccline.cmdbuff[0] = '\0'; /* autoindent for :insert and :append */ if (firstc <= 0) { copy_spaces(ccline.cmdbuff, indent); - ccline.cmdbuff[indent] = NUL; + ccline.cmdbuff[indent] = '\0'; ccline.cmdpos = indent; ccline.cmdspos = indent; ccline.cmdlen = indent; @@ -492,7 +492,7 @@ getcmdline ( upseg[1] = '.'; upseg[2] = '.'; upseg[3] = PATHSEP; - upseg[4] = NUL; + upseg[4] = '\0'; if (c == K_DOWN && ccline.cmdpos > 0 @@ -779,7 +779,7 @@ getcmdline ( goto cmdline_changed; } - if (c == NUL || c == K_ZERO) /* NUL is stored as NL */ + if (c == '\0' || c == K_ZERO) /* NUL is stored as NL */ c = NL; do_abbr = TRUE; /* default: check for abbreviation */ @@ -844,7 +844,7 @@ getcmdline ( ccline.cmdbuff[i++] = ccline.cmdbuff[j++]; /* Truncate at the end, required for multi-byte chars. */ - ccline.cmdbuff[ccline.cmdlen] = NUL; + ccline.cmdbuff[ccline.cmdlen] = '\0'; redrawcmd(); } else if (ccline.cmdlen == 0 && c != Ctrl_W && ccline.cmdprompt == NULL && indent == 0) { @@ -931,7 +931,7 @@ getcmdline ( while (i < ccline.cmdlen) ccline.cmdbuff[i++] = ccline.cmdbuff[j++]; /* Truncate at the end, required for multi-byte chars. */ - ccline.cmdbuff[ccline.cmdlen] = NUL; + ccline.cmdbuff[ccline.cmdlen] = '\0'; redrawcmd(); goto cmdline_changed; @@ -1152,7 +1152,7 @@ getcmdline ( * the character to lowercase */ if (p_ic && p_scs && !pat_has_uppercase(ccline.cmdbuff)) c = vim_tolower(c); - if (c != NUL) { + if (c != '\0') { if (c == firstc || vim_strchr((char_u *)( p_magic ? "\\^$.*[" : "\\^$"), c) != NULL) { @@ -1188,7 +1188,7 @@ getcmdline ( case K_KPAGEUP: case K_PAGEDOWN: case K_KPAGEDOWN: - if (hislen == 0 || firstc == NUL) /* no history */ + if (hislen == 0 || firstc == '\0') /* no history */ goto cmdline_not_changed; i = hiscnt; @@ -1197,7 +1197,7 @@ getcmdline ( if (lookfor == NULL) { if ((lookfor = vim_strsave(ccline.cmdbuff)) == NULL) goto cmdline_not_changed; - lookfor[ccline.cmdpos] = NUL; + lookfor[ccline.cmdpos] = '\0'; } j = (int)STRLEN(lookfor); @@ -1262,7 +1262,7 @@ getcmdline ( * Second loop: copy the characters. */ for (i = 0; i <= 1; ++i) { len = 0; - for (j = 0; p[j] != NUL; ++j) { + for (j = 0; p[j] != '\0'; ++j) { /* Replace old sep with new sep, unless it is * escaped. */ if (p[j] == old_firstc @@ -1289,7 +1289,7 @@ getcmdline ( goto returncmd; } } - ccline.cmdbuff[len] = NUL; + ccline.cmdbuff[len] = '\0'; } else { alloc_cmdbuff((int)STRLEN(p)); if (ccline.cmdbuff == NULL) @@ -1325,7 +1325,7 @@ getcmdline ( dont_scroll = TRUE; /* disallow scrolling here */ #endif c = get_digraph(TRUE); - if (c != NUL) + if (c != '\0') break; redrawcmd(); @@ -1383,7 +1383,7 @@ getcmdline ( else { if (has_mbyte) { j = (*mb_char2bytes)(c, IObuff); - IObuff[j] = NUL; /* exclude composing chars */ + IObuff[j] = '\0'; /* exclude composing chars */ put_on_cmdline(IObuff, j, TRUE); } else { IObuff[0] = c; @@ -1501,7 +1501,7 @@ cmdline_changed: * right-left typing. Not efficient, but it works. * Do it only when there are no characters left to read * to avoid useless intermediate redraws. */ - if (vpeekc() == NUL) + if (vpeekc() == '\0') redrawcmd(); } @@ -1530,10 +1530,10 @@ returncmd: /* * Put line in history buffer (":" and "=" only when it was typed). */ - if (ccline.cmdlen && firstc != NUL + if (ccline.cmdlen && firstc != '\0' && (some_key_typed || histype == HIST_SEARCH)) { add_to_history(histype, ccline.cmdbuff, TRUE, - histype == HIST_SEARCH ? firstc : NUL); + histype == HIST_SEARCH ? firstc : '\0'); if (firstc == ':') { vim_free(new_last_cmdline); new_last_cmdline = vim_strsave(ccline.cmdbuff); @@ -1679,7 +1679,7 @@ static int cmdline_charsize(int idx) */ static void set_cmdspos(void) { - if (ccline.cmdfirstc != NUL) + if (ccline.cmdfirstc != '\0') ccline.cmdspos = 1 + ccline.cmdindent; else ccline.cmdspos = 0 + ccline.cmdindent; @@ -1848,7 +1848,7 @@ getexmodeline ( long sw = get_sw_value(curbuf); p = (char_u *)line_ga.ga_data; - p[line_ga.ga_len] = NUL; + p[line_ga.ga_len] = '\0'; indent = get_indent_str(p, 8); indent += sw - indent % sw; add_indent: @@ -1887,9 +1887,9 @@ redraw: if (prev_char == '^') ex_keep_indent = TRUE; indent = 0; - p[--line_ga.ga_len] = NUL; + p[--line_ga.ga_len] = '\0'; } else { - p[line_ga.ga_len] = NUL; + p[line_ga.ga_len] = '\0'; indent = get_indent_str(p, 8); --indent; indent -= indent % get_sw_value(curbuf); @@ -1956,7 +1956,7 @@ redraw: if ((bcount & 1) == 0) { --line_ga.ga_len; --pend; - *pend = NUL; + *pend = '\0'; break; } } @@ -2033,7 +2033,7 @@ static int realloc_cmdbuff(int len) /* There isn't always a NUL after the command, but it may need to be * there, thus copy up to the NUL and add a NUL. */ memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen); - ccline.cmdbuff[ccline.cmdlen] = NUL; + ccline.cmdbuff[ccline.cmdlen] = '\0'; vim_free(p); if (ccline.xpc != NULL @@ -2120,13 +2120,13 @@ static void draw_cmdline(int start, int len) pc1 = prev_c1; prev_c1 = u8cc[0]; if (j + mb_l >= start + len) - nc = NUL; + nc = '\0'; else nc = utf_ptr2char(p + mb_l); } else { /* displaying from left to right */ if (j + mb_l >= start + len) - pc = NUL; + pc = '\0'; else { int pcc[MAX_MCO]; @@ -2245,7 +2245,7 @@ int put_on_cmdline(char_u *str, int len, int redraw) ccline.cmdlen = ccline.cmdpos + len; } memmove(ccline.cmdbuff + ccline.cmdpos, str, (size_t)len); - ccline.cmdbuff[ccline.cmdlen] = NUL; + ccline.cmdbuff[ccline.cmdlen] = '\0'; if (enc_utf8) { /* When the inserted text starts with a composing character, @@ -2480,7 +2480,7 @@ void cmdline_paste_str(char_u *s, int literally) if (literally) put_on_cmdline(s, -1, TRUE); else - while (*s != NUL) { + while (*s != '\0') { cv = *s; if (cv == Ctrl_V && s[1]) ++s; @@ -2531,13 +2531,13 @@ static void redrawcmdprompt(void) if (cmd_silent) return; - if (ccline.cmdfirstc != NUL) + if (ccline.cmdfirstc != '\0') msg_putchar(ccline.cmdfirstc); if (ccline.cmdprompt != NULL) { msg_puts_attr(ccline.cmdprompt, ccline.cmdattr); ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; /* do the reverse of set_cmdspos() */ - if (ccline.cmdfirstc != NUL) + if (ccline.cmdfirstc != '\0') --ccline.cmdindent; } else for (i = ccline.cmdindent; i > 0; --i) @@ -2957,7 +2957,7 @@ ExpandOne ( len += (long_u)STRLEN(xp->xp_files[i]) + 1; ss = lalloc(len, TRUE); if (ss != NULL) { - *ss = NUL; + *ss = '\0'; for (i = 0; i < xp->xp_numfiles; ++i) { STRCAT(ss, xp->xp_files[i]); if (i != xp->xp_numfiles - 1) @@ -3091,10 +3091,10 @@ char_u *vim_strsave_fnameescape(char_u *fname, int shell) int j = 0; /* Don't escape '[', '{' and '!' if they are in 'isfname'. */ - for (p = PATH_ESC_CHARS; *p != NUL; ++p) + for (p = PATH_ESC_CHARS; *p != '\0'; ++p) if ((*p != '[' && *p != '{' && *p != '!') || !vim_isfilec(*p)) buf[j++] = *p; - buf[j] = NUL; + buf[j] = '\0'; p = vim_strsave_escaped(fname, buf); #else p = vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS); @@ -3111,7 +3111,7 @@ char_u *vim_strsave_fnameescape(char_u *fname, int shell) /* '>' and '+' are special at the start of some commands, e.g. ":edit" and * ":write". "cd -" has a special meaning. */ - if (p != NULL && (*p == '>' || *p == '+' || (*p == '-' && p[1] == NUL))) + if (p != NULL && (*p == '>' || *p == '+' || (*p == '-' && p[1] == '\0'))) escape_fname(&p); return p; @@ -3318,7 +3318,7 @@ char_u *sm_gettail(char_u *s) char_u *t = s; int had_sep = FALSE; - for (p = s; *p != NUL; ) { + for (p = s; *p != '\0'; ) { if (vim_ispathsep(*p) #ifdef BACKSLASH_IN_FILENAME && !rem_backslash(p) @@ -3451,7 +3451,7 @@ addstar ( } retval[j] = fname[i]; } - retval[j] = NUL; + retval[j] = '\0'; } } } else { @@ -3483,7 +3483,7 @@ addstar ( retval[len++] = '*'; else if (len > 0 && retval[len - 1] == '$') --len; - retval[len] = NUL; + retval[len] = '\0'; } } return retval; @@ -3553,7 +3553,7 @@ set_cmd_context ( int col /* position of cursor */ ) { - int old_char = NUL; + int old_char = '\0'; char_u *nextcomm; /* @@ -3562,7 +3562,7 @@ set_cmd_context ( */ if (col < len) old_char = str[col]; - str[col] = NUL; + str[col] = '\0'; nextcomm = str; if (ccline.cmdfirstc == '=') { @@ -3656,7 +3656,7 @@ static void cleanup_help_tags(int num_file, char_u **file) && STRNCMP(file[i], file[j], len + 1) == 0) break; if (j == num_file) - file[i][len] = NUL; + file[i][len] = '\0'; } } } @@ -3735,7 +3735,7 @@ ExpandFromContext ( if (xp->xp_context == EXPAND_HELP) { /* With an empty argument we would get all the help tags, which is * very slow. Get matches for "help" instead. */ - if (find_help_tags(*pat == NUL ? (char_u *)"help" : pat, + if (find_help_tags(*pat == '\0' ? (char_u *)"help" : pat, num_file, file, FALSE) == OK) { cleanup_help_tags(*num_file, *file); return OK; @@ -3874,7 +3874,7 @@ int escaped; str = (*func)(xp, i); if (str == NULL) /* end of list */ break; - if (*str == NUL) /* skip empty strings */ + if (*str == '\0') /* skip empty strings */ continue; if (vim_regexec(regmatch, str, (colnr_T)0)) { @@ -3978,7 +3978,7 @@ expand_shellcmd ( * collect them in "ga". */ ga_init(&ga, (int)sizeof(char *), 10); - for (s = path; *s != NUL; s = e) { + for (s = path; *s != '\0'; s = e) { if (*s == ' ') ++s; /* Skip space used for absolute path name. */ @@ -4011,7 +4011,7 @@ expand_shellcmd ( vim_free(*file); } } - if (*e != NUL) + if (*e != '\0') ++e; } *file = ga.ga_data; @@ -4094,7 +4094,7 @@ static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file, return FAIL; ga_init(&ga, (int)sizeof(char *), 3); - for (s = retstr; *s != NUL; s = e) { + for (s = retstr; *s != '\0'; s = e) { e = vim_strchr(s, '\n'); if (e == NULL) e = s + STRLEN(s); @@ -4103,7 +4103,7 @@ static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file, if (xp->xp_pattern[0] && vim_regexec(regmatch, s, (colnr_T)0) == 0) { *e = keep; - if (*e != NUL) + if (*e != '\0') ++e; continue; } @@ -4114,7 +4114,7 @@ static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file, ++ga.ga_len; *e = keep; - if (*e != NUL) + if (*e != '\0') ++e; } vim_free(retstr); @@ -4186,7 +4186,7 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname if (matches == NULL) continue; - for (s = matches; *s != NUL; s = e) { + for (s = matches; *s != '\0'; s = e) { e = vim_strchr(s, '\n'); if (e == NULL) e = s + STRLEN(s); @@ -4200,7 +4200,7 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname vim_strnsave(s, (int)(e - s - 4)); ++ga.ga_len; } - if (*e != NUL) + if (*e != '\0') ++e; } vim_free(matches); @@ -4244,7 +4244,7 @@ char_u *globpath(char_u *path, char_u *file, int expand_options) ga_init(&ga, 1, 100); /* Loop over all entries in {path}. */ - while (*path != NUL) { + while (*path != '\0') { /* Copy one item of the path to buf[] and concatenate the file name. */ copy_option_part(&path, buf, MAXPATHL, ","); if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL) { @@ -4321,7 +4321,7 @@ static char *(history_names[]) = */ static char_u *get_history_arg(expand_T *xp, int idx) { - static char_u compl[2] = { NUL, NUL }; + static char_u compl[2] = { '\0', '\0' }; char *short_names = ":=@>?/"; int short_names_count = (int)STRLEN(short_names); int history_name_count = sizeof(history_names) / sizeof(char *) - 1; @@ -4485,7 +4485,7 @@ int get_histtype(char_u *name) if (STRNICMP(name, history_names[i], len) == 0) return i; - if (vim_strchr((char_u *)":=@>?/", name[0]) != NULL && name[1] == NUL) + if (vim_strchr((char_u *)":=@>?/", name[0]) != NULL && name[1] == '\0') return hist_char2type(name[0]); return -1; @@ -4643,8 +4643,8 @@ int get_cmdline_type(void) struct cmdline_info *p = get_ccline_ptr(); if (p == NULL) - return NUL; - if (p->cmdfirstc == NUL) + return '\0'; + if (p->cmdfirstc == '\0') return (p->input_fn) ? '@' : '-'; return p->cmdfirstc; } @@ -4739,7 +4739,7 @@ int del_history_entry(int histype, char_u *str) if (hislen != 0 && histype >= 0 && histype < HIST_COUNT - && *str != NUL + && *str != '\0' && (idx = hisidx[histype]) >= 0 && (regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING)) != NULL) { @@ -4889,7 +4889,7 @@ void ex_history(exarg_T *eap) || vim_strchr((char_u *)":=@>/?", *end) != NULL) end++; i = *end; - *end = NUL; + *end = '\0'; histype1 = get_histtype(arg); if (histype1 == -1) { if (STRNICMP(arg, "all", STRLEN(arg)) == 0) { @@ -4905,7 +4905,7 @@ void ex_history(exarg_T *eap) *end = i; } else end = arg; - if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) { + if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != '\0') { EMSG(_(e_trailing)); return; } @@ -5029,8 +5029,8 @@ int read_viminfo_history(vir_T *virp, int writing) type = hist_char2type(virp->vir_line[0]); if (viminfo_hisidx[type] < viminfo_hislen[type]) { val = viminfo_readstring(virp, 1, TRUE); - if (val != NULL && *val != NUL) { - int sep = (*val == ' ' ? NUL : *val); + if (val != NULL && *val != '\0') { + int sep = (*val == ' ' ? '\0' : *val); if (!in_history(type, val + (type == HIST_SEARCH), viminfo_add_at_front, sep, writing)) { @@ -5047,7 +5047,7 @@ int read_viminfo_history(vir_T *virp, int writing) /* Not a search entry: No separator in the viminfo * file, add a NUL separator. */ memmove(p, val, (size_t)len + 1); - p[len + 1] = NUL; + p[len + 1] = '\0'; } viminfo_history[type][viminfo_hisidx[type]++] = p; } @@ -5171,7 +5171,7 @@ void write_viminfo_history(FILE *fp, int merge) * second column; use a space if there isn't one. */ if (type == HIST_SEARCH) { c = p[STRLEN(p) + 1]; - putc(c == NUL ? ' ' : c, fp); + putc(c == '\0' ? ' ' : c, fp); } viminfo_writestring(fp, p); } @@ -5208,14 +5208,14 @@ void cmd_pchar(int c, int offset) return; } ccline.cmdbuff[ccline.cmdpos + offset] = (char_u)c; - ccline.cmdbuff[ccline.cmdlen] = NUL; + ccline.cmdbuff[ccline.cmdlen] = '\0'; } int cmd_gchar(int offset) { if (ccline.cmdpos + offset >= ccline.cmdlen || ccline.cmdpos + offset < 0) { /* EMSG(_("cmd_gchar beyond the command length")); */ - return NUL; + return '\0'; } return (int)ccline.cmdbuff[ccline.cmdpos + offset]; } @@ -5337,7 +5337,7 @@ static int ex_window(void) /* Trigger CmdwinEnter autocommands. */ typestr[0] = cmdwin_type; - typestr[1] = NUL; + typestr[1] = '\0'; apply_autocmds(EVENT_CMDWINENTER, typestr, typestr, FALSE, curbuf); if (restart_edit != 0) /* autocmd with ":startinsert" */ stuffcharReadbuff(K_NOP); @@ -5457,7 +5457,7 @@ char_u *script_get(exarg_T *eap, char_u *cmd) ga_init(&ga, 1, 0x400); - if (cmd[2] != NUL) + if (cmd[2] != '\0') end_pattern = (char *)skipwhite(cmd + 2); else end_pattern = dot; @@ -5465,7 +5465,7 @@ char_u *script_get(exarg_T *eap, char_u *cmd) for (;; ) { theline = eap->getline( eap->cstack->cs_looplevel > 0 ? -1 : - NUL, eap->cookie, 0); + '\0', eap->cookie, 0); if (theline == NULL || STRCMP(end_pattern, theline) == 0) { vim_free(theline); @@ -5476,7 +5476,7 @@ char_u *script_get(exarg_T *eap, char_u *cmd) ga_append(&ga, '\n'); vim_free(theline); } - ga_append(&ga, NUL); + ga_append(&ga, '\0'); return (char_u *)ga.ga_data; } diff --git a/src/farsi.c b/src/farsi.c index ea9432ac8b..a68de6ca25 100644 --- a/src/farsi.c +++ b/src/farsi.c @@ -952,7 +952,7 @@ int fkmap(int c) || gchar_cursor() == F_DIVIDE || gchar_cursor() == F_PERCENT || gchar_cursor() == F_EQUALS)) - && gchar_cursor() != NUL) { + && gchar_cursor() != '\0') { curwin->w_cursor.col++; } } else { @@ -2413,7 +2413,7 @@ static void lrswapbuf(char_u *buf, int len) /// @return The buffer with the characters swapped. char_u* lrswap(char_u *ibuf) { - if ((ibuf != NULL) && (*ibuf != NUL)) { + if ((ibuf != NULL) && (*ibuf != '\0')) { lrswapbuf(ibuf, (int)STRLEN(ibuf)); } return ibuf; diff --git a/src/file_search.c b/src/file_search.c index 1bcb9fa519..76e69269a2 100644 --- a/src/file_search.c +++ b/src/file_search.c @@ -312,7 +312,7 @@ vim_findfile_init ( /* Store information on starting dir now if path is relative. * If path is absolute, we do that later. */ if (path[0] == '.' - && (vim_ispathsep(path[1]) || path[1] == NUL) + && (vim_ispathsep(path[1]) || path[1] == '\0') && (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL) && rel_fname != NULL) { int len = (int)(path_tail(rel_fname) - rel_fname); @@ -325,17 +325,17 @@ vim_findfile_init ( search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len); if (search_ctx->ffsc_start_dir == NULL) goto error_return; - if (*++path != NUL) + if (*++path != '\0') ++path; - } else if (*path == NUL || !vim_isAbsName(path)) { + } else if (*path == '\0' || !vim_isAbsName(path)) { #ifdef BACKSLASH_IN_FILENAME /* "c:dir" needs "c:" to be expanded, otherwise use current dir */ - if (*path != NUL && path[1] == ':') { + if (*path != '\0' && path[1] == ':') { char_u drive[3]; drive[0] = path[0]; drive[1] = ':'; - drive[2] = NUL; + drive[2] = '\0'; if (vim_FullName(drive, ff_expand_buffer, MAXPATHL, TRUE) == FAIL) goto error_return; path += 2; @@ -354,7 +354,7 @@ vim_findfile_init ( if ((*path == '/' || *path == '\\') && path[1] != path[0] && search_ctx->ffsc_start_dir[1] == ':') - search_ctx->ffsc_start_dir[2] = NUL; + search_ctx->ffsc_start_dir[2] = '\0'; #endif } @@ -430,7 +430,7 @@ vim_findfile_init ( * string. */ len = 0; - while (*wc_part != NUL) { + while (*wc_part != '\0') { if (len + 5 >= MAXPATHL) { EMSG(_(e_pathtoolong)); break; @@ -448,7 +448,7 @@ vim_findfile_init ( else ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND; wc_part = (char_u *)errpt; - if (*wc_part != NUL && !vim_ispathsep(*wc_part)) { + if (*wc_part != '\0' && !vim_ispathsep(*wc_part)) { EMSG2(_( "E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."), PATHSEPSTR); @@ -457,7 +457,7 @@ vim_findfile_init ( } else ff_expand_buffer[len++] = *wc_part++; } - ff_expand_buffer[len] = NUL; + ff_expand_buffer[len] = '\0'; search_ctx->ffsc_wc_path = vim_strsave(ff_expand_buffer); if (search_ctx->ffsc_wc_path == NULL) @@ -472,7 +472,7 @@ vim_findfile_init ( search_ctx->ffsc_start_dir = vim_strsave(search_ctx->ffsc_fix_path); if (search_ctx->ffsc_start_dir == NULL) goto error_return; - search_ctx->ffsc_fix_path[0] = NUL; + search_ctx->ffsc_fix_path[0] = '\0'; } /* create an absolute path */ @@ -561,7 +561,7 @@ char_u *vim_findfile_stopdir(char_u *buf) { char_u *r_ptr = buf; - while (*r_ptr != NUL && *r_ptr != ';') { + while (*r_ptr != '\0' && *r_ptr != ';') { if (r_ptr[0] == '\\' && r_ptr[1] == ';') { /* Overwrite the escape char, * use STRLEN(r_ptr) to move the trailing '\0'. */ @@ -573,7 +573,7 @@ char_u *vim_findfile_stopdir(char_u *buf) if (*r_ptr == ';') { *r_ptr = 0; r_ptr++; - } else if (*r_ptr == NUL) + } else if (*r_ptr == '\0') r_ptr = NULL; return r_ptr; } @@ -701,7 +701,7 @@ char_u *vim_findfile(void *search_ctx_arg) continue; } - file_path[0] = NUL; + file_path[0] = '\0'; /* * If no filearray till now expand wildcards @@ -730,7 +730,7 @@ char_u *vim_findfile(void *search_ctx_arg) add_pathsep(file_path); rest_of_wildcards = stackp->ffs_wc_path; - if (*rest_of_wildcards != NUL) { + if (*rest_of_wildcards != '\0') { len = (int)STRLEN(file_path); if (STRNCMP(rest_of_wildcards, "**", 2) == 0) { /* pointer to the restrict byte @@ -767,7 +767,7 @@ char_u *vim_findfile(void *search_ctx_arg) && !vim_ispathsep(*rest_of_wildcards)) file_path[len++] = *rest_of_wildcards++; - file_path[len] = NUL; + file_path[len] = '\0'; if (vim_ispathsep(*rest_of_wildcards)) rest_of_wildcards++; } @@ -800,7 +800,7 @@ char_u *vim_findfile(void *search_ctx_arg) if (stackp->ffs_stage == 0) { /* this is the first time we work on this directory */ - if (*rest_of_wildcards == NUL) { + if (*rest_of_wildcards == '\0') { /* * We don't have further wildcards to expand, so we have to * check for the final file now. @@ -887,7 +887,7 @@ char_u *vim_findfile(void *search_ctx_arg) } /* Not found or found already, try next suffix. */ - if (*suf == NUL) + if (*suf == '\0') break; copy_option_part(&suf, file_path + len, MAXPATHL - len, ","); @@ -1093,8 +1093,8 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char_u *filename, ff_visited_l static int ff_wc_equal(char_u *s1, char_u *s2) { int i; - int prev1 = NUL; - int prev2 = NUL; + int prev1 = '\0'; + int prev2 = '\0'; if (s1 == s2) return TRUE; @@ -1105,7 +1105,7 @@ static int ff_wc_equal(char_u *s1, char_u *s2) if (STRLEN(s1) != STRLEN(s2)) return FAIL; - for (i = 0; s1[i] != NUL && s2[i] != NUL; i += MB_PTR2LEN(s1 + i)) { + for (i = 0; s1[i] != '\0' && s2[i] != '\0'; i += MB_PTR2LEN(s1 + i)) { int c1 = PTR2CHAR(s1 + i); int c2 = PTR2CHAR(s2 + i); @@ -1139,7 +1139,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u * url = TRUE; #endif } else { - ff_expand_buffer[0] = NUL; + ff_expand_buffer[0] = '\0'; #ifdef UNIX if (mch_stat((char *)fname, &st) < 0) #else @@ -1176,7 +1176,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u * vp->ffv_dev_valid = TRUE; vp->ffv_ino = st.st_ino; vp->ffv_dev = st.st_dev; - vp->ffv_fname[0] = NUL; + vp->ffv_fname[0] = '\0'; } else { vp->ffv_dev_valid = FALSE; STRCPY(vp->ffv_fname, ff_expand_buffer); @@ -1378,7 +1378,7 @@ find_file_in_path ( ) { return find_file_in_path_option(ptr, len, options, first, - *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path, + *curbuf->b_p_path == '\0' ? p_path : curbuf->b_p_path, FINDFILE_BOTH, rel_fname, curbuf->b_p_sua); } @@ -1439,7 +1439,7 @@ find_file_in_path_option ( if (first == TRUE) { /* copy file name into NameBuff, expanding environment variables */ save_char = ptr[len]; - ptr[len] = NUL; + ptr[len] = '\0'; expand_env(ptr, NameBuff, MAXPATHL); ptr[len] = save_char; @@ -1452,10 +1452,10 @@ find_file_in_path_option ( } rel_to_curdir = (ff_file_to_find[0] == '.' - && (ff_file_to_find[1] == NUL + && (ff_file_to_find[1] == '\0' || vim_ispathsep(ff_file_to_find[1]) || (ff_file_to_find[1] == '.' - && (ff_file_to_find[2] == NUL + && (ff_file_to_find[2] == '\0' || vim_ispathsep(ff_file_to_find[2]))))); if (vim_isAbsName(ff_file_to_find) /* "..", "../path", "." and "./path": don't use the path_option */ @@ -1504,7 +1504,7 @@ find_file_in_path_option ( file_name = vim_strsave(NameBuff); goto theend; } - if (*buf == NUL) + if (*buf == '\0') break; copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ","); } @@ -1533,7 +1533,7 @@ find_file_in_path_option ( } else { char_u *r_ptr; - if (dir == NULL || *dir == NUL) { + if (dir == NULL || *dir == '\0') { /* We searched all paths of the option, now we can * free the search context. */ vim_findfile_cleanup(fdip_search_ctx); diff --git a/src/fileio.c b/src/fileio.c index 48172eca03..6c3a7b4f26 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -165,7 +165,7 @@ void filemess(buf_T *buf, char_u *name, char_u *s, int attr) msg_add_fname(buf, name); /* put file name in IObuff with quotes */ /* If it's extremely long, truncate it. */ if (STRLEN(IObuff) > IOSIZE - 80) - IObuff[IOSIZE - 80] = NUL; + IObuff[IOSIZE - 80] = '\0'; STRCAT(IObuff, s); /* * For the first message may have to start a new line. @@ -386,7 +386,7 @@ readfile ( * file may destroy it! Reported on MS-DOS and Win 95. * If the name is too long we might crash further on, quit here. */ - if (fname != NULL && *fname != NUL) { + if (fname != NULL && *fname != '\0') { p = fname + STRLEN(fname); if (after_pathsep(fname, p) || STRLEN(fname) >= MAXPATHL) { filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0); @@ -761,7 +761,7 @@ readfile ( keep_dest_enc = TRUE; } fenc_alloced = FALSE; - } else if (*p_fencs == NUL) { + } else if (*p_fencs == '\0') { fenc = curbuf->b_p_fenc; /* use format from buffer */ fenc_alloced = FALSE; } else { @@ -828,7 +828,7 @@ retry: try_unix = try_dos = try_mac = FALSE; } else if (curbuf->b_p_bin) fileformat = EOL_UNIX; /* binary: use Unix format */ - else if (*p_ffs == NUL) + else if (*p_ffs == '\0') fileformat = get_fileformat(curbuf); /* use format from buffer */ else fileformat = EOL_UNKNOWN; /* detect from file */ @@ -917,7 +917,7 @@ retry: * Use the 'charconvert' expression when conversion is required * and we can't do it internally or with iconv(). */ - if (fio_flags == 0 && !read_stdin && !read_buffer && *p_ccv != NUL + if (fio_flags == 0 && !read_stdin && !read_buffer && *p_ccv != '\0' # ifdef USE_ICONV && iconv_fd == (iconv_t)-1 # endif @@ -958,7 +958,7 @@ retry: /* Set "can_retry" when it's possible to rewind the file and try with * another "fenc" value. It's FALSE when no other "fenc" to try, reading * stdin or fixed at a specific encoding. */ - can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc); + can_retry = (*fenc != '\0' && !read_stdin && !keep_dest_enc); if (!skip_read) { linerest = 0; @@ -1058,7 +1058,7 @@ retry: n = (int)(size - tlen); for (ni = 0; ni < n; ++ni) { if (p[ni] == NL) - ptr[tlen++] = NUL; + ptr[tlen++] = '\0'; else ptr[tlen++] = p[ni]; } @@ -1069,7 +1069,7 @@ retry: * to NUL to reverse the effect done below. */ for (ni = 0; ni < n; ++ni) { if (p[ni] == NL) - ptr[tlen++] = NUL; + ptr[tlen++] = '\0'; else ptr[tlen++] = p[ni]; } @@ -1119,7 +1119,7 @@ retry: illegal_byte = curbuf->b_ml.ml_line_count - linecnt + 1; if (bad_char_behavior == BAD_DROP) { - *(ptr - conv_restlen) = NUL; + *(ptr - conv_restlen) = '\0'; conv_restlen = 0; } else { /* Replace the trailing bytes with the replacement @@ -1177,7 +1177,7 @@ retry: && (fio_flags == FIO_UCSBOM || (!curbuf->b_p_bomb && tmpname == NULL - && (*fenc == 'u' || (*fenc == NUL && enc_utf8))))) { + && (*fenc == 'u' || (*fenc == '\0' && enc_utf8))))) { char_u *ccname; int blen; @@ -1538,7 +1538,7 @@ retry: rewind_retry: /* Retry reading with another conversion. */ # if defined(FEAT_EVAL) && defined(USE_ICONV) - if (*p_ccv != NUL && iconv_fd != (iconv_t)-1) + if (*p_ccv != '\0' && iconv_fd != (iconv_t)-1) /* iconv() failed, try 'charconvert' */ did_iconv = TRUE; else @@ -1613,15 +1613,15 @@ rewind_retry: --ptr; while (++ptr, --size >= 0) { /* catch most common case first */ - if ((c = *ptr) != NUL && c != CAR && c != NL) + if ((c = *ptr) != '\0' && c != CAR && c != NL) continue; - if (c == NUL) + if (c == '\0') *ptr = NL; /* NULs are replaced by newlines! */ else if (c == NL) *ptr = CAR; /* NLs are replaced by CRs! */ else { if (skip_count == 0) { - *ptr = NUL; /* end of line */ + *ptr = '\0'; /* end of line */ len = (colnr_T) (ptr - line_start + 1); if (ml_append(lnum, line_start, len, newfile) == FAIL) { error = TRUE; @@ -1643,17 +1643,17 @@ rewind_retry: } else { --ptr; while (++ptr, --size >= 0) { - if ((c = *ptr) != NUL && c != NL) /* catch most common case */ + if ((c = *ptr) != '\0' && c != NL) /* catch most common case */ continue; - if (c == NUL) + if (c == '\0') *ptr = NL; /* NULs are replaced by newlines! */ else { if (skip_count == 0) { - *ptr = NUL; /* end of line */ + *ptr = '\0'; /* end of line */ len = (colnr_T)(ptr - line_start + 1); if (fileformat == EOL_DOS) { if (ptr[-1] == CAR) { /* remove CR */ - ptr[-1] = NUL; + ptr[-1] = '\0'; --len; } /* @@ -1719,7 +1719,7 @@ failed: /* remember for when writing */ if (set_options) curbuf->b_p_eol = FALSE; - *ptr = NUL; + *ptr = '\0'; len = (colnr_T)(ptr - line_start + 1); if (ml_append(lnum, line_start, len, newfile) == FAIL) error = TRUE; @@ -2030,8 +2030,8 @@ static int is_dev_fd_file(char_u *fname) { return STRNCMP(fname, "/dev/fd/", 8) == 0 && VIM_ISDIGIT(fname[8]) - && *skipdigits(fname + 9) == NUL - && (fname[9] != NUL + && *skipdigits(fname + 9) == '\0' + && (fname[9] != '\0' || (fname[8] != '0' && fname[8] != '1' && fname[8] != '2')); } #endif @@ -2086,7 +2086,7 @@ void set_file_options(int set_options, exarg_T *eap) if (set_options) { if (eap != NULL && eap->force_ff != 0) set_fileformat(get_fileformat_force(curbuf, eap), OPT_LOCAL); - else if (*p_ffs != NUL) + else if (*p_ffs != '\0') set_fileformat(default_fileformat(), OPT_LOCAL); } @@ -2126,7 +2126,7 @@ static char_u *next_fenc(char_u **pp) char_u *p; char_u *r; - if (**pp == NUL) { + if (**pp == '\0') { *pp = NULL; return (char_u *)""; } @@ -2281,7 +2281,7 @@ check_for_cryptkey ( *did_ask = TRUE; /* check if empty key entered */ - if (cryptkey != NULL && *cryptkey == NUL) { + if (cryptkey != NULL && *cryptkey == '\0') { if (cryptkey != curbuf->b_p_key) vim_free(cryptkey); cryptkey = NULL; @@ -2313,7 +2313,7 @@ check_for_cryptkey ( } /* When starting to edit a new file which does not have encryption, clear * the 'key' option, except when starting up (called with -x argument) */ - else if (newfile && *curbuf->b_p_key != NUL && !starting) + else if (newfile && *curbuf->b_p_key != '\0' && !starting) set_option_value((char_u *)"key", 0L, (char_u *)"", OPT_LOCAL); return cryptkey; @@ -2503,7 +2503,7 @@ buf_write ( context_sha256_T sha_ctx; int crypt_method_used; - if (fname == NULL || *fname == NUL) /* safety check */ + if (fname == NULL || *fname == '\0') /* safety check */ return FAIL; if (buf->b_ml.ml_mfp == NULL) { /* This can happen during startup when there is a stray "w" in the @@ -2866,8 +2866,8 @@ buf_write ( /* * If 'backupskip' is not empty, don't make a backup for some files. */ - dobackup = (p_wb || p_bk || *p_pm != NUL); - if (dobackup && *p_bsk != NUL && match_file_list(p_bsk, sfname, ffname)) + dobackup = (p_wb || p_bk || *p_pm != '\0'); + if (dobackup && *p_bsk != '\0' && match_file_list(p_bsk, sfname, ffname)) dobackup = FALSE; /* @@ -2889,7 +2889,7 @@ buf_write ( * Do not make any backup, if 'writebackup' and 'backup' are both switched * off. This helps when editing large files on almost-full disks. */ - if (!(append && *p_pm == NUL) && !filtering && perm >= 0 && dobackup) { + if (!(append && *p_pm == '\0') && !filtering && perm >= 0 && dobackup) { #if defined(UNIX) || defined(WIN32) struct stat st; #endif @@ -2984,7 +2984,7 @@ buf_write ( #endif /* make sure we have a valid backup extension to use */ - if (*p_bex == NUL) + if (*p_bex == '\0') backup_ext = (char_u *)".bak"; else backup_ext = p_bex; @@ -3405,7 +3405,7 @@ nobackup: * writing, write to a temp file instead and let the conversion * overwrite the original file. */ - if (*p_ccv != NUL) { + if (*p_ccv != '\0') { wfname = vim_tempname('w'); if (wfname == NULL) { /* Can't write without a tempfile! */ errmsg = (char_u *)_("E214: Can't find temp file for writing"); @@ -3523,7 +3523,7 @@ restore_backup: write_info.bw_fd = fd; - if (*buf->b_p_key != NUL && !filtering) { + if (*buf->b_p_key != '\0' && !filtering) { char_u *header; int header_len; @@ -3592,9 +3592,9 @@ restore_backup: ptr = ml_get_buf(buf, lnum, FALSE) - 1; if (write_undo_file) sha256_update(&sha_ctx, ptr + 1, (uint32_t)(STRLEN(ptr + 1) + 1)); - while ((c = *++ptr) != NUL) { + while ((c = *++ptr) != '\0') { if (c == NL) - *s = NUL; /* replace newlines with NULs */ + *s = '\0'; /* replace newlines with NULs */ else if (c == CAR && fileformat == EOL_MAC) *s = NL; /* Mac: replace CRs with NLs */ else @@ -3983,7 +3983,7 @@ nofail: #endif ); /* put file name in IObuff with quotes */ if (STRLEN(IObuff) + STRLEN(errmsg) + numlen >= IOSIZE) - IObuff[IOSIZE - STRLEN(errmsg) - numlen - 1] = NUL; + IObuff[IOSIZE - STRLEN(errmsg) - numlen - 1] = '\0'; /* If the error message has the form "is ...", put the error number in * front of the file name. */ if (errnum != NULL) { @@ -4091,7 +4091,7 @@ static int set_rw_fname(char_u *fname, char_u *sfname) return FAIL; /* Do filetype detection now if 'filetype' is empty. */ - if (*curbuf->b_p_ft == NUL) { + if (*curbuf->b_p_ft == '\0') { if (au_has_group((char_u *)"filetypedetect")) (void)do_doautocmd((char_u *)"filetypedetect BufRead", FALSE); do_modelines(0); @@ -4500,7 +4500,7 @@ static int need_conversion(char_u *fenc) int enc_flags; int fenc_flags; - if (*fenc == NUL || STRCMP(p_enc, fenc) == 0) { + if (*fenc == '\0' || STRCMP(p_enc, fenc) == 0) { same_encoding = TRUE; fenc_flags = 0; } else { @@ -4530,7 +4530,7 @@ static int get_fio_flags(char_u *ptr) { int prop; - if (*ptr == NUL) + if (*ptr == '\0') ptr = p_enc; prop = enc_canon_props(ptr); @@ -4718,7 +4718,7 @@ buf_modname ( * If there is no file name we must get the name of the current directory * (we need the full path in case :cd is used). */ - if (fname == NULL || *fname == NUL) { + if (fname == NULL || *fname == '\0') { retval = alloc((unsigned)(MAXPATHL + extlen + 3)); if (os_dirname(retval, MAXPATHL) == FAIL || (fnamelen = (int)STRLEN(retval)) == 0) { @@ -4727,7 +4727,7 @@ buf_modname ( } if (!after_pathsep(retval, retval + fnamelen)) { retval[fnamelen++] = PATHSEP; - retval[fnamelen] = NUL; + retval[fnamelen] = '\0'; } #ifndef SHORT_FNAME prepend_dot = FALSE; /* nothing to prepend a dot to */ @@ -4785,7 +4785,7 @@ buf_modname ( * extension starts with '.', put a '_' before the dot, because just * ".ext" is invalid. */ - if (fname == NULL || *fname == NUL + if (fname == NULL || *fname == '\0' || vim_ispathsep(fname[STRLEN(fname) - 1])) { if (*ext == '.') *s++ = '_'; @@ -4819,7 +4819,7 @@ buf_modname ( * '_' before the dot, because just ".ext" may be invalid if it's on a * FAT partition, and on HPFS it doesn't matter. */ - else if ((fname == NULL || *fname == NUL) && *ext == '.') + else if ((fname == NULL || *fname == '\0') && *ext == '.') *s++ = '_'; #endif @@ -4871,24 +4871,24 @@ int vim_fgets(char_u *buf, int size, FILE *fp) #define FGETS_SIZE 200 char tbuf[FGETS_SIZE]; - buf[size - 2] = NUL; + buf[size - 2] = '\0'; #ifdef USE_CR eof = fgets_cr((char *)buf, size, fp); #else eof = fgets((char *)buf, size, fp); #endif - if (buf[size - 2] != NUL && buf[size - 2] != '\n') { - buf[size - 1] = NUL; /* Truncate the line */ + if (buf[size - 2] != '\0' && buf[size - 2] != '\n') { + buf[size - 1] = '\0'; /* Truncate the line */ /* Now throw away the rest of the line: */ do { - tbuf[FGETS_SIZE - 2] = NUL; + tbuf[FGETS_SIZE - 2] = '\0'; #ifdef USE_CR ignoredp = fgets_cr((char *)tbuf, FGETS_SIZE, fp); #else ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp); #endif - } while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n'); + } while (tbuf[FGETS_SIZE - 2] != '\0' && tbuf[FGETS_SIZE - 2] != '\n'); } return eof == NULL; } @@ -4925,7 +4925,7 @@ int tag_fgets(char_u *buf, int size, FILE *fp) if (c == '\n') break; } - buf[i] = NUL; + buf[i] = '\0'; return eof; } #endif @@ -5236,7 +5236,7 @@ buf_check_timestamp ( * this buffer. */ if (buf->b_ffname == NULL || buf->b_ml.ml_mfp == NULL - || *buf->b_p_bt != NUL + || *buf->b_p_bt != '\0' || buf->b_saving || busy ) @@ -5364,7 +5364,7 @@ buf_check_timestamp ( * mesg2 has been appended. */ set_vim_var_string(VV_WARNINGMSG, tbuf, -1); if (can_reload) { - if (*mesg2 != NUL) { + if (*mesg2 != '\0') { STRCAT(tbuf, "\n"); STRCAT(tbuf, mesg2); } @@ -5373,7 +5373,7 @@ buf_check_timestamp ( reload = TRUE; } else if (State > NORMAL_BUSY || (State & CMDLINE) || already_warned) { - if (*mesg2 != NUL) { + if (*mesg2 != '\0') { STRCAT(tbuf, "; "); STRCAT(tbuf, mesg2); } @@ -5383,7 +5383,7 @@ buf_check_timestamp ( if (!autocmd_busy) { msg_start(); msg_puts_attr(tbuf, hl_attr(HLF_E) + MSG_HIST); - if (*mesg2 != NUL) + if (*mesg2 != '\0') msg_puts_attr((char_u *)mesg2, hl_attr(HLF_W) + MSG_HIST); msg_clr_eos(); @@ -5603,7 +5603,7 @@ void vim_deltempdir(void) os_remove((char *)files[i]); FreeWild(file_count, files); } - path_tail(NameBuff)[-1] = NUL; + path_tail(NameBuff)[-1] = '\0'; os_rmdir((char *)NameBuff); vim_free(vim_tempdir); @@ -5755,7 +5755,7 @@ vim_tempname ( /* tmpnam() will make its own name */ p = tmpnam((char *)itmp); - if (p == NULL || *p == NUL) + if (p == NULL || *p == '\0') return NULL; # else char_u *p; @@ -5779,7 +5779,7 @@ void forward_slash(char_u *fname) { char_u *p; - for (p = fname; *p != NUL; ++p) + for (p = fname; *p != '\0'; ++p) /* The Big5 encoding can have '\' in the trail byte. */ if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) ++p; @@ -6239,7 +6239,7 @@ void do_augroup(char_u *arg, int del_group) int i; if (del_group) { - if (*arg == NUL) + if (*arg == '\0') EMSG(_(e_argreq)); else au_del_group(arg); @@ -6352,8 +6352,8 @@ static int event_ignored(event_T event) { char_u *p = p_ei; - while (*p != NUL) { - if (STRNICMP(p, "all", 3) == 0 && (p[3] == NUL || p[3] == ',')) + while (*p != '\0') { + if (STRNICMP(p, "all", 3) == 0 && (p[3] == '\0' || p[3] == ',')) return TRUE; if (event_name2nr(p, &p) == event) return TRUE; @@ -6370,7 +6370,7 @@ int check_ei(void) char_u *p = p_ei; while (*p) { - if (STRNICMP(p, "all", 3) == 0 && (p[3] == NUL || p[3] == ',')) { + if (STRNICMP(p, "all", 3) == 0 && (p[3] == '\0' || p[3] == ',')) { p += 3; if (*p == ',') ++p; @@ -6395,7 +6395,7 @@ char_u *au_event_disable(char *what) if (save_ei != NULL) { new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what))); if (new_ei != NULL) { - if (*what == ',' && *p_ei == NUL) + if (*what == ',' && *p_ei == '\0') STRCPY(new_ei, what + 1); else STRCAT(new_ei, what); @@ -6474,14 +6474,14 @@ void do_autocmd(char_u *arg, int forceit) return; /* - * Scan over the pattern. Put a NUL at the end. + * Scan over the pattern. Put a '\0' at the end. */ pat = skipwhite(pat); cmd = pat; while (*cmd && (!vim_iswhite(*cmd) || cmd[-1] == '\\')) cmd++; if (*cmd) - *cmd++ = NUL; + *cmd++ = '\0'; /* Expand environment variables in the pattern. Set 'shellslash', we want * forward slashes here. */ @@ -6503,7 +6503,7 @@ void do_autocmd(char_u *arg, int forceit) * Check for "nested" flag. */ cmd = skipwhite(cmd); - if (*cmd != NUL && STRNCMP(cmd, "nested", 6) == 0 && vim_iswhite(cmd[6])) { + if (*cmd != '\0' && STRNCMP(cmd, "nested", 6) == 0 && vim_iswhite(cmd[6])) { nested = TRUE; cmd = skipwhite(cmd + 6); } @@ -6512,7 +6512,7 @@ void do_autocmd(char_u *arg, int forceit) * Find the start of the commands. * Expand <sfile> in it. */ - if (*cmd != NUL) { + if (*cmd != '\0') { cmd = expand_sfile(cmd); if (cmd == NULL) /* some error */ return; @@ -6522,7 +6522,7 @@ void do_autocmd(char_u *arg, int forceit) /* * Print header when showing autocommands. */ - if (!forceit && *cmd == NUL) { + if (!forceit && *cmd == '\0') { /* Highlight title */ MSG_PUTS_TITLE(_("\n--- Auto-Commands ---")); } @@ -6532,7 +6532,7 @@ void do_autocmd(char_u *arg, int forceit) */ last_event = (event_T)-1; /* for listing the event name */ last_group = AUGROUP_ERROR; /* for listing the group name */ - if (*arg == '*' || *arg == NUL) { + if (*arg == '*' || *arg == '\0') { for (event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1)) if (do_autocmd_event(event, pat, @@ -6604,12 +6604,12 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd, findgroup = current_augroup; else findgroup = group; - allgroups = (group == AUGROUP_ALL && !forceit && *cmd == NUL); + allgroups = (group == AUGROUP_ALL && !forceit && *cmd == '\0'); /* * Show or delete all patterns for an event. */ - if (*pat == NUL) { + if (*pat == '\0') { for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next) { if (forceit) { /* delete the AutoPat, if it's in the current group */ if (ap->group == findgroup) @@ -6694,7 +6694,7 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd, * this list. */ if (forceit) { - if (*cmd != NUL && ap->next == NULL) { + if (*cmd != '\0' && ap->next == NULL) { au_remove_cmds(ap); break; } @@ -6703,7 +6703,7 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd, /* * Show autocmd's for this autopat, or buflocals <buffer=X> */ - else if (*cmd == NUL) + else if (*cmd == '\0') show_autocmd(ap, event); /* @@ -6719,7 +6719,7 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd, /* * Add a new command. */ - if (*cmd != NUL) { + if (*cmd != '\0') { /* * If the pattern we want to add a command to does appear at the * end of the list (or not is not in the list at all), add the @@ -7309,7 +7309,7 @@ apply_autocmds_group ( if (fname_io == NULL) { if (event == EVENT_COLORSCHEME) autocmd_fname = NULL; - else if (fname != NULL && *fname != NUL) + else if (fname != NULL && *fname != '\0') autocmd_fname = fname; else if (buf != NULL) autocmd_fname = buf->b_ffname; @@ -7334,7 +7334,7 @@ apply_autocmds_group ( * Always use the full path of the file name to match with, in case * "allow_dirs" is set. */ - if (fname == NULL || *fname == NUL) { + if (fname == NULL || *fname == '\0') { if (buf == NULL) fname = NULL; else { @@ -7755,16 +7755,16 @@ set_context_in_autocmd ( if (group == AUGROUP_ERROR) return NULL; /* If there only is a group name that's what we expand. */ - if (*arg == NUL && group != AUGROUP_ALL && !vim_iswhite(arg[-1])) { + if (*arg == '\0' && group != AUGROUP_ALL && !vim_iswhite(arg[-1])) { arg = p; group = AUGROUP_ALL; } /* skip over event name */ - for (p = arg; *p != NUL && !vim_iswhite(*p); ++p) + for (p = arg; *p != '\0' && !vim_iswhite(*p); ++p) if (*p == ',') arg = p + 1; - if (*p == NUL) { + if (*p == '\0') { if (group == AUGROUP_ALL) include_groups = TRUE; xp->xp_context = EXPAND_EVENTS; /* expand event name */ @@ -7840,7 +7840,7 @@ int au_exists(char_u *arg) return FALSE; p = vim_strchr(arg_save, '#'); if (p != NULL) - *p++ = NUL; + *p++ = '\0'; /* First, look for an autocmd group name */ group = au_find_group(arg_save); @@ -7859,7 +7859,7 @@ int au_exists(char_u *arg) event_name = p; p = vim_strchr(event_name, '#'); if (p != NULL) - *p++ = NUL; /* "Group#Event#pat" */ + *p++ = '\0'; /* "Group#Event#pat" */ } pattern = p; /* "pattern" is NULL when there is no pattern */ @@ -7941,7 +7941,7 @@ match_file_pat ( for (type_start = pattern + 1; (c = *pattern); pattern++) { if ((c == ';' || c == '>') && match == FALSE) { - *pattern = NUL; /* Terminate the string */ + *pattern = '\0'; /* Terminate the string */ /* TODO: match with 'filetype' of buffer that "fname" comes * from. */ match = mch_check_filetype(fname, type_start); @@ -7953,9 +7953,9 @@ match_file_pat ( } /* (c should never be NUL, but check anyway) */ - if (match == FALSE || c == NUL) + if (match == FALSE || c == '\0') regmatch.regprog = NULL; /* Doesn't match - don't check pat. */ - else if (*pattern == NUL) { + else if (*pattern == '\0') { regmatch.regprog = NULL; /* Vim will try to free regprog later */ no_pattern = TRUE; /* Always matches - don't check pat. */ } else @@ -8151,7 +8151,7 @@ file_pat_to_reg_pat ( reg_pat[i++] = '.'; break; case '\\': - if (p[1] == NUL) + if (p[1] == '\0') break; #ifdef BACKSLASH_IN_FILENAME if (!no_bslash) { @@ -8245,7 +8245,7 @@ file_pat_to_reg_pat ( } if (add_dollar) reg_pat[i++] = '$'; - reg_pat[i] = NUL; + reg_pat[i] = '\0'; if (nested != 0) { if (nested < 0) EMSG(_("E219: Missing {.")); diff --git a/src/fold.c b/src/fold.c index 38432a79aa..c8dc537eb9 100644 --- a/src/fold.c +++ b/src/fold.c @@ -499,7 +499,7 @@ static void newFoldLevelWin(win_T *wp) */ void foldCheckClose(void) { - if (*p_fcl != NUL) { /* can only be "all" right now */ + if (*p_fcl != '\0') { /* can only be "all" right now */ checkupdate(curwin); if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum, (int)curwin->w_p_fdl)) @@ -1662,13 +1662,13 @@ static void foldDelMarker(linenr_T lnum, char_u *marker, int markerlen) char_u *cms2; line = ml_get(lnum); - for (p = line; *p != NUL; ++p) + for (p = line; *p != '\0'; ++p) if (STRNCMP(p, marker, markerlen) == 0) { /* Found the marker, include a digit if it's there. */ len = markerlen; if (VIM_ISDIGIT(p[len])) ++len; - if (*cms != NUL) { + if (*cms != '\0') { /* Also delete 'commentstring' if it matches. */ cms2 = (char_u *)strstr((char *)cms, "%s"); if (p - line >= cms2 - cms @@ -1713,7 +1713,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T *foldi /* a previous error should not abort evaluating 'foldexpr' */ did_emsg = FALSE; - if (*wp->w_p_fdt != NUL) { + if (*wp->w_p_fdt != '\0') { char_u dashes[MAX_LEVEL + 2]; win_T *save_curwin; int level; @@ -1729,7 +1729,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T *foldi if (level > (int)sizeof(dashes) - 1) level = (int)sizeof(dashes) - 1; memset(dashes, '-', (size_t)level); - dashes[level] = NUL; + dashes[level] = '\0'; set_vim_var_string(VV_FOLDDASHES, dashes, -1); set_vim_var_nr(VV_FOLDLEVEL, (long)level); @@ -1760,7 +1760,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T *foldi if (text != NULL) { /* Replace unprintable characters, if there are any. But * replace a TAB with a space. */ - for (p = text; *p != NUL; ++p) { + for (p = text; *p != '\0'; ++p) { int len; if (has_mbyte && (len = (*mb_ptr2len)(p)) > 1) { @@ -1772,7 +1772,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T *foldi else if (ptr2cells(p) > 1) break; } - if (*p != NUL) { + if (*p != '\0') { p = transstr(text); vim_free(text); text = p; @@ -1826,7 +1826,7 @@ void foldtext_cleanup(char_u *str) } parseMarker(curwin); - for (s = str; *s != NUL; ) { + for (s = str; *s != '\0'; ) { len = 0; if (STRNCMP(s, curwin->w_p_fmr, foldstartmarkerlen) == 0) len = foldstartmarkerlen; @@ -2687,7 +2687,7 @@ static void foldlevelIndent(fline_T *flp) /* empty line or lines starting with a character in 'foldignore': level * depends on surrounding lines */ - if (*s == NUL || vim_strchr(flp->wp->w_p_fdi, *s) != NULL) { + if (*s == '\0' || vim_strchr(flp->wp->w_p_fdi, *s) != NULL) { /* first and last line can't be undefined, use level 0 */ if (lnum == 1 || lnum == buf->b_ml.ml_line_count) flp->lvl = 0; diff --git a/src/garray.c b/src/garray.c index bb035935a8..032d61f150 100644 --- a/src/garray.c +++ b/src/garray.c @@ -189,7 +189,7 @@ void append_ga_line(garray_T *gap) && (((char_u *)gap->ga_data)[gap->ga_len - 1] == CAR)) { gap->ga_len--; } - ga_append(gap, NUL); + ga_append(gap, '\0'); ml_append(curwin->w_cursor.lnum++, gap->ga_data, 0, FALSE); gap->ga_len = 0; } diff --git a/src/getchar.c b/src/getchar.c index 62e0c9bf61..3ad6ff3390 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -66,17 +66,17 @@ #define MINIMAL_SIZE 20 /* minimal size for b_str */ -static buffheader_T redobuff = {{NULL, {NUL}}, NULL, 0, 0}; -static buffheader_T old_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; -static buffheader_T save_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; -static buffheader_T save_old_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; -static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0}; +static buffheader_T redobuff = {{NULL, {'\0'}}, NULL, 0, 0}; +static buffheader_T old_redobuff = {{NULL, {'\0'}}, NULL, 0, 0}; +static buffheader_T save_redobuff = {{NULL, {'\0'}}, NULL, 0, 0}; +static buffheader_T save_old_redobuff = {{NULL, {'\0'}}, NULL, 0, 0}; +static buffheader_T recordbuff = {{NULL, {'\0'}}, NULL, 0, 0}; // First read ahead buffer. Used for translated commands. -static buffheader_T readbuf1 = {{NULL, {NUL}}, NULL, 0, 0}; +static buffheader_T readbuf1 = {{NULL, {'\0'}}, NULL, 0, 0}; // Second read ahead buffer. Used for redo. -static buffheader_T readbuf2 = {{NULL, {NUL}}, NULL, 0, 0}; +static buffheader_T readbuf2 = {{NULL, {'\0'}}, NULL, 0, 0}; static int typeahead_char = 0; /* typeahead char that's not flushed */ @@ -203,7 +203,7 @@ static char_u *get_buffcont(buffheader_T *buffer, for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next) for (str = bp->b_str; *str; ) *p2++ = *str++; - *p2 = NUL; + *p2 = '\0'; } return p; } @@ -228,7 +228,7 @@ char_u *get_recorded(void) len = STRLEN(p); if ((int)len >= last_recorded_len) { len -= last_recorded_len; - p[len] = NUL; + p[len] = '\0'; } /* @@ -236,7 +236,7 @@ char_u *get_recorded(void) * CTRL-O. */ if (len > 0 && restart_edit != 0 && p[len - 1] == Ctrl_O) - p[len - 1] = NUL; + p[len - 1] = '\0'; return p; } @@ -331,15 +331,15 @@ static void add_char_buff(buffheader_T *buf, int c) if (!IS_SPECIAL(c)) c = bytes[i]; - if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL) { + if (IS_SPECIAL(c) || c == K_SPECIAL || c == '\0') { /* translate special key code into three byte sequence */ temp[0] = K_SPECIAL; temp[1] = K_SECOND(c); temp[2] = K_THIRD(c); - temp[3] = NUL; + temp[3] = '\0'; } else { temp[0] = c; - temp[1] = NUL; + temp[1] = '\0'; } add_buff(buf, temp, -1L); } @@ -356,7 +356,7 @@ static int read_readbuffers(int advance) int c; c = read_readbuf(&readbuf1, advance); - if (c == NUL) + if (c == '\0') c = read_readbuf(&readbuf2, advance); return c; } @@ -367,13 +367,13 @@ static int read_readbuf(buffheader_T *buf, int advance) buffblock_T *curr; if (buf->bh_first.b_next == NULL) /* buffer is empty */ - return NUL; + return '\0'; curr = buf->bh_first.b_next; c = curr->b_str[buf->bh_index]; if (advance) { - if (curr->b_str[++buf->bh_index] == NUL) { + if (curr->b_str[++buf->bh_index] == '\0') { buf->bh_first.b_next = curr->b_next; vim_free(curr); buf->bh_index = 0; @@ -432,7 +432,7 @@ void flush_buffers(int flush_typeahead) init_typebuf(); start_stuff(); - while (read_readbuffers(TRUE) != NUL) { + while (read_readbuffers(TRUE) != '\0') { } if (flush_typeahead) { /* remove all typeahead */ @@ -480,7 +480,7 @@ void CancelRedo(void) redobuff = old_redobuff; old_redobuff.bh_first.b_next = NULL; start_stuff(); - while (read_readbuffers(TRUE) != NUL) { + while (read_readbuffers(TRUE) != '\0') { } } } @@ -551,7 +551,7 @@ AppendToRedobuffLit ( if (block_redo) return; - while (len < 0 ? *s != NUL : s - str < len) { + while (len < 0 ? *s != '\0' : s - str < len) { /* Put a string of normal characters in the redo buffer (that's * faster). */ start = s; @@ -562,12 +562,12 @@ AppendToRedobuffLit ( /* Don't put '0' or '^' as last character, just in case a CTRL-D is * typed next. */ - if (*s == NUL && (s[-1] == '0' || s[-1] == '^')) + if (*s == '\0' && (s[-1] == '0' || s[-1] == '^')) --s; if (s > start) add_buff(&redobuff, start, (long)(s - start)); - if (*s == NUL || (len >= 0 && s - str >= len)) + if (*s == '\0' || (len >= 0 && s - str >= len)) break; /* Handle a special or multibyte character. */ @@ -576,11 +576,11 @@ AppendToRedobuffLit ( c = mb_cptr2char_adv(&s); else c = *s++; - if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^'))) + if (c < ' ' || c == DEL || (*s == '\0' && (c == '0' || c == '^'))) add_char_buff(&redobuff, Ctrl_V); /* CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) */ - if (*s == NUL && c == '0') + if (*s == '\0' && c == '0') add_buff(&redobuff, (char_u *)"048", 3L); else add_char_buff(&redobuff, c); @@ -629,8 +629,8 @@ void stuffReadbuffSpec(char_u *s) { int c; - while (*s != NUL) { - if (*s == K_SPECIAL && s[1] != NUL && s[2] != NUL) { + while (*s != '\0') { + if (*s == K_SPECIAL && s[1] != '\0' && s[2] != '\0') { /* Insert special key literally. */ stuffReadbuffLen(s, 3L); s += 3; @@ -687,7 +687,7 @@ static int read_redo(int init, int old_redo) p = bp->b_str; return OK; } - if ((c = *p) != NUL) { + if ((c = *p) != '\0') { /* Reverse the conversion done by add_char_buff() */ /* For a multi-byte character get all the bytes and return the * converted character. */ @@ -700,7 +700,7 @@ static int read_redo(int init, int old_redo) c = TO_SPECIAL(p[1], p[2]); p += 2; } - if (*++p == NUL && bp->b_next != NULL) { + if (*++p == '\0' && bp->b_next != NULL) { bp = bp->b_next; p = bp->b_str; } @@ -711,7 +711,7 @@ static int read_redo(int init, int old_redo) break; } c = *p; - if (c == NUL) /* cannot happen? */ + if (c == '\0') /* cannot happen? */ break; } } @@ -728,7 +728,7 @@ static void copy_redo(int old_redo) { int c; - while ((c = read_redo(FALSE, old_redo)) != NUL) { + while ((c = read_redo(FALSE, old_redo)) != '\0') { add_char_buff(&readbuf2, c); } } @@ -800,7 +800,7 @@ int start_redo_ins(void) start_stuff(); /* skip the count and the command character */ - while ((c = read_redo(FALSE, FALSE)) != NUL) { + while ((c = read_redo(FALSE, FALSE)) != '\0') { if (vim_strchr((char_u *)"AaIiRrOo", c) != NULL) { if (c == 'O' || c == 'o') { add_buff(&readbuf2, NL_STR, -1L); @@ -984,9 +984,9 @@ void ins_char_typebuf(int c) buf[0] = K_SPECIAL; buf[1] = K_SECOND(c); buf[2] = K_THIRD(c); - buf[3] = NUL; + buf[3] = '\0'; } else { - buf[(*mb_char2bytes)(c, buf)] = NUL; + buf[(*mb_char2bytes)(c, buf)] = '\0'; } (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); } @@ -1111,7 +1111,7 @@ static void gotchars(char_u *chars, int len) if (Recording) last_recorded_len += len; - buf[1] = NUL; + buf[1] = '\0'; while (todo--) { /* Handle one byte at a time; no translation to be done. */ c = *s++; @@ -1543,7 +1543,7 @@ int safe_vgetc(void) int c; c = vgetc(); - if (c == NUL) + if (c == '\0') c = get_keystroke(); return c; } @@ -1600,7 +1600,7 @@ int vpeekc_any(void) int c; c = vpeekc(); - if (c == NUL && typebuf.tb_len > 0) + if (c == '\0' && typebuf.tb_len > 0) c = ESC; return c; } @@ -1616,7 +1616,7 @@ int char_avail(void) ++no_mapping; retval = vpeekc(); --no_mapping; - return retval != NUL; + return retval != '\0'; } void @@ -1690,7 +1690,7 @@ static int vgetorpeek(int advance) if (vgetc_busy > 0 && ex_normal_busy == 0 ) - return NUL; + return '\0'; local_State = get_real_state(); @@ -1714,7 +1714,7 @@ static int vgetorpeek(int advance) } else { c = read_readbuffers(advance); } - if (c != NUL && !got_int) { + if (c != '\0' && !got_int) { if (advance) { /* KeyTyped = FALSE; When the command that stuffed something * was typed, behave like the stuffed command was typed. @@ -1920,13 +1920,13 @@ static int vgetorpeek(int advance) } /* Check for match with 'pastetoggle' */ - if (*p_pt != NUL && mp == NULL && (State & (INSERT|NORMAL))) { + if (*p_pt != '\0' && mp == NULL && (State & (INSERT|NORMAL))) { for (mlen = 0; mlen < typebuf.tb_len && p_pt[mlen]; ++mlen) if (p_pt[mlen] != typebuf.tb_buf[typebuf.tb_off + mlen]) break; - if (p_pt[mlen] == NUL) { /* match */ + if (p_pt[mlen] == '\0') { /* match */ /* write chars to script file(s) */ if (mlen > typebuf.tb_maplen) gotchars(typebuf.tb_buf + typebuf.tb_off @@ -2103,7 +2103,7 @@ static int vgetorpeek(int advance) vgetc_busy = 0; save_m_keys = vim_strsave(mp->m_keys); save_m_str = vim_strsave(mp->m_str); - s = eval_map_expr(save_m_str, NUL); + s = eval_map_expr(save_m_str, '\0'); vgetc_busy = save_vgetc_busy; } else s = mp->m_str; @@ -2362,7 +2362,7 @@ static int vgetorpeek(int advance) if (c < 0) continue; /* end of input script reached */ - if (c == NUL) { /* no character available */ + if (c == '\0') { /* no character available */ if (!advance) break; if (wait_tb_len > 0) { /* timed out */ @@ -2371,7 +2371,7 @@ static int vgetorpeek(int advance) } } else { /* allow mapping for just typed characters */ while (typebuf.tb_buf[typebuf.tb_off - + typebuf.tb_len] != NUL) + + typebuf.tb_len] != '\0') typebuf.tb_noremap[typebuf.tb_off + typebuf.tb_len++] = RM_YES; #ifdef USE_IM_CONTROL @@ -2384,7 +2384,7 @@ static int vgetorpeek(int advance) } /* if (!character from stuffbuf) */ /* if advance is FALSE don't loop on NULs */ - } while (c < 0 || (advance && c == NUL)); + } while (c < 0 || (advance && c == '\0')); /* * The "INSERT" message is taken care of here: @@ -2555,7 +2555,7 @@ fix_input_buffer ( * Don't replace K_SPECIAL when reading a script file. */ for (i = len; --i >= 0; ++p) { - if (p[0] == NUL + if (p[0] == '\0' || (p[0] == K_SPECIAL && !script && (i < 2 || p[1] != KS_EXTRA || is_user_input(p[2])))) { @@ -2567,7 +2567,7 @@ fix_input_buffer ( len += 2; } } - *p = NUL; /* add trailing NUL */ + *p = '\0'; /* add trailing NUL */ return len; } @@ -2750,17 +2750,17 @@ do_map ( do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); while (*p && (maptype == 1 || !vim_iswhite(*p))) { if ((p[0] == Ctrl_V || (do_backslash && p[0] == '\\')) && - p[1] != NUL) + p[1] != '\0') ++p; /* skip CTRL-V or backslash */ ++p; } - if (*p != NUL) - *p++ = NUL; + if (*p != '\0') + *p++ = '\0'; p = skipwhite(p); rhs = p; - hasarg = (*rhs != NUL); - haskey = (*keys != NUL); + hasarg = (*rhs != '\0'); + haskey = (*keys != '\0'); /* check for :unmap without argument */ if (maptype == 1 && !haskey) { @@ -2955,7 +2955,7 @@ do_map ( * "lhs", since an abbreviation can't have * trailing space. */ if (n != len && (!abbrev || round || n > len - || *skipwhite(keys + n) != NUL)) { + || *skipwhite(keys + n) != '\0')) { mpp = &(mp->m_next); continue; } @@ -3168,7 +3168,7 @@ void map_clear(char_u *cmdp, char_u *arg, int forceit, int abbr) int local; local = (STRCMP(arg, "<buffer>") == 0); - if (!local && *arg != NUL) { + if (!local && *arg != '\0') { EMSG(_(e_invarg)); return; } @@ -3275,7 +3275,7 @@ char_u *map_mode_to_chars(int mode) } } - ga_append(&mapmode, NUL); + ga_append(&mapmode, '\0'); return (char_u *)mapmode.ga_data; } @@ -3325,7 +3325,7 @@ showmap ( /* Use FALSE below if we only want things like <Up> to show up as such on * the rhs, and not M-x etc, TRUE gets both -- webb */ - if (*mp->m_str == NUL) + if (*mp->m_str == '\0') msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8)); else { /* Remove escaping of CSI, because "m_str" is in a format to be used @@ -3731,7 +3731,7 @@ int check_abbr(int c, char_u *ptr, int col, int mincol) } else tb[j++] = c; } - tb[j] = NUL; + tb[j] = '\0'; /* insert the last typed char */ (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); } @@ -3749,7 +3749,7 @@ int check_abbr(int c, char_u *ptr, int col, int mincol) } tb[0] = Ctrl_H; - tb[1] = NUL; + tb[1] = '\0'; if (has_mbyte) len = clen; /* Delete characters instead of bytes */ while (len-- > 0) /* delete the from string */ @@ -3836,8 +3836,8 @@ char_u *vim_strsave_escape_csi(char_u *p) /* Need a buffer to hold up to three times as much. */ res = alloc((unsigned)(STRLEN(p) * 3) + 1); d = res; - for (s = p; *s != NUL; ) { - if (s[0] == K_SPECIAL && s[1] != NUL && s[2] != NUL) { + for (s = p; *s != '\0'; ) { + if (s[0] == K_SPECIAL && s[1] != '\0' && s[2] != '\0') { /* Copy special key unmodified. */ *d++ = *s++; *d++ = *s++; @@ -3856,7 +3856,7 @@ char_u *vim_strsave_escape_csi(char_u *p) mb_ptr_adv(s); } } - *d = NUL; + *d = '\0'; return res; } @@ -3869,7 +3869,7 @@ void vim_unescape_csi(char_u *p) { char_u *s = p, *d = p; - while (*s != NUL) { + while (*s != '\0') { if (s[0] == K_SPECIAL && s[1] == KS_SPECIAL && s[2] == KE_FILLER) { *d++ = K_SPECIAL; s += 3; @@ -3880,7 +3880,7 @@ void vim_unescape_csi(char_u *p) } else *d++ = *s++; } - *d = NUL; + *d = '\0'; } /* @@ -3931,19 +3931,19 @@ makemap ( /* skip mappings that contain a <SNR> (script-local thing), * they probably don't work when loaded again */ - for (p = mp->m_str; *p != NUL; ++p) + for (p = mp->m_str; *p != '\0'; ++p) if (p[0] == K_SPECIAL && p[1] == KS_EXTRA && p[2] == (int)KE_SNR) break; - if (*p != NUL) + if (*p != '\0') continue; /* It's possible to create a mapping and then ":unmap" certain * modes. We recreate this here by mapping the individual * modes, which requires up to three of them. */ - c1 = NUL; - c2 = NUL; - c3 = NUL; + c1 = '\0'; + c2 = '\0'; + c3 = '\0'; if (abbr) cmd = "abbr"; else @@ -4025,7 +4025,7 @@ makemap ( /* When outputting <> form, need to make sure that 'cpo' * is set to the Vim default. */ if (!did_cpo) { - if (*mp->m_str == NUL) /* will use <Nop> */ + if (*mp->m_str == '\0') /* will use <Nop> */ did_cpo = TRUE; else for (i = 0; i < 2; ++i) @@ -4066,8 +4066,8 @@ makemap ( return FAIL; c1 = c2; c2 = c3; - c3 = NUL; - } while (c1 != NUL); + c3 = '\0'; + } while (c1 != '\0'); } } @@ -4093,20 +4093,20 @@ int put_escstr(FILE *fd, char_u *strstart, int what) int modifiers; /* :map xx <Nop> */ - if (*str == NUL && what == 1) { + if (*str == '\0' && what == 1) { if (fprintf(fd, "<Nop>") < 0) return FAIL; return OK; } - for (; *str != NUL; ++str) { + for (; *str != '\0'; ++str) { char_u *p; /* Check for a multi-byte character, which may contain escaped * K_SPECIAL and CSI bytes */ p = mb_unescape(&str); if (p != NULL) { - while (*p != NUL) + while (*p != '\0') if (fputc(*p++, fd) < 0) return FAIL; --str; @@ -4231,7 +4231,7 @@ void check_map_keycodes(void) if (*p < 128) { /* for "normal" tcap entries */ buf[0] = p[0]; buf[1] = p[1]; - buf[2] = NUL; + buf[2] = '\0'; (void)add_termcap_entry(buf, FALSE); } ++p; @@ -4296,7 +4296,7 @@ check_map ( minlen = len; s = mp->m_keys; if (ign_mod && s[0] == K_SPECIAL && s[1] == KS_MODIFIER - && s[2] != NUL) { + && s[2] != '\0') { s += 3; if (len > mp->m_keylen - 3) minlen = mp->m_keylen - 3; diff --git a/src/globals.h b/src/globals.h index d856a4c155..7d0681dc45 100644 --- a/src/globals.h +++ b/src/globals.h @@ -550,7 +550,7 @@ EXTERN colnr_T ai_col INIT(= 0); * the "end" comment leader when the COM_AUTO_END flag is given for that * comment end in 'comments'. It is only valid when did_ai is TRUE. */ -EXTERN int end_comment_pending INIT(= NUL); +EXTERN int end_comment_pending INIT(= '\0'); /* * This flag is set after a ":syncbind" to let the check_scrollbind() function @@ -900,12 +900,12 @@ EXTERN char_u *globaldir INIT(= NULL); /* Characters from 'listchars' option */ EXTERN int lcs_eol INIT(= '$'); -EXTERN int lcs_ext INIT(= NUL); -EXTERN int lcs_prec INIT(= NUL); -EXTERN int lcs_nbsp INIT(= NUL); -EXTERN int lcs_tab1 INIT(= NUL); -EXTERN int lcs_tab2 INIT(= NUL); -EXTERN int lcs_trail INIT(= NUL); +EXTERN int lcs_ext INIT(= '\0'); +EXTERN int lcs_prec INIT(= '\0'); +EXTERN int lcs_nbsp INIT(= '\0'); +EXTERN int lcs_tab1 INIT(= '\0'); +EXTERN int lcs_tab2 INIT(= '\0'); +EXTERN int lcs_trail INIT(= '\0'); EXTERN int lcs_conceal INIT(= '-'); /* Characters from 'fillchars' option */ diff --git a/src/hardcopy.c b/src/hardcopy.c index 2e8939eece..f6636aa561 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -441,7 +441,7 @@ static void prt_header(prt_settings_T *psettings, int pagenum, linenr_T lnum) tbuf = xmalloc(width + IOSIZE); - if (*p_header != NUL) { + if (*p_header != '\0') { linenr_T tmp_lnum, tmp_topline, tmp_botline; int use_sandbox = FALSE; @@ -478,7 +478,7 @@ static void prt_header(prt_settings_T *psettings, int pagenum, linenr_T lnum) /* Use a negative line number to indicate printing in the top margin. */ page_line = 0 - prt_header_height(); mch_print_start_line(TRUE, page_line); - for (p = tbuf; *p != NUL; ) { + for (p = tbuf; *p != '\0'; ) { if (mch_print_text_out(p, (l = (*mb_ptr2len)(p)) )) { @@ -535,7 +535,7 @@ void ex_hardcopy(exarg_T *eap) return; } settings.outfile = skipwhite(eap->arg + 1); - } else if (*eap->arg != NUL) + } else if (*eap->arg != '\0') settings.arguments = eap->arg; /* @@ -778,7 +778,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T /* * Loop over the columns until the end of the file line or right margin. */ - for (col = ppos->column; line[col] != NUL && !need_break; col += outputlen) { + for (col = ppos->column; line[col] != '\0' && !need_break; col += outputlen) { outputlen = 1; if (has_mbyte && (outputlen = (*mb_ptr2len)(line + col)) < 1) outputlen = 1; @@ -843,7 +843,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T * line, unless we are doing a formfeed. */ if (!ppos->ff - && (line[col] == NUL + && (line[col] == '\0' || (printer_opts[OPT_PRINT_WRAP].present && TOLOWER_ASC(printer_opts[OPT_PRINT_WRAP].string[0]) == 'n'))) @@ -1584,7 +1584,7 @@ static void prt_resource_name(char_u *filename, void *cookie) char_u *resource_filename = cookie; if (STRLEN(filename) >= MAXPATHL) - *resource_filename = NUL; + *resource_filename = '\0'; else STRCPY(resource_filename, filename); } @@ -1602,10 +1602,10 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource) add_pathsep(buffer); vim_strcat(buffer, (char_u *)name, MAXPATHL); vim_strcat(buffer, (char_u *)".ps", MAXPATHL); - resource->filename[0] = NUL; + resource->filename[0] = '\0'; retval = (do_in_runtimepath(buffer, FALSE, prt_resource_name, resource->filename) - && resource->filename[0] != NUL); + && resource->filename[0] != '\0'); vim_free(buffer); return retval; } @@ -1746,7 +1746,7 @@ static int prt_open_resource(struct prt_ps_resource_S *resource) EMSG2(_("E624: Can't open file \"%s\""), resource->filename); return FALSE; } - memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN); + memset(prt_resfile.buffer, '\0', PRT_FILE_BUFFER_LEN); /* Parse first line to ensure valid resource file */ prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u), @@ -2149,7 +2149,7 @@ static int prt_match_charset(char *p_charset, struct prt_ps_mbfont_S *p_cmap, st struct prt_ps_charset_S *p_mbchar; /* Look for recognised character set, using default if one is not given */ - if (*p_charset == NUL) + if (*p_charset == '\0') p_charset = p_cmap->defcs; char_len = (int)STRLEN(p_charset); p_mbchar = p_cmap->charsets; @@ -2186,7 +2186,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) * Set up font and encoding. */ p_encoding = enc_skip(p_penc); - if (*p_encoding == NUL) + if (*p_encoding == '\0') p_encoding = enc_skip(p_enc); /* Look for a multi-byte font that matches the encoding and character set. @@ -2195,7 +2195,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) * uniquely identify a CJK character set to use. */ p_mbenc = NULL; props = enc_canon_props(p_encoding); - if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE))) { + if (!(props & ENC_8BIT) && ((*p_pmcs != '\0') || !(props & ENC_UNICODE))) { p_mbenc_first = NULL; for (cmap = 0; cmap < (int)NUM_ELEMENTS(prt_ps_mbfonts); cmap++) if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap], @@ -2215,7 +2215,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) prt_out_mbyte = (p_mbenc != NULL); if (prt_out_mbyte) { /* Build CMap name - will be same for all multi-byte fonts used */ - prt_cmap[0] = NUL; + prt_cmap[0] = '\0'; prt_custom_cmap = (p_mbchar == NULL); if (!prt_custom_cmap) { @@ -2233,7 +2233,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) } } else { /* Add custom CMap character set name */ - if (*p_pmcs == NUL) { + if (*p_pmcs == '\0') { EMSG(_("E674: printmbcharset cannot be empty with multi-byte encoding.")); return FALSE; } @@ -2527,7 +2527,7 @@ int mch_print_begin(prt_settings_T *psettings) /* Note: ctime() adds a \n so we have to remove it :-( */ p = vim_strchr((char_u *)p_time, '\n'); if (p != NULL) - *p = NUL; + *p = '\0'; prt_dsc_textline("CreationDate", p_time); prt_dsc_textline("DocumentData", "Clean8Bit"); prt_dsc_textline("Orientation", "Portrait"); @@ -2605,7 +2605,7 @@ int mch_print_begin(prt_settings_T *psettings) */ if (!prt_out_mbyte) { p_encoding = enc_skip(p_penc); - if (*p_encoding == NUL + if (*p_encoding == '\0' || !prt_find_resource((char *)p_encoding, res_encoding)) { /* 'printencoding' not set or not supported - find alternate */ int props; @@ -2630,7 +2630,7 @@ int mch_print_begin(prt_settings_T *psettings) * perform */ } else { p_encoding = enc_skip(p_penc); - if (*p_encoding == NUL) + if (*p_encoding == '\0') p_encoding = enc_skip(p_enc); if (prt_use_courier) { /* Include ASCII range encoding vector */ @@ -3119,7 +3119,7 @@ int mch_print_text_out(char_u *p, int len) } /* Need to free any translated characters */ - if (prt_do_conv && (*p != NUL)) + if (prt_do_conv && (*p != '\0')) vim_free(p); prt_text_run += char_width; diff --git a/src/hashtab.c b/src/hashtab.c index 1d3587b3ea..72928f8f0c 100644 --- a/src/hashtab.c +++ b/src/hashtab.c @@ -423,7 +423,7 @@ hash_T hash_hash(char_u *key) // A simplistic algorithm that appears to do very well. // Suggested by George Reilly. - while (*p != NUL) { + while (*p != '\0') { hash = hash * 101 + *p++; } diff --git a/src/if_cscope.c b/src/if_cscope.c index 2f283774fc..dc0768f278 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -181,11 +181,11 @@ void set_context_in_cscope_cmd(expand_T *xp, char_u *arg, cmdidx_T cmdidx) ? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD; /* (part of) subcommand already typed */ - if (*arg != NUL) { + if (*arg != '\0') { p = skiptowhite(arg); - if (*p != NUL) { /* past first word */ + if (*p != '\0') { /* past first word */ xp->xp_pattern = skipwhite(p); - if (*skiptowhite(xp->xp_pattern) != NUL) + if (*skiptowhite(xp->xp_pattern) != '\0') xp->xp_context = EXPAND_NOTHING; else if (STRNICMP(arg, "add", p - arg) == 0) xp->xp_context = EXPAND_FILES; @@ -262,7 +262,7 @@ void do_cstag(exarg_T *eap) { int ret = FALSE; - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { (void)EMSG(_("E562: Usage: cstag <ident>")); return; } @@ -598,7 +598,7 @@ static int cs_check_for_connections(void) static int cs_check_for_tags(void) { - return p_tags[0] != NUL && curbuf->b_p_tags != NULL; + return p_tags[0] != '\0' && curbuf->b_p_tags != NULL; } /* cs_check_for_tags */ /* @@ -960,7 +960,7 @@ static int cs_find(exarg_T *eap) * spaces to correctly display the quickfix/location list window's title. */ for (i = 0; i < eap_arg_len; ++i) - if (NUL == eap->arg[i]) + if ('\0' == eap->arg[i]) eap->arg[i] = ' '; return cs_find_common(opt, pat, eap->forceit, TRUE, @@ -1881,11 +1881,11 @@ static int cs_read_prompt(int i) if (buf != NULL) { /* append character to the message */ buf[bufpos++] = ch; - buf[bufpos] = NUL; + buf[bufpos] = '\0'; if (bufpos >= epromptlen && strcmp(&buf[bufpos - epromptlen], eprompt) == 0) { /* remove eprompt from buf */ - buf[bufpos - epromptlen] = NUL; + buf[bufpos - epromptlen] = '\0'; /* print message to user */ (void)EMSG2(cs_emsg, buf); @@ -1896,7 +1896,7 @@ static int cs_read_prompt(int i) /* clear buf */ bufpos = 0; - buf[bufpos] = NUL; + buf[bufpos] = '\0'; } } } @@ -1906,7 +1906,7 @@ static int cs_read_prompt(int i) ch = getc(csinfo[i].fr_fp); if (ch == EOF) { PERROR("cs_read_prompt EOF"); - if (buf != NULL && buf[0] != NUL) + if (buf != NULL && buf[0] != '\0') (void)EMSG2(cs_emsg, buf); else if (p_csverbose) cs_reading_emsg(i); /* don't have additional information */ @@ -2159,7 +2159,7 @@ static char *cs_resolve_file(int i, char *name) ) { fullname = xmalloc(len); (void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name); - } else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL) { + } else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != '\0') { /* Check for csdir to be non empty to avoid empty path concatenated to * cscope output. */ fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE); diff --git a/src/indent.c b/src/indent.c index 10530b71f8..05db6838b7 100644 --- a/src/indent.c +++ b/src/indent.c @@ -418,7 +418,7 @@ int get_number_indent(linenr_T lnum) vim_regfree(regmatch.regprog); } - if ((pos.lnum == 0) || (*ml_get_pos(&pos) == NUL)) { + if ((pos.lnum == 0) || (*ml_get_pos(&pos) == '\0')) { return -1; } getvcol(curwin, &pos, &col, NULL, NULL); @@ -548,29 +548,29 @@ int get_lisp_indent(void) continue; } - for (that = ml_get_curline(); *that != NUL; ++that) { + for (that = ml_get_curline(); *that != '\0'; ++that) { if (*that == ';') { - while (*(that + 1) != NUL) { + while (*(that + 1) != '\0') { that++; } continue; } if (*that == '\\') { - if (*(that + 1) != NUL) { + if (*(that + 1) != '\0') { that++; } continue; } - if ((*that == '"') && (*(that + 1) != NUL)) { + if ((*that == '"') && (*(that + 1) != '\0')) { while (*++that && *that != '"') { // Skipping escaped characters in the string if (*that == '\\') { - if (*++that == NUL) { + if (*++that == '\0') { break; } - if (that[1] == NUL) { + if (that[1] == '\0') { that++; break; } @@ -649,7 +649,7 @@ int get_lisp_indent(void) if (((*that == ')') || (*that == ']')) && !quotecount) { parencount--; } - if ((*that == '\\') && (*(that + 1) != NUL)) { + if ((*that == '\\') && (*(that + 1) != '\0')) { amount += lbr_chartabsize_adv(&that, (colnr_T)amount); } @@ -684,7 +684,7 @@ static int lisp_match(char_u *p) int len; char_u *word = p_lispwords; - while (*word != NUL) { + while (*word != '\0') { (void)copy_option_part(&word, buf, LSIZE, ","); len = (int)STRLEN(buf); diff --git a/src/indent_c.c b/src/indent_c.c index 08b28c73f2..8b90b0f855 100644 --- a/src/indent_c.c +++ b/src/indent_c.c @@ -83,7 +83,7 @@ static char_u *skip_string(char_u *p) } } else if (p[0] == '"') { /* start of string */ for (++p; p[0]; ++p) { - if (p[0] == '\\' && p[1] != NUL) + if (p[0] == '\\' && p[1] != '\0') ++p; else if (p[0] == '"') /* end of string */ break; @@ -214,7 +214,7 @@ static char_u *cin_skipcomment(char_u *s) */ static int cin_nocode(char_u *s) { - return *cin_skipcomment(s) == NUL; + return *cin_skipcomment(s) == '\0'; } /* @@ -234,7 +234,7 @@ static pos_T *find_line_comment(void) /* XXX */ pos.col = (int)(p - line); return &pos; } - if (*p != NUL) + if (*p != '\0') break; } return NULL; @@ -299,7 +299,7 @@ int cin_islabel(void) line = ml_get_curline(); if (cin_ispreproc(line)) /* ignore #defines, #if, etc. */ continue; - if (*(line = cin_skipcomment(line)) == NUL) + if (*(line = cin_skipcomment(line)) == '\0') continue; curwin->w_cursor = cursor_save; @@ -435,9 +435,9 @@ static int cin_is_cpp_namespace(char_u *s) int has_name = FALSE; s = cin_skipcomment(s); - if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9]))) { + if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == '\0' || !vim_iswordc(s[9]))) { p = cin_skipcomment(skipwhite(s + 9)); - while (*p != NUL) { + while (*p != '\0') { if (vim_iswhite(*p)) { has_name = TRUE; /* found end of a name */ p = cin_skipcomment(skipwhite(p)); @@ -473,10 +473,10 @@ static char_u *after_label(char_u *l) } else if (*l == '\'' && l[1] && l[2] == '\'') l += 2; /* skip over 'x' */ } - if (*l == NUL) + if (*l == '\0') return NULL; l = cin_skipcomment(l + 1); - if (*l == NUL) + if (*l == '\0') return NULL; return l; } @@ -601,12 +601,12 @@ static int cin_get_equal_amount(linenr_T lnum) if (lnum > 1) { line = ml_get(lnum - 1); - if (*line != NUL && line[STRLEN(line) - 1] == '\\') + if (*line != '\0' && line[STRLEN(line) - 1] == '\\') return -1; } line = s = ml_get(lnum); - while (*s != NUL && vim_strchr((char_u *)"=;{}\"'", *s) == NULL) { + while (*s != '\0' && vim_strchr((char_u *)"=;{}\"'", *s) == NULL) { if (cin_iscomment(s)) /* ignore comments */ s = cin_skipcomment(s); else @@ -658,7 +658,7 @@ static int cin_ispreproc_cont(char_u **pp, linenr_T *lnump) if (lnum == 1) break; line = ml_get(--lnum); - if (*line == NUL || line[STRLEN(line) - 1] != '\\') + if (*line == '\0' || line[STRLEN(line) - 1] != '\\') break; } @@ -787,11 +787,11 @@ static int cin_isfuncdecl(char_u **sp, linenr_T first_lnum, linenr_T min_lnum) */ lnum = first_lnum - 1; s = ml_get(lnum); - if (*s == NUL || s[STRLEN(s) - 1] != '\\') + if (*s == '\0' || s[STRLEN(s) - 1] != '\\') retval = TRUE; goto done; } - if ((*s == ',' && cin_nocode(s + 1)) || s[1] == NUL || cin_nocode(s)) { + if ((*s == ',' && cin_nocode(s + 1)) || s[1] == '\0' || cin_nocode(s)) { int comma = (*s == ','); /* ',' at the end: continue looking in the next line. @@ -941,7 +941,7 @@ static int cin_iswhileofdo_end(int terminated) return FALSE; p = line = ml_get_curline(); - while (*p != NUL) { + while (*p != '\0') { p = cin_skipcomment(p); if (*p == ')') { s = skipwhite(p + 1); @@ -966,7 +966,7 @@ static int cin_iswhileofdo_end(int terminated) p = line + i; } } - if (*p != NUL) + if (*p != '\0') ++p; } return FALSE; @@ -1006,7 +1006,7 @@ cin_is_cpp_baseclass ( if (*s == '#') /* skip #define FOO x ? (x) : x */ return FALSE; s = cin_skipcomment(s); - if (*s == NUL) + if (*s == '\0') return FALSE; cpp_base_class = lookfor_ctor_init = class_or_struct = FALSE; @@ -1027,17 +1027,17 @@ cin_is_cpp_baseclass ( while (lnum > 1) { line = ml_get(lnum - 1); s = skipwhite(line); - if (*s == '#' || *s == NUL) + if (*s == '#' || *s == '\0') break; - while (*s != NUL) { + while (*s != '\0') { s = cin_skipcomment(s); if (*s == '{' || *s == '}' || (*s == ';' && cin_nocode(s + 1))) break; - if (*s != NUL) + if (*s != '\0') ++s; } - if (*s != NUL) + if (*s != '\0') break; --lnum; } @@ -1045,13 +1045,13 @@ cin_is_cpp_baseclass ( line = ml_get(lnum); s = cin_skipcomment(line); for (;; ) { - if (*s == NUL) { + if (*s == '\0') { if (lnum == curwin->w_cursor.lnum) break; /* Continue in the cursor line. */ line = ml_get(++lnum); s = cin_skipcomment(line); - if (*s == NUL) + if (*s == '\0') continue; } @@ -1150,7 +1150,7 @@ static int cin_ends_in(char_u *s, char_u *find, char_u *ignore) char_u *r; int len = (int)STRLEN(find); - while (*p != NUL) { + while (*p != '\0') { p = cin_skipcomment(p); if (STRNCMP(p, find, len) == 0) { r = skipwhite(p + len); @@ -1159,7 +1159,7 @@ static int cin_ends_in(char_u *s, char_u *find, char_u *ignore) if (cin_nocode(r)) return TRUE; } - if (*p != NUL) + if (*p != '\0') ++p; } return FALSE; @@ -1286,7 +1286,7 @@ static int find_last_paren(char_u *l, int start, int end) curwin->w_cursor.col = 0; /* default is start of line */ - for (i = 0; l[i] != NUL; i++) { + for (i = 0; l[i] != '\0'; i++) { i = (int)(cin_skipcomment(l + i) - l); /* ignore parens in comments */ i = (int)(skip_string(l + i) - l); /* ignore parens in quotes */ if (l[i] == start) @@ -1586,7 +1586,7 @@ int get_c_indent(void) if ((State & INSERT) && curwin->w_cursor.col < (colnr_T)STRLEN(linecopy) && linecopy[curwin->w_cursor.col] == ')') - linecopy[curwin->w_cursor.col] = NUL; + linecopy[curwin->w_cursor.col] = '\0'; theline = skipwhite(linecopy); @@ -1641,16 +1641,16 @@ int get_c_indent(void) /* find how indented the line beginning the comment is */ getvcol(curwin, trypos, &col, NULL, NULL); amount = col; - *lead_start = NUL; - *lead_middle = NUL; + *lead_start = '\0'; + *lead_middle = '\0'; p = curbuf->b_p_com; - while (*p != NUL) { + while (*p != '\0') { int align = 0; int off = 0; int what = 0; - while (*p != NUL && *p != ':') { + while (*p != '\0' && *p != ':') { if (*p == COM_START || *p == COM_END || *p == COM_MIDDLE) what = *p++; else if (*p == COM_LEFT || *p == COM_RIGHT) @@ -1749,12 +1749,12 @@ int get_c_indent(void) if (!curbuf->b_ind_in_comment2) { start = ml_get(trypos->lnum); look = start + trypos->col + 2; /* skip / and * */ - if (*look != NUL) /* if something after it */ + if (*look != '\0') /* if something after it */ trypos->col = (colnr_T)(skipwhite(look) - start); } getvcol(curwin, trypos, &col, NULL, NULL); amount = col; - if (curbuf->b_ind_in_comment2 || *look == NUL) + if (curbuf->b_ind_in_comment2 || *look == '\0') amount += curbuf->b_ind_in_comment; } } @@ -1919,7 +1919,7 @@ int get_c_indent(void) col = our_paren_pos.col + 1; while (vim_iswhite(l[col])) col++; - if (l[col] != NUL) /* In case of trailing space */ + if (l[col] != '\0') /* In case of trailing space */ our_paren_pos.col = col; else our_paren_pos.col++; @@ -2561,7 +2561,7 @@ int get_c_indent(void) if (terminated == ',') { while (curwin->w_cursor.lnum > 1) { l = ml_get(curwin->w_cursor.lnum - 1); - if (*l == NUL || l[STRLEN(l) - 1] != '\\') + if (*l == '\0' || l[STRLEN(l) - 1] != '\\') break; --curwin->w_cursor.lnum; curwin->w_cursor.col = 0; @@ -2746,7 +2746,7 @@ int get_c_indent(void) cont_amount = cin_first_id_amount(); } else { if (lookfor == LOOKFOR_INITIAL - && *l != NUL + && *l != '\0' && l[STRLEN(l) - 1] == '\\') /* XXX */ cont_amount = cin_get_equal_amount( @@ -3053,7 +3053,7 @@ term_again: */ n = 0; if (cin_ends_in(l, (char_u *)",", NULL) - || (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\')) { + || (*l != '\0' && (n = l[STRLEN(l) - 1]) == '\\')) { /* take us back to opening paren */ if (find_last_paren(l, '(', ')') && (trypos = find_match_paren( @@ -3068,7 +3068,7 @@ term_again: */ while (n == 0 && curwin->w_cursor.lnum > 1) { l = ml_get(curwin->w_cursor.lnum - 1); - if (*l == NUL || l[STRLEN(l) - 1] != '\\') + if (*l == '\0' || l[STRLEN(l) - 1] != '\\') break; --curwin->w_cursor.lnum; curwin->w_cursor.col = 0; @@ -3148,7 +3148,7 @@ term_again: if (cin_ends_in(l, (char_u *)";", NULL)) { l = ml_get(curwin->w_cursor.lnum - 1); if (cin_ends_in(l, (char_u *)",", NULL) - || (*l != NUL && l[STRLEN(l) - 1] == '\\')) + || (*l != '\0' && l[STRLEN(l) - 1] == '\\')) break; l = ml_get_curline(); } @@ -3180,7 +3180,7 @@ term_again: */ if (cur_curpos.lnum > 1) { l = ml_get(cur_curpos.lnum - 1); - if (*l != NUL && l[STRLEN(l) - 1] == '\\') { + if (*l != '\0' && l[STRLEN(l) - 1] == '\\') { cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1); if (cur_amount > 0) amount = cur_amount; @@ -3309,7 +3309,7 @@ static int find_match(int lookfor, linenr_T ourscope) */ void do_c_expr_indent(void) { - if (*curbuf->b_p_inde != NUL) + if (*curbuf->b_p_inde != '\0') fixthisline(get_expr_indent); else fixthisline(get_c_indent); diff --git a/src/keymap.c b/src/keymap.c index bec179c913..02d5903272 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -29,7 +29,7 @@ static struct modmasktable { {MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, (char_u)'4'}, /* 'A' must be the last one */ {MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'A'}, - {0, 0, NUL} + {0, 0, '\0'} }; /* @@ -125,7 +125,7 @@ static char_u modifier_keys_table[] = /* TAB pseudo code*/ MOD_MASK_SHIFT, 'k', 'B', KS_EXTRA, (int)KE_TAB, - NUL + '\0' }; static struct key_name_entry { @@ -349,7 +349,7 @@ int simplify_key(int key, int *modifiers) } key0 = KEY2TERMCAP0(key); key1 = KEY2TERMCAP1(key); - for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) + for (i = 0; modifier_keys_table[i] != '\0'; i += MOD_KEYS_ENTRY_SIZE) if (key0 == modifier_keys_table[i + 3] && key1 == modifier_keys_table[i + 4] && (*modifiers & modifier_keys_table[i])) { @@ -477,7 +477,7 @@ char_u *get_special_key_name(int c, int modifiers) idx = (int)STRLEN(string); } string[idx++] = '>'; - string[idx] = NUL; + string[idx] = '\0'; return string; } @@ -555,7 +555,7 @@ find_special_key ( for (bp = src + 1; *bp == '-' || vim_isIDc(*bp); bp++) { if (*bp == '-') { last_dash = bp; - if (bp[1] != NUL) { + if (bp[1] != '\0') { if (has_mbyte) l = mb_ptr2len(bp + 1); else @@ -617,7 +617,7 @@ find_special_key ( * get_special_key_code() may return NUL for invalid * special key name. */ - if (key != NUL) { + if (key != '\0') { /* * Only use a modifier when there is no special key code that * includes the modifier. @@ -711,19 +711,19 @@ int get_special_key_code(char_u *name) /* * If it's <t_xx> we get the code for xx from the termcap */ - if (name[0] == 't' && name[1] == '_' && name[2] != NUL && name[3] != NUL) { + if (name[0] == 't' && name[1] == '_' && name[2] != '\0' && name[3] != '\0') { string[0] = name[2]; string[1] = name[3]; - string[2] = NUL; + string[2] = '\0'; if (add_termcap_entry(string, FALSE) == OK) return TERMCAP2KEY(name[2], name[3]); } else for (i = 0; key_names_table[i].name != NULL; i++) { table_name = key_names_table[i].name; - for (j = 0; vim_isIDc(name[j]) && table_name[j] != NUL; j++) + for (j = 0; vim_isIDc(name[j]) && table_name[j] != '\0'; j++) if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) break; - if (!vim_isIDc(name[j]) && table_name[j] == NUL) + if (!vim_isIDc(name[j]) && table_name[j] == '\0') return key_names_table[i].key; } return 0; diff --git a/src/keymap.h b/src/keymap.h index 244e9b3ddf..da968dba00 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -131,10 +131,10 @@ * get second or third byte when translating special key code into three bytes */ #define K_SECOND(c) ((c) == K_SPECIAL ? KS_SPECIAL : (c) == \ - NUL ? KS_ZERO : KEY2TERMCAP0(c)) + '\0' ? KS_ZERO : KEY2TERMCAP0(c)) #define K_THIRD(c) (((c) == K_SPECIAL || (c) == \ - NUL) ? KE_FILLER : KEY2TERMCAP1(c)) + '\0') ? KE_FILLER : KEY2TERMCAP1(c)) /* * get single int code from second byte after K_SPECIAL diff --git a/src/macros.h b/src/macros.h index 8dd412f838..7793ab326c 100644 --- a/src/macros.h +++ b/src/macros.h @@ -31,13 +31,13 @@ /* * lineempty() - return TRUE if the line is empty */ -#define lineempty(p) (*ml_get(p) == NUL) +#define lineempty(p) (*ml_get(p) == '\0') /* * bufempty() - return TRUE if the current buffer is empty */ #define bufempty() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == \ - NUL) + '\0') /* * toupper() and tolower() that use the current locale. diff --git a/src/main.c b/src/main.c index 105f676bbd..83886b94b0 100644 --- a/src/main.c +++ b/src/main.c @@ -375,7 +375,7 @@ static char *(main_errors[]) = * Read in registers, history etc, but not marks, from the viminfo file. * This is where v:oldfiles gets filled. */ - if (*p_viminfo != NUL) { + if (*p_viminfo != '\0') { read_viminfo(NULL, VIF_WANT_INFO | VIF_GET_OLDFILES); TIME_MSG("reading viminfo"); } @@ -413,7 +413,7 @@ static char *(main_errors[]) = #if defined(UNIX) /* When switching screens and something caused a message from a vimrc * script, need to output an extra newline on exit. */ - if ((did_emsg || msg_didout) && *T_TI != NUL) + if ((did_emsg || msg_didout) && *T_TI != '\0') newline_on_exit = TRUE; #endif @@ -830,7 +830,7 @@ void getout(int exitval) apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); } - if (p_viminfo && *p_viminfo != NUL) + if (p_viminfo && *p_viminfo != '\0') /* Write out the registers, history, marks etc, to the viminfo file */ write_viminfo(NULL, FALSE); @@ -899,7 +899,7 @@ static void init_locale(void) /* expand_env() doesn't work yet, because chartab[] is not initialized * yet, call vim_getenv() directly */ p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree); - if (p != NULL && *p != NUL) { + if (p != NULL && *p != '\0') { vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p); bindtextdomain(VIMPACKAGE, (char *)NameBuff); } @@ -1012,7 +1012,7 @@ static void command_line_scan(mparm_T *parmp) if (parmp->n_commands >= MAX_ARG_CMDS) mainerr(ME_EXTRA_CMD, NULL); argv_idx = -1; /* skip to next argument */ - if (argv[0][1] == NUL) + if (argv[0][1] == '\0') parmp->commands[parmp->n_commands++] = (char_u *)"$"; else parmp->commands[parmp->n_commands++] = (char_u *)&(argv[0][1]); @@ -1024,7 +1024,7 @@ static void command_line_scan(mparm_T *parmp) want_argument = FALSE; c = argv[0][argv_idx++]; switch (c) { - case NUL: /* "vim -" read from stdin */ + case '\0': /* "vim -" read from stdin */ /* "ex -" silent mode */ if (exmode_active) silent_mode = TRUE; @@ -1226,7 +1226,7 @@ static void command_line_scan(mparm_T *parmp) case 'V': /* "-V{N}" Verbose level */ /* default is 10: a little bit verbose */ p_verbose = get_number_arg((char_u *)argv[0], &argv_idx, 10); - if (argv[0][argv_idx] != NUL) { + if (argv[0][argv_idx] != '\0') { set_option_value((char_u *)"verbosefile", 0L, (char_u *)argv[0] + argv_idx, 0); argv_idx = (int)STRLEN(argv[0]); @@ -1260,7 +1260,7 @@ static void command_line_scan(mparm_T *parmp) case 'c': /* "-c{command}" or "-c {command}" execute command */ - if (argv[0][argv_idx] != NUL) { + if (argv[0][argv_idx] != '\0') { if (parmp->n_commands >= MAX_ARG_CMDS) mainerr(ME_EXTRA_CMD, NULL); parmp->commands[parmp->n_commands++] = (char_u *)argv[0] @@ -1289,7 +1289,7 @@ static void command_line_scan(mparm_T *parmp) /* * Check for garbage immediately after the option letter. */ - if (argv[0][argv_idx] != NUL) + if (argv[0][argv_idx] != '\0') mainerr(ME_GARBAGE, (char_u *)argv[0]); --argc; @@ -1456,7 +1456,7 @@ scripterror: * argument. argv_idx is set to -1 when the current argument is to be * skipped. */ - if (argv_idx <= 0 || argv[0][argv_idx] == NUL) { + if (argv_idx <= 0 || argv[0][argv_idx] == '\0') { --argc; ++argv; argv_idx = 1; @@ -2102,7 +2102,7 @@ process_env ( scid_T save_sid; initstr = (char_u *)os_getenv((char *)env); - if (initstr != NULL && *initstr != NUL) { + if (initstr != NULL && *initstr != '\0') { if (is_viminit) vimrc_found(NULL, NULL); save_sourcing_name = sourcing_name; diff --git a/src/mark.c b/src/mark.c index bd37f93eb1..09eb8a845a 100644 --- a/src/mark.c +++ b/src/mark.c @@ -110,7 +110,7 @@ int setmark_pos(int c, pos_T *pos, int fnum) curbuf->b_visual.vi_start = *pos; else curbuf->b_visual.vi_end = *pos; - if (curbuf->b_visual.vi_mode == NUL) + if (curbuf->b_visual.vi_mode == '\0') /* Visual_mode has not yet been set, use a sane default. */ curbuf->b_visual.vi_mode = 'v'; return OK; @@ -336,7 +336,7 @@ pos_T *getmark_buf_fnum(buf_T *buf, int c, int changefile, int *fnum) pos = curwin->w_cursor; listcmd_busy = TRUE; /* avoid that '' is changed */ if (findpar(&oa.inclusive, - c == '}' ? FORWARD : BACKWARD, 1L, NUL, FALSE)) { + c == '}' ? FORWARD : BACKWARD, 1L, '\0', FALSE)) { pos_copy = curwin->w_cursor; posp = &pos_copy; } @@ -609,12 +609,12 @@ static char_u *mark_line(pos_T *mp, int lead_len) return NULL; /* Truncate the line to fit it in the window */ len = 0; - for (p = s; *p != NUL; mb_ptr_adv(p)) { + for (p = s; *p != '\0'; mb_ptr_adv(p)) { len += ptr2cells(p); if (len >= Columns - lead_len) break; } - *p = NUL; + *p = '\0'; return s; } @@ -627,7 +627,7 @@ void do_marks(exarg_T *eap) int i; char_u *name; - if (arg != NULL && *arg == NUL) + if (arg != NULL && *arg == '\0') arg = NULL; show_one_mark('\'', arg, &curwin->w_pcmark, NULL, TRUE); @@ -717,16 +717,16 @@ void ex_delmarks(exarg_T *eap) int digit; int n; - if (*eap->arg == NUL && eap->forceit) + if (*eap->arg == '\0' && eap->forceit) /* clear all marks */ clrallmarks(curbuf); else if (eap->forceit) EMSG(_(e_invarg)); - else if (*eap->arg == NUL) + else if (*eap->arg == '\0') EMSG(_(e_argreq)); else { /* clear specified marks only */ - for (p = eap->arg; *p != NUL; ++p) { + for (p = eap->arg; *p != '\0'; ++p) { lower = ASCII_ISLOWER(*p); digit = VIM_ISDIGIT(*p); if (lower || digit || ASCII_ISUPPER(*p)) { @@ -1293,7 +1293,7 @@ static void write_one_filemark(FILE *fp, xfmark_T *fm, int c1, int c2) name = buflist_nr2name(fm->fmark.fnum, TRUE, FALSE); else name = fm->fname; /* use name from .viminfo */ - if (name != NULL && *name != NUL) { + if (name != NULL && *name != '\0') { fprintf(fp, "%c%c %" PRId64 " %" PRId64 " ", c1, c2, (int64_t)fm->fmark.mark.lnum, (int64_t)fm->fmark.mark.col); viminfo_writestring(fp, name); @@ -1370,7 +1370,7 @@ int write_viminfo_marks(FILE *fp_out) } } if (is_mark_set && buf->b_ffname != NULL - && buf->b_ffname[0] != NUL && !removable(buf->b_ffname)) { + && buf->b_ffname[0] != '\0' && !removable(buf->b_ffname)) { home_replace(NULL, buf->b_ffname, IObuff, IOSIZE, TRUE); fprintf(fp_out, "\n> "); viminfo_writestring(fp_out, IObuff); @@ -1418,7 +1418,7 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags list_T *list = NULL; name_buf = alloc(LSIZE); - *name_buf = NUL; + *name_buf = '\0'; if (fp_out == NULL && (flags & (VIF_GET_OLDFILES | VIF_FORCEIT))) { list = list_alloc(); @@ -1447,11 +1447,11 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags if (str == NULL) continue; p = str + STRLEN(str); - while (p != str && (*p == NUL || vim_isspace(*p))) + while (p != str && (*p == '\0' || vim_isspace(*p))) p--; if (*p) p++; - *p = NUL; + *p = '\0'; if (list != NULL) list_append_string(list, str, -1); @@ -1463,7 +1463,7 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags load_marks = copy_marks_out = FALSE; if (fp_out == NULL) { if ((flags & VIF_WANT_MARKS) && curbuf->b_ffname != NULL) { - if (*name_buf == NUL) /* only need to do this once */ + if (*name_buf == '\0') /* only need to do this once */ home_replace(NULL, curbuf->b_ffname, name_buf, LSIZE, TRUE); if (fnamecmp(str, name_buf) == 0) load_marks = TRUE; @@ -1492,7 +1492,7 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags pos.coladd = 0; while (!(eof = viminfo_readline(virp)) && line[0] == TAB) { if (load_marks) { - if (line[1] != NUL) { + if (line[1] != '\0') { int64_t lnum_64; unsigned u; sscanf((char *)line + 2, "%" SCNd64 "%u", &lnum_64, &u); diff --git a/src/mbyte.c b/src/mbyte.c index f150b9b9ca..46471d1181 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -526,7 +526,7 @@ char_u * mb_init() n = 1; else { char buf[MB_MAXBYTES + 1]; - if (i == NUL) /* just in case mblen() can't handle "" */ + if (i == '\0') /* just in case mblen() can't handle "" */ n = 1; else { buf[0] = i; @@ -608,7 +608,7 @@ int bomb_size() int n = 0; if (curbuf->b_p_bomb && !curbuf->b_p_bin) { - if (*curbuf->b_p_fenc == NUL) { + if (*curbuf->b_p_fenc == '\0') { if (enc_utf8) { if (enc_unicode != 0) n = enc_unicode; @@ -658,13 +658,13 @@ int mb_get_class(char_u *p) int mb_get_class_buf(char_u *p, buf_T *buf) { if (MB_BYTE2LEN(p[0]) == 1) { - if (p[0] == NUL || vim_iswhite(p[0])) + if (p[0] == '\0' || vim_iswhite(p[0])) return 0; if (vim_iswordc_buf(p[0], buf)) return 2; return 1; } - if (enc_dbcs != 0 && p[0] != NUL && p[1] != NUL) + if (enc_dbcs != 0 && p[0] != '\0' && p[1] != '\0') return dbcs_class(p[0], p[1]); if (enc_utf8) return utf_class(utf_ptr2char(p)); @@ -849,7 +849,7 @@ static int dbcs_char2bytes(int c, char_u *buf) buf[1] = c; /* Never use a NUL byte, it causes lots of trouble. It's an invalid * character anyway. */ - if (buf[1] == NUL) + if (buf[1] == '\0') buf[1] = '\n'; return 2; } @@ -874,7 +874,7 @@ static int dbcs_ptr2len(char_u *p) /* Check if second byte is not missing. */ len = MB_BYTE2LEN(*p); - if (len == 2 && p[1] == NUL) + if (len == 2 && p[1] == '\0') len = 1; return len; } @@ -887,7 +887,7 @@ static int dbcs_ptr2len(char_u *p) */ int latin_ptr2len_len(char_u *p, int size) { - if (size < 1 || *p == NUL) + if (size < 1 || *p == '\0') return 0; return 1; } @@ -896,13 +896,13 @@ static int dbcs_ptr2len_len(char_u *p, int size) { int len; - if (size < 1 || *p == NUL) + if (size < 1 || *p == '\0') return 0; if (size == 1) return 1; /* Check that second byte is not missing. */ len = MB_BYTE2LEN(*p); - if (len == 2 && p[1] == NUL) + if (len == 2 && p[1] == '\0') len = 1; return len; } @@ -1225,7 +1225,7 @@ int utf_ptr2cells(char_u *p) if (*p >= 0x80) { c = utf_ptr2char(p); /* An illegal byte is displayed as <xx>. */ - if (utf_ptr2len(p) == 1 || c == NUL) + if (utf_ptr2len(p) == 1 || c == '\0') return 4; /* If the char is ASCII it must be an overlong sequence. */ if (c < 0x80) @@ -1264,7 +1264,7 @@ static int utf_ptr2cells_len(char_u *p, int size) return 1; /* truncated */ c = utf_ptr2char(p); /* An illegal byte is displayed as <xx>. */ - if (utf_ptr2len(p) == 1 || c == NUL) + if (utf_ptr2len(p) == 1 || c == '\0') return 4; /* If the char is ASCII it must be an overlong sequence. */ if (c < 0x80) @@ -1312,7 +1312,7 @@ int mb_string2cells(char_u *p, int len) int i; int clen = 0; - for (i = 0; (len < 0 || i < len) && p[i] != NUL; i += (*mb_ptr2len)(p + i)) + for (i = 0; (len < 0 || i < len) && p[i] != '\0'; i += (*mb_ptr2len)(p + i)) clen += (*mb_ptr2cells)(p + i); return clen; } @@ -1356,7 +1356,7 @@ int latin_ptr2char(char_u *p) static int dbcs_ptr2char(char_u *p) { - if (MB_BYTE2LEN(*p) > 1 && p[1] != NUL) + if (MB_BYTE2LEN(*p) > 1 && p[1] != '\0') return (p[0] << 8) + p[1]; return *p; } @@ -1614,7 +1614,7 @@ int utf_ptr2len(char_u *p) int len; int i; - if (*p == NUL) + if (*p == '\0') return 0; len = utf8len_tab[*p]; for (i = 1; i < len; ++i) @@ -1670,7 +1670,7 @@ int utfc_ptr2len(char_u *p) int b0 = *p; int prevlen; - if (b0 == NUL) + if (b0 == '\0') return 0; if (b0 < 0x80 && p[1] < 0x80) /* be quick for ASCII */ return 1; @@ -1708,7 +1708,7 @@ int utfc_ptr2len_len(char_u *p, int size) int len; int prevlen; - if (size < 1 || *p == NUL) + if (size < 1 || *p == '\0') return 0; if (p[0] < 0x80 && (size == 1 || p[1] < 0x80)) /* be quick for ASCII */ return 1; @@ -2132,7 +2132,7 @@ int utf_class(int c) /* First quick check for Latin1 characters, use 'iskeyword'. */ if (c < 0x100) { - if (c == ' ' || c == '\t' || c == NUL || c == 0xa0) + if (c == ' ' || c == '\t' || c == '\0' || c == 0xa0) return 0; /* blank */ if (vim_iswordc(c)) return 2; /* word character */ @@ -2781,7 +2781,7 @@ static int utf_strnicmp(char_u *s1, char_u *s2, size_t n1, size_t n2) s2 = buffer; } - while (n1 > 0 && n2 > 0 && *s1 != NUL && *s2 != NUL) { + while (n1 > 0 && n2 > 0 && *s1 != '\0' && *s2 != '\0') { cdiff = (int)(*s1) - (int)(*s2); if (cdiff != 0) return cdiff; @@ -2792,9 +2792,9 @@ static int utf_strnicmp(char_u *s1, char_u *s2, size_t n1, size_t n2) n2--; } - if (n1 > 0 && *s1 == NUL) + if (n1 > 0 && *s1 == '\0') n1 = 0; - if (n2 > 0 && *s2 == NUL) + if (n2 > 0 && *s2 == '\0') n2 = 0; if (n1 == 0 && n2 == 0) @@ -2820,7 +2820,7 @@ int mb_strnicmp(char_u *s1, char_u *s2, size_t nn) return utf_strnicmp(s1, s2, nn, nn); } else { for (i = 0; i < n; i += l) { - if (s1[i] == NUL && s2[i] == NUL) /* both strings end */ + if (s1[i] == '\0' && s2[i] == '\0') /* both strings end */ return 0; l = (*mb_ptr2len)(s1 + i); @@ -2861,7 +2861,7 @@ void show_utf8() line = ml_get_cursor(); len = utfc_ptr2len(line); if (len == 0) { - MSG("NUL"); + MSG("'\0'"); return; } @@ -2876,7 +2876,7 @@ void show_utf8() clen = utf_ptr2len(line + i); } sprintf((char *)IObuff + rlen, "%02x ", - (line[i] == NL) ? NUL : line[i]); /* NUL is stored as NL */ + (line[i] == NL) ? '\0' : line[i]); /* NUL is stored as NL */ --clen; rlen += (int)STRLEN(IObuff + rlen); if (rlen > IOSIZE - 20) @@ -2903,7 +2903,7 @@ int dbcs_head_off(char_u *base, char_u *p) /* It can't be a trailing byte when not using DBCS, at the start of the * string or the previous byte can't start a double-byte. */ - if (p <= base || MB_BYTE2LEN(p[-1]) == 1 || *p == NUL) + if (p <= base || MB_BYTE2LEN(p[-1]) == 1 || *p == '\0') return 0; /* This is slow: need to start at the base and go forward until the @@ -2929,7 +2929,7 @@ int dbcs_screen_head_off(char_u *base, char_u *p) if (p <= base || (enc_dbcs == DBCS_JPNU && p[-1] == 0x8e) || MB_BYTE2LEN(p[-1]) == 1 - || *p == NUL) + || *p == '\0') return 0; /* This is slow: need to start at the base and go forward until the @@ -3049,7 +3049,7 @@ int mb_tail_off(char_u *base, char_u *p) int i; int j; - if (*p == NUL) + if (*p == '\0') return 0; if (enc_utf8) { @@ -3067,7 +3067,7 @@ int mb_tail_off(char_u *base, char_u *p) /* It can't be the first byte if a double-byte when not using DBCS, at the * end of the string or the byte can't start a double-byte. */ - if (enc_dbcs == 0 || p[1] == NUL || MB_BYTE2LEN(*p) == 1) + if (enc_dbcs == 0 || p[1] == '\0' || MB_BYTE2LEN(*p) == 1) return 0; /* Return 1 when on the lead byte, 0 when on the tail byte. */ @@ -3104,7 +3104,7 @@ void utf_find_illegal() p = tofree; } - while (*p != NUL) { + while (*p != '\0') { /* Illegal means that there are not enough trail bytes (checked by * utf_ptr2len()) or too many of them (overlong sequence). */ len = utf_ptr2len(p); @@ -3116,7 +3116,7 @@ void utf_find_illegal() int l; len = (int)(p - tofree); - for (p = ml_get_cursor(); *p != NUL && len-- > 0; p += l) { + for (p = ml_get_cursor(); *p != '\0' && len-- > 0; p += l) { l = utf_ptr2len(p); curwin->w_cursor.col += l; } @@ -3198,7 +3198,7 @@ int mb_charlen(char_u *str) if (p == NULL) return 0; - for (count = 0; *p != NUL; count++) + for (count = 0; *p != '\0'; count++) p += (*mb_ptr2len)(p); return count; @@ -3212,7 +3212,7 @@ int mb_charlen_len(char_u *str, int len) char_u *p = str; int count; - for (count = 0; *p != NUL && p < str + len; count++) + for (count = 0; *p != '\0' && p < str + len; count++) p += (*mb_ptr2len)(p); return count; @@ -3235,7 +3235,7 @@ char_u * mb_unescape(char_u **pp) /* Must translate K_SPECIAL KS_SPECIAL KE_FILLER to K_SPECIAL and CSI * KS_EXTRA KE_CSI to CSI. * Maximum length of a utf-8 character is 4 bytes. */ - for (n = 0; str[n] != NUL && m < 4; ++n) { + for (n = 0; str[n] != '\0' && m < 4; ++n) { if (str[n] == K_SPECIAL && str[n + 1] == KS_SPECIAL && str[n + 2] == KE_FILLER) { @@ -3252,7 +3252,7 @@ char_u * mb_unescape(char_u **pp) break; /* a special key can't be a multibyte char */ else buf[m++] = str[n]; - buf[m] = NUL; + buf[m] = '\0'; /* Return a multi-byte character if it's found. An illegal sequence * will result in a 1 here. */ @@ -3289,7 +3289,7 @@ int mb_fix_col(int col, int row) row = check_row(row); if (has_mbyte && ScreenLines != NULL && col > 0 && ((enc_dbcs - && ScreenLines[LineOffset[row] + col] != NUL + && ScreenLines[LineOffset[row] + col] != '\0' && dbcs_screen_head_off(ScreenLines + LineOffset[row], ScreenLines + LineOffset[row] + col)) || (enc_utf8 && ScreenLines[LineOffset[row] + col] == 0))) @@ -3335,13 +3335,13 @@ char_u * enc_canonize(char_u *enc) r = alloc((unsigned)(STRLEN(enc) + 3)); /* Make it all lower case and replace '_' with '-'. */ p = r; - for (s = enc; *s != NUL; ++s) { + for (s = enc; *s != '\0'; ++s) { if (*s == '_') *p++ = '-'; else *p++ = TOLOWER_ASC(*s); } - *p = NUL; + *p = '\0'; /* Skip "2byte-" and "8bit-". */ p = enc_skip(r); @@ -3408,16 +3408,16 @@ char_u * enc_locale() int i; char buf[50]; # ifdef HAVE_NL_LANGINFO_CODESET - if ((s = nl_langinfo(CODESET)) == NULL || *s == NUL) + if ((s = nl_langinfo(CODESET)) == NULL || *s == '\0') # endif # if defined(HAVE_LOCALE_H) || defined(X_LOCALE) - if ((s = setlocale(LC_CTYPE, NULL)) == NULL || *s == NUL) + if ((s = setlocale(LC_CTYPE, NULL)) == NULL || *s == '\0') # endif - if ((s = (char *)os_getenv("LC_ALL")) == NULL || *s == NUL) - if ((s = (char *)os_getenv("LC_CTYPE")) == NULL || *s == NUL) + if ((s = (char *)os_getenv("LC_ALL")) == NULL || *s == '\0') + if ((s = (char *)os_getenv("LC_CTYPE")) == NULL || *s == '\0') s = (char *)os_getenv("LANG"); - if (s == NULL || *s == NUL) + if (s == NULL || *s == '\0') return FAIL; /* The most generic locale format is: @@ -3440,7 +3440,7 @@ char_u * enc_locale() } else s = p + 1; } - for (i = 0; s[i] != NUL && i < (int)sizeof(buf) - 1; ++i) { + for (i = 0; s[i] != '\0' && i < (int)sizeof(buf) - 1; ++i) { if (s[i] == '_' || s[i] == '-') buf[i] = '-'; else if (isalnum((int)s[i])) @@ -3448,7 +3448,7 @@ char_u * enc_locale() else break; } - buf[i] = NUL; + buf[i] = '\0'; return enc_canonize((char_u *)buf); } @@ -3549,7 +3549,7 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, int slen, int *unconvl if (iconv(vcp->vc_fd, (void *)&from, &fromlen, &to, &tolen) != (size_t)-1) { /* Finished, append a NUL. */ - *to = NUL; + *to = '\0'; break; } @@ -3558,7 +3558,7 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, int slen, int *unconvl if (!vcp->vc_fail && unconvlenp != NULL && (ICONV_ERRNO == ICONV_EINVAL || ICONV_ERRNO == EINVAL)) { /* Handle an incomplete sequence at the end. */ - *to = NUL; + *to = '\0'; *unconvlenp = (int)fromlen; break; } @@ -3766,7 +3766,7 @@ int convert_setup_ext(vcp, from, from_unicode_is_utf8, to, to_unicode_is_utf8) vcp->vc_fail = FALSE; /* No conversion when one of the names is empty or they are equal. */ - if (from == NULL || *from == NUL || to == NULL || *to == NUL + if (from == NULL || *from == '\0' || to == NULL || *to == '\0' || STRCMP(from, to) == 0) return OK; @@ -3918,7 +3918,7 @@ char_u * string_convert_ext(vcp, ptr, lenp, unconvlenp) *d++ = 0x80 + (c & 0x3f); } } - *d = NUL; + *d = '\0'; if (lenp != NULL) *lenp = (int)(d - retval); break; @@ -3940,7 +3940,7 @@ char_u * string_convert_ext(vcp, ptr, lenp, unconvlenp) } d += utf_char2bytes(c, d); } - *d = NUL; + *d = '\0'; if (lenp != NULL) *lenp = (int)(d - retval); break; @@ -3952,7 +3952,7 @@ char_u * string_convert_ext(vcp, ptr, lenp, unconvlenp) for (i = 0; i < len; ++i) { l = utf_ptr2len_len(ptr + i, len - i); if (l == 0) - *d++ = NUL; + *d++ = '\0'; else if (l == 1) { int l_w = utf8len_tab_zero[ptr[i]]; @@ -4003,7 +4003,7 @@ char_u * string_convert_ext(vcp, ptr, lenp, unconvlenp) i += l - 1; } } - *d = NUL; + *d = '\0'; if (lenp != NULL) *lenp = (int)(d - retval); break; diff --git a/src/memfile.c b/src/memfile.c index 9f8d482768..fa5b604304 100644 --- a/src/memfile.c +++ b/src/memfile.c @@ -540,7 +540,7 @@ int mf_sync(memfile_T *mfp, int flags) if (hp == NULL || status == FAIL) mfp->mf_dirty = FALSE; - if ((flags & MFS_FLUSH) && *p_sws != NUL) { + if ((flags & MFS_FLUSH) && *p_sws != '\0') { #if defined(UNIX) # ifdef HAVE_FSYNC if (STRCMP(p_sws, "fsync") == 0) { @@ -838,7 +838,7 @@ static int mf_read(memfile_T *mfp, bhdr_T *hp) } /* Decrypt if 'key' is set and this is a data block. */ - if (*mfp->mf_buffer->b_p_key != NUL) + if (*mfp->mf_buffer->b_p_key != '\0') ml_decrypt_data(mfp, hp->bh_data, offset, size); return OK; @@ -926,7 +926,7 @@ static int mf_write_block(memfile_T *mfp, bhdr_T *hp, off_t offset, unsigned siz int result = OK; /* Encrypt if 'key' is set and this is a data block. */ - if (*mfp->mf_buffer->b_p_key != NUL) { + if (*mfp->mf_buffer->b_p_key != '\0') { data = ml_encrypt_data(mfp, data, offset, size); } diff --git a/src/memline.c b/src/memline.c index 5df8034e69..e0f9b0b232 100644 --- a/src/memline.c +++ b/src/memline.c @@ -347,11 +347,11 @@ int ml_open(buf_T *buf) b0p->b0_flags = get_fileformat(buf) + 1; set_b0_fname(b0p, buf); (void)os_get_user_name((char *)b0p->b0_uname, B0_UNAME_SIZE); - b0p->b0_uname[B0_UNAME_SIZE - 1] = NUL; + b0p->b0_uname[B0_UNAME_SIZE - 1] = '\0'; os_get_hostname((char *)b0p->b0_hname, B0_HNAME_SIZE); - b0p->b0_hname[B0_HNAME_SIZE - 1] = NUL; + b0p->b0_hname[B0_HNAME_SIZE - 1] = '\0'; long_to_char(os_get_pid(), b0p->b0_pid); - if (*buf->b_p_key != NUL) + if (*buf->b_p_key != '\0') ml_set_b0_crypt(buf, b0p); } @@ -397,7 +397,7 @@ int ml_open(buf_T *buf) dp->db_index[0] = --dp->db_txt_start; /* at end of block */ dp->db_free -= 1 + INDEX_SIZE; dp->db_line_count = 1; - *((char_u *)dp + dp->db_txt_start) = NUL; /* empty line */ + *((char_u *)dp + dp->db_txt_start) = '\0'; /* empty line */ return OK; @@ -416,7 +416,7 @@ error: */ static void ml_set_b0_crypt(buf_T *buf, ZERO_BL *b0p) { - if (*buf->b_p_key == NUL) + if (*buf->b_p_key == '\0') b0p->b0_id[1] = BLOCK0_ID1; else { if (get_crypt_method(buf) == 0) @@ -574,7 +574,7 @@ void ml_setname(buf_T *buf) */ dirp = p_dir; for (;; ) { - if (*dirp == NUL) /* tried all directories, fail */ + if (*dirp == '\0') /* tried all directories, fail */ break; fname = findswapname(buf, &dirp, mfp->mf_fname); /* alloc's fname */ @@ -671,7 +671,7 @@ void ml_open_file(buf_T *buf) */ dirp = p_dir; for (;; ) { - if (*dirp == NUL) + if (*dirp == '\0') break; /* There is a small chance that between choosing the swap file name * and creating it, another Vim creates the file. In that case the @@ -835,7 +835,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf) struct stat st; if (buf->b_ffname == NULL) - b0p->b0_fname[0] = NUL; + b0p->b0_fname[0] = '\0'; else { char uname[B0_UNAME_SIZE]; @@ -909,7 +909,7 @@ static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf) /* Without encryption use the same offset as in Vim 7.2 to be compatible. * With encryption it's OK to move elsewhere, the swap file is not * compatible anyway. */ - if (*buf->b_p_key != NUL) + if (*buf->b_p_key != '\0') size = B0_FNAME_SIZE_CRYPT; n = (int)STRLEN(buf->b_p_fenc); @@ -918,7 +918,7 @@ static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf) else { memmove((char *)b0p->b0_fname + size - n, (char *)buf->b_p_fenc, (size_t)n); - *(b0p->b0_fname + size - n - 1) = NUL; + *(b0p->b0_fname + size - n - 1) = '\0'; b0p->b0_flags |= B0_HAS_FENC; } } @@ -1087,7 +1087,7 @@ void ml_recover(void) attr | MSG_HIST); MSG_PUTS_ATTR(_("The file was created on "), attr | MSG_HIST); /* avoid going past the end of a corrupted hostname */ - b0p->b0_fname[0] = NUL; + b0p->b0_fname[0] = '\0'; MSG_PUTS_ATTR(b0p->b0_hname, attr | MSG_HIST); MSG_PUTS_ATTR(_(",\nor the file has been damaged."), attr | MSG_HIST); msg_end(); @@ -1173,7 +1173,7 @@ void ml_recover(void) /* Use the same size as in add_b0_fenc(). */ if (b0p->b0_id[1] != BLOCK0_ID1) fnsize = B0_FNAME_SIZE_CRYPT; - for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; --p) + for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != '\0'; --p) ; b0_fenc = vim_strnsave(p, (int)(b0p->b0_fname + fnsize - p)); } @@ -1200,7 +1200,7 @@ void ml_recover(void) if (b0_cm >= 0) { /* Need to ask the user for the crypt key. If this fails we continue * without a key, will probably get garbage text. */ - if (*curbuf->b_p_key != NUL) { + if (*curbuf->b_p_key != '\0') { smsg((char_u *)_("Swap file is encrypted: \"%s\""), fname_used); MSG_PUTS(_( "\nIf you entered a new crypt key but did not write the text file,")); @@ -1213,7 +1213,7 @@ void ml_recover(void) buf->b_p_key = get_crypt_key(FALSE, FALSE); if (buf->b_p_key == NULL) buf->b_p_key = curbuf->b_p_key; - else if (*buf->b_p_key == NUL) { + else if (*buf->b_p_key == '\0') { vim_free(buf->b_p_key); buf->b_p_key = curbuf->b_p_key; } @@ -1349,7 +1349,7 @@ void ml_recover(void) } /* make sure there is a NUL at the end of the block */ - *((char_u *)dp + dp->db_txt_end - 1) = NUL; + *((char_u *)dp + dp->db_txt_end - 1) = '\0'; /* * check number of lines in block @@ -1403,7 +1403,7 @@ void ml_recover(void) if (orig_file_status != OK || curbuf->b_ml.ml_line_count != lnum * 2 + 1) { /* Recovering an empty file results in two lines and the first line is * empty. Don't set the modified flag then. */ - if (!(curbuf->b_ml.ml_line_count == 2 && *ml_get(1) == NUL)) { + if (!(curbuf->b_ml.ml_line_count == 2 && *ml_get(1) == '\0')) { changed_int(); ++curbuf->b_changedtick; } @@ -1452,7 +1452,7 @@ void ml_recover(void) MSG_PUTS(_("\nYou may want to delete the .swp file now.\n\n")); cmdline_row = msg_row; } - if (*buf->b_p_key != NUL && STRCMP(curbuf->b_p_key, buf->b_p_key) != 0) { + if (*buf->b_p_key != '\0' && STRCMP(curbuf->b_p_key, buf->b_p_key) != 0) { MSG_PUTS(_("Using crypt key from swap file for the text file.\n")); set_option_value((char_u *)"key", 0L, buf->b_p_key, OPT_LOCAL); } @@ -1546,7 +1546,7 @@ recover_names ( */ (void)copy_option_part(&dirp, dir_name, 31000, ","); - if (dir_name[0] == '.' && dir_name[1] == NUL) { /* check current dir */ + if (dir_name[0] == '.' && dir_name[1] == '\0') { /* check current dir */ if (fname == NULL) { names[0] = vim_strsave((char_u *)"*.sw?"); #if defined(UNIX) || defined(WIN3264) @@ -1606,7 +1606,7 @@ recover_names ( * not able to execute the shell). * Try finding a swap file by simply adding ".swp" to the file name. */ - if (*dirp == NUL && file_count + num_files == 0 && fname != NULL) { + if (*dirp == '\0' && file_count + num_files == 0 && fname != NULL) { struct stat st; char_u *swapname; @@ -1650,7 +1650,7 @@ recover_names ( dirp = (char_u *)""; /* stop searching */ } } else if (list) { - if (dir_name[0] == '.' && dir_name[1] == NUL) { + if (dir_name[0] == '.' && dir_name[1] == '\0') { if (fname == NULL) MSG_PUTS(_(" In current directory:\n")); else @@ -1698,7 +1698,7 @@ static char_u *make_percent_swname(char_u *dir, char_u *name) d = NULL; if (f != NULL) { s = (char_u *)xstrdup((char *)f); - for (d = s; *d != NUL; mb_ptr_adv(d)) + for (d = s; *d != '\0'; mb_ptr_adv(d)) if (vim_ispathsep(*d)) *d = '%'; d = concat_fnames(dir, s, TRUE); @@ -1759,7 +1759,7 @@ static time_t swapfile_info(char_u *fname) MSG_PUTS(_(" [does not look like a Vim swap file]")); } else { MSG_PUTS(_(" file name: ")); - if (b0.b0_fname[0] == NUL) + if (b0.b0_fname[0] == '\0') MSG_PUTS(_("[No Name]")); else msg_outtrans(b0.b0_fname); @@ -1767,13 +1767,13 @@ static time_t swapfile_info(char_u *fname) MSG_PUTS(_("\n modified: ")); MSG_PUTS(b0.b0_dirty ? _("YES") : _("no")); - if (*(b0.b0_uname) != NUL) { + if (*(b0.b0_uname) != '\0') { MSG_PUTS(_("\n user name: ")); msg_outtrans(b0.b0_uname); } - if (*(b0.b0_hname) != NUL) { - if (*(b0.b0_uname) != NUL) + if (*(b0.b0_hname) != '\0') { + if (*(b0.b0_uname) != '\0') MSG_PUTS(_(" host name: ")); else MSG_PUTS(_("\n host name: ")); @@ -3349,7 +3349,7 @@ int resolve_symlink(char_u *fname, char_u *buf) /* There must be some error reading links, use original name. */ return FAIL; } - buf[ret] = NUL; + buf[ret] = '\0'; /* * Check whether the symlink is relative or absolute. @@ -3422,7 +3422,7 @@ char_u *makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name FALSE #else /* Prepend a '.' to the swap file name for the current directory. */ - dir_name[0] == '.' && dir_name[1] == NUL + dir_name[0] == '.' && dir_name[1] == '\0' #endif ); if (r == NULL) /* out of memory */ @@ -3458,14 +3458,14 @@ get_file_in_dir ( tail = path_tail(fname); - if (dname[0] == '.' && dname[1] == NUL) + if (dname[0] == '.' && dname[1] == '\0') retval = vim_strsave(fname); else if (dname[0] == '.' && vim_ispathsep(dname[1])) { if (tail == fname) /* no path before file name */ retval = concat_fnames(dname + 2, tail, TRUE); else { save_char = *tail; - *tail = NUL; + *tail = '\0'; t = concat_fnames(fname, dname + 2, TRUE); *tail = save_char; retval = concat_fnames(t, tail, TRUE); @@ -3667,7 +3667,7 @@ findswapname ( fname2[n - 1] = 'x'; else if (*path_tail(fname) == '.') { fname2[n] = 'x'; - fname2[n + 1] = NUL; + fname2[n + 1] = '\0'; } else fname2[n - 5] += 1; /* diff --git a/src/menu.c b/src/menu.c index 01f7f4f9d3..641fae3f75 100644 --- a/src/menu.c +++ b/src/menu.c @@ -113,13 +113,13 @@ ex_menu ( /* Locate an optional "icon=filename" argument. */ if (STRNCMP(arg, "icon=", 5) == 0) { arg += 5; - while (*arg != NUL && *arg != ' ') { + while (*arg != '\0' && *arg != ' ') { if (*arg == '\\') STRMOVE(arg, arg + 1); mb_ptr_adv(arg); } - if (*arg != NUL) { - *arg++ = NUL; + if (*arg != '\0') { + *arg++ = '\0'; arg = skipwhite(arg); } } @@ -162,7 +162,7 @@ ex_menu ( /* * If there is no argument, display all menus. */ - if (*arg == NUL) { + if (*arg == '\0') { show_menus(arg, modes); return; } @@ -179,10 +179,10 @@ ex_menu ( /* * If there is only a menu name, display menus with that name. */ - if (*map_to == NUL && !unmenu && enable == MAYBE) { + if (*map_to == '\0' && !unmenu && enable == MAYBE) { show_menus(menu_path, modes); goto theend; - } else if (*map_to != NUL && (unmenu || enable != MAYBE)) { + } else if (*map_to != '\0' && (unmenu || enable != MAYBE)) { EMSG(_(e_trailing)); goto theend; } @@ -325,7 +325,7 @@ add_menu_path ( dname = menu_text(name, NULL, NULL); if (dname == NULL) goto erret; - if (*dname == NUL) { + if (*dname == '\0') { /* Only a mnemonic or accelerator is not valid. */ EMSG(_("E792: Empty menu name")); goto erret; @@ -336,12 +336,12 @@ add_menu_path ( menu = *menup; while (menu != NULL) { if (menu_name_equal(name, menu) || menu_name_equal(dname, menu)) { - if (*next_name == NUL && menu->children != NULL) { + if (*next_name == '\0' && menu->children != NULL) { if (!sys_menu) EMSG(_("E330: Menu path must not lead to a sub-menu")); goto erret; } - if (*next_name != NUL && menu->children == NULL + if (*next_name != '\0' && menu->children == NULL ) { if (!sys_menu) EMSG(_(e_notsubmenu)); @@ -362,12 +362,12 @@ add_menu_path ( } if (menu == NULL) { - if (*next_name == NUL && parent == NULL) { + if (*next_name == '\0' && parent == NULL) { EMSG(_("E331: Must not add menu items directly to menu bar")); goto erret; } - if (menu_is_separator(dname) && *next_name != NUL) { + if (menu_is_separator(dname) && *next_name != '\0') { EMSG(_("E332: Separator cannot be part of a menu path")); goto erret; } @@ -446,7 +446,7 @@ add_menu_path ( * Don't do this for "<Nop>". */ c = 0; d = 0; - if (amenu && call_data != NULL && *call_data != NUL + if (amenu && call_data != NULL && *call_data != '\0' ) { switch (1 << i) { case MENU_VISUAL_MODE: @@ -477,7 +477,7 @@ add_menu_path ( /* Append CTRL-\ CTRL-G to obey 'insertmode'. */ menu->strings[i][len] = Ctrl_BSL; menu->strings[i][len + 1] = Ctrl_G; - menu->strings[i][len + 2] = NUL; + menu->strings[i][len + 2] = '\0'; } } else menu->strings[i] = p; @@ -531,8 +531,8 @@ static int menu_nable_recurse(vimmenu_T *menu, char_u *name, int modes, int enab /* Find the menu */ while (menu != NULL) { - if (*name == NUL || *name == '*' || menu_name_equal(name, menu)) { - if (*p != NUL) { + if (*name == '\0' || *name == '*' || menu_name_equal(name, menu)) { + if (*p != '\0') { if (menu->children == NULL) { EMSG(_(e_notsubmenu)); return FAIL; @@ -550,12 +550,12 @@ static int menu_nable_recurse(vimmenu_T *menu, char_u *name, int modes, int enab * modes, so keep looping, otherwise we are just doing the named * menu item (which has been found) so break here. */ - if (*name != NUL && *name != '*') + if (*name != '\0' && *name != '*') break; } menu = menu->next; } - if (*name != NUL && *name != '*' && menu == NULL) { + if (*name != '\0' && *name != '*' && menu == NULL) { EMSG2(_(e_nomenu), name); return FAIL; } @@ -588,8 +588,8 @@ remove_menu ( /* Find the menu */ while ((menu = *menup) != NULL) { - if (*name == NUL || menu_name_equal(name, menu)) { - if (*p != NUL && menu->children == NULL) { + if (*name == '\0' || menu_name_equal(name, menu)) { + if (*p != '\0' && menu->children == NULL) { if (!silent) EMSG(_(e_notsubmenu)); return FAIL; @@ -600,14 +600,14 @@ remove_menu ( * If we are removing all entries for this menu,MENU_ALL_MODES, * Then kill any tearoff before we start */ - if (*p == NUL && modes == MENU_ALL_MODES) { + if (*p == '\0' && modes == MENU_ALL_MODES) { if (IsWindow(menu->tearoff_handle)) DestroyWindow(menu->tearoff_handle); } #endif if (remove_menu(&menu->children, p, modes, silent) == FAIL) return FAIL; - } else if (*name != NUL) { + } else if (*name != '\0') { if (!silent) EMSG(_(e_othermode)); return FAIL; @@ -618,7 +618,7 @@ remove_menu ( * modes, so keep looping, otherwise we are just removing the named * menu item (which has been found) so break here. */ - if (*name != NUL) + if (*name != '\0') break; /* Remove the menu item for the given mode[s]. If the menu item @@ -633,7 +633,7 @@ remove_menu ( } else menup = &menu->next; } - if (*name != NUL) { + if (*name != '\0') { if (menu == NULL) { if (!silent) EMSG2(_(e_nomenu), name); @@ -736,7 +736,7 @@ static int show_menus(char_u *path_name, int modes) while (menu != NULL) { if (menu_name_equal(name, menu)) { /* Found menu */ - if (*p != NUL && menu->children == NULL) { + if (*p != '\0' && menu->children == NULL) { EMSG(_(e_notsubmenu)); vim_free(path_name); return FAIL; @@ -817,7 +817,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth) else msg_putchar(' '); MSG_PUTS(" "); - if (*menu->strings[bit] == NUL) + if (*menu->strings[bit] == '\0') msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8)); else msg_outtrans_special(menu->strings[bit], FALSE); @@ -867,22 +867,22 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc if (!vim_iswhite(*p)) { if (STRNCMP(arg, "enable", 6) == 0 - && (arg[6] == NUL || vim_iswhite(arg[6]))) + && (arg[6] == '\0' || vim_iswhite(arg[6]))) p = arg + 6; else if (STRNCMP(arg, "disable", 7) == 0 - && (arg[7] == NUL || vim_iswhite(arg[7]))) + && (arg[7] == '\0' || vim_iswhite(arg[7]))) p = arg + 7; else p = arg; } - while (*p != NUL && vim_iswhite(*p)) + while (*p != '\0' && vim_iswhite(*p)) ++p; arg = after_dot = p; for (; *p && !vim_iswhite(*p); ++p) { - if ((*p == '\\' || *p == Ctrl_V) && p[1] != NUL) + if ((*p == '\\' || *p == Ctrl_V) && p[1] != '\0') p++; else if (*p == '.') after_dot = p + 1; @@ -893,7 +893,7 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc expand_emenu = (*cmd == 'e'); if (expand_menus && vim_iswhite(*p)) return NULL; /* TODO: check for next command? */ - if (*p == NUL) { /* Complete the menu name */ + if (*p == '\0') { /* Complete the menu name */ /* * With :unmenu, you only want to match menus for the appropriate mode. * With :menu though you might want to add a menu with the same name as @@ -914,7 +914,7 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc while (menu != NULL) { if (menu_name_equal(name, menu)) { /* Found menu */ - if ((*p != NUL && menu->children == NULL) + if ((*p != '\0' && menu->children == NULL) || ((menu->modes & expand_modes) == 0x0)) { /* * Menu path continues, but we have reached a leaf. @@ -1065,12 +1065,12 @@ char_u *menu_name_skip(char_u *name) for (p = name; *p && *p != '.'; mb_ptr_adv(p)) { if (*p == '\\' || *p == Ctrl_V) { STRMOVE(p, p + 1); - if (*p == NUL) + if (*p == '\0') break; } } if (*p) - *p++ = NUL; + *p++ = '\0'; return p; } @@ -1091,11 +1091,11 @@ static int menu_namecmp(char_u *name, char_u *mname) { int i; - for (i = 0; name[i] != NUL && name[i] != TAB; ++i) + for (i = 0; name[i] != '\0' && name[i] != TAB; ++i) if (name[i] != mname[i]) break; - return (name[i] == NUL || name[i] == TAB) - && (mname[i] == NUL || mname[i] == TAB); + return (name[i] == '\0' || name[i] == TAB) + && (mname[i] == '\0' || mname[i] == TAB); } /* @@ -1208,7 +1208,7 @@ static char_u *menu_text(char_u *str, int *mnemonic, char_u **actext) for (p = text; p != NULL; ) { p = vim_strchr(p, '&'); if (p != NULL) { - if (p[1] == NUL) /* trailing "&" */ + if (p[1] == '\0') /* trailing "&" */ break; if (mnemonic != NULL && p[1] != '&') #if !defined(__MVS__) || defined(MOTIF390_MNEMONIC_FIXED) @@ -1274,7 +1274,7 @@ int menu_is_separator(char_u *name) */ static int menu_is_hidden(char_u *name) { - return (name[0] == ']') || (menu_is_popup(name) && name[5] != NUL); + return (name[0] == ']') || (menu_is_popup(name) && name[5] != '\0'); } #if defined(FEAT_CMDL_COMPL) \ @@ -1315,10 +1315,10 @@ void ex_emenu(exarg_T *eap) while (menu != NULL) { if (menu_name_equal(name, menu)) { - if (*p == NUL && menu->children != NULL) { + if (*p == '\0' && menu->children != NULL) { EMSG(_("E333: Menu path must lead to a menu item")); menu = NULL; - } else if (*p != NUL && menu->children == NULL) { + } else if (*p != '\0' && menu->children == NULL) { EMSG(_(e_notsubmenu)); menu = NULL; } @@ -1326,7 +1326,7 @@ void ex_emenu(exarg_T *eap) } menu = menu->next; } - if (menu == NULL || *p == NUL) + if (menu == NULL || *p == '\0') break; menu = menu->children; name = p; @@ -1382,7 +1382,7 @@ void ex_emenu(exarg_T *eap) /* Adjust the cursor to make sure it is in the correct pos * for exclusive mode */ - if (*p_sel == 'e' && gchar_cursor() != NUL) + if (*p_sel == 'e' && gchar_cursor() != '\0') ++curwin->w_cursor.col; } else { mode = (char_u *)"Normal"; @@ -1430,14 +1430,14 @@ vimmenu_T *gui_find_menu(char_u *path_name) if (menu_name_equal(name, menu)) { if (menu->children == NULL) { /* found a menu item instead of a sub-menu */ - if (*p == NUL) + if (*p == '\0') EMSG(_("E336: Menu path must lead to a sub-menu")); else EMSG(_(e_notsubmenu)); menu = NULL; goto theend; } - if (*p == NUL) /* found a full match */ + if (*p == '\0') /* found a full match */ goto theend; break; } @@ -1504,7 +1504,7 @@ void ex_menutranslate(exarg_T *eap) from = arg; arg = menu_skip_part(arg); to = skipwhite(arg); - *arg = NUL; + *arg = '\0'; arg = menu_skip_part(to); if (arg == to) EMSG(_(e_invarg)); @@ -1539,8 +1539,8 @@ void ex_menutranslate(exarg_T *eap) */ static char_u *menu_skip_part(char_u *p) { - while (*p != NUL && *p != '.' && !vim_iswhite(*p)) { - if ((*p == '\\' || *p == Ctrl_V) && p[1] != NUL) + while (*p != '\0' && *p != '.' && !vim_iswhite(*p)) { + if ((*p == '\\' || *p == Ctrl_V) && p[1] != '\0') ++p; ++p; } @@ -1558,12 +1558,12 @@ static char_u *menutrans_lookup(char_u *name, int len) char_u *dname; for (i = 0; i < menutrans_ga.ga_len; ++i) - if (STRNCMP(name, tp[i].from, len) == 0 && tp[i].from[len] == NUL) + if (STRNCMP(name, tp[i].from, len) == 0 && tp[i].from[len] == '\0') return tp[i].to; /* Now try again while ignoring '&' characters. */ i = name[len]; - name[len] = NUL; + name[len] = '\0'; dname = menu_text(name, NULL, NULL); name[len] = i; if (dname != NULL) { @@ -1599,7 +1599,7 @@ static char_u *menu_translate_tab_and_shift(char_u *arg_start) char_u *arg = arg_start; while (*arg && !vim_iswhite(*arg)) { - if ((*arg == '\\' || *arg == Ctrl_V) && arg[1] != NUL) + if ((*arg == '\\' || *arg == Ctrl_V) && arg[1] != '\0') arg++; else if (STRNICMP(arg, "<TAB>", 5) == 0) { *arg = TAB; @@ -1607,8 +1607,8 @@ static char_u *menu_translate_tab_and_shift(char_u *arg_start) } arg++; } - if (*arg != NUL) - *arg++ = NUL; + if (*arg != '\0') + *arg++ = '\0'; arg = skipwhite(arg); return arg; diff --git a/src/message.c b/src/message.c index 89bd787d5c..37f3392eb8 100644 --- a/src/message.c +++ b/src/message.c @@ -262,9 +262,9 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen) /* First part: Start of the string. */ for (e = 0; len < half && e < buflen; ++e) { - if (s[e] == NUL) { + if (s[e] == '\0') { /* text fits without truncating! */ - buf[e] = NUL; + buf[e] = '\0'; return; } n = ptr2cells(s + e); @@ -316,9 +316,9 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen) if (len >= buflen - e - 3) len = buflen - e - 3 - 1; memmove(buf + e + 3, s + i, len); - buf[e + 3 + len - 1] = NUL; + buf[e + 3 + len - 1] = '\0'; } else { - buf[e - 1] = NUL; /* make sure it is truncated */ + buf[e - 1] = '\0'; /* make sure it is truncated */ } } @@ -712,7 +712,7 @@ void ex_messages(exarg_T *eap) msg_hist_off = TRUE; s = os_getenv("LANG"); - if (s != NULL && *s != NUL) + if (s != NULL && *s != '\0') msg_attr((char_u *) _("Messages maintainer: Bram Moolenaar <Bram@vim.org>"), hl_attr(HLF_T)); @@ -1052,9 +1052,9 @@ void msg_putchar_attr(int c, int attr) buf[0] = K_SPECIAL; buf[1] = K_SECOND(c); buf[2] = K_THIRD(c); - buf[3] = NUL; + buf[3] = '\0'; } else { - buf[(*mb_char2bytes)(c, buf)] = NUL; + buf[(*mb_char2bytes)(c, buf)] = '\0'; } msg_puts_attr(buf, attr); } @@ -1175,7 +1175,7 @@ int msg_outtrans_len_attr(char_u *msgstr, int len, int attr) str += mb_l; } else { s = transchar_byte(*str); - if (s[1] != NUL) { + if (s[1] != '\0') { /* unprintable char: print the printable chars so far and the * translation of the unprintable char. */ if (str > plain_start) @@ -1240,9 +1240,9 @@ msg_outtrans_special ( int len; attr = hl_attr(HLF_8); - while (*str != NUL) { + while (*str != '\0') { /* Leading and trailing spaces need to be displayed in <> form. */ - if ((str == strstart || str[1] == NUL) && *str == ' ') { + if ((str == strstart || str[1] == '\0') && *str == ' ') { string = (char_u *)"<Space>"; ++str; } else @@ -1271,9 +1271,9 @@ str2special_save ( char_u *p = str; ga_init(&ga, 1, 40); - while (*p != NUL) + while (*p != '\0') ga_concat(&ga, str2special(&p, is_lhs)); - ga_append(&ga, NUL); + ga_append(&ga, '\0'); return (char_u *)ga.ga_data; } @@ -1305,17 +1305,17 @@ str2special ( } c = *str; - if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) { + if (c == K_SPECIAL && str[1] != '\0' && str[2] != '\0') { if (str[1] == KS_MODIFIER) { modifiers = str[2]; str += 3; c = *str; } - if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) { + if (c == K_SPECIAL && str[1] != '\0' && str[2] != '\0') { c = TO_SPECIAL(str[1], str[2]); str += 2; if (c == KS_ZERO) /* display <Nul> as ^@ or <Nul> */ - c = NUL; + c = '\0'; } if (IS_SPECIAL(c) || modifiers) /* special key */ special = TRUE; @@ -1342,7 +1342,7 @@ str2special ( if (special || char2cells(c) > 1 || (from && c == ' ')) return get_special_key_name(c, modifiers); buf[0] = c; - buf[1] = NUL; + buf[1] = '\0'; return buf; } @@ -1353,7 +1353,7 @@ void str2specialbuf(char_u *sp, char_u *buf, int len) { char_u *s; - *buf = NUL; + *buf = '\0'; while (*sp) { s = str2special(&sp, FALSE); if ((int)(STRLEN(s) + STRLEN(buf)) < len) @@ -1389,7 +1389,7 @@ void msg_prt_line(char_u *s, int list) /* output a space for an empty line, otherwise the line will be * overwritten */ - if (*s == NUL && !(list && lcs_eol != NUL)) + if (*s == '\0' && !(list && lcs_eol != '\0')) msg_putchar(' '); while (!got_int) { @@ -1401,12 +1401,12 @@ void msg_prt_line(char_u *s, int list) c = *p_extra++; } else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1) { col += (*mb_ptr2cells)(s); - if (lcs_nbsp != NUL && list && mb_ptr2char(s) == 160) { + if (lcs_nbsp != '\0' && list && mb_ptr2char(s) == 160) { mb_char2bytes(lcs_nbsp, buf); - buf[(*mb_ptr2len)(buf)] = NUL; + buf[(*mb_ptr2len)(buf)] = '\0'; } else { memmove(buf, s, (size_t)l); - buf[l] = NUL; + buf[l] = '\0'; } msg_puts(buf); s += l; @@ -1425,20 +1425,20 @@ void msg_prt_line(char_u *s, int list) c_extra = lcs_tab2; attr = hl_attr(HLF_8); } - } else if (c == 160 && list && lcs_nbsp != NUL) { + } else if (c == 160 && list && lcs_nbsp != '\0') { c = lcs_nbsp; attr = hl_attr(HLF_8); - } else if (c == NUL && list && lcs_eol != NUL) { + } else if (c == '\0' && list && lcs_eol != '\0') { p_extra = (char_u *)""; - c_extra = NUL; + c_extra = '\0'; n_extra = 1; c = lcs_eol; attr = hl_attr(HLF_AT); --s; - } else if (c != NUL && (n = byte2cells(c)) > 1) { + } else if (c != '\0' && (n = byte2cells(c)) > 1) { n_extra = n - 1; p_extra = transchar_byte(c); - c_extra = NUL; + c_extra = '\0'; c = *p_extra++; /* Use special coloring to be able to distinguish <hex> from * the same in plain text. */ @@ -1449,7 +1449,7 @@ void msg_prt_line(char_u *s, int list) } } - if (c == NUL) + if (c == '\0') break; msg_putchar_attr(c, attr); @@ -1603,7 +1603,7 @@ static void msg_puts_display(char_u *str, int maxlen, int attr, int recurse) int did_last_char; did_wait_return = FALSE; - while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL) { + while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != '\0') { /* * We are at the end of the screen line when: * - When outputting a newline. @@ -1684,7 +1684,7 @@ static void msg_puts_display(char_u *str, int maxlen, int attr, int recurse) --lines_left; if (p_more && lines_left == 0 && State != HITRETURN && !msg_no_more && !exmode_active) { - if (do_more_prompt(NUL)) + if (do_more_prompt('\0')) s = confirm_msg_tail; if (quit_more) return; @@ -1800,7 +1800,7 @@ static void msg_scroll_up(void) */ static void inc_msg_scrolled(void) { - if (*get_vim_var_str(VV_SCROLLSTART) == NUL) { + if (*get_vim_var_str(VV_SCROLLSTART) == '\0') { char_u *p = sourcing_name; char_u *tofree = NULL; int len; @@ -2014,7 +2014,7 @@ static void msg_puts_printf(char_u *str, int maxlen) char_u buf[4]; char_u *p; - while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen)) { + while (*s != '\0' && (maxlen < 0 || (int)(s - str) < maxlen)) { if (!(silent_mode && p_verbose == 0)) { /* NL --> CR NL translation (for Unix, not for "--version") */ /* NL --> CR translation (for Mac) */ @@ -2078,15 +2078,15 @@ static int do_more_prompt(int typed_char) State = ASKMORE; setmouse(); - if (typed_char == NUL) + if (typed_char == '\0') msg_moremsg(FALSE); for (;; ) { /* * Get a typed character directly from the user. */ - if (used_typed_char != NUL) { + if (used_typed_char != '\0') { c = used_typed_char; /* was typed at hit-enter prompt */ - used_typed_char = NUL; + used_typed_char = '\0'; } else c = get_keystroke(); @@ -2510,7 +2510,7 @@ static void redir_write(char_u *str, int maxlen) return; /* If 'verbosefile' is set prepare for writing in that file. */ - if (*p_vfile != NUL && verbose_fd == NULL) + if (*p_vfile != '\0' && verbose_fd == NULL) verbose_open(); if (redirecting()) { @@ -2535,7 +2535,7 @@ static void redir_write(char_u *str, int maxlen) var_redir_str(s, maxlen); /* Write and adjust the current column. */ - while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen)) { + while (*s != '\0' && (maxlen < 0 || (int)(s - str) < maxlen)) { if (!redir_reg && !redir_vname) if (redir_fd != NULL) putc(*s, redir_fd); @@ -2557,7 +2557,7 @@ static void redir_write(char_u *str, int maxlen) int redirecting(void) { - return redir_fd != NULL || *p_vfile != NUL + return redir_fd != NULL || *p_vfile != '\0' || redir_reg || redir_vname ; } @@ -2568,7 +2568,7 @@ int redirecting(void) */ void verbose_enter(void) { - if (*p_vfile != NUL) + if (*p_vfile != '\0') ++msg_silent; } @@ -2578,7 +2578,7 @@ void verbose_enter(void) */ void verbose_leave(void) { - if (*p_vfile != NUL) + if (*p_vfile != '\0') if (--msg_silent < 0) msg_silent = 0; } @@ -2588,7 +2588,7 @@ void verbose_leave(void) */ void verbose_enter_scroll(void) { - if (*p_vfile != NUL) + if (*p_vfile != '\0') ++msg_silent; else /* always scroll up, don't overwrite */ @@ -2600,7 +2600,7 @@ void verbose_enter_scroll(void) */ void verbose_leave_scroll(void) { - if (*p_vfile != NUL) { + if (*p_vfile != '\0') { if (--msg_silent < 0) msg_silent = 0; } else @@ -2872,7 +2872,7 @@ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfl hotkp += STRLEN(hotkp); else ++hotkp; - hotkp[copy_char(r + 1, hotkp, TRUE)] = NUL; + hotkp[copy_char(r + 1, hotkp, TRUE)] = '\0'; if (dfltbutton) --dfltbutton; @@ -2899,7 +2899,7 @@ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfl *msgp++ = (dfltbutton == 1) ? ']' : ')'; /* redefine hotkey */ - hotkp[copy_char(r, hotkp, TRUE)] = NUL; + hotkp[copy_char(r, hotkp, TRUE)] = '\0'; } } else { ++len; /* '&a' -> '[a]' */ @@ -2919,7 +2919,7 @@ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfl if (copy) { *msgp++ = ':'; *msgp++ = ' '; - *msgp = NUL; + *msgp = '\0'; } else { len += (int)(STRLEN(message) + 2 /* for the NL's */ @@ -2938,7 +2938,7 @@ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfl */ vim_free(confirm_msg); confirm_msg = alloc(len); - *confirm_msg = NUL; + *confirm_msg = '\0'; hotk = alloc(lenhotkey); *confirm_msg = '\n'; @@ -2949,7 +2949,7 @@ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfl /* Define first default hotkey. Keep the hotkey string NUL * terminated to avoid reading past the end. */ - hotkp[copy_char(buttons, hotkp, TRUE)] = NUL; + hotkp[copy_char(buttons, hotkp, TRUE)] = '\0'; /* Remember where the choices start, displaying starts here when * "hotkp" typed at the more prompt. */ @@ -3163,7 +3163,7 @@ int vim_vsnprintf(char *str, size_t str_m, char *fmt, va_list ap, typval_T *tvs) if (p == NULL) p = ""; - while (*p != NUL) { + while (*p != '\0') { if (*p != '%') { char *q = strchr(p + 1, '%'); size_t n = (q == NULL) ? STRLEN(p) : (size_t)(q - p); @@ -3646,7 +3646,7 @@ int vim_vsnprintf(char *str, size_t str_m, char *fmt, va_list ap, typval_T *tvs) l += sprintf(format + 1, ".%d", (int)precision); } format[l] = fmt_spec; - format[l + 1] = NUL; + format[l + 1] = '\0'; str_arg_l = sprintf(tmp, format, f); if (remove_trailing_zeroes) { @@ -3719,13 +3719,13 @@ int vim_vsnprintf(char *str, size_t str_m, char *fmt, va_list ap, typval_T *tvs) * the unrecognized conversion character */ str_arg = p; str_arg_l = 0; - if (*p != NUL) + if (*p != '\0') str_arg_l++; /* include invalid conversion specifier unchanged if not at end-of-string */ break; } - if (*p != NUL) + if (*p != '\0') p++; /* step over the just processed conversion specifier */ /* insert padding to the left as requested by min_field_width; diff --git a/src/misc1.c b/src/misc1.c index 21fb8face1..63e5718e24 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -104,13 +104,13 @@ open_line ( || defined(FEAT_CINDENT) || defined(FEAT_COMMENTS) char_u *p; #endif - int saved_char = NUL; /* init for GCC */ + int saved_char = '\0'; /* init for GCC */ pos_T *pos; int do_si = (!p_paste && curbuf->b_p_si && !curbuf->b_p_cin ); int no_si = FALSE; /* reset did_si afterwards */ - int first_char = NUL; /* init for GCC */ + int first_char = '\0'; /* init for GCC */ int vreplace_mode; int did_append; /* appended a new line */ int saved_pi = curbuf->b_p_pi; /* copy of preserveindent setting */ @@ -146,16 +146,16 @@ open_line ( * might be replaced at the start of the next line (due to autoindent * etc) a bit later. */ - replace_push(NUL); /* Call twice because BS over NL expects it */ - replace_push(NUL); + replace_push('\0'); /* Call twice because BS over NL expects it */ + replace_push('\0'); p = saved_line + curwin->w_cursor.col; - while (*p != NUL) { + while (*p != '\0') { if (has_mbyte) p += replace_push_mb(p); else replace_push(*p++); } - saved_line[curwin->w_cursor.col] = NUL; + saved_line[curwin->w_cursor.col] = '\0'; } if ((State & INSERT) @@ -168,7 +168,7 @@ open_line ( } extra_len = (int)STRLEN(p_extra); saved_char = *p_extra; - *p_extra = NUL; + *p_extra = '\0'; } u_clearline(); /* cannot do "U" command when adding lines */ @@ -204,7 +204,7 @@ open_line ( * don't add an indent. Fixes inserting a NL before '{' in line * "if (condition) {" */ - if (!trunc_line && do_si && *saved_line != NUL + if (!trunc_line && do_si && *saved_line != '\0' && (p_extra == NULL || first_char != '{')) { char_u *ptr; char_u last_char; @@ -252,7 +252,7 @@ open_line ( * the comment */ curwin->w_cursor.col = (colnr_T)(p - ptr); - if ((pos = findmatch(NULL, NUL)) != NULL) { + if ((pos = findmatch(NULL, '\0')) != NULL) { curwin->w_cursor.lnum = pos->lnum; newindent = get_indent(); } @@ -349,7 +349,7 @@ open_line ( * Find out if the current line starts with a comment leader. * This may then be inserted in front of the new line. */ - end_comment_pending = NUL; + end_comment_pending = '\0'; if (flags & OPENLINE_DO_COM) lead_len = get_leader_len(saved_line, &lead_flags, dir == BACKWARD, TRUE); else @@ -442,7 +442,7 @@ open_line ( && ((p_extra != NULL && (int)curwin->w_cursor.col == lead_len) || (p_extra == NULL - && saved_line[lead_len] == NUL) + && saved_line[lead_len] == '\0') || require_blank)) extra_space = TRUE; } @@ -517,7 +517,7 @@ open_line ( int c = 0; int off = 0; - for (p = lead_flags; *p != NUL && *p != ':'; ) { + for (p = lead_flags; *p != '\0' && *p != ':'; ) { if (*p == COM_RIGHT || *p == COM_LEFT) c = *p++; else if (VIM_ISDIGIT(*p) || *p == '-') @@ -553,7 +553,7 @@ open_line ( } memmove(p, lead_repl, (size_t)lead_repl_len); if (p + lead_repl_len > leader + lead_len) - p[lead_repl_len] = NUL; + p[lead_repl_len] = '\0'; /* blank-out any other chars from the old leader. */ while (--p >= leader) { @@ -583,7 +583,7 @@ open_line ( int i; int l; - for (i = 0; p[i] != NUL && i < lead_len; i += l) { + for (i = 0; p[i] != '\0' && i < lead_len; i += l) { l = (*mb_ptr2len)(p + i); if (vim_strnsize(p, i + l) > repl_size) break; @@ -623,7 +623,7 @@ open_line ( *p = ' '; } } - *p = NUL; + *p = '\0'; } /* Recompute the indent, it may have changed. */ @@ -654,12 +654,12 @@ open_line ( * extra space */ if (lead_len > 0 && vim_iswhite(leader[lead_len - 1])) extra_space = FALSE; - leader[lead_len] = NUL; + leader[lead_len] = '\0'; } if (extra_space) { leader[lead_len++] = ' '; - leader[lead_len] = NUL; + leader[lead_len] = '\0'; } newcol = lead_len; @@ -692,7 +692,7 @@ open_line ( )) { old_cursor = curwin->w_cursor; curwin->w_cursor.col = (colnr_T)(comment_end - saved_line); - if ((pos = findmatch(NULL, NUL)) != NULL) { + if ((pos = findmatch(NULL, '\0')) != NULL) { curwin->w_cursor.lnum = pos->lnum; newindent = get_indent(); } @@ -713,7 +713,7 @@ open_line ( * preceded by a NUL, so they can be put back when a BS is entered. */ if (REPLACE_NORMAL(State)) - replace_push(NUL); /* end of extra blanks */ + replace_push('\0'); /* end of extra blanks */ if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES)) { while ((*p_extra == ' ' || *p_extra == '\t') && (!enc_utf8 @@ -725,7 +725,7 @@ open_line ( ++less_cols_off; } } - if (*p_extra != NUL) + if (*p_extra != '\0') did_ai = FALSE; /* append some text, don't truncate now */ /* columns for marks adjusted for removed columns */ @@ -756,7 +756,7 @@ open_line ( did_ai = TRUE; /* So truncating blanks works with comments */ less_cols -= lead_len; } else - end_comment_pending = NUL; /* turns out there was no leader */ + end_comment_pending = '\0'; /* turns out there was no leader */ old_cursor = curwin->w_cursor; if (dir == BACKWARD) @@ -820,7 +820,7 @@ open_line ( */ if (REPLACE_NORMAL(State)) for (n = 0; n < (int)curwin->w_cursor.col; ++n) - replace_push(NUL); + replace_push('\0'); newcol += curwin->w_cursor.col; if (no_si) did_si = FALSE; @@ -832,14 +832,14 @@ open_line ( */ if (REPLACE_NORMAL(State)) while (lead_len-- > 0) - replace_push(NUL); + replace_push('\0'); curwin->w_cursor = old_cursor; if (dir == FORWARD) { if (trunc_line || (State & INSERT)) { /* truncate current line at cursor */ - saved_line[curwin->w_cursor.col] = NUL; + saved_line[curwin->w_cursor.col] = '\0'; /* Remove trailing white space, unless OPENLINE_KEEPTRAIL used. */ if (trunc_line && !(flags & OPENLINE_KEEPTRAIL)) truncate_spaces(saved_line); @@ -897,7 +897,7 @@ open_line ( */ if (!p_paste && (curbuf->b_p_cin - || *curbuf->b_p_inde != NUL + || *curbuf->b_p_inde != '\0' ) && in_cinkeys(dir == FORWARD ? KEY_OPEN_FORW @@ -970,7 +970,7 @@ int get_leader_len(char_u *line, char_u **flags, int backward, int include_space /* * Repeat to match several nested comment strings. */ - while (line[i] != NUL) { + while (line[i] != '\0') { /* * scan through the 'comments' option for a match */ @@ -985,7 +985,7 @@ int get_leader_len(char_u *line, char_u **flags, int backward, int include_space string = vim_strchr(part_buf, ':'); if (string == NULL) /* missing ':', ignore this part */ continue; - *string++ = NUL; /* isolate flags from string */ + *string++ = '\0'; /* isolate flags from string */ /* If we found a middle match previously, use that match when this * is not a middle or end. */ @@ -1013,15 +1013,15 @@ int get_leader_len(char_u *line, char_u **flags, int backward, int include_space while (vim_iswhite(string[0])) ++string; } - for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j) + for (j = 0; string[j] != '\0' && string[j] == line[i + j]; ++j) ; - if (string[j] != NUL) + if (string[j] != '\0') continue; /* string doesn't match */ /* When 'b' flag used, there must be white space or an * end-of-line after the string in the line. */ if (vim_strchr(part_buf, COM_BLANK) != NULL - && !vim_iswhite(line[i + j]) && line[i + j] != NUL) + && !vim_iswhite(line[i + j]) && line[i + j] != '\0') continue; /* We have found a match, stop searching unless this is a middle @@ -1118,7 +1118,7 @@ int get_last_leader_offset(char_u *line, char_u **flags) * happen. */ continue; } - *string++ = NUL; /* Isolate flags from string. */ + *string++ = '\0'; /* Isolate flags from string. */ com_leader = string; /* @@ -1133,9 +1133,9 @@ int get_last_leader_offset(char_u *line, char_u **flags) while (vim_iswhite(string[0])) ++string; } - for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j) + for (j = 0; string[j] != '\0' && string[j] == line[i + j]; ++j) /* do nothing */; - if (string[j] != NUL) + if (string[j] != '\0') continue; /* @@ -1143,7 +1143,7 @@ int get_last_leader_offset(char_u *line, char_u **flags) * end-of-line after the string in the line. */ if (vim_strchr(part_buf, COM_BLANK) != NULL - && !vim_iswhite(line[i + j]) && line[i + j] != NUL) { + && !vim_iswhite(line[i + j]) && line[i + j] != '\0') { continue; } @@ -1273,7 +1273,7 @@ int plines_win_nofold(win_T *wp, linenr_T lnum) int width; s = ml_get_buf(wp->w_buffer, lnum, FALSE); - if (*s == NUL) /* empty line */ + if (*s == '\0') /* empty line */ return 1; col = win_linetabsize(wp, s, (colnr_T)MAXCOL); @@ -1281,7 +1281,7 @@ int plines_win_nofold(win_T *wp, linenr_T lnum) * If list mode is on, then the '$' at the end of the line may take up one * extra column. */ - if (wp->w_p_list && lcs_eol != NUL) + if (wp->w_p_list && lcs_eol != '\0') col += 1; /* @@ -1321,7 +1321,7 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column) s = ml_get_buf(wp->w_buffer, lnum, FALSE); col = 0; - while (*s != NUL && --column >= 0) { + while (*s != '\0' && --column >= 0) { col += win_lbr_chartabsize(wp, s, (colnr_T)col, NULL); mb_ptr_adv(s); } @@ -1478,7 +1478,7 @@ void ins_char_bytes(char_u *buf, int charlen) */ getvcol(curwin, &curwin->w_cursor, NULL, &vcol, NULL); new_vcol = vcol + chartabsize(buf, vcol); - while (oldp[col + oldlen] != NUL && vcol < new_vcol) { + while (oldp[col + oldlen] != '\0' && vcol < new_vcol) { vcol += chartabsize(oldp + col + oldlen, vcol); /* Don't need to remove a TAB that takes us to the right * position. */ @@ -1490,7 +1490,7 @@ void ins_char_bytes(char_u *buf, int charlen) newlen += vcol - new_vcol; } curwin->w_p_list = old_list; - } else if (oldp[col] != NUL) { + } else if (oldp[col] != '\0') { /* normal replace */ oldlen = (*mb_ptr2len)(oldp + col); } @@ -1500,7 +1500,7 @@ void ins_char_bytes(char_u *buf, int charlen) * put back when BS is used. The bytes of a multi-byte character are * done the other way around, so that the first byte is popped off * first (it tells the byte length of the character). */ - replace_push(NUL); + replace_push('\0'); for (i = 0; i < oldlen; ++i) { if (has_mbyte) i += replace_push_mb(oldp + col + i) - 1; @@ -1599,7 +1599,7 @@ int del_char(int fixpos) if (has_mbyte) { /* Make sure the cursor is at the start of a character. */ mb_adjust_cursor(); - if (*ml_get_cursor() == NUL) + if (*ml_get_cursor() == '\0') return FAIL; return del_chars(1L, fixpos); } @@ -1617,7 +1617,7 @@ int del_chars(long count, int fixpos) int l; p = ml_get_cursor(); - for (i = 0; i < count && *p != NUL; ++i) { + for (i = 0; i < count && *p != '\0'; ++i) { l = (*mb_ptr2len)(p); bytes += l; p += l; @@ -1664,7 +1664,7 @@ del_bytes ( int n; (void)utfc_ptr2char(oldp + col, cc); - if (cc[0] != NUL) { + if (cc[0] != '\0') { /* Find the last composing char, there can be several. */ n = col; do { @@ -2461,7 +2461,7 @@ int get_keystroke(void) if (has_mbyte) { if (MB_BYTE2LEN(n) > len) continue; /* more bytes to get */ - buf[len >= buflen ? buflen - 1 : len] = NUL; + buf[len >= buflen ? buflen - 1 : len] = '\0'; n = (*mb_ptr2char)(buf); } #ifdef UNIX @@ -2672,7 +2672,7 @@ void init_homedir(void) var = (char_u *)os_getenv("HOME"); - if (var != NULL && *var == NUL) /* empty is same as not set */ + if (var != NULL && *var == '\0') /* empty is same as not set */ var = NULL; @@ -2795,7 +2795,7 @@ expand_env_esc ( } else #endif { - while (c-- > 0 && *tail != NUL && ((vim_isIDc(*tail)) + while (c-- > 0 && *tail != '\0' && ((vim_isIDc(*tail)) )) { *var++ = *tail++; } @@ -2816,14 +2816,14 @@ expand_env_esc ( #endif ++tail; #endif - *var = NUL; + *var = '\0'; var = vim_getenv(dst, &mustfree); #if defined(MSWIN) || defined(UNIX) } #endif } /* home directory */ - else if ( src[1] == NUL + else if ( src[1] == '\0' || vim_ispathsep(src[1]) || vim_strchr((char_u *)" ,\t\n", src[1]) != NULL) { var = homedir; @@ -2841,7 +2841,7 @@ expand_env_esc ( && vim_isfilec(*tail) && !vim_ispathsep(*tail)) *var++ = *tail++; - *var = NUL; + *var = '\0'; /* * Use os_get_user_directory() to get the user directory. * If this function fails, the shell is used to @@ -2896,14 +2896,14 @@ expand_env_esc ( } } - if (var != NULL && *var != NUL + if (var != NULL && *var != '\0' && (STRLEN(var) + STRLEN(tail) + 1 < (unsigned)dstlen)) { STRCPY(dst, var); dstlen -= (int)STRLEN(var); c = (int)STRLEN(var); /* if var[] ends in a path separator and tail[] starts * with it, skip a character */ - if (*var != NUL && after_pathsep(dst, dst + c) + if (*var != '\0' && after_pathsep(dst, dst + c) #if defined(BACKSLASH_IN_FILENAME) && dst[-1] != ':' #endif @@ -2924,7 +2924,7 @@ expand_env_esc ( * ":edit foo ~ foo". */ at_start = FALSE; - if (src[0] == '\\' && src[1] != NUL) { + if (src[0] == '\\' && src[1] != '\0') { *dst++ = *src++; --dstlen; } else if ((src[0] == ' ' || src[0] == ',') && !one) @@ -2937,7 +2937,7 @@ expand_env_esc ( at_start = TRUE; } } - *dst = NUL; + *dst = '\0'; } /* @@ -2955,7 +2955,7 @@ char_u *vim_getenv(char_u *name, int *mustfree) p = (char_u *)os_getenv((char *)name); - if (p != NULL && *p == NUL) /* empty is the same as not set */ + if (p != NULL && *p == '\0') /* empty is the same as not set */ p = NULL; if (p != NULL) { @@ -2972,11 +2972,11 @@ char_u *vim_getenv(char_u *name, int *mustfree) */ if (vimruntime #ifdef HAVE_PATHDEF - && *default_vimruntime_dir == NUL + && *default_vimruntime_dir == '\0' #endif ) { p = (char_u *)os_getenv("VIM"); - if (p != NULL && *p == NUL) /* empty is the same as not set */ + if (p != NULL && *p == '\0') /* empty is the same as not set */ p = NULL; if (p != NULL) { p = vim_version_dir(p); @@ -3053,10 +3053,10 @@ char_u *vim_getenv(char_u *name, int *mustfree) * default_vimruntime_dir */ if (p == NULL) { /* Only use default_vimruntime_dir when it is not empty */ - if (vimruntime && *default_vimruntime_dir != NUL) { + if (vimruntime && *default_vimruntime_dir != '\0') { p = default_vimruntime_dir; *mustfree = FALSE; - } else if (*default_vim_dir != NUL) { + } else if (*default_vim_dir != '\0') { if (vimruntime && (p = vim_version_dir(default_vim_dir)) != NULL) *mustfree = TRUE; else { @@ -3091,7 +3091,7 @@ static char_u *vim_version_dir(char_u *vimdir) { char_u *p; - if (vimdir == NULL || *vimdir == NUL) + if (vimdir == NULL || *vimdir == '\0') return NULL; p = concat_fnames(vimdir, (char_u *)VIM_VERSION_NODOT, TRUE); if (os_isdir(p)) @@ -3130,7 +3130,7 @@ void vim_setenv(char_u *name, char_u *val) * When setting $VIMRUNTIME adjust the directory to find message * translations to $VIMRUNTIME/lang. */ - if (*val != NUL && STRICMP(name, "VIMRUNTIME") == 0) { + if (*val != '\0' && STRICMP(name, "VIMRUNTIME") == 0) { char_u *buf = concat_str(val, (char_u *)"/lang"); bindtextdomain(VIMPACKAGE, (char *)buf); vim_free(buf); @@ -3227,7 +3227,7 @@ home_replace ( char_u *p; if (src == NULL) { - *dst = NUL; + *dst = '\0'; return; } @@ -3248,7 +3248,7 @@ home_replace ( homedir_env_orig = homedir_env = (char_u *)os_getenv("HOME"); /* Empty is the same as not set. */ - if (homedir_env != NULL && *homedir_env == NUL) + if (homedir_env != NULL && *homedir_env == '\0') homedir_env = NULL; if (homedir_env != NULL && vim_strchr(homedir_env, '~') != NULL) { @@ -3262,7 +3262,7 @@ home_replace ( flen = (int)STRLEN(homedir_env); if (flen > 0 && vim_ispathsep(homedir_env[flen - 1])) /* Remove the trailing / that is added to a directory. */ - homedir_env[flen - 1] = NUL; + homedir_env[flen - 1] = '\0'; } if (homedir_env != NULL) @@ -3287,7 +3287,7 @@ home_replace ( && fnamencmp(src, p, len) == 0 && (vim_ispathsep(src[len]) || (!one && (src[len] == ',' || src[len] == ' ')) - || src[len] == NUL)) { + || src[len] == '\0')) { src += len; if (--dstlen > 0) *dst++ = '~'; @@ -3314,7 +3314,7 @@ home_replace ( } /* if (dstlen == 0) out of space, what to do??? */ - *dst = NUL; + *dst = '\0'; if (homedir_env != homedir_env_orig) vim_free(homedir_env); @@ -3510,10 +3510,10 @@ get_cmd_output ( } else { /* Change NUL into SOH, otherwise the string is truncated. */ for (i = 0; i < len; ++i) - if (buffer[i] == NUL) + if (buffer[i] == '\0') buffer[i] = 1; - buffer[len] = NUL; /* make sure the buffer is terminated */ + buffer[len] = '\0'; /* make sure the buffer is terminated */ } done: diff --git a/src/misc2.c b/src/misc2.c index d946bd66f5..8dae4a79c8 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -163,7 +163,7 @@ coladvance2 ( int head = 0; one_more = (State & INSERT) - || restart_edit != NUL + || restart_edit != '\0' || (VIsual_active && *p_sel != 'o') || ((ve_flags & VE_ONEMORE) && wcol < MAXCOL) ; @@ -200,7 +200,7 @@ coladvance2 ( } ptr = line; - while (col <= wcol && *ptr != NUL) { + while (col <= wcol && *ptr != '\0') { /* Count a tab for what it's worth (if list mode not on) */ csize = win_lbr_chartabsize(curwin, ptr, col, &head); mb_ptr_adv(ptr); @@ -226,7 +226,7 @@ coladvance2 ( /* 'virtualedit' is set: The difference between wcol and col is * filled with spaces. */ - if (line[idx] == NUL) { + if (line[idx] == '\0') { /* Append spaces */ int correct = wcol - col; char_u *newline = alloc(idx + correct + 1); @@ -238,7 +238,7 @@ coladvance2 ( for (t = 0; t < correct; ++t) newline[t + idx] = ' '; - newline[idx + correct] = NUL; + newline[idx + correct] = '\0'; ml_replace(pos->lnum, newline, FALSE); changed_bytes(pos->lnum, (colnr_T)idx); @@ -265,7 +265,7 @@ coladvance2 ( newline[s++] = ' '; } - newline[linelen + csize - 1] = NUL; + newline[linelen + csize - 1] = '\0'; ml_replace(pos->lnum, newline, FALSE); changed_bytes(pos->lnum, idx); @@ -330,16 +330,16 @@ int inc(pos_T *lp) { char_u *p = ml_get_pos(lp); - if (*p != NUL) { /* still within line, move to next char (may be NUL) */ + if (*p != '\0') { /* still within line, move to next char (may be NUL) */ if (has_mbyte) { int l = (*mb_ptr2len)(p); lp->col += l; - return (p[l] != NUL) ? 0 : 2; + return (p[l] != '\0') ? 0 : 2; } lp->col++; lp->coladd = 0; - return (p[1] != NUL) ? 0 : 2; + return (p[1] != '\0') ? 0 : 2; } if (lp->lnum != curbuf->b_ml.ml_line_count) { /* there is a next line */ lp->col = 0; @@ -538,7 +538,7 @@ void adjust_cursor_col(void) { if (curwin->w_cursor.col > 0 && (!VIsual_active || *p_sel == 'o') - && gchar_cursor() == NUL) + && gchar_cursor() == '\0') --curwin->w_cursor.col; } @@ -618,7 +618,7 @@ char_u *vim_strnsave(char_u *string, int len) p = alloc((unsigned)(len + 1)); STRNCPY(p, string, len); - p[len] = NUL; + p[len] = '\0'; return p; } @@ -672,7 +672,7 @@ char_u *vim_strsave_escaped_ext(char_u *string, char_u *esc_chars, int cc, int b *p2++ = cc; *p2++ = *p; } - *p2 = NUL; + *p2 = '\0'; return escaped_string; } @@ -712,7 +712,7 @@ char_u *vim_strsave_shellescape(char_u *string, bool do_special, bool do_newline /* First count the number of extra bytes required. */ length = (unsigned)STRLEN(string) + 3; /* two quotes and a trailing NUL */ - for (p = string; *p != NUL; mb_ptr_adv(p)) { + for (p = string; *p != '\0'; mb_ptr_adv(p)) { if (*p == '\'') length += 3; /* ' => '\'' */ if ((*p == '\n' && (csh_like || do_newline)) @@ -734,7 +734,7 @@ char_u *vim_strsave_shellescape(char_u *string, bool do_special, bool do_newline /* add opening quote */ *d++ = '\''; - for (p = string; *p != NUL; ) { + for (p = string; *p != '\0'; ) { if (*p == '\'') { *d++ = '\''; *d++ = '\\'; @@ -763,7 +763,7 @@ char_u *vim_strsave_shellescape(char_u *string, bool do_special, bool do_newline /* add terminating quote and finish with a NUL */ *d++ = '\''; - *d = NUL; + *d = '\0'; return escaped_string; } @@ -804,7 +804,7 @@ void vim_strup(char_u *p) if (p != NULL) { p2 = p; - while ((c = *p2) != NUL) + while ((c = *p2) != '\0') *p2++ = (c < 'a' || c > 'z') ? c : (c - 0x20); } } @@ -822,7 +822,7 @@ char_u *strup_save(char_u *orig) res = p = vim_strsave(orig); if (res != NULL) - while (*p != NUL) { + while (*p != '\0') { int l; if (enc_utf8) { @@ -893,7 +893,7 @@ void del_trailing_spaces(char_u *ptr) q = ptr + STRLEN(ptr); while (--q > ptr && vim_iswhite(q[0]) && q[-1] != '\\' && q[-1] != Ctrl_V) - *q = NUL; + *q = '\0'; } /* @@ -903,7 +903,7 @@ void del_trailing_spaces(char_u *ptr) void vim_strncpy(char_u *to, char_u *from, size_t len) { STRNCPY(to, from, len); - to[len] = NUL; + to[len] = '\0'; } /* @@ -917,7 +917,7 @@ void vim_strcat(char_u *to, char_u *from, size_t tosize) if (tolen + fromlen + 1 > tosize) { memmove(to + tolen, from, tosize - tolen - 1); - to[tosize - 1] = NUL; + to[tosize - 1] = '\0'; } else STRCPY(to + tolen, from); } @@ -937,7 +937,7 @@ int copy_option_part(char_u **option, char_u *buf, int maxlen, char *sep_chars) /* skip '.' at start of option part, for 'suffixes' */ if (*p == '.') buf[len++] = *p++; - while (*p != NUL && vim_strchr((char_u *)sep_chars, *p) == NULL) { + while (*p != '\0' && vim_strchr((char_u *)sep_chars, *p) == NULL) { /* * Skip backslash before a separator character and space. */ @@ -947,9 +947,9 @@ int copy_option_part(char_u **option, char_u *buf, int maxlen, char *sep_chars) buf[len++] = *p; ++p; } - buf[len] = NUL; + buf[len] = '\0'; - if (*p != NUL && *p != ',') /* skip non-standard separator */ + if (*p != '\0' && *p != ',') /* skip non-standard separator */ ++p; p = skip_to_option_part(p); /* p points to next file name */ @@ -983,7 +983,7 @@ int vim_stricmp(char *s1, char *s2) i = (int)TOLOWER_LOC(*s1) - (int)TOLOWER_LOC(*s2); if (i != 0) return i; /* this character different */ - if (*s1 == NUL) + if (*s1 == '\0') break; /* strings match until NUL */ ++s1; ++s2; @@ -1006,7 +1006,7 @@ int vim_strnicmp(char *s1, char *s2, size_t len) i = (int)TOLOWER_LOC(*s1) - (int)TOLOWER_LOC(*s2); if (i != 0) return i; /* this character different */ - if (*s1 == NUL) + if (*s1 == '\0') break; /* strings match until NUL */ ++s1; ++s2; @@ -1028,7 +1028,7 @@ char_u *vim_strchr(char_u *string, int c) p = string; if (enc_utf8 && c >= 0x80) { - while (*p != NUL) { + while (*p != '\0') { if (utf_ptr2char(p) == c) return p; p += (*mb_ptr2len)(p); @@ -1039,7 +1039,7 @@ char_u *vim_strchr(char_u *string, int c) int n2 = c & 0xff; c = ((unsigned)c >> 8) & 0xff; - while ((b = *p) != NUL) { + while ((b = *p) != '\0') { if (b == c && p[1] == n2) return p; p += (*mb_ptr2len)(p); @@ -1047,14 +1047,14 @@ char_u *vim_strchr(char_u *string, int c) return NULL; } if (has_mbyte) { - while ((b = *p) != NUL) { + while ((b = *p) != '\0') { if (b == c) return p; p += (*mb_ptr2len)(p); } return NULL; } - while ((b = *p) != NUL) { + while ((b = *p) != '\0') { if (b == c) return p; ++p; @@ -1071,7 +1071,7 @@ char_u *vim_strbyte(char_u *string, int c) { char_u *p = string; - while (*p != NUL) { + while (*p != '\0') { if (*p == c) return p; ++p; @@ -1217,19 +1217,19 @@ int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg) if (do_profiling == PROF_YES) prof_child_enter(&wait_time); - if (*p_sh == NUL) { + if (*p_sh == '\0') { EMSG(_(e_shellempty)); retval = -1; } else { /* The external command may update a tags file, clear cached tags. */ tag_freematch(); - if (cmd == NULL || *p_sxq == NUL) + if (cmd == NULL || *p_sxq == '\0') retval = os_call_shell(cmd, opts, extra_shell_arg); else { char_u *ecmd = cmd; - if (*p_sxe != NUL && STRCMP(p_sxq, "(") == 0) { + if (*p_sxe != '\0' && STRCMP(p_sxq, "(") == 0) { ecmd = vim_strsave_escaped_ext(cmd, p_sxe, '^', FALSE); if (ecmd == NULL) ecmd = cmd; @@ -1293,7 +1293,7 @@ int vim_chdirfile(char_u *fname) char_u dir[MAXPATHL]; vim_strncpy(dir, fname, MAXPATHL - 1); - *path_tail_with_sep(dir) = NUL; + *path_tail_with_sep(dir) = '\0'; return os_chdir((char *)dir) == 0 ? OK : FAIL; } #endif @@ -1306,7 +1306,7 @@ int vim_chdirfile(char_u *fname) */ int illegal_slash(char *name) { - if (name[0] == NUL) + if (name[0] == '\0') return FALSE; /* no file name is not illegal */ if (name[strlen(name) - 1] != '/') return FALSE; /* no trailing slash */ @@ -1447,7 +1447,7 @@ char_u *read_string(FILE *fd, int cnt) } str[i] = c; } - str[i] = NUL; + str[i] = '\0'; return str; } @@ -1510,7 +1510,7 @@ int has_non_ascii(char_u *s) char_u *p; if (s != NULL) - for (p = s; *p != NUL; ++p) + for (p = s; *p != '\0'; ++p) if (*p >= 128) return TRUE; return FALSE; diff --git a/src/move.c b/src/move.c index f234d968a6..1c7fd8b32d 100644 --- a/src/move.c +++ b/src/move.c @@ -796,7 +796,7 @@ curs_columns ( /* When cursor wraps to first char of next line in Insert * mode, the 'showbreak' string isn't shown, backup to first * column */ - if (*p_sbr && *ml_get_cursor() == NUL + if (*p_sbr && *ml_get_cursor() == '\0' && curwin->w_wcol == (int)vim_strsize(p_sbr)) curwin->w_wcol = 0; } diff --git a/src/msgpack_rpc.c b/src/msgpack_rpc.c index 5e36830132..aa4cfa57cb 100644 --- a/src/msgpack_rpc.c +++ b/src/msgpack_rpc.c @@ -93,7 +93,7 @@ char *msgpack_rpc_raw_argument(msgpack_object *obj) { char *rv = xmalloc(obj->via.raw.size + 1); memcpy(rv, obj->via.raw.ptr, obj->via.raw.size); - rv[obj->via.raw.size] = NUL; + rv[obj->via.raw.size] = '\0'; return rv; } diff --git a/src/normal.c b/src/normal.c index 0d6410f3a9..fcf3fb36d6 100644 --- a/src/normal.c +++ b/src/normal.c @@ -58,10 +58,10 @@ /* * The Visual area is remembered for reselection. */ -static int resel_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */ +static int resel_VIsual_mode = '\0'; /* 'v', 'V', or Ctrl-V */ static linenr_T resel_VIsual_line_count; /* number of lines */ static colnr_T resel_VIsual_vcol; /* nr of cols or end col */ -static int VIsual_mode_orig = NUL; /* saved Visual mode */ +static int VIsual_mode_orig = '\0'; /* saved Visual mode */ static int restart_VIsual_select = 0; @@ -222,7 +222,7 @@ static const struct nv_cmd { short cmd_arg; /* value for ca.arg */ } nv_cmds[] = { - {NUL, nv_error, 0, 0}, + {'\0', nv_error, 0, 0}, {Ctrl_A, nv_addsub, 0, 0}, {Ctrl_B, nv_page, NV_STS, BACKWARD}, {Ctrl_C, nv_esc, 0, TRUE}, @@ -595,7 +595,7 @@ normal_cmd ( || (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0)) old_mapped_len = typebuf_maplen(); - if (c == NUL) + if (c == '\0') c = K_ZERO; /* @@ -919,7 +919,7 @@ getcount: ca.nchar = ca.extra_char; idx = find_command(ca.cmdchar); } else if ((ca.nchar == 'n' || ca.nchar == 'N') && ca.cmdchar == 'g') - ca.oap->op_type = get_op_type(*cp, NUL); + ca.oap->op_type = get_op_type(*cp, '\0'); else if (*cp == Ctrl_BSL) { long towait = (p_ttm >= 0 ? p_ttm : p_tm); @@ -1194,7 +1194,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) int restart_edit_save; /* The visual area is remembered for redo */ - static int redo_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */ + static int redo_VIsual_mode = '\0'; /* 'v', 'V', or Ctrl-V */ static linenr_T redo_VIsual_line_count; /* number of lines */ static colnr_T redo_VIsual_vcol; /* number of cols or end column */ static long redo_VIsual_count; /* count for Visual operator */ @@ -1303,9 +1303,9 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) curbuf->b_visual.vi_start = VIsual; curbuf->b_visual.vi_end = curwin->w_cursor; curbuf->b_visual.vi_mode = VIsual_mode; - if (VIsual_mode_orig != NUL) { + if (VIsual_mode_orig != '\0') { curbuf->b_visual.vi_mode = VIsual_mode_orig; - VIsual_mode_orig = NUL; + VIsual_mode_orig = '\0'; } curbuf->b_visual.vi_curswant = curwin->w_curswant; curbuf->b_visual_mode_eval = VIsual_mode; @@ -1458,7 +1458,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) && oap->op_type != OP_FOLDCLOSEREC && oap->op_type != OP_FOLDDEL && oap->op_type != OP_FOLDDELREC - && oap->motion_force == NUL + && oap->motion_force == '\0' ) { /* Prepare for redoing. Only use the nchar field for "r", * otherwise it might be the second char of the operator. */ @@ -1468,11 +1468,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) get_op_char(oap->op_type), get_extra_op_char(oap->op_type), oap->motion_force, cap->cmdchar, cap->nchar); else if (cap->cmdchar != ':') - prep_redo(oap->regname, 0L, NUL, 'v', + prep_redo(oap->regname, 0L, '\0', 'v', get_op_char(oap->op_type), get_extra_op_char(oap->op_type), oap->op_type == OP_REPLACE - ? cap->nchar : NUL); + ? cap->nchar : '\0'); if (!redo_VIsual_busy) { redo_VIsual_mode = resel_VIsual_mode; redo_VIsual_vcol = resel_VIsual_vcol; @@ -1486,13 +1486,13 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) * If oap->end is on a NUL (empty line) oap->inclusive becomes * FALSE. This makes "d}P" and "v}dP" work the same. */ - if (oap->motion_force == NUL || oap->motion_type == MLINE) + if (oap->motion_force == '\0' || oap->motion_type == MLINE) oap->inclusive = TRUE; if (VIsual_mode == 'V') oap->motion_type = MLINE; else { oap->motion_type = MCHAR; - if (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == NUL + if (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == '\0' && (include_line_break || !virtual_op) ) { oap->inclusive = FALSE; @@ -1535,7 +1535,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) || oap->op_type == OP_COLON || oap->op_type == OP_FUNCTION || oap->op_type == OP_FILTER) - && oap->motion_force == NUL) + && oap->motion_force == '\0') redraw_curbuf_later(INVERTED); } } @@ -1557,7 +1557,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) oap->empty = (oap->motion_type == MCHAR && (!oap->inclusive || (oap->op_type == OP_YANK - && gchar_pos(&oap->end) == NUL)) + && gchar_pos(&oap->end) == '\0')) && equalpos(oap->start, oap->end) && !(virtual_op && oap->start.coladd != oap->end.coladd) ); @@ -1686,13 +1686,13 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) /* * If 'equalprg' is empty, do the indenting internally. */ - if (oap->op_type == OP_INDENT && *get_equalprg() == NUL) { + if (oap->op_type == OP_INDENT && *get_equalprg() == '\0') { if (curbuf->b_p_lisp) { op_reindent(oap, get_lisp_indent); break; } op_reindent(oap, - *curbuf->b_p_inde != NUL ? get_expr_indent : + *curbuf->b_p_inde != '\0' ? get_expr_indent : get_c_indent); break; } @@ -1713,9 +1713,9 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) break; case OP_FORMAT: - if (*curbuf->b_p_fex != NUL) + if (*curbuf->b_p_fex != '\0') op_formatexpr(oap); /* use expression */ - else if (*p_fp != NUL) + else if (*p_fp != '\0') op_colon(oap); /* use external command */ else op_format(oap, FALSE); /* use internal function */ @@ -1841,7 +1841,7 @@ static void op_colon(oparg_T *oap) stuffReadbuff(get_equalprg()); stuffReadbuff((char_u *)"\n"); } else if (oap->op_type == OP_FORMAT) { - if (*p_fp == NUL) + if (*p_fp == '\0') stuffReadbuff((char_u *)"fmt"); else stuffReadbuff(p_fp); @@ -1861,7 +1861,7 @@ static void op_function(oparg_T *oap) char_u *(argv[1]); int save_virtual_op = virtual_op; - if (*p_opfunc == NUL) + if (*p_opfunc == '\0') EMSG(_("E774: 'operatorfunc' is empty")); else { /* Set '[ and '] marks to text to be operated on. */ @@ -1980,7 +1980,7 @@ do_mouse ( if (is_drag) { /* If the next character is the same mouse event then use that * one. Speeds up dragging the status line. */ - if (vpeekc() != NUL) { + if (vpeekc() != '\0') { int nc; int save_mouse_row = mouse_row; int save_mouse_col = mouse_col; @@ -2448,9 +2448,9 @@ do_mouse ( c2 = 'p'; } else { c1 = (dir == FORWARD) ? 'p' : 'P'; - c2 = NUL; + c2 = '\0'; } - prep_redo(regname, count, NUL, c1, NUL, c2, NUL); + prep_redo(regname, count, '\0', c1, '\0', c2, '\0'); /* * Remember where the paste started, so in edit() Insstart can be set @@ -2551,7 +2551,7 @@ do_mouse ( && VIsual_mode == 'v' && !vim_iswordc(gchar_pos(&end_visual)) && equalpos(curwin->w_cursor, VIsual) - && (pos = findmatch(oap, NUL)) != NULL) { + && (pos = findmatch(oap, '\0')) != NULL) { curwin->w_cursor = *pos; if (oap->motion_type == MLINE) VIsual_mode = 'V'; @@ -2572,7 +2572,7 @@ do_mouse ( find_end_of_word(&VIsual); } else { find_start_of_word(&VIsual); - if (*p_sel == 'e' && *ml_get_cursor() != NUL) + if (*p_sel == 'e' && *ml_get_cursor() != '\0') curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); find_end_of_word(&curwin->w_cursor); @@ -2635,7 +2635,7 @@ static void find_end_of_word(pos_T *pos) pos->col -= (*mb_head_off)(line, line + pos->col); } cclass = get_mouse_class(line + pos->col); - while (line[pos->col] != NUL) { + while (line[pos->col] != '\0') { col = pos->col + (*mb_ptr2len)(line + pos->col); if (get_mouse_class(line + col) != cclass) { if (*p_sel == 'e') @@ -2673,7 +2673,7 @@ static int get_mouse_class(char_u *p) * "->", "/ *", "*=", "+=", "&=", "<=", ">=", "!=" etc. Otherwise, each * character is in its own class. */ - if (c != NUL && vim_strchr((char_u *)"-+*/%<>&|^!=", c) != NULL) + if (c != '\0' && vim_strchr((char_u *)"-+*/%<>&|^!=", c) != NULL) return 1; return c; } @@ -2797,14 +2797,14 @@ int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **strin */ col = startcol; if (has_mbyte) { - while (ptr[col] != NUL) { + while (ptr[col] != '\0') { this_class = mb_get_class(ptr + col); if (this_class != 0 && (i == 1 || this_class != 1)) break; col += (*mb_ptr2len)(ptr + col); } } else - while (ptr[col] != NUL + while (ptr[col] != '\0' && (i == 0 ? !vim_iswordc(ptr[col]) : vim_iswhite(ptr[col])) ) ++col; @@ -2851,7 +2851,7 @@ int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **strin } } - if (ptr[col] == NUL || (i == 0 && ( + if (ptr[col] == '\0' || (i == 0 && ( has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col])))) { /* @@ -2873,14 +2873,14 @@ int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **strin if (has_mbyte) { /* Search for point of changing multibyte character class. */ this_class = mb_get_class(ptr); - while (ptr[col] != NUL + while (ptr[col] != '\0' && ((i == 0 ? mb_get_class(ptr + col) == this_class : mb_get_class(ptr + col) != 0) )) col += (*mb_ptr2len)(ptr + col); } else while ((i == 0 ? vim_iswordc(ptr[col]) - : (ptr[col] != NUL && !vim_iswhite(ptr[col]))) + : (ptr[col] != '\0' && !vim_iswhite(ptr[col]))) ) { ++col; } @@ -2894,7 +2894,7 @@ int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **strin static void prep_redo_cmd(cmdarg_T *cap) { prep_redo(cap->oap->regname, cap->count0, - NUL, cap->cmdchar, NUL, NUL, cap->nchar); + '\0', cap->cmdchar, '\0', '\0', cap->nchar); } /* @@ -2911,15 +2911,15 @@ static void prep_redo(int regname, long num, int cmd1, int cmd2, int cmd3, int c if (num) AppendNumberToRedobuff(num); - if (cmd1 != NUL) + if (cmd1 != '\0') AppendCharToRedobuff(cmd1); - if (cmd2 != NUL) + if (cmd2 != '\0') AppendCharToRedobuff(cmd2); - if (cmd3 != NUL) + if (cmd3 != '\0') AppendCharToRedobuff(cmd3); - if (cmd4 != NUL) + if (cmd4 != '\0') AppendCharToRedobuff(cmd4); - if (cmd5 != NUL) + if (cmd5 != '\0') AppendCharToRedobuff(cmd5); } @@ -2955,7 +2955,7 @@ static void clearop(oparg_T *oap) { oap->op_type = OP_NOP; oap->regname = 0; - oap->motion_force = NUL; + oap->motion_force = '\0'; oap->use_reg_one = FALSE; } @@ -3057,10 +3057,10 @@ void clear_showcmd(void) else sprintf((char *)showcmd_buf, "%d-%d", chars, bytes); } - showcmd_buf[SHOWCMD_COLS] = NUL; /* truncate */ + showcmd_buf[SHOWCMD_COLS] = '\0'; /* truncate */ showcmd_visual = TRUE; } else { - showcmd_buf[0] = NUL; + showcmd_buf[0] = '\0'; showcmd_visual = FALSE; /* Don't actually display something if there is nothing to clear. */ @@ -3098,7 +3098,7 @@ int add_to_showcmd(int c) return FALSE; if (showcmd_visual) { - showcmd_buf[0] = NUL; + showcmd_buf[0] = '\0'; showcmd_visual = FALSE; } @@ -3146,7 +3146,7 @@ static void del_from_showcmd(int len) old_len = (int)STRLEN(showcmd_buf); if (len > old_len) len = old_len; - showcmd_buf[old_len - len] = NUL; + showcmd_buf[old_len - len] = '\0'; if (!char_avail()) display_showcmd(); @@ -3459,7 +3459,7 @@ find_decl ( par_pos = curwin->w_cursor; } else { par_pos = curwin->w_cursor; - while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != NUL) + while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != '\0') --curwin->w_cursor.lnum; } curwin->w_cursor.col = 0; @@ -4407,11 +4407,11 @@ static void nv_ident(cmdarg_T *cap) /* Allocate buffer to put the command in. Inserting backslashes can * double the length of the word. p_kp / curbuf->b_p_kp could be added * and some numbers. */ - kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp); - kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0 + kp = (*curbuf->b_p_kp == '\0' ? p_kp : curbuf->b_p_kp); + kp_help = (*kp == '\0' || STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0); buf = alloc((unsigned)(n * 2 + 30 + STRLEN(kp))); - buf[0] = NUL; + buf[0] = '\0'; switch (cmdchar) { case '*': @@ -4528,7 +4528,7 @@ static void nv_ident(cmdarg_T *cap) } *p++ = *ptr++; } - *p = NUL; + *p = '\0'; } /* @@ -4541,7 +4541,7 @@ static void nv_ident(cmdarg_T *cap) STRCAT(buf, "\\>"); /* put pattern in search history */ init_history(); - add_to_history(HIST_SEARCH, buf, TRUE, NUL); + add_to_history(HIST_SEARCH, buf, TRUE, '\0'); normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0); } else do_cmdline_cmd(buf); @@ -4698,7 +4698,7 @@ static void nv_right(cmdarg_T *cap) for (n = cap->count1; n > 0; --n) { if ((!PAST_LINE && oneright() == FAIL) - || (PAST_LINE && *ml_get_cursor() == NUL) + || (PAST_LINE && *ml_get_cursor() == '\0') ) { /* * <Space> wraps to next line if 'whichwrap' has 's'. @@ -4801,7 +4801,7 @@ static void nv_left(cmdarg_T *cap) && !lineempty(curwin->w_cursor.lnum)) { char_u *cp = ml_get_cursor(); - if (*cp != NUL) { + if (*cp != '\0') { if (has_mbyte) { curwin->w_cursor.col += (*mb_ptr2len)(cp); } else { @@ -4933,7 +4933,7 @@ static void nv_dollar(cmdarg_T *cap) /* In virtual mode when off the edge of a line and an operator * is pending (whew!) keep the cursor where it is. * Otherwise, send it to the end of the line. */ - if (!virtual_active() || gchar_cursor() != NUL + if (!virtual_active() || gchar_cursor() != '\0' || cap->oap->op_type == OP_NOP) curwin->w_curswant = MAXCOL; /* so we stay at the end */ if (cursor_down((long)(cap->count1 - 1), @@ -5269,7 +5269,7 @@ static void nv_brackets(cmdarg_T *cap) if (VIsual_mode == 'V') { /* delete visually selected lines */ cap->cmdchar = 'd'; - cap->nchar = NUL; + cap->nchar = '\0'; cap->oap->regname = regname; nv_operator(cap); do_pending_operator(cap, 0, FALSE); @@ -5371,7 +5371,7 @@ static void nv_percent(cmdarg_T *cap) } else { /* "%" : go to matching paren */ cap->oap->motion_type = MCHAR; cap->oap->use_reg_one = TRUE; - if ((pos = findmatch(cap->oap, NUL)) == NULL) + if ((pos = findmatch(cap->oap, '\0')) == NULL) clearopbeep(cap->oap); else { setpcmark(); @@ -5432,7 +5432,7 @@ static void nv_findpar(cmdarg_T *cap) cap->oap->inclusive = FALSE; cap->oap->use_reg_one = TRUE; curwin->w_set_curswant = TRUE; - if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE)) + if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, '\0', FALSE)) clearopbeep(cap->oap); else { curwin->w_cursor.coladd = 0; @@ -5486,9 +5486,9 @@ static void nv_replace(cmdarg_T *cap) cap->nchar = get_literal(); /* Don't redo a multibyte character with CTRL-V. */ if (cap->nchar > DEL) - had_ctrl_v = NUL; + had_ctrl_v = '\0'; } else - had_ctrl_v = NUL; + had_ctrl_v = '\0'; /* Abort if the character is a special key. */ if (IS_SPECIAL(cap->nchar)) { @@ -5514,7 +5514,7 @@ static void nv_replace(cmdarg_T *cap) if (virtual_active()) { if (u_save_cursor() == FAIL) return; - if (gchar_cursor() == NUL) { + if (gchar_cursor() == '\0') { /* Add extra space and put the cursor on the first one. */ coladvance_force((colnr_T)(getviscol() + cap->count1)); curwin->w_cursor.col -= cap->count1; @@ -5567,7 +5567,7 @@ static void nv_replace(cmdarg_T *cap) invoke_edit(cap, TRUE, 'r', FALSE); } else { prep_redo(cap->oap->regname, cap->count1, - NUL, 'r', NUL, had_ctrl_v, cap->nchar); + '\0', 'r', '\0', had_ctrl_v, cap->nchar); curbuf->b_op_start = curwin->w_cursor; if (has_mbyte) { @@ -5586,7 +5586,7 @@ static void nv_replace(cmdarg_T *cap) if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) { int c = ins_copychar(curwin->w_cursor.lnum + (cap->nchar == Ctrl_Y ? -1 : 1)); - if (c != NUL) + if (c != '\0') ins_char(c); else /* will be decremented further down */ @@ -5613,7 +5613,7 @@ static void nv_replace(cmdarg_T *cap) if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) { int c = ins_copychar(curwin->w_cursor.lnum + (cap->nchar == Ctrl_Y ? -1 : 1)); - if (c != NUL) + if (c != '\0') ptr[curwin->w_cursor.col] = c; } else ptr[curwin->w_cursor.col] = cap->nchar; @@ -5689,7 +5689,7 @@ static void nv_Replace(cmdarg_T *cap) { if (VIsual_active) { /* "R" is replace lines */ cap->cmdchar = 'c'; - cap->nchar = NUL; + cap->nchar = '\0'; VIsual_mode_orig = VIsual_mode; /* remember original area for gv */ VIsual_mode = 'V'; nv_operator(cap); @@ -5754,7 +5754,7 @@ static void n_swapchar(cmdarg_T *cap) for (n = cap->count1; n > 0; --n) { did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor); inc_cursor(); - if (gchar_cursor() == NUL) { + if (gchar_cursor() == '\0') { if (vim_strchr(p_ww, '~') != NULL && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { ++curwin->w_cursor.lnum; @@ -5972,7 +5972,7 @@ static void nv_regname(cmdarg_T *cap) return; if (cap->nchar == '=') cap->nchar = get_expr_register(); - if (cap->nchar != NUL && valid_yank_reg(cap->nchar, FALSE)) { + if (cap->nchar != '\0' && valid_yank_reg(cap->nchar, FALSE)) { cap->oap->regname = cap->nchar; cap->opcount = cap->count0; /* remember count before '"' */ set_reg_var(cap->oap->regname); @@ -6011,7 +6011,7 @@ static void nv_visual(cmdarg_T *cap) redraw_curbuf_later(INVERTED); /* update the inversion */ } else { /* start Visual mode */ check_visual_highlight(); - if (cap->count0 > 0 && resel_VIsual_mode != NUL) { + if (cap->count0 > 0 && resel_VIsual_mode != '\0') { /* use previously selected part */ VIsual = curwin->w_cursor; @@ -6136,7 +6136,7 @@ static void n_start_visual_mode(int c) static void nv_window(cmdarg_T *cap) { if (!checkclearop(cap->oap)) - do_window(cap->nchar, cap->count0, NUL); /* everything is in window.c */ + do_window(cap->nchar, cap->count0, '\0'); /* everything is in window.c */ } /* @@ -6365,7 +6365,7 @@ static void nv_g_cmd(cmdarg_T *cap) char_u *ptr = ml_get_curline(); /* In Visual mode we may end up after the line. */ - if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL) + if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == '\0') --curwin->w_cursor.col; /* Decrease the cursor column until it's on a non-blank. */ @@ -6781,7 +6781,7 @@ static void set_op_var(int optype) else { opchars[0] = get_op_char(optype); opchars[1] = get_extra_op_char(optype); - opchars[2] = NUL; + opchars[2] = '\0'; set_vim_var_string(VV_OP, opchars, -1); } } @@ -6884,7 +6884,7 @@ static void nv_wordcmd(cmdarg_T *cap) */ if (!word_end && cap->oap->op_type == OP_CHANGE) { n = gchar_cursor(); - if (n != NUL) { /* not an empty line */ + if (n != '\0') { /* not an empty line */ if (vim_iswhite(n)) { /* * Reproduce a funny Vi behaviour: "cw" on a blank only @@ -6949,7 +6949,7 @@ static void adjust_cursor(oparg_T *oap) * - not in Visual mode or 'selection' is "o" * - 'virtualedit' is not "all" and not "onemore". */ - if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL + if (curwin->w_cursor.col > 0 && gchar_cursor() == '\0' && (!VIsual_active || *p_sel == 'o') && !virtual_active() && (ve_flags & VE_ONEMORE) == 0 ) { @@ -6982,7 +6982,7 @@ static void nv_beginline(cmdarg_T *cap) static void adjust_for_sel(cmdarg_T *cap) { if (VIsual_active && cap->oap->inclusive && *p_sel == 'e' - && gchar_cursor() != NUL && lt(VIsual, curwin->w_cursor)) { + && gchar_cursor() != '\0' && lt(VIsual, curwin->w_cursor)) { if (has_mbyte) inc_cursor(); else @@ -7185,10 +7185,10 @@ static void nv_edit(cmdarg_T *cap) * column otherwise, also to append after an unprintable char */ if (virtual_active() && (curwin->w_cursor.coladd > 0 - || *ml_get_cursor() == NUL + || *ml_get_cursor() == '\0' || *ml_get_cursor() == TAB)) curwin->w_cursor.coladd++; - else if (*ml_get_cursor() != NUL) + else if (*ml_get_cursor() != '\0') inc_cursor(); break; } @@ -7339,7 +7339,7 @@ static void nv_at(cmdarg_T *cap) if (checkclearop(cap->oap)) return; if (cap->nchar == '=') { - if (get_expr_register() == NUL) + if (get_expr_register() == '\0') return; } while (cap->count1-- && !got_int) { @@ -7379,8 +7379,8 @@ static void nv_join(cmdarg_T *cap) clearopbeep(cap->oap); /* beyond last line */ else { prep_redo(cap->oap->regname, cap->count0, - NUL, cap->cmdchar, NUL, NUL, cap->nchar); - (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE); + '\0', cap->cmdchar, '\0', '\0', cap->nchar); + (void)do_join(cap->count0, cap->nchar == '\0', TRUE, TRUE); } } } @@ -7431,8 +7431,8 @@ static void nv_put(cmdarg_T *cap) /* Now delete the selected text. */ cap->cmdchar = 'd'; - cap->nchar = NUL; - cap->oap->regname = NUL; + cap->nchar = '\0'; + cap->oap->regname = '\0'; nv_operator(cap); do_pending_operator(cap, 0, FALSE); empty = (curbuf->b_ml.ml_flags & ML_EMPTY); @@ -7482,7 +7482,7 @@ static void nv_put(cmdarg_T *cap) /* When all lines were selected and deleted do_put() leaves an empty * line that needs to be deleted now. */ - if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) { + if (empty && *ml_get(curbuf->b_ml.ml_line_count) == '\0') { ml_delete(curbuf->b_ml.ml_line_count, TRUE); /* If the cursor was in that line, move it to the end of the last @@ -119,34 +119,34 @@ static int fmt_check_par(linenr_T, int *, char_u **, int do_comments); */ static char opchars[][3] = { - {NUL, NUL, FALSE}, /* OP_NOP */ - {'d', NUL, FALSE}, /* OP_DELETE */ - {'y', NUL, FALSE}, /* OP_YANK */ - {'c', NUL, FALSE}, /* OP_CHANGE */ - {'<', NUL, TRUE}, /* OP_LSHIFT */ - {'>', NUL, TRUE}, /* OP_RSHIFT */ - {'!', NUL, TRUE}, /* OP_FILTER */ - {'g', '~', FALSE}, /* OP_TILDE */ - {'=', NUL, TRUE}, /* OP_INDENT */ - {'g', 'q', TRUE}, /* OP_FORMAT */ - {':', NUL, TRUE}, /* OP_COLON */ - {'g', 'U', FALSE}, /* OP_UPPER */ - {'g', 'u', FALSE}, /* OP_LOWER */ - {'J', NUL, TRUE}, /* DO_JOIN */ - {'g', 'J', TRUE}, /* DO_JOIN_NS */ - {'g', '?', FALSE}, /* OP_ROT13 */ - {'r', NUL, FALSE}, /* OP_REPLACE */ - {'I', NUL, FALSE}, /* OP_INSERT */ - {'A', NUL, FALSE}, /* OP_APPEND */ - {'z', 'f', TRUE}, /* OP_FOLD */ - {'z', 'o', TRUE}, /* OP_FOLDOPEN */ - {'z', 'O', TRUE}, /* OP_FOLDOPENREC */ - {'z', 'c', TRUE}, /* OP_FOLDCLOSE */ - {'z', 'C', TRUE}, /* OP_FOLDCLOSEREC */ - {'z', 'd', TRUE}, /* OP_FOLDDEL */ - {'z', 'D', TRUE}, /* OP_FOLDDELREC */ - {'g', 'w', TRUE}, /* OP_FORMAT2 */ - {'g', '@', FALSE}, /* OP_FUNCTION */ + {'\0', '\0', FALSE}, /* OP_NOP */ + {'d', '\0', FALSE}, /* OP_DELETE */ + {'y', '\0', FALSE}, /* OP_YANK */ + {'c', '\0', FALSE}, /* OP_CHANGE */ + {'<', '\0', TRUE}, /* OP_LSHIFT */ + {'>', '\0', TRUE}, /* OP_RSHIFT */ + {'!', '\0', TRUE}, /* OP_FILTER */ + {'g', '~', FALSE}, /* OP_TILDE */ + {'=', '\0', TRUE}, /* OP_INDENT */ + {'g', 'q', TRUE}, /* OP_FORMAT */ + {':', '\0', TRUE}, /* OP_COLON */ + {'g', 'U', FALSE}, /* OP_UPPER */ + {'g', 'u', FALSE}, /* OP_LOWER */ + {'J', '\0', TRUE}, /* DO_JOIN */ + {'g', 'J', TRUE}, /* DO_JOIN_NS */ + {'g', '?', FALSE}, /* OP_ROT13 */ + {'r', '\0', FALSE}, /* OP_REPLACE */ + {'I', '\0', FALSE}, /* OP_INSERT */ + {'A', '\0', FALSE}, /* OP_APPEND */ + {'z', 'f', TRUE}, /* OP_FOLD */ + {'z', 'o', TRUE}, /* OP_FOLDOPEN */ + {'z', 'O', TRUE}, /* OP_FOLDOPENREC */ + {'z', 'c', TRUE}, /* OP_FOLDCLOSE */ + {'z', 'C', TRUE}, /* OP_FOLDCLOSEREC */ + {'z', 'd', TRUE}, /* OP_FOLDDEL */ + {'z', 'D', TRUE}, /* OP_FOLDDELREC */ + {'g', 'w', TRUE}, /* OP_FORMAT2 */ + {'g', '@', FALSE}, /* OP_FUNCTION */ }; /* @@ -211,7 +211,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount) for (i = oap->line_count; --i >= 0; ) { first_char = *ml_get_curline(); - if (first_char == NUL) /* empty line */ + if (first_char == '\0') /* empty line */ curwin->w_cursor.col = 0; else if (oap->block_mode) shift_block(oap, amount); @@ -309,7 +309,7 @@ shift_line ( /* Set new indent */ if (State & VREPLACE_FLAG) - change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes); + change_indent(INDENT_SET, count, FALSE, '\0', call_changed_bytes); else (void)set_indent(count, call_changed_bytes ? SIN_CHANGED : 0); } @@ -377,7 +377,7 @@ static void shift_block(oparg_T *oap, int amount) bd.textcol -= bd.pre_whitesp_c - (bd.startspaces != 0); len = (int)STRLEN(bd.textstart) + 1; newp = (char_u *) xmalloc((size_t)(bd.textcol + i + j + len)); - memset(newp, NUL, (size_t)(bd.textcol + i + j + len)); + memset(newp, '\0', (size_t)(bd.textcol + i + j + len)); memmove(newp, oldp, (size_t)bd.textcol); copy_chars(newp + bd.textcol, (size_t)i, TAB); copy_spaces(newp + bd.textcol + i, (size_t)j); @@ -597,7 +597,7 @@ int (*how)(void); if (i != oap->line_count - 1 || oap->line_count == 1 || how != get_lisp_indent) { l = skipwhite(ml_get_curline()); - if (*l == NUL) /* empty or blank line */ + if (*l == '\0') /* empty or blank line */ count = 0; else count = how(); /* get the indent for this line */ @@ -654,8 +654,8 @@ int get_expr_register(void) new_line = getcmdline('=', 0L, 0); if (new_line == NULL) - return NUL; - if (*new_line == NUL) /* use previous line */ + return '\0'; + if (*new_line == '\0') /* use previous line */ vim_free(new_line); else set_expr_line(new_line); @@ -927,7 +927,7 @@ static int stuff_yank(int regname, char_u *p) return OK; } -static int execreg_lastc = NUL; +static int execreg_lastc = '\0'; /* * execute a yank register: copy it into the stuff buffer @@ -948,7 +948,7 @@ do_execreg ( int remap; if (regname == '@') { /* repeat previous one */ - if (execreg_lastc == NUL) { + if (execreg_lastc == '\0') { EMSG(_("E748: No previously used register")); return FAIL; } @@ -1046,17 +1046,17 @@ static void put_reedit_in_typebuf(int silent) { char_u buf[3]; - if (restart_edit != NUL) { + if (restart_edit != '\0') { if (restart_edit == 'V') { buf[0] = 'g'; buf[1] = 'R'; - buf[2] = NUL; + buf[2] = '\0'; } else { buf[0] = restart_edit == 'I' ? 'i' : restart_edit; - buf[1] = NUL; + buf[1] = '\0'; } if (ins_typebuf(buf, REMAP_NONE, 0, TRUE, silent) == OK) - restart_edit = NUL; + restart_edit = '\0'; } } @@ -1126,12 +1126,12 @@ insert_reg ( return FAIL; /* check for valid regname */ - if (regname != NUL && !valid_yank_reg(regname, FALSE)) + if (regname != '\0' && !valid_yank_reg(regname, FALSE)) return FAIL; if (regname == '.') /* insert last inserted text */ - retval = stuff_inserted(NUL, 1L, TRUE); + retval = stuff_inserted('\0', 1L, TRUE); else if (get_spec_reg(regname, &arg, &allocated, TRUE)) { if (arg == NULL) return FAIL; @@ -1167,7 +1167,7 @@ static void stuffescaped(char_u *arg, int literally) int c; char_u *start; - while (*arg != NUL) { + while (*arg != '\0') { /* Stuff a sequence of normal ASCII characters, that's fast. Also * stuff K_SPECIAL to get the effect of a special key when "literally" * is TRUE. */ @@ -1181,7 +1181,7 @@ static void stuffescaped(char_u *arg, int literally) stuffReadbuffLen(start, (long)(arg - start)); /* stuff a single special character */ - if (*arg != NUL) { + if (*arg != '\0') { if (has_mbyte) c = mb_cptr2char_adv(&arg); else @@ -1302,7 +1302,7 @@ cmdline_paste_reg ( || (i < y_current->y_size - 1 && !(remcr && i == y_current->y_size - 2 - && *y_current->y_array[i + 1] == NUL))) + && *y_current->y_array[i + 1] == '\0'))) cmdline_paste_str((char_u *)"\r", literally); /* Check for CTRL-C, in case someone tries to paste a few thousand @@ -1356,13 +1356,13 @@ int op_delete(oparg_T *oap) && !oap->is_VIsual && !oap->block_mode && oap->line_count > 1 - && oap->motion_force == NUL + && oap->motion_force == '\0' && oap->op_type == OP_DELETE) { ptr = ml_get(oap->end.lnum) + oap->end.col; - if (*ptr != NUL) + if (*ptr != '\0') ptr += oap->inclusive; ptr = skipwhite(ptr); - if (*ptr == NUL && inindent(0)) + if (*ptr == '\0' && inindent(0)) oap->motion_type = MLINE; } @@ -1373,7 +1373,7 @@ int op_delete(oparg_T *oap) if ( oap->motion_type == MCHAR && oap->line_count == 1 && oap->op_type == OP_DELETE - && *ml_get(oap->start.lnum) == NUL) { + && *ml_get(oap->start.lnum) == '\0') { /* * It's an error to operate on an empty region, when 'E' included in * 'cpoptions' (Vi compatible). @@ -1588,7 +1588,7 @@ int op_delete(oparg_T *oap) n = 1; /* When deleted a char in the line, reset coladd. */ - if (gchar_cursor() != NUL) + if (gchar_cursor() != '\0') curwin->w_cursor.coladd = 0; } if (oap->op_type == OP_DELETE @@ -1720,7 +1720,7 @@ int op_replace(oparg_T *oap, int c) */ /* If the range starts in virtual space, count the initial * coladd offset as part of "startspaces" */ - if (virtual_op && bd.is_short && *bd.textstart == NUL) { + if (virtual_op && bd.is_short && *bd.textstart == '\0') { pos_T vpos; vpos.lnum = curwin->w_cursor.lnum; @@ -1759,7 +1759,7 @@ int op_replace(oparg_T *oap, int c) oldp = ml_get_curline(); oldlen = STRLEN(oldp); newp = (char_u *) xmalloc((size_t)(oldlen + 1 + n)); - memset(newp, NUL, (size_t)(oldlen + 1 + n)); + memset(newp, '\0', (size_t)(oldlen + 1 + n)); /* copy up to deleted part */ memmove(newp, oldp, (size_t)bd.textcol); oldp += bd.textcol + bd.textlen; @@ -1809,7 +1809,7 @@ int op_replace(oparg_T *oap, int c) while (ltoreq(curwin->w_cursor, oap->end)) { n = gchar_cursor(); - if (n != NUL) { + if (n != '\0') { if ((*mb_char2len)(c) > 1 || (*mb_char2len)(n) > 1) { /* This is slow, but it handles replacing a single-byte * with a multi-byte and the other way around. */ @@ -2082,7 +2082,7 @@ void op_insert(oparg_T *oap, long count1) ) { /* Move the cursor to the character right of the block. */ curwin->w_set_curswant = TRUE; - while (*ml_get_cursor() != NUL + while (*ml_get_cursor() != '\0' && (curwin->w_cursor.col < bd.textcol + bd.textlen)) ++curwin->w_cursor.col; if (bd.is_short && !bd.is_MAX) { @@ -2105,7 +2105,7 @@ void op_insert(oparg_T *oap, long count1) } } - edit(NUL, FALSE, (linenr_T)count1); + edit('\0', FALSE, (linenr_T)count1); /* If user has moved off this line, we don't know what to do, so do * nothing. @@ -2225,7 +2225,7 @@ int op_change(oparg_T *oap) if (oap->block_mode) { /* Add spaces before getting the current line length. */ if (virtual_op && (curwin->w_cursor.coladd > 0 - || gchar_cursor() == NUL)) + || gchar_cursor() == '\0')) coladvance_force(getviscol()); firstline = ml_get(oap->start.lnum); pre_textlen = (long)STRLEN(firstline); @@ -2236,7 +2236,7 @@ int op_change(oparg_T *oap) if (oap->motion_type == MLINE) fix_indent(); - retval = edit(NUL, FALSE, (linenr_T)1); + retval = edit('\0', FALSE, (linenr_T)1); /* * In Visual block mode, handle copying the new text to all lines of the @@ -2458,7 +2458,7 @@ int op_yank(oparg_T *oap, int deleting, int mess) endcol = oap->end.col; if (virtual_op) { getvcol(curwin, &oap->end, &cs, NULL, &ce); - if (p[endcol] == NUL || (cs + oap->end.coladd < ce + if (p[endcol] == '\0' || (cs + oap->end.coladd < ce /* Don't add space for double-wide * char; endcol will be on last byte * of multi-byte char. */ @@ -2582,7 +2582,7 @@ static void yank_copy_line(struct block_def *bd, long y_idx) pnew += bd->textlen; copy_spaces(pnew, (size_t)bd->endspaces); pnew += bd->endspaces; - *pnew = NUL; + *pnew = '\0'; } @@ -2646,7 +2646,7 @@ do_put ( (count == -1 ? 'O' : 'i')), count, FALSE); /* Putting the text is done later, so can't really move the cursor to * the next character. Use "l" to simulate it. */ - if ((flags & PUT_CURSEND) && gchar_cursor() != NUL) + if ((flags & PUT_CURSEND) && gchar_cursor() != '\0') stuffcharReadbuff('l'); return; } @@ -2680,10 +2680,10 @@ do_put ( ptr = vim_strchr(ptr, '\n'); if (ptr != NULL) { if (y_array != NULL) - *ptr = NUL; + *ptr = '\0'; ++ptr; /* A trailing '\n' makes the register linewise. */ - if (*ptr == NUL) { + if (*ptr == '\0') { y_type = MLINE; break; } @@ -2784,7 +2784,7 @@ do_put ( coladvance_force(getviscol()); else curwin->w_cursor.coladd = 0; - } else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL) + } else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == '\0') coladvance_force(getviscol() + (dir == FORWARD)); } @@ -2798,7 +2798,7 @@ do_put ( char c = gchar_cursor(); colnr_T endcol2 = 0; - if (dir == FORWARD && c != NUL) { + if (dir == FORWARD && c != '\0') { if (ve_flags == VE_ALL) getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2); else @@ -2817,9 +2817,9 @@ do_put ( if (ve_flags == VE_ALL && (curwin->w_cursor.coladd > 0 || endcol2 == curwin->w_cursor.col)) { - if (dir == FORWARD && c == NUL) + if (dir == FORWARD && c == '\0') ++col; - if (dir != FORWARD && c != NUL) + if (dir != FORWARD && c != '\0') ++curwin->w_cursor.col; if (c == TAB) { if (dir == BACKWARD && curwin->w_cursor.col) @@ -2948,7 +2948,7 @@ do_put ( if (y_type == MCHAR) { /* if type is MCHAR, FORWARD is the same as BACKWARD on the next * char */ - if (dir == FORWARD && gchar_cursor() != NUL) { + if (dir == FORWARD && gchar_cursor() != '\0') { if (has_mbyte) { int bytelen = (*mb_ptr2len)(ml_get_cursor()); @@ -3060,7 +3060,7 @@ do_put ( lendiff = (int)STRLEN(ptr); if (*ptr == '#' && preprocs_left()) indent = 0; /* Leave # lines at start */ - else if (*ptr == NUL) + else if (*ptr == '\0') indent = 0; /* Ignore empty lines */ else if (first_indent) { indent_diff = orig_indent - get_indent(); @@ -3153,7 +3153,7 @@ end: void adjust_cursor_eol(void) { if (curwin->w_cursor.col > 0 - && gchar_cursor() == NUL + && gchar_cursor() == '\0' && (ve_flags & VE_ONEMORE) == 0 && !(restart_edit || (State & INSERT))) { /* Put the cursor on the last character in the line. */ @@ -3209,7 +3209,7 @@ void ex_display(exarg_T *eap) char_u *arg = eap->arg; int clen; - if (arg != NULL && *arg == NUL) + if (arg != NULL && *arg == '\0') arg = NULL; attr = hl_attr(HLF_8); @@ -3337,8 +3337,8 @@ dis_msg ( int l; n = (int)Columns - 6; - while (*p != NUL - && !(*p == ESC && skip_esc && *(p + 1) == NUL) + while (*p != '\0' + && !(*p == ESC && skip_esc && *(p + 1) == '\0') && (n -= ptr2cells(p)) >= 0) { if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) { msg_outtrans_len(p, l); @@ -3407,7 +3407,7 @@ static char_u *skip_comment(char_u *line, int process, int include_space, int *i * starting with a closing part of a three-part comment. That's good, * because we don't want to remove those as this would be annoying. */ - if (*comment_flags == ':' || *comment_flags == NUL) + if (*comment_flags == ':' || *comment_flags == '\0') line += lead_len; return line; @@ -3428,8 +3428,8 @@ int do_join(long count, int insert_space, int save_undo, int use_formatoptions) char_u *cend; char_u *newp; char_u *spaces; /* number of spaces inserted before a line */ - int endcurr1 = NUL; - int endcurr2 = NUL; + int endcurr1 = '\0'; + int endcurr2 = '\0'; int currsize = 0; /* size of the current line */ int sumsize = 0; /* size of the long new line */ linenr_T t; @@ -3501,7 +3501,7 @@ int do_join(long count, int insert_space, int save_undo, int use_formatoptions) } currsize = (int)STRLEN(curr); sumsize += currsize + spaces[t]; - endcurr1 = endcurr2 = NUL; + endcurr1 = endcurr2 = '\0'; if (insert_space && currsize > 0) { if (has_mbyte) { cend = curr + currsize; @@ -3626,7 +3626,7 @@ static int same_leader(linenr_T lnum, int leader1_len, char_u *leader1_flags, in if (*p == COM_END) return FALSE; if (*p == COM_START) { - if (*(ml_get(lnum) + leader1_len) == NUL) + if (*(ml_get(lnum) + leader1_len) == '\0') return FALSE; if (leader2_flags == NULL || leader2_len == 0) return FALSE; @@ -3739,7 +3739,7 @@ void op_formatexpr(oparg_T *oap) /* When there is no change: need to remove the Visual selection */ redraw_curbuf_later(INVERTED); - if (fex_format(oap->start.lnum, oap->line_count, NUL) != 0) + if (fex_format(oap->start.lnum, oap->line_count, '\0') != 0) /* As documented: when 'formatexpr' returns non-zero fall back to * internal formatting. */ op_format(oap, FALSE); @@ -3941,7 +3941,7 @@ format_lines ( State = INSERT; /* for open_line() */ smd_save = p_smd; p_smd = FALSE; - insertchar(NUL, INSCHAR_FORMAT + insertchar('\0', INSCHAR_FORMAT + (do_comments ? INSCHAR_DO_COM : 0) + (do_comments && do_comments_list ? INSCHAR_COM_LIST : 0) @@ -4010,7 +4010,7 @@ static int ends_in_white(linenr_T lnum) char_u *s = ml_get(lnum); size_t l; - if (*s == NUL) + if (*s == '\0') return FALSE; /* Don't use STRLEN() inside vim_iswhite(), SAS/C complains: "macro * invocation may call function multiple times". */ @@ -4046,9 +4046,9 @@ static int fmt_check_par(linenr_T lnum, int *leader_len, char_u **leader_flags, ++flags; } - return *skipwhite(ptr + *leader_len) == NUL + return *skipwhite(ptr + *leader_len) == '\0' || (*leader_len > 0 && *flags == COM_END) - || startPS(lnum, NUL, FALSE); + || startPS(lnum, '\0', FALSE); } /* @@ -4068,7 +4068,7 @@ int paragraph_start(linenr_T lnum) return TRUE; /* start of the file */ p = ml_get(lnum - 1); - if (*p == NUL) + if (*p == '\0') return TRUE; /* after empty line */ do_comments = has_format_option(FO_Q_COMS); @@ -4180,7 +4180,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, int i } } else { prev_pend = pend; - while (bdp->end_vcol <= oap->end_vcol && *pend != NUL) { + while (bdp->end_vcol <= oap->end_vcol && *pend != '\0') { /* Count a tab for what it's worth (if list mode not on) */ prev_pend = pend; incr = lbr_chartabsize_adv(&pend, (colnr_T)bdp->end_vcol); @@ -4292,7 +4292,7 @@ int do_addsub(int command, linenr_T Prenum1) */ col = curwin->w_cursor.col; - while (ptr[col] != NUL + while (ptr[col] != '\0' && !vim_isdigit(ptr[col]) && !(doalp && ASCII_ISALPHA(ptr[col]))) ++col; @@ -4452,7 +4452,7 @@ int do_addsub(int command, linenr_T Prenum1) if (firstdigit == '0' && !(dooct && hex == 0)) while (length-- > 0) *ptr++ = '0'; - *ptr = NUL; + *ptr = '\0'; STRCAT(buf1, buf2); ins_str(buf1); /* insert the new number */ vim_free(buf1); @@ -4495,7 +4495,7 @@ int read_viminfo_register(vir_T *virp, int force) if (*str == '@') { /* "x@: register x used for @@ */ - if (force || execreg_lastc == NUL) + if (force || execreg_lastc == '\0') execreg_lastc = str[-1]; } @@ -4583,7 +4583,7 @@ void write_viminfo_registers(FILE *fp) num_lines = y_regs[i].y_size; if (num_lines == 0 || (num_lines == 1 && y_regs[i].y_type == MCHAR - && *y_regs[i].y_array[0] == NUL)) + && *y_regs[i].y_array[0] == '\0')) continue; if (max_kbyte > 0) { @@ -4659,7 +4659,7 @@ char_u get_reg_type(int regname, long *reglen) } - if (regname != NUL && !valid_yank_reg(regname, FALSE)) + if (regname != '\0' && !valid_yank_reg(regname, FALSE)) return MAUTO; get_yank_register(regname, FALSE); @@ -4703,7 +4703,7 @@ get_reg_contents ( regname = '"'; /* check for valid regname */ - if (regname != NUL && !valid_yank_reg(regname, FALSE)) + if (regname != '\0' && !valid_yank_reg(regname, FALSE)) return NULL; @@ -4751,7 +4751,7 @@ get_reg_contents ( if (y_current->y_type == MLINE || i < y_current->y_size - 1) retval[len++] = '\n'; } - retval[len] = NUL; + retval[len] = '\0'; } return retval; @@ -4911,10 +4911,10 @@ str_to_reg ( if (i) memmove(s + extra, str + start, (size_t)i); extra += i; - s[extra] = NUL; + s[extra] = '\0'; y_ptr->y_array[lnum++] = s; while (--extra >= 0) { - if (*s == NUL) + if (*s == '\0') *s = '\n'; /* replace NUL with newline */ ++s; } @@ -4958,7 +4958,7 @@ static long line_count_info(char_u *line, long *wc, long *cc, long limit, int eo long chars = 0; int is_word = 0; - for (i = 0; i < limit && line[i] != NUL; ) { + for (i = 0; i < limit && line[i] != '\0'; ) { if (is_word) { if (vim_isspace(line[i])) { words++; @@ -4975,7 +4975,7 @@ static long line_count_info(char_u *line, long *wc, long *cc, long limit, int eo *wc += words; /* Add eol_size if the end of line was reached before hitting limit. */ - if (i < limit && line[i] == NUL) { + if (i < limit && line[i] == '\0') { i += eol_size; chars += eol_size; } @@ -5127,7 +5127,7 @@ void cursor_pos_info(void) vim_snprintf((char *)buf1, sizeof(buf1), _("%" PRId64 " Cols; "), (int64_t)(oparg.end_vcol - oparg.start_vcol + 1)); } else - buf1[0] = NUL; + buf1[0] = '\0'; if (char_count_cursor == byte_count_cursor && char_count == byte_count) diff --git a/src/option.c b/src/option.c index 210a747022..7ad6f20d66 100644 --- a/src/option.c +++ b/src/option.c @@ -1944,7 +1944,7 @@ void set_init_1(void) * Find default value for 'shell' option. * Don't use it if it is empty. */ - if (((p = (char_u *)os_getenv("SHELL")) != NULL && *p != NUL) + if (((p = (char_u *)os_getenv("SHELL")) != NULL && *p != '\0') ) set_string_default("sh", p); @@ -1966,12 +1966,12 @@ void set_init_1(void) for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) { mustfree = FALSE; # ifdef UNIX - if (*names[n] == NUL) + if (*names[n] == '\0') p = (char_u *)"/tmp"; else # endif p = vim_getenv((char_u *)names[n], &mustfree); - if (p != NULL && *p != NUL) { + if (p != NULL && *p != '\0') { /* First time count the NUL, otherwise count the ','. */ len = (int)STRLEN(p) + 3; ga_grow(&ga, len); @@ -2036,7 +2036,7 @@ void set_init_1(void) { buf[0] = ','; /* start with ",", current dir first */ j = 1; - for (i = 0; cdpath[i] != NUL; ++i) { + for (i = 0; cdpath[i] != '\0'; ++i) { if (vim_ispathlistsep(cdpath[i])) buf[j++] = ','; else { @@ -2045,7 +2045,7 @@ void set_init_1(void) buf[j++] = cdpath[i]; } } - buf[j] = NUL; + buf[j] = '\0'; opt_idx = findoption((char_u *)"cdpath"); if (opt_idx >= 0) { options[opt_idx].def_val[VI_DEFAULT] = buf; @@ -2421,7 +2421,7 @@ static char_u *term_bg_default(void) || ((p = (char_u *)os_getenv("COLORFGBG")) != NULL && (p = vim_strrchr(p, ';')) != NULL && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') - && p[2] == NUL)) + && p[2] == '\0')) return (char_u *)"dark"; return (char_u *)"light"; } @@ -2463,7 +2463,7 @@ void set_init_3(void) * But don't do that for Windows, it's common to have a space in the path. */ p = skiptowhite(p_sh); - if (*p == NUL) { + if (*p == '\0') { /* No white space, use the tail. */ p = vim_strsave(path_tail(p_sh)); } else { @@ -2540,7 +2540,7 @@ void set_helplang_default(char_u *lang) p_hlg[0] = TOLOWER_ASC(p_hlg[3]); p_hlg[1] = TOLOWER_ASC(p_hlg[4]); } - p_hlg[2] = NUL; + p_hlg[2] = '\0'; } options[idx].flags |= P_ALLOCED; } @@ -2619,13 +2619,13 @@ do_set ( int cp_val = 0; char_u key_name[2]; - if (*arg == NUL) { + if (*arg == '\0') { showoptions(0, opt_flags); did_show = TRUE; goto theend; } - while (*arg != NUL) { /* loop to process all options */ + while (*arg != '\0') { /* loop to process all options */ errmsg = NULL; startarg = arg; /* remember for error message */ @@ -2670,14 +2670,14 @@ do_set ( len = 5; else { len = 1; - while (arg[len] != NUL && arg[len] != '>') + while (arg[len] != '\0' && arg[len] != '>') ++len; } if (arg[len] != '>') { errmsg = e_invarg; goto skip; } - arg[len] = NUL; /* put NUL after name */ + arg[len] = '\0'; /* put NUL after name */ if (arg[1] == 't' && arg[2] == '_') /* could be term code */ opt_idx = findoption(arg + 1); arg[len++] = '>'; /* restore '>' */ @@ -2694,7 +2694,7 @@ do_set ( while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') ++len; nextchar = arg[len]; - arg[len] = NUL; /* put NUL after name */ + arg[len] = '\0'; /* put NUL after name */ opt_idx = findoption(arg); arg[len] = nextchar; /* restore nextchar */ if (opt_idx == -1) @@ -2711,7 +2711,7 @@ do_set ( adding = FALSE; prepending = FALSE; removing = FALSE; - if (arg[len] != NUL && arg[len + 1] == '=') { + if (arg[len] != '\0' && arg[len + 1] == '=') { if (arg[len] == '+') { adding = TRUE; /* "+=" */ ++len; @@ -2802,7 +2802,7 @@ do_set ( } } if (vim_strchr((char_u *)"?!&<", nextchar) != NULL - && arg[1] != NUL && !vim_iswhite(arg[1])) { + && arg[1] != '\0' && !vim_iswhite(arg[1])) { errmsg = e_trailing; goto skip; } @@ -2849,7 +2849,7 @@ do_set ( (void)show_one_termcode(key_name, p, TRUE); } if (nextchar != '?' - && nextchar != NUL && !vim_iswhite(afterchar)) + && nextchar != '\0' && !vim_iswhite(afterchar)) errmsg = e_trailing; } else { if (flags & P_BOOL) { /* boolean */ @@ -2882,7 +2882,7 @@ do_set ( * ":set invopt": invert * ":set opt" or ":set noopt": set or reset */ - if (nextchar != NUL && !vim_iswhite(afterchar)) { + if (nextchar != '\0' && !vim_iswhite(afterchar)) { errmsg = e_trailing; goto skip; } @@ -2947,7 +2947,7 @@ do_set ( i += 2; while (VIM_ISDIGIT(arg[i])) ++i; - if (arg[i] != NUL && !vim_iswhite(arg[i])) { + if (arg[i] != '\0' && !vim_iswhite(arg[i])) { errmsg = e_invarg; goto skip; } @@ -3021,7 +3021,7 @@ do_set ( * Misuse errbuf[] for the resulting string. */ if (varp == (char_u *)&p_kp - && (*arg == NUL || *arg == ' ')) { + && (*arg == '\0' || *arg == ' ')) { STRCPY(errbuf, ":help"); save_arg = arg; arg = errbuf; @@ -3056,7 +3056,7 @@ do_set ( */ else if (varp == (char_u *)&p_ww && VIM_ISDIGIT(*arg)) { - *errbuf = NUL; + *errbuf = '\0'; i = getdigits(&arg); if (i & 1) STRCAT(errbuf, "b,"); @@ -3068,8 +3068,8 @@ do_set ( STRCAT(errbuf, "<,>,"); if (i & 16) STRCAT(errbuf, "[,],"); - if (*errbuf != NUL) /* remove trailing , */ - errbuf[STRLEN(errbuf) - 1] = NUL; + if (*errbuf != '\0') /* remove trailing , */ + errbuf[STRLEN(errbuf) - 1] = '\0'; save_arg = arg; arg = errbuf; } @@ -3113,7 +3113,7 @@ do_set ( * The reverse is found in ExpandOldSetting(). */ while (*arg && !vim_iswhite(*arg)) { - if (*arg == '\\' && arg[1] != NUL + if (*arg == '\\' && arg[1] != '\0' #ifdef BACKSLASH_IN_FILENAME && !((flags & P_EXPAND) && vim_isfilec(arg[1]) @@ -3132,7 +3132,7 @@ do_set ( } else *s++ = *arg++; } - *s = NUL; + *s = '\0'; /* * Expand environment variables and ~. @@ -3165,7 +3165,7 @@ do_set ( && STRNCMP(s, newval, i) == 0 && (!(flags & P_COMMA) || s[i] == ',' - || s[i] == NUL)) + || s[i] == '\0')) break; /* Count backslashes. Only a comma with an * even number of backslashes before it is @@ -3187,8 +3187,8 @@ do_set ( /* concatenate the two strings; add a ',' if * needed */ if (adding || prepending) { - comma = ((flags & P_COMMA) && *origval != NUL - && *newval != NUL); + comma = ((flags & P_COMMA) && *origval != '\0' + && *newval != '\0'); if (adding) { i = (int)STRLEN(origval); memmove(newval + i + comma, newval, @@ -3258,10 +3258,10 @@ do_set ( } else { ++arg; /* jump to after the '=' or ':' */ for (p = arg; *p && !vim_iswhite(*p); ++p) - if (*p == '\\' && p[1] != NUL) + if (*p == '\\' && p[1] != '\0') ++p; nextchar = *p; - *p = NUL; + *p = '\0'; add_termcode(key_name, arg, FALSE); *p = nextchar; } @@ -3284,8 +3284,8 @@ skip: * - skip one "=val" argument (for hidden options ":set gfn =xx") */ for (i = 0; i < 2; ++i) { - while (*arg != NUL && !vim_iswhite(*arg)) - if (*arg++ == '\\' && *arg != NUL) + while (*arg != '\0' && !vim_iswhite(*arg)) + if (*arg++ == '\\' && *arg != '\0') ++arg; arg = skipwhite(arg); if (*arg != '=') @@ -3300,7 +3300,7 @@ skip: /* append the argument with the error */ STRCAT(IObuff, ": "); memmove(IObuff + i, startarg, (arg - startarg)); - IObuff[i + (arg - startarg)] = NUL; + IObuff[i + (arg - startarg)] = '\0'; } /* make sure all characters are printable */ trans_characters(IObuff, IOSIZE); @@ -3389,7 +3389,7 @@ static char_u *check_cedit(void) { int n; - if (*p_cedit == NUL) + if (*p_cedit == '\0') cedit_key = -1; else { n = string_to_key(p_cedit); @@ -3893,7 +3893,7 @@ did_set_string_option ( } /* 'term' */ else if (varp == &T_NAME) { - if (T_NAME[0] == NUL) + if (T_NAME[0] == '\0') errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string"); else if (set_termname(T_NAME) == FAIL) errmsg = (char_u *)N_("E522: Not found in termcap"); @@ -3952,12 +3952,12 @@ did_set_string_option ( /* 'helplang' */ else if (varp == &p_hlg) { /* Check for "", "ab", "ab,cd", etc. */ - for (s = p_hlg; *s != NUL; s += 3) { - if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) { + for (s = p_hlg; *s != '\0'; s += 3) { + if (s[1] == '\0' || ((s[2] != ',' || s[3] == '\0') && s[2] != '\0')) { errmsg = e_invarg; break; } - if (s[2] == NUL) + if (s[2] == '\0') break; } } @@ -4033,7 +4033,7 @@ did_set_string_option ( } /* 'winaltkeys' */ else if (varp == &p_wak) { - if (*p_wak == NUL + if (*p_wak == '\0' || check_opt_strings(p_wak, p_wak_values, FALSE) != OK) errmsg = e_invarg; } @@ -4075,13 +4075,13 @@ did_set_string_option ( if (errmsg == NULL) { /* When 'keymap' is used and 'encoding' changes, reload the keymap * (with another encoding). */ - if (varp == &p_enc && *curbuf->b_p_keymap != NUL) + if (varp == &p_enc && *curbuf->b_p_keymap != '\0') (void)keymap_init(); /* When 'termencoding' is not empty and 'encoding' changes or when * 'termencoding' changes, need to setup for keyboard input and * display output conversion. */ - if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc)) { + if (((varp == &p_enc && *p_tenc != '\0') || varp == &p_tenc)) { convert_setup(&input_conv, p_tenc, p_enc); convert_setup(&output_conv, p_enc, p_tenc); } @@ -4095,7 +4095,7 @@ did_set_string_option ( p_penc = p; } else { /* Ensure lower case and '-' for '_' */ - for (s = p_penc; *s != NUL; s++) { + for (s = p_penc; *s != '\0'; s++) { if (*s == '_') *s = '-'; else @@ -4107,7 +4107,7 @@ did_set_string_option ( errmsg = keymap_init(); if (errmsg == NULL) { - if (*curbuf->b_p_keymap != NUL) { + if (*curbuf->b_p_keymap != '\0') { /* Installed a new keymap, switch on using it. */ curbuf->b_p_iminsert = B_IMODE_LMAP; if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) @@ -4167,7 +4167,7 @@ did_set_string_option ( errmsg = e_invarg; else { /* When setting the global value to empty, make it "zip". */ - if (*p_cm == NUL) { + if (*p_cm == '\0') { if (new_value_alloced) free_string_option(p_cm); p_cm = vim_strsave((char_u *)"zip"); @@ -4177,11 +4177,11 @@ did_set_string_option ( /* Need to update the swapfile when the effective method changed. * Set "s" to the effective old value, "p" to the effective new * method and compare. */ - if ((opt_flags & OPT_LOCAL) && *oldval == NUL) + if ((opt_flags & OPT_LOCAL) && *oldval == '\0') s = p_cm; /* was previously using the global value */ else s = oldval; - if (*curbuf->b_p_cm == NUL) + if (*curbuf->b_p_cm == '\0') p = p_cm; /* is now using the global value */ else p = curbuf->b_p_cm; @@ -4195,7 +4195,7 @@ did_set_string_option ( buf_T *buf; for (buf = firstbuf; buf != NULL; buf = buf->b_next) - if (buf != curbuf && *buf->b_p_cm == NUL) + if (buf != curbuf && *buf->b_p_cm == '\0') ml_set_crypt_key(buf, buf->b_p_key, crypt_method_from_string(oldval)); } @@ -4204,33 +4204,33 @@ did_set_string_option ( /* 'matchpairs' */ else if (gvarp == &p_mps) { if (has_mbyte) { - for (p = *varp; *p != NUL; ++p) { + for (p = *varp; *p != '\0'; ++p) { int x2 = -1; int x3 = -1; - if (*p != NUL) + if (*p != '\0') p += mb_ptr2len(p); - if (*p != NUL) + if (*p != '\0') x2 = *p++; - if (*p != NUL) { + if (*p != '\0') { x3 = mb_ptr2char(p); p += mb_ptr2len(p); } - if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) { + if (x2 != ':' || x3 == -1 || (*p != '\0' && *p != ',')) { errmsg = e_invarg; break; } - if (*p == NUL) + if (*p == '\0') break; } } else { /* Check for "x:y,x:y" */ - for (p = *varp; *p != NUL; p += 4) { - if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ',')) { + for (p = *varp; *p != '\0'; p += 4) { + if (p[1] != ':' || p[2] == '\0' || (p[3] != '\0' && p[3] != ',')) { errmsg = e_invarg; break; } - if (p[3] == NUL) + if (p[3] == '\0') break; } } @@ -4246,14 +4246,14 @@ did_set_string_option ( } ++s; } - if (*s++ == NUL) + if (*s++ == '\0') errmsg = (char_u *)N_("E524: Missing colon"); - else if (*s == ',' || *s == NUL) + else if (*s == ',' || *s == '\0') errmsg = (char_u *)N_("E525: Zero length string"); if (errmsg != NULL) break; while (*s && *s != ',') { - if (*s == '\\' && s[1] != NUL) + if (*s == '\\' && s[1] != '\0') ++s; ++s; } @@ -4275,7 +4275,7 @@ did_set_string_option ( /* 'verbosefile' */ else if (varp == &p_vfile) { verbose_stop(); - if (*p_vfile != NUL && verbose_open() == FAIL) + if (*p_vfile != '\0' && verbose_open() == FAIL) errmsg = e_invarg; } /* 'viminfo' */ @@ -4409,7 +4409,7 @@ did_set_string_option ( /* 'selection' */ else if (varp == &p_sel) { - if (*p_sel == NUL + if (*p_sel == '\0' || check_opt_strings(p_sel, p_sel_values, FALSE) != OK) errmsg = e_invarg; } @@ -4542,7 +4542,7 @@ did_set_string_option ( errmsg = illegal_char(errbuf, *s); break; } - if (*++s != NUL && *s != ',' && *s != ' ') { + if (*++s != '\0' && *s != ',' && *s != ' ') { if (s[-1] == 'k' || s[-1] == 's') { /* skip optional filename after 'k' and 's' */ while (*s && *s != ',' && *s != ' ') { @@ -4583,7 +4583,7 @@ did_set_string_option ( /* 'backspace' */ else if (varp == &p_bs) { if (VIM_ISDIGIT(*p_bs)) { - if (*p_bs >'2' || p_bs[1] != NUL) + if (*p_bs >'2' || p_bs[1] != '\0') errmsg = e_invarg; } else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) errmsg = e_invarg; @@ -4601,7 +4601,7 @@ did_set_string_option ( /* 'foldmethod' */ else if (gvarp == &curwin->w_allbuf_opt.wo_fdm) { if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK - || *curwin->w_p_fdm == NUL) + || *curwin->w_p_fdm == '\0') errmsg = e_invarg; else { foldUpdateAll(curwin); @@ -4619,14 +4619,14 @@ did_set_string_option ( p = vim_strchr(*varp, ','); if (p == NULL) errmsg = (char_u *)N_("E536: comma required"); - else if (p == *varp || p[1] == NUL) + else if (p == *varp || p[1] == '\0') errmsg = e_invarg; else if (foldmethodIsMarker(curwin)) foldUpdateAll(curwin); } /* 'commentstring' */ else if (gvarp == &p_cms) { - if (**varp != NUL && strstr((char *)*varp, "%s") == NULL) + if (**varp != '\0' && strstr((char *)*varp, "%s") == NULL) errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s"); } /* 'foldopen' */ @@ -4657,14 +4657,14 @@ did_set_string_option ( } else if (varp == &p_csqf) { if (p_csqf != NULL) { p = p_csqf; - while (*p != NUL) { + while (*p != '\0') { if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL - || p[1] == NUL + || p[1] == '\0' || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL - || (p[2] != NUL && p[2] != ',')) { + || (p[2] != '\0' && p[2] != ',')) { errmsg = e_invarg; break; - } else if (p[2] == NUL) + } else if (p[2] == '\0') break; else p += 3; @@ -4769,7 +4769,7 @@ did_set_string_option ( * Use the first name in 'spelllang' up to '_region' or * '.encoding'. */ - for (p = q; *p != NUL; ++p) + for (p = q; *p != '\0'; ++p) if (vim_strchr((char_u *)"_.,", *p) != NULL) break; vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q); @@ -4778,7 +4778,7 @@ did_set_string_option ( } if (varp == &p_mouse) { - if (*p_mouse == NUL) + if (*p_mouse == '\0') mch_setmouse(FALSE); /* switch mouse off */ else setmouse(); /* in case 'mouse' changed */ @@ -4817,7 +4817,7 @@ char_u *check_colorcolumn(win_T *wp) if (wp->w_buffer == NULL) return NULL; /* buffer was closed */ - for (s = wp->w_p_cc; *s != NUL && count < 255; ) { + for (s = wp->w_p_cc; *s != '\0' && count < 255; ) { if (*s == '-' || *s == '+') { /* -N and +N: add to 'textwidth' */ col = (*s == '-') ? -1 : 1; @@ -4836,11 +4836,11 @@ char_u *check_colorcolumn(win_T *wp) return e_invarg; color_cols[count++] = col - 1; /* 1-based to 0-based */ skip: - if (*s == NUL) + if (*s == '\0') break; if (*s != ',') return e_invarg; - if (*++s == NUL) + if (*++s == '\0') return e_invarg; /* illegal trailing comma as in "set cc=80," */ } @@ -4911,9 +4911,9 @@ static char_u *set_chars_option(char_u **varp) * 'fillchars', NUL for 'listchars' */ for (i = 0; i < entries; ++i) if (tab[i].cp != NULL) - *(tab[i].cp) = (varp == &p_lcs ? NUL : ' '); + *(tab[i].cp) = (varp == &p_lcs ? '\0' : ' '); if (varp == &p_lcs) - lcs_tab1 = NUL; + lcs_tab1 = '\0'; else fill_diff = '-'; } @@ -4923,19 +4923,19 @@ static char_u *set_chars_option(char_u **varp) len = (int)STRLEN(tab[i].name); if (STRNCMP(p, tab[i].name, len) == 0 && p[len] == ':' - && p[len + 1] != NUL) { + && p[len + 1] != '\0') { s = p + len + 1; c1 = mb_ptr2char_adv(&s); if (mb_char2cells(c1) > 1) continue; if (tab[i].cp == &lcs_tab2) { - if (*s == NUL) + if (*s == '\0') continue; c2 = mb_ptr2char_adv(&s); if (mb_char2cells(c2) > 1) continue; } - if (*s == ',' || *s == NUL) { + if (*s == ',' || *s == '\0') { if (round) { if (tab[i].cp == &lcs_tab2) { lcs_tab1 = c1; @@ -5032,7 +5032,7 @@ static char_u *compile_cap_prog(synblock_T *synblock) regprog_T *rp = synblock->b_cap_prog; char_u *re; - if (*synblock->b_p_spc == NUL) + if (*synblock->b_p_spc == '\0') synblock->b_cap_prog = NULL; else { /* Prepend a ^ so that we only match at one column */ @@ -5292,7 +5292,7 @@ set_bool_option ( T_XS = (char_u *)"y"; else if (!p_wiv && old_value) T_XS = empty_option; - p_wiv = (*T_XS != NUL); + p_wiv = (*T_XS != '\0'); } else if ((int *)varp == &p_acd) { /* Change directories when the 'acd' option is set now. */ do_autochdir(); @@ -5938,7 +5938,7 @@ get_option_value ( if (stringval != NULL) { /* never return the value of the crypt key */ if ((char_u **)varp == &curbuf->b_p_key - && **(char_u **)(varp) != NUL) + && **(char_u **)(varp) != '\0') *stringval = vim_strsave((char_u *)"*****"); else *stringval = vim_strsave(*(char_u **)(varp)); @@ -6004,7 +6004,7 @@ set_option_value ( * to zero. */ for (idx = 0; string[idx] == '0'; ++idx) ; - if (string[idx] != NUL || idx == 0) { + if (string[idx] != '\0' || idx == 0) { /* There's another character after zeros or the string * is empty. In both cases, we are trying to set a * num option using a string. */ @@ -6036,7 +6036,7 @@ char_u *get_term_code(char_u *tname) char_u *varp; if (tname[0] != 't' || tname[1] != '_' || - tname[2] == NUL || tname[3] == NUL) + tname[2] == '\0' || tname[3] == '\0') return NULL; if ((opt_idx = findoption(tname)) >= 0) { varp = get_varp(&(options[opt_idx])); @@ -6405,7 +6405,7 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int e * CTRL-V or backslash */ if (valuep == &p_pt) { s = *valuep; - while (*s != NUL) + while (*s != '\0') if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) return FAIL; } else if (expand) { @@ -6679,33 +6679,33 @@ static char_u *get_varp(struct vimoption *p) case PV_NONE: return p->var; /* global option with local value: use local value if it's been set */ - case PV_EP: return *curbuf->b_p_ep != NUL + case PV_EP: return *curbuf->b_p_ep != '\0' ? (char_u *)&curbuf->b_p_ep : p->var; - case PV_KP: return *curbuf->b_p_kp != NUL + case PV_KP: return *curbuf->b_p_kp != '\0' ? (char_u *)&curbuf->b_p_kp : p->var; - case PV_PATH: return *curbuf->b_p_path != NUL + case PV_PATH: return *curbuf->b_p_path != '\0' ? (char_u *)&(curbuf->b_p_path) : p->var; case PV_AR: return curbuf->b_p_ar >= 0 ? (char_u *)&(curbuf->b_p_ar) : p->var; - case PV_TAGS: return *curbuf->b_p_tags != NUL + case PV_TAGS: return *curbuf->b_p_tags != '\0' ? (char_u *)&(curbuf->b_p_tags) : p->var; - case PV_DEF: return *curbuf->b_p_def != NUL + case PV_DEF: return *curbuf->b_p_def != '\0' ? (char_u *)&(curbuf->b_p_def) : p->var; - case PV_INC: return *curbuf->b_p_inc != NUL + case PV_INC: return *curbuf->b_p_inc != '\0' ? (char_u *)&(curbuf->b_p_inc) : p->var; - case PV_DICT: return *curbuf->b_p_dict != NUL + case PV_DICT: return *curbuf->b_p_dict != '\0' ? (char_u *)&(curbuf->b_p_dict) : p->var; - case PV_TSR: return *curbuf->b_p_tsr != NUL + case PV_TSR: return *curbuf->b_p_tsr != '\0' ? (char_u *)&(curbuf->b_p_tsr) : p->var; - case PV_EFM: return *curbuf->b_p_efm != NUL + case PV_EFM: return *curbuf->b_p_efm != '\0' ? (char_u *)&(curbuf->b_p_efm) : p->var; - case PV_GP: return *curbuf->b_p_gp != NUL + case PV_GP: return *curbuf->b_p_gp != '\0' ? (char_u *)&(curbuf->b_p_gp) : p->var; - case PV_MP: return *curbuf->b_p_mp != NUL + case PV_MP: return *curbuf->b_p_mp != '\0' ? (char_u *)&(curbuf->b_p_mp) : p->var; - case PV_CM: return *curbuf->b_p_cm != NUL + case PV_CM: return *curbuf->b_p_cm != '\0' ? (char_u *)&(curbuf->b_p_cm) : p->var; - case PV_STL: return *curwin->w_p_stl != NUL + case PV_STL: return *curwin->w_p_stl != '\0' ? (char_u *)&(curwin->w_p_stl) : p->var; case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL ? (char_u *)&(curbuf->b_p_ul) : p->var; @@ -6813,7 +6813,7 @@ static char_u *get_varp(struct vimoption *p) */ char_u *get_equalprg(void) { - if (*curbuf->b_p_ep == NUL) + if (*curbuf->b_p_ep == '\0') return p_ep; return curbuf->b_p_ep; } @@ -7134,7 +7134,7 @@ void set_imsearch_global(void) } static int expand_option_idx = -1; -static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; +static char_u expand_option_name[5] = {'t', '_', '\0', '\0', '\0'}; static int expand_option_flags = 0; void @@ -7155,7 +7155,7 @@ set_context_in_set_cmd ( expand_option_flags = opt_flags; xp->xp_context = EXPAND_SETTINGS; - if (*arg == NUL) { + if (*arg == '\0') { xp->xp_pattern = arg; return; } @@ -7189,7 +7189,7 @@ set_context_in_set_cmd ( xp->xp_pattern = arg = p; if (*arg == '<') { while (*p != '>') - if (*p++ == NUL) /* expand terminal option name */ + if (*p++ == '\0') /* expand terminal option name */ return; key = get_special_key_code(arg + 1); if (key == 0) { /* unknown name */ @@ -7203,9 +7203,9 @@ set_context_in_set_cmd ( } else { if (p[0] == 't' && p[1] == '_') { p += 2; - if (*p != NUL) + if (*p != '\0') ++p; - if (*p == NUL) + if (*p == '\0') return; /* expand option name */ nextchar = *++p; is_term_option = TRUE; @@ -7215,10 +7215,10 @@ set_context_in_set_cmd ( /* Allow * wildcard */ while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') p++; - if (*p == NUL) + if (*p == '\0') return; nextchar = *p; - *p = NUL; + *p = '\0'; opt_idx = findoption(arg); *p = nextchar; if (opt_idx == -1 || options[opt_idx].var == NULL) { @@ -7242,7 +7242,7 @@ set_context_in_set_cmd ( xp->xp_context = EXPAND_UNSUCCESSFUL; return; } - if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) { + if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == '\0') { xp->xp_context = EXPAND_OLD_SETTING; if (is_term_option) expand_option_idx = -1; @@ -7362,7 +7362,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u *** name_buf[3] = str[2]; name_buf[4] = str[3]; name_buf[5] = '>'; - name_buf[6] = NUL; + name_buf[6] = '\0'; if (vim_regexec(regmatch, name_buf, (colnr_T)0)) { match = TRUE; str = name_buf; @@ -7390,7 +7390,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u *** name_buf[1] = '_'; name_buf[2] = str[0]; name_buf[3] = str[1]; - name_buf[4] = NUL; + name_buf[4] = '\0'; match = FALSE; if (vim_regexec(regmatch, name_buf, (colnr_T)0)) @@ -7402,7 +7402,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u *** name_buf[3] = str[0]; name_buf[4] = str[1]; name_buf[5] = '>'; - name_buf[6] = NUL; + name_buf[6] = '\0'; if (vim_regexec(regmatch, name_buf, (colnr_T)0)) match = TRUE; @@ -7486,7 +7486,7 @@ int ExpandOldSetting(int *num_file, char_u ***file) #ifdef BACKSLASH_IN_FILENAME /* For MS-Windows et al. we don't double backslashes at the start and * before a file name character. */ - for (var = buf; *var != NUL; mb_ptr_adv(var)) + for (var = buf; *var != '\0'; mb_ptr_adv(var)) if (var[0] == '\\' && var[1] == '\\' && expand_option_idx >= 0 && (options[expand_option_idx].flags & P_EXPAND) @@ -7526,7 +7526,7 @@ option_value2string ( } else { /* P_STRING */ varp = *(char_u **)(varp); if (varp == NULL) /* just in case */ - NameBuff[0] = NUL; + NameBuff[0] = '\0'; /* don't show the actual value of 'key', only that it's set */ else if (opp->var == (char_u *)&p_key && *varp) STRCPY(NameBuff, "*****"); @@ -7660,10 +7660,10 @@ static void langmap_set(void) ga_clear(&langmap_mapga); /* clear the previous map first */ langmap_init(); /* back to one-to-one map */ - for (p = p_langmap; p[0] != NUL; ) { - for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; + for (p = p_langmap; p[0] != '\0'; ) { + for (p2 = p; p2[0] != '\0' && p2[0] != ',' && p2[0] != ';'; mb_ptr_adv(p2)) { - if (p2[0] == '\\' && p2[1] != NUL) + if (p2[0] == '\\' && p2[1] != '\0') ++p2; } if (p2[0] == ';') @@ -7675,10 +7675,10 @@ static void langmap_set(void) ++p; break; } - if (p[0] == '\\' && p[1] != NUL) + if (p[0] == '\\' && p[1] != '\0') ++p; from = (*mb_ptr2char)(p); - to = NUL; + to = '\0'; if (p2 == NULL) { mb_ptr_adv(p); if (p[0] != ',') { @@ -7693,7 +7693,7 @@ static void langmap_set(void) to = (*mb_ptr2char)(p2); } } - if (to == NUL) { + if (to == '\0') { EMSG2(_("E357: 'langmap': Matching character missing for %s"), transchar(from)); return; @@ -7710,7 +7710,7 @@ static void langmap_set(void) mb_ptr_adv(p2); if (*p == ';') { p = p2; - if (p[0] != NUL) { + if (p[0] != '\0') { if (p[0] != ',') { EMSG2(_( "E358: 'langmap': Extra characters after semicolon: %s"), @@ -7997,7 +7997,7 @@ opt_strings_flags ( len = (int)STRLEN(values[i]); if (STRNCMP(values[i], val, len) == 0 - && ((list && val[len] == ',') || val[len] == NUL)) { + && ((list && val[len] == ',') || val[len] == '\0')) { val += len + (val[len] == ','); new_flags |= (1 << i); break; /* check next item in val list */ @@ -8026,7 +8026,7 @@ static int check_opt_wim(void) for (p = p_wim; *p; ++p) { for (i = 0; ASCII_ISALPHA(p[i]); ++i) ; - if (p[i] != NUL && p[i] != ',' && p[i] != ':') + if (p[i] != '\0' && p[i] != ',' && p[i] != ':') return FAIL; if (i == 7 && STRNCMP(p, "longest", 7) == 0) new_wim_flags[idx] |= WIM_LONGEST; @@ -8037,7 +8037,7 @@ static int check_opt_wim(void) else return FAIL; p += i; - if (*p == NUL) + if (*p == '\0') break; if (*p == ',') { if (idx == 3) @@ -8108,7 +8108,7 @@ int file_ff_differs(buf_T *buf, int ignore_empty) if (ignore_empty && (buf->b_flags & BF_NEW) && buf->b_ml.ml_line_count == 1 - && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) + && *ml_get_buf(buf, (linenr_T)1, FALSE) == '\0') return FALSE; if (buf->b_start_ffc != *buf->b_p_ff) return TRUE; @@ -8117,7 +8117,7 @@ int file_ff_differs(buf_T *buf, int ignore_empty) if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb) return TRUE; if (buf->b_start_fenc == NULL) - return *buf->b_p_fenc != NUL; + return *buf->b_p_fenc != '\0'; return STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0; } @@ -8158,7 +8158,7 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit) char_u *ptr; ptr = curbuf->b_p_mps; - while (*ptr != NUL) { + while (*ptr != '\0') { if (has_mbyte) { char_u *prev; diff --git a/src/os/env.c b/src/os/env.c index e6cdb92ea8..174f142854 100644 --- a/src/os/env.c +++ b/src/os/env.c @@ -42,7 +42,7 @@ char *os_getenvname_at_index(size_t index) return NULL; } int namesize = 0; - while (str[namesize] != '=' && str[namesize] != NUL) { + while (str[namesize] != '=' && str[namesize] != '\0') { namesize++; } char *name = (char *)vim_strnsave((char_u *)str, namesize); diff --git a/src/os/fs.c b/src/os/fs.c index f9b02375e1..461913433f 100644 --- a/src/os/fs.c +++ b/src/os/fs.c @@ -84,7 +84,7 @@ static bool is_executable_in_path(const char_u *name) { const char *path = getenv("PATH"); // PATH environment variable does not exist or is empty. - if (path == NULL || *path == NUL) { + if (path == NULL || *path == '\0') { return false; } diff --git a/src/os/shell.c b/src/os/shell.c index d14e355d19..7e5f5fd41e 100644 --- a/src/os/shell.c +++ b/src/os/shell.c @@ -251,14 +251,14 @@ static int tokenize(char_u *str, char **argv) int argc = 0, len; char_u *p = str; - while (*p != NUL) { + while (*p != '\0') { len = word_length(p); if (argv != NULL) { // Fill the slot argv[argc] = xmalloc(len + 1); memcpy(argv[argc], p, len); - argv[argc][len] = NUL; + argv[argc][len] = '\0'; } argc++; @@ -323,7 +323,7 @@ static void write_selection(uv_write_t *req) buflen *= 2; pdata->wbuffer = xrealloc(pdata->wbuffer, buflen); } - pdata->wbuffer[off++] = NUL; + pdata->wbuffer[off++] = '\0'; } else { char_u *s = vim_strchr(lp + written, NL); len = s == NULL ? l : s - (lp + written); @@ -405,7 +405,7 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) if (pdata->rbuffer[i] == NL) { // Insert the line append_ga_line(&pdata->ga); - } else if (pdata->rbuffer[i] == NUL) { + } else if (pdata->rbuffer[i] == '\0') { // Translate NUL to NL ga_append(&pdata->ga, NL); } else { diff --git a/src/os/users.c b/src/os/users.c index e7b362637b..8a52f905be 100644 --- a/src/os/users.c +++ b/src/os/users.c @@ -56,7 +56,7 @@ int os_get_uname(uid_t uid, char *s, size_t len) struct passwd *pw; if ((pw = getpwuid(uid)) != NULL - && pw->pw_name != NULL && *(pw->pw_name) != NUL) { + && pw->pw_name != NULL && *(pw->pw_name) != '\0') { vim_strncpy((char_u *)s, (char_u *)pw->pw_name, len - 1); return OK; } diff --git a/src/os_unix.c b/src/os_unix.c index b2f0df988b..d2de9b8c4c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -250,22 +250,22 @@ void mch_settitle(char_u *title, char_u *icon) * Note: if "t_ts" is set, title is set with escape sequence rather * than x11 calls, because the x11 calls don't always work */ - if ((type || *T_TS != NUL) && title != NULL) { + if ((type || *T_TS != '\0') && title != NULL) { if (oldtitle == NULL ) /* first call but not in GUI, save title */ (void)get_x11_title(FALSE); - if (*T_TS != NUL) /* it's OK if t_fs is empty */ + if (*T_TS != '\0') /* it's OK if t_fs is empty */ term_settitle(title); did_set_title = TRUE; } - if ((type || *T_CIS != NUL) && icon != NULL) { + if ((type || *T_CIS != '\0') && icon != NULL) { if (oldicon == NULL ) /* first call, save icon */ get_x11_icon(FALSE); - if (*T_CIS != NUL) { + if (*T_CIS != '\0') { out_str(T_CIS); /* set icon start */ out_str_nf(icon); out_str(T_CIE); /* set icon end */ @@ -396,7 +396,7 @@ int len; /* buffer size, only used when name gets longer */ dirp = opendir("."); tail = name; } else { - *slash = NUL; + *slash = '\0'; dirp = opendir((char *)name); *slash = '/'; tail = slash + 1; @@ -757,7 +757,7 @@ void get_stty() buf[0] = keys.sg_erase; intr_char = keys.sg_kill; #endif - buf[1] = NUL; + buf[1] = '\0'; add_termcode((char_u *)"kb", buf, FALSE); /* @@ -832,7 +832,7 @@ void check_mouse_termcode() set_mouse_termcode(KS_MOUSE, (char_u *)(term_is_8bit(T_NAME) ? IF_EB("\233M", CSI_STR "M") : IF_EB("\033[M", ESC_STR "[M"))); - if (*p_mouse != NUL) { + if (*p_mouse != '\0') { /* force mouse off and maybe on to send possibly new mouse * activation sequence to the xterm, with(out) drag tracing. */ mch_setmouse(FALSE); @@ -867,7 +867,7 @@ void check_mouse_termcode() ? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "["))); - if (*p_mouse != NUL) { + if (*p_mouse != '\0') { mch_setmouse(FALSE); setmouse(); } @@ -880,7 +880,7 @@ void check_mouse_termcode() ? IF_EB("\233<", CSI_STR "<") : IF_EB("\033[<", ESC_STR "[<"))); - if (*p_mouse != NUL) { + if (*p_mouse != '\0') { mch_setmouse(FALSE); setmouse(); } @@ -1115,7 +1115,7 @@ int flags; /* EW_* flags */ /* Count the length of the patterns in the same way as they are put in * "command" below. */ ++len; /* add space */ - for (j = 0; pat[i][j] != NUL; ++j) { + for (j = 0; pat[i][j] != '\0'; ++j) { if (vim_strchr(SHELL_SPECIAL, pat[i][j]) != NULL) ++len; /* may add a backslash */ ++len; @@ -1169,10 +1169,10 @@ int flags; /* EW_* flags */ p = command + STRLEN(command); *p++ = ' '; - for (j = 0; pat[i][j] != NUL; ++j) { + for (j = 0; pat[i][j] != '\0'; ++j) { if (pat[i][j] == '`') intick = !intick; - else if (pat[i][j] == '\\' && pat[i][j + 1] != NUL) { + else if (pat[i][j] == '\\' && pat[i][j + 1] != '\0') { /* Remove a backslash, take char literally. But keep * backslash inside backticks, before a special character * and before a backtick. */ @@ -1190,7 +1190,7 @@ int flags; /* EW_* flags */ /* Copy one character. */ *p++ = pat[i][j]; } - *p = NUL; + *p = '\0'; } if (flags & EW_SILENT) { @@ -1297,12 +1297,12 @@ int flags; /* EW_* flags */ } /* file names are separated with NL */ else if (shell_style == STYLE_BT || shell_style == STYLE_VIMGLOB) { - buffer[len] = NUL; /* make sure the buffer ends in NUL */ + buffer[len] = '\0'; /* make sure the buffer ends in NUL */ p = buffer; - for (i = 0; *p != NUL; ++i) { /* count number of entries */ - while (*p != '\n' && *p != NUL) + for (i = 0; *p != '\0'; ++i) { /* count number of entries */ + while (*p != '\n' && *p != '\0') ++p; - if (*p != NUL) + if (*p != '\0') ++p; p = skipwhite(p); /* skip leading white space */ } @@ -1320,7 +1320,7 @@ int flags; /* EW_* flags */ check_spaces = FALSE; if (shell_style == STYLE_PRINT && !did_find_nul) { /* If there is a NUL, set did_find_nul, else set check_spaces */ - buffer[len] = NUL; + buffer[len] = '\0'; if (len && (int)STRLEN(buffer) < (int)len) did_find_nul = TRUE; else @@ -1331,15 +1331,15 @@ int flags; /* EW_* flags */ * Make sure the buffer ends with a NUL. For STYLE_PRINT there * already is one, for STYLE_GLOB it needs to be added. */ - if (len && buffer[len - 1] == NUL) + if (len && buffer[len - 1] == '\0') --len; else - buffer[len] = NUL; + buffer[len] = '\0'; i = 0; for (p = buffer; p < buffer + len; ++p) - if (*p == NUL || (*p == ' ' && check_spaces)) { /* count entry */ + if (*p == '\0' || (*p == ' ' && check_spaces)) { /* count entry */ ++i; - *p = NUL; + *p = '\0'; } if (len) ++i; /* count last entry */ @@ -1366,12 +1366,12 @@ int flags; /* EW_* flags */ if (shell_style == STYLE_ECHO || shell_style == STYLE_BT || shell_style == STYLE_VIMGLOB) { while (!(shell_style == STYLE_ECHO && *p == ' ') - && *p != '\n' && *p != NUL) + && *p != '\n' && *p != '\0') ++p; if (p == buffer + len) /* last entry */ - *p = NUL; + *p = '\0'; else { - *p++ = NUL; + *p++ = '\0'; p = skipwhite(p); /* skip to next entry */ } } else { /* NUL separates */ @@ -1455,7 +1455,7 @@ int mch_has_exp_wildcard(p) char_u *p; { for (; *p; mb_ptr_adv(p)) { - if (*p == '\\' && p[1] != NUL) + if (*p == '\\' && p[1] != '\0') ++p; else if (vim_strchr((char_u *) "*?[{'" @@ -1473,12 +1473,12 @@ int mch_has_wildcard(p) char_u *p; { for (; *p; mb_ptr_adv(p)) { - if (*p == '\\' && p[1] != NUL) + if (*p == '\\' && p[1] != '\0') ++p; else if (vim_strchr((char_u *) "*?[{`'$" , *p) != NULL - || (*p == '~' && p[1] != NUL)) + || (*p == '~' && p[1] != '\0')) return TRUE; } return FALSE; diff --git a/src/path.c b/src/path.c index 6e736f1daa..292659a4c3 100644 --- a/src/path.c +++ b/src/path.c @@ -72,7 +72,7 @@ char_u *path_tail(char_u *fname) char_u *tail = get_past_head(fname); char_u *p = tail; // Find last part of path. - while (*p != NUL) { + while (*p != '\0') { if (vim_ispathsep_nocolon(*p)) { tail = p + 1; } @@ -97,10 +97,10 @@ char_u *path_tail_with_sep(char_u *fname) char_u *path_next_component(char_u *fname) { assert(fname != NULL); - while (*fname != NUL && !vim_ispathsep(*fname)) { + while (*fname != '\0' && !vim_ispathsep(*fname)) { mb_ptr_adv(fname); } - if (*fname != NUL) { + if (*fname != '\0') { fname++; } return fname; @@ -180,7 +180,7 @@ void shorten_dir(char_u *str) for (s = str;; ++s) { if (s >= tail) { /* copy the whole tail */ *d++ = *s; - if (*s == NUL) + if (*s == '\0') break; } else if (vim_ispathsep(*s)) { /* copy '/' and next char */ *d++ = *s; @@ -215,7 +215,7 @@ int dir_of_file_exists(char_u *fname) if (p == fname) return TRUE; c = *p; - *p = NUL; + *p = '\0'; retval = os_isdir(fname); *p = c; return retval; @@ -241,13 +241,13 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len) #ifdef BACKSLASH_IN_FILENAME char_u *px = x; char_u *py = y; - int cx = NUL; - int cy = NUL; + int cx = '\0'; + int cy = '\0'; while (len > 0) { cx = PTR2CHAR(px); cy = PTR2CHAR(py); - if (cx == NUL || cy == NUL + if (cx == '\0' || cy == '\0' || ((p_fic ? vim_tolower(cx) != vim_tolower(cy) : cx != cy) && !(cx == '/' && cy == '\\') && !(cx == '\\' && cy == '/'))) @@ -301,7 +301,7 @@ char_u *concat_str(char_u *str1, char_u *str2) */ void add_pathsep(char_u *p) { - if (*p != NUL && !after_pathsep(p, p + STRLEN(p))) + if (*p != '\0' && !after_pathsep(p, p + STRLEN(p))) STRCAT(p, PATHSEPSTR); } @@ -402,7 +402,7 @@ unix_expandpath ( s = buf; e = NULL; path_end = path; - while (*path_end != NUL) { + while (*path_end != '\0') { /* May ignore a wildcard that has a backslash before it; it will * be removed by rem_backslash() or file_pat_to_reg_pat() below. */ if (path_end >= path + wildoff && rem_backslash(path_end)) @@ -425,7 +425,7 @@ unix_expandpath ( *p++ = *path_end++; } e = p; - *e = NUL; + *e = '\0'; /* Now we have one wildcard component between "s" and "e". */ /* Remove backslashes between "wildoff" and the start of the wildcard @@ -478,8 +478,8 @@ unix_expandpath ( } /* open the directory for scanning */ - *s = NUL; - dirp = opendir(*buf == NUL ? "." : (char *)buf); + *s = '\0'; + dirp = opendir(*buf == '\0' ? "." : (char *)buf); /* Find all matching entries */ if (dirp != NULL) { @@ -513,7 +513,7 @@ unix_expandpath ( } else { /* no more wildcards, check if there is a match */ /* remove backslashes for the remaining components only */ - if (*path_end != NUL) + if (*path_end != '\0') backslash_halve(buf + len + 1); if (os_file_exists(buf)) { /* add existing file */ #ifdef MACOS_CONVERT @@ -614,7 +614,7 @@ static int is_unique(char_u *maybe_unique, garray_T *gap, int i) */ static void expand_path_option(char_u *curdir, garray_T *gap) { - char_u *path_option = *curbuf->b_p_path == NUL + char_u *path_option = *curbuf->b_p_path == '\0' ? p_path : curbuf->b_p_path; char_u *buf; char_u *p; @@ -622,10 +622,10 @@ static void expand_path_option(char_u *curdir, garray_T *gap) buf = alloc((int)MAXPATHL); - while (*path_option != NUL) { + while (*path_option != '\0') { copy_option_part(&path_option, buf, MAXPATHL, " ,"); - if (buf[0] == '.' && (buf[1] == NUL || vim_ispathsep(buf[1]))) { + if (buf[0] == '.' && (buf[1] == '\0' || vim_ispathsep(buf[1]))) { /* Relative to current buffer: * "/path/file" + "." -> "/path/" * "/path/file" + "./subdir" -> "/path/subdir" */ @@ -635,13 +635,13 @@ static void expand_path_option(char_u *curdir, garray_T *gap) len = (int)(p - curbuf->b_ffname); if (len + (int)STRLEN(buf) >= MAXPATHL) continue; - if (buf[1] == NUL) - buf[len] = NUL; + if (buf[1] == '\0') + buf[len] = '\0'; else STRMOVE(buf + len, buf + 2); memmove(buf, curbuf->b_ffname, len); simplify_filename(buf); - } else if (buf[0] == NUL) + } else if (buf[0] == '\0') /* relative to current directory */ STRCPY(buf, curdir); else if (path_with_url(buf)) @@ -688,7 +688,7 @@ static char_u *get_path_cutoff(char_u *fname, garray_T *gap) int j = 0; while ((fname[j] == path_part[i][j] - ) && fname[j] != NUL && path_part[i][j] != NUL) + ) && fname[j] != '\0' && path_part[i][j] != '\0') j++; if (j > maxlen) { maxlen = j; @@ -736,7 +736,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) len = (int)STRLEN(pattern); file_pattern = alloc(len + 2); file_pattern[0] = '*'; - file_pattern[1] = NUL; + file_pattern[1] = '\0'; STRCAT(file_pattern, pattern); pat = file_pat_to_reg_pat(file_pattern, NULL, NULL, TRUE); vim_free(file_pattern); @@ -764,7 +764,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) len = (int)STRLEN(path); is_in_curdir = fnamencmp(curdir, path, dir_end - path) == 0 - && curdir[dir_end - path] == NUL; + && curdir[dir_end - path] == '\0'; if (is_in_curdir) in_curdir[i] = vim_strsave(path); @@ -862,7 +862,7 @@ static char_u *gettail_dir(char_u *fname) int look_for_sep = TRUE; char_u *p; - for (p = fname; *p != NUL; ) { + for (p = fname; *p != '\0'; ) { if (vim_ispathsep(*p)) { if (look_for_sep) { next_dir_end = p; @@ -917,15 +917,15 @@ expand_in_path ( /* Copy each path in files into gap */ s = e = files; - while (*s != NUL) { - while (*e != '\n' && *e != NUL) + while (*s != '\0') { + while (*e != '\n' && *e != '\0') e++; - if (*e == NUL) { + if (*e == '\0') { addfile(gap, s, flags); break; } else { /* *e is '\n' */ - *e = NUL; + *e = '\0'; addfile(gap, s, flags); e++; s = e; @@ -946,7 +946,7 @@ static int has_env_var(char_u *p); static int has_env_var(char_u *p) { for (; *p; mb_ptr_adv(p)) { - if (*p == '\\' && p[1] != NUL) + if (*p == '\\' && p[1] != '\0') ++p; else if (vim_strchr((char_u *) "$" @@ -966,7 +966,7 @@ static int has_special_wildchar(char_u *p); static int has_special_wildchar(char_u *p) { for (; *p; mb_ptr_adv(p)) { - if (*p == '\\' && p[1] != NUL) + if (*p == '\\' && p[1] != '\0') ++p; else if (vim_strchr((char_u *)SPECIAL_WILDCHAR, *p) != NULL) return TRUE; @@ -1125,7 +1125,7 @@ gen_expand_wildcards ( */ static int vim_backtick(char_u *p) { - return *p == '`' && *(p + 1) != NUL && *(p + STRLEN(p) - 1) == '`'; + return *p == '`' && *(p + 1) != '\0' && *(p + STRLEN(p) - 1) == '`'; } /* @@ -1161,21 +1161,21 @@ expand_backtick ( return 0; cmd = buffer; - while (*cmd != NUL) { + while (*cmd != '\0') { cmd = skipwhite(cmd); /* skip over white space */ p = cmd; - while (*p != NUL && *p != '\r' && *p != '\n') /* skip over entry */ + while (*p != '\0' && *p != '\r' && *p != '\n') /* skip over entry */ ++p; /* add an entry if it is not empty */ if (p > cmd) { i = *p; - *p = NUL; + *p = '\0'; addfile(gap, cmd, flags); *p = i; ++cnt; } cmd = p; - while (*cmd != NUL && (*cmd == '\r' || *cmd == '\n')) + while (*cmd != '\0' && (*cmd == '\r' || *cmd == '\n')) ++cmd; } @@ -1271,16 +1271,16 @@ void simplify_filename(char_u *filename) * or "p" is at the "start" of the (absolute or relative) path name. */ if (vim_ispathsep(*p)) STRMOVE(p, p + 1); /* remove duplicate "/" */ - else if (p[0] == '.' && (vim_ispathsep(p[1]) || p[1] == NUL)) { + else if (p[0] == '.' && (vim_ispathsep(p[1]) || p[1] == '\0')) { if (p == start && relative) - p += 1 + (p[1] != NUL); /* keep single "." or leading "./" */ + p += 1 + (p[1] != '\0'); /* keep single "." or leading "./" */ else { /* Strip "./" or ".///". If we are at the end of the file name * and there is no trailing path separator, either strip "/." if * we are after "start", or strip "." if we are at the beginning * of an absolute path name . */ tail = p + 1; - if (p[1] != NUL) + if (p[1] != '\0') while (vim_ispathsep(*tail)) mb_ptr_adv(tail); else if (p > start) @@ -1288,7 +1288,7 @@ void simplify_filename(char_u *filename) STRMOVE(p, tail); } } else if (p[0] == '.' && p[1] == '.' && - (vim_ispathsep(p[2]) || p[2] == NUL)) { + (vim_ispathsep(p[2]) || p[2] == '\0')) { /* Skip to after ".." or "../" or "..///". */ tail = p + 2; while (vim_ispathsep(*tail)) @@ -1305,7 +1305,7 @@ void simplify_filename(char_u *filename) * system, we strip it. On Unix, we don't accept a symbolic * link that refers to a non-existent file. */ saved_char = p[-1]; - p[-1] = NUL; + p[-1] = '\0'; #ifdef UNIX if (mch_lstat((char *)filename, &st) < 0) #else @@ -1331,7 +1331,7 @@ void simplify_filename(char_u *filename) * a valid one, and we disable stripping of later * components. */ saved_char = *tail; - *tail = NUL; + *tail = '\0'; if (mch_stat((char *)filename, &st) >= 0) do_strip = TRUE; else @@ -1352,7 +1352,7 @@ void simplify_filename(char_u *filename) (void)mch_stat(".", &new_st); else { saved_char = *p; - *p = NUL; + *p = '\0'; (void)mch_stat((char *)filename, &new_st); *p = saved_char; } @@ -1383,7 +1383,7 @@ void simplify_filename(char_u *filename) * path separator as well. */ if (p == start && relative && tail[-1] == '.') { *p++ = '.'; - *p = NUL; + *p = '\0'; } else { if (p > start && tail[-1] == '.') --p; @@ -1405,7 +1405,7 @@ void simplify_filename(char_u *filename) ++components; /* simple path component */ p = path_next_component(p); } - } while (*p != NUL); + } while (*p != '\0'); } static char_u *eval_includeexpr(char_u *ptr, int len); @@ -1438,7 +1438,7 @@ find_file_name_in_path ( int c; char_u *tofree = NULL; - if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) { + if ((options & FNAME_INCL) && *curbuf->b_p_inex != '\0') { tofree = eval_includeexpr(ptr, len); if (tofree != NULL) { ptr = tofree; @@ -1455,7 +1455,7 @@ find_file_name_in_path ( * 'includeexpr' (unless done already). */ if (file_name == NULL - && !(options & FNAME_INCL) && *curbuf->b_p_inex != NUL) { + && !(options & FNAME_INCL) && *curbuf->b_p_inex != '\0') { tofree = eval_includeexpr(ptr, len); if (tofree != NULL) { ptr = tofree; @@ -1466,7 +1466,7 @@ find_file_name_in_path ( } if (file_name == NULL && (options & FNAME_MESS)) { c = ptr[len]; - ptr[len] = NUL; + ptr[len] = '\0'; EMSG2(_("E447: Can't find file \"%s\" in path"), ptr); ptr[len] = c; } @@ -1537,7 +1537,7 @@ vim_FullName ( int retval = OK; int url; - *buf = NUL; + *buf = '\0'; if (fname == NULL) return FAIL; @@ -1642,15 +1642,15 @@ int pathcmp(const char *p, const char *q, int maxlen) c2 = PTR2CHAR((char_u *)q + i); /* End of "p": check if "q" also ends or just has a slash. */ - if (c1 == NUL) { - if (c2 == NUL) /* full match */ + if (c1 == '\0') { + if (c2 == '\0') /* full match */ return 0; s = q; break; } /* End of "q": check if "p" just has a slash. */ - if (c2 == NUL) { + if (c2 == '\0') { s = p; break; } @@ -1676,7 +1676,7 @@ int pathcmp(const char *p, const char *q, int maxlen) c1 = PTR2CHAR((char_u *)s + i); c2 = PTR2CHAR((char_u *)s + i + MB_PTR2LEN((char_u *)s + i)); /* ignore a trailing slash, but not "//" or ":/" */ - if (c2 == NUL + if (c2 == '\0' && i > 0 && !after_pathsep((char_u *)s, (char_u *)s + i) #ifdef BACKSLASH_IN_FILENAME @@ -1715,7 +1715,7 @@ char_u *path_shorten_fname_if_possible(char_u *full_path) if (os_dirname(dirname, MAXPATHL) == OK) { p = path_shorten_fname(full_path, dirname); - if (p == NULL || *p == NUL) { + if (p == NULL || *p == '\0') { p = full_path; } } @@ -1970,7 +1970,7 @@ int append_path(char *path, const char *to_append, int max_len) static int path_get_absolute_path(char_u *fname, char_u *buf, int len, int force) { char_u *p; - *buf = NUL; + *buf = '\0'; char relative_directory[len]; char *end_of_path = (char *) fname; @@ -1979,10 +1979,10 @@ static int path_get_absolute_path(char_u *fname, char_u *buf, int len, int force if (force || !path_is_absolute_path(fname)) { if ((p = vim_strrchr(fname, '/')) != NULL) { STRNCPY(relative_directory, fname, p-fname); - relative_directory[p-fname] = NUL; + relative_directory[p-fname] = '\0'; end_of_path = (char *) (p + 1); } else { - relative_directory[0] = NUL; + relative_directory[0] = '\0'; end_of_path = (char *) fname; } diff --git a/src/popupmnu.c b/src/popupmnu.c index bfb6b693e1..283d6a5e83 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -333,13 +333,13 @@ void pum_redraw(void) } w = ptr2cells(p); - if ((*p == NUL) || (*p == TAB) || (totwidth + w > pum_width)) { + if ((*p == '\0') || (*p == TAB) || (totwidth + w > pum_width)) { // Display the text that fits or comes before a Tab. // First convert it to printable characters. char_u *st; int saved = *p; - *p = NUL; + *p = '\0'; st = transstr(s); *p = saved; @@ -573,13 +573,13 @@ static int pum_set_selected(int n, int repeat) char_u *p, *e; linenr_T lnum = 0; - for (p = pum_array[pum_selected].pum_info; *p != NUL;) { + for (p = pum_array[pum_selected].pum_info; *p != '\0';) { e = vim_strchr(p, '\n'); if (e == NULL) { ml_append(lnum++, p, 0, FALSE); break; } else { - *e = NUL; + *e = '\0'; ml_append(lnum++, p, (int)(e - p + 1), FALSE); *e = '\n'; p = e + 1; diff --git a/src/quickfix.c b/src/quickfix.c index c98b43fff6..a97415ebc6 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -305,7 +305,7 @@ qf_init_ext ( * regex prog. Only a few % characters are allowed. */ /* Use the local value of 'errorformat' if it's set. */ - if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL) + if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != '\0') efm = buf->b_p_efm; else efm = errorformat; @@ -322,7 +322,7 @@ qf_init_ext ( #endif fmtstr = alloc(i); - while (efm[0] != NUL) { + while (efm[0] != '\0') { /* * Allocate a new eformat structure and put it at the end of the list */ @@ -336,8 +336,8 @@ qf_init_ext ( /* * Isolate one part in the 'errorformat' option */ - for (len = 0; efm[len] != NUL && efm[len] != ','; ++len) - if (efm[len] == '\\' && efm[len + 1] != NUL) + for (len = 0; efm[len] != '\0' && efm[len] != ','; ++len) + if (efm[len] == '\\' && efm[len + 1] != '\0') ++len; /* @@ -383,7 +383,7 @@ qf_init_ext ( ptr += 10; } #endif - if (*efmp == 'f' && efmp[1] != NUL) { + if (*efmp == 'f' && efmp[1] != '\0') { if (efmp[1] != '\\' && efmp[1] != '%') { /* A file name may contain spaces, but this isn't * in "\f". For "%f:%l:%m" there may be a ":" in @@ -400,7 +400,7 @@ qf_init_ext ( } } else { srcptr = (char_u *)fmt_pat[idx].pattern; - while ((*ptr = *srcptr++) != NUL) + while ((*ptr = *srcptr++) != '\0') ++ptr; } *ptr++ = '\\'; @@ -464,7 +464,7 @@ qf_init_ext ( } } *ptr++ = '$'; - *ptr = NUL; + *ptr = '\0'; if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL) goto error2; /* @@ -546,14 +546,14 @@ qf_init_ext ( } else if (fgets((char *)IObuff, CMDBUFFSIZE - 2, fd) == NULL) break; - IObuff[CMDBUFFSIZE - 2] = NUL; /* for very long lines */ + IObuff[CMDBUFFSIZE - 2] = '\0'; /* for very long lines */ remove_bom(IObuff); if ((efmp = vim_strrchr(IObuff, '\n')) != NULL) - *efmp = NUL; + *efmp = '\0'; #ifdef USE_CRNL if ((efmp = vim_strrchr(IObuff, '\r')) != NULL) - *efmp = NUL; + *efmp = '\0'; #endif /* If there was no %> item start at the first pattern */ @@ -574,10 +574,10 @@ restofline: idx = fmt_ptr->prefix; if (multiscan && vim_strchr((char_u *)"OPQ", idx) == NULL) continue; - namebuf[0] = NUL; - pattern[0] = NUL; + namebuf[0] = '\0'; + pattern[0] = '\0'; if (!multiscan) - errmsg[0] = NUL; + errmsg[0] = '\0'; lnum = 0; col = 0; use_viscol = FALSE; @@ -606,7 +606,7 @@ restofline: /* Expand ~/file and $HOME/file to full path. */ c = *regmatch.endp[i]; - *regmatch.endp[i] = NUL; + *regmatch.endp[i] = '\0'; expand_env(regmatch.startp[i], namebuf, CMDBUFFSIZE); *regmatch.endp[i] = c; @@ -680,7 +680,7 @@ restofline: STRNCAT(pattern, regmatch.startp[i], len); pattern[len + 3] = '\\'; pattern[len + 4] = '$'; - pattern[len + 5] = NUL; + pattern[len + 5] = '\0'; } break; } @@ -690,7 +690,7 @@ restofline: if (fmt_ptr == NULL || idx == 'D' || idx == 'X') { if (fmt_ptr != NULL) { if (idx == 'D') { /* enter directory */ - if (*namebuf == NUL) { + if (*namebuf == '\0') { EMSG(_("E379: Missing or empty directory name")); goto error2; } @@ -699,7 +699,7 @@ restofline: } else if (idx == 'X') /* leave directory */ directory = qf_pop_dir(&dir_stack); } - namebuf[0] = NUL; /* no match found, remove file name */ + namebuf[0] = '\0'; /* no match found, remove file name */ lnum = 0; /* don't jump to this line */ valid = FALSE; STRCPY(errmsg, IObuff); /* copy whole line to error message */ @@ -746,12 +746,12 @@ restofline: } else if (vim_strchr((char_u *)"OPQ", idx) != NULL) { /* global file names */ valid = FALSE; - if (*namebuf == NUL || os_file_exists(namebuf)) { + if (*namebuf == '\0' || os_file_exists(namebuf)) { if (*namebuf && idx == 'P') currfile = qf_push_dir(namebuf, &file_stack); else if (idx == 'Q') currfile = qf_pop_dir(&file_stack); - *namebuf = NUL; + *namebuf = '\0'; if (tail && *tail) { STRMOVE(IObuff, skipwhite(tail)); multiscan = TRUE; @@ -935,7 +935,7 @@ qf_add_entry ( qfp->qf_lnum = lnum; qfp->qf_col = col; qfp->qf_viscol = vis_col; - if (pattern == NULL || *pattern == NUL) + if (pattern == NULL || *pattern == '\0') qfp->qf_pattern = NULL; else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL) { vim_free(qfp->qf_text); @@ -1102,7 +1102,7 @@ void copy_loclist(win_T *from, win_T *to) */ static int qf_get_fnum(char_u *directory, char_u *fname) { - if (fname == NULL || *fname == NUL) /* no file name */ + if (fname == NULL || *fname == '\0') /* no file name */ return 0; { char_u *ptr; @@ -1487,7 +1487,7 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit) if (!usable_win) { /* Locate a window showing a normal buffer */ FOR_ALL_WINDOWS(win) - if (win->w_buffer->b_p_bt[0] == NUL) { + if (win->w_buffer->b_p_bt[0] == '\0') { usable_win = 1; break; } @@ -1545,7 +1545,7 @@ win_found: /* Find a previous usable window */ win = curwin; do { - if (win->w_buffer->b_p_bt[0] == NUL) + if (win->w_buffer->b_p_bt[0] == '\0') break; if (win->w_prev == NULL) win = lastwin; /* wrap around the top */ @@ -1592,7 +1592,7 @@ win_found: /* Remember a usable window. */ if (altwin == NULL && !win->w_p_pvw - && win->w_buffer->b_p_bt[0] == NUL) + && win->w_buffer->b_p_bt[0] == '\0') altwin = win; } @@ -1651,7 +1651,7 @@ win_found: line = ml_get_curline(); screen_col = 0; for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col) { - if (*line == NUL) + if (*line == '\0') break; if (*line++ == '\t') { curwin->w_cursor.col -= 7 - (screen_col % 8); @@ -1757,7 +1757,7 @@ void qf_list(exarg_T *eap) EMSG(_(e_quickfix)); return; } - if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL) { + if (!get_list_range(&arg, &idx1, &idx2) || *arg != '\0') { EMSG(_(e_trailing)); return; } @@ -1791,7 +1791,7 @@ void qf_list(exarg_T *eap) msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index ? hl_attr(HLF_L) : hl_attr(HLF_D)); if (qfp->qf_lnum == 0) - IObuff[0] = NUL; + IObuff[0] = '\0'; else if (qfp->qf_col == 0) sprintf((char *)IObuff, ":%" PRId64, (int64_t)qfp->qf_lnum); else @@ -1832,16 +1832,16 @@ static void qf_fmt_text(char_u *text, char_u *buf, int bufsize) int i; char_u *p = text; - for (i = 0; *p != NUL && i < bufsize - 1; ++i) { + for (i = 0; *p != '\0' && i < bufsize - 1; ++i) { if (*p == '\n') { buf[i] = ' '; - while (*++p != NUL) + while (*++p != '\0') if (!vim_iswhite(*p) && *p != '\n') break; } else buf[i] = *p++; } - buf[i] = NUL; + buf[i] = '\0'; } /* @@ -1984,7 +1984,7 @@ static char_u *qf_types(int c, int nr) else { cc[0] = ' '; cc[1] = c; - cc[2] = NUL; + cc[2] = '\0'; p = cc; } @@ -2466,7 +2466,7 @@ int grep_internal(cmdidx_T cmdidx) || cmdidx == CMD_grepadd || cmdidx == CMD_lgrepadd) && STRCMP("internal", - *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0; + *curbuf->b_p_gp == '\0' ? p_gp : curbuf->b_p_gp) == 0; } /* @@ -2518,12 +2518,12 @@ void ex_make(exarg_T *eap) * If 'shellpipe' empty: don't redirect to 'errorfile'. */ len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1; - if (*p_sp != NUL) + if (*p_sp != '\0') len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3; cmd = alloc(len); sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg, (char *)p_shq); - if (*p_sp != NUL) + if (*p_sp != '\0') append_redir(cmd, len, p_sp, fname); /* * Output a newline if there's something else than the :make command that @@ -2536,7 +2536,7 @@ void ex_make(exarg_T *eap) msg_outtrans(cmd); /* show what we are doing */ /* let the shell know if we are redirecting output or not */ - do_shell(cmd, *p_sp != NUL ? kShellOptDoOut : 0); + do_shell(cmd, *p_sp != '\0' ? kShellOptDoOut : 0); res = qf_init(wp, fname, (eap->cmdidx != CMD_make @@ -2577,7 +2577,7 @@ static char_u *get_mef_name(void) struct stat sb; #endif - if (*p_mef == NUL) { + if (*p_mef == '\0') { name = vim_tempname('e'); if (name == NULL) EMSG(_(e_notmp)); @@ -2588,7 +2588,7 @@ static char_u *get_mef_name(void) if (p[0] == '#' && p[1] == '#') break; - if (*p == NUL) + if (*p == '\0') return vim_strsave(p_mef); /* Keep trying until the name doesn't exist yet. */ @@ -2702,7 +2702,7 @@ void ex_cfile(exarg_T *eap) } if (au_name != NULL) apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf); - if (*eap->arg != NUL) + if (*eap->arg != '\0') set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); /* @@ -2806,7 +2806,7 @@ void ex_vimgrep(exarg_T *eap) goto theend; } - if (s != NULL && *s == NUL) { + if (s != NULL && *s == '\0') { /* Pattern is empty, use last search pattern. */ if (last_search_pat() == NULL) { EMSG(_(e_noprevre)); @@ -2822,7 +2822,7 @@ void ex_vimgrep(exarg_T *eap) regmatch.rmm_maxcol = 0; p = skipwhite(p); - if (*p == NUL) { + if (*p == '\0') { EMSG(_("E683: File name missing or invalid pattern")); goto theend; } @@ -3079,8 +3079,8 @@ char_u *skip_vimgrep_pat(char_u *p, char_u **s, int *flags) if (s != NULL) *s = p; p = skiptowhite(p); - if (s != NULL && *p != NUL) - *p++ = NUL; + if (s != NULL && *p != '\0') + *p++ = '\0'; } else { /* ":vimgrep /pattern/[g][j] fname" */ if (s != NULL) @@ -3092,7 +3092,7 @@ char_u *skip_vimgrep_pat(char_u *p, char_u **s, int *flags) /* Truncate the pattern. */ if (s != NULL) - *p = NUL; + *p = '\0'; ++p; /* Find the flags */ @@ -3290,7 +3290,7 @@ int get_errorlist(win_T *wp, list_T *list) list_append_dict(list, dict); buf[0] = qfp->qf_type; - buf[1] = NUL; + buf[1] = '\0'; if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL @@ -3388,7 +3388,7 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title) vcol, /* vis_col */ pattern, /* search pattern */ nr, - type == NULL ? NUL : *type, + type == NULL ? '\0' : *type, valid); vim_free(filename); @@ -3433,9 +3433,9 @@ void ex_cbuffer(exarg_T *eap) qi = ll_get_or_alloc_list(curwin); } - if (*eap->arg == NUL) + if (*eap->arg == '\0') buf = curbuf; - else if (*skipwhite(skipdigits(eap->arg)) == NUL) + else if (*skipwhite(skipdigits(eap->arg)) == '\0') buf = buflist_findnr(atoi((char *)eap->arg)); if (buf == NULL) EMSG(_(e_invarg)); @@ -3576,7 +3576,7 @@ void ex_helpgrep(exarg_T *eap) /* Go through all directories in 'runtimepath' */ p = p_rtp; - while (*p != NUL && !got_int) { + while (*p != '\0' && !got_int) { copy_option_part(&p, NameBuff, MAXPATHL, ","); /* Find all "*.txt" and "*.??x" files in the "doc" directory. */ @@ -3613,7 +3613,7 @@ void ex_helpgrep(exarg_T *eap) /* remove trailing CR, LF, spaces, etc. */ while (l > 0 && line[l - 1] <= ' ') - line[--l] = NUL; + line[--l] = '\0'; if (qf_add_entry(qi, &prevp, NULL, /* dir */ diff --git a/src/regexp.c b/src/regexp.c index b9a111caf1..49afd52e66 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -1092,12 +1092,12 @@ static char_u *skip_anyof(char_u *p) ++p; if (*p == ']' || *p == '-') ++p; - while (*p != NUL && *p != ']') { + while (*p != '\0' && *p != ']') { if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) p += l; else if (*p == '-') { ++p; - if (*p != ']' && *p != NUL) + if (*p != ']' && *p != '\0') mb_ptr_adv(p); } else if (*p == '\\' && !reg_cpo_bsl @@ -1136,15 +1136,15 @@ char_u *skip_regexp(char_u *startp, int dirc, int magic, char_u **newp) mymagic = MAGIC_OFF; get_cpo_flags(); - for (; p[0] != NUL; mb_ptr_adv(p)) { + for (; p[0] != '\0'; mb_ptr_adv(p)) { if (p[0] == dirc) /* found end of regexp */ break; if ((p[0] == '[' && mymagic >= MAGIC_ON) || (p[0] == '\\' && p[1] == '[' && mymagic <= MAGIC_OFF)) { p = skip_anyof(p + 1); - if (p[0] == NUL) + if (p[0] == '\0') break; - } else if (p[0] == '\\' && p[1] != NUL) { + } else if (p[0] == '\\' && p[1] != '\0') { if (dirc == '?' && newp != NULL && p[1] == '?') { /* change "\?" to "?", make a copy first. */ if (*newp == NULL) { @@ -1236,7 +1236,7 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags) } /* Dig out information for optimizations. */ - r->regstart = NUL; /* Worst-case defaults. */ + r->regstart = '\0'; /* Worst-case defaults. */ r->reganch = 0; r->regmust = NULL; r->regmlen = 0; @@ -1439,7 +1439,7 @@ reg ( EMSG2_RET_NULL(_(e_unmatchedpp), reg_magic == MAGIC_ALL); else EMSG2_RET_NULL(_(e_unmatchedp), reg_magic == MAGIC_ALL); - } else if (paren == REG_NOPAREN && peekchr() != NUL) { + } else if (paren == REG_NOPAREN && peekchr() != '\0') { if (curchr == Magic(')')) EMSG2_RET_NULL(_(e_unmatchedpar), reg_magic == MAGIC_ALL); else @@ -1511,7 +1511,7 @@ static char_u *regconcat(int *flagp) while (cont) { switch (peekchr()) { - case NUL: + case '\0': case Magic('|'): case Magic('&'): case Magic(')'): @@ -1823,7 +1823,7 @@ static char_u *regatom(int *flagp) /* In a string "\n" matches a newline character. */ ret = regnode(EXACTLY); regc(NL); - regc(NUL); + regc('\0'); *flagp |= HASWIDTH | SIMPLE; } else { /* In buffer text "\n" matches the end of a line. */ @@ -1841,7 +1841,7 @@ static char_u *regatom(int *flagp) *flagp |= flags & (HASWIDTH | SPSTART | HASNL | HASLOOKBH); break; - case NUL: + case '\0': case Magic('|'): case Magic('&'): case Magic(')'): @@ -1869,10 +1869,10 @@ static char_u *regatom(int *flagp) ret = regnode(EXACTLY); lp = reg_prev_sub; - while (*lp != NUL) + while (*lp != '\0') regc(*lp++); - regc(NUL); - if (*reg_prev_sub != NUL) { + regc('\0'); + if (*reg_prev_sub != '\0') { *flagp |= HASWIDTH; if ((lp - reg_prev_sub) == 1) *flagp |= SIMPLE; @@ -1904,11 +1904,11 @@ static char_u *regatom(int *flagp) if (!had_endbrace[refnum]) { /* Trick: check if "@<=" or "@<!" follows, in which case * the \1 can appear before the referenced match. */ - for (p = regparse; *p != NUL; ++p) + for (p = regparse; *p != '\0'; ++p) if (p[0] == '@' && p[1] == '<' && (p[2] == '!' || p[2] == '=')) break; - if (*p == NUL) + if (*p == '\0') EMSG_RET_NULL(_("E65: Illegal back reference")); } ret = regnode(BACKREF + refnum); @@ -1999,7 +1999,7 @@ static char_u *regatom(int *flagp) ret = NULL; while ((c = getchr()) != ']') { - if (c == NUL) + if (c == '\0') EMSG2_RET_NULL(_(e_missing_sb), reg_magic == MAGIC_ALL); br = regnode(BRANCH); @@ -2066,7 +2066,7 @@ static char_u *regatom(int *flagp) regc(0x0a); else regmbc(i); - regc(NUL); + regc('\0'); *flagp |= HASWIDTH; break; } @@ -2150,12 +2150,12 @@ collection: regc(*regparse++); } - while (*regparse != NUL && *regparse != ']') { + while (*regparse != '\0' && *regparse != ']') { if (*regparse == '-') { ++regparse; /* The '-' is not used for a range at the end and * after or before a '\n'. */ - if (*regparse == ']' || *regparse == NUL + if (*regparse == ']' || *regparse == '\0' || startc == -1 || (regparse[0] == '\\' && regparse[1] == 'n')) { regc('-'); @@ -2345,7 +2345,7 @@ collection: } } } - regc(NUL); + regc('\0'); prevchr_len = 1; /* last char was the ']' */ if (*regparse != ']') EMSG_RET_NULL(_(e_toomsbra)); /* Cannot happen? */ @@ -2382,7 +2382,7 @@ do_multibyte: * But always emit at least one character. Might be a Multi, * e.g., a "[" without matching "]". */ - for (len = 0; c != NUL && (len == 0 + for (len = 0; c != '\0' && (len == 0 || (re_multi_type(peekchr()) == NOT_MULTI && !one_exactly && !is_Magic(c))); ++len) { @@ -2407,7 +2407,7 @@ do_multibyte: } ungetchr(); - regc(NUL); + regc('\0'); *flagp |= HASWIDTH; if (len == 1) *flagp |= SIMPLE; @@ -2442,8 +2442,8 @@ static char_u *regnode(int op) regsize += 3; else { *regcode++ = op; - *regcode++ = NUL; /* Null "next" pointer. */ - *regcode++ = NUL; + *regcode++ = '\0'; /* Null "next" pointer. */ + *regcode++ = '\0'; } return ret; } @@ -2495,8 +2495,8 @@ static void reginsert(int op, char_u *opnd) place = opnd; /* Op node, where operand used to be. */ *place++ = op; - *place++ = NUL; - *place = NUL; + *place++ = '\0'; + *place = '\0'; } /* @@ -2521,8 +2521,8 @@ static void reginsert_nr(int op, long val, char_u *opnd) place = opnd; /* Op node, where operand used to be. */ *place++ = op; - *place++ = NUL; - *place++ = NUL; + *place++ = '\0'; + *place++ = '\0'; re_put_long(place, (long_u)val); } @@ -2550,8 +2550,8 @@ static void reginsert_limits(int op, long minval, long maxval, char_u *opnd) place = opnd; /* Op node, where operand used to be. */ *place++ = op; - *place++ = NUL; - *place++ = NUL; + *place++ = '\0'; + *place++ = '\0'; place = re_put_long(place, (long_u)minval); place = re_put_long(place, (long_u)maxval); regtail(opnd, place); @@ -2753,7 +2753,7 @@ static int peekchr(void) while (p[0] == '\\' && (p[1] == 'c' || p[1] == 'C' || p[1] == 'm' || p[1] == 'M' || p[1] == 'Z')) p += 2; - if (p[0] == NUL + if (p[0] == '\0' || (p[0] == '\\' && (p[1] == '|' || p[1] == '&' || p[1] == ')' || p[1] == 'n')) @@ -2765,7 +2765,7 @@ static int peekchr(void) { int c = regparse[1]; - if (c == NUL) + if (c == '\0') curchr = '\\'; /* trailing '\' */ else if ( c <= '~' && META_flags[c] @@ -2825,7 +2825,7 @@ static void skipchr(void) prevchr_len = 1; else prevchr_len = 0; - if (regparse[prevchr_len] != NUL) { + if (regparse[prevchr_len] != '\0') { if (enc_utf8) /* exclude composing chars that mb_ptr2len does include */ prevchr_len += utf_ptr2len(regparse + prevchr_len); @@ -3479,7 +3479,7 @@ proftime_T *tm; /* timeout limit or NULL */ c = (*mb_ptr2char)(regline + col); else c = regline[col]; - if (prog->regstart == NUL + if (prog->regstart == '\0' || prog->regstart == c || (ireg_ic && (( (enc_utf8 && utf_fold(prog->regstart) == utf_fold(c))) @@ -3492,7 +3492,7 @@ proftime_T *tm; /* timeout limit or NULL */ int tm_count = 0; /* Messy cases: unanchored match. */ while (!got_int) { - if (prog->regstart != NUL) { + if (prog->regstart != '\0') { /* Skip until the char we know it must start with. * Used often, do some work to avoid call overhead. */ if (!ireg_ic @@ -3523,7 +3523,7 @@ proftime_T *tm; /* timeout limit or NULL */ reglnum = 0; regline = reg_getline((linenr_T)0); } - if (regline[col] == NUL) + if (regline[col] == '\0') break; if (has_mbyte) col += (*mb_ptr2len)(regline + col); @@ -3827,7 +3827,7 @@ regmatch ( op = OP(scan); /* Check for character class with NL added. */ if (!reg_line_lbr && WITH_NL(op) && REG_MULTI - && *reginput == NUL && reglnum <= reg_maxline) { + && *reginput == '\0' && reglnum <= reg_maxline) { reg_nextline(); } else if (reg_line_lbr && WITH_NL(op) && *reginput == '\n') { ADVANCE_REGINPUT(); @@ -3845,7 +3845,7 @@ regmatch ( break; case EOL: - if (c != NUL) + if (c != '\0') status = RA_NOMATCH; break; @@ -3859,7 +3859,7 @@ regmatch ( break; case RE_EOF: - if (reglnum != reg_maxline || c != NUL) + if (reglnum != reg_maxline || c != '\0') status = RA_NOMATCH; break; @@ -3919,7 +3919,7 @@ regmatch ( break; case BOW: /* \<word; reginput points to w */ - if (c == NUL) /* Can't match at end of line */ + if (c == '\0') /* Can't match at end of line */ status = RA_NOMATCH; else if (has_mbyte) { int this_class; @@ -3952,14 +3952,14 @@ regmatch ( status = RA_NOMATCH; } else { if (!vim_iswordc_buf(reginput[-1], reg_buf) - || (reginput[0] != NUL && vim_iswordc_buf(c, reg_buf))) + || (reginput[0] != '\0' && vim_iswordc_buf(c, reg_buf))) status = RA_NOMATCH; } break; /* Matched with EOW */ case ANY: /* ANY does not match new lines. */ - if (c == NUL) + if (c == '\0') status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4029,7 +4029,7 @@ regmatch ( break; case NWHITE: - if (c == NUL || vim_iswhite(c)) + if (c == '\0' || vim_iswhite(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4043,7 +4043,7 @@ regmatch ( break; case NDIGIT: - if (c == NUL || ri_digit(c)) + if (c == '\0' || ri_digit(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4057,7 +4057,7 @@ regmatch ( break; case NHEX: - if (c == NUL || ri_hex(c)) + if (c == '\0' || ri_hex(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4071,7 +4071,7 @@ regmatch ( break; case NOCTAL: - if (c == NUL || ri_octal(c)) + if (c == '\0' || ri_octal(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4085,7 +4085,7 @@ regmatch ( break; case NWORD: - if (c == NUL || ri_word(c)) + if (c == '\0' || ri_word(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4099,7 +4099,7 @@ regmatch ( break; case NHEAD: - if (c == NUL || ri_head(c)) + if (c == '\0' || ri_head(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4113,7 +4113,7 @@ regmatch ( break; case NALPHA: - if (c == NUL || ri_alpha(c)) + if (c == '\0' || ri_alpha(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4127,7 +4127,7 @@ regmatch ( break; case NLOWER: - if (c == NUL || ri_lower(c)) + if (c == '\0' || ri_lower(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4141,7 +4141,7 @@ regmatch ( break; case NUPPER: - if (c == NUL || ri_upper(c)) + if (c == '\0' || ri_upper(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); @@ -4159,10 +4159,10 @@ regmatch ( !enc_utf8 && vim_tolower(*opnd) != vim_tolower(*reginput)))) status = RA_NOMATCH; - else if (*opnd == NUL) { + else if (*opnd == '\0') { /* match empty string always works; happens when "~" is * empty. */ - } else if (opnd[1] == NUL + } else if (opnd[1] == '\0' && !(enc_utf8 && ireg_ic) ) ++reginput; /* matched a single char */ @@ -4187,7 +4187,7 @@ regmatch ( case ANYOF: case ANYBUT: - if (c == NUL) + if (c == '\0') status = RA_NOMATCH; else if ((cstrchr(OPERAND(scan), c) == NULL) == (op == ANYOF)) status = RA_NOMATCH; @@ -4214,7 +4214,7 @@ regmatch ( /* When only a composing char is given match at any * position where that composing char appears. */ status = RA_NOMATCH; - for (i = 0; reginput[i] != NUL; i += utf_char2len(inpc)) { + for (i = 0; reginput[i] != '\0'; i += utf_char2len(inpc)) { inpc = mb_ptr2char(reginput + i); if (!utf_iscomposing(inpc)) { if (i > 0) @@ -4573,8 +4573,8 @@ regmatch ( } else rst.nextb_ic = rst.nextb; } else { - rst.nextb = NUL; - rst.nextb_ic = NUL; + rst.nextb = '\0'; + rst.nextb_ic = '\0'; } if (op != BRACE_SIMPLE) { rst.minval = (op == STAR) ? 0 : 1; @@ -4670,7 +4670,7 @@ regmatch ( break; case NEWL: - if ((c != NUL || !REG_MULTI || reglnum > reg_maxline + if ((c != '\0' || !REG_MULTI || reglnum > reg_maxline || reg_line_lbr) && (c != '\n' || !reg_line_lbr)) status = RA_NOMATCH; else if (reg_line_lbr) @@ -4998,7 +4998,7 @@ regmatch ( status = RA_NOMATCH; /* If it could match, try it. */ - if (rst->nextb == NUL || *reginput == rst->nextb + if (rst->nextb == '\0' || *reginput == rst->nextb || *reginput == rst->nextb_ic) { reg_save(&rp->rs_un.regsave, &backpos); scan = regnext(rp->rs_scan); @@ -5110,7 +5110,7 @@ regrepeat ( while (count < maxcount) { /* Matching anything means we continue until end-of-line (or * end-of-file for ANY + ADD_NL), only limited by maxcount. */ - while (*scan != NUL && count < maxcount) { + while (*scan != '\0' && count < maxcount) { ++count; mb_ptr_adv(scan); } @@ -5134,7 +5134,7 @@ regrepeat ( while (count < maxcount) { if (vim_isIDc(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan))) { mb_ptr_adv(scan); - } else if (*scan == NUL) { + } else if (*scan == '\0') { if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline || reg_line_lbr) break; @@ -5160,7 +5160,7 @@ regrepeat ( if (vim_iswordp_buf(scan, reg_buf) && (testval || !VIM_ISDIGIT(*scan))) { mb_ptr_adv(scan); - } else if (*scan == NUL) { + } else if (*scan == '\0') { if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline || reg_line_lbr) break; @@ -5185,7 +5185,7 @@ regrepeat ( while (count < maxcount) { if (vim_isfilec(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan))) { mb_ptr_adv(scan); - } else if (*scan == NUL) { + } else if (*scan == '\0') { if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline || reg_line_lbr) break; @@ -5208,7 +5208,7 @@ regrepeat ( case SPRINT: case SPRINT + ADD_NL: while (count < maxcount) { - if (*scan == NUL) { + if (*scan == '\0') { if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline || reg_line_lbr) break; @@ -5233,7 +5233,7 @@ regrepeat ( do_class: while (count < maxcount) { int l; - if (*scan == NUL) { + if (*scan == '\0') { if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline || reg_line_lbr) break; @@ -5380,7 +5380,7 @@ do_class: case ANYBUT + ADD_NL: while (count < maxcount) { int len; - if (*scan == NUL) { + if (*scan == '\0') { if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline || reg_line_lbr) break; @@ -5405,7 +5405,7 @@ do_class: case NEWL: while (count < maxcount - && ((*scan == NUL && reglnum <= reg_maxline && !reg_line_lbr + && ((*scan == '\0' && reglnum <= reg_maxline && !reg_line_lbr && REG_MULTI) || (*scan == '\n' && reg_line_lbr))) { count++; if (reg_line_lbr) @@ -5760,7 +5760,7 @@ static void regdump(char_u *pattern, bt_regprog_T *r) || op == EXACTLY) { /* Literal string, where present. */ fprintf(f, "\nxxxxxxxxx\n"); - while (*s != NUL) + while (*s != '\0') fprintf(f, "%c", *s++); fprintf(f, "\nxxxxxxxxx\n"); s++; @@ -5769,7 +5769,7 @@ static void regdump(char_u *pattern, bt_regprog_T *r) } /* Header fields of interest. */ - if (r->regstart != NUL) + if (r->regstart != '\0') fprintf(f, "start `%s' 0x%x; ", r->regstart < 256 ? (char *)transchar(r->regstart) : "multibyte", r->regstart); @@ -6314,7 +6314,7 @@ static char_u *cstrchr(char_u *s, int c) return vim_strchr(s, c); if (has_mbyte) { - for (p = s; *p != NUL; p += (*mb_ptr2len)(p)) { + for (p = s; *p != '\0'; p += (*mb_ptr2len)(p)) { if (enc_utf8 && c > 0x80) { if (utf_fold(utf_ptr2char(p)) == cc) return p; @@ -6323,7 +6323,7 @@ static char_u *cstrchr(char_u *s, int c) } } else /* Faster version for when there are no multi-byte characters. */ - for (p = s; *p != NUL; ++p) + for (p = s; *p != '\0'; ++p) if (*p == c || *p == cc) return p; @@ -6564,13 +6564,13 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in if (eval_result != NULL) { int had_backslash = FALSE; - for (s = eval_result; *s != NUL; mb_ptr_adv(s)) { + for (s = eval_result; *s != '\0'; mb_ptr_adv(s)) { /* Change NL to CR, so that it becomes a line break, * unless called from vim_regexec_nl(). * Skip over a backslashed character. */ if (*s == NL && !submatch_line_lbr) *s = CAR; - else if (*s == '\\' && s[1] != NUL) { + else if (*s == '\\' && s[1] != '\0') { ++s; /* Change NL to CR here too, so that this works: * :s/abc\\\ndef/\="aaa\\\nbbb"/ on text: @@ -6605,10 +6605,10 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in can_f_submatch = FALSE; } } else - while ((c = *src++) != NUL) { + while ((c = *src++) != '\0') { if (c == '&' && magic) no = 0; - else if (c == '\\' && *src != NUL) { + else if (c == '\\' && *src != '\0') { if (*src == '&' && !magic) { ++src; no = 0; @@ -6631,7 +6631,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in } } if (no < 0) { /* Ordinary character. */ - if (c == K_SPECIAL && src[0] != NUL && src[1] != NUL) { + if (c == K_SPECIAL && src[0] != '\0' && src[1] != '\0') { /* Copy a special key as-is. */ if (copy) { *dst++ = c; @@ -6644,7 +6644,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in continue; } - if (c == '\\' && *src != NUL) { + if (c == '\\' && *src != '\0') { /* Check for abbreviations -- webb */ switch (*src) { case 'r': c = CAR; ++src; break; @@ -6734,7 +6734,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in len = (int)STRLEN(s); } else break; - } else if (*s == NUL) { /* we hit NUL. */ + } else if (*s == '\0') { /* we hit NUL. */ if (copy) EMSG(_(e_re_damg)); goto exit; @@ -6795,7 +6795,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in } } if (copy) - *dst = NUL; + *dst = '\0'; exit: return (int)((dst - dest) + 1); @@ -6884,7 +6884,7 @@ char_u *reg_submatch(int no) submatch_mmatch->endpos[no].col); len += submatch_mmatch->endpos[no].col; if (round == 2) - retval[len] = NUL; + retval[len] = '\0'; ++len; } diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 52dc228bb2..6d87b0b183 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -527,7 +527,7 @@ static char_u *nfa_get_match_text(nfa_state_T *start) *s++ = p->c; p = p->out; } - *s = NUL; + *s = '\0'; return ret; } @@ -1060,7 +1060,7 @@ static int nfa_regatom(void) c = getchr(); switch (c) { - case NUL: + case '\0': EMSG_RET_FAIL(_(e_nul_found)); case Magic('^'): @@ -1082,7 +1082,7 @@ static int nfa_regatom(void) case Magic('_'): c = no_Magic(getchr()); - if (c == NUL) + if (c == '\0') EMSG_RET_FAIL(_(e_nul_found)); if (c == '^') { /* "\_^" is start-of-line */ @@ -1201,7 +1201,7 @@ static int nfa_regatom(void) EMSG(_(e_nopresub)); return FAIL; } - for (lp = reg_prev_sub; *lp != NUL; mb_cptr_adv(lp)) { + for (lp = reg_prev_sub; *lp != '\0'; mb_cptr_adv(lp)) { EMIT(PTR2CHAR(lp)); if (lp != reg_prev_sub) EMIT(NFA_CONCAT); @@ -1326,7 +1326,7 @@ static int nfa_regatom(void) /* \%[abc] */ for (n = 0; (c = peekchr()) != ']'; ++n) { - if (c == NUL) + if (c == '\0') EMSG2_RET_FAIL(_(e_missing_sb), reg_magic == MAGIC_ALL); /* recursive call! */ @@ -1915,7 +1915,7 @@ static int nfa_regconcat(void) while (cont) { switch (peekchr()) { - case NUL: + case '\0': case Magic('|'): case Magic('&'): case Magic(')'): @@ -2060,7 +2060,7 @@ nfa_reg ( EMSG2_RET_FAIL(_(e_unmatchedpp), reg_magic == MAGIC_ALL); else EMSG2_RET_FAIL(_(e_unmatchedp), reg_magic == MAGIC_ALL); - } else if (paren == REG_NOPAREN && peekchr() != NUL) { + } else if (paren == REG_NOPAREN && peekchr() != '\0') { if (peekchr() == Magic(')')) EMSG2_RET_FAIL(_(e_unmatchedpar), reg_magic == MAGIC_ALL); else @@ -2415,7 +2415,7 @@ static void nfa_dump(nfa_regprog_T *prog) if (prog->reganch) fprintf(debugf, "reganch: %d\n", prog->reganch); - if (prog->regstart != NUL) + if (prog->regstart != '\0') fprintf(debugf, "regstart: %c (decimal: %d)\n", prog->regstart, prog->regstart); if (prog->match_text != NULL) @@ -3473,7 +3473,7 @@ static char *pim_info(nfa_pim_T *pim) static char buf[30]; if (pim == NULL || pim->result == NFA_PIM_UNUSED) - buf[0] = NUL; + buf[0] = '\0'; else { sprintf(buf, " PIM col %d", REG_MULTI ? (int)pim->end.pos.col : (int)(pim->end.ptr - reginput)); @@ -3875,7 +3875,7 @@ addstate ( * Except when at the end of the line, or when we are going to the * next line for a look-behind match. */ if (reginput > regline - && *reginput != NUL + && *reginput != '\0' && (nfa_endp == NULL || !REG_MULTI || reglnum == nfa_endp->se_u.pos.lnum)) @@ -4773,7 +4773,7 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text) for (;; ) { match = TRUE; len2 = MB_CHAR2LEN(regstart); /* skip regstart */ - for (len1 = 0; match_text[len1] != NUL; len1 += MB_CHAR2LEN(c1)) { + for (len1 = 0; match_text[len1] != '\0'; len1 += MB_CHAR2LEN(c1)) { c1 = PTR2CHAR(match_text + len1); c2 = PTR2CHAR(regline + col + len2); if (c1 != c2 && (!ireg_ic || vim_tolower(c1) != vim_tolower(c2))) { @@ -4918,7 +4918,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm curc = *reginput; clen = 1; } - if (curc == NUL) { + if (curc == '\0') { clen = 0; go_to_nextline = FALSE; } @@ -5249,7 +5249,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_EOL: - if (curc == NUL) { + if (curc == '\0') { add_here = TRUE; add_state = t->state->out; } @@ -5258,7 +5258,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm case NFA_BOW: result = TRUE; - if (curc == NUL) + if (curc == '\0') result = FALSE; else if (has_mbyte) { int this_class; @@ -5293,7 +5293,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm || prev_class == 0 || prev_class == 1) result = FALSE; } else if (!vim_iswordc_buf(reginput[-1], reg_buf) - || (reginput[0] != NUL + || (reginput[0] != '\0' && vim_iswordc_buf(curc, reg_buf))) result = FALSE; if (result) { @@ -5311,7 +5311,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_EOF: - if (reglnum == reg_maxline && curc == NUL) { + if (reglnum == reg_maxline && curc == '\0') { add_here = TRUE; add_state = t->state->out; } @@ -5385,7 +5385,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm } case NFA_NEWL: - if (curc == NUL && !reg_line_lbr && REG_MULTI + if (curc == '\0' && !reg_line_lbr && REG_MULTI && reglnum <= reg_maxline) { go_to_nextline = TRUE; /* Pass -1 for the offset, which means taking the position @@ -5410,7 +5410,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm /* Never match EOL. If it's part of the collection it is added * as a separate state with an OR. */ - if (curc == NUL) + if (curc == '\0') break; state = t->state->out; @@ -5521,7 +5521,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NWHITE: /* \S */ - result = curc != NUL && !vim_iswhite(curc); + result = curc != '\0' && !vim_iswhite(curc); ADD_STATE_IF_MATCH(t->state); break; @@ -5531,7 +5531,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NDIGIT: /* \D */ - result = curc != NUL && !ri_digit(curc); + result = curc != '\0' && !ri_digit(curc); ADD_STATE_IF_MATCH(t->state); break; @@ -5541,7 +5541,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NHEX: /* \X */ - result = curc != NUL && !ri_hex(curc); + result = curc != '\0' && !ri_hex(curc); ADD_STATE_IF_MATCH(t->state); break; @@ -5551,7 +5551,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NOCTAL: /* \O */ - result = curc != NUL && !ri_octal(curc); + result = curc != '\0' && !ri_octal(curc); ADD_STATE_IF_MATCH(t->state); break; @@ -5561,7 +5561,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NWORD: /* \W */ - result = curc != NUL && !ri_word(curc); + result = curc != '\0' && !ri_word(curc); ADD_STATE_IF_MATCH(t->state); break; @@ -5571,7 +5571,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NHEAD: /* \H */ - result = curc != NUL && !ri_head(curc); + result = curc != '\0' && !ri_head(curc); ADD_STATE_IF_MATCH(t->state); break; @@ -5581,7 +5581,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NALPHA: /* \A */ - result = curc != NUL && !ri_alpha(curc); + result = curc != '\0' && !ri_alpha(curc); ADD_STATE_IF_MATCH(t->state); break; @@ -5591,7 +5591,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NLOWER: /* \L */ - result = curc != NUL && !ri_lower(curc); + result = curc != '\0' && !ri_lower(curc); ADD_STATE_IF_MATCH(t->state); break; @@ -5601,7 +5601,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NUPPER: /* \U */ - result = curc != NUL && !ri_upper(curc); + result = curc != '\0' && !ri_upper(curc); ADD_STATE_IF_MATCH(t->state); break; @@ -5611,7 +5611,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NLOWER_IC: /* [^a-z] */ - result = curc != NUL + result = curc != '\0' && !(ri_lower(curc) || (ireg_ic && ri_upper(curc))); ADD_STATE_IF_MATCH(t->state); break; @@ -5622,7 +5622,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm break; case NFA_NUPPER_IC: /* ^[A-Z] */ - result = curc != NUL + result = curc != '\0' && !(ri_upper(curc) || (ireg_ic && ri_lower(curc))); ADD_STATE_IF_MATCH(t->state); break; @@ -5939,7 +5939,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm int add = TRUE; int c; - if (prog->regstart != NUL && clen != 0) { + if (prog->regstart != '\0' && clen != 0) { if (nextlist->n == 0) { colnr_T col = (colnr_T)(reginput - regline) + clen; @@ -6190,7 +6190,7 @@ nfa_regexec_both ( } else nfa_has_zsubexpr = FALSE; - if (prog->regstart != NUL) { + if (prog->regstart != '\0') { /* Skip ahead until a character we know the match must start with. * When there is none there is no match. */ if (skip_to_start(prog->regstart, &col) == FAIL) diff --git a/src/screen.c b/src/screen.c index 9910f93324..5889a5b6c9 100644 --- a/src/screen.c +++ b/src/screen.c @@ -620,7 +620,7 @@ int conceal_cursor_line(win_T *wp) { int c; - if (*wp->w_p_cocu == NUL) + if (*wp->w_p_cocu == '\0') return FALSE; if (get_real_state() & VISUAL) c = 'v'; @@ -1974,7 +1974,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T idx = off + col; /* Store multibyte characters in ScreenLines[] et al. correctly. */ - for (p = text; *p != NUL; ) { + for (p = text; *p != '\0'; ) { cells = (*mb_ptr2cells)(p); c_len = (*mb_ptr2len)(p); if (col + cells > W_WIDTH(wp) @@ -2235,7 +2235,7 @@ win_line ( char_u extra[18]; /* line number and 'fdc' must fit in here */ int n_extra = 0; /* number of extra chars */ char_u *p_extra = NULL; /* string of extra chars, plus NUL */ - int c_extra = NUL; /* extra chars, all the same */ + int c_extra = '\0'; /* extra chars, all the same */ int extra_attr = 0; /* attributes when n_extra != 0 */ static char_u *at_end_str = (char_u *)""; /* used for p_extra when displaying lcs_eol at end-of-line */ @@ -2383,7 +2383,7 @@ win_line ( draw_color_col = advance_color_col(VCOL_HLC, &color_cols); if (wp->w_p_spell - && *wp->w_s->b_p_spl != NUL + && *wp->w_s->b_p_spl != '\0' && wp->w_s->b_langp.ga_len > 0 && *(char **)(wp->w_s->b_langp.ga_data) != NULL) { /* Prepare for spell checking. */ @@ -2393,7 +2393,7 @@ win_line ( /* Get the start of the next line, so that words that wrap to the next * line are found too: "et<line-break>al.". * Trick: skip a few chars for C/shell/Vim comments */ - nextline[SPWORDLEN] = NUL; + nextline[SPWORDLEN] = '\0'; if (lnum < wp->w_buffer->b_ml.ml_line_count) { line = ml_get_buf(wp->w_buffer, lnum + 1, FALSE); spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN); @@ -2443,7 +2443,7 @@ win_line ( fromcol = 0; else { getvvcol(wp, top, (colnr_T *)&fromcol, NULL, NULL); - if (gchar_pos(top) == NUL) + if (gchar_pos(top) == '\0') tocol = fromcol + 1; } } @@ -2545,7 +2545,7 @@ win_line ( /* To be able to spell-check over line boundaries copy the end of the * current line into nextline[]. Above the start of the next line was * copied to nextline[SPWORDLEN]. */ - if (nextline[SPWORDLEN] == NUL) { + if (nextline[SPWORDLEN] == '\0') { /* No next line or it is empty. */ nextlinecol = MAXCOL; nextline_idx = 0; @@ -2586,7 +2586,7 @@ win_line ( v = wp->w_leftcol; if (v > 0) { char_u *prev_ptr = ptr; - while (vcol < v && *ptr != NUL) { + while (vcol < v && *ptr != '\0') { c = win_lbr_chartabsize(wp, ptr, (colnr_T)vcol, NULL); vcol += c; prev_ptr = ptr; @@ -2723,7 +2723,7 @@ win_line ( shl->endcol = MAXCOL; /* Highlight one character for an empty match. */ if (shl->startcol == shl->endcol) { - if (has_mbyte && line[shl->endcol] != NUL) + if (has_mbyte && line[shl->endcol] != '\0') shl->endcol += (*mb_ptr2len)(line + shl->endcol); else ++shl->endcol; @@ -2781,8 +2781,8 @@ win_line ( fill_foldcolumn(extra, wp, FALSE, lnum); n_extra = wp->w_p_fdc; p_extra = extra; - p_extra[n_extra] = NUL; - c_extra = NUL; + p_extra[n_extra] = '\0'; + c_extra = '\0'; char_attr = hl_attr(HLF_FC); } } @@ -2804,7 +2804,7 @@ win_line ( if (text_sign != 0) { p_extra = sign_get_text(text_sign); if (p_extra != NULL) { - c_extra = NUL; + c_extra = '\0'; n_extra = (int)STRLEN(p_extra); } char_attr = sign_get_attr(text_sign, FALSE); @@ -2849,7 +2849,7 @@ win_line ( if (wp->w_p_rl) /* reverse line numbers */ rl_mirror(extra); p_extra = extra; - c_extra = NUL; + c_extra = '\0'; } else c_extra = ' '; n_extra = number_width(wp) + 1; @@ -2878,10 +2878,10 @@ win_line ( n_extra = W_WIDTH(wp) - col; char_attr = hl_attr(HLF_DED); } - if (*p_sbr != NUL && need_showbreak) { + if (*p_sbr != '\0' && need_showbreak) { /* Draw 'showbreak' at the start of each broken line. */ p_extra = p_sbr; - c_extra = NUL; + c_extra = '\0'; n_extra = (int)STRLEN(p_sbr); char_attr = hl_attr(HLF_AT); need_showbreak = FALSE; @@ -3068,7 +3068,7 @@ win_line ( * For the '$' of the 'list' option, n_extra == 1, p_extra == "". */ if (n_extra > 0) { - if (c_extra != NUL) { + if (c_extra != '\0') { c = c_extra; mb_c = c; /* doesn't handle non-utf-8 multi-byte! */ if (enc_utf8 && (*mb_char2len)(c) > 1) { @@ -3191,7 +3191,7 @@ win_line ( mb_c = mb_ptr2char_adv(&p_extra); mb_utf8 = (c >= 0x80); n_extra = (int)STRLEN(p_extra); - c_extra = NUL; + c_extra = '\0'; if (area_attr == 0 && search_attr == 0) { n_attr = n_extra + 1; extra_attr = hl_attr(HLF_8); @@ -3232,7 +3232,7 @@ win_line ( if (ptr[1] >= 32) mb_c = (c << 8) + ptr[1]; else { - if (ptr[1] == NUL) { + if (ptr[1] == '\0') { /* head byte at end of line */ mb_l = 1; transchar_nonprint(extra, c); @@ -3243,7 +3243,7 @@ win_line ( } p_extra = extra; n_extra = (int)STRLEN(extra) - 1; - c_extra = NUL; + c_extra = '\0'; c = *p_extra++; if (area_attr == 0 && search_attr == 0) { n_attr = n_extra + 1; @@ -3269,7 +3269,7 @@ win_line ( /* Put pointer back so that the character will be * displayed at the start of the next line. */ --ptr; - } else if (*ptr != NUL) + } else if (*ptr != '\0') ptr += mb_l - 1; /* If a double-width char doesn't fit at the left side display @@ -3344,7 +3344,7 @@ win_line ( char_attr = hl_combine_attr(syntax_attr, char_attr); /* no concealing past the end of the line, it interferes * with line highlighting */ - if (c == NUL) + if (c == '\0') syntax_flags = 0; else syntax_flags = get_syntax_info(&syntax_seqnr); @@ -3496,7 +3496,7 @@ win_line ( c_extra = ' '; c = ' '; } - } else if (c == NUL + } else if (c == '\0' && ((wp->w_p_list && lcs_eol > 0) || ((fromcol >= 0 || fromcol_prev >= 0) && tocol > vcol @@ -3529,7 +3529,7 @@ win_line ( else { p_extra = at_end_str; n_extra = 1; - c_extra = NUL; + c_extra = '\0'; } } if (wp->w_p_list) @@ -3549,12 +3549,12 @@ win_line ( c = 0xc0; } else mb_utf8 = FALSE; /* don't draw as UTF-8 */ - } else if (c != NUL) { + } else if (c != '\0') { p_extra = transchar(c); if ((dy_flags & DY_UHEX) && wp->w_p_rl) rl_mirror(p_extra); /* reverse "<12>" */ n_extra = byte2cells(c) - 1; - c_extra = NUL; + c_extra = '\0'; c = *p_extra++; if (!attr_pri) { n_attr = n_extra + 1; @@ -3610,13 +3610,13 @@ win_line ( && vim_strchr(wp->w_p_cocu, 'v') == NULL)) { char_attr = conceal_attr; if (prev_syntax_id != syntax_seqnr - && (syn_get_sub_char() != NUL || wp->w_p_cole == 1) + && (syn_get_sub_char() != '\0' || wp->w_p_cole == 1) && wp->w_p_cole != 3) { /* First time at this concealed item: display one * character. */ - if (syn_get_sub_char() != NUL) + if (syn_get_sub_char() != '\0') c = syn_get_sub_char(); - else if (lcs_conceal != NUL) + else if (lcs_conceal != '\0') c = lcs_conceal; else c = ' '; @@ -3676,13 +3676,13 @@ win_line ( * character of the line and the user wants us to show us a * special character (via 'listchars' option "precedes:<char>". */ - if (lcs_prec_todo != NUL + if (lcs_prec_todo != '\0' && (wp->w_p_wrap ? wp->w_skipcol > 0 : wp->w_leftcol > 0) && filler_todo <= 0 && draw_state > WL_NR - && c != NUL) { + && c != '\0') { c = lcs_prec; - lcs_prec_todo = NUL; + lcs_prec_todo = '\0'; if (has_mbyte && (*mb_char2cells)(mb_c) > 1) { /* Double-width character being overwritten by the "precedes" * character, need to fill up half the character. */ @@ -3708,12 +3708,12 @@ win_line ( /* * At end of the text line or just after the last character. */ - if (c == NUL + if (c == '\0' #if defined(LINE_ATTR) || did_line_attr == 1 #endif ) { - long prevcol = (long)(ptr - line) - (c == NUL); + long prevcol = (long)(ptr - line) - (c == '\0'); /* we're not really at that column when skipping some text */ if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol) @@ -3741,7 +3741,7 @@ win_line ( && (VIsual_mode != Ctrl_V || lnum == VIsual.lnum || lnum == curwin->w_cursor.lnum) - && c == NUL) + && c == '\0') /* highlight 'hlsearch' match at end of line */ || (prevcol_hl_flag == TRUE # if defined(LINE_ATTR) @@ -3806,7 +3806,7 @@ win_line ( /* * At end of the text line. */ - if (c == NUL) { + if (c == '\0') { if (eol_hl_off > 0 && vcol - eol_hl_off == (long)wp->w_virtcol && lnum == wp->w_cursor.lnum) { /* highlight last char after line */ @@ -3899,9 +3899,9 @@ win_line ( && ( wp->w_p_rl ? col == 0 : col == W_WIDTH(wp) - 1) - && (*ptr != NUL + && (*ptr != '\0' || (wp->w_p_list && lcs_eol_one > 0) - || (n_extra && (c_extra != NUL || *p_extra != NUL)))) { + || (n_extra && (c_extra != '\0' || *p_extra != '\0')))) { c = lcs_ext; char_attr = hl_attr(HLF_AT); mb_c = c; @@ -4088,10 +4088,10 @@ win_line ( if (( wp->w_p_rl ? (col < 0) : (col >= W_WIDTH(wp))) - && (*ptr != NUL + && (*ptr != '\0' || filler_todo > 0 - || (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str) - || (n_extra != 0 && (c_extra != NUL || *p_extra != NUL))) + || (wp->w_p_list && lcs_eol != '\0' && p_extra != at_end_str) + || (n_extra != 0 && (c_extra != '\0' || *p_extra != '\0'))) ) { SCREEN_LINE(screen_row, W_WINCOL(wp), col - boguscols, (int)W_WIDTH(wp), wp->w_p_rl); @@ -4200,7 +4200,7 @@ win_line ( } /* for every character in the line */ /* After an empty line check first word for capital. */ - if (*skipwhite(line) == NUL) { + if (*skipwhite(line) == '\0') { capcol_lnum = lnum + 1; cap_col = 0; } @@ -4629,7 +4629,7 @@ static int status_match_len(expand_T *xp, char_u *s) if (emenu && menu_is_separator(s)) return 1; - while (*s != NUL) { + while (*s != '\0') { s += skip_status_match_char(xp, s); len += ptr2cells(s); mb_ptr_adv(s); @@ -4647,7 +4647,7 @@ static int skip_status_match_char(expand_T *xp, char_u *s) if ((rem_backslash(s) && xp->xp_context != EXPAND_HELP) || ((xp->xp_context == EXPAND_MENUS || xp->xp_context == EXPAND_MENUNAMES) - && (s[0] == '\t' || (s[0] == '\\' && s[1] != NUL))) + && (s[0] == '\t' || (s[0] == '\\' && s[1] != '\0'))) ) { #ifndef BACKSLASH_IN_FILENAME if (xp->xp_shell && csh_like_shell() && s[1] == '\\' && s[2] == '!') @@ -4743,7 +4743,7 @@ win_redr_status_matches ( fillchar = fillchar_status(&attr, TRUE); if (first_match == 0) { - *buf = NUL; + *buf = '\0'; len = 0; } else { STRCPY(buf, "< "); @@ -4768,7 +4768,7 @@ win_redr_status_matches ( len += l; clen += l; } else - for (; *s != NUL; ++s) { + for (; *s != '\0'; ++s) { s += skip_status_match_char(xp, s); clen += ptr2cells(s); if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1) { @@ -4795,7 +4795,7 @@ win_redr_status_matches ( ++clen; } - buf[len] = NUL; + buf[len] = '\0'; row = cmdline_row - 1; if (row >= 0) { @@ -4828,7 +4828,7 @@ win_redr_status_matches ( screen_puts(buf, row, 0, attr); if (selstart != NULL && highlight) { - *selend = NUL; + *selend = '\0'; screen_puts(selstart, row, selstart_col, hl_attr(HLF_WM)); } @@ -4871,7 +4871,7 @@ void win_redr_status(win_T *wp) ) { /* Don't redraw right now, do it later. */ wp->w_redr_status = TRUE; - } else if (*p_stl != NUL || *wp->w_p_stl != NUL) { + } else if (*p_stl != '\0' || *wp->w_p_stl != '\0') { /* redraw custom status line */ redraw_custom_statusline(wp); } else { @@ -4917,7 +4917,7 @@ void win_redr_status(win_T *wp) /* Find first character that will fit. * Going from start to end is much faster for DBCS. */ - for (i = 0; p[i] != NUL && clen >= this_ru_col - 1; + for (i = 0; p[i] != '\0' && clen >= this_ru_col - 1; i += (*mb_ptr2len)(p + i)) clen -= (*mb_ptr2cells)(p + i); len = clen; @@ -4982,7 +4982,7 @@ static void redraw_custom_statusline(win_T *wp) * display is messed up with errors and a redraw triggers the problem * again and again. */ set_string_option_direct((char_u *)"statusline", -1, - (char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL + (char_u *)"", OPT_FREE | (*wp->w_p_stl != '\0' ? OPT_LOCAL : OPT_GLOBAL), SID_ERROR); } called_emsg |= save_called_emsg; @@ -5041,7 +5041,7 @@ get_keymap_str ( --emsg_skip; curbuf = old_curbuf; curwin = old_curwin; - if (p == NULL || *p == NUL) { + if (p == NULL || *p == '\0') { if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED) p = wp->w_buffer->b_p_keymap; else @@ -5050,10 +5050,10 @@ get_keymap_str ( if ((int)(STRLEN(p) + 3) < len) sprintf((char *)buf, "<%s>", p); else - buf[0] = NUL; + buf[0] = '\0'; vim_free(s); } - return buf[0] != NUL; + return buf[0] != '\0'; } /* @@ -5131,12 +5131,12 @@ win_redr_custom ( use_sandbox = was_set_insecurely((char_u *)"rulerformat", 0); } else { - if (*wp->w_p_stl != NUL) + if (*wp->w_p_stl != '\0') stl = wp->w_p_stl; else stl = p_stl; use_sandbox = was_set_insecurely((char_u *)"statusline", - *wp->w_p_stl == NUL ? 0 : OPT_LOCAL); + *wp->w_p_stl == '\0' ? 0 : OPT_LOCAL); } col += W_WINCOL(wp); @@ -5171,7 +5171,7 @@ win_redr_custom ( len += (*mb_char2bytes)(fillchar, buf + len); ++width; } - buf[len] = NUL; + buf[len] = '\0'; /* * Draw each snippet with the specified highlighting. @@ -5225,10 +5225,10 @@ void screen_putchar(int c, int row, int col, int attr) char_u buf[MB_MAXBYTES + 1]; if (has_mbyte) - buf[(*mb_char2bytes)(c, buf)] = NUL; + buf[(*mb_char2bytes)(c, buf)] = '\0'; else { buf[0] = c; - buf[1] = NUL; + buf[1] = '\0'; } screen_puts(buf, row, col, attr); } @@ -5246,17 +5246,17 @@ void screen_getbytes(int row, int col, char_u *bytes, int *attrp) off = LineOffset[row] + col; *attrp = ScreenAttrs[off]; bytes[0] = ScreenLines[off]; - bytes[1] = NUL; + bytes[1] = '\0'; if (enc_utf8 && ScreenLinesUC[off] != 0) - bytes[utfc_char2bytes(off, bytes)] = NUL; + bytes[utfc_char2bytes(off, bytes)] = '\0'; else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) { bytes[0] = ScreenLines[off]; bytes[1] = ScreenLines2[off]; - bytes[2] = NUL; + bytes[2] = '\0'; } else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1) { bytes[1] = ScreenLines[off + 1]; - bytes[2] = NUL; + bytes[2] = '\0'; } } } @@ -5337,7 +5337,7 @@ void screen_puts_len(char_u *text, int len, int row, int col, int attr) max_off = LineOffset[row] + screen_Columns; while (col < screen_Columns && (len < 0 || (int)(ptr - text) < len) - && *ptr != NUL) { + && *ptr != '\0') { c = *ptr; /* check if this is the first byte of a multibyte */ if (has_mbyte) { @@ -5368,8 +5368,8 @@ void screen_puts_len(char_u *text, int len, int row, int col, int attr) /* Do Arabic shaping. */ if (len >= 0 && (int)(ptr - text) + mbyte_blen >= len) { /* Past end of string to be displayed. */ - nc = NUL; - nc1 = NUL; + nc = '\0'; + nc1 = '\0'; } else { nc = utfc_ptr2char_len(ptr + mbyte_blen, pcc, (int)((text + len) - ptr - mbyte_blen)); @@ -5435,7 +5435,7 @@ void screen_puts_len(char_u *text, int len, int row, int col, int attr) if (clear_next_cell) clear_next_cell = FALSE; else if (has_mbyte - && (len < 0 ? ptr[mbyte_blen] == NUL + && (len < 0 ? ptr[mbyte_blen] == '\0' : ptr + mbyte_blen >= text + len) && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1) || (mbyte_cells == 2 @@ -5669,7 +5669,7 @@ next_search_hl ( matchcol = shl->rm.startpos[0].col; ml = ml_get_buf(shl->buf, lnum, FALSE) + matchcol; - if (*ml == NUL) { + if (*ml == '\0') { ++matchcol; shl->lnum = 0; break; @@ -5899,7 +5899,7 @@ static void screen_char(unsigned off, int row, int col) /* Convert UTF-8 character to bytes and write it. */ - buf[utfc_char2bytes(off, buf)] = NUL; + buf[utfc_char2bytes(off, buf)] = '\0'; out_str(buf); if (utf_char2cells(ScreenLinesUC[off]) > 1) @@ -6547,8 +6547,8 @@ static void linecopy(int to, int from, win_T *wp) */ int can_clear(char_u *p) { - return *p != NUL && (t_colors <= 1 - || cterm_normal_bg_color == 0 || *T_UT != NUL); + return *p != '\0' && (t_colors <= 1 + || cterm_normal_bg_color == 0 || *T_UT != '\0'); } /* @@ -6599,7 +6599,7 @@ void windgoto(int row, int col) col = screen_Columns - 1; /* check if no cursor movement is allowed in highlight mode */ - if (screen_attr && *T_MS == NUL) + if (screen_attr && *T_MS == '\0') noinvcurs = HIGHL_COST; else noinvcurs = 0; @@ -6739,7 +6739,7 @@ void windgoto(int row, int col) * removing a line of pixels from the last bold char, when * using the bold trick in the GUI. */ - if (T_ND[0] != NUL && T_ND[1] == NUL) { + if (T_ND[0] != '\0' && T_ND[1] == '\0') { while (i-- > 0) out_char(*T_ND); } else { @@ -6766,7 +6766,7 @@ void windgoto(int row, int col) if (noinvcurs) screen_stop_highlight(); if (row == screen_cur_row && (col > screen_cur_col) && - *T_CRI != NUL) + *T_CRI != '\0') term_cursor_right(col - screen_cur_col); else term_windgoto(row, col); @@ -6958,7 +6958,7 @@ static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int de if (scroll_region || W_WIDTH(wp) != Columns ) { - if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL)) + if (scroll_region && (wp->w_width == Columns || *T_CSV != '\0')) scroll_region_set(wp, row); if (del) retval = screen_del_lines(W_WINROW(wp) + row, 0, line_count, @@ -6966,7 +6966,7 @@ static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int de else retval = screen_ins_lines(W_WINROW(wp) + row, 0, line_count, wp->w_height - row, wp); - if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL)) + if (scroll_region && (wp->w_width == Columns || *T_CSV != '\0')) scroll_region_reset(); return retval; } @@ -7074,21 +7074,21 @@ screen_ins_lines ( * exists. */ result_empty = (row + line_count >= end); - if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL) + if (wp != NULL && wp->w_width != Columns && *T_CSV == '\0') type = USE_REDRAW; else if (can_clear(T_CD) && result_empty) type = USE_T_CD; - else if (*T_CAL != NUL && (line_count > 1 || *T_AL == NUL)) + else if (*T_CAL != '\0' && (line_count > 1 || *T_AL == '\0')) type = USE_T_CAL; - else if (*T_CDL != NUL && result_empty && (line_count > 1 || !can_ce)) + else if (*T_CDL != '\0' && result_empty && (line_count > 1 || !can_ce)) type = USE_T_CDL; - else if (*T_AL != NUL) + else if (*T_AL != '\0') type = USE_T_AL; else if (can_ce && result_empty) type = USE_T_CE; - else if (*T_DL != NUL && result_empty) + else if (*T_DL != '\0' && result_empty) type = USE_T_DL; - else if (*T_SR != NUL && row == 0 && (*T_DA == NUL || can_ce)) + else if (*T_SR != '\0' && row == 0 && (*T_DA == '\0' || can_ce)) type = USE_T_SR; else return FAIL; @@ -7111,7 +7111,7 @@ screen_ins_lines ( - if (*T_CCS != NUL) /* cursor relative to region */ + if (*T_CCS != '\0') /* cursor relative to region */ cursor_row = row; else cursor_row = row + off; @@ -7233,7 +7233,7 @@ screen_del_lines ( * We can delete lines only when 'db' flag not set or when 'ce' option * available. */ - can_delete = (*T_DB == NUL || can_clear(T_CE)); + can_delete = (*T_DB == '\0' || can_clear(T_CE)); /* * There are six ways to delete lines: @@ -7247,7 +7247,7 @@ screen_del_lines ( * 5. Use T_DL (delete line) if it exists. * 6. redraw the characters from ScreenLines[]. */ - if (wp != NULL && wp->w_width != Columns && *T_CSV == NUL) + if (wp != NULL && wp->w_width != Columns && *T_CSV == '\0') type = USE_REDRAW; else if (can_clear(T_CD) && result_empty) type = USE_T_CD; @@ -7255,24 +7255,24 @@ screen_del_lines ( /* On the Amiga, somehow '\n' on the last line doesn't always scroll * up, so use delete-line command */ line_count == 1 || - *T_CDL == NUL)) + *T_CDL == '\0')) type = USE_NL; - else if (*T_CDL != NUL && line_count > 1 && can_delete) + else if (*T_CDL != '\0' && line_count > 1 && can_delete) type = USE_T_CDL; else if (can_clear(T_CE) && result_empty && (wp == NULL || wp->w_width == Columns) ) type = USE_T_CE; - else if (*T_DL != NUL && can_delete) + else if (*T_DL != '\0' && can_delete) type = USE_T_DL; - else if (*T_CDL != NUL && can_delete) + else if (*T_CDL != '\0' && can_delete) type = USE_T_CDL; else return FAIL; - if (*T_CCS != NUL) { /* cursor relative to region */ + if (*T_CCS != '\0') { /* cursor relative to region */ cursor_row = row; cursor_end = end; } else { @@ -7590,7 +7590,7 @@ static void draw_tabline(void) TabPageIdxs[scol] = 0; /* Use the 'tabline' option if it's set. */ - if (*p_tal != NUL) { + if (*p_tal != '\0') { int save_called_emsg = called_emsg; /* Check for an error. If there is one we would loop in redrawing the @@ -7784,7 +7784,7 @@ void showruler(int always) curwin->w_redr_status = TRUE; return; } - if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height) { + if ((*p_stl != '\0' || *curwin->w_p_stl != '\0') && curwin->w_status_height) { redraw_custom_statusline(curwin); } else win_redr_ruler(curwin, always); @@ -7853,7 +7853,7 @@ static void win_redr_ruler(win_T *wp, int always) * Check if not in Insert mode and the line is empty (will show "0-1"). */ if (!(State & INSERT) - && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == NUL) + && *ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE) == '\0') empty_line = TRUE; /* @@ -7886,7 +7886,7 @@ static void win_redr_ruler(win_T *wp, int always) /* In list mode virtcol needs to be recomputed */ virtcol = wp->w_virtcol; - if (wp->w_p_list && lcs_tab1 == NUL) { + if (wp->w_p_list && lcs_tab1 == '\0') { wp->w_p_list = FALSE; getvvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL); wp->w_p_list = TRUE; @@ -7934,15 +7934,15 @@ static void win_redr_ruler(win_T *wp, int always) /* Truncate at window boundary. */ if (has_mbyte) { o = 0; - for (i = 0; buffer[i] != NUL; i += (*mb_ptr2len)(buffer + i)) { + for (i = 0; buffer[i] != '\0'; i += (*mb_ptr2len)(buffer + i)) { o += (*mb_ptr2cells)(buffer + i); if (this_ru_col + o > WITH_WIDTH(width)) { - buffer[i] = NUL; + buffer[i] = '\0'; break; } } } else if (this_ru_col + (int)STRLEN(buffer) > WITH_WIDTH(width)) - buffer[WITH_WIDTH(width) - this_ru_col] = NUL; + buffer[WITH_WIDTH(width) - this_ru_col] = '\0'; screen_puts(buffer, row, this_ru_col + WITH_OFF(off), attr); i = redraw_cmdline; diff --git a/src/search.c b/src/search.c index 2c33c3f6ab..c9ca8ea170 100644 --- a/src/search.c +++ b/src/search.c @@ -161,7 +161,7 @@ search_regcomp ( /* * If no pattern given, use a previously defined pattern. */ - if (pat == NULL || *pat == NUL) { + if (pat == NULL || *pat == '\0') { if (pat_use == RE_LAST) i = last_idx; else @@ -178,7 +178,7 @@ search_regcomp ( magic = spats[i].magic; no_smartcase = spats[i].no_scs; } else if (options & SEARCH_HIS) /* put new pattern in history */ - add_to_history(HIST_SEARCH, pat, TRUE, NUL); + add_to_history(HIST_SEARCH, pat, TRUE, '\0'); if (mr_pattern_alloced) { vim_free(mr_pattern); @@ -256,7 +256,7 @@ char_u *reverse_text(char_u *s) rev[--rev_i] = s[s_i]; } - rev[len] = NUL; + rev[len] = '\0'; } return rev; } @@ -348,7 +348,7 @@ int pat_has_uppercase(char_u *pat) { char_u *p = pat; - while (*p != NUL) { + while (*p != '\0') { int l; if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) { @@ -356,11 +356,11 @@ int pat_has_uppercase(char_u *pat) return TRUE; p += l; } else if (*p == '\\') { - if (p[1] == '_' && p[2] != NUL) /* skip "\_X" */ + if (p[1] == '_' && p[2] != '\0') /* skip "\_X" */ p += 3; - else if (p[1] == '%' && p[2] != NUL) /* skip "\%X" */ + else if (p[1] == '%' && p[2] != '\0') /* skip "\%X" */ p += 3; - else if (p[1] != NUL) /* skip "\X" */ + else if (p[1] != '\0') /* skip "\X" */ p += 2; else p += 1; @@ -394,7 +394,7 @@ void set_last_search_pat(char_u *s, int idx, int magic, int setlast) { vim_free(spats[idx].pat); /* An empty string means that nothing should be matched. */ - if (*s == NUL) + if (*s == '\0') spats[idx].pat = NULL; else spats[idx].pat = vim_strsave(s); @@ -503,7 +503,7 @@ proftime_T *tm; /* timeout limit or NULL */ && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count && pos->col < MAXCOL - 2) { ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col; - if (*ptr == NUL) + if (*ptr == '\0') extra_col = 1; else extra_col = (*mb_ptr2len)(ptr); @@ -590,7 +590,7 @@ proftime_T *tm; /* timeout limit or NULL */ && (int)endpos.col - 1 < (int)start_pos.col + extra_col) : ((int)matchpos.col - - (ptr[matchpos.col] == NUL) + - (ptr[matchpos.col] == '\0') < (int)start_pos.col + extra_col))) { /* * If vi-compatible searching, continue at the end @@ -607,7 +607,7 @@ proftime_T *tm; /* timeout limit or NULL */ matchcol = endpos.col; /* for empty match: advance one char */ if (matchcol == matchpos.col - && ptr[matchcol] != NUL) { + && ptr[matchcol] != '\0') { if (has_mbyte) matchcol += (*mb_ptr2len)(ptr + matchcol); @@ -616,7 +616,7 @@ proftime_T *tm; /* timeout limit or NULL */ } } else { matchcol = matchpos.col; - if (ptr[matchcol] != NUL) { + if (ptr[matchcol] != '\0') { if (has_mbyte) matchcol += (*mb_ptr2len)(ptr + matchcol); @@ -626,7 +626,7 @@ proftime_T *tm; /* timeout limit or NULL */ } if (matchcol == 0 && (options & SEARCH_START)) break; - if (ptr[matchcol] == NUL + if (ptr[matchcol] == '\0' || (nmatched = vim_regexec_multi(®match, win, buf, lnum + matchpos.lnum, matchcol, @@ -696,7 +696,7 @@ proftime_T *tm; /* timeout limit or NULL */ matchcol = endpos.col; /* for empty match: advance one char */ if (matchcol == matchpos.col - && ptr[matchcol] != NUL) { + && ptr[matchcol] != '\0') { if (has_mbyte) matchcol += (*mb_ptr2len)(ptr + matchcol); @@ -708,7 +708,7 @@ proftime_T *tm; /* timeout limit or NULL */ if (matchpos.lnum > 0) break; matchcol = matchpos.col; - if (ptr[matchcol] != NUL) { + if (ptr[matchcol] != '\0') { if (has_mbyte) matchcol += (*mb_ptr2len)(ptr + matchcol); @@ -716,7 +716,7 @@ proftime_T *tm; /* timeout limit or NULL */ ++matchcol; } } - if (ptr[matchcol] == NUL + if (ptr[matchcol] == '\0' || (nmatched = vim_regexec_multi(®match, win, buf, lnum + matchpos.lnum, matchcol, @@ -978,7 +978,7 @@ proftime_T *tm; /* timeout limit or NULL */ searchstr = pat; dircp = NULL; /* use previous pattern */ - if (pat == NULL || *pat == NUL || *pat == dirc) { + if (pat == NULL || *pat == '\0' || *pat == dirc) { if (spats[RE_SEARCH].pat == NULL) { /* no previous pattern */ pat = spats[RE_SUBST].pat; if (pat == NULL) { @@ -993,7 +993,7 @@ proftime_T *tm; /* timeout limit or NULL */ } } - if (pat != NULL && *pat != NUL) { /* look for (new) offset */ + if (pat != NULL && *pat != '\0') { /* look for (new) offset */ /* * Find end of regular expression. * If there is a matching '/' or '?', toss it. @@ -1008,7 +1008,7 @@ proftime_T *tm; /* timeout limit or NULL */ } if (*p == dirc) { dircp = p; /* remember where we put the NUL */ - *p++ = NUL; + *p++ = '\0'; } spats[0].off.line = FALSE; spats[0].off.end = FALSE; @@ -1051,7 +1051,7 @@ proftime_T *tm; /* timeout limit or NULL */ char_u *msgbuf; char_u *trunc; - if (*searchstr == NUL) + if (*searchstr == '\0') p = spats[last_idx].pat; else p = searchstr; @@ -1076,7 +1076,7 @@ proftime_T *tm; /* timeout limit or NULL */ if (spats[0].off.off != 0 || spats[0].off.line) sprintf((char *)p, "%" PRId64, (int64_t)spats[0].off.off); else - *p = NUL; + *p = '\0'; } msg_start(); @@ -1277,7 +1277,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, int dir, char_u *pat) && !(compl_cont_status & CONT_SOL)) { if ((p_ic ? MB_STRICMP(p, pat) : STRCMP(p, pat)) == 0) return OK; - } else if (*p != NUL) { /* ignore empty lines */ + } else if (*p != '\0') { /* ignore empty lines */ /* expanding lines or words */ if ((p_ic ? MB_STRNICMP(p, pat, compl_length) : STRNCMP(p, pat, compl_length)) == 0) @@ -1302,7 +1302,7 @@ int searchc(cmdarg_T *cap, int t_cmd) int c = cap->nchar; /* char to search for */ int dir = cap->arg; /* TRUE for searching forward */ long count = cap->count1; /* repeat count */ - static int lastc = NUL; /* last character searched for */ + static int lastc = '\0'; /* last character searched for */ static int lastcdir; /* last direction of character search */ static int last_t_cmd; /* last search t_cmd */ int col; @@ -1312,7 +1312,7 @@ int searchc(cmdarg_T *cap, int t_cmd) static char_u bytes[MB_MAXBYTES + 1]; static int bytelen = 1; /* >1 for multi-byte char */ - if (c != NUL) { /* normal search: remember args for repeat */ + if (c != '\0') { /* normal search: remember args for repeat */ if (!KeyStuffed) { /* don't remember when redoing */ lastc = c; lastcdir = dir; @@ -1325,7 +1325,7 @@ int searchc(cmdarg_T *cap, int t_cmd) } } } else { /* repeat previous search */ - if (lastc == NUL) + if (lastc == '\0') return FAIL; if (dir) /* repeat in opposite direction */ dir = -lastcdir; @@ -1500,10 +1500,10 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) if (initc == '/') ignore_cend = TRUE; backwards = (dir == FORWARD) ? FALSE : TRUE; - initc = NUL; - } else if (initc != '#' && initc != NUL) { + initc = '\0'; + } else if (initc != '#' && initc != '\0') { find_mps_values(&initc, &findc, &backwards, TRUE); - if (findc == NUL) + if (findc == '\0') return NULL; } /* @@ -1561,11 +1561,11 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) * If beyond the end of the line, use the last character in * the line. */ - if (linep[pos.col] == NUL && pos.col) + if (linep[pos.col] == '\0' && pos.col) --pos.col; for (;; ) { initc = PTR2CHAR(linep + pos.col); - if (initc == NUL) + if (initc == '\0') break; find_mps_values(&initc, &findc, &backwards, FALSE); @@ -1699,7 +1699,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) pos.col -= (*mb_head_off)(linep, linep + pos.col); } } else { /* forward search */ - if (linep[pos.col] == NUL + if (linep[pos.col] == '\0' /* at end of line, go to next one */ /* don't search for match in comment */ || (lisp && comment_col != MAXCOL @@ -1796,7 +1796,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) if (*ptr == '"' && (ptr == linep || ptr[-1] != '\'' || ptr[1] != '\'')) ++do_quotes; - if (*ptr == '\\' && ptr[1] != NUL) + if (*ptr == '\\' && ptr[1] != '\0') ++ptr; } do_quotes &= 1; /* result is 1 with even number of quotes */ @@ -1849,7 +1849,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) */ c = PTR2CHAR(linep + pos.col); switch (c) { - case NUL: + case '\0': /* at end of line without trailing backslash, reset inquote */ if (pos.col == 0 || linep[pos.col - 1] != '\\') { inquote = FALSE; @@ -2020,7 +2020,7 @@ showmatch ( * Only show match for chars in the 'matchpairs' option. */ /* 'matchpairs' is "x:y,x:y" */ - for (p = curbuf->b_p_mps; *p != NUL; ++p) { + for (p = curbuf->b_p_mps; *p != '\0'; ++p) { if (PTR2CHAR(p) == c && (curwin->w_p_rl ^ p_ri)) break; p += MB_PTR2LEN(p) + 1; @@ -2029,11 +2029,11 @@ showmatch ( ) break; p += MB_PTR2LEN(p); - if (*p == NUL) + if (*p == '\0') return; } - if ((lpos = findmatch(NULL, NUL)) == NULL) /* no match, so beep */ + if ((lpos = findmatch(NULL, '\0')) == NULL) /* no match, so beep */ vim_beep(); else if (lpos->lnum >= curwin->w_topline && lpos->lnum < curwin->w_botline) { if (!curwin->w_p_wrap) @@ -2110,11 +2110,11 @@ int findsent(int dir, long count) /* * if on an empty line, skip upto a non-empty line */ - if (gchar_pos(&pos) == NUL) { + if (gchar_pos(&pos) == '\0') { do if ((*func)(&pos) == -1) break; - while (gchar_pos(&pos) == NUL); + while (gchar_pos(&pos) == '\0'); if (dir == FORWARD) goto found; } @@ -2123,7 +2123,7 @@ int findsent(int dir, long count) * go to the next line */ else if (dir == FORWARD && pos.col == 0 && - startPS(pos.lnum, NUL, FALSE)) { + startPS(pos.lnum, '\0', FALSE)) { if (pos.lnum == curbuf->b_ml.ml_line_count) return FAIL; ++pos.lnum; @@ -2156,7 +2156,7 @@ int findsent(int dir, long count) for (;; ) { /* find end of sentence */ c = gchar_pos(&pos); - if (c == NUL || (pos.col == 0 && startPS(pos.lnum, NUL, FALSE))) { + if (c == '\0' || (pos.col == 0 && startPS(pos.lnum, '\0', FALSE))) { if (dir == BACKWARD && pos.lnum != startlnum) ++pos.lnum; break; @@ -2168,11 +2168,11 @@ int findsent(int dir, long count) break; while (vim_strchr((char_u *)")]\"'", c = gchar_pos(&tpos)) != NULL); - if (c == -1 || (!cpo_J && (c == ' ' || c == '\t')) || c == NUL + if (c == -1 || (!cpo_J && (c == ' ' || c == '\t')) || c == '\0' || (cpo_J && (c == ' ' && inc(&tpos) >= 0 && gchar_pos(&tpos) == ' '))) { pos = tpos; - if (gchar_pos(&pos) == NUL) /* skip NUL at EOL */ + if (gchar_pos(&pos) == '\0') /* skip NUL at EOL */ inc(&pos); break; } @@ -2227,7 +2227,7 @@ findpar ( while (count--) { did_skip = FALSE; for (first = TRUE;; first = FALSE) { - if (*ml_get(curr) != NUL) + if (*ml_get(curr) != '\0') did_skip = TRUE; /* skip folded lines */ @@ -2241,7 +2241,7 @@ findpar ( * doesn't match historical Vi: It also stops at a "{" in the * first column and at an empty line. */ if (!first && did_skip && (startPS(curr, what, both) - || (posix && what == NUL && *ml_get(curr) == + || (posix && what == '\0' && *ml_get(curr) == '{'))) break; @@ -2282,16 +2282,16 @@ static int inmacro(char_u *opt, char_u *s) * line or the line having ended. */ if ( (macro[0] == s[0] || (macro[0] == ' ' - && (s[0] == NUL || s[0] == ' '))) + && (s[0] == '\0' || s[0] == ' '))) && (macro[1] == s[1] - || ((macro[1] == NUL || macro[1] == ' ') - && (s[0] == NUL || s[1] == NUL || s[1] == ' ')))) + || ((macro[1] == '\0' || macro[1] == ' ') + && (s[0] == '\0' || s[1] == '\0' || s[1] == ' ')))) break; ++macro; - if (macro[0] == NUL) + if (macro[0] == '\0') break; } - return macro[0] != NUL; + return macro[0] != '\0'; } /* @@ -2344,7 +2344,7 @@ static int cls(void) c = gchar_cursor(); if (p_altkeymap && c == F_BLANK) return 0; - if (c == ' ' || c == '\t' || c == NUL) + if (c == ' ' || c == '\t' || c == '\0') return 0; if (enc_dbcs != 0 && c > 0xFF) { /* If cls_bigword, report multi-byte chars as class 1. */ @@ -2424,7 +2424,7 @@ fwd_word ( /* * We'll stop if we land on a blank line */ - if (curwin->w_cursor.col == 0 && *ml_get_curline() == NUL) + if (curwin->w_cursor.col == 0 && *ml_get_curline() == '\0') break; i = inc_cursor(); @@ -3075,7 +3075,7 @@ current_block ( if (VIsual_active) { if (*p_sel == 'e') ++curwin->w_cursor.col; - if (sol && gchar_cursor() != NUL) + if (sol && gchar_cursor() != '\0') inc(&curwin->w_cursor); /* include the line break */ VIsual = start_pos; VIsual_mode = 'v'; @@ -3110,7 +3110,7 @@ static int in_html_tag(int end_tag) char_u *line = ml_get_curline(); char_u *p; int c; - int lc = NUL; + int lc = '\0'; pos_T pos; if (enc_dbcs) { @@ -3249,7 +3249,7 @@ again: */ inc_cursor(); p = ml_get_cursor(); - for (cp = p; *cp != NUL && *cp != '>' && !vim_iswhite(*cp); mb_ptr_adv(cp)) + for (cp = p; *cp != '\0' && *cp != '>' && !vim_iswhite(*cp); mb_ptr_adv(cp)) ; len = (int)(cp - p); if (len == 0) { @@ -3523,7 +3523,7 @@ find_next_quote ( for (;; ) { c = line[col]; - if (c == NUL) + if (c == '\0') return -1; else if (escape != NULL && vim_strchr(escape, c)) ++col; @@ -3605,14 +3605,14 @@ current_quote ( if (vis_bef_curs) { inside_quotes = VIsual.col > 0 && line[VIsual.col - 1] == quotechar - && line[curwin->w_cursor.col] != NUL + && line[curwin->w_cursor.col] != '\0' && line[curwin->w_cursor.col + 1] == quotechar; i = VIsual.col; col_end = curwin->w_cursor.col; } else { inside_quotes = curwin->w_cursor.col > 0 && line[curwin->w_cursor.col - 1] == quotechar - && line[VIsual.col] != NUL + && line[VIsual.col] != '\0' && line[VIsual.col + 1] == quotechar; i = curwin->w_cursor.col; col_end = VIsual.col; @@ -3760,7 +3760,7 @@ current_quote ( if (inside_quotes || (!selected_quote && line[VIsual.col] != quotechar - && (line[VIsual.col] == NUL + && (line[VIsual.col] == '\0' || line[VIsual.col + 1] != quotechar))) { dec_cursor(); VIsual = curwin->w_cursor; @@ -3965,7 +3965,7 @@ int linewhite(linenr_T lnum) char_u *p; p = skipwhite(ml_get(lnum)); - return *p == NUL; + return *p == '\0'; } #endif @@ -4043,15 +4043,15 @@ find_pattern_in_path ( if (regmatch.regprog == NULL) goto fpip_end; } - inc_opt = (*curbuf->b_p_inc == NUL) ? p_inc : curbuf->b_p_inc; - if (*inc_opt != NUL) { + inc_opt = (*curbuf->b_p_inc == '\0') ? p_inc : curbuf->b_p_inc; + if (*inc_opt != '\0') { incl_regmatch.regprog = vim_regcomp(inc_opt, p_magic ? RE_MAGIC : 0); if (incl_regmatch.regprog == NULL) goto fpip_end; incl_regmatch.rm_ic = FALSE; /* don't ignore case in incl. pat. */ } - if (type == FIND_DEFINE && (*curbuf->b_p_def != NUL || *p_def != NUL)) { - def_regmatch.regprog = vim_regcomp(*curbuf->b_p_def == NUL + if (type == FIND_DEFINE && (*curbuf->b_p_def != '\0' || *p_def != '\0')) { + def_regmatch.regprog = vim_regcomp(*curbuf->b_p_def == '\0' ? p_def : curbuf->b_p_def, p_magic ? RE_MAGIC : 0); if (def_regmatch.regprog == NULL) goto fpip_end; @@ -4177,7 +4177,7 @@ find_pattern_in_path ( ++i; } save_char = p[i]; - p[i] = NUL; + p[i] = '\0'; msg_outtrans_attr(p, hl_attr(HLF_D)); p[i] = save_char; } @@ -4381,7 +4381,7 @@ search_line: i += (int)(p - aux); reuse |= CONT_S_IPOS; } - IObuff[i] = NUL; + IObuff[i] = '\0'; aux = IObuff; if (i == compl_length) @@ -4480,8 +4480,8 @@ exit_matched: if (def_regmatch.regprog == NULL && action == ACTION_EXPAND && !(compl_cont_status & CONT_SOL) - && *startp != NUL - && *(p = startp + MB_PTR2LEN(startp)) != NUL) + && *startp != '\0' + && *(p = startp + MB_PTR2LEN(startp)) != '\0') goto search_line; } line_breakcheck(); @@ -4512,9 +4512,9 @@ exit_matched: /* Remove any CR and LF from the line. */ i = (int)STRLEN(line); if (i > 0 && line[i - 1] == '\n') - line[--i] = NUL; + line[--i] = '\0'; if (i > 0 && line[i - 1] == '\r') - line[--i] = NUL; + line[--i] = '\0'; } else if (!already) { if (++lnum > end_lnum) break; @@ -4578,7 +4578,7 @@ static void show_pat_in_path(char_u *line, int type, int did_show, int action, F --p; if (p >= line && *p == '\r') --p; - *(p + 1) = NUL; + *(p + 1) = '\0'; } if (action == ACTION_SHOW_ALL) { sprintf((char *)IObuff, "%3ld: ", count); /* show match nr */ diff --git a/src/sha256.c b/src/sha256.c index 0ccb13d763..9c15e9ad29 100644 --- a/src/sha256.c +++ b/src/sha256.c @@ -294,7 +294,7 @@ char_u *sha256_bytes(char_u *buf, int buf_len, char_u *salt, int salt_len) char_u* sha256_key(char_u *buf, char_u *salt, int salt_len) { // No passwd means don't encrypt - if ((buf == NULL) || (*buf == NUL)) { + if ((buf == NULL) || (*buf == '\0')) { return (char_u *)""; } diff --git a/src/spell.c b/src/spell.c index b948aed530..59285db5a2 100644 --- a/src/spell.c +++ b/src/spell.c @@ -1018,7 +1018,7 @@ spell_check ( if (spell_iswordp(mi.mi_fend, wp)) { do { mb_ptr_adv(mi.mi_fend); - } while (*mi.mi_fend != NUL && spell_iswordp(mi.mi_fend, wp)); + } while (*mi.mi_fend != '\0' && spell_iswordp(mi.mi_fend, wp)); if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL) { // Check word starting with capital letter. @@ -1041,7 +1041,7 @@ spell_check ( // case-fold the word with one non-word character, so that we can check // for the word end. - if (*mi.mi_fend != NUL) + if (*mi.mi_fend != '\0') mb_ptr_adv(mi.mi_fend); (void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, @@ -1226,7 +1226,7 @@ static void find_word(matchinf_T *mip, int mode) // - we reach the end of the tree, // - or we reach the end of the line. for (;; ) { - if (flen <= 0 && *mip->mi_fend != NUL) + if (flen <= 0 && *mip->mi_fend != '\0') flen = fold_more(mip); len = byts[arridx++]; @@ -1254,7 +1254,7 @@ static void find_word(matchinf_T *mip, int mode) } // Stop looking at end of the line. - if (ptr[wlen] == NUL) + if (ptr[wlen] == '\0') break; // Perform a binary search in the list of accepted bytes. @@ -1288,7 +1288,7 @@ static void find_word(matchinf_T *mip, int mode) // checked word. if (c == ' ') { for (;; ) { - if (flen <= 0 && *mip->mi_fend != NUL) + if (flen <= 0 && *mip->mi_fend != '\0') flen = fold_more(mip); if (ptr[wlen] != ' ' && ptr[wlen] != TAB) break; @@ -1459,7 +1459,7 @@ static void find_word(matchinf_T *mip, int mode) // words must match with one of the COMPOUNDRULE items and // the number of syllables must not be too large. mip->mi_compflags[mip->mi_complen] = ((unsigned)flags >> 24); - mip->mi_compflags[mip->mi_complen + 1] = NUL; + mip->mi_compflags[mip->mi_complen + 1] = '\0'; if (word_ends) { char_u fword[MAXWLEN]; @@ -1649,9 +1649,9 @@ static int can_compound(slang_T *slang, char_u *word, char_u *flags) if (enc_utf8) { // Need to convert the single byte flags to utf8 characters. p = uflags; - for (i = 0; flags[i] != NUL; ++i) + for (i = 0; flags[i] != '\0'; ++i) p += mb_char2bytes(flags[i], p); - *p = NUL; + *p = '\0'; p = uflags; } else p = flags; @@ -1687,9 +1687,9 @@ static int can_be_compound(trystate_T *sp, slang_T *slang, char_u *compflags, in int v; compflags[sp->ts_complen] = flag; - compflags[sp->ts_complen + 1] = NUL; + compflags[sp->ts_complen + 1] = '\0'; v = match_compoundrule(slang, compflags + sp->ts_compsplit); - compflags[sp->ts_complen] = NUL; + compflags[sp->ts_complen] = '\0'; return v; } @@ -1708,22 +1708,22 @@ static int match_compoundrule(slang_T *slang, char_u *compflags) int c; // loop over all the COMPOUNDRULE entries - for (p = slang->sl_comprules; *p != NUL; ++p) { + for (p = slang->sl_comprules; *p != '\0'; ++p) { // loop over the flags in the compound word we have made, match // them against the current rule entry for (i = 0;; ++i) { c = compflags[i]; - if (c == NUL) + if (c == '\0') // found a rule that matches for the flags we have so far return TRUE; - if (*p == '/' || *p == NUL) + if (*p == '/' || *p == '\0') break; // end of rule, it's too short if (*p == '[') { int match = FALSE; // compare against all the flags in [] ++p; - while (*p != ']' && *p != NUL) + while (*p != ']' && *p != '\0') if (*p++ == c) match = TRUE; if (!match) @@ -1833,7 +1833,7 @@ static void find_prefix(matchinf_T *mip, int mode) // - we reach the end of the tree, // - or we reach the end of the line. for (;; ) { - if (flen == 0 && *mip->mi_fend != NUL) + if (flen == 0 && *mip->mi_fend != '\0') flen = fold_more(mip); len = byts[arridx++]; @@ -1873,7 +1873,7 @@ static void find_prefix(matchinf_T *mip, int mode) } // Stop looking at end of the line. - if (ptr[wlen] == NUL) + if (ptr[wlen] == '\0') break; // Perform a binary search in the list of accepted bytes. @@ -1914,10 +1914,10 @@ static int fold_more(matchinf_T *mip) p = mip->mi_fend; do { mb_ptr_adv(mip->mi_fend); - } while (*mip->mi_fend != NUL && spell_iswordp(mip->mi_fend, mip->mi_win)); + } while (*mip->mi_fend != '\0' && spell_iswordp(mip->mi_fend, mip->mi_win)); // Include the non-word character so that we can check for the word end. - if (*mip->mi_fend != NUL) + if (*mip->mi_fend != '\0') mb_ptr_adv(mip->mi_fend); (void)spell_casefold(p, (int)(mip->mi_fend - p), @@ -1945,7 +1945,7 @@ spell_valid_case ( // Return TRUE if spell checking is not enabled. static int no_spell_checking(win_T *wp) { - if (!wp->w_p_spell || *wp->w_s->b_p_spl == NUL + if (!wp->w_p_spell || *wp->w_s->b_p_spl == '\0' || wp->w_s->b_langp.ga_len == 0) { EMSG(_("E756: Spell checking is not enabled")); return TRUE; @@ -2161,7 +2161,7 @@ spell_move_to ( --capcol; // But after empty line check first word in next line - if (*skipwhite(line) == NUL) + if (*skipwhite(line) == '\0') capcol = 0; } @@ -2185,7 +2185,7 @@ void spell_cat_line(char_u *buf, char_u *line, int maxlen) while (vim_strchr((char_u *)"*#/\"\t", *p) != NULL) p = skipwhite(p + 1); - if (*p != NUL) { + if (*p != '\0') { // Only worth concatenating if there is something else than spaces to // concatenate. n = (int)(p - line) + 1; @@ -2227,14 +2227,14 @@ static void spell_load_lang(char_u *lang) lang, spell_enc()); r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl); - if (r == FAIL && *sl.sl_lang != NUL) { + if (r == FAIL && *sl.sl_lang != '\0') { // Try loading the ASCII version. vim_snprintf((char *)fname_enc, sizeof(fname_enc) - 5, "spell/%s.ascii.spl", lang); r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl); - if (r == FAIL && *sl.sl_lang != NUL && round == 1 + if (r == FAIL && *sl.sl_lang != '\0' && round == 1 && apply_autocmds(EVENT_SPELLFILEMISSING, lang, curbuf->b_fname, FALSE, curbuf)) continue; @@ -2389,7 +2389,7 @@ static void slang_clear(slang_T *lp) lp->sl_compmax = MAXWLEN; lp->sl_compminlen = 0; lp->sl_compsylmax = MAXWLEN; - lp->sl_regions[0] = NUL; + lp->sl_regions[0] = '\0'; } // Clear the info from the .sug file in "lp". @@ -2649,7 +2649,7 @@ truncerr: endFAIL: if (lang != NULL) // truncating the name signals the error to spell_load_lang() - *lang = NUL; + *lang = '\0'; if (lp != NULL && old_lp == NULL) slang_free(lp); lp = NULL; @@ -2701,7 +2701,7 @@ static int read_region_section(FILE *fd, slang_T *lp, int len) return SP_FORMERROR; for (i = 0; i < len; ++i) lp->sl_regions[i] = getc(fd); // <regionname> - lp->sl_regions[len] = NUL; + lp->sl_regions[len] = '\0'; return 0; } @@ -2770,7 +2770,7 @@ static int read_prefcond_section(FILE *fd, slang_T *lp) p = buf + 1; while (n-- > 0) *p++ = getc(fd); // <condstr> - *p = NUL; + *p = '\0'; lp->sl_prefprog[i] = vim_regcomp(buf, RE_MAGIC + RE_STRING); } } @@ -2829,7 +2829,7 @@ static int read_sal_section(FILE *fd, slang_T *slang) salitem_T *smp; int ccnt; char_u *p; - int c = NUL; + int c = '\0'; slang->sl_sofo = FALSE; @@ -2866,7 +2866,7 @@ static int read_sal_section(FILE *fd, slang_T *slang) *p++ = c; } smp->sm_leadlen = (int)(p - smp->sm_lead); - *p++ = NUL; + *p++ = '\0'; // Put (abc) chars in sm_oneof, if any. if (c == '(') { @@ -2877,7 +2877,7 @@ static int read_sal_section(FILE *fd, slang_T *slang) break; *p++ = c; } - *p++ = NUL; + *p++ = '\0'; if (++i < ccnt) c = getc(fd); } else @@ -2890,7 +2890,7 @@ static int read_sal_section(FILE *fd, slang_T *slang) *p++ = c; for (++i; i < ccnt; ++i) *p++ = getc(fd); // <salfrom> - *p++ = NUL; + *p++ = '\0'; // <saltolen> <salto> smp->sm_to = read_cnt_string(fd, 1, &ccnt); @@ -2919,7 +2919,7 @@ static int read_sal_section(FILE *fd, slang_T *slang) // that we need to check the index every time. smp = &((salitem_T *)gap->ga_data)[gap->ga_len]; p = alloc(1); - p[0] = NUL; + p[0] = '\0'; smp->sm_lead = p; smp->sm_leadlen = 0; smp->sm_oneof = NULL; @@ -2956,7 +2956,7 @@ static int read_words_section(FILE *fd, slang_T *lp, int len) if (c == EOF) return SP_TRUNCERROR; word[i] = c; - if (word[i] == NUL) + if (word[i] == '\0') break; if (i == MAXWLEN - 1) return SP_FORMERROR; @@ -3151,11 +3151,11 @@ static int read_compound(FILE *fd, slang_T *slang, int len) // for all flags. cp = alloc(todo + 1); slang->sl_compstartflags = cp; - *cp = NUL; + *cp = '\0'; ap = alloc(todo + 1); slang->sl_compallflags = ap; - *ap = NUL; + *ap = '\0'; // And a list of all patterns in their original form, for checking whether // compounding may work in match_compoundrule(). This is freed when we @@ -3180,7 +3180,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len) if (vim_strchr((char_u *)"?*+[]/", c) == NULL && !byte_in_str(slang->sl_compallflags, c)) { *ap++ = c; - *ap = NUL; + *ap = '\0'; } if (atstart != 0) { @@ -3193,7 +3193,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len) else { if (!byte_in_str(slang->sl_compstartflags, c)) { *cp++ = c; - *cp = NUL; + *cp = '\0'; } if (atstart == 1) atstart = 0; @@ -3227,10 +3227,10 @@ static int read_compound(FILE *fd, slang_T *slang, int len) *pp++ = '\\'; *pp++ = ')'; *pp++ = '$'; - *pp = NUL; + *pp = '\0'; if (crp != NULL) - *crp = NUL; + *crp = '\0'; slang->sl_compprog = vim_regcomp(pat, RE_MAGIC + RE_STRING + RE_STRICT); vim_free(pat); @@ -3246,7 +3246,7 @@ static int byte_in_str(char_u *str, int n) { char_u *p; - for (p = str; *p != NUL; ++p) + for (p = str; *p != '\0'; ++p) if (*p == n) return TRUE; return FALSE; @@ -3270,8 +3270,8 @@ static int init_syl_tab(slang_T *slang) ga_init(&slang->sl_syl_items, sizeof(syl_item_T), 4); p = vim_strchr(slang->sl_syllable, '/'); while (p != NULL) { - *p++ = NUL; - if (*p == NUL) // trailing slash + *p++ = '\0'; + if (*p == '\0') // trailing slash break; s = p; p = vim_strchr(p, '/'); @@ -3306,7 +3306,7 @@ static int count_syllables(slang_T *slang, char_u *word) if (slang->sl_syllable == NULL) return 0; - for (p = word; *p != NUL; p += len) { + for (p = word; *p != '\0'; p += len) { // When running into a space reset counter. if (*p == ' ') { len = 1; @@ -3365,13 +3365,13 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to) // First count the number of items for each list. Temporarily use // sl_sal_first[] for this. - for (p = from, s = to; *p != NUL && *s != NUL; ) { + for (p = from, s = to; *p != '\0' && *s != '\0'; ) { c = mb_cptr2char_adv(&p); mb_cptr_adv(s); if (c >= 256) ++lp->sl_sal_first[c & 0xff]; } - if (*p != NUL || *s != NUL) // lengths differ + if (*p != '\0' || *s != '\0') // lengths differ return SP_FORMERROR; // Allocate the lists. @@ -3385,7 +3385,7 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to) // Put the characters up to 255 in sl_sal_first[] the rest in a sl_sal // list. memset(lp->sl_sal_first, 0, sizeof(salfirst_T) * 256); - for (p = from, s = to; *p != NUL && *s != NUL; ) { + for (p = from, s = to; *p != '\0' && *s != '\0'; ) { c = mb_cptr2char_adv(&p); i = mb_cptr2char_adv(&s); if (c >= 256) { @@ -3396,7 +3396,7 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to) ++inp; *inp++ = c; // from char *inp++ = i; // to char - *inp++ = NUL; // NUL at the end + *inp++ = '\0'; // NUL at the end } else // mapping byte to char is done in sl_sal_first[] lp->sl_sal_first[c] = i; @@ -3406,7 +3406,7 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to) if (STRLEN(from) != STRLEN(to)) return SP_FORMERROR; - for (i = 0; to[i] != NUL; ++i) + for (i = 0; to[i] != '\0'; ++i) lp->sl_sal_first[from[i]] = to[i]; lp->sl_sal.ga_len = 1; // indicates we have soundfolding } @@ -3473,9 +3473,9 @@ static int *mb_str2wide(char_u *s) int i = 0; int *res = xmalloc((mb_charlen(s) + 1) * sizeof(int)); - for (char_u *p = s; *p != NUL; ) + for (char_u *p = s; *p != '\0'; ) res[i++] = mb_ptr2char_adv(&p); - res[i] = NUL; + res[i] = '\0'; return res; } @@ -3675,7 +3675,7 @@ char_u *did_set_spelllang(win_T *wp) wp->w_s->b_cjk = 0; // Loop over comma separated language names. - for (splp = spl_copy; *splp != NUL; ) { + for (splp = spl_copy; *splp != '\0'; ) { // Get one language name. copy_option_part(&splp, lang, MAXWLEN, ","); region = NULL; @@ -3712,7 +3712,7 @@ char_u *did_set_spelllang(win_T *wp) if (len > 3 && lang[len - 3] == '_') { region = lang + len - 2; len -= 3; - lang[len] = NUL; + lang[len] = '\0'; } else dont_use_region = TRUE; @@ -3756,7 +3756,7 @@ char_u *did_set_spelllang(win_T *wp) c = find_region(slang->sl_regions, region); if (c == REGION_ALL) { if (slang->sl_add) { - if (*slang->sl_regions != NUL) + if (*slang->sl_regions != '\0') // This addition file is for other regions. region_mask = 0; } else @@ -3786,7 +3786,7 @@ char_u *did_set_spelllang(win_T *wp) // round 2: load second name in 'spellfile. // etc. spf = curwin->w_s->b_p_spf; - for (round = 0; round == 0 || *spf != NUL; ++round) { + for (round = 0; round == 0 || *spf != '\0'; ++round) { if (round == 0) { // Internal wordlist, if there is one. if (int_wordlist == NULL) @@ -3821,7 +3821,7 @@ char_u *did_set_spelllang(win_T *wp) vim_strncpy(lang, path_tail(spf_name), MAXWLEN); p = vim_strchr(lang, '.'); if (p != NULL) - *p = NUL; // truncate at ".encoding.add" + *p = '\0'; // truncate at ".encoding.add" } slang = spell_load_file(spf_name, lang, NULL, TRUE); @@ -3838,7 +3838,7 @@ char_u *did_set_spelllang(win_T *wp) c = find_region(slang->sl_regions, use_region); if (c != REGION_ALL) region_mask = 1 << c; - else if (*slang->sl_regions != NUL) + else if (*slang->sl_regions != '\0') // This spell file is for other regions. region_mask = 0; } @@ -3920,7 +3920,7 @@ static void use_midword(slang_T *lp, win_T *wp) if (lp->sl_midword == NULL) // there aren't any return; - for (p = lp->sl_midword; *p != NUL; ) + for (p = lp->sl_midword; *p != '\0'; ) if (has_mbyte) { int c, l, n; char_u *bp; @@ -3955,7 +3955,7 @@ static int find_region(char_u *rp, char_u *region) int i; for (i = 0;; i += 2) { - if (rp[i] == NUL) + if (rp[i] == '\0') return REGION_ALL; if (rp[i] == region[0] && rp[i + 1] == region[1]) break; @@ -3982,7 +3982,7 @@ captype ( // find first letter for (p = word; !spell_iswordp_nmw(p, curwin); mb_ptr_adv(p)) - if (end == NULL ? *p == NUL : p >= end) + if (end == NULL ? *p == '\0' : p >= end) return 0; // only non-word characters, illegal word if (has_mbyte) c = mb_ptr2char_adv(&p); @@ -3992,7 +3992,7 @@ captype ( // Need to check all letters to find a word with mixed upper/lower. // But a word with an upper char only at start is a ONECAP. - for (; end == NULL ? *p != NUL : p < end; mb_ptr_adv(p)) + for (; end == NULL ? *p != '\0' : p < end; mb_ptr_adv(p)) if (spell_iswordp_nmw(p, curwin)) { c = PTR2CHAR(p); if (!SPELL_ISUPPER(c)) { @@ -4107,7 +4107,7 @@ void spell_reload(void) for (wp = firstwin; wp != NULL; wp = wp->w_next) { // Only load the wordlists when 'spelllang' is set and there is a // window for this buffer in which 'spell' is set. - if (*wp->w_s->b_p_spl != NUL) { + if (*wp->w_s->b_p_spl != '\0') { if (wp->w_p_spell) { (void)did_set_spelllang(wp); break; @@ -4457,7 +4457,7 @@ static void spell_print_node(wordnode_T *node, int depth) } else { node->wn_u1.index = TRUE; - if (node->wn_byte != NUL) { + if (node->wn_byte != '\0') { if (node->wn_child != NULL) PRINTSOME(line1, depth, " %c -> ", node->wn_byte, 0); else @@ -4473,14 +4473,14 @@ static void spell_print_node(wordnode_T *node, int depth) else PRINTSOME(line3, depth, " ", 0, 0); - if (node->wn_byte == NUL) { + if (node->wn_byte == '\0') { msg(line1); msg(line2); msg(line3); } // do the children - if (node->wn_byte != NUL && node->wn_child != NULL) + if (node->wn_byte != '\0' && node->wn_child != NULL) spell_print_node(node->wn_child, depth + 1); // do the siblings @@ -4606,9 +4606,9 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) // item. itemcnt = 0; for (p = line;; ) { - while (*p != NUL && *p <= ' ') // skip white space and CR/NL + while (*p != '\0' && *p <= ' ') // skip white space and CR/NL ++p; - if (*p == NUL) + if (*p == '\0') break; if (itemcnt == MAXITEMCNT) // too many items break; @@ -4620,9 +4620,9 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) else while (*p > ' ') // skip until white space or CR/NL ++p; - if (*p == NUL) + if (*p == '\0') break; - *p++ = NUL; + *p++ = '\0'; } // Handle non-empty lines. @@ -4754,7 +4754,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) fname, lnum, items[1]); } else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2)) { // Don't use the first rule if it is a number. - if (compflags != NULL || *skipdigits(items[1]) != NUL) { + if (compflags != NULL || *skipdigits(items[1]) != '\0') { // Concatenate this string to previously defined ones, // using a slash to separate them. l = (int)STRLEN(items[1]) + 1; @@ -4948,7 +4948,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) // Recognize flags on the affix: abcd/XYZ aff_entry->ae_flags = vim_strchr(aff_entry->ae_add, '/'); if (aff_entry->ae_flags != NULL) { - *aff_entry->ae_flags++ = NUL; + *aff_entry->ae_flags++ = '\0'; aff_process_flags(aff, aff_entry); } } @@ -4989,7 +4989,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) if (aff_entry->ae_chop != NULL && aff_entry->ae_add != NULL && aff_entry->ae_chop[(*mb_ptr2len)( - aff_entry->ae_chop)] == NUL + aff_entry->ae_chop)] == '\0' ) { int c, c_up; @@ -5004,7 +5004,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) if (PTR2CHAR(p) == c_up) { upper = TRUE; aff_entry->ae_chop = NULL; - *p = NUL; + *p = '\0'; // The condition is matched with the // actual word, thus must check for the @@ -5107,10 +5107,10 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) if (items[0][3] == 'S' ? do_repsal : do_rep) { // Replace underscore with space (can't include a space // directly). - for (p = items[1]; *p != NUL; mb_ptr_adv(p)) + for (p = items[1]; *p != '\0'; mb_ptr_adv(p)) if (*p == '_') *p = ' '; - for (p = items[2]; *p != NUL; mb_ptr_adv(p)) + for (p = items[2]; *p != '\0'; mb_ptr_adv(p)) if (*p == '_') *p = ' '; add_fromto(spin, items[0][3] == 'S' @@ -5129,7 +5129,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) int c; // Check that every character appears only once. - for (p = items[1]; *p != NUL; ) { + for (p = items[1]; *p != '\0'; ) { c = mb_ptr2char_adv(&p); if ((spin->si_map.ga_len > 0 && vim_strchr(spin->si_map.ga_data, c) @@ -5296,7 +5296,7 @@ static void aff_process_flags(afffile_T *affile, affentry_T *entry) if (entry->ae_flags != NULL && (affile->af_compforbid != 0 || affile->af_comppermit != 0)) { - for (p = entry->ae_flags; *p != NUL; ) { + for (p = entry->ae_flags; *p != '\0'; ) { prevp = p; flag = get_affitem(affile->af_flagtype, &p); if (flag == affile->af_comppermit || flag == affile->af_compforbid) { @@ -5310,7 +5310,7 @@ static void aff_process_flags(afffile_T *affile, affentry_T *entry) if (affile->af_flagtype == AFT_NUM && *p == ',') ++p; } - if (*entry->ae_flags == NUL) + if (*entry->ae_flags == '\0') entry->ae_flags = NULL; // nothing left } } @@ -5342,7 +5342,7 @@ static unsigned affitem2flag(int flagtype, char_u *item, char_u *fname, int lnum smsg((char_u *)_("Illegal flag in %s line %d: %s"), fname, lnum, item); } - if (*p != NUL) { + if (*p != '\0') { smsg((char_u *)_(e_affname), fname, lnum, item); return 0; } @@ -5366,7 +5366,7 @@ static unsigned get_affitem(int flagtype, char_u **pp) res = mb_ptr2char_adv(pp); if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG && res >= 'A' && res <= 'Z')) { - if (**pp == NUL) + if (**pp == '\0') return 0; res = mb_ptr2char_adv(pp) + (res << 16); } @@ -5406,7 +5406,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla spin->si_compflags = p; tp = p + STRLEN(p); - for (p = compflags; *p != NUL; ) { + for (p = compflags; *p != '\0'; ) { if (vim_strchr((char_u *)"/?*+[]", *p) != NULL) // Copy non-flag characters directly. *tp++ = *p++; @@ -5443,7 +5443,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla } } - *tp = NUL; + *tp = '\0'; } // Check that the new IDs for postponed affixes and compounding don't overrun @@ -5470,10 +5470,10 @@ static int flag_in_afflist(int flagtype, char_u *afflist, unsigned flag) case AFT_CAPLONG: case AFT_LONG: - for (p = afflist; *p != NUL; ) { + for (p = afflist; *p != '\0'; ) { n = mb_ptr2char_adv(&p); if ((flagtype == AFT_LONG || (n >= 'A' && n <= 'Z')) - && *p != NUL) + && *p != '\0') n = mb_ptr2char_adv(&p) + (n << 16); if (n == flag) return TRUE; @@ -5481,11 +5481,11 @@ static int flag_in_afflist(int flagtype, char_u *afflist, unsigned flag) break; case AFT_NUM: - for (p = afflist; *p != NUL; ) { + for (p = afflist; *p != '\0'; ) { n = getdigits(&p); if (n == flag) return TRUE; - if (*p != NUL) // skip over comma + if (*p != '\0') // skip over comma ++p; } break; @@ -5634,7 +5634,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile) --l; if (l == 0) continue; // empty line - line[l] = NUL; + line[l] = '\0'; // Convert from "SET" to 'encoding' when needed. if (spin->si_conv.vc_type != CONV_NONE) { @@ -5653,11 +5653,11 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile) // Truncate the word at the "/", set "afflist" to what follows. // Replace "\/" by "/" and "\\" by "\". afflist = NULL; - for (p = w; *p != NUL; mb_ptr_adv(p)) { + for (p = w; *p != '\0'; mb_ptr_adv(p)) { if (*p == '\\' && (p[1] == '\\' || p[1] == '/')) STRMOVE(p, p + 1); else if (*p == '/') { - *p = NUL; + *p = '\0'; afflist = p + 1; break; } @@ -5706,7 +5706,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile) hash_add_item(&ht, hi, dw, hash); flags = 0; - store_afflist[0] = NUL; + store_afflist[0] = '\0'; pfxlen = 0; need_affix = FALSE; if (afflist != NULL) { @@ -5801,7 +5801,7 @@ static int get_pfxlist(afffile_T *affile, char_u *afflist, char_u *store_afflist char_u key[AH_KEY_LEN]; hashitem_T *hi; - for (p = afflist; *p != NUL; ) { + for (p = afflist; *p != '\0'; ) { prevp = p; if (get_affitem(affile->af_flagtype, &p) != 0) { // A flag is a postponed prefix flag if it appears in "af_pref" @@ -5818,7 +5818,7 @@ static int get_pfxlist(afffile_T *affile, char_u *afflist, char_u *store_afflist ++p; } - store_afflist[cnt] = NUL; + store_afflist[cnt] = '\0'; return cnt; } @@ -5833,7 +5833,7 @@ static void get_compflags(afffile_T *affile, char_u *afflist, char_u *store_affl char_u key[AH_KEY_LEN]; hashitem_T *hi; - for (p = afflist; *p != NUL; ) { + for (p = afflist; *p != '\0'; ) { prevp = p; if (get_affitem(affile->af_flagtype, &p) != 0) { // A flag is a compound flag if it appears in "af_comp". @@ -5846,7 +5846,7 @@ static void get_compflags(afffile_T *affile, char_u *afflist, char_u *store_affl ++p; } - store_afflist[cnt] = NUL; + store_afflist[cnt] = '\0'; } // Apply affixes to a word and store the resulting words. @@ -5930,7 +5930,7 @@ store_aff_word ( if (xht == NULL) { // prefix: chop/add at the start of the word if (ae->ae_add == NULL) - *newword = NUL; + *newword = '\0'; else vim_strncpy(newword, ae->ae_add, MAXWLEN - 1); p = word; @@ -5953,7 +5953,7 @@ store_aff_word ( i = (int)MB_CHARLEN(ae->ae_chop); for (; i > 0; --i) mb_ptr_back(newword, p); - *p = NUL; + *p = '\0'; } if (ae->ae_add != NULL) STRCAT(newword, ae->ae_add); @@ -6012,14 +6012,14 @@ store_aff_word ( // Combine the list of compound flags. // Concatenate them to the prefix IDs list. // Avoid adding the same ID twice. - for (i = pfxlen; pfxlist[i] != NUL; ++i) { + for (i = pfxlen; pfxlist[i] != '\0'; ++i) { for (j = use_pfxlen; - use_pfxlist[j] != NUL; ++j) + use_pfxlist[j] != '\0'; ++j) if (pfxlist[i] == use_pfxlist[j]) break; - if (use_pfxlist[j] == NUL) { + if (use_pfxlist[j] == '\0') { use_pfxlist[j++] = pfxlist[i]; - use_pfxlist[j] = NUL; + use_pfxlist[j] = '\0'; } } } @@ -6138,7 +6138,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) --l; if (l == 0) continue; // empty or blank line - rline[l] = NUL; + rline[l] = '\0'; // Convert from "/encoding={encoding}" to 'encoding' when needed. vim_free(pc); @@ -6214,8 +6214,8 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) // Check for flags and region after a slash. p = vim_strchr(line, '/'); if (p != NULL) { - *p++ = NUL; - while (*p != NUL) { + *p++ = '\0'; + while (*p != '\0') { if (*p == '=') // keep-case word flags |= WF_KEEPCAP | WF_FIXCAP; else if (*p == '!') // Bad, bad, wicked word. @@ -6365,20 +6365,20 @@ store_word ( (void)spell_casefold(word, len, foldword, MAXWLEN); for (p = pfxlist; res == OK; ++p) { - if (!need_affix || (p != NULL && *p != NUL)) + if (!need_affix || (p != NULL && *p != '\0')) res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags, region, p == NULL ? 0 : *p); - if (p == NULL || *p == NUL) + if (p == NULL || *p == '\0') break; } ++spin->si_foldwcount; if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP))) { for (p = pfxlist; res == OK; ++p) { - if (!need_affix || (p != NULL && *p != NUL)) + if (!need_affix || (p != NULL && *p != '\0')) res = tree_add_word(spin, word, spin->si_keeproot, flags, region, p == NULL ? 0 : *p); - if (p == NULL || *p == NUL) + if (p == NULL || *p == '\0') break; } ++spin->si_keepwcount; @@ -6415,7 +6415,7 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int if (np->wn_child != NULL) ++np->wn_child->wn_refs; // child gets extra ref np->wn_byte = copyp->wn_byte; - if (np->wn_byte == NUL) { + if (np->wn_byte == '\0') { np->wn_flags = copyp->wn_flags; np->wn_region = copyp->wn_region; np->wn_affixID = copyp->wn_affixID; @@ -6439,7 +6439,7 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int // done on flags and then on affixID. while (node != NULL && (node->wn_byte < word[i] - || (node->wn_byte == NUL + || (node->wn_byte == '\0' && (flags < 0 ? node->wn_affixID < (unsigned)affixID : (node->wn_flags < (unsigned)(flags & WN_MASK) @@ -6453,7 +6453,7 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int } if (node == NULL || node->wn_byte != word[i] - || (word[i] == NUL + || (word[i] == '\0' && (flags < 0 || spin->si_sugtree || node->wn_flags != (flags & WN_MASK) @@ -6480,7 +6480,7 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int node = np; } - if (word[i] == NUL) { + if (word[i] == '\0') { node->wn_flags = flags; node->wn_region |= region; node->wn_affixID = affixID; @@ -6572,7 +6572,7 @@ int spell_check_msm(void) if (!VIM_ISDIGIT(*p)) return FAIL; added = getdigits(&p) * 1024; - if (*p != NUL) + if (*p != '\0') return FAIL; if (start == 0 || incr == 0 || added == 0 || incr > start) @@ -6741,7 +6741,7 @@ node_compress ( node->wn_u1.hashkey[0] = len; nr = 0; for (np = node; np != NULL; np = np->wn_sibling) { - if (np->wn_byte == NUL) + if (np->wn_byte == '\0') // end node: use wn_flags, wn_region and wn_affixID n = np->wn_flags + (np->wn_region << 8) + (np->wn_affixID << 16); else @@ -6759,7 +6759,7 @@ node_compress ( node->wn_u1.hashkey[3] = n == 0 ? 1 : n; n = (nr >> 24) & 0xff; node->wn_u1.hashkey[4] = n == 0 ? 1 : n; - node->wn_u1.hashkey[5] = NUL; + node->wn_u1.hashkey[5] = '\0'; // Check for CTRL-C pressed now and then. fast_breakcheck(); @@ -6776,7 +6776,7 @@ static int node_equal(wordnode_T *n1, wordnode_T *n2) for (p1 = n1, p2 = n2; p1 != NULL && p2 != NULL; p1 = p1->wn_sibling, p2 = p2->wn_sibling) if (p1->wn_byte != p2->wn_byte - || (p1->wn_byte == NUL + || (p1->wn_byte == '\0' ? (p1->wn_flags != p2->wn_flags || p1->wn_region != p2->wn_region || p1->wn_affixID != p2->wn_affixID) @@ -7181,7 +7181,7 @@ static void clear_node(wordnode_T *node) np->wn_u1.index = 0; np->wn_u2.wnode = NULL; - if (np->wn_byte != NUL) + if (np->wn_byte != '\0') clear_node(np->wn_child); } } @@ -7448,7 +7448,7 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang) c = byts[n]; if (c == 0) { // Sound-fold the word. - tword[depth] = NUL; + tword[depth] = '\0'; spell_soundfold(slang, tword, TRUE, tsalword); // We use the "flags" field for the MSB of the wordnr, @@ -7529,10 +7529,10 @@ sug_filltable ( int prev_nr; for (p = node; p != NULL; p = p->wn_sibling) { - if (p->wn_byte == NUL) { + if (p->wn_byte == '\0') { gap->ga_len = 0; prev_nr = 0; - for (np = p; np != NULL && np->wn_byte == NUL; np = np->wn_sibling) { + for (np = p; np != NULL && np->wn_byte == '\0'; np = np->wn_sibling) { ga_grow(gap, 10); nr = (np->wn_flags << 16) + (np->wn_region & 0xffff); @@ -7547,7 +7547,7 @@ sug_filltable ( } // add the NUL byte - ((char_u *)gap->ga_data)[gap->ga_len++] = NUL; + ((char_u *)gap->ga_data)[gap->ga_len++] = '\0'; if (ml_append_buf(spin->si_spellbuf, (linenr_T)wordnr, gap->ga_data, gap->ga_len, TRUE) == FAIL) @@ -7556,7 +7556,7 @@ sug_filltable ( // Remove extra NUL entries, we no longer need them. We don't // bother freeing the nodes, the won't be reused anyway. - while (p->wn_sibling != NULL && p->wn_sibling->wn_byte == NUL) + while (p->wn_sibling != NULL && p->wn_sibling->wn_byte == '\0') p->wn_sibling = p->wn_sibling->wn_sibling; // Clear the flags on the remaining NUL node, so that compression @@ -8025,22 +8025,22 @@ spell_add_word ( fname = int_wordlist; } else { // If 'spellfile' isn't set figure out a good default value. - if (*curwin->w_s->b_p_spf == NUL) { + if (*curwin->w_s->b_p_spf == '\0') { init_spellfile(); new_spf = TRUE; } - if (*curwin->w_s->b_p_spf == NUL) { + if (*curwin->w_s->b_p_spf == '\0') { EMSG2(_(e_notset), "spellfile"); return; } fnamebuf = alloc(MAXPATHL); - for (spf = curwin->w_s->b_p_spf, i = 1; *spf != NUL; ++i) { + for (spf = curwin->w_s->b_p_spf, i = 1; *spf != '\0'; ++i) { copy_option_part(&spf, fnamebuf, MAXPATHL, ","); if (i == idx) break; - if (*spf == NUL) { + if (*spf == '\0') { EMSGN(_("E765: 'spellfile' does not have %" PRId64 " entries"), idx); vim_free(fnamebuf); return; @@ -8107,7 +8107,7 @@ spell_add_word ( // The directory doesn't exist. Try creating it and opening // the file again. - *p = NUL; + *p = '\0'; os_mkdir((char *)fname, 0755); *p = c; fd = mch_fopen((char *)fname, "a"); @@ -8152,12 +8152,12 @@ static void init_spellfile(void) int aspath = FALSE; char_u *lstart = curbuf->b_s.b_p_spl; - if (*curwin->w_s->b_p_spl != NUL && curwin->w_s->b_langp.ga_len > 0) { + if (*curwin->w_s->b_p_spl != '\0' && curwin->w_s->b_langp.ga_len > 0) { buf = alloc(MAXPATHL); // Find the end of the language name. Exclude the region. If there // is a path separator remember the start of the tail. - for (lend = curwin->w_s->b_p_spl; *lend != NUL + for (lend = curwin->w_s->b_p_spl; *lend != '\0' && vim_strchr((char_u *)",._", *lend) == NULL; ++lend) if (vim_ispathsep(*lend)) { aspath = TRUE; @@ -8167,7 +8167,7 @@ static void init_spellfile(void) // Loop over all entries in 'runtimepath'. Use the first one where we // are allowed to write. rtp = p_rtp; - while (*rtp != NUL) { + while (*rtp != '\0') { if (aspath) // Use directory of an entry with path, e.g., for // "/dir/lg.utf-8.spl" use "/dir". @@ -8295,8 +8295,8 @@ static int set_spell_chartab(char_u *fol, char_u *low, char_u *upp) clear_spell_chartab(&new_st); - while (*pf != NUL) { - if (*pl == NUL || *pu == NUL) { + while (*pf != '\0') { + if (*pl == '\0' || *pu == '\0') { EMSG(_(e_affform)); return FAIL; } @@ -8335,7 +8335,7 @@ static int set_spell_chartab(char_u *fol, char_u *low, char_u *upp) } } - if (*pl != NUL || *pu != NUL) { + if (*pl != '\0' || *pu != '\0') { EMSG(_(e_affform)); return FAIL; } @@ -8366,7 +8366,7 @@ set_spell_charflags ( new_st.st_isu[i + 128] = (flags[i] & CF_UPPER) != 0; } - if (*p != NUL) { + if (*p != '\0') { c = mb_ptr2char_adv(&p); new_st.st_fold[i + 128] = c; if (i + 128 != c && new_st.st_isu[i + 128] && c < 256) @@ -8529,7 +8529,7 @@ static int spell_casefold(char_u *str, int len, char_u *buf, int buflen) int i; if (len >= buflen) { - buf[0] = NUL; + buf[0] = '\0'; return FAIL; // result will not fit } @@ -8541,18 +8541,18 @@ static int spell_casefold(char_u *str, int len, char_u *buf, int buflen) // Fold one character at a time. for (p = str; p < str + len; ) { if (outi + MB_MAXBYTES > buflen) { - buf[outi] = NUL; + buf[outi] = '\0'; return FAIL; } c = mb_cptr2char_adv(&p); outi += mb_char2bytes(SPELL_TOFOLD(c), buf + outi); } - buf[outi] = NUL; + buf[outi] = '\0'; } else { // Be quick for non-multibyte encodings. for (i = 0; i < len; ++i) buf[i] = spelltab.st_fold[str[i]]; - buf[i] = NUL; + buf[i] = '\0'; } return OK; @@ -8578,14 +8578,14 @@ int spell_check_sps(void) sps_flags = 0; sps_limit = 9999; - for (p = p_sps; *p != NUL; ) { + for (p = p_sps; *p != '\0'; ) { copy_option_part(&p, buf, MAXPATHL, ","); f = 0; if (VIM_ISDIGIT(*buf)) { s = buf; sps_limit = getdigits(&s); - if (*s != NUL && !VIM_ISDIGIT(*s)) + if (*s != '\0' && !VIM_ISDIGIT(*s)) f = -1; } else if (STRCMP(buf, "best") == 0) f = SPS_BEST; @@ -8663,7 +8663,7 @@ void spell_suggest(int count) while (p > line && spell_iswordp_nmw(p, curwin)) mb_ptr_back(line, p); // Forward to start of word. - while (*p != NUL && !spell_iswordp_nmw(p, curwin)) + while (*p != '\0' && !spell_iswordp_nmw(p, curwin)) mb_ptr_adv(p); if (!spell_iswordp_nmw(p, curwin)) { // No word found. @@ -8847,7 +8847,7 @@ static int check_need_cap(linenr_T lnum, colnr_T col) need_cap = TRUE; else { line = ml_get(lnum - 1); - if (*skipwhite(line) == NUL) + if (*skipwhite(line) == '\0') need_cap = TRUE; else { // Append a space in place of the line break. @@ -9008,7 +9008,7 @@ spell_find_suggest ( memset(su, 0, sizeof(suginfo_T)); ga_init(&su->su_ga, (int)sizeof(suggest_T), 10); ga_init(&su->su_sga, (int)sizeof(suggest_T), 10); - if (*badptr == NUL) + if (*badptr == '\0') return; hash_init(&su->su_banned); @@ -9069,7 +9069,7 @@ spell_find_suggest ( return; // Loop over the items in 'spellsuggest'. - for (p = sps_copy; *p != NUL; ) { + for (p = sps_copy; *p != '\0'; ) { copy_option_part(&p, buf, MAXPATHL, ","); if (STRNCMP(buf, "expr:", 5) == 0) { @@ -9152,12 +9152,12 @@ static void spell_suggest_file(suginfo_T *su, char_u *fname) p = vim_strchr(line, '/'); if (p == NULL) continue; // No Tab found, just skip the line. - *p++ = NUL; + *p++ = '\0'; if (STRICMP(su->su_badword, line) == 0) { // Match! Isolate the good word, until CR or NL. for (len = 0; p[len] >= ' '; ++len) ; - p[len] = NUL; + p[len] = '\0'; // If the suggestion doesn't have specific case duplicate the case // of the bad word. @@ -9349,7 +9349,7 @@ someerror: } ga_grow(&ga, 1); ((char_u *)ga.ga_data)[ga.ga_len++] = c; - if (c == NUL) + if (c == '\0') break; } if (ml_append_buf(slang->sl_sugbuf, (linenr_T)wordnr, @@ -9480,7 +9480,7 @@ static void allcap_copy(char_u *word, char_u *wcopy) int c; d = wcopy; - for (s = word; *s != NUL; ) { + for (s = word; *s != '\0'; ) { if (has_mbyte) c = mb_cptr2char_adv(&s); else @@ -9506,7 +9506,7 @@ static void allcap_copy(char_u *word, char_u *wcopy) *d++ = c; } } - *d = NUL; + *d = '\0'; } // Try finding suggestions by recognizing specific situations. @@ -9525,7 +9525,7 @@ static void suggest_try_special(suginfo_T *su) // Include badflags: if the badword is onecap or allcap // use that for the goodword too: "The the" -> "The". c = su->su_fbadword[len]; - su->su_fbadword[len] = NUL; + su->su_fbadword[len] = '\0'; make_case_word(su->su_fbadword, word, su->su_badflags); su->su_fbadword[len] = c; @@ -9724,7 +9724,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou // Move the prefix to preword[] with the right case // and make find_keepcap_word() works. - tword[sp->ts_twordlen] = NUL; + tword[sp->ts_twordlen] = '\0'; make_case_word(tword + sp->ts_splitoff, preword + sp->ts_prewordlen, flags); sp->ts_prewordlen = (char_u)STRLEN(preword); @@ -9749,11 +9749,11 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou if (flags & WF_NOSUGGEST) break; - fword_ends = (fword[sp->ts_fidx] == NUL + fword_ends = (fword[sp->ts_fidx] == '\0' || (soundfold ? vim_iswhite(fword[sp->ts_fidx]) : !spell_iswordp(fword + sp->ts_fidx, curwin))); - tword[sp->ts_twordlen] = NUL; + tword[sp->ts_twordlen] = '\0'; if (sp->ts_prefixdepth <= PFD_NOTSPECIAL && (sp->ts_flags & TSF_PREFIXOK) == 0) { @@ -9804,7 +9804,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou && STRNCMP(fword + sp->ts_splitfidx, tword + sp->ts_splitoff, sp->ts_fidx - sp->ts_splitfidx) == 0) { - preword[sp->ts_prewordlen] = NUL; + preword[sp->ts_prewordlen] = '\0'; newscore = score_wordcount_adj(slang, sp->ts_score, preword + sp->ts_prewordlen, sp->ts_prewordlen > 0); @@ -9834,7 +9834,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou break; compflags[sp->ts_complen] = ((unsigned)flags >> 24); - compflags[sp->ts_complen + 1] = NUL; + compflags[sp->ts_complen + 1] = '\0'; vim_strncpy(preword + sp->ts_prewordlen, tword + sp->ts_splitoff, sp->ts_twordlen - sp->ts_splitoff); @@ -9846,7 +9846,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou if (compound_ok) { p = preword; - while (*skiptowhite(p) != NUL) + while (*skiptowhite(p) != '\0') p = skipwhite(skiptowhite(p)); if (fword_ends && !can_compound(slang, p, compflags + sp->ts_compsplit)) @@ -10027,7 +10027,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou compflags, ((unsigned)flags >> 24)))) { try_compound = TRUE; compflags[sp->ts_complen] = ((unsigned)flags >> 24); - compflags[sp->ts_complen + 1] = NUL; + compflags[sp->ts_complen + 1] = '\0'; } // For NOBREAK we never try splitting, it won't make any word @@ -10044,7 +10044,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou try_compound = FALSE; sp->ts_flags |= TSF_DIDSPLIT; --sp->ts_curi; // do the same NUL again - compflags[sp->ts_complen] = NUL; + compflags[sp->ts_complen] = '\0'; } else sp->ts_flags &= ~TSF_DIDSPLIT; @@ -10058,7 +10058,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou && (flags & WF_NEEDCOMP)) break; p = preword; - while (*skiptowhite(p) != NUL) + while (*skiptowhite(p) != '\0') p = skipwhite(skiptowhite(p)); if (sp->ts_complen > sp->ts_compsplit && !can_compound(slang, p, @@ -10108,7 +10108,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou + sp->ts_fidx, curwin)) || fword_ends) - && fword[sp->ts_fidx] != NUL + && fword[sp->ts_fidx] != '\0' && goodword_ends) { int l; @@ -10121,7 +10121,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou memmove(preword + sp->ts_prewordlen, fword + sp->ts_fidx, l); sp->ts_prewordlen += l; - preword[sp->ts_prewordlen] = NUL; + preword[sp->ts_prewordlen] = '\0'; } else sp->ts_score -= SCORE_SPLIT - SCORE_SUBST; sp->ts_fidx += l; @@ -10175,7 +10175,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou case STATE_ENDNUL: // Past the NUL bytes in the node. su->su_badflags = sp->ts_save_badflags; - if (fword[sp->ts_fidx] == NUL + if (fword[sp->ts_fidx] == '\0' && sp->ts_tcharlen == 0 ) { // The badword ends, can't use STATE_PLAIN. @@ -10339,7 +10339,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou newscore = 2 * SCORE_DEL / 3; else newscore = SCORE_DEL; - if (fword[sp->ts_fidx] != NUL + if (fword[sp->ts_fidx] != '\0' && TRY_DEEPER(su, stack, depth, newscore)) { go_deeper(stack, depth, newscore); #ifdef DEBUG_TRIEWALK @@ -10390,7 +10390,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou sp->ts_state = STATE_SWAP; break; } - if (byts[n + sp->ts_curi] != NUL) { + if (byts[n + sp->ts_curi] != '\0') { // Found a byte to insert. sp->ts_state = STATE_INS; break; @@ -10465,7 +10465,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou // STATE_UNSWAP. p = fword + sp->ts_fidx; c = *p; - if (c == NUL) { + if (c == '\0') { // End of word, can't swap or replace. sp->ts_state = STATE_FINAL; break; @@ -10481,15 +10481,15 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou if (has_mbyte) { n = mb_cptr2len(p); c = mb_ptr2char(p); - if (p[n] == NUL) - c2 = NUL; + if (p[n] == '\0') + c2 = '\0'; else if (!soundfold && !spell_iswordp(p + n, curwin)) c2 = c; // don't swap non-word char else c2 = mb_ptr2char(p + n); } else { - if (p[1] == NUL) - c2 = NUL; + if (p[1] == '\0') + c2 = '\0'; else if (!soundfold && !spell_iswordp(p + 1, curwin)) c2 = c; // don't swap non-word char else @@ -10497,7 +10497,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou } // When the second character is NUL we can't swap. - if (c2 == NUL) { + if (c2 == '\0') { sp->ts_state = STATE_REP_INI; break; } @@ -10508,7 +10508,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou sp->ts_state = STATE_SWAP3; break; } - if (c2 != NUL && TRY_DEEPER(su, stack, depth, SCORE_SWAP)) { + if (c2 != '\0' && TRY_DEEPER(su, stack, depth, SCORE_SWAP)) { go_deeper(stack, depth, SCORE_SWAP); #ifdef DEBUG_TRIEWALK sprintf(changename[depth], "%.*s-%s: swap %c and %c", @@ -10575,7 +10575,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou // Also skip when c3 is NUL. // Also get here when the third character is not a word character. // Second character may any char: "a.b" -> "b.a" - if (c == c3 || c3 == NUL) { + if (c == c3 || c3 == '\0') { sp->ts_state = STATE_REP_INI; break; } @@ -10896,7 +10896,7 @@ static void find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword) if (byts == NULL) { // array is empty: "cannot happen" - *kword = NUL; + *kword = '\0'; return; } @@ -10913,11 +10913,11 @@ static void find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword) uwordidx[0] = 0; kwordlen[0] = 0; while (depth >= 0) { - if (fword[fwordidx[depth]] == NUL) { + if (fword[fwordidx[depth]] == '\0') { // We are at the end of "fword". If the tree allows a word to end // here we have found a match. if (byts[arridx[depth] + 1] == 0) { - kword[kwordlen[depth]] = NUL; + kword[kwordlen[depth]] = '\0'; return; } @@ -10992,7 +10992,7 @@ static void find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword) } // Didn't find it: "cannot happen". - *kword = NUL; + *kword = '\0'; } // Compute the sound-a-like score for suggestions in su->su_ga and add them to @@ -11170,8 +11170,8 @@ stp_sal_score ( // removing the space. Don't do it when the good word also contains a // space. if (vim_iswhite(su->su_badptr[su->su_badlen]) - && *skiptowhite(stp->st_word) == NUL) - for (p = fword; *(p = skiptowhite(p)) != NUL; ) + && *skiptowhite(stp->st_word) == '\0') + for (p = fword; *(p = skiptowhite(p)) != '\0'; ) STRMOVE(p, p + 1); spell_soundfold(slang, fword, TRUE, badsound2); @@ -11337,7 +11337,7 @@ add_sound_suggest ( // Go over the list of good words that produce this soundfold word nrline = ml_get_buf(slang->sl_sugbuf, (linenr_T)(sfwordnr + 1), FALSE); orgnr = 0; - while (*nrline != NUL) { + while (*nrline != '\0') { // The wordnr was stored in a minimal nr of bytes as an offset to the // previous wordnr. orgnr += bytes2offset(&nrline); @@ -11350,14 +11350,14 @@ add_sound_suggest ( wordcount = 0; for (wlen = 0; wlen < MAXWLEN - 3; ++wlen) { i = 1; - if (wordcount == orgnr && byts[n + 1] == NUL) + if (wordcount == orgnr && byts[n + 1] == '\0') break; // found end of word - if (byts[n + 1] == NUL) + if (byts[n + 1] == '\0') ++wordcount; // skip over the NUL bytes - for (; byts[n + i] == NUL; ++i) + for (; byts[n + i] == '\0'; ++i) if (i > byts[n]) { // safety check STRCPY(theword + wlen, "BAD"); wlen += 3; @@ -11376,10 +11376,10 @@ add_sound_suggest ( n = idxs[n + i]; } badword: - theword[wlen] = NUL; + theword[wlen] = '\0'; // Go over the possible flags and regions. - for (; i <= byts[n] && byts[n + i] == NUL; ++i) { + for (; i <= byts[n] && byts[n + i] == '\0'; ++i) { char_u cword[MAXWLEN]; char_u *p; int flags = (int)idxs[n + i]; @@ -11481,12 +11481,12 @@ static int soundfold_find(slang_T *slang, char_u *word) // If the first possible byte is a zero the word could end here. // If the word ends we found the word. If not skip the NUL bytes. c = ptr[wlen]; - if (byts[arridx] == NUL) { - if (c == NUL) + if (byts[arridx] == '\0') { + if (c == '\0') break; // Skip over the zeros, there can be several. - while (len > 0 && byts[arridx] == NUL) { + while (len > 0 && byts[arridx] == '\0') { ++arridx; --len; } @@ -11496,7 +11496,7 @@ static int soundfold_find(slang_T *slang, char_u *word) } // If the word ends we didn't find it. - if (c == NUL) + if (c == '\0') return -1; // Perform a binary search in the list of accepted bytes. @@ -11548,7 +11548,7 @@ static void set_map_str(slang_T *lp, char_u *map) int c; int i; - if (*map == NUL) { + if (*map == '\0') { lp->sl_has_map = FALSE; return; } @@ -11562,7 +11562,7 @@ static void set_map_str(slang_T *lp, char_u *map) // The similar characters are stored separated with slashes: // "aaa/bbb/ccc/". Fill sl_map_array[c] with the character before c and // before the same slash. For characters above 255 sl_map_hash is used. - for (p = map; *p != NUL; ) { + for (p = map; *p != '\0'; ) { c = mb_cptr2char_adv(&p); if (c == '/') headc = 0; @@ -11582,9 +11582,9 @@ static void set_map_str(slang_T *lp, char_u *map) b = alloc((unsigned)(cl + headcl + 2)); mb_char2bytes(c, b); - b[cl] = NUL; + b[cl] = '\0'; mb_char2bytes(headc, b + cl + 1); - b[cl + 1 + headcl] = NUL; + b[cl + 1 + headcl] = '\0'; hash = hash_hash(b); hi = hash_lookup(&lp->sl_map_hash, b, hash); if (HASHITEM_EMPTY(hi)) @@ -11896,7 +11896,7 @@ char_u *eval_soundfold(char_u *word) char_u sound[MAXWLEN]; int lpi; - if (curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) + if (curwin->w_p_spell && *curwin->w_s->b_p_spl != '\0') // Use the sound-folding of the first language that supports it. for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi) { lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi); @@ -11965,7 +11965,7 @@ static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res) // The sl_sal_first[] table contains the translation for chars up to // 255, sl_sal the rest. - for (s = inword; *s != NUL; ) { + for (s = inword; *s != '\0'; ) { c = mb_cptr2char_adv(&s); if (enc_utf8 ? utf_class(c) == 0 : vim_iswhite(c)) c = ' '; @@ -11974,11 +11974,11 @@ static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res) else { ip = ((int **)slang->sl_sal.ga_data)[c & 0xff]; if (ip == NULL) // empty list, can't match - c = NUL; + c = '\0'; else for (;; ) { // find "c" in the list if (*ip == 0) { // not found - c = NUL; + c = '\0'; break; } if (*ip == c) { // match! @@ -11989,7 +11989,7 @@ static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res) } } - if (c != NUL && c != prevc) { + if (c != '\0' && c != prevc) { ri += mb_char2bytes(c, res + ri); if (ri + MB_MAXBYTES > MAXWLEN) break; @@ -11998,17 +11998,17 @@ static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res) } } else { // The sl_sal_first[] table contains the translation. - for (s = inword; (c = *s) != NUL; ++s) { + for (s = inword; (c = *s) != '\0'; ++s) { if (vim_iswhite(c)) c = ' '; else c = slang->sl_sal_first[c]; - if (c != NUL && (ri == 0 || res[ri - 1] != c)) + if (c != '\0' && (ri == 0 || res[ri - 1] != c)) res[ri++] = c; } } - res[ri] = NUL; + res[ri] = '\0'; } static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) @@ -12033,7 +12033,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) // But keep white space. We need a copy, the word may be changed here. if (slang->sl_rem_accents) { t = word; - while (*s != NUL) { + while (*s != '\0') { if (vim_iswhite(*s)) { *t++ = ' '; s = skipwhite(s); @@ -12043,7 +12043,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) ++s; } } - *t = NUL; + *t = '\0'; } else vim_strncpy(word, s, MAXWLEN - 1); @@ -12052,7 +12052,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) // This comes from Aspell phonet.cpp. Converted from C++ to C. // Changed to keep spaces. i = reslen = z = 0; - while ((c = word[i]) != NUL) { + while ((c = word[i]) != '\0') { // Start with the first rule that has the character in the word. n = slang->sl_sal_first[c]; z0 = 0; @@ -12077,9 +12077,9 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) if ((pf = smp[n].sm_oneof) != NULL) { // Check for match with one of the chars in "sm_oneof". - while (*pf != NUL && *pf != word[i + k]) + while (*pf != '\0' && *pf != word[i + k]) ++pf; - if (*pf == NUL) + if (*pf == '\0') continue; ++k; } @@ -12102,7 +12102,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) if (*s == '^' && *(s + 1) == '^') s++; - if (*s == NUL + if (*s == '\0' || (*s == '^' && (i == 0 || !(word[i - 1] == ' ' || spell_iswordp(word + i - 1, curwin))) @@ -12117,7 +12117,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) n0 = slang->sl_sal_first[c0]; if (slang->sl_followup && k > 1 && n0 >= 0 - && p0 != '-' && word[i + k] != NUL) { + && p0 != '-' && word[i + k] != '\0') { // test follow-up rule for "word[i + k]" for (; (s = smp[n0].sm_lead)[0] == c0; ++n0) { // Quickly skip entries that don't match the word. @@ -12139,9 +12139,9 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) if ((pf = smp[n0].sm_oneof) != NULL) { // Check for match with one of the chars in // "sm_oneof". - while (*pf != NUL && *pf != word[i + k0]) + while (*pf != '\0' && *pf != word[i + k0]) ++pf; - if (*pf == NUL) + if (*pf == '\0') continue; ++k0; } @@ -12160,7 +12160,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) s++; } - if (*s == NUL + if (*s == '\0' // *s == '^' cuts || (*s == '$' && !spell_iswordp(word + i + k0, @@ -12189,13 +12189,13 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) p0 = (vim_strchr(pf, '<') != NULL) ? 1 : 0; if (p0 == 1 && z == 0) { // rule with '<' is used - if (reslen > 0 && *s != NUL && (res[reslen - 1] == c + if (reslen > 0 && *s != '\0' && (res[reslen - 1] == c || res[reslen - 1] == *s)) reslen--; z0 = 1; z = 1; k0 = 0; - while (*s != NUL && word[i + k0] != NUL) { + while (*s != '\0' && word[i + k0] != '\0') { word[i + k0] = *s; k0++; s++; @@ -12209,7 +12209,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) // no '<' rule used i += k - 1; z = 0; - while (*s != NUL && s[1] != NUL && reslen < MAXWLEN) { + while (*s != '\0' && s[1] != '\0' && reslen < MAXWLEN) { if (reslen == 0 || res[reslen - 1] != *s) res[reslen++] = *s; s++; @@ -12217,7 +12217,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) // new "actual letter" c = *s; if (strstr((char *)pf, "^^") != NULL) { - if (c != NUL) + if (c != '\0') res[reslen++] = c; STRMOVE(word, word + i + 1); i = 0; @@ -12233,7 +12233,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) } if (z0 == 0) { - if (k && !p0 && reslen < MAXWLEN && c != NUL + if (k && !p0 && reslen < MAXWLEN && c != '\0' && (!slang->sl_collapse || reslen == 0 || res[reslen - 1] != c)) // condense only double letters @@ -12245,7 +12245,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) } } - res[reslen] = NUL; + res[reslen] = '\0'; } // Turn "inword" into its sound-a-like equivalent in "res[MAXWLEN]". @@ -12278,7 +12278,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) // Remove accents, if wanted. We actually remove all non-word characters. // But keep white space. wordlen = 0; - for (s = inword; *s != NUL; ) { + for (s = inword; *s != '\0'; ) { t = s; c = mb_cptr2char_adv(&s); if (slang->sl_rem_accents) { @@ -12295,13 +12295,13 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) } word[wordlen++] = c; } - word[wordlen] = NUL; + word[wordlen] = '\0'; // This algorithm comes from Aspell phonet.cpp. // Converted from C++ to C. Added support for multi-byte chars. // Changed to keep spaces. i = reslen = z = 0; - while ((c = word[i]) != NUL) { + while ((c = word[i]) != '\0') { // Start with the first rule that has the character in the word. n = slang->sl_sal_first[c & 0xff]; z0 = 0; @@ -12311,7 +12311,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) // If c is 0x300 need extra check for the end of the array, as // (c & 0xff) is NUL. for (; ((ws = smp[n].sm_lead_w)[0] & 0xff) == (c & 0xff) - && ws[0] != NUL; ++n) { + && ws[0] != '\0'; ++n) { // Quickly skip entries that don't match the word. Most // entries are less then three chars, optimize for that. if (c != ws[0]) @@ -12331,9 +12331,9 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) if ((pf = smp[n].sm_oneof_w) != NULL) { // Check for match with one of the chars in "sm_oneof". - while (*pf != NUL && *pf != word[i + k]) + while (*pf != '\0' && *pf != word[i + k]) ++pf; - if (*pf == NUL) + if (*pf == '\0') continue; ++k; } @@ -12356,7 +12356,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) if (*s == '^' && *(s + 1) == '^') s++; - if (*s == NUL + if (*s == '\0' || (*s == '^' && (i == 0 || !(word[i - 1] == ' ' || spell_iswordp_w(word + i - 1, curwin))) @@ -12371,7 +12371,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) n0 = slang->sl_sal_first[c0 & 0xff]; if (slang->sl_followup && k > 1 && n0 >= 0 - && p0 != '-' && word[i + k] != NUL) { + && p0 != '-' && word[i + k] != '\0') { // Test follow-up rule for "word[i + k]"; loop over // all entries with the same index byte. for (; ((ws = smp[n0].sm_lead_w)[0] & 0xff) @@ -12397,9 +12397,9 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) if ((pf = smp[n0].sm_oneof_w) != NULL) { // Check for match with one of the chars in // "sm_oneof". - while (*pf != NUL && *pf != word[i + k0]) + while (*pf != '\0' && *pf != word[i + k0]) ++pf; - if (*pf == NUL) + if (*pf == '\0') continue; ++k0; } @@ -12418,7 +12418,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) s++; } - if (*s == NUL + if (*s == '\0' // *s == '^' cuts || (*s == '$' && !spell_iswordp_w(word + i + k0, @@ -12446,7 +12446,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) p0 = (vim_strchr(s, '<') != NULL) ? 1 : 0; if (p0 == 1 && z == 0) { // rule with '<' is used - if (reslen > 0 && ws != NULL && *ws != NUL + if (reslen > 0 && ws != NULL && *ws != '\0' && (wres[reslen - 1] == c || wres[reslen - 1] == *ws)) reslen--; @@ -12454,7 +12454,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) z = 1; k0 = 0; if (ws != NULL) - while (*ws != NUL && word[i + k0] != NUL) { + while (*ws != '\0' && word[i + k0] != '\0') { word[i + k0] = *ws; k0++; ws++; @@ -12470,7 +12470,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) i += k - 1; z = 0; if (ws != NULL) - while (*ws != NUL && ws[1] != NUL + while (*ws != '\0' && ws[1] != '\0' && reslen < MAXWLEN) { if (reslen == 0 || wres[reslen - 1] != *ws) wres[reslen++] = *ws; @@ -12478,11 +12478,11 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) } // new "actual letter" if (ws == NULL) - c = NUL; + c = '\0'; else c = *ws; if (strstr((char *)s, "^^") != NULL) { - if (c != NUL) + if (c != '\0') wres[reslen++] = c; memmove(word, word + i + 1, sizeof(int) * (wordlen - (i + 1) + 1)); @@ -12499,7 +12499,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) } if (z0 == 0) { - if (k && !p0 && reslen < MAXWLEN && c != NUL + if (k && !p0 && reslen < MAXWLEN && c != '\0' && (!slang->sl_collapse || reslen == 0 || wres[reslen - 1] != c)) // condense only double letters @@ -12518,7 +12518,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) if (l + MB_MAXBYTES > MAXWLEN) break; } - res[l] = NUL; + res[l] = '\0'; } // Compute a score for two sound-a-like words. @@ -12543,17 +12543,17 @@ soundalike_score ( // Adding/inserting "*" at the start (word starts with vowel) shouldn't be // counted so much, vowels halfway the word aren't counted at all. if ((*badsound == '*' || *goodsound == '*') && *badsound != *goodsound) { - if ((badsound[0] == NUL && goodsound[1] == NUL) - || (goodsound[0] == NUL && badsound[1] == NUL)) + if ((badsound[0] == '\0' && goodsound[1] == '\0') + || (goodsound[0] == '\0' && badsound[1] == '\0')) // changing word with vowel to word without a sound return SCORE_DEL; - if (badsound[0] == NUL || goodsound[0] == NUL) + if (badsound[0] == '\0' || goodsound[0] == '\0') // more than two changes return SCORE_MAXMAX; if (badsound[1] == goodsound[1] - || (badsound[1] != NUL - && goodsound[1] != NUL + || (badsound[1] != '\0' + && goodsound[1] != '\0' && badsound[2] == goodsound[2])) { // handle like a substitute } else { @@ -12583,7 +12583,7 @@ soundalike_score ( } // Skip over the identical part. - while (*pl == *ps && *pl != NUL) { + while (*pl == *ps && *pl != '\0') { ++pl; ++ps; } @@ -12612,7 +12612,7 @@ soundalike_score ( pl2 = pl + 1; ps2 = ps; while (*pl2 == *ps2) { - if (*pl2 == NUL) // reached the end + if (*pl2 == '\0') // reached the end return score + SCORE_DEL; ++pl2; ++ps2; @@ -12658,7 +12658,7 @@ soundalike_score ( // Lengths are equal, thus changes must result in same length: An // insert is only possible in combination with a delete. // 1: check if for identical strings - if (*pl == NUL) + if (*pl == '\0') return score; // 2: swap @@ -12666,7 +12666,7 @@ soundalike_score ( pl2 = pl + 2; // swap, skip two chars ps2 = ps + 2; while (*pl2 == *ps2) { - if (*pl2 == NUL) // reached the end + if (*pl2 == '\0') // reached the end return score + SCORE_SWAP; ++pl2; ++ps2; @@ -12685,7 +12685,7 @@ soundalike_score ( pl2 = pl + 1; ps2 = ps + 1; while (*pl2 == *ps2) { - if (*pl2 == NUL) // reached the end + if (*pl2 == '\0') // reached the end return score + SCORE_SUBST; ++pl2; ++ps2; @@ -12749,10 +12749,10 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) if (has_mbyte) { // Get the characters from the multi-byte strings and put them in an // int array for easy access. - for (p = badword, badlen = 0; *p != NUL; ) + for (p = badword, badlen = 0; *p != '\0'; ) wbadword[badlen++] = mb_cptr2char_adv(&p); wbadword[badlen++] = 0; - for (p = goodword, goodlen = 0; *p != NUL; ) + for (p = goodword, goodlen = 0; *p != '\0'; ) wgoodword[goodlen++] = mb_cptr2char_adv(&p); wgoodword[goodlen++] = 0; } else { @@ -12873,7 +12873,7 @@ static int spell_edit_score_limit(slang_T *slang, char_u *badword, char_u *goodw gc = goodword[gi]; if (bc != gc) // stop at a char that's different break; - if (bc == NUL) { // both words end + if (bc == '\0') { // both words end if (score < minscore) minscore = score; goto pop; // do next alternative @@ -12882,17 +12882,17 @@ static int spell_edit_score_limit(slang_T *slang, char_u *badword, char_u *goodw ++gi; } - if (gc == NUL) { // goodword ends, delete badword chars + if (gc == '\0') { // goodword ends, delete badword chars do { if ((score += SCORE_DEL) >= minscore) goto pop; // do next alternative - } while (badword[++bi] != NUL); + } while (badword[++bi] != '\0'); minscore = score; - } else if (bc == NUL) { // badword ends, insert badword chars + } else if (bc == '\0') { // badword ends, insert badword chars do { if ((score += SCORE_INS) >= minscore) goto pop; // do next alternative - } while (goodword[++gi] != NUL); + } while (goodword[++gi] != '\0'); minscore = score; } else { // both words continue // If not close to the limit, perform a change. Only try changes @@ -12909,7 +12909,7 @@ static int spell_edit_score_limit(slang_T *slang, char_u *badword, char_u *goodw bi2 = bi + 1 - round; gi2 = gi + round; while (goodword[gi2] == badword[bi2]) { - if (goodword[gi2] == NUL) { + if (goodword[gi2] == '\0') { minscore = score_off; break; } @@ -13001,11 +13001,11 @@ static int spell_edit_score_limit_w(slang_T *slang, char_u *badword, char_u *goo // Get the characters from the multi-byte strings and put them in an // int array for easy access. bi = 0; - for (p = badword; *p != NUL; ) + for (p = badword; *p != '\0'; ) wbadword[bi++] = mb_cptr2char_adv(&p); wbadword[bi++] = 0; gi = 0; - for (p = goodword; *p != NUL; ) + for (p = goodword; *p != '\0'; ) wgoodword[gi++] = mb_cptr2char_adv(&p); wgoodword[gi++] = 0; @@ -13030,7 +13030,7 @@ static int spell_edit_score_limit_w(slang_T *slang, char_u *badword, char_u *goo if (bc != gc) // stop at a char that's different break; - if (bc == NUL) { // both words end + if (bc == '\0') { // both words end if (score < minscore) minscore = score; goto pop; // do next alternative @@ -13039,17 +13039,17 @@ static int spell_edit_score_limit_w(slang_T *slang, char_u *badword, char_u *goo ++gi; } - if (gc == NUL) { // goodword ends, delete badword chars + if (gc == '\0') { // goodword ends, delete badword chars do { if ((score += SCORE_DEL) >= minscore) goto pop; // do next alternative - } while (wbadword[++bi] != NUL); + } while (wbadword[++bi] != '\0'); minscore = score; - } else if (bc == NUL) { // badword ends, insert badword chars + } else if (bc == '\0') { // badword ends, insert badword chars do { if ((score += SCORE_INS) >= minscore) goto pop; // do next alternative - } while (wgoodword[++gi] != NUL); + } while (wgoodword[++gi] != '\0'); minscore = score; } else { // both words continue // If not close to the limit, perform a change. Only try changes @@ -13066,7 +13066,7 @@ static int spell_edit_score_limit_w(slang_T *slang, char_u *badword, char_u *goo bi2 = bi + 1 - round; gi2 = gi + round; while (wgoodword[gi2] == wbadword[bi2]) { - if (wgoodword[gi2] == NUL) { + if (wgoodword[gi2] == '\0') { minscore = score_off; break; } @@ -13331,7 +13331,7 @@ spell_dump_compl ( || (flags & WF_REGION) == 0 || (((unsigned)flags >> 16) & lp->lp_region) != 0)) { - word[depth] = NUL; + word[depth] = '\0'; if (!do_region) flags &= ~WF_REGION; @@ -13551,7 +13551,7 @@ char_u *spell_to_word_end(char_u *start, win_T *win) { char_u *p = start; - while (*p != NUL && spell_iswordp(p, win)) + while (*p != '\0' && spell_iswordp(p, win)) mb_ptr_adv(p); return p; } diff --git a/src/syntax.c b/src/syntax.c index 5105a8c161..917d7214c4 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -485,7 +485,7 @@ void syntax_start(win_T *wp, linenr_T lnum) int dist; static int changedtick = 0; /* remember the last change ID */ - current_sub_char = NUL; + current_sub_char = '\0'; /* * After switching buffers, invalidate current_state. @@ -741,7 +741,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid) */ for (; start_lnum > 1; --start_lnum) { line = ml_get(start_lnum - 1); - if (*line == NUL || *(line + STRLEN(line) - 1) != '\\') + if (*line == '\0' || *(line + STRLEN(line) - 1) != '\\') break; } current_lnum = start_lnum; @@ -858,7 +858,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid) * an item that ends here, need to do that now. Be * careful not to go past the NUL. */ prev_current_col = current_col; - if (syn_getcurline()[current_col] != NUL) + if (syn_getcurline()[current_col] != '\0') ++current_col; check_state_ends(); current_col = prev_current_col; @@ -1629,7 +1629,7 @@ syn_finish_line ( * that ends here, need to do that now. Be careful not to go * past the NUL. */ prev_current_col = current_col; - if (syn_getcurline()[current_col] != NUL) + if (syn_getcurline()[current_col] != '\0') ++current_col; check_state_ends(); current_col = prev_current_col; @@ -1740,7 +1740,7 @@ syn_current_attr ( * Do try matching with an empty line (could be the start of a region). */ line = syn_getcurline(); - if (line[current_col] == NUL && current_col != 0) { + if (line[current_col] == '\0' && current_col != 0) { /* * If we found a match after the last column, use it. */ @@ -1754,7 +1754,7 @@ syn_current_attr ( } /* if the current or next character is NUL, we will finish the line now */ - if (line[current_col] == NUL || line[current_col + 1] == NUL) { + if (line[current_col] == '\0' || line[current_col + 1] == '\0') { current_finished = TRUE; current_state_stored = FALSE; } @@ -2084,7 +2084,7 @@ syn_current_attr ( if (((current_next_flags & HL_SKIPWHITE) && vim_iswhite(line[current_col])) || ((current_next_flags & HL_SKIPEMPTY) - && *line == NUL)) + && *line == '\0')) break; } @@ -2185,7 +2185,7 @@ syn_current_attr ( if (!syncing && !keep_state) { check_state_ends(); if (current_state.ga_len > 0 - && syn_getcurline()[current_col] != NUL) { + && syn_getcurline()[current_col] != '\0') { ++current_col; check_state_ends(); --current_col; @@ -2200,7 +2200,7 @@ syn_current_attr ( /* nextgroup ends at end of line, unless "skipnl" or "skipempty" present */ if (current_next_list != NULL - && syn_getcurline()[current_col + 1] == NUL + && syn_getcurline()[current_col + 1] == '\0' && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))) current_next_list = NULL; @@ -2364,7 +2364,7 @@ static void check_state_ends(void) current_next_list = cur_si->si_next_list; current_next_flags = cur_si->si_flags; if (!(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)) - && syn_getcurline()[current_col] == NUL) + && syn_getcurline()[current_col] == '\0') current_next_list = NULL; /* When the ended item has "extend", another item with @@ -2401,7 +2401,7 @@ static void check_state_ends(void) check_keepend(); if ((current_next_flags & HL_HAS_EOL) && keepend_level < 0 - && syn_getcurline()[current_col] == NUL) + && syn_getcurline()[current_col] == '\0') break; } } @@ -2744,12 +2744,12 @@ find_endpos ( else /* Be careful not to jump over the NUL at the end-of-line */ for (matchcol = regmatch.endpos[0].col; - line[matchcol] != NUL && matchcol < pos.col; + line[matchcol] != '\0' && matchcol < pos.col; ++matchcol) ; /* if the skip pattern includes end-of-line, break here */ - if (line[matchcol] == NUL) + if (line[matchcol] == '\0') break; continue; /* start with first end pattern again */ @@ -2873,7 +2873,7 @@ syn_add_end_off ( base = ml_get_buf(syn_buf, result->lnum, FALSE); p = base + col; if (off > 0) { - while (off-- > 0 && *p != NUL) + while (off-- > 0 && *p != '\0') mb_ptr_adv(p); } else if (off < 0) { while (off++ < 0 && base < p) @@ -2920,7 +2920,7 @@ syn_add_start_off ( base = ml_get_buf(syn_buf, result->lnum, FALSE); p = base + col; if (off > 0) { - while (off-- && *p != NUL) + while (off-- && *p != '\0') mb_ptr_adv(p); } else if (off < 0) { while (off++ && base < p) @@ -3715,7 +3715,7 @@ static void put_pattern(char *s, int c, synpat_T *spp, int attr) /* output the pattern, in between a char that is not in the pattern */ for (i = 0; vim_strchr(spp->sp_pattern, sepchars[i]) != NULL; ) - if (sepchars[++i] == NUL) { + if (sepchars[++i] == '\0') { i = 0; /* no good char found, just use the first one */ break; } @@ -3978,7 +3978,7 @@ get_group_name ( * Check if there are enough arguments. The first argument may be a * pattern, where '|' is allowed, so only check for NUL. */ - if (ends_excmd(*arg) || *rest == NUL) + if (ends_excmd(*arg) || *rest == '\0') return NULL; return rest; } @@ -4046,10 +4046,10 @@ get_syn_options ( for (fidx = sizeof(flagtab) / sizeof(struct flag); --fidx >= 0; ) { p = flagtab[fidx].name; - for (i = 0, len = 0; p[i] != NUL; i += 2, ++len) + for (i = 0, len = 0; p[i] != '\0'; i += 2, ++len) if (arg[len] != p[i] && arg[len] != p[i + 1]) break; - if (p[i] == NUL && (vim_iswhite(arg[len]) + if (p[i] == '\0' && (vim_iswhite(arg[len]) || (flagtab[fidx].argtype > 0 ? arg[len] == '=' : ends_excmd(arg[len])))) { @@ -4242,7 +4242,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) char_u *kw; syn_opt_arg_T syn_opt_arg; int cnt; - int conceal_char = NUL; + int conceal_char = '\0'; rest = get_group_name(arg, &group_name_end); @@ -4270,12 +4270,12 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) if (rest == NULL || ends_excmd(*rest)) break; /* Copy the keyword, removing backslashes, and add a NUL. */ - while (*rest != NUL && !vim_iswhite(*rest)) { - if (*rest == '\\' && rest[1] != NUL) + while (*rest != '\0' && !vim_iswhite(*rest)) { + if (*rest == '\\' && rest[1] != '\0') ++rest; *p++ = *rest++; } - *p++ = NUL; + *p++ = '\0'; ++cnt; } @@ -4289,13 +4289,13 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) for (kw = keyword_copy; --cnt >= 0; kw += STRLEN(kw) + 1) { for (p = vim_strchr(kw, '[');; ) { if (p != NULL) - *p = NUL; + *p = '\0'; add_keyword(kw, syn_id, syn_opt_arg.flags, syn_opt_arg.cont_in_list, syn_opt_arg.next_list, conceal_char); if (p == NULL) break; - if (p[1] == NUL) { + if (p[1] == '\0') { EMSG2(_("E789: Missing ']': %s"), kw); kw = p + 2; /* skip over the NUL */ break; @@ -4350,7 +4350,7 @@ syn_cmd_match ( int idx; syn_opt_arg_T syn_opt_arg; int sync_idx = 0; - int conceal_char = NUL; + int conceal_char = '\0'; /* Isolate the group name, check for validity */ rest = get_group_name(arg, &group_name_end); @@ -4469,7 +4469,7 @@ syn_cmd_region ( int success = FALSE; int idx; syn_opt_arg_T syn_opt_arg; - int conceal_char = NUL; + int conceal_char = '\0'; /* Isolate the group name, check for validity */ rest = get_group_name(arg, &group_name_end); @@ -4528,7 +4528,7 @@ syn_cmd_region ( break; } rest = skipwhite(rest + 1); - if (*rest == NUL) { + if (*rest == '\0') { not_enough = TRUE; break; } @@ -4980,7 +4980,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) char_u *cpo_save; /* need at least three chars */ - if (arg == NULL || arg[1] == NUL || arg[2] == NUL) + if (arg == NULL || arg[1] == '\0' || arg[2] == '\0') return NULL; end = skip_regexp(arg + 1, *arg, TRUE, NULL); @@ -5619,11 +5619,11 @@ void set_context_in_syntax_cmd(expand_T *xp, char_u *arg) include_default = 0; /* (part of) subcommand already typed */ - if (*arg != NUL) { + if (*arg != '\0') { p = skiptowhite(arg); - if (*p != NUL) { /* past first word */ + if (*p != '\0') { /* past first word */ xp->xp_pattern = skipwhite(p); - if (*skiptowhite(xp->xp_pattern) != NUL) + if (*skiptowhite(xp->xp_pattern) != '\0') xp->xp_context = EXPAND_NOTHING; else if (STRNICMP(arg, "case", p - arg) == 0) expand_what = EXP_CASE; @@ -6448,7 +6448,7 @@ do_highlight ( || STRCMP(key, "GUI") == 0) { attr = 0; off = 0; - while (arg[off] != NUL) { + while (arg[off] != '\0') { for (i = sizeof(hl_attr_table) / sizeof(int); --i >= 0; ) { len = (int)STRLEN(hl_name_table[i]); if (STRNICMP(arg + off, hl_name_table[i], len) == 0) { @@ -6609,11 +6609,11 @@ do_highlight ( * probably an xterm-like terminal. Use the changed * order for colors. */ - if (*T_CAF != NUL) + if (*T_CAF != '\0') p = T_CAF; else p = T_CSF; - if (*p != NUL && *(p + STRLEN(p) - 1) == 'm') + if (*p != '\0' && *(p + STRLEN(p) - 1) == 'm') switch (t_colors) { case 16: color = color_numbers_8[i]; @@ -6712,7 +6712,7 @@ do_highlight ( if (STRNCMP(arg, "t_", 2) == 0) { off = 0; buf[0] = 0; - while (arg[off] != NUL) { + while (arg[off] != '\0') { /* Isolate one termcap name */ for (len = 0; arg[off + len] && arg[off + len] != ','; ++len) @@ -6752,7 +6752,7 @@ do_highlight ( else /* copy as normal char */ buf[off++] = *p++; } - buf[off] = NUL; + buf[off] = '\0'; } if (error) break; @@ -7168,10 +7168,10 @@ static int highlight_list_arg(int id, int didh, int type, int iarg, char_u *sarg else if (type == LIST_STRING) ts = sarg; else { /* type == LIST_ATTR */ - buf[0] = NUL; + buf[0] = '\0'; for (i = 0; hl_attr_table[i] != 0; ++i) { if (iarg & hl_attr_table[i]) { - if (buf[0] != NUL) + if (buf[0] != '\0') vim_strcat(buf, (char_u *)",", 100); vim_strcat(buf, (char_u *)hl_name_table[i], 100); iarg &= ~hl_attr_table[i]; /* don't want "inverse" */ @@ -7183,7 +7183,7 @@ static int highlight_list_arg(int id, int didh, int type, int iarg, char_u *sarg (int)(vim_strsize(ts) + STRLEN(name) + 1), id); didh = TRUE; if (!got_int) { - if (*name != NUL) { + if (*name != '\0') { MSG_PUTS_ATTR(name, hl_attr(HLF_D)); MSG_PUTS_ATTR("=", hl_attr(HLF_D)); } @@ -7475,7 +7475,7 @@ static int syn_add_group(char_u *name) char_u *p; /* Check that the name is ASCII letters, digits and underscore. */ - for (p = name; *p != NUL; ++p) { + for (p = name; *p != '\0'; ++p) { if (!vim_isprintc(*p)) { EMSG(_("E669: Unprintable character in group name")); vim_free(name); @@ -7622,7 +7622,7 @@ int highlight_changed(void) if (hl_flags[hlf] == *p) break; ++p; - if (hlf == (int)HLF_COUNT || *p == NUL) + if (hlf == (int)HLF_COUNT || *p == '\0') return FAIL; /* @@ -7654,7 +7654,7 @@ int highlight_changed(void) case 'c': attr |= HL_UNDERCURL; break; case ':': ++p; /* highlight group name */ - if (attr || *p == NUL) /* no combinations */ + if (attr || *p == '\0') /* no combinations */ return FAIL; end = vim_strchr(p, ','); if (end == NULL) @@ -7758,16 +7758,16 @@ void set_context_in_highlight_cmd(expand_T *xp, char_u *arg) include_default = 1; /* (part of) subcommand already typed */ - if (*arg != NUL) { + if (*arg != '\0') { p = skiptowhite(arg); - if (*p != NUL) { /* past "default" or group name */ + if (*p != '\0') { /* past "default" or group name */ include_default = 0; if (STRNCMP("default", arg, p - arg) == 0) { arg = skipwhite(p); xp->xp_pattern = arg; p = skiptowhite(arg); } - if (*p != NUL) { /* past group name */ + if (*p != '\0') { /* past group name */ include_link = 0; if (arg[1] == 'i' && arg[0] == 'N') highlight_list(); @@ -7775,12 +7775,12 @@ void set_context_in_highlight_cmd(expand_T *xp, char_u *arg) || STRNCMP("clear", arg, p - arg) == 0) { xp->xp_pattern = skipwhite(p); p = skiptowhite(xp->xp_pattern); - if (*p != NUL) { /* past first group name */ + if (*p != '\0') { /* past first group name */ xp->xp_pattern = skipwhite(p); p = skiptowhite(xp->xp_pattern); } } - if (*p != NUL) /* past group name(s) */ + if (*p != '\0') /* past group name(s) */ xp->xp_context = EXPAND_NOTHING; } } @@ -211,7 +211,7 @@ do_tag ( /* * Don't add a tag to the tagstack if 'tagstack' has been reset. */ - if ((!p_tgst && *tag != NUL)) { + if ((!p_tgst && *tag != '\0')) { use_tagstack = FALSE; new_tag = TRUE; } else { @@ -221,7 +221,7 @@ do_tag ( use_tagstack = TRUE; /* new pattern, add to the tag stack */ - if (*tag != NUL + if (*tag != '\0' && (type == DT_TAG || type == DT_SELECT || type == DT_JUMP || type == DT_LTAG || type == DT_CSCOPE @@ -451,7 +451,7 @@ do_tag ( * If a count is supplied to the ":tag <name>" command, then * jump to count'th matching tag. */ - if (type == DT_TAG && *tag != NUL && count > 0) + if (type == DT_TAG && *tag != '\0' && count > 0) cur_match = count - 1; if (type == DT_SELECT || type == DT_JUMP @@ -699,7 +699,7 @@ do_tag ( if (len > 128) len = 128; vim_strncpy(tag_name, tagp.tagname, len); - tag_name[len] = NUL; + tag_name[len] = '\0'; /* Save the tag file name */ p = tag_full_fname(&tagp); @@ -749,7 +749,7 @@ do_tag ( cmd_end--; len = 0; - cmd[0] = NUL; + cmd[0] = '\0'; /* * If "^" is present in the tag search pattern, then @@ -784,7 +784,7 @@ do_tag ( len++; } - cmd[len] = NUL; + cmd[len] = '\0'; } if ((dict = dict_alloc()) == NULL) @@ -1012,7 +1012,7 @@ static int tag_strnicmp(char_u *s1, char_u *s2, size_t len) i = (int)TOUPPER_ASC(*s1) - (int)TOUPPER_ASC(*s2); if (i != 0) return i; /* this character different */ - if (*s1 == NUL) + if (*s1 == '\0') break; /* strings match until NUL */ ++s1; ++s2; @@ -1051,7 +1051,7 @@ static void prepare_pats(pat_T *pats, int has_re) if (pats->head == pats->pat) pats->headlen = 0; else - for (pats->headlen = 0; pats->head[pats->headlen] != NUL; + for (pats->headlen = 0; pats->head[pats->headlen] != '\0'; ++pats->headlen) if (vim_strchr((char_u *)(p_magic ? ".[~*\\$" : "\\$"), pats->head[pats->headlen]) != NULL) @@ -1118,7 +1118,7 @@ find_tags ( char_u *p; char_u *s; int i; - int tag_file_sorted = NUL; /* !_TAG_FILE_SORTED value */ + int tag_file_sorted = '\0'; /* !_TAG_FILE_SORTED value */ struct tag_search_info /* Binary search file offsets */ { off_t low_offset; /* offset for first char of first line that @@ -1287,14 +1287,14 @@ find_tags ( help_pri = 0; else { help_pri = 1; - for (s = p_hlg; *s != NUL; ++s) { + for (s = p_hlg; *s != '\0'; ++s) { if (STRNICMP(s, help_lang, 2) == 0) break; ++help_pri; if ((s = vim_strchr(s, ',')) == NULL) break; } - if (s == NULL || *s == NUL) { + if (s == NULL || *s == '\0') { /* Language not in 'helplang': use last, prefer English, * unless found already. */ ++help_pri; @@ -1467,7 +1467,7 @@ line_read_in: * encoding to 'encoding'. */ for (p = lbuf + 20; *p > ' ' && *p < 127; ++p) ; - *p = NUL; + *p = '\0'; convert_setup(&vimconv, lbuf + 20, p_enc); } @@ -1488,7 +1488,7 @@ line_read_in: */ if (linear || use_cscope) state = TS_LINEAR; - else if (tag_file_sorted == NUL) + else if (tag_file_sorted == '\0') state = TS_BINARY; else if (tag_file_sorted == '1') state = TS_BINARY; @@ -1542,7 +1542,7 @@ parse_line: tagp.tagname = lbuf; #ifdef FEAT_TAG_ANYWHITE tagp.tagname_end = skiptowhite(lbuf); - if (*tagp.tagname_end == NUL) + if (*tagp.tagname_end == '\0') #else tagp.tagname_end = vim_strchr(lbuf, TAB); if (tagp.tagname_end == NULL) @@ -1707,7 +1707,7 @@ parse_line: #ifdef FEAT_TAG_ANYWHITE tagp.fname_end = skiptowhite(tagp.fname); tagp.command = skipwhite(tagp.fname_end); - if (*tagp.command == NUL) + if (*tagp.command == '\0') #else tagp.fname_end = vim_strchr(tagp.fname, TAB); tagp.command = tagp.fname_end + 1; @@ -1752,7 +1752,7 @@ parse_line: int cc; cc = *tagp.tagname_end; - *tagp.tagname_end = NUL; + *tagp.tagname_end = '\0'; match = vim_regexec(&orgpat.regmatch, tagp.tagname, (colnr_T)0); if (match) { matchoff = (int)(orgpat.regmatch.startp[0] - tagp.tagname); @@ -1820,7 +1820,7 @@ parse_line: * Append the help-heuristic number after the * tagname, for sorting it later. */ - *tagp.tagname_end = NUL; + *tagp.tagname_end = '\0'; len = (int)(tagp.tagname_end - tagp.tagname); mfp = (struct match_found *) alloc((int)sizeof(struct match_found) + len @@ -1940,7 +1940,7 @@ parse_line: if (vimconv.vc_type != CONV_NONE) convert_setup(&vimconv, NULL, NULL); - tag_file_sorted = NUL; + tag_file_sorted = '\0'; if (sort_error) { EMSG2(_("E432: Tags file not sorted: %s"), tag_fname); sort_error = FALSE; @@ -2085,7 +2085,7 @@ get_tagfname ( if (tnp->tn_hf_idx >= tag_fnames.ga_len) { /* Not found in 'runtimepath', use 'helpfile', if it exists and * wasn't used yet, replacing "help.txt" with "tags". */ - if (tnp->tn_hf_idx > tag_fnames.ga_len || *p_hf == NUL) + if (tnp->tn_hf_idx > tag_fnames.ga_len || *p_hf == '\0') return FAIL; ++tnp->tn_hf_idx; STRCPY(buf, p_hf); @@ -2099,7 +2099,7 @@ get_tagfname ( if (first) { /* Init. We make a copy of 'tags', because autocommands may change * the value without notifying us. */ - tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != NUL) + tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != '\0') ? curbuf->b_p_tags : p_tags); if (tnp->tn_tags == NULL) return FAIL; @@ -2123,7 +2123,7 @@ get_tagfname ( char_u *filename = NULL; /* Stop when used all parts of 'tags'. */ - if (*tnp->tn_np == NUL) { + if (*tnp->tn_np == '\0') { vim_findfile_cleanup(tnp->tn_search_ctx); tnp->tn_search_ctx = NULL; return FAIL; @@ -2132,7 +2132,7 @@ get_tagfname ( /* * Copy next file name into buf. */ - buf[0] = NUL; + buf[0] = '\0'; (void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,"); r_ptr = vim_findfile_stopdir(buf); @@ -2140,7 +2140,7 @@ get_tagfname ( * filepath with a NUL */ filename = path_tail(buf); STRMOVE(filename + 1, filename); - *filename++ = NUL; + *filename++ = '\0'; tnp->tn_search_ctx = vim_findfile_init(buf, filename, r_ptr, 100, @@ -2199,7 +2199,7 @@ parse_tag_line ( #ifdef FEAT_TAG_ANYWHITE p = skipwhite(p); #else - if (*p != NUL) + if (*p != '\0') ++p; #endif tagp->fname = p; @@ -2216,10 +2216,10 @@ parse_tag_line ( #ifdef FEAT_TAG_ANYWHITE p = skipwhite(p); #else - if (*p != NUL) + if (*p != '\0') ++p; #endif - if (*p == NUL) + if (*p == '\0') return FAIL; tagp->command = p; @@ -2346,7 +2346,7 @@ static char_u *tag_full_fname(tagptrs_T *tagp) { c = *tagp->fname_end; - *tagp->fname_end = NUL; + *tagp->fname_end = '\0'; } fullname = expand_tag_fname(tagp->fname, tagp->tag_fname, FALSE); @@ -2396,7 +2396,7 @@ jumpto_tag ( /* truncate the file name, so it can be used as a string */ csave = *tagp.fname_end; - *tagp.fname_end = NUL; + *tagp.fname_end = '\0'; fname = tagp.fname; /* copy the command to pbuf[], remove trailing CR/NL */ @@ -2404,7 +2404,7 @@ jumpto_tag ( for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r'; ) { *pbuf_end++ = *str++; } - *pbuf_end = NUL; + *pbuf_end = '\0'; { /* @@ -2413,7 +2413,7 @@ jumpto_tag ( str = pbuf; if (find_extra(&str) == OK) { pbuf_end = str; - *pbuf_end = NUL; + *pbuf_end = '\0'; } } @@ -2548,7 +2548,7 @@ jumpto_tag ( found = 2; (void)test_for_static(&tagp); cc = *tagp.tagname_end; - *tagp.tagname_end = NUL; + *tagp.tagname_end = '\0'; sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname); if (!do_search(NULL, '/', pbuf, (long)1, search_options, NULL)) { @@ -2710,7 +2710,7 @@ static int test_for_current(char_u *fname, char_u *fname_end, char_u *tag_fname, if (buf_ffname != NULL) { /* if the buffer has a name */ { c = *fname_end; - *fname_end = NUL; + *fname_end = '\0'; } fullname = expand_tag_fname(fname, tag_fname, TRUE); if (fullname != NULL) { @@ -2843,7 +2843,7 @@ add_tag_field ( len = MAXPATHL - 1; vim_strncpy(buf, start, len); } - buf[len] = NUL; + buf[len] = '\0'; retval = dict_add_nr_str(dict, field_name, 0L, buf); vim_free(buf); return retval; @@ -2892,7 +2892,7 @@ int get_tags(list_T *list, char_u *pat) if (tp.command_end != NULL) { for (p = tp.command_end + 3; - *p != NUL && *p != '\n' && *p != '\r'; ++p) { + *p != '\0' && *p != '\n' && *p != '\r'; ++p) { if (p == tp.tagkind || (p + 5 == tp.tagkind && STRNCMP(p, "kind:", 5) == 0)) /* skip "kind:<kind>" and "<kind>" */ @@ -2907,22 +2907,22 @@ int get_tags(list_T *list, char_u *pat) /* Add extra field as a dict entry. Fields are * separated by Tabs. */ n = p; - while (*p != NUL && *p >= ' ' && *p < 127 && *p != ':') + while (*p != '\0' && *p >= ' ' && *p < 127 && *p != ':') ++p; len = (int)(p - n); if (*p == ':' && len > 0) { s = ++p; - while (*p != NUL && *p >= ' ') + while (*p != '\0' && *p >= ' ') ++p; - n[len] = NUL; + n[len] = '\0'; if (add_tag_field(dict, (char *)n, s, p) == FAIL) ret = FAIL; n[len] = ':'; } else /* Skip field without colon. */ - while (*p != NUL && *p >= ' ') + while (*p != '\0' && *p >= ' ') ++p; - if (*p == NUL) + if (*p == '\0') break; } } diff --git a/src/term.c b/src/term.c index 0483af8401..ea0d8d79ae 100644 --- a/src/term.c +++ b/src/term.c @@ -1232,7 +1232,7 @@ static void set_color_count(int nr) if (t_colors > 1) sprintf((char *)nr_colors, "%d", t_colors); else - *nr_colors = NUL; + *nr_colors = '\0'; set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); } @@ -1520,9 +1520,9 @@ int set_termname(char_u *term) { bs_p = find_termcode((char_u *)"kb"); del_p = find_termcode((char_u *)"kD"); - if (bs_p == NULL || *bs_p == NUL) + if (bs_p == NULL || *bs_p == '\0') add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); - if ((del_p == NULL || *del_p == NUL) && + if ((del_p == NULL || *del_p == '\0') && (bs_p == NULL || *bs_p != DEL)) add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); } @@ -1771,7 +1771,7 @@ getlinecol ( { char_u tbuf[TBUFSZ]; - if (T_NAME != NULL && *T_NAME != NUL && + if (T_NAME != NULL && *T_NAME != '\0' && tgetent_error(tbuf, T_NAME) == NULL) { if (*cp == 0) *cp = tgetnum("co"); @@ -1812,7 +1812,7 @@ int add_termcap_entry(char_u *name, int force) return OK; term = T_NAME; - if (term == NULL || *term == NUL) /* 'term' not defined yet */ + if (term == NULL || *term == '\0') /* 'term' not defined yet */ return FAIL; if (term_is_builtin(term)) { /* name starts with "builtin_" */ @@ -1861,7 +1861,7 @@ int add_termcap_entry(char_u *name, int force) error_msg = tgetent_error(tbuf, term); if (error_msg == NULL) { string = TGETSTR((char *)name, &tp); - if (string != NULL && *string != NUL) { + if (string != NULL && *string != '\0') { add_termcode(name, string, FALSE); return OK; } @@ -1992,13 +1992,13 @@ void termcapinit(char_u *name) { char_u *term; - if (name != NULL && *name == NUL) + if (name != NULL && *name == '\0') name = NULL; /* empty name is equal to no name */ term = name; if (term == NULL) term = (char_u *)os_getenv("TERM"); - if (term == NULL || *term == NUL) + if (term == NULL || *term == '\0') term = DEFAULT_TERM; set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); @@ -2200,7 +2200,7 @@ static void term_color(char_u *s, int n) /* Also accept CSI instead of <Esc>[ */ if (n >= 8 && t_colors >= 16 && ((s[0] == ESC && s[1] == '[') || (s[0] == CSI && (i = 1) == 1)) - && s[i] != NUL + && s[i] != '\0' && (STRCMP(s + i + 1, "%p1%dm") == 0 || STRCMP(s + i + 1, "%dm") == 0) && (s[i] == '3' || s[i] == '4')) { @@ -2246,13 +2246,13 @@ void ttest(int pairs) /* * MUST have "cm": cursor motion. */ - if (*T_CM == NUL) + if (*T_CM == '\0') EMSG(_("E437: terminal capability \"cm\" required")); /* * if "cs" defined, use a scroll region, it's faster. */ - if (*T_CS != NUL) + if (*T_CS != '\0') scroll_region = TRUE; else scroll_region = FALSE; @@ -2262,62 +2262,62 @@ void ttest(int pairs) * optional pairs */ /* TP goes to normal mode for TI (invert) and TB (bold) */ - if (*T_ME == NUL) + if (*T_ME == '\0') T_ME = T_MR = T_MD = T_MB = empty_option; - if (*T_SO == NUL || *T_SE == NUL) + if (*T_SO == '\0' || *T_SE == '\0') T_SO = T_SE = empty_option; - if (*T_US == NUL || *T_UE == NUL) + if (*T_US == '\0' || *T_UE == '\0') T_US = T_UE = empty_option; - if (*T_CZH == NUL || *T_CZR == NUL) + if (*T_CZH == '\0' || *T_CZR == '\0') T_CZH = T_CZR = empty_option; /* T_VE is needed even though T_VI is not defined */ - if (*T_VE == NUL) + if (*T_VE == '\0') T_VI = empty_option; /* if 'mr' or 'me' is not defined use 'so' and 'se' */ - if (*T_ME == NUL) { + if (*T_ME == '\0') { T_ME = T_SE; T_MR = T_SO; T_MD = T_SO; } /* if 'so' or 'se' is not defined use 'mr' and 'me' */ - if (*T_SO == NUL) { + if (*T_SO == '\0') { T_SE = T_ME; - if (*T_MR == NUL) + if (*T_MR == '\0') T_SO = T_MD; else T_SO = T_MR; } /* if 'ZH' or 'ZR' is not defined use 'mr' and 'me' */ - if (*T_CZH == NUL) { + if (*T_CZH == '\0') { T_CZR = T_ME; - if (*T_MR == NUL) + if (*T_MR == '\0') T_CZH = T_MD; else T_CZH = T_MR; } /* "Sb" and "Sf" come in pairs */ - if (*T_CSB == NUL || *T_CSF == NUL) { + if (*T_CSB == '\0' || *T_CSF == '\0') { T_CSB = empty_option; T_CSF = empty_option; } /* "AB" and "AF" come in pairs */ - if (*T_CAB == NUL || *T_CAF == NUL) { + if (*T_CAB == '\0' || *T_CAF == '\0') { T_CAB = empty_option; T_CAF = empty_option; } /* if 'Sb' and 'AB' are not defined, reset "Co" */ - if (*T_CSB == NUL && *T_CAB == NUL) + if (*T_CSB == '\0' && *T_CAB == '\0') free_one_termoption(T_CCO); /* Set 'weirdinvert' according to value of 't_xs' */ - p_wiv = (*T_XS != NUL); + p_wiv = (*T_XS != '\0'); } need_gather = TRUE; @@ -2387,13 +2387,13 @@ static int get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) char_u c; for (i = 0; i < num_bytes; i++) { - if ((c = buf[len++]) == NUL) + if ((c = buf[len++]) == '\0') return -1; if (c == K_SPECIAL) { - if (buf[len] == NUL || buf[len + 1] == NUL) /* cannot happen? */ + if (buf[len] == '\0' || buf[len + 1] == '\0') /* cannot happen? */ return -1; if (buf[len++] == (int)KS_ZERO) - c = NUL; + c = '\0'; /* else it should be KS_SPECIAL; when followed by KE_FILLER c is * K_SPECIAL, or followed by KE_CSI and c must be CSI. */ if (buf[len++] == (int)KE_CSI) @@ -2691,7 +2691,7 @@ void may_req_termresponse(void) && isatty(1) && isatty(read_cmd_fd) # endif - && *T_CRV != NUL) { + && *T_CRV != '\0') { LOG_TR("Sending CRV"); out_str(T_CRV); crv_status = CRV_SENT; @@ -2721,7 +2721,7 @@ void may_req_ambiguous_char_width(void) && isatty(1) && isatty(read_cmd_fd) # endif - && *T_U7 != NUL + && *T_U7 != '\0' && !option_was_set((char_u *)"ambiwidth")) { char_u buf[16]; @@ -2770,7 +2770,7 @@ static void log_tr(char *msg) { */ int swapping_screen(void) { - return full_screen && *T_TI != NUL; + return full_screen && *T_TI != '\0'; } /* @@ -2782,7 +2782,7 @@ void setmouse(void) /* be quick when mouse is off */ - if (*p_mouse == NUL || has_mouse_termcode == 0) + if (*p_mouse == '\0' || has_mouse_termcode == 0) return; /* don't switch mouse on when not in raw mode (Ex mode) */ @@ -2849,7 +2849,7 @@ int mouse_model_popup(void) */ void scroll_start(void) { - if (*T_VS != NUL) { + if (*T_VS != '\0') { out_str(T_VS); out_str(T_VE); screen_start(); /* don't know where cursor is now */ @@ -2888,7 +2888,7 @@ void term_cursor_shape(void) { static int showing_insert_mode = MAYBE; - if (!full_screen || *T_CSI == NUL || *T_CEI == NUL) + if (!full_screen || *T_CSI == '\0' || *T_CEI == '\0') return; if (State & INSERT) { @@ -2912,7 +2912,7 @@ void scroll_region_set(win_T *wp, int off) { OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, W_WINROW(wp) + off)); - if (*T_CSV != NUL && wp->w_width != Columns) + if (*T_CSV != '\0' && wp->w_width != Columns) OUT_STR(tgoto((char *)T_CSV, W_WINCOL(wp) + wp->w_width - 1, W_WINCOL(wp))); screen_start(); /* don't know where cursor is now */ @@ -2924,7 +2924,7 @@ void scroll_region_set(win_T *wp, int off) void scroll_region_reset(void) { OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); - if (*T_CSV != NUL) + if (*T_CSV != '\0') OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); screen_start(); /* don't know where cursor is now */ } @@ -2956,7 +2956,7 @@ void clear_termcodes(void) #ifdef HAVE_TGETENT BC = (char *)empty_option; UP = (char *)empty_option; - PC = NUL; /* set pad character to NUL */ + PC = '\0'; /* set pad character to NUL */ ospeed = 0; #endif @@ -2978,7 +2978,7 @@ void add_termcode(char_u *name, char_u *string, int flags) char_u *s; int len; - if (string == NULL || *string == NUL) { + if (string == NULL || *string == '\0') { del_termcode(name); return; } @@ -3271,7 +3271,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) i = *tp; for (p = termleader; *p && *p != i; ++p) ; - if (*p == NUL) + if (*p == '\0') continue; /* @@ -3281,8 +3281,8 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) if (*tp == ESC && !p_ek && (State & INSERT)) continue; - key_name[0] = NUL; /* no key name found yet */ - key_name[1] = NUL; /* no key name found yet */ + key_name[0] = '\0'; /* no key name found yet */ + key_name[1] = '\0'; /* no key name found yet */ modifiers = 0; /* no modifiers yet */ { @@ -3377,7 +3377,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) } } - if (key_name[0] == NUL + if (key_name[0] == '\0' /* URXVT mouse uses <ESC>[#;#;#M, but we are matching <ESC>[ */ || key_name[0] == KS_URXVT_MOUSE || u7_status == U7_SENT @@ -3396,7 +3396,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) * ambiguous-width character state. */ p = tp[0] == CSI ? tp + 1 : tp + 2; - if ((*T_CRV != NUL || *T_U7 != NUL) + if ((*T_CRV != '\0' || *T_U7 != '\0') && ((tp[0] == ESC && tp[1] == '[' && len >= 3) || (tp[0] == CSI && len >= 2)) && (VIM_ISDIGIT(*p) || *p == '>' || *p == '?')) { @@ -3459,7 +3459,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) slen = i + 1; } else /* eat it when at least one digit and ending in 'c' */ - if (*T_CRV != NUL && i > 2 + (tp[0] != CSI) && tp[i] == 'c') { + if (*T_CRV != '\0' && i > 2 + (tp[0] != CSI) && tp[i] == 'c') { LOG_TR("Received CRV"); crv_status = CRV_GOT; did_cursorhold = TRUE; @@ -3533,7 +3533,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) } } - if (key_name[0] == NUL) + if (key_name[0] == '\0') continue; /* No match at this position, try next one */ /* We only get here when we have a complete termcode match */ @@ -3592,8 +3592,8 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) j = termcodes[idx].len; if (STRNCMP(tp, tp + slen, (size_t)j) == 0 && tp[slen + j] == mouse_code - && tp[slen + j + 1] != NUL - && tp[slen + j + 2] != NUL + && tp[slen + j + 1] != '\0' + && tp[slen + j + 2] != '\0' ) slen += j; else @@ -4103,7 +4103,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) string[new_slen++] = key_name[0]; string[new_slen++] = key_name[1]; } - string[new_slen] = NUL; + string[new_slen] = '\0'; extra = new_slen - slen; if (buf == NULL) { if (extra < 0) @@ -4208,7 +4208,7 @@ replace_termcodes ( /* * Copy each byte from *from to result[dlen] */ - while (*src != NUL) { + while (*src != '\0') { /* * If 'cpoptions' does not contain '<', check for special key codes, * like "<C-S-LeftMouse>" @@ -4278,11 +4278,11 @@ replace_termcodes ( } if (len != 0) { /* Allow up to 8 * 6 characters for "mapleader". */ - if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) + if (p == NULL || *p == '\0' || STRLEN(p) > 8 * 6) s = (char_u *)"\\"; else s = p; - while (*s != NUL) + while (*s != '\0') result[dlen++] = *s++; src += len; continue; @@ -4298,7 +4298,7 @@ replace_termcodes ( key = *src; if (key == Ctrl_V || (do_backslash && key == '\\')) { ++src; /* skip CTRL-V or backslash */ - if (*src == NUL) { + if (*src == '\0') { if (from_part) result[dlen++] = key; break; @@ -4321,7 +4321,7 @@ replace_termcodes ( ++src; } } - result[dlen] = NUL; + result[dlen] = '\0'; /* * Copy the new string to allocated memory. @@ -4362,12 +4362,12 @@ static void gather_termleader(void) if (check_for_codes) termleader[len++] = DCS; /* the termcode response starts with DCS in 8-bit mode */ - termleader[len] = NUL; + termleader[len] = '\0'; for (i = 0; i < tc_len; ++i) if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) { termleader[len++] = termcodes[i].code[0]; - termleader[len] = NUL; + termleader[len] = '\0'; } need_gather = FALSE; @@ -4476,12 +4476,12 @@ int show_one_termcode(char_u *name, char_u *code, int printit) if (p[1] != 't') STRCPY(IObuff + 5, p); else - IObuff[5] = NUL; + IObuff[5] = '\0'; len = (int)STRLEN(IObuff); do IObuff[len++] = ' '; while (len < 17); - IObuff[len] = NUL; + IObuff[len] = '\0'; if (code == NULL) len += 4; else @@ -4564,7 +4564,7 @@ static void got_code_from_term(char_u *code, int len) /* Get the name from the response and find it in the table. */ name[0] = hexhex2nr(code + 3); name[1] = hexhex2nr(code + 5); - name[2] = NUL; + name[2] = '\0'; for (i = 0; key_names[i] != NULL; ++i) { if (STRCMP(key_names[i], name) == 0) { xt_index_in = i; @@ -4582,7 +4582,7 @@ static void got_code_from_term(char_u *code, int len) if (key_names[i] != NULL) { for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) str[j++] = c; - str[j] = NUL; + str[j] = '\0'; if (name[0] == 'C' && name[1] == 'o') { /* Color count is not a key code. */ i = atoi((char *)str); @@ -4641,7 +4641,7 @@ static void check_for_codes_from_term(void) ++allow_keys; for (;; ) { c = vpeekc(); - if (c == NUL) /* nothing available */ + if (c == '\0') /* nothing available */ break; /* If a response is recognized it's replaced with K_IGNORE, must read @@ -4695,7 +4695,7 @@ translate_mapping ( for (; *str; ++str) { c = *str; - if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) { + if (c == K_SPECIAL && str[1] != '\0' && str[2] != '\0') { modifiers = 0; if (str[1] == KS_MODIFIER) { str++; @@ -4716,14 +4716,14 @@ translate_mapping ( continue; /* for (str) */ } } - if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) { + if (c == K_SPECIAL && str[1] != '\0' && str[2] != '\0') { if (expmap && cpo_special) { ga_clear(&ga); return NULL; } c = TO_SPECIAL(str[1], str[2]); if (c == K_ZERO) /* display <Nul> as ^@ */ - c = NUL; + c = '\0'; str += 2; } if (IS_SPECIAL(c) || modifiers) { /* special key */ @@ -4741,7 +4741,7 @@ translate_mapping ( if (c) ga_append(&ga, c); } - ga_append(&ga, NUL); + ga_append(&ga, '\0'); return (char_u *)(ga.ga_data); } @@ -1075,7 +1075,7 @@ int vcol2col(win_T *wp, linenr_T lnum, int vcol) char_u *start; start = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE); - while (count < vcol && *ptr != NUL) { + while (count < vcol && *ptr != '\0') { count += win_lbr_chartabsize(wp, ptr, count, NULL); mb_ptr_adv(ptr); } diff --git a/src/undo.c b/src/undo.c index 243d865513..39162aea29 100644 --- a/src/undo.c +++ b/src/undo.c @@ -694,7 +694,7 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading) /* Loop over 'undodir'. When reading find the first file that exists. * When not reading use the first directory that exists or ".". */ dirp = p_udir; - while (*dirp != NUL) { + while (*dirp != '\0') { dir_len = copy_option_part(&dirp, dir_name, IOSIZE, ","); if (dir_len == 1 && dir_name[0] == '.') { /* Use same directory as the ffname, @@ -707,13 +707,13 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading) *p = '.'; STRCAT(p, ".un~"); } else { - dir_name[dir_len] = NUL; + dir_name[dir_len] = '\0'; if (os_isdir(dir_name)) { if (munged_name == NULL) { munged_name = vim_strsave(ffname); if (munged_name == NULL) return NULL; - for (p = munged_name; *p != NUL; mb_ptr_adv(p)) + for (p = munged_name; *p != '\0'; mb_ptr_adv(p)) if (vim_ispathsep(*p)) *p = '%'; } @@ -763,7 +763,7 @@ static size_t fwrite_crypt(buf_T *buf, char_u *ptr, size_t len, FILE *fp) char_u small_buf[100]; size_t i; - if (*buf->b_p_key == NUL) + if (*buf->b_p_key == '\0') return fwrite(ptr, len, (size_t)1, fp); if (len < 100) copy = small_buf; /* no malloc()/free() for short strings */ @@ -786,7 +786,7 @@ static char_u *read_string_decrypt(buf_T *buf, FILE *fd, int len) char_u *ptr; ptr = read_string(fd, len); - if (ptr != NULL && *buf->b_p_key != NUL) + if (ptr != NULL && *buf->b_p_key != '\0') crypt_decode(ptr, len); return ptr; } @@ -801,7 +801,7 @@ static int serialize_header(FILE *fp, buf_T *buf, char_u *hash) /* If the buffer is encrypted then all text bytes following will be * encrypted. Numbers and other info is not crypted. */ - if (*buf->b_p_key != NUL) { + if (*buf->b_p_key != '\0') { char_u *header; int header_len; @@ -1253,7 +1253,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash) */ if (serialize_header(fp, buf, hash) == FAIL) goto write_error; - if (*buf->b_p_key != NUL) + if (*buf->b_p_key != '\0') do_crypt = TRUE; /* @@ -1404,7 +1404,7 @@ void u_read_undo(char_u *name, char_u *hash, char_u *orig_name) } version = get2c(fp); if (version == UF_VERSION_CRYPT) { - if (*curbuf->b_p_key == NUL) { + if (*curbuf->b_p_key == '\0') { EMSG2(_("E832: Non-encrypted file has encrypted undo file: %s"), file_name); goto error; @@ -2317,7 +2317,7 @@ u_undo_end ( uhp = curbuf->b_u_newhead; if (uhp == NULL) - *msgbuf = NUL; + *msgbuf = '\0'; else u_add_time(msgbuf, sizeof(msgbuf), uhp->uh_time); diff --git a/src/version.c b/src/version.c index 6e41f41c97..f504264134 100644 --- a/src/version.c +++ b/src/version.c @@ -517,7 +517,7 @@ int has_patch(int n) void ex_version(exarg_T *eap) { // Ignore a ":version 9.99" command. - if (*eap->arg == NUL) { + if (*eap->arg == '\0') { msg_putchar('\n'); list_version(); } @@ -639,15 +639,15 @@ void list_version(void) #ifdef HAVE_PATHDEF - if ((*compiled_user != NUL) || (*compiled_sys != NUL)) { + if ((*compiled_user != '\0') || (*compiled_sys != '\0')) { MSG_PUTS(_("\nCompiled ")); - if (*compiled_user != NUL) { + if (*compiled_user != '\0') { MSG_PUTS(_("by ")); MSG_PUTS(compiled_user); } - if (*compiled_sys != NUL) { + if (*compiled_sys != '\0') { MSG_PUTS("@"); MSG_PUTS(compiled_sys); } @@ -692,13 +692,13 @@ void list_version(void) #endif // ifdef USR_EXRC_FILE2 #ifdef HAVE_PATHDEF - if (*default_vim_dir != NUL) { + if (*default_vim_dir != '\0') { version_msg(_(" fall-back for $VIM: \"")); version_msg((char *)default_vim_dir); version_msg("\"\n"); } - if (*default_vimruntime_dir != NUL) { + if (*default_vimruntime_dir != '\0') { version_msg(_(" f-b for $VIMRUNTIME: \"")); version_msg((char *)default_vimruntime_dir); version_msg("\"\n"); @@ -832,7 +832,7 @@ void intro_message(int colon) } } - if (*p != NUL) { + if (*p != '\0') { do_intro_line(row, (char_u *)_(p), i == 2, 0); } row++; @@ -890,10 +890,10 @@ static void do_intro_line(int row, char_u *mesg, int add_version, int attr) } // Split up in parts to highlight <> items differently. - for (p = mesg; *p != NUL; p += l) { + for (p = mesg; *p != '\0'; p += l) { clen = 0; - for (l = 0; p[l] != NUL + for (l = 0; p[l] != '\0' && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l) { if (has_mbyte) { clen += ptr2cells(p + l); diff --git a/src/window.c b/src/window.c index 305bf6b7c9..9ed9e4de59 100644 --- a/src/window.c +++ b/src/window.c @@ -185,7 +185,7 @@ newwindow: /* window height */ vim_snprintf((char *)cbuf, sizeof(cbuf) - 5, "%" PRId64, (int64_t)Prenum); else - cbuf[0] = NUL; + cbuf[0] = '\0'; if (nchar == 'v' || nchar == Ctrl_V) STRCAT(cbuf, "v"); STRCAT(cbuf, "new"); @@ -418,7 +418,7 @@ newwindow: /* Execute the command right here, required when * "wincmd ]" was used in a function. */ - do_nv_ident(Ctrl_RSB, NUL); + do_nv_ident(Ctrl_RSB, '\0'); break; /* edit file name under cursor in a new window */ @@ -487,7 +487,7 @@ wingotofile: #endif ++ no_mapping; ++allow_keys; /* no mapping for xchar, but allow key codes */ - if (xchar == NUL) + if (xchar == '\0') xchar = plain_vgetc(); LANGMAP_ADJUST(xchar, TRUE); --no_mapping; @@ -4791,9 +4791,9 @@ file_name_in_line ( * search forward for what could be the start of a file name */ ptr = line + col; - while (*ptr != NUL && !vim_isfilec(*ptr)) + while (*ptr != '\0' && !vim_isfilec(*ptr)) mb_ptr_adv(ptr); - if (*ptr == NUL) { /* nothing found */ + if (*ptr == '\0') { /* nothing found */ if (options & FNAME_MESS) EMSG(_("E446: No file name under cursor")); return NULL; @@ -4839,7 +4839,7 @@ file_name_in_line ( /* Get the number after the file name and a separator character */ p = ptr + len; p = skipwhite(p); - if (*p != NUL) { + if (*p != '\0') { if (!isdigit(*p)) ++p; /* skip the separator */ p = skipwhite(p); @@ -5224,7 +5224,7 @@ int match_add(win_T *wp, char_u *grp, char_u *pat, int prio, int id) int hlg_id; regprog_T *regprog; - if (*grp == NUL || *pat == NUL) + if (*grp == '\0' || *pat == '\0') return -1; if (id < -1 || id == 0) { EMSGN("E799: Invalid ID: %" PRId64 |