From 2e4613aecc712eb5e893d341da5f571f932376d5 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Tue, 29 Apr 2014 21:56:49 +0200 Subject: Remove NUL macro --- src/arabic.c | 4 +- src/ascii.h | 1 - src/blowfish.c | 2 +- src/buffer.c | 62 +++---- src/charset.c | 72 ++++---- src/crypt.c | 10 +- src/cursor_shape.c | 2 +- src/diff.c | 24 +-- src/digraph.c | 20 +-- src/edit.c | 254 +++++++++++++------------- src/eval.c | 382 +++++++++++++++++++-------------------- src/ex_cmds.c | 208 ++++++++++----------- src/ex_cmds2.c | 60 +++---- src/ex_docmd.c | 274 ++++++++++++++-------------- src/ex_eval.c | 32 ++-- src/ex_getln.c | 132 +++++++------- src/farsi.c | 4 +- src/file_search.c | 56 +++--- src/fileio.c | 166 ++++++++--------- src/fold.c | 18 +- src/garray.c | 2 +- src/getchar.c | 150 ++++++++-------- src/globals.h | 14 +- src/hardcopy.c | 36 ++-- src/hashtab.c | 2 +- src/if_cscope.c | 22 +-- src/indent.c | 18 +- src/indent_c.c | 80 ++++----- src/keymap.c | 20 +-- src/keymap.h | 4 +- src/macros.h | 4 +- src/main.c | 22 +-- src/mark.c | 30 ++-- src/mbyte.c | 100 +++++------ src/memfile.c | 6 +- src/memline.c | 60 +++---- src/menu.c | 104 +++++------ src/message.c | 100 +++++------ src/misc1.c | 134 +++++++------- src/misc2.c | 72 ++++---- src/move.c | 2 +- src/msgpack_rpc.c | 2 +- src/normal.c | 160 ++++++++--------- src/ops.c | 192 ++++++++++---------- src/option.c | 250 +++++++++++++------------- src/os/env.c | 2 +- src/os/fs.c | 2 +- src/os/shell.c | 8 +- src/os/users.c | 2 +- src/os_unix.c | 56 +++--- src/path.c | 112 ++++++------ src/popupmnu.c | 8 +- src/quickfix.c | 98 +++++----- src/regexp.c | 160 ++++++++--------- src/regexp_nfa.c | 62 +++---- src/screen.c | 192 ++++++++++---------- src/search.c | 140 +++++++-------- src/sha256.c | 2 +- src/spell.c | 520 ++++++++++++++++++++++++++--------------------------- src/syntax.c | 96 +++++----- src/tag.c | 78 ++++---- src/term.c | 128 ++++++------- src/ui.c | 2 +- src/undo.c | 18 +- src/version.c | 18 +- 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 */ /* 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');