summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-08 17:20:12 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-08 17:20:12 +0200
commit9490b9a61cf1f1f3fa9758663a33124ea9f71c87 (patch)
tree39d917a9ab96f20e4652e7703180c464afddbbeb
parent3d2a3cbce873af861031a01e02694dcfae0c4582 (diff)
patch 8.1.2010: new file uses old style commentsv8.1.2010
Problem: New file uses old style comments. Solution: Change to new style comments. (Yegappan Lakshmanan, closes #4910)
-rw-r--r--src/regexp_bt.c986
-rw-r--r--src/version.c2
2 files changed, 480 insertions, 508 deletions
diff --git a/src/regexp_bt.c b/src/regexp_bt.c
index 2397af544f..b71b862056 100644
--- a/src/regexp_bt.c
+++ b/src/regexp_bt.c
@@ -134,124 +134,124 @@
* The opcodes are:
*/
-/* definition number opnd? meaning */
-#define END 0 /* End of program or NOMATCH operand. */
-#define BOL 1 /* Match "" at beginning of line. */
-#define EOL 2 /* Match "" at end of line. */
-#define BRANCH 3 /* node Match this alternative, or the
- * next... */
-#define BACK 4 /* Match "", "next" ptr points backward. */
-#define EXACTLY 5 /* str Match this string. */
-#define NOTHING 6 /* Match empty string. */
-#define STAR 7 /* node Match this (simple) thing 0 or more
- * times. */
-#define PLUS 8 /* node Match this (simple) thing 1 or more
- * times. */
-#define MATCH 9 /* node match the operand zero-width */
-#define NOMATCH 10 /* node check for no match with operand */
-#define BEHIND 11 /* node look behind for a match with operand */
-#define NOBEHIND 12 /* node look behind for no match with operand */
-#define SUBPAT 13 /* node match the operand here */
-#define BRACE_SIMPLE 14 /* node Match this (simple) thing between m and
- * n times (\{m,n\}). */
-#define BOW 15 /* Match "" after [^a-zA-Z0-9_] */
-#define EOW 16 /* Match "" at [^a-zA-Z0-9_] */
-#define BRACE_LIMITS 17 /* nr nr define the min & max for BRACE_SIMPLE
- * and BRACE_COMPLEX. */
-#define NEWL 18 /* Match line-break */
-#define BHPOS 19 /* End position for BEHIND or NOBEHIND */
-
-
-/* character classes: 20-48 normal, 50-78 include a line-break */
+// definition number opnd? meaning
+#define END 0 // End of program or NOMATCH operand.
+#define BOL 1 // Match "" at beginning of line.
+#define EOL 2 // Match "" at end of line.
+#define BRANCH 3 // node Match this alternative, or the
+ // next...
+#define BACK 4 // Match "", "next" ptr points backward.
+#define EXACTLY 5 // str Match this string.
+#define NOTHING 6 // Match empty string.
+#define STAR 7 // node Match this (simple) thing 0 or more
+ // times.
+#define PLUS 8 // node Match this (simple) thing 1 or more
+ // times.
+#define MATCH 9 // node match the operand zero-width
+#define NOMATCH 10 // node check for no match with operand
+#define BEHIND 11 // node look behind for a match with operand
+#define NOBEHIND 12 // node look behind for no match with operand
+#define SUBPAT 13 // node match the operand here
+#define BRACE_SIMPLE 14 // node Match this (simple) thing between m and
+ // n times (\{m,n\}).
+#define BOW 15 // Match "" after [^a-zA-Z0-9_]
+#define EOW 16 // Match "" at [^a-zA-Z0-9_]
+#define BRACE_LIMITS 17 // nr nr define the min & max for BRACE_SIMPLE
+ // and BRACE_COMPLEX.
+#define NEWL 18 // Match line-break
+#define BHPOS 19 // End position for BEHIND or NOBEHIND
+
+
+// character classes: 20-48 normal, 50-78 include a line-break
#define ADD_NL 30
#define FIRST_NL ANY + ADD_NL
-#define ANY 20 /* Match any one character. */
-#define ANYOF 21 /* str Match any character in this string. */
-#define ANYBUT 22 /* str Match any character not in this
- * string. */
-#define IDENT 23 /* Match identifier char */
-#define SIDENT 24 /* Match identifier char but no digit */
-#define KWORD 25 /* Match keyword char */
-#define SKWORD 26 /* Match word char but no digit */
-#define FNAME 27 /* Match file name char */
-#define SFNAME 28 /* Match file name char but no digit */
-#define PRINT 29 /* Match printable char */
-#define SPRINT 30 /* Match printable char but no digit */
-#define WHITE 31 /* Match whitespace char */
-#define NWHITE 32 /* Match non-whitespace char */
-#define DIGIT 33 /* Match digit char */
-#define NDIGIT 34 /* Match non-digit char */
-#define HEX 35 /* Match hex char */
-#define NHEX 36 /* Match non-hex char */
-#define OCTAL 37 /* Match octal char */
-#define NOCTAL 38 /* Match non-octal char */
-#define WORD 39 /* Match word char */
-#define NWORD 40 /* Match non-word char */
-#define HEAD 41 /* Match head char */
-#define NHEAD 42 /* Match non-head char */
-#define ALPHA 43 /* Match alpha char */
-#define NALPHA 44 /* Match non-alpha char */
-#define LOWER 45 /* Match lowercase char */
-#define NLOWER 46 /* Match non-lowercase char */
-#define UPPER 47 /* Match uppercase char */
-#define NUPPER 48 /* Match non-uppercase char */
+#define ANY 20 // Match any one character.
+#define ANYOF 21 // str Match any character in this string.
+#define ANYBUT 22 // str Match any character not in this
+ // string.
+#define IDENT 23 // Match identifier char
+#define SIDENT 24 // Match identifier char but no digit
+#define KWORD 25 // Match keyword char
+#define SKWORD 26 // Match word char but no digit
+#define FNAME 27 // Match file name char
+#define SFNAME 28 // Match file name char but no digit
+#define PRINT 29 // Match printable char
+#define SPRINT 30 // Match printable char but no digit
+#define WHITE 31 // Match whitespace char
+#define NWHITE 32 // Match non-whitespace char
+#define DIGIT 33 // Match digit char
+#define NDIGIT 34 // Match non-digit char
+#define HEX 35 // Match hex char
+#define NHEX 36 // Match non-hex char
+#define OCTAL 37 // Match octal char
+#define NOCTAL 38 // Match non-octal char
+#define WORD 39 // Match word char
+#define NWORD 40 // Match non-word char
+#define HEAD 41 // Match head char
+#define NHEAD 42 // Match non-head char
+#define ALPHA 43 // Match alpha char
+#define NALPHA 44 // Match non-alpha char
+#define LOWER 45 // Match lowercase char
+#define NLOWER 46 // Match non-lowercase char
+#define UPPER 47 // Match uppercase char
+#define NUPPER 48 // Match non-uppercase char
#define LAST_NL NUPPER + ADD_NL
#define WITH_NL(op) ((op) >= FIRST_NL && (op) <= LAST_NL)
-#define MOPEN 80 /* -89 Mark this point in input as start of
- * \( subexpr. MOPEN + 0 marks start of
- * match. */
-#define MCLOSE 90 /* -99 Analogous to MOPEN. MCLOSE + 0 marks
- * end of match. */
-#define BACKREF 100 /* -109 node Match same string again \1-\9 */
+#define MOPEN 80 // -89 Mark this point in input as start of
+ // \( subexpr. MOPEN + 0 marks start of
+ // match.
+#define MCLOSE 90 // -99 Analogous to MOPEN. MCLOSE + 0 marks
+ // end of match.
+#define BACKREF 100 // -109 node Match same string again \1-\9
#ifdef FEAT_SYN_HL
-# define ZOPEN 110 /* -119 Mark this point in input as start of
- * \z( subexpr. */
-# define ZCLOSE 120 /* -129 Analogous to ZOPEN. */
-# define ZREF 130 /* -139 node Match external submatch \z1-\z9 */
+# define ZOPEN 110 // -119 Mark this point in input as start of
+ // \z( subexpr.
+# define ZCLOSE 120 // -129 Analogous to ZOPEN.
+# define ZREF 130 // -139 node Match external submatch \z1-\z9
#endif
-#define BRACE_COMPLEX 140 /* -149 node Match nodes between m & n times */
+#define BRACE_COMPLEX 140 // -149 node Match nodes between m & n times
-#define NOPEN 150 /* Mark this point in input as start of
- \%( subexpr. */
-#define NCLOSE 151 /* Analogous to NOPEN. */
+#define NOPEN 150 // Mark this point in input as start of
+ // \%( subexpr.
+#define NCLOSE 151 // Analogous to NOPEN.
-#define MULTIBYTECODE 200 /* mbc Match one multi-byte character */
-#define RE_BOF 201 /* Match "" at beginning of file. */
-#define RE_EOF 202 /* Match "" at end of file. */
-#define CURSOR 203 /* Match location of cursor. */
+#define MULTIBYTECODE 200 // mbc Match one multi-byte character
+#define RE_BOF 201 // Match "" at beginning of file.
+#define RE_EOF 202 // Match "" at end of file.
+#define CURSOR 203 // Match location of cursor.
-#define RE_LNUM 204 /* nr cmp Match line number */
-#define RE_COL 205 /* nr cmp Match column number */
-#define RE_VCOL 206 /* nr cmp Match virtual column number */
+#define RE_LNUM 204 // nr cmp Match line number
+#define RE_COL 205 // nr cmp Match column number
+#define RE_VCOL 206 // nr cmp Match virtual column number
-#define RE_MARK 207 /* mark cmp Match mark position */
-#define RE_VISUAL 208 /* Match Visual area */
-#define RE_COMPOSING 209 /* any composing characters */
+#define RE_MARK 207 // mark cmp Match mark position
+#define RE_VISUAL 208 // Match Visual area
+#define RE_COMPOSING 209 // any composing characters
/*
* Flags to be passed up and down.
*/
-#define HASWIDTH 0x1 /* Known never to match null string. */
-#define SIMPLE 0x2 /* Simple enough to be STAR/PLUS operand. */
-#define SPSTART 0x4 /* Starts with * or +. */
-#define HASNL 0x8 /* Contains some \n. */
-#define HASLOOKBH 0x10 /* Contains "\@<=" or "\@<!". */
-#define WORST 0 /* Worst case. */
-
-static int num_complex_braces; /* Complex \{...} count */
-static char_u *regcode; /* Code-emit pointer, or JUST_CALC_SIZE */
-static long regsize; /* Code size. */
-static int reg_toolong; /* TRUE when offset out of range */
-static char_u had_endbrace[NSUBEXP]; /* flags, TRUE if end of () found */
-static long brace_min[10]; /* Minimums for complex brace repeats */
-static long brace_max[10]; /* Maximums for complex brace repeats */
-static int brace_count[10]; /* Current counts for complex brace repeats */
-static int one_exactly = FALSE; /* only do one char for EXACTLY */
-
-/* When making changes to classchars also change nfa_classcodes. */
+#define HASWIDTH 0x1 // Known never to match null string.
+#define SIMPLE 0x2 // Simple enough to be STAR/PLUS operand.
+#define SPSTART 0x4 // Starts with * or +.
+#define HASNL 0x8 // Contains some \n.
+#define HASLOOKBH 0x10 // Contains "\@<=" or "\@<!".
+#define WORST 0 // Worst case.
+
+static int num_complex_braces; // Complex \{...} count
+static char_u *regcode; // Code-emit pointer, or JUST_CALC_SIZE
+static long regsize; // Code size.
+static int reg_toolong; // TRUE when offset out of range
+static char_u had_endbrace[NSUBEXP]; // flags, TRUE if end of () found
+static long brace_min[10]; // Minimums for complex brace repeats
+static long brace_max[10]; // Maximums for complex brace repeats
+static int brace_count[10]; // Current counts for complex brace repeats
+static int one_exactly = FALSE; // only do one char for EXACTLY
+
+// When making changes to classchars also change nfa_classcodes.
static char_u *classchars = (char_u *)".iIkKfFpPsSdDxXoOwWhHaAlLuU";
static int classcodes[] = {
ANY, IDENT, SIDENT, KWORD, SKWORD,
@@ -269,25 +269,25 @@ static int classcodes[] = {
*/
#define JUST_CALC_SIZE ((char_u *) -1)
-/* Values for rs_state in regitem_T. */
+// Values for rs_state in regitem_T.
typedef enum regstate_E
{
- RS_NOPEN = 0 /* NOPEN and NCLOSE */
- , RS_MOPEN /* MOPEN + [0-9] */
- , RS_MCLOSE /* MCLOSE + [0-9] */
+ RS_NOPEN = 0 // NOPEN and NCLOSE
+ , RS_MOPEN // MOPEN + [0-9]
+ , RS_MCLOSE // MCLOSE + [0-9]
#ifdef FEAT_SYN_HL
- , RS_ZOPEN /* ZOPEN + [0-9] */
- , RS_ZCLOSE /* ZCLOSE + [0-9] */
+ , RS_ZOPEN // ZOPEN + [0-9]
+ , RS_ZCLOSE // ZCLOSE + [0-9]
#endif
- , RS_BRANCH /* BRANCH */
- , RS_BRCPLX_MORE /* BRACE_COMPLEX and trying one more match */
- , RS_BRCPLX_LONG /* BRACE_COMPLEX and trying longest match */
- , RS_BRCPLX_SHORT /* BRACE_COMPLEX and trying shortest match */
- , RS_NOMATCH /* NOMATCH */
- , RS_BEHIND1 /* BEHIND / NOBEHIND matching rest */
- , RS_BEHIND2 /* BEHIND / NOBEHIND matching behind part */
- , RS_STAR_LONG /* STAR/PLUS/BRACE_SIMPLE longest match */
- , RS_STAR_SHORT /* STAR/PLUS/BRACE_SIMPLE shortest match */
+ , RS_BRANCH // BRANCH
+ , RS_BRCPLX_MORE // BRACE_COMPLEX and trying one more match
+ , RS_BRCPLX_LONG // BRACE_COMPLEX and trying longest match
+ , RS_BRCPLX_SHORT // BRACE_COMPLEX and trying shortest match
+ , RS_NOMATCH // NOMATCH
+ , RS_BEHIND1 // BEHIND / NOBEHIND matching rest
+ , RS_BEHIND2 // BEHIND / NOBEHIND matching behind part
+ , RS_STAR_LONG // STAR/PLUS/BRACE_SIMPLE longest match
+ , RS_STAR_SHORT // STAR/PLUS/BRACE_SIMPLE shortest match
} regstate_T;
/*
@@ -299,13 +299,13 @@ typedef struct
{
union
{
- char_u *ptr; /* rex.input pointer, for single-line regexp */
- lpos_T pos; /* rex.input pos, for multi-line regexp */
+ char_u *ptr; // rex.input pointer, for single-line regexp
+ lpos_T pos; // rex.input pos, for multi-line regexp
} rs_u;
int rs_len;
} regsave_T;
-/* struct to save start/end pointer/position in for \(\) */
+// struct to save start/end pointer/position in for \(\)
typedef struct
{
union
@@ -315,7 +315,7 @@ typedef struct
} se_u;
} save_se_T;
-/* used for BEHIND and NOBEHIND matching */
+// used for BEHIND and NOBEHIND matching
typedef struct regbehind_S
{
regsave_T save_after;
@@ -344,22 +344,22 @@ typedef struct regitem_S
} regitem_T;
-/* used for STAR, PLUS and BRACE_SIMPLE matching */
+// used for STAR, PLUS and BRACE_SIMPLE matching
typedef struct regstar_S
{
- int nextb; /* next byte */
- int nextb_ic; /* next byte reverse case */
+ int nextb; // next byte
+ int nextb_ic; // next byte reverse case
long count;
long minval;
long maxval;
} regstar_T;
-/* used to store input position when a BACK was encountered, so that we now if
- * we made any progress since the last time. */
+// used to store input position when a BACK was encountered, so that we now if
+// we made any progress since the last time.
typedef struct backpos_S
{
- char_u *bp_scan; /* "scan" where BACK was encountered */
- regsave_T bp_pos; /* last input position */
+ char_u *bp_scan; // "scan" where BACK was encountered
+ regsave_T bp_pos; // last input position
} backpos_T;
/*
@@ -428,12 +428,12 @@ static regsave_T behind_pos;
#define OP(p) ((int)*(p))
#define NEXT(p) (((*((p) + 1) & 0377) << 8) + (*((p) + 2) & 0377))
#define OPERAND(p) ((p) + 3)
-/* Obtain an operand that was stored as four bytes, MSB first. */
+// Obtain an operand that was stored as four bytes, MSB first.
#define OPERAND_MIN(p) (((long)(p)[3] << 24) + ((long)(p)[4] << 16) \
+ ((long)(p)[5] << 8) + (long)(p)[6])
-/* Obtain a second operand stored as four bytes. */
+// Obtain a second operand stored as four bytes.
#define OPERAND_MAX(p) OPERAND_MIN((p) + 4)
-/* Obtain a second single-byte operand stored after a four bytes operand. */
+// Obtain a second single-byte operand stored after a four bytes operand.
#define OPERAND_CMP(p) (p)[7]
static char_u *reg(int paren, int *flagp);
@@ -457,7 +457,7 @@ static int regnarrate = 0;
static void
regcomp_start(
char_u *expr,
- int re_flags) /* see vim_regcomp() */
+ int re_flags) // see vim_regcomp()
{
initchr(expr);
if (re_flags & RE_MAGIC)
@@ -538,7 +538,7 @@ reg_equi_class(int c)
#ifdef EBCDIC
int i;
- /* This might be slower than switch/case below. */
+ // This might be slower than switch/case below.
for (i = 0; i < 16; i++)
{
if (vim_strchr(EQUIVAL_CLASS_C[i], c) != NULL)
@@ -553,7 +553,7 @@ reg_equi_class(int c)
#else
switch (c)
{
- /* Do not use '\300' style, it results in a negative number. */
+ // Do not use '\300' style, it results in a negative number.
case 'A': case 0xc0: case 0xc1: case 0xc2:
case 0xc3: case 0xc4: case 0xc5:
CASEMBC(0x100) CASEMBC(0x102) CASEMBC(0x104) CASEMBC(0x1cd)
@@ -866,7 +866,7 @@ regnode(int op)
else
{
*regcode++ = op;
- *regcode++ = NUL; /* Null "next" pointer. */
+ *regcode++ = NUL; // Null "next" pointer.
*regcode++ = NUL;
}
return ret;
@@ -921,7 +921,7 @@ regtail(char_u *p, char_u *val)
if (p == JUST_CALC_SIZE)
return;
- /* Find last node. */
+ // Find last node.
scan = p;
for (;;)
{
@@ -935,9 +935,9 @@ regtail(char_u *p, char_u *val)
offset = (int)(scan - val);
else
offset = (int)(val - scan);
- /* When the offset uses more than 16 bits it can no longer fit in the two
- * bytes available. Use a global flag to avoid having to check return
- * values in too many places. */
+ // When the offset uses more than 16 bits it can no longer fit in the two
+ // bytes available. Use a global flag to avoid having to check return
+ // values in too many places.
if (offset > 0xffff)
reg_toolong = TRUE;
else
@@ -953,7 +953,7 @@ regtail(char_u *p, char_u *val)
static void
regoptail(char_u *p, char_u *val)
{
- /* When op is neither BRANCH nor BRACE_COMPLEX0-9, it is "operandless" */
+ // When op is neither BRANCH nor BRACE_COMPLEX0-9, it is "operandless"
if (p == NULL || p == JUST_CALC_SIZE
|| (OP(p) != BRANCH
&& (OP(p) < BRACE_COMPLEX || OP(p) > BRACE_COMPLEX + 9)))
@@ -984,7 +984,7 @@ reginsert(int op, char_u *opnd)
while (src > opnd)
*--dst = *--src;
- place = opnd; /* Op node, where operand used to be. */
+ place = opnd; // Op node, where operand used to be.
*place++ = op;
*place++ = NUL;
*place = NUL;
@@ -1012,7 +1012,7 @@ reginsert_nr(int op, long val, char_u *opnd)
while (src > opnd)
*--dst = *--src;
- place = opnd; /* Op node, where operand used to be. */
+ place = opnd; // Op node, where operand used to be.
*place++ = op;
*place++ = NUL;
*place++ = NUL;
@@ -1047,7 +1047,7 @@ reginsert_limits(
while (src > opnd)
*--dst = *--src;
- place = opnd; /* Op node, where operand used to be. */
+ place = opnd; // Op node, where operand used to be.
*place++ = op;
*place++ = NUL;
*place++ = NUL;
@@ -1069,8 +1069,8 @@ seen_endbrace(int refnum)
{
char_u *p;
- /* Trick: check if "@<=" or "@<!" follows, in which case
- * the \1 can appear before the referenced match. */
+ // Trick: check if "@<=" or "@<!" follows, in which case
+ // the \1 can appear before the referenced match.
for (p = regparse; *p != NUL; ++p)
if (p[0] == '@' && p[1] == '<' && (p[2] == '!' || p[2] == '='))
break;
@@ -1101,7 +1101,7 @@ regatom(int *flagp)
int extra = 0;
int save_prev_at_start = prev_at_start;
- *flagp = WORST; /* Tentatively. */
+ *flagp = WORST; // Tentatively.
c = getchr();
switch (c)
@@ -1127,12 +1127,12 @@ regatom(int *flagp)
case Magic('_'):
c = no_Magic(getchr());
- if (c == '^') /* "\_^" is start-of-line */
+ if (c == '^') // "\_^" is start-of-line
{
ret = regnode(BOL);
break;
}
- if (c == '$') /* "\_$" is end-of-line */
+ if (c == '$') // "\_$" is end-of-line
{
ret = regnode(EOL);
#if defined(FEAT_SYN_HL) || defined(PROTO)
@@ -1144,16 +1144,14 @@ regatom(int *flagp)
extra = ADD_NL;
*flagp |= HASNL;
- /* "\_[" is character range plus newline */
+ // "\_[" is character range plus newline
if (c == '[')
goto collection;
- /* "\_x" is character class plus newline */
- /* FALLTHROUGH */
+ // "\_x" is character class plus newline
+ // FALLTHROUGH
- /*
- * Character classes.
- */
+ // Character classes.
case Magic('.'):
case Magic('i'):
case Magic('I'):
@@ -1185,8 +1183,8 @@ regatom(int *flagp)
if (p == NULL)
EMSG_RET_NULL(_("E63: invalid use of \\_"));
- /* When '.' is followed by a composing char ignore the dot, so that
- * the composing char is matched here. */
+ // When '.' is followed by a composing char ignore the dot, so that
+ // the composing char is matched here.
if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr()))
{
c = getchr();
@@ -1199,7 +1197,7 @@ regatom(int *flagp)
case Magic('n'):
if (reg_string)
{
- /* In a string "\n" matches a newline character. */
+ // In a string "\n" matches a newline character.
ret = regnode(EXACTLY);
regc(NL);
regc(NUL);
@@ -1207,7 +1205,7 @@ regatom(int *flagp)
}
else
{
- /* In buffer text "\n" matches the end of a line. */
+ // In buffer text "\n" matches the end of a line.
ret = regnode(NEWL);
*flagp |= HASWIDTH | HASNL;
}
@@ -1228,8 +1226,8 @@ regatom(int *flagp)
case Magic(')'):
if (one_exactly)
EMSG_ONE_RET_NULL;
- IEMSG_RET_NULL(_(e_internal)); /* Supposed to be caught earlier. */
- /* NOTREACHED */
+ IEMSG_RET_NULL(_(e_internal)); // Supposed to be caught earlier.
+ // NOTREACHED
case Magic('='):
case Magic('?'):
@@ -1240,9 +1238,9 @@ regatom(int *flagp)
c = no_Magic(c);
EMSG3_RET_NULL(_("E64: %s%c follows nothing"),
(c == '*' ? reg_magic >= MAGIC_ON : reg_magic == MAGIC_ALL), c);
- /* NOTREACHED */
+ // NOTREACHED
- case Magic('~'): /* previous substitute pattern */
+ case Magic('~'): // previous substitute pattern
if (reg_prev_sub != NULL)
{
char_u *lp;
@@ -1334,7 +1332,7 @@ regatom(int *flagp)
c = no_Magic(getchr());
switch (c)
{
- /* () without a back reference */
+ // () without a back reference
case '(':
if (one_exactly)
EMSG_ONE_RET_NULL;
@@ -1344,8 +1342,8 @@ regatom(int *flagp)
*flagp |= flags & (HASWIDTH | SPSTART | HASNL | HASLOOKBH);
break;
- /* Catch \%^ and \%$ regardless of where they appear in the
- * pattern -- regardless of whether or not it makes sense. */
+ // Catch \%^ and \%$ regardless of where they appear in the
+ // pattern -- regardless of whether or not it makes sense.
case '^':
ret = regnode(RE_BOF);
break;
@@ -1366,10 +1364,10 @@ regatom(int *flagp)
ret = regnode(RE_COMPOSING);
break;
- /* \%[abc]: Emit as a list of branches, all ending at the last
- * branch which matches nothing. */
+ // \%[abc]: Emit as a list of branches, all ending at the last
+ // branch which matches nothing.
case '[':
- if (one_exactly) /* doesn't nest */
+ if (one_exactly) // doesn't nest
EMSG_ONE_RET_NULL;
{
char_u *lastbranch;
@@ -1408,8 +1406,8 @@ regatom(int *flagp)
{
regtail(lastnode, br);
regtail(lastbranch, br);
- /* connect all branches to the NOTHING
- * branch at the end */
+ // connect all branches to the NOTHING
+ // branch at the end
for (br = ret; br != lastnode; )
{
if (OP(br) == BRANCH)
@@ -1427,11 +1425,11 @@ regatom(int *flagp)
break;
}
- case 'd': /* %d123 decimal */
- case 'o': /* %o123 octal */
- case 'x': /* %xab hex 2 */
- case 'u': /* %uabcd hex 4 */
- case 'U': /* %U1234abcd hex 8 */
+ case 'd': // %d123 decimal
+ case 'o': // %o123 octal
+ case 'x': // %xab hex 2
+ case 'u': // %uabcd hex 4
+ case 'U': // %U1234abcd hex 8
{
long i;
@@ -1479,7 +1477,7 @@ regatom(int *flagp)
}
if (c == '\'' && n == 0)
{
- /* "\%'m", "\%<'m" and "\%>'m": Mark */
+ // "\%'m", "\%<'m" and "\%>'m": Mark
c = getchr();
ret = regnode(RE_MARK);
if (ret == JUST_CALC_SIZE)
@@ -1507,8 +1505,8 @@ regatom(int *flagp)
regsize += 5;
else
{
- /* put the number and the optional
- * comparator after the opcode */
+ // put the number and the optional
+ // comparator after the opcode
regcode = re_put_long(regcode, n);
*regcode++ = cmp;
}
@@ -1527,21 +1525,17 @@ collection:
{
char_u *lp;
- /*
- * If there is no matching ']', we assume the '[' is a normal
- * character. This makes 'incsearch' and ":help [" work.
- */
+ // If there is no matching ']', we assume the '[' is a normal
+ // character. This makes 'incsearch' and ":help [" work.
lp = skip_anyof(regparse);
- if (*lp == ']') /* there is a matching ']' */
+ if (*lp == ']') // there is a matching ']'
{
- int startc = -1; /* > 0 when next '-' is a range */
+ int startc = -1; // > 0 when next '-' is a range
int endc;
- /*
- * In a character class, different parsing rules apply.
- * Not even \ is special anymore, nothing is.
- */
- if (*regparse == '^') /* Complement of range. */
+ // In a character class, different parsing rules apply.
+ // Not even \ is special anymore, nothing is.
+ if (*regparse == '^') // Complement of range.
{
ret = regnode(ANYBUT + extra);
regparse++;
@@ -1549,7 +1543,7 @@ collection:
else
ret = regnode(ANYOF + extra);
- /* At the start ']' and '-' mean the literal character. */
+ // At the start ']' and '-' mean the literal character.
if (*regparse == ']' || *regparse == '-')
{
startc = *regparse;
@@ -1561,18 +1555,18 @@ collection:
if (*regparse == '-')
{
++regparse;
- /* The '-' is not used for a range at the end and
- * after or before a '\n'. */
+ // The '-' is not used for a range at the end and
+ // after or before a '\n'.
if (*regparse == ']' || *regparse == NUL
|| startc == -1
|| (regparse[0] == '\\' && regparse[1] == 'n'))
{
regc('-');
- startc = '-'; /* [--x] is a range */
+ startc = '-'; // [--x] is a range
}
else
{
- /* Also accept "a-[.z.]" */
+ // Also accept "a-[.z.]"
endc = 0;
if (*regparse == '[')
endc = get_coll_element(&regparse);
@@ -1584,7 +1578,7 @@ collection:
endc = *regparse++;
}
- /* Handle \o40, \x20 and \u20AC style sequences */
+ // Handle \o40, \x20 and \u20AC style sequences
if (endc == '\\' && !reg_cpo_lit && !reg_cpo_bsl)
endc = coll_get_char();
@@ -1593,7 +1587,7 @@ collection:
if (has_mbyte && ((*mb_char2len)(startc) > 1
|| (*mb_char2len)(endc) > 1))
{
- /* Limit to a range of 256 chars. */
+ // Limit to a range of 256 chars.
if (endc > startc + 256)
EMSG_RET_NULL(_(e_large_class));
while (++startc <= endc)
@@ -1604,8 +1598,8 @@ collection:
#ifdef EBCDIC
int alpha_only = FALSE;
- /* for alphabetical range skip the gaps
- * 'i'-'j', 'r'-'s', 'I'-'J' and 'R'-'S'. */
+ // for alphabetical range skip the gaps
+ // 'i'-'j', 'r'-'s', 'I'-'J' and 'R'-'S'.
if (isalpha(startc) && isalpha(endc))
alpha_only = TRUE;
#endif
@@ -1618,12 +1612,10 @@ collection:
startc = -1;
}
}
- /*
- * Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
- * accepts "\t", "\e", etc., but only when the 'l' flag in
- * 'cpoptions' is not included.
- * Posix doesn't recognize backslash at all.
- */
+ // Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
+ // accepts "\t", "\e", etc., but only when the 'l' flag in
+ // 'cpoptions' is not included.
+ // Posix doesn't recognize backslash at all.
else if (*regparse == '\\'
&& !reg_cpo_bsl
&& (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
@@ -1634,17 +1626,17 @@ collection:
regparse++;
if (*regparse == 'n')
{
- /* '\n' in range: also match NL */
+ // '\n' in range: also match NL
if (ret != JUST_CALC_SIZE)
{
- /* Using \n inside [^] does not change what
- * matches. "[^\n]" is the same as ".". */
+ // Using \n inside [^] does not change what
+ // matches. "[^\n]" is the same as ".".
if (*ret == ANYOF)
{
*ret = ANYOF + ADD_NL;
*flagp |= HASNL;
}
- /* else: must have had a \n already */
+ // else: must have had a \n already
}
regparse++;
startc = -1;
@@ -1674,25 +1666,25 @@ collection:
c_class = get_char_class(&regparse);
startc = -1;
- /* Characters assumed to be 8 bits! */
+ // Characters assumed to be 8 bits!
switch (c_class)
{
case CLASS_NONE:
c_class = get_equi_class(&regparse);
if (c_class != 0)
{
- /* produce equivalence class */
+ // produce equivalence class
reg_equi_class(c_class);
}
else if ((c_class =
get_coll_element(&regparse)) != 0)
{
- /* produce a collating element */
+ // produce a collating element
regmbc(c_class);
}
else
{
- /* literal '[', allow [[-x] as a range */
+ // literal '[', allow [[-x] as a range
startc = *regparse++;
regc(startc);
}
@@ -1792,12 +1784,12 @@ collection:
{
int len;
- /* produce a multibyte character, including any
- * following composing characters */
+ // produce a multibyte character, including any
+ // following composing characters
startc = mb_ptr2char(regparse);
len = (*mb_ptr2len)(regparse);
if (enc_utf8 && utf_char2len(startc) != len)
- startc = -1; /* composing chars */
+ startc = -1; // composing chars
while (--len >= 0)
regc(*regparse++);
}
@@ -1809,24 +1801,24 @@ collection:
}
}
regc(NUL);
- prevchr_len = 1; /* last char was the ']' */
+ prevchr_len = 1; // last char was the ']'
if (*regparse != ']')
- EMSG_RET_NULL(_(e_toomsbra)); /* Cannot happen? */
- skipchr(); /* let's be friends with the lexer again */
+ EMSG_RET_NULL(_(e_toomsbra)); // Cannot happen?
+ skipchr(); // let's be friends with the lexer again
*flagp |= HASWIDTH | SIMPLE;
break;
}
else if (reg_strict)
EMSG2_RET_NULL(_(e_missingbracket), reg_magic > MAGIC_OFF);
}
- /* FALLTHROUGH */
+ // FALLTHROUGH
default:
{
int len;
- /* A multi-byte character is handled as a separate atom if it's
- * before a multi and when it's a composing char. */
+ // A multi-byte character is handled as a separate atom if it's
+ // before a multi and when it's a composing char.
if (use_multibytecode(c))
{
do_multibyte:
@@ -1838,15 +1830,13 @@ do_multibyte:
ret = regnode(EXACTLY);
- /*
- * Append characters as long as:
- * - there is no following multi, we then need the character in
- * front of it as a single character operand
- * - not running into a Magic character
- * - "one_exactly" is not set
- * But always emit at least one character. Might be a Multi,
- * e.g., a "[" without matching "]".
- */
+ // Append characters as long as:
+ // - there is no following multi, we then need the character in
+ // front of it as a single character operand
+ // - not running into a Magic character
+ // - "one_exactly" is not set
+ // But always emit at least one character. Might be a Multi,
+ // e.g., a "[" without matching "]".
for (len = 0; c != NUL && (len == 0
|| (re_multi_type(peekchr()) == NOT_MULTI
&& !one_exactly
@@ -1860,7 +1850,7 @@ do_multibyte:
{
int l;
- /* Need to get composing character too. */
+ // Need to get composing character too.
for (;;)
{
l = utf_ptr2len(regparse);
@@ -1917,7 +1907,7 @@ regpiece(int *flagp)
*flagp = flags;
return ret;
}
- /* default flags */
+ // default flags
*flagp = (WORST | SPSTART | (flags & (HASNL | HASLOOKBH)));
skipchr();
@@ -1928,12 +1918,12 @@ regpiece(int *flagp)
reginsert(STAR, ret);
else
{
- /* Emit x* as (x&|), where & means "self". */
- reginsert(BRANCH, ret); /* Either x */
- regoptail(ret, regnode(BACK)); /* and loop */
- regoptail(ret, ret); /* back */
- regtail(ret, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
+ // Emit x* as (x&|), where & means "self".
+ reginsert(BRANCH, ret); // Either x
+ regoptail(ret, regnode(BACK)); // and loop
+ regoptail(ret, ret); // back
+ regtail(ret, regnode(BRANCH)); // or
+ regtail(ret, regnode(NOTHING)); // null.
}
break;
@@ -1942,12 +1932,12 @@ regpiece(int *flagp)
reginsert(PLUS, ret);
else
{
- /* Emit x+ as x(&|), where & means "self". */
- next = regnode(BRANCH); /* Either */
+ // Emit x+ as x(&|), where & means "self".
+ next = regnode(BRANCH); // Either
regtail(ret, next);
- regtail(regnode(BACK), ret); /* loop back */
- regtail(next, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
+ regtail(regnode(BACK), ret); // loop back
+ regtail(next, regnode(BRANCH)); // or
+ regtail(ret, regnode(NOTHING)); // null.
}
*flagp = (WORST | HASWIDTH | (flags & (HASNL | HASLOOKBH)));
break;
@@ -1960,29 +1950,29 @@ regpiece(int *flagp)
nr = getdecchrs();
switch (no_Magic(getchr()))
{
- case '=': lop = MATCH; break; /* \@= */
- case '!': lop = NOMATCH; break; /* \@! */
- case '>': lop = SUBPAT; break; /* \@> */
+ case '=': lop = MATCH; break; // \@=
+ case '!': lop = NOMATCH; break; // \@!
+ case '>': lop = SUBPAT; break; // \@>
case '<': switch (no_Magic(getchr()))
{
- case '=': lop = BEHIND; break; /* \@<= */
- case '!': lop = NOBEHIND; break; /* \@<! */
+ case '=': lop = BEHIND; break; // \@<=
+ case '!': lop = NOBEHIND; break; // \@<!
}
}
if (lop == END)
EMSG2_RET_NULL(_("E59: invalid character after %s@"),
reg_magic == MAGIC_ALL);
- /* Look behind must match with behind_pos. */
+ // Look behind must match with behind_pos.
if (lop == BEHIND || lop == NOBEHIND)
{
regtail(ret, regnode(BHPOS));
*flagp |= HASLOOKBH;
}
- regtail(ret, regnode(END)); /* operand ends */
+ regtail(ret, regnode(END)); // operand ends
if (lop == BEHIND || lop == NOBEHIND)
{
if (nr < 0)
- nr = 0; /* no limit is same as zero limit */
+ nr = 0; // no limit is same as zero limit
reginsert_nr(lop, nr, ret);
}
else
@@ -1992,10 +1982,10 @@ regpiece(int *flagp)
case Magic('?'):
case Magic('='):
- /* Emit x= as (x|) */
- reginsert(BRANCH, ret); /* Either x */
- regtail(ret, regnode(BRANCH)); /* or */
- next = regnode(NOTHING); /* null. */
+ // Emit x= as (x|)
+ reginsert(BRANCH, ret); // Either x
+ regtail(ret, regnode(BRANCH)); // or
+ next = regnode(NOTHING); // null.
regtail(ret, next);
regoptail(ret, next);
break;
@@ -2048,7 +2038,7 @@ regconcat(int *flagp)
int flags;
int cont = TRUE;
- *flagp = WORST; /* Tentatively. */
+ *flagp = WORST; // Tentatively.
while (cont)
{
@@ -2097,7 +2087,7 @@ regconcat(int *flagp)
if (latest == NULL || reg_toolong)
return NULL;
*flagp |= flags & (HASWIDTH | HASNL | HASLOOKBH);
- if (chain == NULL) /* First piece. */
+ if (chain == NULL) // First piece.
*flagp |= flags & SPSTART;
else
regtail(chain, latest);
@@ -2107,7 +2097,7 @@ regconcat(int *flagp)
break;
}
}
- if (first == NULL) /* Loop ran zero times. */
+ if (first == NULL) // Loop ran zero times.
first = regnode(NOTHING);
return first;
}
@@ -2124,7 +2114,7 @@ regbranch(int *flagp)
char_u *latest;
int flags;
- *flagp = WORST | HASNL; /* Tentatively. */
+ *flagp = WORST | HASNL; // Tentatively.
ret = regnode(BRANCH);
for (;;)
@@ -2132,19 +2122,19 @@ regbranch(int *flagp)
latest = regconcat(&flags);
if (latest == NULL)
return NULL;
- /* If one of the branches has width, the whole thing has. If one of
- * the branches anchors at start-of-line, the whole thing does.
- * If one of the branches uses look-behind, the whole thing does. */
+ // If one of the branches has width, the whole thing has. If one of
+ // the branches anchors at start-of-line, the whole thing does.
+ // If one of the branches uses look-behind, the whole thing does.
*flagp |= flags & (HASWIDTH | SPSTART | HASLOOKBH);
- /* If one of the branches doesn't match a line-break, the whole thing
- * doesn't. */
+ // If one of the branches doesn't match a line-break, the whole thing
+ // doesn't.
*flagp &= ~HASNL | (flags & HASNL);
if (chain != NULL)
regtail(chain, latest);
if (peekchr() != Magic('&'))
break;
skipchr();
- regtail(latest, regn