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/regexp.c | 160 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 80 insertions(+), 80 deletions(-) (limited to 'src/regexp.c') 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 "@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: /* \ 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; } -- cgit