From 63d9e730f726341bf41ee4f4b829253cb9879110 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 5 Dec 2019 21:10:38 +0100 Subject: patch 8.1.2394: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate. --- src/popupmenu.c | 182 +++---- src/pty.c | 66 ++- src/quickfix.c | 2 +- src/regexp.c | 504 +++++++++---------- src/regexp_nfa.c | 1443 +++++++++++++++++++++++++++--------------------------- src/screen.c | 575 +++++++++++----------- src/search.c | 972 ++++++++++++++++++------------------ src/sha256.c | 14 +- src/sign.c | 6 +- src/version.c | 2 + 10 files changed, 1880 insertions(+), 1886 deletions(-) diff --git a/src/popupmenu.c b/src/popupmenu.c index 76255aa97f..14539adf23 100644 --- a/src/popupmenu.c +++ b/src/popupmenu.c @@ -12,22 +12,22 @@ */ #include "vim.h" -static pumitem_T *pum_array = NULL; /* items of displayed pum */ -static int pum_size; /* nr of items in "pum_array" */ -static int pum_selected; /* index of selected item or -1 */ -static int pum_first = 0; /* index of top item */ +static pumitem_T *pum_array = NULL; // items of displayed pum +static int pum_size; // nr of items in "pum_array" +static int pum_selected; // index of selected item or -1 +static int pum_first = 0; // index of top item static int call_update_screen = FALSE; -static int pum_height; /* nr of displayed pum items */ -static int pum_width; /* width of displayed pum items */ -static int pum_base_width; /* width of pum items base */ -static int pum_kind_width; /* width of pum items kind column */ -static int pum_extra_width; /* width of extra stuff */ -static int pum_scrollbar; /* TRUE when scrollbar present */ +static int pum_height; // nr of displayed pum items +static int pum_width; // width of displayed pum items +static int pum_base_width; // width of pum items base +static int pum_kind_width; // width of pum items kind column +static int pum_extra_width; // width of extra stuff +static int pum_scrollbar; // TRUE when scrollbar present -static int pum_row; /* top row of pum */ -static int pum_col; /* left column of pum */ +static int pum_row; // top row of pum +static int pum_col; // left column of pum static win_T *pum_window = NULL; static int pum_win_row; @@ -49,7 +49,7 @@ pum_compute_size(void) int i; int w; - /* Compute the width of the widest match and the widest extra. */ + // Compute the width of the widest match and the widest extra. pum_base_width = 0; pum_kind_width = 0; pum_extra_width = 0; @@ -83,8 +83,8 @@ pum_compute_size(void) pum_display( pumitem_T *array, int size, - int selected) /* index of initially selected item, none if - out of range */ + int selected) // index of initially selected item, none if + // out of range { int def_width; int max_width; @@ -103,8 +103,8 @@ pum_display( above_row = 0; below_row = cmdline_row; - /* Pretend the pum is already there to avoid that must_redraw is set - * when 'cuc' is on. */ + // Pretend the pum is already there to avoid that must_redraw is set + // when 'cuc' is on. pum_array = (pumitem_T *)1; validate_cursor_col(); pum_array = NULL; @@ -141,14 +141,14 @@ pum_display( if (p_ph > 0 && pum_height > p_ph) pum_height = p_ph; - /* Put the pum below "pum_win_row" if possible. If there are few lines - * decide on where there is more room. */ + // Put the pum below "pum_win_row" if possible. If there are few lines + // decide on where there is more room. if (pum_win_row + 2 >= below_row - pum_height && pum_win_row - above_row > (below_row - above_row) / 2) { - /* pum above "pum_win_row" */ + // pum above "pum_win_row" - /* Leave two lines of context if possible */ + // Leave two lines of context if possible if (curwin->w_wrow - curwin->w_cline_row >= 2) context_lines = 2; else @@ -172,9 +172,9 @@ pum_display( } else { - /* pum below "pum_win_row" */ + // pum below "pum_win_row" - /* Leave two lines of context if possible */ + // Leave two lines of context if possible if (curwin->w_cline_row + curwin->w_cline_height - curwin->w_wrow >= 3) context_lines = 3; @@ -191,7 +191,7 @@ pum_display( pum_height = p_ph; } - /* don't display when we only have room for one line */ + // don't display when we only have room for one line if (pum_height < 1 || (pum_height == 1 && size > 1)) return; @@ -209,7 +209,7 @@ pum_display( pum_compute_size(); max_width = pum_base_width; - /* Calculate column */ + // Calculate column #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) cursor_col = curwin->w_wincol + curwin->w_width @@ -218,7 +218,7 @@ pum_display( #endif cursor_col = curwin->w_wincol + curwin->w_wcol; - /* if there are more items than room we need a scrollbar */ + // if there are more items than room we need a scrollbar if (pum_height < size) { pum_scrollbar = 1; @@ -239,10 +239,10 @@ pum_display( #endif )) { - /* align pum with "cursor_col" */ + // align pum with "cursor_col" pum_col = cursor_col; - /* start with the maximum space available */ + // start with the maximum space available #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) pum_width = pum_col - pum_scrollbar + 1; @@ -253,8 +253,8 @@ pum_display( if (pum_width > max_width + pum_kind_width + pum_extra_width + 1 && pum_width > p_pw) { - /* the width is more than needed for the items, make it - * narrower */ + // the width is more than needed for the items, make it + // narrower pum_width = max_width + pum_kind_width + pum_extra_width + 1; if (pum_width < p_pw) pum_width = p_pw; @@ -267,7 +267,7 @@ pum_display( #endif )) { - /* align pum edge with "cursor_col" */ + // align pum edge with "cursor_col" #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl && W_ENDCOL(curwin) < max_width + pum_scrollbar + 1) @@ -282,7 +282,7 @@ pum_display( if (curwin->w_wincol > Columns - max_width - pum_scrollbar && max_width <= p_pw) { - /* use full width to end of the screen */ + // use full width to end of the screen pum_col = Columns - max_width - pum_scrollbar; if (pum_col < 0) pum_col = 0; @@ -326,7 +326,7 @@ pum_display( } else if (Columns < def_width) { - /* not enough room, will use what we have */ + // not enough room, will use what we have #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) pum_col = Columns - 1; @@ -338,7 +338,7 @@ pum_display( else { if (max_width > p_pw) - max_width = p_pw; /* truncate */ + max_width = p_pw; // truncate #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) pum_col = max_width - 1; @@ -348,9 +348,9 @@ pum_display( pum_width = max_width - pum_scrollbar; } - /* Set selected item and redraw. If the window size changed need to - * redo the positioning. Limit this to two times, when there is not - * much room the window size will keep changing. */ + // Set selected item and redraw. If the window size changed need to + // redo the positioning. Limit this to two times, when there is not + // much room the window size will keep changing. } while (pum_set_selected(selected, redo_count) && ++redo_count <= 2); } @@ -440,7 +440,7 @@ pum_redraw(void) idx = i + pum_first; attr = (idx == pum_selected) ? attr_select : attr_norm; - /* prepend a space if there is room */ + // prepend a space if there is room #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) { @@ -452,8 +452,8 @@ pum_redraw(void) if (pum_col > 0) screen_putchar(' ', row, pum_col - 1, attr); - /* Display each entry, use two spaces for a Tab. - * Do this 3 times: For the main text, kind and extra info */ + // Display each entry, use two spaces for a Tab. + // Do this 3 times: For the main text, kind and extra info col = pum_col; totwidth = 0; for (round = 1; round <= 3; ++round) @@ -474,8 +474,8 @@ pum_redraw(void) w = ptr2cells(p); if (*p == NUL || *p == TAB || totwidth + w > pum_width) { - /* Display the text that fits or comes before a Tab. - * First convert it to printable characters. */ + // Display the text that fits or comes before a Tab. + // First convert it to printable characters. char_u *st; int saved = *p; @@ -508,11 +508,11 @@ pum_redraw(void) if (size < pum_width) { - /* Most left character requires - * 2-cells but only 1 cell is - * available on screen. Put a - * '<' on the left of the pum - * item */ + // Most left character requires + // 2-cells but only 1 cell is + // available on screen. Put a + // '<' on the left of the pum + // item *(--rt) = '<'; size++; } @@ -540,7 +540,7 @@ pum_redraw(void) if (*p != TAB) break; - /* Display two spaces for a Tab. */ + // Display two spaces for a Tab. #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) { @@ -555,7 +555,7 @@ pum_redraw(void) col += 2; } totwidth += 2; - s = NULL; /* start text at next char */ + s = NULL; // start text at next char width = 0; } else @@ -567,7 +567,7 @@ pum_redraw(void) else n = 1; - /* Stop when there is nothing more to display. */ + // Stop when there is nothing more to display. if (round == 3 || (round == 2 && pum_array[idx].pum_extra == NULL) || (round == 1 && pum_array[idx].pum_kind == NULL @@ -693,8 +693,8 @@ pum_set_selected(int n, int repeat UNUSED) { if (pum_first > pum_selected - 4) { - /* scroll down; when we did a jump it's probably a PageUp then - * scroll a whole page */ + // scroll down; when we did a jump it's probably a PageUp then + // scroll a whole page if (pum_first > pum_selected - 2) { pum_first -= pum_height - 2; @@ -708,8 +708,8 @@ pum_set_selected(int n, int repeat UNUSED) } else if (pum_first < pum_selected - pum_height + 5) { - /* scroll up; when we did a jump it's probably a PageDown then - * scroll a whole page */ + // scroll up; when we did a jump it's probably a PageDown then + // scroll a whole page if (pum_first < pum_selected - pum_height + 1 + 2) { pum_first += pum_height - 2; @@ -720,21 +720,21 @@ pum_set_selected(int n, int repeat UNUSED) pum_first = pum_selected - pum_height + 1; } - /* Give a few lines of context when possible. */ + // Give a few lines of context when possible. if (context > 3) context = 3; if (pum_height > 2) { if (pum_first > pum_selected - context) { - /* scroll down */ + // scroll down pum_first = pum_selected - context; if (pum_first < 0) pum_first = 0; } else if (pum_first < pum_selected + context - pum_height + 1) { - /* scroll up */ + // scroll up pum_first = pum_selected + context - pum_height + 1; } } @@ -845,8 +845,8 @@ pum_set_selected(int n, int repeat UNUSED) // delete the empty last line ml_delete(curbuf->b_ml.ml_line_count, FALSE); - /* Increase the height of the preview window to show the - * text, but no more than 'previewheight' lines. */ + // Increase the height of the preview window to show the + // text, but no more than 'previewheight' lines. if (repeat == 0 && use_popup == USEPOPUP_NONE) { if (lnum > p_pvh) @@ -886,20 +886,20 @@ pum_set_selected(int n, int repeat UNUSED) if (curtab != curtab_save && valid_tabpage(curtab_save)) goto_tabpage_tp(curtab_save, FALSE, FALSE); - /* When the first completion is done and the preview - * window is not resized, skip the preview window's - * status line redrawing. */ + // When the first completion is done and the preview + // window is not resized, skip the preview window's + // status line redrawing. if (ins_compl_active() && !resized) curwin->w_redr_status = FALSE; - /* Return cursor to where we were */ + // Return cursor to where we were validate_cursor(); redraw_later(SOME_VALID); - /* When the preview window was resized we need to - * update the view on the buffer. Only go back to - * the window when needed, otherwise it will always be - * redraw. */ + // When the preview window was resized we need to + // update the view on the buffer. Only go back to + // the window when needed, otherwise it will always be + // redraw. if (resized && win_valid(curwin_save)) { ++no_u_sync; @@ -908,8 +908,8 @@ pum_set_selected(int n, int repeat UNUSED) update_topline(); } - /* Update the screen before drawing the popup menu. - * Enable updating the status lines. */ + // Update the screen before drawing the popup menu. + // Enable updating the status lines. pum_do_redraw = TRUE; update_screen(0); pum_do_redraw = FALSE; @@ -928,8 +928,8 @@ pum_set_selected(int n, int repeat UNUSED) # endif } - /* May need to update the screen again when there are - * autocommands involved. */ + // May need to update the screen again when there are + // autocommands involved. pum_do_redraw = TRUE; update_screen(0); pum_do_redraw = FALSE; @@ -1064,14 +1064,14 @@ pum_position_at_mouse(int min_width) { if (Rows - mouse_row > pum_size) { - /* Enough space below the mouse row. */ + // Enough space below the mouse row. pum_row = mouse_row + 1; if (pum_height > Rows - pum_row) pum_height = Rows - pum_row; } else { - /* Show above the mouse row, reduce height if it does not fit. */ + // Show above the mouse row, reduce height if it does not fit. pum_row = mouse_row - pum_size; if (pum_row < 0) { @@ -1081,10 +1081,10 @@ pum_position_at_mouse(int min_width) } if (Columns - mouse_col >= pum_base_width || Columns - mouse_col > min_width) - /* Enough space to show at mouse column. */ + // Enough space to show at mouse column. pum_col = mouse_col; else - /* Not enough space, right align with window. */ + // Not enough space, right align with window. pum_col = Columns - (pum_base_width > min_width ? min_width : pum_base_width); @@ -1158,7 +1158,7 @@ split_message(char_u *mesg, pumitem_T **array) { if ((*p == ',' && p[1] == ' ') || *p == '{' || *p == '}') { - /* Looks like a good point to break. */ + // Looks like a good point to break. if (*p == '{') ++indent; else if (*p == '}' && indent > 0) @@ -1181,22 +1181,22 @@ split_message(char_u *mesg, pumitem_T **array) height = 2 + ga.ga_len; - /* If there are long items and the height is below the limit: split lines */ + // If there are long items and the height is below the limit: split lines if (long_item_count > 0 && height + long_item_count <= max_height) { split_long_items = TRUE; height += long_item_count; } - /* Limit to half the window height, it has to fit above or below the mouse - * position. */ + // Limit to half the window height, it has to fit above or below the mouse + // position. if (height > max_height) height = max_height; *array = ALLOC_CLEAR_MULT(pumitem_T, height); if (*array == NULL) goto failed; - /* Add an empty line above and below, looks better. */ + // Add an empty line above and below, looks better. (*array)->pum_text = vim_strsave((char_u *)""); (*array + height - 1)->pum_text = vim_strsave((char_u *)""); @@ -1246,7 +1246,7 @@ split_message(char_u *mesg, pumitem_T **array) vim_strncpy(p + ind, item->start + skip, copylen); (*array)[line].pum_text = p; - item->indent = 0; /* wrapped line has no indent */ + item->indent = 0; // wrapped line has no indent ++line; } } @@ -1415,7 +1415,7 @@ pum_show_popupmenu(vimmenu_T *menu) pum_selected = -1; pum_first = 0; # ifdef FEAT_BEVAL_TERM - p_bevalterm = TRUE; /* track mouse movement */ + p_bevalterm = TRUE; // track mouse movement mch_setmouse(TRUE); # endif @@ -1435,13 +1435,13 @@ pum_show_popupmenu(vimmenu_T *menu) break; else if (c == CAR || c == NL) { - /* enter: select current item, if any, and close */ + // enter: select current item, if any, and close pum_execute_menu(menu, mode); break; } else if (c == 'k' || c == K_UP || c == K_MOUSEUP) { - /* cursor up: select previous item */ + // cursor up: select previous item while (pum_selected > 0) { --pum_selected; @@ -1451,7 +1451,7 @@ pum_show_popupmenu(vimmenu_T *menu) } else if (c == 'j' || c == K_DOWN || c == K_MOUSEDOWN) { - /* cursor down: select next item */ + // cursor down: select next item while (pum_selected < pum_size - 1) { ++pum_selected; @@ -1461,19 +1461,19 @@ pum_show_popupmenu(vimmenu_T *menu) } else if (c == K_RIGHTMOUSE) { - /* Right mouse down: reposition the menu. */ + // Right mouse down: reposition the menu. vungetc(c); break; } else if (c == K_LEFTDRAG || c == K_RIGHTDRAG || c == K_MOUSEMOVE) { - /* mouse moved: select item in the mouse row */ + // mouse moved: select item in the mouse row pum_select_mouse_pos(); } else if (c == K_LEFTMOUSE || c == K_LEFTMOUSE_NM || c == K_RIGHTRELEASE) { - /* left mouse click: select clicked item, if any, and close; - * right mouse release: select clicked item, close if any */ + // left mouse click: select clicked item, if any, and close; + // right mouse release: select clicked item, close if any pum_select_mouse_pos(); if (pum_selected >= 0) { @@ -1500,8 +1500,8 @@ pum_make_popup(char_u *path_name, int use_mouse_pos) if (!use_mouse_pos) { - /* Hack: set mouse position at the cursor so that the menu pops up - * around there. */ + // Hack: set mouse position at the cursor so that the menu pops up + // around there. mouse_row = curwin->w_winrow + curwin->w_wrow; mouse_col = curwin->w_wincol + curwin->w_wcol; } diff --git a/src/pty.c b/src/pty.c index 86fbca2790..a44d0a0888 100644 --- a/src/pty.c +++ b/src/pty.c @@ -20,26 +20,25 @@ * copyright notice below. */ -/* Copyright (c) 1993 - * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) - * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de) - * Copyright (c) 1987 Oliver Laumann - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program (see the file COPYING); if not, write to the - * Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ +// Copyright (c) 1993 +// Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de) +// Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de) +// Copyright (c) 1987 Oliver Laumann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program (see the file COPYING); if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA #include "vim.h" @@ -124,7 +123,7 @@ # define PTYRANGE1 "0123456789abcdef" #endif -/* SVR4 pseudo ttys don't seem to work with SCO-5 */ +// SVR4 pseudo ttys don't seem to work with SCO-5 #ifdef M_UNIX # undef HAVE_SVR4_PTYS #endif @@ -240,7 +239,7 @@ mch_openpty(char **ttyn) { char *m, *s; int f; - /* used for opening a new pty-pair: */ + // used for opening a new pty-pair: static char PtyName[32]; static char TtyName[32]; @@ -289,7 +288,7 @@ mch_openpty(char **ttyn) { int f; stat_T buf; - /* used for opening a new pty-pair: */ + // used for opening a new pty-pair: static char TtyName[32]; if ((f = open("/dev/ptc", O_RDWR | O_NOCTTY | O_NONBLOCK | O_EXTRA, 0)) < 0) @@ -309,8 +308,8 @@ mch_openpty(char **ttyn) #if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE) && !defined(hpux) \ && !(defined(MACOS_X) && !defined(MAC_OS_X_VERSION_10_6)) -/* NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work! - * Same for Mac OS X Leopard (10.5). */ +// NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work! +// Same for Mac OS X Leopard (10.5). #define PTY_DONE int mch_openpty(char **ttyn) @@ -318,7 +317,7 @@ mch_openpty(char **ttyn) int f; char *m; RETSIGTYPE (*sigcld) SIGPROTOARG; - /* used for opening a new pty-pair: */ + // used for opening a new pty-pair: static char TtyName[32]; if ((f = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_EXTRA, 0)) == -1) @@ -354,10 +353,10 @@ static int aixhack = -1; mch_openpty(char **ttyn) { int f; - /* used for opening a new pty-pair: */ + // used for opening a new pty-pair: static char TtyName[32]; - /* a dumb looking loop replaced by mycrofts code: */ + // a dumb looking loop replaced by mycrofts code: if ((f = open("/dev/ptc", O_RDWR | O_NOCTTY | O_EXTRA)) < 0) return -1; vim_strncpy((char_u *)TtyName, (char_u *)ttyname(f), sizeof(TtyName) - 1); @@ -401,7 +400,7 @@ mch_openpty(char **ttyn) { char *p, *q, *l, *d; int f; - /* used for opening a new pty-pair: */ + // used for opening a new pty-pair: static char PtyName[32]; static char TtyName[32]; @@ -425,13 +424,12 @@ mch_openpty(char **ttyn) continue; } #if defined(SUN_SYSTEM) && defined(TIOCGPGRP) && !defined(SUNOS3) - /* Hack to ensure that the slave side of the pty is - * unused. May not work in anything other than SunOS4.1 - */ + // Hack to ensure that the slave side of the pty is + // unused. May not work in anything other than SunOS4.1 { int pgrp; - /* tcgetpgrp does not work (uses TIOCGETPGRP)! */ + // tcgetpgrp does not work (uses TIOCGETPGRP)! if (ioctl(f, TIOCGPGRP, (char *)&pgrp) != -1 || errno != EIO) { close(f); @@ -474,4 +472,4 @@ mch_isatty(int fd) return isatty(fd); } -#endif /* FEAT_GUI || FEAT_JOB_CHANNEL */ +#endif // FEAT_GUI || FEAT_JOB_CHANNEL diff --git a/src/quickfix.c b/src/quickfix.c index 72cdc6ed6b..3d12374b41 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -7880,7 +7880,7 @@ ex_helpgrep(exarg_T *eap) curwin->w_llist = qi; } } -#endif /* FEAT_QUICKFIX */ +#endif // FEAT_QUICKFIX #if defined(FEAT_EVAL) || defined(PROTO) # ifdef FEAT_QUICKFIX diff --git a/src/regexp.c b/src/regexp.c index 7fe891d319..112f75369e 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 "\@?@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(®parse); - if (*regparse == ',') /* There is a comma */ + if (*regparse == ',') // There is a comma { if (vim_isdigit(*++regparse)) *maxval = getdigits(®parse); @@ -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) { diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 685a6d7bd2..fb512f9610 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -29,43 +29,43 @@ # define NFA_REGEXP_DEBUG_LOG "nfa_regexp_debug.log" #endif -/* Added to NFA_ANY - NFA_NUPPER_IC to include a NL. */ +// Added to NFA_ANY - NFA_NUPPER_IC to include a NL. #define NFA_ADD_NL 31 enum { NFA_SPLIT = -1024, NFA_MATCH, - NFA_EMPTY, /* matches 0-length */ - - NFA_START_COLL, /* [abc] start */ - NFA_END_COLL, /* [abc] end */ - NFA_START_NEG_COLL, /* [^abc] start */ - NFA_END_NEG_COLL, /* [^abc] end (postfix only) */ - NFA_RANGE, /* range of the two previous items - * (postfix only) */ - NFA_RANGE_MIN, /* low end of a range */ - NFA_RANGE_MAX, /* high end of a range */ - - NFA_CONCAT, /* concatenate two previous items (postfix - * only) */ - NFA_OR, /* \| (postfix only) */ - NFA_STAR, /* greedy * (postfix only) */ - NFA_STAR_NONGREEDY, /* non-greedy * (postfix only) */ - NFA_QUEST, /* greedy \? (postfix only) */ - NFA_QUEST_NONGREEDY, /* non-greedy \? (postfix only) */ - - NFA_BOL, /* ^ Begin line */ - NFA_EOL, /* $ End line */ - NFA_BOW, /* \< Begin word */ - NFA_EOW, /* \> End word */ - NFA_BOF, /* \%^ Begin file */ - NFA_EOF, /* \%$ End file */ + NFA_EMPTY, // matches 0-length + + NFA_START_COLL, // [abc] start + NFA_END_COLL, // [abc] end + NFA_START_NEG_COLL, // [^abc] start + NFA_END_NEG_COLL, // [^abc] end (postfix only) + NFA_RANGE, // range of the two previous items + // (postfix only) + NFA_RANGE_MIN, // low end of a range + NFA_RANGE_MAX, // high end of a range + + NFA_CONCAT, // concatenate two previous i