summaryrefslogtreecommitdiff
path: root/src/regexp.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-05 21:10:38 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-05 21:10:38 +0100
commit63d9e730f726341bf41ee4f4b829253cb9879110 (patch)
tree02d6ed210385b78f06d7df1e30ede7d48f718600 /src/regexp.c
parent0f8737355d291679659579a48db1861b88970293 (diff)
downloadvim-git-63d9e730f726341bf41ee4f4b829253cb9879110.tar.gz
patch 8.1.2394: using old C style commentsv8.1.2394
Problem: Using old C style comments. Solution: Use // comments where appropriate.
Diffstat (limited to 'src/regexp.c')
-rw-r--r--src/regexp.c504
1 files changed, 252 insertions, 252 deletions
diff --git a/src/regexp.c b/src/regexp.c
index 7fe891d31..112f75369 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -12,9 +12,9 @@
#include "vim.h"
#ifdef DEBUG
-/* show/save debugging data when BT engine is used */
+// show/save debugging data when BT engine is used
# define BT_REGEXP_DUMP
-/* save the debugging data to a file instead of displaying it */
+// save the debugging data to a file instead of displaying it
# define BT_REGEXP_LOG
# define BT_REGEXP_DEBUG_LOG
# define BT_REGEXP_DEBUG_LOG_NAME "bt_regexp_debug.log"
@@ -58,8 +58,8 @@ toggle_Magic(int x)
*/
#define UCHARAT(p) ((int)*(char_u *)(p))
-/* Used for an error (down from) vim_regcomp(): give the error message, set
- * rc_did_emsg and return NULL */
+// Used for an error (down from) vim_regcomp(): give the error message, set
+// rc_did_emsg and return NULL
#define EMSG_RET_NULL(m) return (emsg((m)), rc_did_emsg = TRUE, (void *)NULL)
#define IEMSG_RET_NULL(m) return (iemsg((m)), rc_did_emsg = TRUE, (void *)NULL)
#define EMSG_RET_FAIL(m) return (emsg((m)), rc_did_emsg = TRUE, FAIL)
@@ -90,11 +90,11 @@ static char_u e_recursive[] = N_("E956: Cannot use pattern recursively");
#define MULTI_MULT 2
// return values for regmatch()
-#define RA_FAIL 1 /* something failed, abort */
-#define RA_CONT 2 /* continue in inner loop */
-#define RA_BREAK 3 /* break inner loop */
-#define RA_MATCH 4 /* successful match */
-#define RA_NOMATCH 5 /* didn't match */
+#define RA_FAIL 1 // something failed, abort
+#define RA_CONT 2 // continue in inner loop
+#define RA_BREAK 3 // break inner loop
+#define RA_MATCH 4 // successful match
+#define RA_NOMATCH 5 // didn't match
/*
* Return NOT_MULTI if c is not a "multi" operator.
@@ -281,37 +281,37 @@ init_class_tab(void)
#define ri_upper(c) (c < 0x100 && (class_tab[c] & RI_UPPER))
#define ri_white(c) (c < 0x100 && (class_tab[c] & RI_WHITE))
-/* flags for regflags */
-#define RF_ICASE 1 /* ignore case */
-#define RF_NOICASE 2 /* don't ignore case */
-#define RF_HASNL 4 /* can match a NL */
-#define RF_ICOMBINE 8 /* ignore combining characters */
-#define RF_LOOKBH 16 /* uses "\@<=" or "\@<!" */
+// flags for regflags
+#define RF_ICASE 1 // ignore case
+#define RF_NOICASE 2 // don't ignore case
+#define RF_HASNL 4 // can match a NL
+#define RF_ICOMBINE 8 // ignore combining characters
+#define RF_LOOKBH 16 // uses "\@<=" or "\@<!"
/*
* Global work variables for vim_regcomp().
*/
-static char_u *regparse; /* Input-scan pointer. */
-static int regnpar; /* () count. */
+static char_u *regparse; // Input-scan pointer.
+static int regnpar; // () count.
#ifdef FEAT_SYN_HL
-static int regnzpar; /* \z() count. */
-static int re_has_z; /* \z item detected */
+static int regnzpar; // \z() count.
+static int re_has_z; // \z item detected
#endif
-static unsigned regflags; /* RF_ flags for prog */
+static unsigned regflags; // RF_ flags for prog
#if defined(FEAT_SYN_HL) || defined(PROTO)
-static int had_eol; /* TRUE when EOL found by vim_regcomp() */
+static int had_eol; // TRUE when EOL found by vim_regcomp()
#endif
-static int reg_magic; /* magicness of the pattern: */
-#define MAGIC_NONE 1 /* "\V" very unmagic */
-#define MAGIC_OFF 2 /* "\M" or 'magic' off */
-#define MAGIC_ON 3 /* "\m" or 'magic' */
-#define MAGIC_ALL 4 /* "\v" very magic */
+static int reg_magic; // magicness of the pattern:
+#define MAGIC_NONE 1 // "\V" very unmagic
+#define MAGIC_OFF 2 // "\M" or 'magic' off
+#define MAGIC_ON 3 // "\m" or 'magic'
+#define MAGIC_ALL 4 // "\v" very magic
-static int reg_string; /* matching with a string instead of a buffer
- line */
-static int reg_strict; /* "[abc" is illegal */
+static int reg_string; // matching with a string instead of a buffer
+ // line
+static int reg_strict; // "[abc" is illegal
/*
* META contains all characters that may be magic, except '^' and '$'.
@@ -320,38 +320,38 @@ static int reg_strict; /* "[abc" is illegal */
#ifdef EBCDIC
static char_u META[] = "%&()*+.123456789<=>?@ACDFHIKLMOPSUVWX[_acdfhiklmnopsuvwxz{|~";
#else
-/* META[] is used often enough to justify turning it into a table. */
+// META[] is used often enough to justify turning it into a table.
static char_u META_flags[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* % & ( ) * + . */
+// % & ( ) * + .
0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0,
-/* 1 2 3 4 5 6 7 8 9 < = > ? */
+// 1 2 3 4 5 6 7 8 9 < = > ?
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1,
-/* @ A C D F H I K L M O */
+// @ A C D F H I K L M O
1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1,
-/* P S U V W X Z [ _ */
+// P S U V W X Z [ _
1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1,
-/* a c d f h i k l m n o */
+// a c d f h i k l m n o
0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
-/* p s u v w x z { | ~ */
+// p s u v w x z { | ~
1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1
};
#endif
-static int curchr; /* currently parsed character */
-/* Previous character. Note: prevchr is sometimes -1 when we are not at the
- * start, eg in /[ ^I]^ the pattern was never found even if it existed,
- * because ^ was taken to be magic -- webb */
+static int curchr; // currently parsed character
+// Previous character. Note: prevchr is sometimes -1 when we are not at the
+// start, eg in /[ ^I]^ the pattern was never found even if it existed,
+// because ^ was taken to be magic -- webb
static int prevchr;
-static int prevprevchr; /* previous-previous character */
-static int nextchr; /* used for ungetchr() */
+static int prevprevchr; // previous-previous character
+static int nextchr; // used for ungetchr()
-/* arguments for reg() */
-#define REG_NOPAREN 0 /* toplevel reg() */
-#define REG_PAREN 1 /* \(\) */
-#define REG_ZPAREN 2 /* \z(\) */
-#define REG_NPAREN 3 /* \%(\) */
+// arguments for reg()
+#define REG_NOPAREN 0 // toplevel reg()
+#define REG_PAREN 1 // \(\)
+#define REG_ZPAREN 2 // \z(\)
+#define REG_NPAREN 3 // \%(\)
typedef struct
{
@@ -477,8 +477,8 @@ get_coll_element(char_u **pp)
return 0;
}
-static int reg_cpo_lit; /* 'cpoptions' contains 'l' flag */
-static int reg_cpo_bsl; /* 'cpoptions' contains '\' flag */
+static int reg_cpo_lit; // 'cpoptions' contains 'l' flag
+static int reg_cpo_bsl; // 'cpoptions' contains '\' flag
static void
get_cpo_flags(void)
@@ -497,7 +497,7 @@ skip_anyof(char_u *p)
{
int l;
- if (*p == '^') /* Complement of range. */
+ if (*p == '^') // Complement of range.
++p;
if (*p == ']' || *p == '-')
++p;
@@ -523,7 +523,7 @@ skip_anyof(char_u *p)
&& get_equi_class(&p) == 0
&& get_coll_element(&p) == 0
&& *p != NUL)
- ++p; /* it is not a class name and not NUL */
+ ++p; // it is not a class name and not NUL
}
else
++p;
@@ -559,7 +559,7 @@ skip_regexp(
for (; p[0] != NUL; MB_PTR_ADV(p))
{
- if (p[0] == dirc) /* found end of regexp */
+ if (p[0] == dirc) // found end of regexp
break;
if ((p[0] == '[' && mymagic >= MAGIC_ON)
|| (p[0] == '\\' && p[1] == '[' && mymagic <= MAGIC_OFF))
@@ -572,7 +572,7 @@ skip_regexp(
{
if (dirc == '?' && newp != NULL && p[1] == '?')
{
- /* change "\?" to "?", make a copy first. */
+ // change "\?" to "?", make a copy first.
if (*newp == NULL)
{
*newp = vim_strsave(startp);
@@ -585,7 +585,7 @@ skip_regexp(
++p;
}
else
- ++p; /* skip next character */
+ ++p; // skip next character
if (*p == 'v')
mymagic = MAGIC_ALL;
else if (*p == 'V')
@@ -598,7 +598,7 @@ skip_regexp(
/*
* Functions for getting characters from the regexp input.
*/
-static int prevchr_len; /* byte length of previous char */
+static int prevchr_len; // byte length of previous char
static int at_start; // True when on the first character
static int prev_at_start; // True when on the second character
@@ -666,7 +666,7 @@ peekchr(void)
case '.':
case '[':
case '~':
- /* magic when 'magic' is on */
+ // magic when 'magic' is on
if (reg_magic >= MAGIC_ON)
curchr = Magic(curchr);
break;
@@ -683,23 +683,23 @@ peekchr(void)
case '|':
case '<':
case '>':
- case '#': /* future ext. */
- case '"': /* future ext. */
- case '\'': /* future ext. */
- case ',': /* future ext. */
- case '-': /* future ext. */
- case ':': /* future ext. */
- case ';': /* future ext. */
- case '`': /* future ext. */
- case '/': /* Can't be used in / command */
- /* magic only after "\v" */
+ case '#': // future ext.
+ case '"': // future ext.
+ case '\'': // future ext.
+ case ',': // future ext.
+ case '-': // future ext.
+ case ':': // future ext.
+ case ';': // future ext.
+ case '`': // future ext.
+ case '/': // Can't be used in / command
+ // magic only after "\v"
if (reg_magic == MAGIC_ALL)
curchr = Magic(curchr);
break;
case '*':
- /* * is not magic as the very first character, eg "?*ptr", when
- * after '^', eg "/^*ptr" and when after "\(", "\|", "\&". But
- * "\(\*" is not magic, thus must be magic if "after_slash" */
+ // * is not magic as the very first character, eg "?*ptr", when
+ // after '^', eg "/^*ptr" and when after "\(", "\|", "\&". But
+ // "\(\*" is not magic, thus must be magic if "after_slash"
if (reg_magic >= MAGIC_ON
&& !at_start
&& !(prev_at_start && prevchr == Magic('^'))
@@ -710,8 +710,8 @@ peekchr(void)
curchr = Magic('*');
break;
case '^':
- /* '^' is only magic as the very first character and if it's after
- * "\(", "\|", "\&' or "\n" */
+ // '^' is only magic as the very first character and if it's after
+ // "\(", "\|", "\&' or "\n"
if (reg_magic >= MAGIC_OFF
&& (at_start
|| reg_magic == MAGIC_ALL
@@ -728,14 +728,14 @@ peekchr(void)
}
break;
case '$':
- /* '$' is only magic as the very last char and if it's in front of
- * either "\|", "\)", "\&", or "\n" */
+ // '$' is only magic as the very last char and if it's in front of
+ // either "\|", "\)", "\&", or "\n"
if (reg_magic >= MAGIC_OFF)
{
char_u *p = regparse + 1;
int is_magic_all = (reg_magic == MAGIC_ALL);
- /* ignore \c \C \m \M \v \V and \Z after '$' */
+ // ignore \c \C \m \M \v \V and \Z after '$'
while (p[0] == '\\' && (p[1] == 'c' || p[1] == 'C'
|| p[1] == 'm' || p[1] == 'M'
|| p[1] == 'v' || p[1] == 'V' || p[1] == 'Z'))
@@ -761,7 +761,7 @@ peekchr(void)
int c = regparse[1];
if (c == NUL)
- curchr = '\\'; /* trailing '\' */
+ curchr = '\\'; // trailing '\'
else if (
#ifdef EBCDIC
vim_strchr(META, c)
@@ -779,7 +779,7 @@ peekchr(void)
*/
curchr = -1;
prev_at_start = at_start;
- at_start = FALSE; /* be able to say "/\*ptr" */
+ at_start = FALSE; // be able to say "/\*ptr"
++regparse;
++after_slash;
peekchr();
@@ -825,7 +825,7 @@ peekchr(void)
static void
skipchr(void)
{
- /* peekchr() eats a backslash, do the same here */
+ // peekchr() eats a backslash, do the same here
if (*regparse == '\\')
prevchr_len = 1;
else
@@ -833,7 +833,7 @@ skipchr(void)
if (regparse[prevchr_len] != NUL)
{
if (enc_utf8)
- /* exclude composing chars that mb_ptr2len does include */
+ // exclude composing chars that mb_ptr2len does include
prevchr_len += utf_ptr2len(regparse + prevchr_len);
else if (has_mbyte)
prevchr_len += (*mb_ptr2len)(regparse + prevchr_len);
@@ -845,7 +845,7 @@ skipchr(void)
at_start = FALSE;
prevprevchr = prevchr;
prevchr = curchr;
- curchr = nextchr; /* use previously unget char, or -1 */
+ curchr = nextchr; // use previously unget char, or -1
nextchr = -1;
}
@@ -891,8 +891,8 @@ ungetchr(void)
at_start = prev_at_start;
prev_at_start = FALSE;
- /* Backup regparse, so that it's at the same position as before the
- * getchr(). */
+ // Backup regparse, so that it's at the same position as before the
+ // getchr().
regparse -= prevchr_len;
}
@@ -946,7 +946,7 @@ getdecchrs(void)
nr *= 10;
nr += c - '0';
++regparse;
- curchr = -1; /* no longer valid */
+ curchr = -1; // no longer valid
}
if (i == 0)
@@ -999,13 +999,13 @@ read_limits(long *minval, long *maxval)
if (*regparse == '-')
{
- /* Starts with '-', so reverse the range later */
+ // Starts with '-', so reverse the range later
regparse++;
reverse = TRUE;
}
first_char = regparse;
*minval = getdigits(&regparse);
- if (*regparse == ',') /* There is a comma */
+ if (*regparse == ',') // There is a comma
{
if (vim_isdigit(*++regparse))
*maxval = getdigits(&regparse);
@@ -1013,11 +1013,11 @@ read_limits(long *minval, long *maxval)
*maxval = MAX_LIMIT;
}
else if (VIM_ISDIGIT(*first_char))
- *maxval = *minval; /* It was \{n} or \{-n} */
+ *maxval = *minval; // It was \{n} or \{-n}
else
- *maxval = MAX_LIMIT; /* It was \{} or \{-} */
+ *maxval = MAX_LIMIT; // It was \{} or \{-}
if (*regparse == '\\')
- regparse++; /* Allow either \{...} or \{...\} */
+ regparse++; // Allow either \{...} or \{...\}
if (*regparse != '}')
EMSG2_RET_FAIL(_("E554: Syntax error in %s{...}"),
reg_magic == MAGIC_ALL);
@@ -1032,7 +1032,7 @@ read_limits(long *minval, long *maxval)
*minval = *maxval;
*maxval = tmp;
}
- skipchr(); /* let's be friends with the lexer again */
+ skipchr(); // let's be friends with the lexer again
return OK;
}
@@ -1087,7 +1087,7 @@ typedef struct {
buf_T *reg_buf;
linenr_T reg_firstlnum;
linenr_T reg_maxline;
- int reg_line_lbr; /* "\n" in string is line break */
+ int reg_line_lbr; // "\n" in string is line break
// The current match-position is stord in these variables:
linenr_T lnum; // line number, relative to first line
@@ -1100,17 +1100,17 @@ typedef struct {
// cleared
#endif
- /* Internal copy of 'ignorecase'. It is set at each call to vim_regexec().
- * Normally it gets the value of "rm_ic" or "rmm_ic", but when the pattern
- * contains '\c' or '\C' the value is overruled. */
+ // Internal copy of 'ignorecase'. It is set at each call to vim_regexec().
+ // Normally it gets the value of "rm_ic" or "rmm_ic", but when the pattern
+ // contains '\c' or '\C' the value is overruled.
int reg_ic;
- /* Similar to "reg_ic", but only for 'combining' characters. Set with \Z
- * flag in the regexp. Defaults to false, always. */
+ // Similar to "reg_ic", but only for 'combining' characters. Set with \Z
+ // flag in the regexp. Defaults to false, always.
int reg_icombine;
- /* Copy of "rmm_maxcol": maximum column to search for a match. Zero when
- * there is no maximum. */
+ // Copy of "rmm_maxcol": maximum column to search for a match. Zero when
+ // there is no maximum.
colnr_T reg_maxcol;
// State for the NFA engine regexec.
@@ -1149,24 +1149,24 @@ reg_iswordc(int c)
static char_u *
reg_getline(linenr_T lnum)
{
- /* when looking behind for a match/no-match lnum is negative. But we
- * can't go before line 1 */
+ // when looking behind for a match/no-match lnum is negative. But we
+ // can't go before line 1
if (rex.reg_firstlnum + lnum < 1)
return NULL;
if (lnum > rex.reg_maxline)
- /* Must have matched the "\n" in the last line. */
+ // Must have matched the "\n" in the last line.
return (char_u *)"";
return ml_get_buf(rex.reg_buf, rex.reg_firstlnum + lnum, FALSE);
}
#ifdef FEAT_SYN_HL
-static char_u *reg_startzp[NSUBEXP]; /* Workspace to mark beginning */
-static char_u *reg_endzp[NSUBEXP]; /* and end of \z(...\) matches */
-static lpos_T reg_startzpos[NSUBEXP]; /* idem, beginning pos */
-static lpos_T reg_endzpos[NSUBEXP]; /* idem, end pos */
+static char_u *reg_startzp[NSUBEXP]; // Workspace to mark beginning
+static char_u *reg_endzp[NSUBEXP]; // and end of \z(...\) matches
+static lpos_T reg_startzpos[NSUBEXP]; // idem, beginning pos
+static lpos_T reg_endzpos[NSUBEXP]; // idem, end pos
#endif
-/* TRUE if using multi-line regexp. */
+// TRUE if using multi-line regexp.
#define REG_MULTI (rex.reg_match == NULL)
#ifdef FEAT_SYN_HL
@@ -1240,7 +1240,7 @@ reg_match_visual(void)
colnr_T start2, end2;
colnr_T cols;
- /* Check if the buffer is the current buffer. */
+ // Check if the buffer is the current buffer.
if (rex.reg_buf != curbuf || VIsual.lnum == 0)
return FALSE;
@@ -1311,7 +1311,7 @@ prog_magic_wrong(void)
prog = REG_MULTI ? rex.reg_mmatch->regprog : rex.reg_match->regprog;
if (prog->engine == &nfa_regengine)
- /* For NFA matcher we don't check the magic */
+ // For NFA matcher we don't check the magic
return FALSE;
if (UCHARAT(((bt_regprog_T *)prog)->program) != REGMAGIC)
@@ -1334,7 +1334,7 @@ cleanup_subexpr(void)
{
if (REG_MULTI)
{
- /* Use 0xff to set lnum to -1 */
+ // Use 0xff to set lnum to -1
vim_memset(rex.reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP);
vim_memset(rex.reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP);
}
@@ -1355,7 +1355,7 @@ cleanup_zsubexpr(void)
{
if (REG_MULTI)
{
- /* Use 0xff to set lnum to -1 */
+ // Use 0xff to set lnum to -1
vim_memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
vim_memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
}
@@ -1403,18 +1403,18 @@ match_with_backref(
*bytelen = 0;
for (;;)
{
- /* Since getting one line may invalidate the other, need to make copy.
- * Slow! */
+ // Since getting one line may invalidate the other, need to make copy.
+ // Slow!
if (rex.line != reg_tofree)
{
len = (int)STRLEN(rex.line);
if (reg_tofree == NULL || len >= (int)reg_tofreelen)
{
- len += 50; /* get some extra */
+ len += 50; // get some extra
vim_free(reg_tofree);
reg_tofree = alloc(len);
if (reg_tofree == NULL)
- return RA_FAIL; /* out of memory!*/
+ return RA_FAIL; // out of memory!
reg_tofreelen = len;
}
STRCPY(reg_tofree, rex.line);
@@ -1422,7 +1422,7 @@ match_with_backref(
rex.line = reg_tofree;
}
- /* Get the line to compare with. */
+ // Get the line to compare with.
p = reg_getline(clnum);
if (clnum == end_lnum)
len = end_col - ccol;
@@ -1430,15 +1430,15 @@ match_with_backref(
len = (int)STRLEN(p + ccol);
if (cstrncmp(p + ccol, rex.input, &len) != 0)
- return RA_NOMATCH; /* doesn't match */
+ return RA_NOMATCH; // doesn't match
if (bytelen != NULL)
*bytelen += len;
if (clnum == end_lnum)
- break; /* match and at end! */
+ break; // match and at end!
if (rex.lnum >= rex.reg_maxline)
- return RA_NOMATCH; /* text too short */
+ return RA_NOMATCH; // text too short
- /* Advance to next line. */
+ // Advance to next line.
reg_nextline();
if (bytelen != NULL)
*bytelen = 0;
@@ -1448,8 +1448,8 @@ match_with_backref(
return RA_FAIL;
}
- /* found a match! Note that rex.line may now point to a copy of the line,
- * that should not matter. */
+ // found a match! Note that rex.line may now point to a copy of the line,
+ // that should not matter.
return RA_MATCH;
}
@@ -1474,57 +1474,57 @@ typedef struct
} decomp_T;
-/* 0xfb20 - 0xfb4f */
+// 0xfb20 - 0xfb4f
static decomp_T decomp_table[0xfb4f-0xfb20+1] =
{
- {0x5e2,0,0}, /* 0xfb20 alt ayin */
- {0x5d0,0,0}, /* 0xfb21 alt alef */
- {0x5d3,0,0}, /* 0xfb22 alt dalet */
- {0x5d4,0,0}, /* 0xfb23 alt he */
- {0x5db,0,0}, /* 0xfb24 alt kaf */
- {0x5dc,0,0}, /* 0xfb25 alt lamed */
- {0x5dd,0,0}, /* 0xfb26 alt mem-sofit */
- {0x5e8,0,0}, /* 0xfb27 alt resh */
- {0x5ea,0,0}, /* 0xfb28 alt tav */
- {'+', 0, 0}, /* 0xfb29 alt plus */
- {0x5e9, 0x5c1, 0}, /* 0xfb2a shin+shin-dot */
- {0x5e9, 0x5c2, 0}, /* 0xfb2b shin+sin-dot */
- {0x5e9, 0x5c1, 0x5bc}, /* 0xfb2c shin+shin-dot+dagesh */
- {0x5e9, 0x5c2, 0x5bc}, /* 0xfb2d shin+sin-dot+dagesh */
- {0x5d0, 0x5b7, 0}, /* 0xfb2e alef+patah */
- {0x5d0, 0x5b8, 0}, /* 0xfb2f alef+qamats */
- {0x5d0, 0x5b4, 0}, /* 0xfb30 alef+hiriq */
- {0x5d1, 0x5bc, 0}, /* 0xfb31 bet+dagesh */
- {0x5d2, 0x5bc, 0}, /* 0xfb32 gimel+dagesh */
- {0x5d3, 0x5bc, 0}, /* 0xfb33 dalet+dagesh */
- {0x5d4, 0x5bc, 0}, /* 0xfb34 he+dagesh */
- {0x5d5, 0x5bc, 0}, /* 0xfb35 vav+dagesh */
- {0x5d6, 0x5bc, 0}, /* 0xfb36 zayin+dagesh */
- {0xfb37, 0, 0}, /* 0xfb37 -- UNUSED */
- {0x5d8, 0x5bc, 0}, /* 0xfb38 tet+dagesh */
- {0x5d9, 0x5bc, 0}, /* 0xfb39 yud+dagesh */
- {0x5da, 0x5bc, 0}, /* 0xfb3a kaf sofit+dagesh */
- {0x5db, 0x5bc, 0}, /* 0xfb3b kaf+dagesh */
- {0x5dc, 0x5bc, 0}, /* 0xfb3c lamed+dagesh */
- {0xfb3d, 0, 0}, /* 0xfb3d -- UNUSED */
- {0x5de, 0x5bc, 0}, /* 0xfb3e mem+dagesh */
- {0xfb3f, 0, 0}, /* 0xfb3f -- UNUSED */
- {0x5e0, 0x5bc, 0}, /* 0xfb40 nun+dagesh */
- {0x5e1, 0x5bc, 0}, /* 0xfb41 samech+dagesh */
- {0xfb42, 0, 0}, /* 0xfb42 -- UNUSED */
- {0x5e3, 0x5bc, 0}, /* 0xfb43 pe sofit+dagesh */
- {0x5e4, 0x5bc,0}, /* 0xfb44 pe+dagesh */
- {0xfb45, 0, 0}, /* 0xfb45 -- UNUSED */
- {0x5e6, 0x5bc, 0}, /* 0xfb46 tsadi+dagesh */
- {0x5e7, 0x5bc, 0}, /* 0xfb47 qof+dagesh */
- {0x5e8, 0x5bc, 0}, /* 0xfb48 resh+dagesh */
- {0x5e9, 0x5bc, 0}, /* 0xfb49 shin+dagesh */
- {0x5ea, 0x5bc, 0}, /* 0xfb4a tav+dagesh */
- {0x5d5, 0x5b9, 0}, /* 0xfb4b vav+holam */
- {0x5d1, 0x5bf, 0}, /* 0xfb4c bet+rafe */
- {0x5db, 0x5bf, 0}, /* 0xfb4d kaf+rafe */
- {0x5e4, 0x5bf, 0}, /* 0xfb4e pe+rafe */
- {0x5d0, 0x5dc, 0} /* 0xfb4f alef-lamed */
+ {0x5e2,0,0}, // 0xfb20 alt ayin
+ {0x5d0,0,0}, // 0xfb21 alt alef
+ {0x5d3,0,0}, // 0xfb22 alt dalet
+ {0x5d4,0,0}, // 0xfb23 alt he
+ {0x5db,0,0}, // 0xfb24 alt kaf
+ {0x5dc,0,0}, // 0xfb25 alt lamed
+ {0x5dd,0,0}, // 0xfb26 alt mem-sofit
+ {0x5e8,0,0}, // 0xfb27 alt resh
+ {0x5ea,0,0}, // 0xfb28 alt tav
+ {'+', 0, 0}, // 0xfb29 alt plus
+ {0x5e9, 0x5c1, 0}, // 0xfb2a shin+shin-dot
+ {0x5e9, 0x5c2, 0}, // 0xfb2b shin+sin-dot
+ {0x5e9, 0x5c1, 0x5bc}, // 0xfb2c shin+shin-dot+dagesh
+ {0x5e9, 0x5c2, 0x5bc}, // 0xfb2d shin+sin-dot+dagesh
+ {0x5d0, 0x5b7, 0}, // 0xfb2e alef+patah
+ {0x5d0, 0x5b8, 0}, // 0xfb2f alef+qamats
+ {0x5d0, 0x5b4, 0}, // 0xfb30 alef+hiriq
+ {0x5d1, 0x5bc, 0}, // 0xfb31 bet+dagesh
+ {0x5d2, 0x5bc, 0}, // 0xfb32 gimel+dagesh
+ {0x5d3, 0x5bc, 0}, // 0xfb33 dalet+dagesh
+ {0x5d4, 0x5bc, 0}, // 0xfb34 he+dagesh
+ {0x5d5, 0x5bc, 0}, // 0xfb35 vav+dagesh
+ {0x5d6, 0x5bc, 0}, // 0xfb36 zayin+dagesh
+ {0xfb37, 0, 0}, // 0xfb37 -- UNUSED
+ {0x5d8, 0x5bc, 0}, // 0xfb38 tet+dagesh
+ {0x5d9, 0x5bc, 0}, // 0xfb39 yud+dagesh
+ {0x5da, 0x5bc, 0}, // 0xfb3a kaf sofit+dagesh
+ {0x5db, 0x5bc, 0}, // 0xfb3b kaf+dagesh
+ {0x5dc, 0x5bc, 0}, // 0xfb3c lamed+dagesh
+ {0xfb3d, 0, 0}, // 0xfb3d -- UNUSED
+ {0x5de, 0x5bc, 0}, // 0xfb3e mem+dagesh
+ {0xfb3f, 0, 0}, // 0xfb3f -- UNUSED
+ {0x5e0, 0x5bc, 0}, // 0xfb40 nun+dagesh
+ {0x5e1, 0x5bc, 0}, // 0xfb41 samech+dagesh
+ {0xfb42, 0, 0}, // 0xfb42 -- UNUSED
+ {0x5e3, 0x5bc, 0}, // 0xfb43 pe sofit+dagesh
+ {0x5e4, 0x5bc,0}, // 0xfb44 pe+dagesh
+ {0xfb45, 0, 0}, // 0xfb45 -- UNUSED
+ {0x5e6, 0x5bc, 0}, // 0xfb46 tsadi+dagesh
+ {0x5e7, 0x5bc, 0}, // 0xfb47 qof+dagesh
+ {0x5e8, 0x5bc, 0}, // 0xfb48 resh+dagesh
+ {0x5e9, 0x5bc, 0}, // 0xfb49 shin+dagesh
+ {0x5ea, 0x5bc, 0}, // 0xfb4a tav+dagesh
+ {0x5d5, 0x5b9, 0}, // 0xfb4b vav+holam
+ {0x5d1, 0x5bf, 0}, // 0xfb4c bet+rafe
+ {0x5db, 0x5bf, 0}, // 0xfb4d kaf+rafe
+ {0x5e4, 0x5bf, 0}, // 0xfb4e pe+rafe
+ {0x5d0, 0x5dc, 0} // 0xfb4f alef-lamed
};
static void
@@ -1561,15 +1561,15 @@ cstrncmp(char_u *s1, char_u *s2, int *n)
else
result = MB_STRNICMP(s1, s2, *n);
- /* if it failed and it's utf8 and we want to combineignore: */
+ // if it failed and it's utf8 and we want to combineignore:
if (result != 0 && enc_utf8 && rex.reg_icombine)
{
char_u *str1, *str2;
int c1, c2, c11, c12;
int junk;
- /* we have to handle the strcmp ourselves, since it is necessary to
- * deal with the composing characters by ignoring them: */
+ // we have to handle the strcmp ourselves, since it is necessary to
+ // deal with the composing characters by ignoring them:
str1 = s1;
str2 = s2;
c1 = c2 = 0;
@@ -1612,9 +1612,9 @@ cstrchr(char_u *s, int c)
if (!rex.reg_ic || (!enc_utf8 && mb_char2len(c) > 1))
return vim_strchr(s, c);
- /* tolower() and toupper() can be slow, comparing twice should be a lot
- * faster (esp. when using MS Visual C++!).
- * For UTF-8 need to use folded case. */
+ // tolower() and toupper() can be slow, comparing twice should be a lot
+ // faster (esp. when using MS Visual C++!).
+ // For UTF-8 need to use folded case.
if (enc_utf8 && c > 0x80)
cc = utf_fold(c);
else
@@ -1639,7 +1639,7 @@ cstrchr(char_u *s, int c)
}
}
else
- /* Faster version for when there are no multi-byte characters. */
+ // Faster version for when there are no multi-byte characters.
for (p = s; *p != NUL; ++p)
if (*p == c || *p == cc)
return p;
@@ -1647,9 +1647,9 @@ cstrchr(char_u *s, int c)
return NULL;
}
-/***************************************************************
- * regsub stuff *
- ***************************************************************/
+////////////////////////////////////////////////////////////////
+// regsub stuff //
+////////////////////////////////////////////////////////////////
/*
* We should define ftpr as a pointer to a function returning a pointer to
@@ -1720,36 +1720,36 @@ regtilde(char_u *source, int magic)
{
if (reg_prev_sub != NULL)
{
- /* length = len(newsub) - 1 + len(prev_sub) + 1 */
+ // length = len(newsub) - 1 + len(prev_sub) + 1
prevlen = (int)STRLEN(reg_prev_sub);
tmpsub = alloc(STRLEN(newsub) + prevlen);
if (tmpsub != NULL)
{
- /* copy prefix */
- len = (int)(p - newsub); /* not including ~ */
+ // copy prefix
+ len = (int)(p - newsub); // not including ~
mch_memmove(tmpsub, newsub, (size_t)len);
- /* interpret tilde */
+ // interpret tilde
mch_memmove(tmpsub + len, reg_prev_sub, (size_t)prevlen);
- /* copy postfix */
+ // copy postfix
if (!magic)
- ++p; /* back off \ */
+ ++p; // back off backslash
STRCPY(tmpsub + len + prevlen, p + 1);
- if (newsub != source) /* already allocated newsub */
+ if (newsub != source) // already allocated newsub
vim_free(newsub);
newsub = tmpsub;
p = newsub + len + prevlen;
}
}
else if (magic)
- STRMOVE(p, p + 1); /* remove '~' */
+ STRMOVE(p, p + 1); // remove '~'
else
- STRMOVE(p, p + 2); /* remove '\~' */
+ STRMOVE(p, p + 2); // remove '\~'
--p;
}
else
{
- if (*p == '\\' && p[1]) /* skip escaped characters */
+ if (*p == '\\' && p[1]) // skip escaped characters
++p;
if (has_mbyte)
p += (*mb_ptr2len)(p) - 1;
@@ -1757,19 +1757,19 @@ regtilde(char_u *source, int magic)
}
vim_free(reg_prev_sub);
- if (newsub != source) /* newsub was allocated, just keep it */
+ if (newsub != source) // newsub was allocated, just keep it
reg_prev_sub = newsub;
- else /* no ~ found, need to save newsub */
+ else // no ~ found, need to save newsub
reg_prev_sub = vim_strsave(newsub);
return newsub;
}
#ifdef FEAT_EVAL
-static int can_f_submatch = FALSE; /* TRUE when submatch() can be used */
+static int can_f_submatch = FALSE; // TRUE when submatch() can be used
-/* These pointers are used for reg_submatch(). Needed for when the
- * substitution string is an expression that contains a call to substitute()
- * and submatch(). */
+// These pointers are used for reg_submatch(). Needed for when the
+// substitution string is an expression that contains a call to substitute()
+// and submatch().
typedef struct {
regmatch_T *sm_match;
regmmatch_T *sm_mmatch;
@@ -1778,7 +1778,7 @@ typedef struct {
int sm_line_lbr;
} regsubmatch_T;
-static regsubmatch_T rsm; /* can only be used when can_f_submatch is TRUE */
+static regsubmatch_T rsm; // can only be used when can_f_submatch is TRUE
#endif
#ifdef FEAT_EVAL
@@ -1861,7 +1861,7 @@ vim_regsub(
int rex_in_use_save = rex_in_use;
if (rex_in_use)
- /* Being called recursively, save the state. */
+ // Being called recursively, save the state.
rex_save = rex;
rex_in_use = TRUE;
@@ -1894,13 +1894,13 @@ vim_regsub_multi(
int rex_in_use_save = rex_in_use;
if (rex_in_use)
- /* Being called recursively, save the state. */
+ // Being called recursively, save the state.
rex_save = rex;
rex_in_use = TRUE;
rex.reg_match = NULL;
rex.reg_mmatch = rmp;
- rex.reg_buf = curbuf; /* always works on the current buffer! */
+ rex.reg_buf = curbuf; // always works on the current buffer!
rex.reg_firstlnum = lnum;
rex.reg_maxline = curbuf->b_ml.ml_line_count - lnum;
rex.reg_line_lbr = FALSE;
@@ -1930,13 +1930,13 @@ vim_regsub_both(
int no = -1;
fptr_T func_all = (fptr_T)NULL;
fptr_T func_one = (fptr_T)NULL;
- linenr_T clnum = 0; /* init for GCC */
- int len = 0; /* init for GCC */
+ linenr_T clnum = 0; // init for GCC
+ int len = 0; // init for GCC
#ifdef FEAT_EVAL
static char_u *eval_result = NULL;
#endif
- /* Be paranoid... */
+ // Be paranoid...
if ((source == NULL && expr == NULL) || dest == NULL)
{
emsg(_(e_null));
@@ -1953,10 +1953,10 @@ vim_regsub_both(
if (expr != NULL || (source[0] == '\\' && source[1] == '='))
{
#ifdef FEAT_EVAL
- /* To make sure that the length doesn't change between checking the
- * length and copying the string, and to speed up things, the
- * resulting string is saved from the call with "copy" == FALSE to the
- * call with "copy" == TRUE. */
+ // To make sure that the length doesn't change between checking the
+ // length and copying the string, and to speed up things, the
+ // resulting string is saved from the call with "copy" == FALSE to the
+ // call with "copy" == TRUE.
if (copy)
{
if (eval_result != NULL)
@@ -1973,9 +1973,9 @@ vim_regsub_both(
vim_free(eval_result);
- /* The expression may contain substitute(), which calls us
- * recursively. Make sure submatch() gets the text from the first
- * level. */
+ // The expression may contain substitute(), which calls us
+ // recursively. Make sure submatch() gets the text from the first
+ // level.
if (can_f_submatch)
rsm_save = rsm;
can_f_submatch = TRUE;
@@ -2038,9 +2038,9 @@ vim_regsub_both(
for (s = eval_result; *s != NUL; 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. */
+ // 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 && !rsm.sm_line_lbr)
*s = CAR;
else if (*s == '\\' && s[1] != NUL)
@@ -2059,7 +2059,7 @@ vim_regsub_both(
}
if (had_backslash && backslash)
{
- /* Backslashes will be consumed, need to double them. */
+ // Backslashes will be consumed, need to double them.
s = vim_strsave_escaped(eval_result, (char_u *)"\\");
if (s != NULL)
{
@@ -2111,11 +2111,11 @@ vim_regsub_both(
}
}
}
- if (no < 0) /* Ordinary character. */
+ if (no < 0) // Ordinary character.
{
if (c == K_SPECIAL && src[0] != NUL && src[1] != NUL)
{
- /* Copy a special key as-is. */
+ // Copy a special key as-is.
if (copy)
{
*dst++ = c;
@@ -2132,18 +2132,18 @@ vim_regsub_both(
if (c == '\\' && *src != NUL)
{
- /* Check for abbreviations -- webb */
+ // Check for abbreviations -- webb
switch (*src)
{
case 'r': c = CAR; ++src; break;
case 'n': c = NL; ++src; break;
case 't': c = TAB; ++src; break;
- /* Oh no! \e already has meaning in subst pat :-( */
- /* case 'e': c = ESC; ++src; break; */
+ // Oh no! \e already has meaning in subst pat :-(
+ // case 'e': c = ESC; ++src; break;
case 'b': c = Ctrl_H; ++src; break;
- /* If "backslash" is TRUE the backslash will be removed
- * later. Used to insert a literal CR. */
+ // If "backslash" is TRUE the backslash will be removed
+ // later. Used to insert a literal CR.
default: if (backslash)
{
if (copy)
@@ -2156,14 +2156,14 @@ vim_regsub_both(
else if (has_mbyte)
c = mb_ptr2char(src - 1);
- /* Write to buffer, if copy is set. */
+ // Write to buffer, if copy is set.
if (func_one != (fptr_T)NULL)
- /* Turbo C complains without the typecast */
+ // Turbo C complains without the typecast
func_one = (fptr_T)(func_one(&cc, c));
else if (func_all != (fptr_T)NULL)
- /* Turbo C complains without the typecast */
+ // Turbo C complains without the typecast
func_all = (fptr_T)(func_all(&cc, c));
- else /* just copy */
+ else // just copy
cc = c;
if (has_mbyte)
@@ -2177,8 +2177,8 @@ vim_regsub_both(
{
int clen = utf_ptr2len(src - 1);
- /* If the character length is shorter than "totlen", there
- * are composing characters; copy them as-is. */
+ // If the character length is shorter than "totlen", there
+ // are composing characters; copy them as-is.
if (clen < totlen)
{
if (copy)
@@ -2240,7 +2240,7 @@ vim_regsub_both(
else
break;
}
- else if (*s == NUL) /* we hit NUL. */
+ else if (*s == NUL) // we hit NUL.
{
if (copy)
emsg(_(e_re_damg));
@@ -2271,20 +2271,20 @@ vim_regsub_both(
c = *s;
if (func_one != (fptr_T)NULL)
- /* Turbo C complains without the typecast */
+ // Turbo C complains without the typecast
func_one = (fptr_T)(func_one(&cc, c));
else if (func_all != (fptr_T)NULL)
- /* Turbo C complains without the typecast */
+ // Turbo C complains without the typecast
func_all = (fptr_T)(func_all(&cc, c));
- else /* just copy */
+ else // just copy
cc = c;
if (has_mbyte)
{
int l;
- /* Copy composing characters separately, one
- * at a time. */
+ // Copy composing characters separately, one
+ // at a time.
if (enc_utf8)
l = utf_ptr2len(s) - 1;
else
@@ -2374,7 +2374,7 @@ reg_submatch(int no)
s += rsm.sm_mmatch->startpos[no].col;
if (rsm.sm_mmatch->endpos[no].lnum == lnum)
{
- /* Within one line: take form start to end col. */
+ // Within one line: take form start to end col.
len = rsm.sm_mmatch->endpos[no].col
- rsm.sm_mmatch->startpos[no].col;
if (round == 2)
@@ -2383,8 +2383,8 @@ reg_submatch(int no)
}
else
{
- /* Multiple lines: take start line from start col, middle
- * lines completely and end line up to end col. */
+ // Multiple lines: take start line from start col, middle
+ // lines completely and end line up to end col.
len = (int)STRLEN(s);
if (round == 2)
{
@@ -2533,8 +2533,8 @@ static regengine_T nfa_regengine =
(char_u *)""
};
-/* Which regexp engine to use? Needed for vim_regcomp().
- * Must match with 'regexpengine'. */
+// Which regexp engine to use? Needed for vim_regcomp().
+// Must match with 'regexpengine'.
static int regexp_engine = 0;
#ifdef DEBUG
@@ -2560,7 +2560,7 @@ vim_regcomp(char_u *expr_arg, int re_flags)
regexp_engine = p_re;
- /* Check for prefix "\%#=", that sets the regexp engine */
+ // Check for prefix "\%#=", that sets the regexp engine
if (STRNCMP(expr, "\\%#=", 4) == 0)
{
int newengine = expr[4] - '0';
@@ -2600,11 +2600,11 @@ vim_regcomp(char_u *expr_arg, int re_flags)
else
prog = bt_regengine.regcomp(expr, re_flags);
- /* Check for error compiling regexp with initial engine. */
+ // Check for error compiling regexp with initial engine.
if (prog == NULL)
{
#ifdef BT_REGEXP_DEBUG_LOG
- if (regexp_engine != BACKTRACKING_ENGINE) /* debugging log for NFA */
+ if (regexp_engine != BACKTRACKING_ENGINE) // debugging log for NFA
{
FILE *f;
f = fopen(BT_REGEXP_DEBUG_LOG_NAME, "a");
@@ -2634,8 +2634,8 @@ vim_regcomp(char_u *expr_arg, int re_flags)
if (prog != NULL)
{
- /* Store the info needed to call regcomp() again when the engine turns
- * out to be very slow when executing it. */
+ // Store the info needed to call regcomp() again when the engine turns
+ // out to be very slow when executing it.
prog->re_engine = regexp_engine;
prog->re_flags = re_flags;
}
@@ -2702,8 +2702,8 @@ regprog_in_use(regprog_T *prog)
static int
vim_regexec_string(
regmatch_T *rmp,
- char_u *line, /* string to match against */
- colnr_T col, /* column to start looking for match */
+ char_u *line, // string to match against
+ colnr_T col, // column to start looking for match
int nl)
{
int result;
@@ -2731,7 +2731,7 @@ vim_regexec_string(
result = rmp->regprog->engine->regexec_nl(rmp, line, col, nl);
rmp->regprog->re_in_use = FALSE;
- /* NFA engine aborted because it's very slow. */
+ // NFA engine aborted because it's very slow.
if (rmp->regprog->re_engine == AUTOMATIC_ENGINE
&& result == NFA_TOO_EXPENSIVE)
{
@@ -2820,12 +2820,12 @@ vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col)
long
vim_regexec_multi(
regmmatch_T *rmp,
- win_T *win, /* window in which to search or NULL */
- buf_T *buf, /* buffer in which to search */
- linenr_T lnum, /* nr of line to start looking for match */
- colnr_T col, /* column to start looking for match */
- proftime_T *tm, /* timeout limit or NULL */
- int *timed_out) /* flag is set when timeout limit reached */
+ win_T *win, // window in which to search or NULL
+ buf_T *buf, // buffer in which to search
+ linenr_T lnum, // nr of line to start looking for match
+ colnr_T col, // column to start looking for match
+ proftime_T *tm, // timeout limit or NULL
+ int *timed_out) // flag is set when timeout limit reached
{
int result;
regexec_T rex_save;
@@ -2840,7 +2840,7 @@ vim_regexec_multi(
rmp->regprog->re_in_use = TRUE;
if (rex_in_use)
- /* Being called recursively, save the state. */
+ // Being called recursively, save the state.
rex_save = rex;
rex_in_use = TRUE;
@@ -2848,7 +2848,7 @@ vim_regexec_multi(
rmp, win, buf, lnum, col, tm, timed_out);
rmp->regprog->re_in_use = FALSE;
- /* NFA engine aborted because it's very slow. */
+ // NFA engine aborted because it's very slow.
if (rmp->regprog->re_engine == AUTOMATIC_ENGINE
&& result == NFA_TOO_EXPENSIVE)
{