Mercurial > vim
changeset 18816:15539899a112 v8.1.2396
patch 8.1.2396: using old C style comments
Commit: https://github.com/vim/vim/commit/e38eab22c1fb950127f0307a9904de6d4561dc70
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 5 21:50:01 2019 +0100
patch 8.1.2396: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 05 Dec 2019 22:00:04 +0100 |
parents | 404220424246 |
children | 17aefb9d7c45 |
files | src/ui.c src/undo.c src/uninstall.c src/usercmd.c src/userfunc.c src/version.c src/winclip.c src/window.c src/xpm_w32.c |
diffstat | 9 files changed, 1330 insertions(+), 1331 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ui.c +++ b/src/ui.c @@ -37,7 +37,7 @@ ui_write(char_u *s, int len) } #endif #ifndef NO_CONSOLE - /* Don't output anything in silent mode ("ex -s") unless 'verbose' set */ + // Don't output anything in silent mode ("ex -s") unless 'verbose' set if (!(silent_mode && p_verbose == 0)) { #if !defined(MSWIN) @@ -45,7 +45,7 @@ ui_write(char_u *s, int len) if (output_conv.vc_type != CONV_NONE) { - /* Convert characters from 'encoding' to 'termencoding'. */ + // Convert characters from 'encoding' to 'termencoding'. tofree = string_convert(&output_conv, s, &len); if (tofree != NULL) s = tofree; @@ -69,8 +69,8 @@ ui_write(char_u *s, int len) * here for the next call. */ static char_u *ta_str = NULL; -static int ta_off; /* offset for next char to use when ta_str != NULL */ -static int ta_len; /* length of ta_str when it's not NULL*/ +static int ta_off; // offset for next char to use when ta_str != NULL +static int ta_len; // length of ta_str when it's not NULL void ui_inchar_undo(char_u *s, int len) @@ -116,7 +116,7 @@ ui_inchar_undo(char_u *s, int len) ui_inchar( char_u *buf, int maxlen, - long wtime, /* don't use "time", MIPS cannot handle it */ + long wtime, // don't use "time", MIPS cannot handle it int tb_change_cnt) { int retval = 0; @@ -145,10 +145,10 @@ ui_inchar( #endif #ifdef NO_CONSOLE_INPUT - /* Don't wait for character input when the window hasn't been opened yet. - * Do try reading, this works when redirecting stdin from a file. - * Must return something, otherwise we'll loop forever. If we run into - * this very often we probably got stuck, exit Vim. */ + // Don't wait for character input when the window hasn't been opened yet. + // Do try reading, this works when redirecting stdin from a file. + // Must return something, otherwise we'll loop forever. If we run into + // this very often we probably got stuck, exit Vim. if (no_console_input()) { static int count = 0; @@ -166,14 +166,14 @@ ui_inchar( } #endif - /* If we are going to wait for some time or block... */ + // If we are going to wait for some time or block... if (wtime == -1 || wtime > 100L) { - /* ... allow signals to kill us. */ + // ... allow signals to kill us. (void)vim_handle_signal(SIGNAL_UNBLOCK); - /* ... there is no need for CTRL-C to interrupt something, don't let - * it set got_int when it was mapped. */ + // ... there is no need for CTRL-C to interrupt something, don't let + // it set got_int when it was mapped. if ((mapped_ctrl_c | curbuf->b_mapped_ctrl_c) & get_real_state()) ctrl_c_interrupts = FALSE; } @@ -232,7 +232,7 @@ ui_inchar( #endif if (wtime == -1 || wtime > 100L) - /* block SIGHUP et al. */ + // block SIGHUP et al. (void)vim_handle_signal(SIGNAL_BLOCK); ctrl_c_interrupts = TRUE; @@ -282,11 +282,11 @@ inchar_loop( ELAPSED_INIT(start_tv); #endif - /* repeat until we got a character or waited long enough */ + // repeat until we got a character or waited long enough for (;;) { - /* Check if window changed size while we were busy, perhaps the ":set - * columns=99" command was used. */ + // Check if window changed size while we were busy, perhaps the ":set + // columns=99" command was used. if (resize_func != NULL) resize_func(FALSE); @@ -454,7 +454,7 @@ ui_wait_for_chars_or_timer( due_time = check_due_timer(); if (typebuf.tb_change_cnt != tb_change_cnt) { - /* timer may have used feedkeys() */ + // timer may have used feedkeys() return FAIL; } if (due_time <= 0 || (wtime > 0 && due_time > remaining)) @@ -598,7 +598,7 @@ ui_get_shellsize(void) check_shellsize(); - /* adjust the default for 'lines' and 'columns' */ + // adjust the default for 'lines' and 'columns' if (retval == OK) { set_number_default("lines", Rows); @@ -614,7 +614,7 @@ ui_get_shellsize(void) */ void ui_set_shellsize( - int mustset UNUSED) /* set by the user */ + int mustset UNUSED) // set by the user { #ifdef FEAT_GUI if (gui.in_use) @@ -711,17 +711,16 @@ ui_breakcheck_force(int force) recursive = FALSE; } -/***************************************************************************** - * Functions for copying and pasting text between applications. - * This is always included in a GUI version, but may also be included when the - * clipboard and mouse is available to a terminal version such as xterm. - * Note: there are some more functions in ops.c that handle selection stuff. - * - * Also note that the majority of functions here deal with the X 'primary' - * (visible - for Visual mode use) selection, and only that. There are no - * versions of these for the 'clipboard' selection, as Visual mode has no use - * for them. - */ +////////////////////////////////////////////////////////////////////////////// +// Functions for copying and pasting text between applications. +// This is always included in a GUI version, but may also be included when the +// clipboard and mouse is available to a terminal version such as xterm. +// Note: there are some more functions in ops.c that handle selection stuff. +// +// Also note that the majority of functions here deal with the X 'primary' +// (visible - for Visual mode use) selection, and only that. There are no +// versions of these for the 'clipboard' selection, as Visual mode has no use +// for them. #if defined(FEAT_CLIPBOARD) || defined(PROTO) @@ -776,7 +775,7 @@ clip_update_selection(Clipboard_T *clip) { pos_T start, end; - /* If visual mode is only due to a redo command ("."), then ignore it */ + // If visual mode is only due to a redo command ("."), then ignore it if (!redo_VIsual_busy && VIsual_active && (State & NORMAL)) { if (LT_POS(VIsual, curwin->w_cursor)) @@ -814,8 +813,8 @@ clip_own_selection(Clipboard_T *cbd) * than a mapping etc. */ #ifdef FEAT_X11 - /* Always own the selection, we might have lost it without being - * notified, e.g. during a ":sh" command. */ + // Always own the selection, we might have lost it without being + // notified, e.g. during a ":sh" command. if (cbd->available) { int was_owned = cbd->owned; @@ -823,9 +822,9 @@ clip_own_selection(Clipboard_T *cbd) cbd->owned = (clip_gen_own_selection(cbd) == OK); if (!was_owned && (cbd == &clip_star || cbd == &clip_plus)) { - /* May have to show a different kind of highlighting for the - * selected area. There is no specific redraw command for this, - * just redraw all windows on the current buffer. */ + // May have to show a different kind of highlighting for the + // selected area. There is no specific redraw command for this, + // just redraw all windows on the current buffer. if (cbd->owned && (get_real_state() == VISUAL || get_real_state() == SELECTMODE) @@ -836,7 +835,7 @@ clip_own_selection(Clipboard_T *cbd) } } #else - /* Only own the clipboard when we didn't own it yet. */ + // Only own the clipboard when we didn't own it yet. if (!cbd->owned && cbd->available) cbd->owned = (clip_gen_own_selection(cbd) == OK); #endif @@ -861,9 +860,9 @@ clip_lose_selection(Clipboard_T *cbd) #ifdef FEAT_X11 if (visual_selection) { - /* May have to show a different kind of highlighting for the selected - * area. There is no specific redraw command for this, just redraw all - * windows on the current buffer. */ + // May have to show a different kind of highlighting for the selected + // area. There is no specific redraw command for this, just redraw all + // windows on the current buffer. if (was_owned && (get_real_state() == VISUAL || get_real_state() == SELECTMODE) @@ -899,8 +898,8 @@ clip_copy_selection(Clipboard_T *clip) * prevents accessing the clipboard very often which might slow down Vim * considerably. */ -static int global_change_count = 0; /* if set, inside a start_global_changes */ -static int clipboard_needs_update = FALSE; /* clipboard needs to be updated */ +static int global_change_count = 0; // if set, inside a start_global_changes +static int clipboard_needs_update = FALSE; // clipboard needs to be updated static int clip_did_set_selection = TRUE; /* @@ -938,7 +937,7 @@ is_clipboard_needs_update() end_global_changes(void) { if (--global_change_count > 0) - /* recursive */ + // recursive return; if (!clip_did_set_selection) { @@ -947,8 +946,8 @@ end_global_changes(void) clip_unnamed_saved = 0; if (clipboard_needs_update) { - /* only store something in the clipboard, - * if we have yanked anything to it */ + // only store something in the clipboard, + // if we have yanked anything to it if (clip_unnamed & CLIP_UNNAMED) { clip_own_selection(&clip_star); @@ -1036,8 +1035,8 @@ clip_modeless(int button, int is_click, && (mod_mask & MOD_MASK_3CLICK)); if (is_click && button == MOUSE_RIGHT) { - /* Right mouse button: If there was no selection, start one. - * Otherwise extend the existing selection. */ + // Right mouse button: If there was no selection, start one. + // Otherwise extend the existing selection. if (clip_star.state == SELECT_CLEARED) clip_start_selection(mouse_col, mouse_row, FALSE); clip_process_selection(button, mouse_col, mouse_row, repeat); @@ -1046,12 +1045,12 @@ clip_modeless(int button, int is_click, clip_start_selection(mouse_col, mouse_row, repeat); else if (is_drag) { - /* Don't try extending a selection if there isn't one. Happens when - * button-down is in the cmdline and them moving mouse upwards. */ + // Don't try extending a selection if there isn't one. Happens when + // button-down is in the cmdline and them moving mouse upwards. if (clip_star.state != SELECT_CLEARED) clip_process_selection(button, mouse_col, mouse_row, repeat); } - else /* release */ + else // release clip_process_selection(MOUSE_RELEASE, mouse_col, mouse_row, FALSE); } @@ -1135,7 +1134,7 @@ clip_start_selection(int col, int row, i cb->mode = SELECT_MODE_CHAR; #ifdef FEAT_GUI - /* clear the cursor until the selection is made */ + // clear the cursor until the selection is made if (gui.in_use) gui_undraw_cursor(); #endif @@ -1265,7 +1264,7 @@ clip_process_selection( cb->mode = SELECT_MODE_CHAR; } - /* set state, for when using the right mouse button */ + // set state, for when using the right mouse button cb->state = SELECT_IN_PROGRESS; #ifdef DEBUG_SELECTION @@ -1278,11 +1277,11 @@ clip_process_selection( switch (cb->mode) { case SELECT_MODE_CHAR: - /* If we're on a different line, find where the line ends */ + // If we're on a different line, find where the line ends if (row != cb->prev.lnum) cb->word_end_col = clip_get_line_end(cb, row); - /* See if we are before or after the origin of the selection */ + // See if we are before or after the origin of the selection if (clip_compare_pos(row, col, cb->origin_row, cb->origin_start_col) >= 0) { @@ -1312,15 +1311,15 @@ clip_process_selection( break; case SELECT_MODE_WORD: - /* If we are still within the same word, do nothing */ + // If we are still within the same word, do nothing if (row == cb->prev.lnum && col >= (int)cb->word_start_col && col < (int)cb->word_end_col && !repeated_click) return; - /* Get new word boundaries */ + // Get new word boundaries clip_get_word_boundaries(cb, row, col); - /* Handle being after the origin point of selection */ + // Handle being after the origin point of selection if (clip_compare_pos(row, col, cb->origin_row, cb->origin_start_col) >= 0) clip_update_modeless_selection(cb, cb->origin_row, @@ -1411,7 +1410,7 @@ clip_may_clear_selection(int row1, int r */ void clip_scroll_selection( - int rows) /* negative for scroll down */ + int rows) // negative for scroll down { int lnum; @@ -1421,13 +1420,13 @@ clip_scroll_selection( lnum = clip_star.start.lnum - rows; if (lnum <= 0) clip_star.start.lnum = 0; - else if (lnum >= screen_Rows) /* scrolled off of the screen */ + else if (lnum >= screen_Rows) // scrolled off of the screen clip_star.state = SELECT_CLEARED; else clip_star.start.lnum = lnum; lnum = clip_star.end.lnum - rows; - if (lnum < 0) /* scrolled off of the screen */ + if (lnum < 0) // scrolled off of the screen clip_star.state = SELECT_CLEARED; else if (lnum >= screen_Rows) clip_star.end.lnum = screen_Rows - 1; @@ -1464,7 +1463,7 @@ clip_invert_area( if (how == CLIP_SET) invert = TRUE; - /* Swap the from and to positions so the from is always before */ + // Swap the from and to positions so the from is always before if (clip_compare_pos(row1, col1, row2, col2) > 0) { int tmp_row, tmp_col; @@ -1479,14 +1478,14 @@ clip_invert_area( else if (how == CLIP_TOGGLE) invert = TRUE; - /* If all on the same line, do it the easy way */ + // If all on the same line, do it the easy way if (row1 == row2) { clip_invert_rectangle(cbd, row1, col1, 1, col2 - col1, invert); } else { - /* Handle a piece of the first line */ + // Handle a piece of the first line if (col1 > 0) { clip_invert_rectangle(cbd, row1, col1, 1, @@ -1494,14 +1493,14 @@ clip_invert_area( row1++; } - /* Handle a piece of the last line */ + // Handle a piece of the last line if (col2 < max_col) { clip_invert_rectangle(cbd, row2, 0, 1, col2, invert); row2--; } - /* Handle the rectangle thats left */ + // Handle the rectangle thats left if (row2 >= row1) clip_invert_rectangle(cbd, row1, 0, row2 - row1 + 1, (int)Columns, invert); @@ -1578,7 +1577,7 @@ clip_copy_modeless_selection(int both UN int row2 = clip_star.end.lnum; int col2 = clip_star.end.col; - /* Can't use ScreenLines unless initialized */ + // Can't use ScreenLines unless initialized if (ScreenLines == NULL) return; @@ -1606,24 +1605,24 @@ clip_copy_modeless_selection(int both UN if (row2 > clip_star.max_row) row2 = clip_star.max_row; #endif - /* correct starting point for being on right halve of double-wide char */ + // correct starting point for being on right halve of double-wide char p = ScreenLines + LineOffset[row1]; if (enc_dbcs != 0) col1 -= (*mb_head_off)(p, p + col1); else if (enc_utf8 && p[col1] == 0) --col1; - /* Create a temporary buffer for storing the text */ + // Create a temporary buffer for storing the text len = (row2 - row1 + 1) * Columns + 1; if (enc_dbcs != 0) - len *= 2; /* max. 2 bytes per display cell */ + len *= 2; // max. 2 bytes per display cell else if (enc_utf8) len *= MB_MAXBYTES; buffer = alloc(len); - if (buffer == NULL) /* out of memory */ + if (buffer == NULL) // out of memory return; - /* Process each row in the selection */ + // Process each row in the selection for (bufp = buffer, row = row1; row <= row2; row++) { if (row == row1) @@ -1646,7 +1645,7 @@ clip_copy_modeless_selection(int both UN line_end_col = clip_get_line_end(&clip_star, row); - /* See if we need to nuke some trailing whitespace */ + // See if we need to nuke some trailing whitespace if (end_col >= #ifdef FEAT_PROP_POPUP clip_star.max_col @@ -1655,17 +1654,17 @@ clip_copy_modeless_selection(int both UN #endif && (row < row2 || end_col > line_end_col)) { - /* Get rid of trailing whitespace */ + // Get rid of trailing whitespace end_col = line_end_col; if (end_col < start_col) end_col = start_col; - /* If the last line extended to the end, add an extra newline */ + // If the last line extended to the end, add an extra newline if (row == row2) add_newline_flag = TRUE; } - /* If after the first row, we need to always add a newline */ + // If after the first row, we need to always add a newline if (row > row1 && !LineWraps[row - 1]) *bufp++ = NL; @@ -1680,7 +1679,7 @@ clip_copy_modeless_selection(int both UN for (i = start_col; i < end_col; ++i) if (enc_dbcs == DBCS_JPNU && p[i] == 0x8e) { - /* single-width double-byte char */ + // single-width double-byte char *bufp++ = 0x8e; *bufp++ = ScreenLines2[LineOffset[row] + i]; } @@ -1700,8 +1699,8 @@ clip_copy_modeless_selection(int both UN off = LineOffset[row]; for (i = start_col; i < end_col; ++i) { - /* The base character is either in ScreenLinesUC[] or - * ScreenLines[]. */ + // The base character is either in ScreenLinesUC[] or + // ScreenLines[]. if (ScreenLinesUC[off + i] == 0) *bufp++ = ScreenLines[off + i]; else @@ -1709,14 +1708,14 @@ clip_copy_modeless_selection(int both UN bufp += utf_char2bytes(ScreenLinesUC[off + i], bufp); for (ci = 0; ci < Screen_mco; ++ci) { - /* Add a composing character. */ + // Add a composing character. if (ScreenLinesC[ci][off + i] == 0) break; bufp += utf_char2bytes(ScreenLinesC[ci][off + i], bufp); } } - /* Skip right halve of double-wide character. */ + // Skip right halve of double-wide character. if (ScreenLines[off + i + 1] == 0) ++i; } @@ -1730,24 +1729,24 @@ clip_copy_modeless_selection(int both UN } } - /* Add a newline at the end if the selection ended there */ + // Add a newline at the end if the selection ended there if (add_newline_flag) *bufp++ = NL; - /* First cleanup any old selection and become the owner. */ + // First cleanup any old selection and become the owner. clip_free_selection(&clip_star); clip_own_selection(&clip_star); - /* Yank the text into the '*' register. */ + // Yank the text into the '*' register. clip_yank_selection(MCHAR, buffer, (long)(bufp - buffer), &clip_star); - /* Make the register contents available to the outside world. */ + // Make the register contents available to the outside world. clip_gen_set_selection(&clip_star); #ifdef FEAT_X11 if (both) { - /* Do the same for the '+' register. */ + // Do the same for the '+' register. clip_free_selection(&clip_plus); clip_own_selection(&clip_plus); clip_yank_selection(MCHAR, buffer, (long)(bufp - buffer), &clip_plus); @@ -1775,7 +1774,7 @@ clip_get_word_boundaries(Clipboard_T *cb return; p = ScreenLines + LineOffset[row]; - /* Correct for starting in the right halve of a double-wide char */ + // Correct for starting in the right halve of a double-wide char if (enc_dbcs != 0) col -= dbcs_screen_head_off(p, p + col); else if (enc_utf8 && p[col] == 0) @@ -1837,7 +1836,7 @@ clip_update_modeless_selection( int row2, int col2) { - /* See if we changed at the beginning of the selection */ + // See if we changed at the beginning of the selection if (row1 != cb->start.lnum || col1 != (int)cb->start.col) { clip_invert_area(cb, row1, col1, (int)cb->start.lnum, cb->start.col, @@ -1846,7 +1845,7 @@ clip_update_modeless_selection( cb->start.col = col1; } - /* See if we changed at the end of the selection */ + // See if we changed at the end of the selection if (row2 != cb->end.lnum || col2 != (int)cb->end.col) { clip_invert_area(cb, (int)cb->end.lnum, cb->end.col, row2, col2, @@ -1891,8 +1890,8 @@ clip_gen_set_selection(Clipboard_T *cbd) { if (!clip_did_set_selection) { - /* Updating postponed, so that accessing the system clipboard won't - * hang Vim when accessing it many times (e.g. on a :g command). */ + // Updating postponed, so that accessing the system clipboard won't + // hang Vim when accessing it many times (e.g. on a :g command). if ((cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS)) || (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED))) { @@ -2037,17 +2036,16 @@ check_clipboard_option(void) #endif // FEAT_CLIPBOARD -/***************************************************************************** - * Functions that handle the input buffer. - * This is used for any GUI version, and the unix terminal version. - * - * For Unix, the input characters are buffered to be able to check for a - * CTRL-C. This should be done with signals, but I don't know how to do that - * in a portable way for a tty in RAW mode. - * - * For the client-server code in the console the received keys are put in the - * input buffer. - */ +////////////////////////////////////////////////////////////////////////////// +// Functions that handle the input buffer. +// This is used for any GUI version, and the unix terminal version. +// +// For Unix, the input characters are buffered to be able to check for a +// CTRL-C. This should be done with signals, but I don't know how to do that +// in a portable way for a tty in RAW mode. +// +// For the client-server code in the console the received keys are put in the +// input buffer. #if defined(USE_INPUT_BUF) || defined(PROTO) @@ -2068,7 +2066,7 @@ check_clipboard_option(void) #endif static char_u inbuf[INBUFLEN + MAX_KEY_CODE_LEN]; -static int inbufcount = 0; /* number of chars in inbuf[] */ +static int inbufcount = 0; // number of chars in inbuf[] /* * vim_is_input_buf_full(), vim_is_input_buf_empty(), add_to_input_buf(), and @@ -2113,11 +2111,11 @@ get_input_buf(void) { garray_T *gap; - /* We use a growarray to store the data pointer and the length. */ + // We use a growarray to store the data pointer and the length. gap = ALLOC_ONE(garray_T); if (gap != NULL) { - /* Add one to avoid a zero size. */ + // Add one to avoid a zero size. gap->ga_data = alloc(inbufcount + 1); if (gap->ga_data != NULL) mch_memmove(gap->ga_data, inbuf, (size_t)inbufcount); @@ -2157,7 +2155,7 @@ set_input_buf(char_u *p) add_to_input_buf(char_u *s, int len) { if (inbufcount + len > INBUFLEN + MAX_KEY_CODE_LEN) - return; /* Shouldn't ever happen! */ + return; // Shouldn't ever happen! while (len--) inbuf[inbufcount++] = *s++; @@ -2177,7 +2175,7 @@ add_to_input_buf_csi(char_u *str, int le add_to_input_buf(str + i, 1); if (str[i] == CSI) { - /* Turn CSI into K_CSI. */ + // Turn CSI into K_CSI. buf[0] = KS_EXTRA; buf[1] = (int)KE_CSI; add_to_input_buf(buf, 2); @@ -2185,7 +2183,9 @@ add_to_input_buf_csi(char_u *str, int le } } -/* Remove everything from the input buffer. Called when ^C is found */ +/* + * Remove everything from the input buffer. Called when ^C is found. + */ void trash_input_buf(void) { @@ -2199,7 +2199,7 @@ trash_input_buf(void) int read_from_input_buf(char_u *buf, long maxlen) { - if (inbufcount == 0) /* if the buffer is empty, fill it */ + if (inbufcount == 0) // if the buffer is empty, fill it fill_input_buf(TRUE); if (maxlen > inbufcount) maxlen = inbufcount; @@ -2217,7 +2217,7 @@ fill_input_buf(int exit_on_error UNUSED) int len; int try; static int did_read_something = FALSE; - static char_u *rest = NULL; /* unconverted rest of previous read */ + static char_u *rest = NULL; // unconverted rest of previous read static int restlen = 0; int unconverted; #endif @@ -2225,8 +2225,8 @@ fill_input_buf(int exit_on_error UNUSED) #ifdef FEAT_GUI if (gui.in_use # ifdef NO_CONSOLE_INPUT - /* Don't use the GUI input when the window hasn't been opened yet. - * We get here from ui_inchar() when we should try reading from stdin. */ + // Don't use the GUI input when the window hasn't been opened yet. + // We get here from ui_inchar() when we should try reading from stdin. && !no_console_input() # endif ) @@ -2257,8 +2257,8 @@ fill_input_buf(int exit_on_error UNUSED) if (rest != NULL) { - /* Use remainder of previous call, starts with an invalid character - * that may become valid when reading more. */ + // Use remainder of previous call, starts with an invalid character + // that may become valid when reading more. if (restlen > INBUFLEN - inbufcount) unconverted = INBUFLEN - inbufcount; else @@ -2276,7 +2276,7 @@ fill_input_buf(int exit_on_error UNUSED) else unconverted = 0; - len = 0; /* to avoid gcc warning */ + len = 0; // to avoid gcc warning for (try = 0; try < 100; ++try) { size_t readlen = (size_t)((INBUFLEN - inbufcount) @@ -2297,16 +2297,16 @@ fill_input_buf(int exit_on_error UNUSED) { int m = cur_tmode; - /* We probably set the wrong file descriptor to raw mode. Switch - * back to cooked mode, use another descriptor and set the mode to - * what it was. */ + // We probably set the wrong file descriptor to raw mode. Switch + // back to cooked mode, use another descriptor and set the mode to + // what it was. settmode(TMODE_COOK); #ifdef HAVE_DUP - /* Use stderr for stdin, also works for shell commands. */ + // Use stderr for stdin, also works for shell commands. close(0); vim_ignored = dup(2); #else - read_cmd_fd = 2; /* read from stderr instead of stdin */ + read_cmd_fd = 2; // read from stderr instead of stdin #endif settmode(m); } @@ -2320,7 +2320,7 @@ fill_input_buf(int exit_on_error UNUSED) did_read_something = TRUE; if (got_int) { - /* Interrupted, pretend a CTRL-C was typed. */ + // Interrupted, pretend a CTRL-C was typed. inbuf[0] = 3; inbufcount = 1; } @@ -2348,7 +2348,7 @@ fill_input_buf(int exit_on_error UNUSED) */ if (inbuf[inbufcount] == 3 && ctrl_c_interrupts) { - /* remove everything typed before the CTRL-C */ + // remove everything typed before the CTRL-C mch_memmove(inbuf, inbuf + inbufcount, (size_t)(len + 1)); inbufcount = 0; got_int = TRUE; @@ -2356,9 +2356,9 @@ fill_input_buf(int exit_on_error UNUSED) ++inbufcount; } } -#endif /* UNIX or VMS*/ +#endif // UNIX or VMS } -#endif /* defined(UNIX) || defined(FEAT_GUI) || defined(VMS) */ +#endif // defined(UNIX) || defined(FEAT_GUI) || defined(VMS) /* * Exit because of an input read error. @@ -2366,7 +2366,7 @@ fill_input_buf(int exit_on_error UNUSED) void read_error_exit(void) { - if (silent_mode) /* Normal way to exit for "ex -s" */ + if (silent_mode) // Normal way to exit for "ex -s" getout(0); STRCPY(IObuff, _("Vim: Error reading input, exiting...\n")); preserve_exit(); @@ -2450,13 +2450,13 @@ open_app_context(void) } } -static Atom vim_atom; /* Vim's own special selection format */ -static Atom vimenc_atom; /* Vim's extended selection format */ +static Atom vim_atom; // Vim's own special selection format +static Atom vimenc_atom; // Vim's extended selection format static Atom utf8_atom; static Atom compound_text_atom; static Atom text_atom; static Atom targets_atom; -static Atom timestamp_atom; /* Used to get a timestamp */ +static Atom timestamp_atom; // Used to get a timestamp void x11_setup_atoms(Display *dpy) @@ -2496,8 +2496,8 @@ clip_x11_timestamp_cb( unsigned char *prop=NULL; XPropertyEvent *xproperty=&event->xproperty; - /* Must be a property notify, state can't be Delete (True), has to be - * one of the supported selection types. */ + // Must be a property notify, state can't be Delete (True), has to be + // one of the supported selection types. if (event->type != PropertyNotify || xproperty->state || (xproperty->atom != clip_star.sel_atom && xproperty->atom != clip_plus.sel_atom)) @@ -2511,17 +2511,17 @@ clip_x11_timestamp_cb( if (prop) XFree(prop); - /* Make sure the property type is "TIMESTAMP" and it's 32 bits. */ + // Make sure the property type is "TIMESTAMP" and it's 32 bits. if (actual_type != timestamp_atom || format != 32) return; - /* Get the selection, using the event timestamp. */ + // Get the selection, using the event timestamp. if (XtOwnSelection(w, xproperty->atom, xproperty->time, clip_x11_convert_selection_cb, clip_x11_lose_ownership_cb, clip_x11_notify_cb) == OK) { - /* Set the "owned" flag now, there may have been a call to - * lose_ownership_cb in between. */ + // Set the "owned" flag now, there may have been a call to + // lose_ownership_cb in between. if (xproperty->atom == clip_plus.sel_atom) clip_plus.owned = TRUE; else @@ -2560,7 +2560,7 @@ clip_x11_request_selection_cb( if (value == NULL || *length == 0) { - clip_free_selection(cbd); /* nothing received, clear register */ + clip_free_selection(cbd); // nothing received, clear register *(int *)success = FALSE; return; } @@ -2585,13 +2585,13 @@ clip_x11_request_selection_cb( p += STRLEN(p) + 1; len -= p - enc; - /* If the encoding of the text is different from 'encoding', attempt - * converting it. */ + // If the encoding of the text is different from 'encoding', attempt + // converting it. conv.vc_type = CONV_NONE; convert_setup(&conv, enc, p_enc); if (conv.vc_type != CONV_NONE) { - convlen = len; /* Need to use an int here. */ + convlen = len; // Need to use an int here. tmpbuf = string_convert(&conv, p, &convlen); len = convlen; if (tmpbuf != NULL) @@ -2666,15 +2666,15 @@ clip_x11_request_selection( && !enc_utf8 # endif ) - /* Only request utf-8 when 'encoding' is utf8 and - * Xutf8TextPropertyToTextList is available. */ + // Only request utf-8 when 'encoding' is utf8 and + // Xutf8TextPropertyToTextList is available. continue; success = MAYBE; XtGetSelectionValue(myShell, cbd->sel_atom, type, clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime); - /* Make sure the request for the selection goes out before waiting for - * a response. */ + // Make sure the request for the selection goes out before waiting for + // a response. XFlush(dpy); /* @@ -2689,44 +2689,44 @@ clip_x11_request_selection( || XCheckTypedEvent(dpy, SelectionNotify, &event) || XCheckTypedEvent(dpy, SelectionRequest, &event)) { - /* This is where clip_x11_request_selection_cb() should be - * called. It may actually happen a bit later, so we loop - * until "success" changes. - * We may get a SelectionRequest here and if we don't handle - * it we hang. KDE klipper does this, for example. - * We need to handle a PropertyNotify for large selections. */ + // This is where clip_x11_request_selection_cb() should be + // called. It may actually happen a bit later, so we loop + // until "success" changes. + // We may get a SelectionRequest here and if we don't handle + // it we hang. KDE klipper does this, for example. + // We need to handle a PropertyNotify for large selections. XtDispatchEvent(&event); continue; } - /* Time out after 2 to 3 seconds to avoid that we hang when the - * other process doesn't respond. Note that the SelectionNotify - * event may still come later when the selection owner comes back - * to life and the text gets inserted unexpectedly. Don't know - * why that happens or how to avoid that :-(. */ + // Time out after 2 to 3 seconds to avoid that we hang when the + // other process doesn't respond. Note that the SelectionNotify + // event may still come later when the selection owner comes back + // to life and the text gets inserted unexpectedly. Don't know + // why that happens or how to avoid that :-(. if (time(NULL) > start_time + 2) { timed_out = TRUE; break; } - /* Do we need this? Probably not. */ + // Do we need this? Probably not. XSync(dpy, False); - /* Wait for 1 msec to avoid that we eat up all CPU time. */ + // Wait for 1 msec to avoid that we eat up all CPU time. ui_delay(1L, TRUE); } if (success == TRUE) return; - /* don't do a retry with another type after timing out, otherwise we - * hang for 15 seconds. */ + // don't do a retry with another type after timing out, otherwise we + // hang for 15 seconds. if (timed_out) break; } - /* Final fallback position - use the X CUT_BUFFER0 store */ + // Final fallback position - use the X CUT_BUFFER0 store yank_cut_buffer0(dpy, cbd); } @@ -2753,9 +2753,9 @@ clip_x11_convert_selection_cb( cbd = &clip_star; if (!cbd->owned) - return False; /* Shouldn't ever happen */ + return False; // Shouldn't ever happen - /* requestor wants to know what target types we support */ + // requestor wants to know what target types we support if (*target == targets_atom) { static Atom array[7]; @@ -2772,8 +2772,8 @@ clip_x11_convert_selection_cb( array[i++] = compound_text_atom; *type = XA_ATOM; - /* This used to be: *format = sizeof(Atom) * 8; but that caused - * crashes on 64 bit machines. (Peter Derr) */ + // This used to be: *format = sizeof(Atom) * 8; but that caused + // crashes on 64 bit machines. (Peter Derr) *format = 32; *length = i; return True; @@ -2792,11 +2792,11 @@ clip_x11_convert_selection_cb( if (motion_type < 0) return False; - /* For our own format, the first byte contains the motion type */ + // For our own format, the first byte contains the motion type if (*target == vim_atom) (*length)++; - /* Our own format with encoding: motion 'encoding' NUL text */ + // Our own format with encoding: motion 'encoding' NUL text if (*target == vimenc_atom) *length += STRLEN(p_enc) + 2; @@ -2823,7 +2823,7 @@ clip_x11_convert_selection_cb( char *string_nt = (char *)save_result; int conv_result; - /* create NUL terminated string which XmbTextListToTextProperty wants */ + // create NUL terminated string which XmbTextListToTextProperty wants mch_memmove(string_nt, string, (size_t)*length); string_nt[*length] = NUL; conv_result = XmbTextListToTextProperty(X_DISPLAY, (char **)&string_nt, @@ -2833,7 +2833,7 @@ clip_x11_convert_selection_cb( vim_free(string); return False; } - *value = (XtPointer)(text_prop.value); /* from plain text */ + *value = (XtPointer)(text_prop.value); // from plain text *length = text_prop.nitems; *type = compound_text_atom; XtFree((char *)save_result); @@ -2855,7 +2855,7 @@ clip_x11_convert_selection_cb( mch_memmove(save_result + 1, string, (size_t)(*length - 1)); *type = vim_atom; } - *format = 8; /* 8 bits per char */ + *format = 8; // 8 bits per char vim_free(string); return True; } @@ -2879,16 +2879,16 @@ clip_x11_lose_selection(Widget myShell, static void clip_x11_notify_cb(Widget w UNUSED, Atom *sel_atom UNUSED, Atom *target UNUSED) { - /* To prevent automatically freeing the selection value. */ + // To prevent automatically freeing the selection value. } int clip_x11_own_selection(Widget myShell, Clipboard_T *cbd) { - /* When using the GUI we have proper timestamps, use the one of the last - * event. When in the console we don't get events (the terminal gets - * them), Get the time by a zero-length append, clip_x11_timestamp_cb will - * be called with the current timestamp. */ + // When using the GUI we have proper timestamps, use the one of the last + // event. When in the console we don't get events (the terminal gets + // them), Get the time by a zero-length append, clip_x11_timestamp_cb will + // be called with the current timestamp. #ifdef FEAT_GUI if (gui.in_use) { @@ -2905,7 +2905,7 @@ clip_x11_own_selection(Widget myShell, C cbd->sel_atom, timestamp_atom, 32, PropModeAppend, NULL, 0)) return FAIL; } - /* Flush is required in a terminal as nothing else is doing it. */ + // Flush is required in a terminal as nothing else is doing it. XFlush(XtDisplay(myShell)); return OK; } @@ -2944,10 +2944,10 @@ yank_cut_buffer0(Display *dpy, Clipboard { int done = FALSE; - /* CUT_BUFFER0 is supposed to be always latin1. Convert to 'enc' when - * using a multi-byte encoding. Conversion between two 8-bit - * character sets usually fails and the text might actually be in - * 'enc' anyway. */ + // CUT_BUFFER0 is supposed to be always latin1. Convert to 'enc' when + // using a multi-byte encoding. Conversion between two 8-bit + // character sets usually fails and the text might actually be in + // 'enc' anyway. if (has_mbyte) { char_u *conv_buf; @@ -2966,7 +2966,7 @@ yank_cut_buffer0(Display *dpy, Clipboard convert_setup(&vc, NULL, NULL); } } - if (!done) /* use the text without conversion */ + if (!done) // use the text without conversion clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd); XFree((void *)buffer); if (p_verbose > 0) @@ -2986,14 +2986,14 @@ yank_cut_buffer0(Display *dpy, Clipboard */ void ui_focus_change( - int in_focus) /* TRUE if focus gained. */ + int in_focus) // TRUE if focus gained. { static time_t last_time = (time_t)0; int need_redraw = FALSE; - /* When activated: Check if any file was modified outside of Vim. - * Only do this when not done within the last two seconds (could get - * several events in a row). */ + // When activated: Check if any file was modified outside of Vim. + // Only do this when not done within the last two seconds (could get + // several events in a row). if (in_focus && last_time + 2 < time(NULL)) { need_redraw = check_timestamps( @@ -3014,8 +3014,8 @@ ui_focus_change( if (need_redraw) { - /* Something was executed, make sure the cursor is put back where it - * belongs. */ + // Something was executed, make sure the cursor is put back where it + // belongs. need_wait_return = FALSE; if (State & CMDLINE) @@ -3029,7 +3029,7 @@ ui_focus_change( update_screen(0); setcursor(); } - cursor_on(); /* redrawing may have switched it off */ + cursor_on(); // redrawing may have switched it off out_flush_cursor(FALSE, TRUE); # ifdef FEAT_GUI if (gui.in_use) @@ -3037,7 +3037,7 @@ ui_focus_change( # endif } #ifdef FEAT_TITLE - /* File may have been changed from 'readonly' to 'noreadonly' */ + // File may have been changed from 'readonly' to 'noreadonly' if (need_maketitle) maketitle(); #endif @@ -3051,13 +3051,13 @@ ui_focus_change( void im_save_status(long *psave) { - /* Don't save when 'imdisable' is set or "xic" is NULL, IM is always - * disabled then (but might start later). - * Also don't save when inside a mapping, vgetc_im_active has not been set - * then. - * And don't save when the keys were stuffed (e.g., for a "." command). - * And don't save when the GUI is running but our window doesn't have - * input focus (e.g., when a find dialog is open). */ + // Don't save when 'imdisable' is set or "xic" is NULL, IM is always + // disabled then (but might start later). + // Also don't save when inside a mapping, vgetc_im_active has not been set + // then. + // And don't save when the keys were stuffed (e.g., for a "." command). + // And don't save when the GUI is running but our window doesn't have + // input focus (e.g., when a find dialog is open). if (!p_imdisable && KeyTyped && !KeyStuffed # ifdef FEAT_XIM && xic != NULL @@ -3067,7 +3067,7 @@ im_save_status(long *psave) # endif ) { - /* Do save when IM is on, or IM is off and saved status is on. */ + // Do save when IM is on, or IM is off and saved status is on. if (vgetc_im_active) *psave = B_IMODE_IM; else if (*psave == B_IMODE_IM)
--- a/src/undo.c +++ b/src/undo.c @@ -75,27 +75,27 @@ * All data is allocated and will all be freed when the buffer is unloaded. */ -/* Uncomment the next line for including the u_check() function. This warns - * for errors in the debug information. */ -/* #define U_DEBUG 1 */ -#define UH_MAGIC 0x18dade /* value for uh_magic when in use */ -#define UE_MAGIC 0xabc123 /* value for ue_magic when in use */ - -/* Size of buffer used for encryption. */ +// Uncomment the next line for including the u_check() function. This warns +// for errors in the debug information. +// #define U_DEBUG 1 +#define UH_MAGIC 0x18dade // value for uh_magic when in use +#define UE_MAGIC 0xabc123 // value for ue_magic when in use + +// Size of buffer used for encryption. #define CRYPT_BUF_SIZE 8192 #include "vim.h" -/* Structure passed around between functions. - * Avoids passing cryptstate_T when encryption not available. */ +// Structure passed around between functions. +// Avoids passing cryptstate_T when encryption not available. typedef struct { buf_T *bi_buf; FILE *bi_fp; #ifdef FEAT_CRYPT cryptstate_T *bi_state; - char_u *bi_buffer; /* CRYPT_BUF_SIZE, NULL when not buffering */ - size_t bi_used; /* bytes written to/read from bi_buffer */ - size_t bi_avail; /* bytes available in bi_buffer */ + char_u *bi_buffer; // CRYPT_BUF_SIZE, NULL when not buffering + size_t bi_used; // bytes written to/read from bi_buffer + size_t bi_avail; // bytes available in bi_buffer #endif } bufinfo_T; @@ -126,7 +126,7 @@ static void u_saveline(linenr_T lnum); #define U_ALLOC_LINE(size) lalloc(size, FALSE) -/* used in undo_end() to report number of added and deleted lines */ +// used in undo_end() to report number of added and deleted lines static long u_newcount, u_oldcount; /* @@ -171,7 +171,7 @@ u_check_tree(u_header_T *uhp, emsg("uh_magic wrong (may be using freed memory)"); else { - /* Check pointers back are correct. */ + // Check pointers back are correct. if (uhp->uh_next.ptr != exp_uh_next) { emsg("uh_next wrong"); @@ -185,7 +185,7 @@ u_check_tree(u_header_T *uhp, exp_uh_alt_prev, uhp->uh_alt_prev.ptr); } - /* Check the undo tree at this header. */ + // Check the undo tree at this header. for (uep = uhp->uh_entry; uep != NULL; uep = uep->ue_next) { if (uep->ue_magic != UE_MAGIC) @@ -195,10 +195,10 @@ u_check_tree(u_header_T *uhp, } } - /* Check the next alt tree. */ + // Check the next alt tree. u_check_tree(uhp->uh_alt_next.ptr, uhp->uh_next.ptr, uhp); - /* Check the next header in this branch. */ + // Check the next header in this branch. u_check_tree(uhp->uh_prev.ptr, uhp, NULL); } } @@ -313,7 +313,7 @@ u_savedel(linenr_T lnum, long nlines) int undo_allowed(void) { - /* Don't allow changes when 'modifiable' is off. */ + // Don't allow changes when 'modifiable' is off. if (!curbuf->b_p_ma) { emsg(_(e_modifiable)); @@ -321,7 +321,7 @@ undo_allowed(void) } #ifdef HAVE_SANDBOX - /* In the sandbox it's not allowed to change the text. */ + // In the sandbox it's not allowed to change the text. if (sandbox != 0) { emsg(_(e_sandbox)); @@ -329,8 +329,8 @@ undo_allowed(void) } #endif - /* Don't allow changes in the buffer while editing the cmdline. The - * caller of getcmdline() may get confused. */ + // Don't allow changes in the buffer while editing the cmdline. The + // caller of getcmdline() may get confused. if (textlock != 0) { emsg(_(e_secure)); @@ -401,8 +401,8 @@ u_savecommon( if (!reload) { - /* When making changes is not allowed return FAIL. It's a crude way - * to make all change commands fail. */ + // When making changes is not allowed return FAIL. It's a crude way + // to make all change commands fail. if (!undo_allowed()) return FAIL; @@ -426,7 +426,7 @@ u_savecommon( } #endif #ifdef FEAT_TERMINAL - /* A change in a terminal buffer removes the highlighting. */ + // A change in a terminal buffer removes the highlighting. term_change_in_curbuf(); #endif @@ -439,8 +439,8 @@ u_savecommon( change_warning(0); if (bot > curbuf->b_ml.ml_line_count + 1) { - /* This happens when the FileChangedRO autocommand changes the - * file in a way it becomes shorter. */ + // This happens when the FileChangedRO autocommand changes the + // file in a way it becomes shorter. emsg(_("E881: Line count changed unexpectedly")); return FAIL; } @@ -458,7 +458,7 @@ u_savecommon( if (curbuf->b_u_synced) { #ifdef FEAT_JUMPLIST - /* Need to create new entry in b_changelist. */ + // Need to create new entry in b_changelist. curbuf->b_new_change = TRUE; #endif @@ -498,14 +498,14 @@ u_savecommon( u_header_T *uhfree = curbuf->b_u_oldhead; if (uhfree == old_curhead) - /* Can't reconnect the branch, delete all of it. */ + // Can't reconnect the branch, delete all of it. u_freebranch(curbuf, uhfree, &old_curhead); else if (uhfree->uh_alt_next.ptr == NULL) - /* There is no branch, only free one header. */ + // There is no branch, only free one header. u_freeheader(curbuf, uhfree, &old_curhead); else { - /* Free the oldest alternate branch as a whole. */ + // Free the oldest alternate branch as a whole. while (uhfree->uh_alt_next.ptr != NULL) uhfree = uhfree->uh_alt_next.ptr; u_freebranch(curbuf, uhfree, &old_curhead); @@ -515,7 +515,7 @@ u_savecommon( #endif } - if (uhp == NULL) /* no undo at all */ + if (uhp == NULL) // no undo at all { if (old_curhead != NULL) u_freebranch(curbuf, old_curhead, NULL); @@ -549,17 +549,17 @@ u_savecommon( uhp->uh_walk = 0; uhp->uh_entry = NULL; uhp->uh_getbot_entry = NULL; - uhp->uh_cursor = curwin->w_cursor; /* save cursor pos. for undo */ + uhp->uh_cursor = curwin->w_cursor; // save cursor pos. for undo if (virtual_active() && curwin->w_cursor.coladd > 0) uhp->uh_cursor_vcol = getviscol(); else uhp->uh_cursor_vcol = -1; - /* save changed and buffer empty flag for undo */ + // save changed and buffer empty flag for undo uhp->uh_flags = (curbuf->b_changed ? UH_CHANGED : 0) + ((curbuf->b_ml.ml_flags & ML_EMPTY) ? UH_EMPTYBUF : 0); - /* save named marks and Visual marks for undo */ + // save named marks and Visual marks for undo mch_memmove(uhp->uh_namedm, curbuf->b_namedm, sizeof(pos_T) * NMARKS); uhp->uh_visual = curbuf->b_visual; @@ -570,7 +570,7 @@ u_savecommon( } else { - if (get_undolevel() < 0) /* no undo at all */ + if (get_undolevel() < 0) // no undo at all return OK; /* @@ -591,8 +591,8 @@ u_savecommon( if (uep == NULL) break; - /* If lines have been inserted/deleted we give up. - * Also when the line was included in a multi-line save. */ + // If lines have been inserted/deleted we give up. + // Also when the line was included in a multi-line save. if ((curbuf->b_u_newhead->uh_getbot_entry != uep ? (uep->ue_top + uep->ue_size + 1 != (uep->ue_bot == 0 @@ -604,29 +604,29 @@ u_savecommon( && top + 2 <= uep->ue_top + uep->ue_size + 1)) break; - /* If it's the same line we can skip saving it again. */ + // If it's the same line we can skip saving it again. if (uep->ue_size == 1 && uep->ue_top == top) { if (i > 0) { - /* It's not the last entry: get ue_bot for the last - * entry now. Following deleted/inserted lines go to - * the re-used entry. */ + // It's not the last entry: get ue_bot for the last + // entry now. Following deleted/inserted lines go to + // the re-used entry. u_getbot(); curbuf->b_u_synced = FALSE; - /* Move the found entry to become the last entry. The - * order of undo/redo doesn't matter for the entries - * we move it over, since they don't change the line - * count and don't include this line. It does matter - * for the found entry if the line count is changed by - * the executed command. */ + // Move the found entry to become the last entry. The + // order of undo/redo doesn't matter for the entries + // we move it over, since they don't change the line + // count and don't include this line. It does matter + // for the found entry if the line count is changed by + // the executed command. prev_uep->ue_next = uep->ue_next; uep->ue_next = curbuf->b_u_newhead->uh_entry; curbuf->b_u_newhead->uh_entry = uep; } - /* The executed command may change the line count. */ + // The executed command may change the line count. if (newbot != 0) uep->ue_bot = newbot; else if (bot > curbuf->b_ml.ml_line_count) @@ -643,7 +643,7 @@ u_savecommon( } } - /* find line number for ue_bot for previous u_save() */ + // find line number for ue_bot for previous u_save() u_getbot(); } @@ -718,11 +718,11 @@ u_savecommon( return OK; nomem: - msg_silent = 0; /* must display the prompt */ + msg_silent = 0; // must display the prompt if (ask_yesno((char_u *)_("No undo possible; continue anyway"), TRUE) == 'y') { - undo_off = TRUE; /* will be reset when character typed */ + undo_off = TRUE; // will be reset when character typed return OK; } do_outofmem_msg((long_u)0); @@ -731,19 +731,19 @@ nomem: #if defined(FEAT_PERSISTENT_UNDO) || defined(PROTO) -# define UF_START_MAGIC "Vim\237UnDo\345" /* magic at start of undofile */ +# define UF_START_MAGIC "Vim\237UnDo\345" // magic at start of undofile # define UF_START_MAGIC_LEN 9 -# define UF_HEADER_MAGIC 0x5fd0 /* magic at start of header */ -# define UF_HEADER_END_MAGIC 0xe7aa /* magic after last header */ -# define UF_ENTRY_MAGIC 0xf518 /* magic at start of entry */ -# define UF_ENTRY_END_MAGIC 0x3581 /* magic after last entry */ -# define UF_VERSION 2 /* 2-byte undofile version number */ -# define UF_VERSION_CRYPT 0x8002 /* idem, encrypted */ - -/* extra fields for header */ +# define UF_HEADER_MAGIC 0x5fd0 // magic at start of header +# define UF_HEADER_END_MAGIC 0xe7aa // magic after last header +# define UF_ENTRY_MAGIC 0xf518 // magic at start of entry +# define UF_ENTRY_END_MAGIC 0x3581 // magic after last entry +# define UF_VERSION 2 // 2-byte undofile version number +# define UF_VERSION_CRYPT 0x8002 // idem, encrypted + +// extra fields for header # define UF_LAST_SAVE_NR 1 -/* extra fields for uhp */ +// extra fields for uhp # define UHP_SAVE_NR 1 static char_u e_not_open[] = N_("E828: Cannot open undo file for writing: %s"); @@ -793,36 +793,36 @@ u_get_undo_file_name(char_u *buf_ffname, return NULL; #ifdef HAVE_READLINK - /* Expand symlink in the file name, so that we put the undo file with the - * actual file instead of with the symlink. */ + // Expand symlink in the file name, so that we put the undo file with the + // actual file instead of with the symlink. if (resolve_symlink(ffname, fname_buf) == OK) ffname = fname_buf; #endif - /* Loop over 'undodir'. When reading find the first file that exists. - * When not reading use the first directory that exists or ".". */ + // Loop over 'undodir'. When reading find the first file that exists. + // When not reading use the first directory that exists or ".". dirp = p_udir; while (*dirp != NUL) { dir_len = copy_option_part(&dirp, dir_name, IOSIZE, ","); if (dir_len == 1 && dir_name[0] == '.') { - /* Use same directory as the ffname, - * "dir/name" -> "dir/.name.un~" */ + // Use same directory as the ffname, + // "dir/name" -> "dir/.name.un~" undo_file_name = vim_strnsave(ffname, (int)(STRLEN(ffname) + 5)); if (undo_file_name == NULL) break; p = gettail(undo_file_name); #ifdef VMS - /* VMS can not handle more than one dot in the filenames - * use "dir/name" -> "dir/_un_name" - add _un_ - * at the beginning to keep the extension */ + // VMS can not handle more than one dot in the filenames + // use "dir/name" -> "dir/_un_name" - add _un_ + // at the beginning to keep the extension mch_memmove(p + 4, p, STRLEN(p) + 1); mch_memmove(p, "_un_", 4); #else - /* Use same directory as the ffname, - * "dir/name" -> "dir/.name.un~" */ + // Use same directory as the ffname, + // "dir/name" -> "dir/.name.un~" mch_memmove(p + 1, p, STRLEN(p) + 1); *p = '.'; STRCAT(p, ".un~"); @@ -846,7 +846,7 @@ u_get_undo_file_name(char_u *buf_ffname, } } - /* When reading check if the file exists. */ + // When reading check if the file exists. if (undo_file_name != NULL && (!reading || mch_stat((char *)undo_file_name, &st) >= 0)) break; @@ -946,9 +946,9 @@ fwrite_crypt(bufinfo_T *bi, char_u *ptr, if (bi->bi_state != NULL && bi->bi_buffer == NULL) { - /* crypting every piece of text separately */ + // crypting every piece of text separately if (len < 100) - copy = small_buf; /* no malloc()/free() for short strings */ + copy = small_buf; // no malloc()/free() for short strings else { copy = lalloc(len, FALSE); @@ -1106,8 +1106,8 @@ undo_read(bufinfo_T *bi, char_u *buffer, retval = FAIL; if (retval == FAIL) - /* Error may be checked for only later. Fill with zeros, - * so that the reader won't use garbage. */ + // Error may be checked for only later. Fill with zeros, + // so that the reader won't use garbage. vim_memset(buffer, 0, size); return retval; } @@ -1153,12 +1153,12 @@ serialize_header(bufinfo_T *bi, char_u * FILE *fp = bi->bi_fp; char_u time_buf[8]; - /* Start writing, first the magic marker and undo info version. */ + // Start writing, first the magic marker and undo info version. if (fwrite(UF_START_MAGIC, (size_t)UF_START_MAGIC_LEN, (size_t)1, fp) != 1) return FAIL; - /* If the buffer is encrypted then all text bytes following will be - * encrypted. Numbers and other info is not crypted. */ + // If the buffer is encrypted then all text bytes following will be + // encrypted. Numbers and other info is not crypted. #ifdef FEAT_CRYPT if (*buf->b_p_key != NUL) { @@ -1196,12 +1196,12 @@ serialize_header(bufinfo_T *bi, char_u * undo_write_bytes(bi, (long_u)UF_VERSION, 2); - /* Write a hash of the buffer text, so that we can verify it is still the - * same when reading the buffer text. */ + // Write a hash of the buffer text, so that we can verify it is still the + // same when reading the buffer text. if (undo_write(bi, hash, (size_t)UNDO_HASH_SIZE) == FAIL) return FAIL; - /* buffer-specific data */ + // buffer-specific data undo_write_bytes(bi, (long_u)buf->b_ml.ml_line_count, 4); len = buf->b_u_line_ptr.ul_line == NULL ? 0L : (long)STRLEN(buf->b_u_line_ptr.ul_line); @@ -1212,7 +1212,7 @@ serialize_header(bufinfo_T *bi, char_u * undo_write_bytes(bi, (long_u)buf->b_u_line_lnum, 4); undo_write_bytes(bi, (long_u)buf->b_u_line_colnr, 4); - /* Undo structures header data */ + // Undo structures header data put_header_ptr(bi, buf->b_u_oldhead); put_header_ptr(bi, buf->b_u_newhead); put_header_ptr(bi, buf->b_u_curhead); @@ -1223,12 +1223,12 @@ serialize_header(bufinfo_T *bi, char_u * time_to_bytes(buf->b_u_time_cur, time_buf); undo_write(bi, time_buf, 8); - /* Optional fields. */ + // Optional fields. undo_write_bytes(bi, 4, 1); undo_write_bytes(bi, UF_LAST_SAVE_NR, 1); undo_write_bytes(bi, (long_u)buf->b_u_save_nr_last, 4); - undo_write_bytes(bi, 0, 1); /* end marker */ + undo_write_bytes(bi, 0, 1); // end marker return OK; } @@ -1251,21 +1251,21 @@ serialize_uhp(bufinfo_T *bi, u_header_T serialize_pos(bi, uhp->uh_cursor); undo_write_bytes(bi, (long_u)uhp->uh_cursor_vcol, 4); undo_write_bytes(bi, (long_u)uhp->uh_flags, 2); - /* Assume NMARKS will stay the same. */ + // Assume NMARKS will stay the same. for (i = 0; i < NMARKS; ++i) serialize_pos(bi, uhp->uh_namedm[i]); serialize_visualinfo(bi, &uhp->uh_visual); time_to_bytes(uhp->uh_time, time_buf); undo_write(bi, time_buf, 8); - /* Optional fields. */ + // Optional fields. undo_write_bytes(bi, 4, 1); undo_write_bytes(bi, UHP_SAVE_NR, 1); undo_write_bytes(bi, (long_u)uhp->uh_save_nr, 4); - undo_write_bytes(bi, 0, 1); /* end marker */ - - /* Write all the entries. */ + undo_write_bytes(bi, 0, 1); // end marker + + // Write all the entries. for (uep = uhp->uh_entry; uep != NULL; uep = uep->ue_next) { undo_write_bytes(bi, (long_u)UF_ENTRY_MAGIC, 2); @@ -1311,7 +1311,7 @@ unserialize_uhp(bufinfo_T *bi, char_u *f unserialize_visualinfo(bi, &uhp->uh_visual); uhp->uh_time = undo_read_time(bi); - /* Optional fields. */ + // Optional fields. for (;;) { int len = undo_read_byte(bi); @@ -1332,13 +1332,13 @@ unserialize_uhp(bufinfo_T *bi, char_u *f uhp->uh_save_nr = undo_read_4c(bi); break; default: - /* field not supported, skip */ + // field not supported, skip while (--len >= 0) (void)undo_read_byte(bi); } } - /* Unserialize the uep list. */ + // Unserialize the uep list. last_uep = NULL; while ((c = undo_read_2c(bi)) == UF_ENTRY_MAGIC) { @@ -1573,16 +1573,16 @@ u_write_undo( #endif } - /* strip any s-bit and executable bit */ + // strip any s-bit and executable bit perm = perm & 0666; - /* If the undo file already exists, verify that it actually is an undo - * file, and delete it. */ + // If the undo file already exists, verify that it actually is an undo + // file, and delete it. if (mch_getperm(file_name) >= 0) { if (name == NULL || !forceit) { - /* Check we can read it and it's an undo file. */ + // Check we can read it and it's an undo file. fd = mch_open((char *)file_name, O_RDONLY|O_EXTRA, 0); if (fd < 0) { @@ -1625,8 +1625,8 @@ u_write_undo( mch_remove(file_name); } - /* If there is no undo information at all, quit here after deleting any - * existing undo file. */ + // If there is no undo information at all, quit here after deleting any + // existing undo file. if (buf->b_u_numhead == 0 && buf->b_u_line_ptr.ul_line == NULL) { if (p_verbose > 0) @@ -1650,7 +1650,7 @@ u_write_undo( } #ifdef U_DEBUG - /* Check there is no problem in undo info before writing. */ + // Check there is no problem in undo info before writing. u_check(FALSE); #endif @@ -1663,7 +1663,7 @@ u_write_undo( if (st_old_valid && mch_stat((char *)file_name, &st_new) >= 0 && st_new.st_gid != st_old.st_gid -# ifdef HAVE_FCHOWN /* sequent-ptx lacks fchown() */ +# ifdef HAVE_FCHOWN // sequent-ptx lacks fchown() && fchown(fd, (uid_t)-1, st_old.st_gid) != 0 # endif ) @@ -1683,7 +1683,7 @@ u_write_undo( goto theend; } - /* Undo must be synced. */ + // Undo must be synced. u_sync(TRUE); /* @@ -1701,7 +1701,7 @@ u_write_undo( uhp = buf->b_u_oldhead; while (uhp != NULL) { - /* Serialize current UHP if we haven't seen it */ + // Serialize current UHP if we haven't seen it if (uhp->uh_walk != mark) { uhp->uh_walk = mark; @@ -1712,7 +1712,7 @@ u_write_undo( goto write_error; } - /* Now walk through the tree - algorithm from undo_time(). */ + // Now walk through the tree - algorithm from undo_time(). if (uhp->uh_prev.ptr != NULL && uhp->uh_prev.ptr->uh_walk != mark) uhp = uhp->uh_prev.ptr; else if (uhp->uh_alt_next.ptr != NULL @@ -1748,8 +1748,8 @@ write_error: semsg(_("E829: write error in undo file: %s"), file_name); #if defined(MSWIN) - /* Copy file attributes; for systems where this can only be done after - * closing the file. */ + // Copy file attributes; for systems where this can only be done after + // closing the file. if (buf->b_ffname != NULL) (void)mch_copy_file_attribute(buf->b_ffname, file_name); #endif @@ -1758,7 +1758,7 @@ write_error: { vim_acl_T acl; - /* For systems that support ACL: get the ACL from the original file. */ + // For systems that support ACL: get the ACL from the original file. acl = mch_get_acl(buf->b_ffname); mch_set_acl(file_name, acl); mch_free_acl(acl); @@ -1825,8 +1825,8 @@ u_read_undo(char_u *name, char_u *hash, return; #ifdef UNIX - /* For safety we only read an undo file if the owner is equal to the - * owner of the text file or equal to the current user. */ + // For safety we only read an undo file if the owner is equal to the + // owner of the text file or equal to the current user. if (mch_stat((char *)orig_name, &st_orig) >= 0 && mch_stat((char *)file_name, &st_undo) >= 0 && st_orig.st_uid != st_undo.st_uid @@ -1932,7 +1932,7 @@ u_read_undo(char_u *name, char_u *hash, goto error; } - /* Read undo data for "U" command. */ + // Read undo data for "U" command. str_len = undo_read_4c(&bi); if (str_len < 0) goto error; @@ -1949,7 +1949,7 @@ u_read_undo(char_u *name, char_u *hash, goto error; } - /* Begin general undo data */ + // Begin general undo data old_header_seq = undo_read_4c(&bi); new_header_seq = undo_read_4c(&bi); cur_header_seq = undo_read_4c(&bi); @@ -1958,7 +1958,7 @@ u_read_undo(char_u *name, char_u *hash, seq_cur = undo_read_4c(&bi); seq_time = undo_read_time(&bi); - /* Optional header fields. */ + // Optional header fields. for (;;) { int len = undo_read_byte(&bi); @@ -1973,16 +1973,16 @@ u_read_undo(char_u *name, char_u *hash, last_save_nr = undo_read_4c(&bi); break; default: - /* field not supported, skip */ + // field not supported, skip while (--len >= 0) (void)undo_read_byte(&bi); } } - /* uhp_table will store the freshly created undo headers we allocate - * until we insert them into curbuf. The table remains sorted by the - * sequence numbers of the headers. - * When there are no headers uhp_table is NULL. */ + // uhp_table will store the freshly created undo headers we allocate + // until we insert them into curbuf. The table remains sorted by the + // sequence numbers of the headers. + // When there are no headers uhp_table is NULL. if (num_head > 0) { if (num_head < LONG_MAX / (long)sizeof(u_header_T *)) @@ -2023,9 +2023,9 @@ u_read_undo(char_u *name, char_u *hash, # define SET_FLAG(j) #endif - /* We have put all of the headers into a table. Now we iterate through the - * table and swizzle each sequence number we have stored in uh_*_seq into - * a pointer corresponding to the header with that sequence number. */ + // We have put all of the headers into a table. Now we iterate through the + // table and swizzle each sequence number we have stored in uh_*_seq into + // a pointer corresponding to the header with that sequence number. for (i = 0; i < num_head; i++) { uhp = uhp_table[i]; @@ -2087,8 +2087,8 @@ u_read_undo(char_u *name, char_u *hash, } } - /* Now that we have read the undo info successfully, free the current undo - * info and use the info from the file. */ + // Now that we have read the undo info successfully, free the current undo + // info and use the info from the file. u_blockfree(curbuf); curbuf->b_u_oldhead = old_idx < 0 ? NULL : uhp_table[old_idx]; curbuf->b_u_newhead = new_idx < 0 ? NULL : uhp_table[new_idx]; @@ -2141,7 +2141,7 @@ theend: return; } -#endif /* FEAT_PERSISTENT_UNDO */ +#endif // FEAT_PERSISTENT_UNDO /* @@ -2198,23 +2198,23 @@ u_doit(int startcount) u_oldcount = -1; while (count--) { - /* Do the change warning now, so that it triggers FileChangedRO when - * needed. This may cause the file to be reloaded, that must happen - * before we do anything, because it may change curbuf->b_u_curhead - * and more. */ + // Do the change warning now, so that it triggers FileChangedRO when + // needed. This may cause the file to be reloaded, that must happen + // before we do anything, because it may change curbuf->b_u_curhead + // and more. change_warning(0); if (undo_undoes) { - if (curbuf->b_u_curhead == NULL) /* first undo */ + if (curbuf->b_u_curhead == NULL) // first undo curbuf->b_u_curhead = curbuf->b_u_newhead; - else if (get_undolevel() > 0) /* multi level undo */ - /* get next undo */ + else if (get_undolevel() > 0) // multi level undo + // get next undo curbuf->b_u_curhead = curbuf->b_u_curhead->uh_next.ptr; - /* nothing to undo */ + // nothing to undo if (curbuf->b_u_numhead == 0 || curbuf->b_u_curhead == NULL) { - /* stick curbuf->b_u_curhead at end */ + // stick curbuf->b_u_curhead at end curbuf->b_u_curhead = curbuf->b_u_oldhead; beep_flush(); if (count == startcount - 1) @@ -2231,7 +2231,7 @@ u_doit(int startcount) { if (curbuf->b_u_curhead == NULL || get_undolevel() <= 0) { - beep_flush(); /* nothing to redo */ + beep_flush(); // nothing to redo if (count == startcount - 1) { msg(_("Already at newest change")); @@ -2242,8 +2242,8 @@ u_doit(int startcount) u_undoredo(FALSE); - /* Advance for next redo. Set "newhead" when at the end of the - * redoable changes. */ + // Advance for next redo. Set "newhead" when at the end of the + // redoable changes. if (curbuf->b_u_curhead->uh_prev.ptr == NULL) curbuf->b_u_newhead = curbuf->b_u_curhead; curbuf->b_u_curhead = curbuf->b_u_curhead->uh_prev.ptr; @@ -2283,7 +2283,7 @@ undo_time( int above = FALSE; int did_undo = TRUE; - /* First make sure the current undoable change is synced. */ + // First make sure the current undoable change is synced. if (curbuf->b_u_synced == FALSE) u_sync(TRUE); @@ -2292,8 +2292,8 @@ undo_time( if (curbuf->b_ml.ml_flags & ML_EMPTY) u_oldcount = -1; - /* "target" is the node below which we want to be. - * Init "closest" to a value we can't reach. */ + // "target" is the node below which we want to be. + // Init "closest" to a value we can't reach. if (absolute) { target = step; @@ -2307,34 +2307,34 @@ undo_time( { if (step < 0) { - /* Going back to a previous write. If there were changes after - * the last write, count that as moving one file-write, so - * that ":earlier 1f" undoes all changes since the last save. */ + // Going back to a previous write. If there were changes after + // the last write, count that as moving one file-write, so + // that ":earlier 1f" undoes all changes since the last save. uhp = curbuf->b_u_curhead; if (uhp != NULL) uhp = uhp->uh_next.ptr; else uhp = curbuf->b_u_newhead; if (uhp != NULL && uhp->uh_save_nr != 0) - /* "uh_save_nr" was set in the last block, that means - * there were no changes since the last write */ + // "uh_save_nr" was set in the last block, that means + // there were no changes since the last write target = curbuf->b_u_save_nr_cur + step; else - /* count the changes since the last write as one step */ + // count the changes since the last write as one step target = curbuf->b_u_save_nr_cur + step + 1; if (target <= 0) - /* Go to before first write: before the oldest change. Use - * the sequence number for that. */ + // Go to before first write: before the oldest change. Use + // the sequence number for that. dofile = FALSE; } else { - /* Moving forward to a newer write. */ + // Moving forward to a newer write. target = curbuf->b_u_save_nr_cur + step; if (target > curbuf->b_u_save_nr_last) { - /* Go to after last write: after the latest change. Use - * the sequence number for that. */ + // Go to after last write: after the latest change. Use + // the sequence number for that. target = curbuf->b_u_seq_last + 1; dofile = FALSE; } @@ -2363,10 +2363,10 @@ undo_time( closest_start = closest; closest_seq = curbuf->b_u_seq_cur; - /* When "target" is 0; Back to origin. */ + // When "target" is 0; Back to origin. if (target == 0) { - mark = lastmark; /* avoid that GCC complains */ + mark = lastmark; // avoid that GCC complains goto target_zero; } @@ -2380,14 +2380,14 @@ undo_time( */ for (round = 1; round <= 2; ++round) { - /* Find the path from the current state to where we want to go. The - * desired state can be anywhere in the undo tree, need to go all over - * it. We put "nomark" in uh_walk where we have been without success, - * "mark" where it could possibly be. */ + // Find the path from the current state to where we want to go. The + // desired state can be anywhere in the undo tree, need to go all over + // it. We put "nomark" in uh_walk where we have been without success, + // "mark" where it could possibly be. mark = ++lastmark; nomark = ++lastmark; - if (curbuf->b_u_curhead == NULL) /* at leaf of the tree */ + if (curbuf->b_u_curhead == NULL) // at leaf of the tree uhp = curbuf->b_u_newhead; else uhp = curbuf->b_u_curhead; @@ -2404,10 +2404,10 @@ undo_time( if (round == 1 && !(dofile && val == 0)) { - /* Remember the header that is closest to the target. - * It must be at least in the right direction (checked with - * "b_u_seq_cur"). When the timestamp is equal find the - * highest/lowest sequence number. */ + // Remember the header that is closest to the target. + // It must be at least in the right direction (checked with + // "b_u_seq_cur"). When the timestamp is equal find the + // highest/lowest sequence number. if ((step < 0 ? uhp->uh_seq <= curbuf->b_u_seq_cur : uhp->uh_seq > curbuf->b_u_seq_cur) && ((dosec && val == closest) @@ -2428,32 +2428,32 @@ undo_time( } } - /* Quit searching when we found a match. But when searching for a - * time we need to continue looking for the best uh_seq. */ + // Quit searching when we found a match. But when searching for a + // time we need to continue looking for the best uh_seq. if (target == val && !dosec) { target = uhp->uh_seq; break; } - /* go down in the tree if we haven't been there */ + // go down in the tree if we haven't been there if (uhp->uh_prev.ptr != NULL && uhp->uh_prev.ptr->uh_walk != nomark && uhp->uh_prev.ptr->uh_walk != mark) uhp = uhp->uh_prev.ptr; - /* go to alternate branch if we haven't been there */ + // go to alternate branch if we haven't been there else if (uhp->uh_alt_next.ptr != NULL && uhp->uh_alt_next.ptr->uh_walk != nomark && uhp->uh_alt_next.ptr->uh_walk != mark) uhp = uhp->uh_alt_next.ptr; - /* go up in the tree if we haven't been there and we are at the - * start of alternate branches */ + // go up in the tree if we haven't been there and we are at the + // start of alternate branches else if (uhp->uh_next.ptr != NULL && uhp->uh_alt_prev.ptr == NULL && uhp->uh_next.ptr->uh_walk != nomark && uhp->uh_next.ptr->uh_walk != mark) { - /* If still at the start we don't go through this change. */ + // If still at the start we don't go through this change. if (uhp == curbuf->b_u_curhead) uhp->uh_walk = nomark; uhp = uhp->uh_next.ptr; @@ -2461,7 +2461,7 @@ undo_time( else { - /* need to backtrack; mark this node as useless */ + // need to backtrack; mark this node as useless uhp->uh_walk = nomark; if (uhp->uh_alt_prev.ptr != NULL) uhp = uhp->uh_alt_prev.ptr; @@ -2470,7 +2470,7 @@ undo_time( } } - if (uhp != NULL) /* found it */ + if (uhp != NULL) // found it break; if (absolute) @@ -2492,11 +2492,11 @@ undo_time( dosec = FALSE; dofile = FALSE; if (step < 0) - above = TRUE; /* stop above the header */ + above = TRUE; // stop above the header } target_zero: - /* If we found it: Follow the path to go to where we want to be. */ + // If we found it: Follow the path to go to where we want to be. if (uhp != NULL || target == 0) { /* @@ -2504,7 +2504,7 @@ target_zero: */ while (!got_int) { - /* Do the change warning now, for the same reason as above. */ + // Do the change warning now, for the same reason as above. change_warning(0); uhp = curbuf->b_u_curhead; @@ -2518,10 +2518,10 @@ target_zero: curbuf->b_u_curhead = uhp; u_undoredo(TRUE); if (target > 0) - uhp->uh_walk = nomark; /* don't go back down here */ + uhp->uh_walk = nomark; // don't go back down here } - /* When back to origin, redo is not needed. */ + // When back to origin, redo is not needed. if (target > 0) { /* @@ -2529,27 +2529,27 @@ target_zero: */ while (!got_int) { - /* Do the change warning now, for the same reason as above. */ + // Do the change warning now, for the same reason as above. change_warning(0); uhp = curbuf->b_u_curhead; if (uhp == NULL) break; - /* Go back to the first branch with a mark. */ + // Go back to the first branch with a mark. while (uhp->uh_alt_prev.ptr != NULL && uhp->uh_alt_prev.ptr->uh_walk == mark) uhp = uhp->uh_alt_prev.ptr; - /* Find the last branch with a mark, that's the one. */ + // Find the last branch with a mark, that's the one. last = uhp; while (last->uh_alt_next.ptr != NULL && last->uh_alt_next.ptr->uh_walk == mark) last = last->uh_alt_next.ptr; if (last != uhp) { - /* Make the used branch the first entry in the list of - * alternatives to make "u" and CTRL-R take this branch. */ + // Make the used branch the first entry in the list of + // alternatives to make "u" and CTRL-R take this branch. while (uhp->uh_alt_prev.ptr != NULL) uhp = uhp->uh_alt_prev.ptr; if (last->uh_alt_next.ptr != NULL) @@ -2570,10 +2570,10 @@ target_zero: curbuf->b_u_curhead = uhp; if (uhp->uh_walk != mark) - break; /* must have reached the target */ - - /* Stop when going backwards in time and didn't find the exact - * header we were looking for. */ + break; // must have reached the target + + // Stop when going backwards in time and didn't find the exact + // header we were looking for. if (uhp->uh_seq == target && above) { curbuf->b_u_seq_cur = target - 1; @@ -2582,20 +2582,20 @@ target_zero: u_undoredo(FALSE); - /* Advance "curhead" to below the header we last used. If it - * becomes NULL then we need to set "newhead" to this leaf. */ + // Advance "curhead" to below the header we last used. If it + // becomes NULL then we need to set "newhead" to this leaf. if (uhp->uh_prev.ptr == NULL) curbuf->b_u_newhead = uhp; curbuf->b_u_curhead = uhp->uh_prev.ptr; did_undo = FALSE; - if (uhp->uh_seq == target) /* found it! */ + if (uhp->uh_seq == target) // found it! break; uhp = uhp->uh_prev.ptr; if (uhp == NULL || uhp->uh_walk != mark) { - /* Need to redo more but can't find it... */ + // Need to redo more but can't find it... internal_error("undo_time()"); break; } @@ -2631,11 +2631,11 @@ u_undoredo(int undo) int new_flags; pos_T namedm[NMARKS]; visualinfo_T visualinfo; - int empty_buffer; /* buffer became empty */ + int empty_buffer; // buffer became empty u_header_T *curhead = curbuf->b_u_curhead; - /* Don't want autocommands using the undo structures here, they are - * invalid till the end. */ + // Don't want autocommands using the undo structures here, they are + // invalid till the end. block_autocmds(); #ifdef U_DEBUG @@ -2821,7 +2821,7 @@ u_undoredo(int undo) changed(); else #ifdef FEAT_NETBEANS_INTG - /* per netbeans undo rules, keep it as modified */ + // per netbeans undo rules, keep it as modified if (!isNetbeansModified(curbuf)) #endif unchanged(curbuf, FALSE, TRUE); @@ -2867,30 +2867,30 @@ u_undoredo(int undo) } else { - /* We get here with the current cursor line being past the end (eg - * after adding lines at the end of the file, and then undoing it). - * check_cursor() will move the cursor to the last line. Move it to - * the first column here. */ + // We get here with the current cursor line being past the end (eg + // after adding lines at the end of the file, and then undoing it). + // check_cursor() will move the cursor to the last line. Move it to + // the first column here. curwin->w_cursor.col = 0; curwin->w_cursor.coladd = 0; } - /* Make sure the cursor is on an existing line and column. */ + // Make sure the cursor is on an existing line and column. check_cursor(); - /* Remember where we are for "g-" and ":earlier 10s". */ + // Remember where we are for "g-" and ":earlier 10s". curbuf->b_u_seq_cur = curhead->uh_seq; if (undo) { - /* We are below the previous undo. However, to make ":earlier 1s" - * work we compute this as being just above the just undone change. */ + // We are below the previous undo. However, to make ":earlier 1s" + // work we compute this as being just above the just undone change. if (curhead->uh_next.ptr != NULL) curbuf->b_u_seq_cur = curhead->uh_next.ptr->uh_seq; else curbuf->b_u_seq_cur = 0; } - /* Remember where we are for ":earlier 1f" and ":later 1f". */ + // Remember where we are for ":earlier 1f" and ":later 1f". if (curhead->uh_save_nr != 0) { if (undo) @@ -2899,8 +2899,8 @@ u_undoredo(int undo) curbuf->b_u_save_nr_cur = curhead->uh_save_nr; } - /* The timestamp can be the same for multiple changes, just use the one of - * the undone/redone change. */ + // The timestamp can be the same for multiple changes, just use the one of + // the undone/redone change. curbuf->b_u_time_cur = curhead->uh_time; unblock_autocmds(); @@ -2916,8 +2916,8 @@ u_undoredo(int undo) */ static void u_undo_end( - int did_undo, /* just did an undo */ - int absolute) /* used ":undo N" */ + int did_undo, // just did an undo + int absolute) // used ":undo N" { char *msgstr; u_header_T *uhp; @@ -2928,8 +2928,8 @@ u_undo_end( foldOpenCursor(); #endif - if (global_busy /* no messages now, wait until global is finished */ - || !messaging()) /* 'lazyredraw' set, don't do messages now */ + if (global_busy // no messages now, wait until global is finished + || !messaging()) // 'lazyredraw' set, don't do messages now return; if (curbuf->b_ml.ml_flags & ML_EMPTY) @@ -2955,7 +2955,7 @@ u_undo_end( if (curbuf->b_u_curhead != NULL) { - /* For ":undo N" we prefer a "after #N" message. */ + // For ":undo N" we prefer a "after #N" message. if (absolute && curbuf->b_u_curhead->uh_next.ptr != NULL) { uhp = curbuf->b_u_curhead->uh_next.ptr; @@ -2999,20 +2999,20 @@ u_undo_end( */ void u_sync( - int force) /* Also sync when no_u_sync is set. */ + int force) // Also sync when no_u_sync is set. { - /* Skip it when already synced or syncing is disabled. */ + // Skip it when already synced or syncing is disabled. if (curbuf->b_u_synced || (!force && no_u_sync > 0)) return; #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) if (p_imst == IM_ON_THE_SPOT && im_is_preediting()) - return; /* XIM is busy, don't break an undo sequence */ + return; // XIM is busy, don't break an undo sequence #endif if (get_undolevel() < 0) - curbuf->b_u_synced = TRUE; /* no entries, nothing to do */ + curbuf->b_u_synced = TRUE; // no entries, nothing to do else { - u_getbot(); /* compute ue_bot of previous u_save */ + u_getbot(); // compute ue_bot of previous u_save curbuf->b_u_curhead = NULL; } } @@ -3063,7 +3063,7 @@ ex_undolist(exarg_T *eap UNUSED) uhp->uh_walk = mark; - /* go down in the tree if we haven't been there */ + // go down in the tree if we haven't been there if (uhp->uh_prev.ptr != NULL && uhp->uh_prev.ptr->uh_walk != nomark && uhp->uh_prev.ptr->uh_walk != mark) { @@ -3071,14 +3071,14 @@ ex_undolist(exarg_T *eap UNUSED) ++changes; } - /* go to alternate branch if we haven't been there */ + // go to alternate branch if we haven't been there else if (uhp->uh_alt_next.ptr != NULL && uhp->uh_alt_next.ptr->uh_walk != nomark && uhp->uh_alt_next.ptr->uh_walk != mark) uhp = uhp->uh_alt_next.ptr; - /* go up in the tree if we haven't been there and we are at the - * start of alternate branches */ + // go up in the tree if we haven't been there and we are at the + // start of alternate branches else if (uhp->uh_next.ptr != NULL && uhp->uh_alt_prev.ptr == NULL && uhp->uh_next.ptr->uh_walk != nomark && uhp->uh_next.ptr->uh_walk != mark) @@ -3089,7 +3089,7 @@ ex_undolist(exarg_T *eap UNUSED) else { - /* need to backtrack; mark this node as done */ + // need to backtrack; mark this node as done uhp->uh_walk = nomark; if (uhp->uh_alt_prev.ptr != NULL) uhp = uhp->uh_alt_prev.ptr; @@ -3130,18 +3130,18 @@ ex_undolist(exarg_T *eap UNUSED) ex_undojoin(exarg_T *eap UNUSED) { if (curbuf->b_u_newhead == NULL) - return; /* nothing changed before */ + return; // nothing changed before if (curbuf->b_u_curhead != NULL) { emsg(_("E790: undojoin is not allowed after undo")); return; } if (!curbuf->b_u_synced) - return; /* already unsynced */ + return; // already unsynced if (get_undolevel() < 0) - return; /* no entries, nothing to do */ + return; // no entries, nothing to do else - /* Append next change to the last entry */ + // Append next change to the last entry curbuf->b_u_synced = FALSE; } @@ -3168,9 +3168,9 @@ u_find_first_changed(void) linenr_T lnum; if (curbuf->b_u_curhead != NULL || uhp == NULL) - return; /* undid something in an autocmd? */ - - /* Check that the last undo block was for the whole file. */ + return; // undid something in an autocmd? + + // Check that the last undo block was for the whole file. uep = uhp->uh_entry; if (uep->ue_top != 0 || uep->ue_bot != 0) return; @@ -3190,7 +3190,7 @@ u_find_first_changed(void) } if (curbuf->b_ml.ml_line_count != uep->ue_size) { - /* lines added or deleted at the end, put the cursor there */ + // lines added or deleted at the end, put the cursor there CLEAR_POS(&(uhp->uh_cursor)); uhp->uh_cursor.lnum = lnum; } @@ -3225,7 +3225,7 @@ u_unch_branch(u_header_T *uhp) { uh->uh_flags |= UH_CHANGED; if (uh->uh_alt_next.ptr != NULL) - u_unch_branch(uh->uh_alt_next.ptr); /* recursive */ + u_unch_branch(uh->uh_alt_next.ptr); // recursive } } @@ -3254,7 +3254,7 @@ u_getbot(void) u_entry_T *uep; linenr_T extra; - uep = u_get_headentry(); /* check for corrupt undo list */ + uep = u_get_headentry(); // check for corrupt undo list if (uep == NULL) return; @@ -3271,10 +3271,10 @@ u_getbot(void) if (uep->ue_bot < 1 || uep->ue_bot > curbuf->b_ml.ml_line_count) { iemsg(_("E440: undo line missing")); - uep->ue_bot = uep->ue_top + 1; /* assume all lines deleted, will - * get all the old lines back - * without deleting the current - * ones */ + uep->ue_bot = uep->ue_top + 1; // assume all lines deleted, will + // get all the old lines back + // without deleting the current + // ones } curbuf->b_u_newhead->uh_getbot_entry = NULL; @@ -3290,19 +3290,19 @@ u_getbot(void) u_freeheader( buf_T *buf, u_header_T *uhp, - u_header_T **uhpp) /* if not NULL reset when freeing this header */ + u_header_T **uhpp) // if not NULL reset when freeing this header { u_header_T *uhap; - /* When there is an alternate redo list free that branch completely, - * because we can never go there. */ + // When there is an alternate redo list free that branch completely, + // because we can never go there. if (uhp->uh_alt_next.ptr != NULL) u_freebranch(buf, uhp->uh_alt_next.ptr, uhpp); if (uhp->uh_alt_prev.ptr != NULL) uhp->uh_alt_prev.ptr->uh_alt_next.ptr = NULL; - /* Update the links in the list to remove the header. */ + // Update the links in the list to remove the header. if (uhp->uh_next.ptr == NULL) buf->b_u_oldhead = uhp->uh_prev.ptr; else @@ -3325,12 +3325,12 @@ u_freeheader( u_freebranch( buf_T *buf, u_header_T *uhp, - u_header_T **uhpp) /* if not NULL reset when freeing this header */ + u_header_T **uhpp) // if not NULL reset when freeing this header { u_header_T *tofree, *next; - /* If this is the top branch we may need to use u_freeheader() to update - * all the pointers. */ + // If this is the top branch we may need to use u_freeheader() to update + // all the pointers. if (uhp == buf->b_u_oldhead) { while (buf->b_u_oldhead != NULL) @@ -3346,7 +3346,7 @@ u_freebranch( { tofree = next; if (tofree->uh_alt_next.ptr != NULL) - u_freebranch(buf, tofree->uh_alt_next.ptr, uhpp); /* recursive */ + u_freebranch(buf, tofree->uh_alt_next.ptr, uhpp); // recursive next = tofree->uh_prev.ptr; u_freeentries(buf, tofree, uhpp); } @@ -3360,15 +3360,15 @@ u_freebranch( u_freeentries( buf_T *buf, u_header_T *uhp, - u_header_T **uhpp) /* if not NULL reset when freeing this header */ + u_header_T **uhpp) // if not NULL reset when freeing this header { u_entry_T *uep, *nuep; - /* Check for pointers to the header that become invalid now. */ + // Check for pointers to the header that become invalid now. if (buf->b_u_curhead == uhp) buf->b_u_curhead = NULL; if (buf->b_u_newhead == uhp) - buf->b_u_newhead = NULL; /* freeing the newest entry */ + buf->b_u_newhead = NULL; // freeing the newest entry if (uhpp != NULL && uhp == *uhpp) *uhpp = NULL; @@ -3420,9 +3420,9 @@ u_clearall(buf_T *buf) static void u_saveline(linenr_T lnum) { - if (lnum == curbuf->b_u_line_lnum) /* line is already saved */ + if (lnum == curbuf->b_u_line_lnum) // line is already saved return; - if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) /* should never happen */ + if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) // should never happen return; u_clearline(); curbuf->b_u_line_lnum = lnum; @@ -3584,7 +3584,7 @@ u_eval_tree(u_header_T *first_uhp, list_ if (alt_list != NULL) { - /* Recursive call to add alternate undo tree. */ + // Recursive call to add alternate undo tree. u_eval_tree(uhp->uh_alt_next.ptr, alt_list); dict_add_list(dict, "alt", alt_list); } @@ -3608,7 +3608,7 @@ f_undofile(typval_T *argvars UNUSED, typ if (*fname == NUL) { - /* If there is no file name there will be no undo file. */ + // If there is no file name there will be no undo file. rettv->vval.v_string = NULL; } else
--- a/src/uninstall.c +++ b/src/uninstall.c @@ -17,7 +17,7 @@ * - the Vim entry in the Start Menu */ -/* Include common code for dosinst.c and uninstall.c. */ +// Include common code for dosinst.c and uninstall.c. #include "dosinst.h" /* @@ -41,9 +41,9 @@ reg_delete_key(HKEY hRootKey, const char if (!did_load) { - /* The RegDeleteKeyEx() function is only available on new systems. It - * is required for 64-bit registry access. For other systems fall - * back to RegDeleteKey(). */ + // The RegDeleteKeyEx() function is only available on new systems. It + // is required for 64-bit registry access. For other systems fall + // back to RegDeleteKey(). did_load = TRUE; advapi_lib = LoadLibrary("ADVAPI32.DLL"); if (advapi_lib != NULL) @@ -66,14 +66,14 @@ popup_gvim_path(char *buf, DWORD bufsize DWORD value_type; int r; - /* Open the key where the path to gvim.exe is stored. */ + // Open the key where the path to gvim.exe is stored. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0, KEY_WOW64_64KEY | KEY_READ, &key_handle) != ERROR_SUCCESS) if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0, KEY_WOW64_32KEY | KEY_READ, &key_handle) != ERROR_SUCCESS) return 0; - /* get the DisplayName out of it to show the user */ + // get the DisplayName out of it to show the user r = RegQueryValueEx(key_handle, "path", 0, &value_type, (LPBYTE)buf, &bufsize); RegCloseKey(key_handle); @@ -92,13 +92,13 @@ openwith_gvim_path(char *buf, DWORD bufs DWORD value_type; int r; - /* Open the key where the path to gvim.exe is stored. */ + // Open the key where the path to gvim.exe is stored. if (RegOpenKeyEx(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit\\command", 0, KEY_WOW64_64KEY | KEY_READ, &key_handle) != ERROR_SUCCESS) return 0; - /* get the DisplayName out of it to show the user */ + // get the DisplayName out of it to show the user r = RegQueryValueEx(key_handle, "", 0, &value_type, (LPBYTE)buf, &bufsize); RegCloseKey(key_handle); @@ -210,7 +210,7 @@ batfile_thisversion(char *path) while (fgets(line, sizeof(line), fd) != NULL) { for (p = line; *p != 0; ++p) - /* don't accept "vim60an" when looking for "vim60". */ + // don't accept "vim60an" when looking for "vim60". if (strnicmp(p, VIM_VERSION_NODOT, ver_len) == 0 && !isdigit(p[ver_len]) && !isalpha(p[ver_len])) @@ -293,7 +293,7 @@ remove_start_menu(void) remove_if_exists(path, targets[i].lnkname); remove_if_exists(path, "uninstall.lnk"); remove_if_exists(path, "Help.lnk"); - /* Win95 uses .pif, WinNT uses .lnk */ + // Win95 uses .pif, WinNT uses .lnk remove_if_exists(path, "Vim tutor.pif"); remove_if_exists(path, "Vim tutor.lnk"); remove_if_exists(path, "Vim online.url"); @@ -322,13 +322,13 @@ main(int argc, char *argv[]) char path[MAX_PATH]; char popup_path[MAX_PATH]; - /* The nsis uninstaller calls us with a "-nsis" argument. */ + // The nsis uninstaller calls us with a "-nsis" argument. if (argc == 2 && stricmp(argv[1], "-nsis") == 0) interactive = FALSE; else interactive = TRUE; - /* Initialize this program. */ + // Initialize this program. do_inits(argv); printf("This program will remove the following items:\n"); @@ -342,8 +342,8 @@ main(int argc, char *argv[]) if (!interactive || confirm()) { remove_popup(); - /* Assume the "Open With" entry can be removed as well, don't - * bother the user with asking him again. */ + // Assume the "Open With" entry can be removed as well, don't + // bother the user with asking him again. remove_openwith(); } }
--- a/src/usercmd.c +++ b/src/usercmd.c @@ -392,7 +392,7 @@ uc_list(char_u *name, size_t name_len) long a; garray_T *gap; - /* In cmdwin, the alternative buffer should be used. */ + // In cmdwin, the alternative buffer should be used. gap = #ifdef FEAT_CMDWIN (cmdwin_type != 0 && get_cmdline_type() == NUL) ?
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -30,7 +30,7 @@ */ static hashtab_T func_hashtab; -/* Used by get_func_tv() */ +// Used by get_func_tv() static garray_T funcargs = GA_EMPTY; // pointer to funccal for currently active function @@ -128,7 +128,7 @@ get_function_args( goto err_ret; } - /* Check for duplicate argument name. */ + // Check for duplicate argument name. for (i = 0; i < newargs->ga_len; ++i) if (STRCMP(((char_u **)(newargs->ga_data))[i], arg) == 0) { @@ -193,7 +193,7 @@ get_function_args( } if (*p != endchar) goto err_ret; - ++p; /* skip "endchar" */ + ++p; // skip "endchar" *argp = p; return OK; @@ -213,7 +213,7 @@ err_ret: register_closure(ufunc_T *fp) { if (fp->uf_scoped == current_funccal) - /* no change */ + // no change return OK; funccal_unref(fp->uf_scoped, fp, FALSE); fp->uf_scoped = current_funccal; @@ -249,12 +249,12 @@ get_lambda_tv(char_u **arg, typval_T *re ga_init(&newargs); ga_init(&newlines); - /* First, check if this is a lambda expression. "->" must exist. */ + // First, check if this is a lambda expression. "->" must exist. ret = get_function_args(&start, '-', NULL, NULL, NULL, TRUE); if (ret == FAIL || *start != '>') return NOTDONE; - /* Parse the arguments again. */ + // Parse the arguments again. if (evaluate) pnewargs = &newargs; else @@ -264,11 +264,11 @@ get_lambda_tv(char_u **arg, typval_T *re if (ret == FAIL || **arg != '>') goto errret; - /* Set up a flag for checking local variables and arguments. */ + // Set up a flag for checking local variables and arguments. if (evaluate) eval_lavars_used = &eval_lavars; - /* Get the start and the end of the expression. */ + // Get the start and the end of the expression. *arg = skipwhite(*arg + 1); s = *arg; ret = skip_expr(arg); @@ -299,7 +299,7 @@ get_lambda_tv(char_u **arg, typval_T *re if (ga_grow(&newlines, 1) == FAIL) goto errret; - /* Add "return " before the expression. */ + // Add "return " before the expression. len = 7 + e - s + 1; p = alloc(len); if (p == NULL) @@ -378,7 +378,7 @@ deref_func_name(char_u *name, int *lenp, if (v->di_tv.vval.v_string == NULL) { *lenp = 0; - return (char_u *)""; /* just in case */ + return (char_u *)""; // just in case } s = v->di_tv.vval.v_string; *lenp = (int)STRLEN(s); @@ -392,7 +392,7 @@ deref_func_name(char_u *name, int *lenp, if (pt == NULL) { *lenp = 0; - return (char_u *)""; /* just in case */ + return (char_u *)""; // just in case } if (partialp != NULL) *partialp = pt; @@ -436,8 +436,8 @@ get_func_tv( { char_u *argp; int ret = OK; - typval_T argvars[MAX_FUNC_ARGS + 1]; /* vars for arguments */ - int argcount = 0; /* number of arguments found */ + typval_T argvars[MAX_FUNC_ARGS + 1]; // vars for arguments + int argcount = 0; // number of arguments found /* * Get the arguments. @@ -446,7 +446,7 @@ get_func_tv( while (argcount < MAX_FUNC_ARGS - (funcexe->partial == NULL ? 0 : funcexe->partial->pt_argc)) { - argp = skipwhite(argp + 1); /* skip the '(' or ',' */ + argp = skipwhite(argp + 1); // skip the '(' or ',' if (*argp == ')' || *argp == ',' || *argp == NUL) break; if (eval1(&argp, &argvars[argcount], funcexe->evaluate) == FAIL) @@ -469,8 +469,8 @@ get_func_tv( if (get_vim_var_nr(VV_TESTING)) { - /* Prepare for calling test_garbagecollect_now(), need to know - * what variables are used on the call stack. */ + // Prepare for calling test_garbagecollect_now(), need to know + // what variables are used on the call stack. if (funcargs.ga_itemsize == 0) ga_init2(&funcargs, (int)sizeof(typval_T *), 50); for (i = 0; i < argcount; ++i) @@ -530,7 +530,7 @@ fname_trans_sid(char_u *name, char_u *fn fname_buf[1] = KS_EXTRA; fname_buf[2] = (int)KE_SNR; i = 3; - if (eval_fname_sid(name)) /* "<SID>" or "s:" */ + if (eval_fname_sid(name)) // "<SID>" or "s:" { if (current_sctx.sc_sid <= 0) *error = ERROR_SCRIPT; @@ -751,13 +751,13 @@ cleanup_function_call(funccall_T *fc) */ static void call_user_func( - ufunc_T *fp, /* pointer to function */ - int argcount, /* nr of args */ - typval_T *argvars, /* arguments */ - typval_T *rettv, /* return value */ - linenr_T firstline, /* first line of range */ - linenr_T lastline, /* last line of range */ - dict_T *selfdict) /* Dictionary for "self" */ + ufunc_T *fp, // pointer to function + int argcount, // nr of args + typval_T *argvars, // arguments + typval_T *rettv, // return value + linenr_T firstline, // first line of range + linenr_T lastline, // last line of range + dict_T *selfdict) // Dictionary for "self" { char_u *save_sourcing_name; linenr_T save_sourcing_lnum; @@ -768,7 +768,7 @@ call_user_func( int default_arg_err = FALSE; static int depth = 0; dictitem_T *v; - int fixvar_idx = 0; /* index in fixvar[] */ + int fixvar_idx = 0; // index in fixvar[] int i; int ai; int islambda = FALSE; @@ -781,7 +781,7 @@ call_user_func( int started_profiling = FALSE; #endif - /* If depth of calling is getting too high, don't execute the function */ + // If depth of calling is getting too high, don't execute the function if (depth >= p_mfd) { emsg(_("E132: Function call depth is higher than 'maxfuncdepth'")); @@ -791,7 +791,7 @@ call_user_func( } ++depth; - line_breakcheck(); /* check for CTRL-C hit */ + line_breakcheck(); // check for CTRL-C hit fc = ALLOC_CLEAR_ONE(funccall_T); if (fc == NULL) @@ -804,10 +804,10 @@ call_user_func( fc->linenr = 0; fc->returned = FALSE; fc->level = ex_nesting_level; - /* Check if this function has a breakpoint. */ + // Check if this function has a breakpoint. fc->breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name, (linenr_T)0); fc->dbg_tick = debug_tick; - /* Set up fields for closure. */ + // Set up fields for closure. fc->fc_refcount = 0; fc->fc_copyID = 0; ga_init2(&fc->fc_funcs, sizeof(ufunc_T *), 1); @@ -827,8 +827,8 @@ call_user_func( init_var_dict(&fc->l_vars, &fc->l_vars_var, VAR_DEF_SCOPE); if (selfdict != NULL) { - /* Set l:self to "selfdict". Use "name" to avoid a warning from - * some compiler that checks the destination size. */ + // Set l:self to "selfdict". Use "name" to avoid a warning from + // some compiler that checks the destination size. v = &fc->fixvar[fixvar_idx++].var; name = v->di_key; STRCPY(name, "self"); @@ -850,8 +850,8 @@ call_user_func( (varnumber_T)(argcount >= fp->uf_args.ga_len ? argcount - fp->uf_args.ga_len : 0)); fc->l_avars.dv_lock = VAR_FIXED; - /* Use "name" to avoid a warning from some compiler that checks the - * destination size. */ + // Use "name" to avoid a warning from some compiler that checks the + // destination size. v = &fc->fixvar[fixvar_idx++].var; name = v->di_key; STRCPY(name, "000"); @@ -882,7 +882,7 @@ call_user_func( ai = i - fp->uf_args.ga_len; if (ai < 0) { - /* named argument a:name */ + // named argument a:name name = FUNCARG(fp, i); if (islambda) addlocal = TRUE; @@ -908,7 +908,7 @@ call_user_func( } else { - /* "..." argument a:1, a:2, etc. */ + // "..." argument a:1, a:2, etc. sprintf((char *)numbuf, "%d", ai + 1); name = numbuf; } @@ -933,8 +933,8 @@ call_user_func( if (addlocal) { - /* Named arguments should be accessed without the "a:" prefix in - * lambda expressions. Add to the l: dict. */ + // Named arguments should be accessed without the "a:" prefix in + // lambda expressions. Add to the l: dict. copy_tv(&v->di_tv, &v->di_tv); hash_add(&fc->l_vars.dv_hashtab, DI2HIKEY(v)); } @@ -951,7 +951,7 @@ call_user_func( } } - /* Don't redraw while executing the function. */ + // Don't redraw while executing the function. ++RedrawingDisabled; save_sourcing_name = sourcing_name; save_sourcing_lnum = sourcing_lnum; @@ -963,7 +963,7 @@ call_user_func( ++sandbox; } - /* need space for function name + ("function " + 3) or "[number]" */ + // need space for function name + ("function " + 3) or "[number]" len = (save_sourcing_name == NULL ? 0 : STRLEN(save_sourcing_name)) + STRLEN(fp->uf_name) + 20; sourcing_name = alloc(len); @@ -999,7 +999,7 @@ call_user_func( msg_outnum((long)argvars[i].vval.v_number); else { - /* Do not want errors such as E724 here. */ + // Do not want errors such as E724 here. ++emsg_off; s = tv2string(&argvars[i], &tofree, numbuf2, 0); --emsg_off; @@ -1017,7 +1017,7 @@ call_user_func( } msg_puts(")"); } - msg_puts("\n"); /* don't overwrite this either */ + msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); --no_wait_return; @@ -1056,7 +1056,7 @@ call_user_func( --RedrawingDisabled; - /* when the function was aborted because of an error, return -1 */ + // when the function was aborted because of an error, return -1 if ((did_emsg && (fp->uf_flags & FC_ABORT)) || rettv->v_type == VAR_UNKNOWN) { clear_tv(rettv); @@ -1083,7 +1083,7 @@ call_user_func( } #endif - /* when being verbose, mention the return value */ + // when being verbose, mention the return value if (p_verbose >= 12) { ++no_wait_return; @@ -1101,9 +1101,9 @@ call_user_func( char_u *tofree; char_u *s; - /* The value may be very long. Skip the middle part, so that we - * have some idea how it starts and ends. smsg() would always - * truncate it at the end. Don't want errors such as E724 here. */ + // The value may be very long. Skip the middle part, so that we + // have some idea how it starts and ends. smsg() would always + // truncate it at the end. Don't want errors such as E724 here. ++emsg_off; s = tv2string(fc->rettv, &tofree, numbuf2, 0); --emsg_off; @@ -1118,7 +1118,7 @@ call_user_func( vim_free(tofree); } } - msg_puts("\n"); /* don't overwrite this either */ + msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); --no_wait_return; @@ -1141,7 +1141,7 @@ call_user_func( verbose_enter_scroll(); smsg(_("continuing in %s"), sourcing_name); - msg_puts("\n"); /* don't overwrite this either */ + msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); --no_wait_return; @@ -1231,7 +1231,7 @@ func_clear(ufunc_T *fp, int force) return; fp->uf_cleared = TRUE; - /* clear this function */ + // clear this function func_clear_items(fp); funccal_unref(fp->uf_scoped, fp, force); } @@ -1243,8 +1243,8 @@ func_clear(ufunc_T *fp, int force) static void func_free(ufunc_T *fp) { - /* only remove it when not done already, otherwise we would remove a newer - * version of the function */ + // only remove it when not done already, otherwise we would remove a newer + // version of the function if ((fp->uf_flags & (FC_DELETED | FC_REMOVED)) == 0) func_remove(fp); @@ -1319,7 +1319,7 @@ free_all_functions(void) long_u todo = 1; long_u used; - /* Clean up the current_funccal chain and the funccal stack. */ + // Clean up the current_funccal chain and the funccal stack. while (current_funccal != NULL) { clear_tv(current_funccal->rettv); @@ -1328,17 +1328,17 @@ free_all_functions(void) restore_funccal(); } - /* First clear what the functions contain. Since this may lower the - * reference count of a function, it may also free a function and change - * the hash table. Restart if that happens. */ + // First clear what the functions contain. Since this may lower the + // reference count of a function, it may also free a function and change + // the hash table. Restart if that happens. while (todo > 0) { todo = func_hashtab.ht_used; for (hi = func_hashtab.ht_array; todo > 0; ++hi) if (!HASHITEM_EMPTY(hi)) { - /* Only free functions that are not refcounted, those are - * supposed to be freed when no longer referenced. */ + // Only free functions that are not refcounted, those are + // supposed to be freed when no longer referenced. fp = HI2UF(hi); if (func_name_refcount(fp->uf_name)) ++skipped; @@ -1356,8 +1356,8 @@ free_all_functions(void) } } - /* Now actually free the functions. Need to start all over every time, - * because func_free() may change the hash table. */ + // Now actually free the functions. Need to start all over every time, + // because func_free() may change the hash table. skipped = 0; while (func_hashtab.ht_used > skipped) { @@ -1366,8 +1366,8 @@ free_all_functions(void) if (!HASHITEM_EMPTY(hi)) { --todo; - /* Only free functions that are not refcounted, those are - * supposed to be freed when no longer referenced. */ + // Only free functions that are not refcounted, those are + // supposed to be freed when no longer referenced. fp = HI2UF(hi); if (func_name_refcount(fp->uf_name)) ++skipped; @@ -1421,9 +1421,8 @@ func_call( emsg(_("E699: Too many arguments")); break; } - /* Make a copy of each argument. This is needed to be able to set - * v_lock to VAR_FIXED in the copy without changing the original list. - */ + // Make a copy of each argument. This is needed to be able to set + // v_lock to VAR_FIXED in the copy without changing the original list. copy_tv(&item->li_tv, &argv[argc++]); } @@ -1440,7 +1439,7 @@ func_call( r = call_func(name, -1, rettv, argc, argv, &funcexe); } - /* Free the arguments. */ + // Free the arguments. while (argc > 0) clear_tv(&argv[--argc]); @@ -1529,9 +1528,9 @@ call_func( if (partial != NULL) { - /* When the function has a partial with a dict and there is a dict - * argument, use the dict argument. That is backwards compatible. - * When the dict was bound explicitly use the one from the partial. */ + // When the function has a partial with a dict and there is a dict + // argument, use the dict argument. That is backwards compatible. + // When the dict was bound explicitly use the one from the partial. if (partial->pt_dict != NULL && (selfdict == NULL || !partial->pt_auto)) selfdict = partial->pt_dict; if (error == ERROR_NONE && partial->pt_argc > 0) @@ -1556,11 +1555,11 @@ call_func( { char_u *rfname = fname; - /* Ignore "g:" before a function name. */ + // Ignore "g:" before a function name. if (fname[0] == 'g' && fname[1] == ':') rfname = fname + 2; - rettv->v_type = VAR_NUMBER; /* default rettv is number zero */ + rettv->v_type = VAR_NUMBER; // default rettv is number zero rettv->vval.v_number = 0; error = ERROR_UNKNOWN; @@ -1574,19 +1573,19 @@ call_func( else fp = find_func(rfname); - /* Trigger FuncUndefined event, may load the function. */ + // Trigger FuncUndefined event, may load the function. if (fp == NULL && apply_autocmds(EVENT_FUNCUNDEFINED, rfname, rfname, TRUE, NULL) && !aborting()) { - /* executed an autocommand, search for the function again */ + // executed an autocommand, search for the function again fp = find_func(rfname); } - /* Try loading a package. */ + // Try loading a package. if (fp == NULL && script_autoload(rfname, TRUE) && !aborting()) { - /* loaded a package, search for the function again */ + // loaded a package, search for the function again fp = find_func(rfname); } @@ -1638,8 +1637,8 @@ call_func( funcexe->firstline, funcexe->lastline, (fp->uf_flags & FC_DICT) ? selfdict : NULL); if (--fp->uf_calls <= 0 && fp->uf_refcount <= 0) - /* Function was unreferenced while being used, free it - * now. */ + // Function was unreferenced while being used, free it + // now. func_clear_free(fp, FALSE); if (did_save_redo) restoreRedobuff(&save_redo); @@ -1796,10 +1795,10 @@ list_func_head(ufunc_T *fp, int indent) char_u * trans_function_name( char_u **pp, - int skip, /* only find the end, don't evaluate */ + int skip, // only find the end, don't evaluate int flags, - funcdict_T *fdp, /* return: info about dictionary used */ - partial_T **partial) /* return: partial of a FuncRef */ + funcdict_T *fdp, // return: info about dictionary used + partial_T **partial) // return: partial of a FuncRef { char_u *name = NULL; char_u *start; @@ -1813,8 +1812,8 @@ trans_function_name( vim_memset(fdp, 0, sizeof(funcdict_T)); start = *pp; - /* Check for hard coded <SNR>: already translated function ID (from a user - * command). */ + // Check for hard coded <SNR>: already translated function ID (from a user + // command). if ((*pp)[0] == K_SPECIAL && (*pp)[1] == KS_EXTRA && (*pp)[2] == (int)KE_SNR) { @@ -1823,13 +1822,13 @@ trans_function_name( return vim_strnsave(start, len); } - /* A name starting with "<SID>" or "<SNR>" is local to a script. But - * don't skip over "s:", get_lval() needs it for "s:dict.func". */ + // A name starting with "<SID>" or "<SNR>" is local to a script. But + // don't skip over "s:", get_lval() needs it for "s:dict.func". lead = eval_fname_script(start); if (lead > 2) start += lead; - /* Note that TFN_ flags use the same values as GLV_ flags. */ + // Note that TFN_ flags use the same values as GLV_ flags. end = get_lval(start, NULL, &lv, FALSE, skip, flags | GLV_READ_ONLY, lead > 2 ? 0 : FNE_CHECK_START); if (end == start) @@ -1891,12 +1890,12 @@ trans_function_name( if (lv.ll_name == NULL) { - /* Error found, but continue after the function name. */ + // Error found, but continue after the function name. *pp = end; goto theend; } - /* Check if the name is a Funcref. If so, use the value. */ + // Check if the name is a Funcref. If so, use the value. if (lv.ll_exp_name != NULL) { len = (int)STRLEN(lv.ll_exp_name); @@ -1918,7 +1917,7 @@ trans_function_name( *pp = end; if (STRNCMP(name, "<SNR>", 5) == 0) { - /* Change "<SNR>" to the byte sequence. */ + // Change "<SNR>" to the byte sequence. name[0] = K_SPECIAL; name[1] = KS_EXTRA; name[2] = (int)KE_SNR; @@ -1933,8 +1932,8 @@ trans_function_name( if (lead <= 2 && lv.ll_name == lv.ll_exp_name && STRNCMP(lv.ll_name, "s:", 2) == 0) { - /* When there was "s:" already or the name expanded to get a - * leading "s:" then remove it. */ + // When there was "s:" already or the name expanded to get a + // leading "s:" then remove it. lv.ll_name += 2; len -= 2; lead = 2; @@ -1942,7 +1941,7 @@ trans_function_name( } else { - /* skip over "s:" and "g:" */ + // skip over "s:" and "g:" if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':')) lv.ll_name += 2; len = (int)(end - lv.ll_name); @@ -1954,14 +1953,14 @@ trans_function_name( * Accept <SNR>123_name() outside a script. */ if (skip) - lead = 0; /* do nothing */ + lead = 0; // do nothing else if (lead > 0) { lead = 3; if ((lv.ll_exp_name != NULL && eval_fname_sid(lv.ll_exp_name)) || eval_fname_sid(*pp)) { - /* It's "s:" or "<SID>" */ + // It's "s:" or "<SID>" if (current_sctx.sc_sid <= 0) { emsg(_(e_usingsid)); @@ -1996,7 +1995,7 @@ trans_function_name( name[0] = K_SPECIAL; name[1] = KS_EXTRA; name[2] = (int)KE_SNR; - if (lead > 3) /* If it's "<SID>" */ + if (lead > 3) // If it's "<SID>" STRCPY(name + 3, sid_buf); } mch_memmove(name + lead, lv.ll_name, (size_t)len); @@ -2036,7 +2035,7 @@ ex_function(exarg_T *eap) int nesting; dictitem_T *v; funcdict_T fudi; - static int func_nr = 0; /* number for nameless function */ + static int func_nr = 0; // number for nameless function int paren; hashtab_T *ht; int todo; @@ -2149,8 +2148,8 @@ ex_function(exarg_T *eap) eap->skip = TRUE; } - /* An error in a function call during evaluation of an expression in magic - * braces should not cause the function not to be defined. */ + // An error in a function call during evaluation of an expression in magic + // braces should not cause the function not to be defined. saved_did_emsg = did_emsg; did_emsg = FALSE; @@ -2184,7 +2183,7 @@ ex_function(exarg_T *eap) if (j < 99) msg_putchar(' '); msg_prt_line(FUNCLINE(fp, j), FALSE); - out_flush(); /* show a line at a time */ + out_flush(); // show a line at a time ui_breakcheck(); } if (!got_int) @@ -2210,7 +2209,7 @@ ex_function(exarg_T *eap) semsg(_("E124: Missing '(': %s"), eap->arg); goto ret_free; } - /* attempt to continue by skipping some text */ + // attempt to continue by skipping some text if (vim_strchr(p, '(') != NULL) p = vim_strchr(p, '('); } @@ -2220,8 +2219,8 @@ ex_function(exarg_T *eap) if (!eap->skip) { - /* Check the name of the function. Unless it's a dictionary function - * (that we are overwriting). */ + // Check the name of the function. Unless it's a dictionary function + // (that we are overwriting). if (name != NULL) arg = name; else @@ -2240,7 +2239,7 @@ ex_function(exarg_T *eap) if (arg[j] != NUL) emsg_funcname((char *)e_invarg2, arg); } - /* Disallow using the g: dict. */ + // Disallow using the g: dict. if (fudi.fd_dict != NULL && fudi.fd_dict->dv_scope == VAR_DEF_SCOPE) emsg(_("E862: Cannot use g: here")); } @@ -2249,7 +2248,7 @@ ex_function(exarg_T *eap) &default_args, eap->skip) == FAIL) goto errret_2; - /* find extra arguments "range", "dict", "abort" and "closure" */ + // find extra arguments "range", "dict", "abort" and "closure" for (;;) { p = skipwhite(p); @@ -2283,8 +2282,8 @@ ex_function(exarg_T *eap) break; } - /* When there is a line break use what follows for the function body. - * Makes 'exe "func Test()\n...\nendfunc"' work. */ + // When there is a line break use what follows for the function body. + // Makes 'exe "func Test()\n...\nendfunc"' work. if (*p == '\n') line_arg = p + 1; else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg) @@ -2295,9 +2294,9 @@ ex_function(exarg_T *eap) */ if (KeyTyped) { - /* Check if the function already exists, don't let the user type the - * whole function before telling him it doesn't work! For a script we - * need to skip the body to be able to find what follows. */ + // Check if the function already exists, don't let the user type the + // whole function before telling him it doesn't work! For a script we + // need to skip the body to be able to find what follows. if (!eap->skip && !eap->forceit) { if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) @@ -2309,7 +2308,7 @@ ex_function(exarg_T *eap) if (!eap->skip && did_emsg) goto erret; - msg_putchar('\n'); /* don't overwrite the function name */ + msg_putchar('\n'); // don't overwrite the function name cmdline_row = msg_row; } @@ -2329,7 +2328,7 @@ ex_function(exarg_T *eap) if (line_arg != NULL) { - /* Use eap->arg, split up in parts by line breaks. */ + // Use eap->arg, split up in parts by line breaks. theline = line_arg; p = vim_strchr(theline, '\n'); if (p == NULL) @@ -2357,7 +2356,7 @@ ex_function(exarg_T *eap) goto erret; } - /* Detect line continuation: sourcing_lnum increased more than one. */ + // Detect line continuation: sourcing_lnum increased more than one. sourcing_lnum_off = get_sourced_lnum(eap->getline, eap->cookie); if (sourcing_lnum < sourcing_lnum_off) sourcing_lnum_off -= sourcing_lnum; @@ -2393,11 +2392,11 @@ ex_function(exarg_T *eap) } else { - /* skip ':' and blanks*/ + // skip ':' and blanks for (p = theline; VIM_ISWHITE(*p) || *p == ':'; ++p) ; - /* Check for "endfunction". */ + // Check for "endfunction". if (checkforcmd(&p, "endfunction", 4) && nesting-- == 0) { char_u *nextcmd = NULL; @@ -2412,9 +2411,9 @@ ex_function(exarg_T *eap) p, TRUE); if (nextcmd != NULL) { - /* Another command follows. If the line came from "eap" we - * can simply point into it, otherwise we need to change - * "eap->cmdlinep". */ + // Another command follows. If the line came from "eap" we + // can simply point into it, otherwise we need to change + // "eap->cmdlinep". eap->nextcmd = nextcmd; if (line_to_free != NULL) { @@ -2426,8 +2425,8 @@ ex_function(exarg_T *eap) break; } - /* Increase indent inside "if", "while", "for" and "try", decrease - * at "end". */ + // Increase indent inside "if", "while", "for" and "try", decrease + // at "end". if (indent > 2 && STRNCMP(p, "end", 3) == 0) indent -= 2; else if (STRNCMP(p, "if", 2) == 0 @@ -2436,7 +2435,7 @@ ex_function(exarg_T *eap) || STRNCMP(p, "try", 3) == 0) indent += 2; - /* Check for defining a function inside this function. */ + // Check for defining a function inside this function. if (checkforcmd(&p, "function", 2)) { if (*p == '!') @@ -2450,7 +2449,7 @@ ex_function(exarg_T *eap) } } - /* Check for ":append", ":change", ":insert". */ + // Check for ":append", ":change", ":insert". p = skip_range(p, NULL); if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p')) || (p[0] == 'c' @@ -2463,7 +2462,7 @@ ex_function(exarg_T *eap) && (!ASCII_ISALPHA(p[2]) || (p[2] == 's')))))) skip_until = vim_strsave((char_u *)"."); - /* Check for ":python <<EOF", ":tcl <<EOF", etc. */ + // Check for ":python <<EOF", ":tcl <<EOF", etc. arg = skipwhite(skiptowhite(p)); if (arg[0] == '<' && arg[1] =='<' && ((p[0] == 'p' && p[1] == 'y' @@ -2482,7 +2481,7 @@ ex_function(exarg_T *eap) && (!ASCII_ISALPHA(p[2]) || p[2] == 's')) )) { - /* ":python <<" continues until a dot, like ":append" */ + // ":python <<" continues until a dot, like ":append" p = skipwhite(arg + 2); if (*p == NUL) skip_until = vim_strsave((char_u *)"."); @@ -2519,30 +2518,30 @@ ex_function(exarg_T *eap) } } - /* Add the line to the function. */ + // Add the line to the function. if (ga_grow(&newlines, 1 + sourcing_lnum_off) == FAIL) goto erret; - /* Copy the line to newly allocated memory. get_one_sourceline() - * allocates 250 bytes per line, this saves 80% on average. The cost - * is an extra alloc/free. */ + // Copy the line to newly allocated memory. get_one_sourceline() + // allocates 250 bytes per line, this saves 80% on average. The cost + // is an extra alloc/free. p = vim_strsave(theline); if (p == NULL) goto erret; ((char_u **)(newlines.ga_data))[newlines.ga_len++] = p; - /* Add NULL lines for continuation lines, so that the line count is - * equal to the index in the growarray. */ + // Add NULL lines for continuation lines, so that the line count is + // equal to the index in the growarray. while (sourcing_lnum_off-- > 0) ((char_u **)(newlines.ga_data))[newlines.ga_len++] = NULL; - /* Check for end of eap->arg. */ + // Check for end of eap->arg. if (line_arg != NULL && *line_arg == NUL) line_arg = NULL; } - /* Don't define the function when skipping commands or when an error was - * detected. */ + // Don't define the function when skipping commands or when an error was + // detected. if (eap->skip || did_emsg) goto erret; @@ -2580,8 +2579,8 @@ ex_function(exarg_T *eap) } if (fp->uf_refcount > 1) { - /* This function is referenced somewhere, don't redefine it but - * create a new one. */ + // This function is referenced somewhere, don't redefine it but + // create a new one. --fp->uf_refcount; fp->uf_flags |= FC_REMOVED; fp = NULL; @@ -2589,7 +2588,7 @@ ex_function(exarg_T *eap) } else { - /* redefine existing function */ + // redefine existing function VIM_CLEAR(name); func_clear_items(fp); #ifdef FEAT_PROFILE @@ -2611,16 +2610,16 @@ ex_function(exarg_T *eap) } if (fudi.fd_di == NULL) { - /* Can't add a function to a locked dictionary */ + // Can't add a function to a locked dictionary if (var_check_lock(fudi.fd_dict->dv_lock, eap->arg, FALSE)) goto erret; } - /* Can't change an existing function if it is locked */ + // Can't change an existing function if it is locked else if (var_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg, FALSE)) goto erret; - /* Give the function a sequential number. Can only be used with a - * Funcref! */ + // Give the function a sequential number. Can only be used with a + // Funcref! vim_free(name); sprintf(numbuf, "%d", ++func_nr); name = vim_strsave((char_u *)numbuf); @@ -2635,7 +2634,7 @@ ex_function(exarg_T *eap) int slen, plen; char_u *scriptname; - /* Check that the autoload name matches the script name. */ + // Check that the autoload name matches the script name. j = FAIL; if (sourcing_name != NULL) { @@ -2666,7 +2665,7 @@ ex_function(exarg_T *eap) { if (fudi.fd_di == NULL) { - /* add new dict entry */ + // add new dict entry fudi.fd_di = dictitem_alloc(fudi.fd_newkey); if (fudi.fd_di == NULL) { @@ -2681,16 +2680,16 @@ ex_function(exarg_T *eap) } } else - /* overwrite existing dict entry */ + // overwrite existing dict entry clear_tv(&fudi.fd_di->di_tv); fudi.fd_di->di_tv.v_type = VAR_FUNC; fudi.fd_di->di_tv.vval.v_string = vim_strsave(name); - /* behave like "dict" was used */ + // behave like "dict" was used flags |= FC_DICT; } - /* insert the new function in the function list */ + // insert the new function in the function list STRCPY(fp->uf_name, name); if (overwrite) { @@ -2750,8 +2749,8 @@ ret_free: int eval_fname_script(char_u *p) { - /* Use MB_STRICMP() because in Turkish comparing the "I" may not work with - * the standard library function. */ + // Use MB_STRICMP() because in Turkish comparing the "I" may not work with + // the standard library function. if (p[0] == '<' && (MB_STRNICMP(p + 1, "SID>", 4) == 0 || MB_STRNICMP(p + 1, "SNR>", 4) == 0)) return 5; @@ -2786,8 +2785,8 @@ function_exists(char_u *name, int no_der p = trans_function_name(&nm, FALSE, flag, NULL, NULL); nm = skipwhite(nm); - /* Only accept "funcname", "funcname ", "funcname (..." and - * "funcname(...", not "funcname!...". */ + // Only accept "funcname", "funcname ", "funcname (..." and + // "funcname(...", not "funcname!...". if (p != NULL && (*nm == NUL || *nm == '(')) n = translated_function_exists(p); vim_free(p); @@ -2838,10 +2837,10 @@ get_user_func_name(expand_T *xp, int idx if ((fp->uf_flags & FC_DICT) || STRNCMP(fp->uf_name, "<lambda>", 8) == 0) - return (char_u *)""; /* don't show dict and lambda functions */ + return (char_u *)""; // don't show dict and lambda functions if (STRLEN(fp->uf_name) + 4 >= IOSIZE) - return fp->uf_name; /* prevents overflow */ + return fp->uf_name; // prevents overflow cat_func_name(IObuff, fp); if (xp->xp_context != EXPAND_USER_FUNC) @@ -2905,21 +2904,21 @@ ex_delfunction(exarg_T *eap) if (fudi.fd_dict != NULL) { - /* Delete the dict item that refers to the function, it will - * invoke func_unref() and possibly delete the function. */ + // Delete the dict item that refers to the function, it will + // invoke func_unref() and possibly delete the function. dictitem_remove(fudi.fd_dict, fudi.fd_di); } else { - /* A normal function (not a numbered function or lambda) has a - * refcount of 1 for the entry in the hashtable. When deleting - * it and the refcount is more than one, it should be kept. - * A numbered function and lambda should be kept if the refcount is - * one or more. */ + // A normal function (not a numbered function or lambda) has a + // refcount of 1 for the entry in the hashtable. When deleting + // it and the refcount is more than one, it should be kept. + // A numbered function and lambda should be kept if the refcount is + // one or more. if (fp->uf_refcount > (func_name_refcount(fp->uf_name) ? 0 : 1)) { - /* Function is still referenced somewhere. Don't free it but - * do remove it from the hashtable. */ + // Function is still referenced somewhere. Don't free it but + // do remove it from the hashtable. if (func_remove(fp)) fp->uf_refcount--; fp->uf_flags |= FC_DELETED; @@ -2951,8 +2950,8 @@ func_unref(char_u *name) } if (fp != NULL && --fp->uf_refcount <= 0) { - /* Only delete it when it's not being used. Otherwise it's done - * when "uf_calls" becomes zero. */ + // Only delete it when it's not being used. Otherwise it's done + // when "uf_calls" becomes zero. if (fp->uf_calls == 0) func_clear_free(fp, FALSE); } @@ -2967,8 +2966,8 @@ func_ptr_unref(ufunc_T *fp) { if (fp != NULL && --fp->uf_refcount <= 0) { - /* Only delete it when it's not being used. Otherwise it's done - * when "uf_calls" becomes zero. */ + // Only delete it when it's not being used. Otherwise it's done + // when "uf_calls" becomes zero. if (fp->uf_calls == 0) func_clear_free(fp, FALSE); } @@ -2988,8 +2987,8 @@ func_ref(char_u *name) if (fp != NULL) ++fp->uf_refcount; else if (isdigit(*name)) - /* Only give an error for a numbered function. - * Fail silently, when named or lambda function isn't found. */ + // Only give an error for a numbered function. + // Fail silently, when named or lambda function isn't found. internal_error("func_ref()"); } @@ -3044,10 +3043,10 @@ ex_return(exarg_T *eap) else clear_tv(&rettv); } - /* It's safer to return also on error. */ + // It's safer to return also on error. else if (!eap->skip) { - /* In return statement, cause_abort should be force_abort. */ + // In return statement, cause_abort should be force_abort. update_force_abort(); /* @@ -3058,12 +3057,12 @@ ex_return(exarg_T *eap) returning = do_return(eap, FALSE, TRUE, NULL); } - /* When skipping or the return gets pending, advance to the next command - * in this line (!returning). Otherwise, ignore the rest of the line. - * Following lines will be ignored by get_func_line(). */ + // When skipping or the return gets pending, advance to the next command + // in this line (!returning). Otherwise, ignore the rest of the line. + // Following lines will be ignored by get_func_line(). if (returning) eap->nextcmd = NULL; - else if (eap->nextcmd == NULL) /* no argument */ + else if (eap->nextcmd == NULL) // no argument eap->nextcmd = check_nextcmd(arg); if (eap->skip) @@ -3090,9 +3089,9 @@ ex_call(exarg_T *eap) if (eap->skip) { - /* trans_function_name() doesn't work well when skipping, use eval0() - * instead to skip to any following command, e.g. for: - * :if 0 | call dict.foo().bar() | endif */ + // trans_function_name() doesn't work well when skipping, use eval0() + // instead to skip to any following command, e.g. for: + // :if 0 | call dict.foo().bar() | endif ++emsg_skip; if (eval0(eap->arg, &rettv, &eap->nextcmd, FALSE) != FAIL) clear_tv(&rettv); @@ -3103,29 +3102,29 @@ ex_call(exarg_T *eap) tofree = trans_function_name(&arg, eap->skip, TFN_INT, &fudi, &partial); if (fudi.fd_newkey != NULL) { - /* Still need to give an error message for missing key. */ + // Still need to give an error message for missing key. semsg(_(e_dictkey), fudi.fd_newkey); vim_free(fudi.fd_newkey); } if (tofree == NULL) return; - /* Increase refcount on dictionary, it could get deleted when evaluating - * the arguments. */ + // Increase refcount on dictionary, it could get deleted when evaluating + // the arguments. if (fudi.fd_dict != NULL) ++fudi.fd_dict->dv_refcount; - /* If it is the name of a variable of type VAR_FUNC or VAR_PARTIAL use its - * contents. For VAR_PARTIAL get its partial, unless we already have one - * from trans_function_name(). */ + // If it is the name of a variable of type VAR_FUNC or VAR_PARTIAL use its + // contents. For VAR_PARTIAL get its partial, unless we already have one + // from trans_function_name(). len = (int)STRLEN(tofree); name = deref_func_name(tofree, &len, partial != NULL ? NULL : &partial, FALSE); - /* Skip white space to allow ":call func ()". Not good, but required for - * backward compatibility. */ + // Skip white space to allow ":call func ()". Not good, but required for + // backward compatibility. startarg = skipwhite(arg); - rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */ + rettv.v_type = VAR_UNKNOWN; // clear_tv() uses this if (*startarg != '(') { @@ -3142,7 +3141,7 @@ ex_call(exarg_T *eap) if (eap->skip) { ++emsg_skip; - lnum = eap->line2; /* do it once, also with an invalid range */ + lnum = eap->line2; // do it once, also with an invalid range } else lnum = eap->line1; @@ -3192,10 +3191,10 @@ ex_call(exarg_T *eap) if (doesrange || eap->skip) break; - /* Stop when immediately aborting on error, or when an interrupt - * occurred or an exception was thrown but not caught. - * get_func_tv() returned OK, so that the check for trailing - * characters below is executed. */ + // Stop when immediately aborting on error, or when an interrupt + // occurred or an exception was thrown but not caught. + // get_func_tv() returned OK, so that the check for trailing + // characters below is executed. if (aborting()) break; } @@ -3204,7 +3203,7 @@ ex_call(exarg_T *eap) if (!failed) { - /* Check for trailing illegal characters and a following command. */ + // Check for trailing illegal characters and a following command. if (!ends_excmd(*arg)) { emsg_severe = TRUE; @@ -3238,7 +3237,7 @@ do_return( struct condstack *cstack = eap->cstack; if (reanimate) - /* Undo the return. */ + // Undo the return. current_funccal->returned = FALSE; /* @@ -3253,20 +3252,20 @@ do_return( cstack->cs_pending[idx] = CSTP_RETURN; if (!is_cmd && !reanimate) - /* A pending return again gets pending. "rettv" points to an - * allocated variable with the rettv of the original ":return"'s - * argument if present or is NULL else. */ + // A pending return again gets pending. "rettv" points to an + // allocated variable with the rettv of the original ":return"'s + // argument if present or is NULL else. cstack->cs_rettv[idx] = rettv; else { - /* When undoing a return in order to make it pending, get the stored - * return rettv. */ + // When undoing a return in order to make it pending, get the stored + // return rettv. if (reanimate) rettv = current_funccal->rettv; if (rettv != NULL) { - /* Store the value of the pending return. */ + // Store the value of the pending return. if ((cstack->cs_rettv[idx] = alloc_tv()) != NULL) *(typval_T *)cstack->cs_rettv[idx] = *(typval_T *)rettv; else @@ -3277,9 +3276,9 @@ do_return( if (reanimate) { - /* The pending return value could be overwritten by a ":return" - * without argument in a finally clause; reset the default - * return value. */ + // The pending return value could be overwritten by a ":return" + // without argument in a finally clause; reset the default + // return value. current_funccal->rettv->v_type = VAR_NUMBER; current_funccal->rettv->vval.v_number = 0; } @@ -3290,9 +3289,9 @@ do_return( { current_funccal->returned = TRUE; - /* If the return is carried out now, store the return value. For - * a return immediately after reanimation, the value is already - * there. */ + // If the return is carried out now, store the return value. For + // a return immediately after reanimation, the value is already + // there. if (!reanimate && rettv != NULL) { clear_tv(current_funccal->rettv); @@ -3353,9 +3352,9 @@ get_func_line( funccall_T *fcp = (funccall_T *)cookie; ufunc_T *fp = fcp->func; char_u *retval; - garray_T *gap; /* growarray with function lines */ - - /* If breakpoints have been added/deleted need to check for it. */ + garray_T *gap; // growarray with function lines + + // If breakpoints have been added/deleted need to check for it. if (fcp->dbg_tick != debug_tick) { fcp->breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name, @@ -3373,7 +3372,7 @@ get_func_line( retval = NULL; else { - /* Skip NULL lines (continuation lines). */ + // Skip NULL lines (continuation lines). while (fcp->linenr < gap->ga_len && ((char_u **)(gap->ga_data))[fcp->linenr] == NULL) ++fcp->linenr; @@ -3390,11 +3389,11 @@ get_func_line( } } - /* Did we encounter a breakpoint? */ + // Did we encounter a breakpoint? if (fcp->breakpoint != 0 && fcp->breakpoint <= sourcing_lnum) { dbg_breakpoint(fp->uf_name, sourcing_lnum); - /* Find next breakpoint. */ + // Find next breakpoint. fcp->breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name, sourcing_lnum); fcp->dbg_tick = debug_tick; @@ -3412,8 +3411,8 @@ func_has_ended(void *cookie) { funccall_T *fcp = (funccall_T *)cookie; - /* Ignore the "abort" flag if the abortion behavior has been changed due to - * an error inside a try conditional. */ + // Ignore the "abort" flag if the abortion behavior has been changed due to + // an error inside a try conditional. return (((fcp->func->uf_flags & FC_ABORT) && did_emsg && !aborted_in_try()) || fcp->returned); } @@ -3452,7 +3451,7 @@ make_partial(dict_T *selfdict_in, typval { fname = rettv->v_type == VAR_FUNC ? rettv->vval.v_string : rettv->vval.v_partial->pt_name; - /* Translate "s:func" to the stored function name. */ + // Translate "s:func" to the stored function name. fname = fname_trans_sid(fname, fname_buf, &tofree, &error); fp = find_func(fname); vim_free(tofree); @@ -3470,8 +3469,8 @@ make_partial(dict_T *selfdict_in, typval selfdict = NULL; if (rettv->v_type == VAR_FUNC) { - /* Just a function: Take over the function name and use - * selfdict. */ + // Just a function: Take over the function name and use + // selfdict. pt->pt_name = rettv->vval.v_string; } else @@ -3479,9 +3478,9 @@ make_partial(dict_T *selfdict_in, typval partial_T *ret_pt = rettv->vval.v_partial; int i; - /* Partial: copy the function name, use selfdict and copy - * args. Can't take over name or args, the partial might - * be referenced elsewhere. */ + // Partial: copy the function name, use selfdict and copy + // args. Can't take over name or args, the partial might + // be referenced elsewhere. if (ret_pt->pt_name != NULL) { pt->pt_name = vim_strsave(ret_pt->pt_name); @@ -3496,7 +3495,7 @@ make_partial(dict_T *selfdict_in, typval { pt->pt_argv = ALLOC_MULT(typval_T, ret_pt->pt_argc); if (pt->pt_argv == NULL) - /* out of memory: drop the arguments */ + // out of memory: drop the arguments pt->pt_argc = 0; else { @@ -3580,8 +3579,8 @@ free_unref_funccal(int copyID, int testi pfc = &(*pfc)->caller; } if (did_free_funccal) - /* When a funccal was freed some more items might be garbage - * collected, so run again. */ + // When a funccal was freed some more items might be garbage + // collected, so run again. (void)garbage_collect(testing); return did_free; @@ -3606,7 +3605,7 @@ get_funccal(void) if (temp_funccal) funccal = temp_funccal; else - /* backtrace level overflow. reset to max */ + // backtrace level overflow. reset to max debug_backtrace_level = i; } } @@ -3700,7 +3699,7 @@ find_hi_in_scoped_ht(char_u *name, hasht if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL) return NULL; - /* Search in parent scope which is possible to reference from lambda */ + // Search in parent scope which is possible to reference from lambda current_funccal = current_funccal->func->uf_scoped; while (current_funccal != NULL) { @@ -3737,7 +3736,7 @@ find_var_in_scoped_ht(char_u *name, int if (current_funccal == NULL || current_funccal->func->uf_scoped == NULL) return NULL; - /* Search in parent scope which is possible to reference from lambda */ + // Search in parent scope which is possible to reference from lambda current_funccal = current_funccal->func->uf_scoped; while (current_funccal) { @@ -3887,4 +3886,4 @@ set_ref_in_func(char_u *name, ufunc_T *f return abort; } -#endif /* FEAT_EVAL */ +#endif // FEAT_EVAL
--- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2396, +/**/ 2395, /**/ 2394,
--- a/src/winclip.c +++ b/src/winclip.c @@ -61,11 +61,11 @@ utf8_to_utf16(char_u *instr, int inlen, while (todo > 0) { - /* Only convert if we have a complete sequence. */ + // Only convert if we have a complete sequence. l = utf_ptr2len_len(p, todo); if (l > todo) { - /* Return length of incomplete sequence. */ + // Return length of incomplete sequence. if (unconvlenp != NULL) *unconvlenp = todo; break; @@ -74,7 +74,7 @@ utf8_to_utf16(char_u *instr, int inlen, ch = utf_ptr2char(p); if (ch >= 0x10000) { - /* non-BMP character, encoding with surrogate pairs */ + // non-BMP character, encoding with surrogate pairs ++outlen; if (outstr != NULL) { @@ -113,7 +113,7 @@ utf16_to_utf8(short_u *instr, int inlen, ch = *p; if (ch >= 0xD800 && ch <= 0xDBFF && todo > 1) { - /* surrogate pairs handling */ + // surrogate pairs handling ch2 = p[1]; if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) { @@ -148,7 +148,7 @@ MultiByteToWideChar_alloc(UINT cp, DWORD LPWSTR *out, int *outlen) { *outlen = MultiByteToWideChar(cp, flags, in, inlen, 0, 0); - /* Add one one word to avoid a zero-length alloc(). */ + // Add one one word to avoid a zero-length alloc(). *out = ALLOC_MULT(WCHAR, *outlen + 1); if (*out != NULL) { @@ -168,7 +168,7 @@ WideCharToMultiByte_alloc(UINT cp, DWORD LPCSTR def, LPBOOL useddef) { *outlen = WideCharToMultiByte(cp, flags, in, inlen, NULL, 0, def, useddef); - /* Add one one byte to avoid a zero-length alloc(). */ + // Add one one byte to avoid a zero-length alloc(). *out = alloc(*outlen + 1); if (*out != NULL) { @@ -198,14 +198,14 @@ win_clip_init(void) clip_star.format_raw = RegisterClipboardFormat("VimRawBytes"); } -/* Type used for the clipboard type of Vim's data. */ +// Type used for the clipboard type of Vim's data. typedef struct { - int type; /* MCHAR, MBLOCK or MLINE */ - int txtlen; /* length of CF_TEXT in bytes */ - int ucslen; /* length of CF_UNICODETEXT in words */ - int rawlen; /* length of clip_star.format_raw, including encoding, - excluding terminating NUL */ + int type; // MCHAR, MBLOCK or MLINE + int txtlen; // length of CF_TEXT in bytes + int ucslen; // length of CF_UNICODETEXT in words + int rawlen; // length of clip_star.format_raw, including encoding, + // excluding terminating NUL } VimClipType_t; /* @@ -227,7 +227,7 @@ clip_mch_own_selection(Clipboard_T *cbd void clip_mch_lose_selection(Clipboard_T *cbd UNUSED) { - /* Nothing needs to be done here */ + // Nothing needs to be done here } /* @@ -243,7 +243,7 @@ crnl_to_nl(const char_u *str, int *size) char_u *ret; char_u *retp; - /* Avoid allocating zero bytes, it generates an error message. */ + // Avoid allocating zero bytes, it generates an error message. ret = alloc(str_len == 0 ? 1 : str_len); if (ret != NULL) { @@ -274,9 +274,9 @@ vim_open_clipboard(void) while (!OpenClipboard(NULL)) { if (delay > 500) - return FALSE; /* waited too long, give up */ + return FALSE; // waited too long, give up Sleep(delay); - delay *= 2; /* wait for 10, 20, 40, 80, etc. msec */ + delay *= 2; // wait for 10, 20, 40, 80, etc. msec } return TRUE; } @@ -311,19 +311,19 @@ clip_mch_request_selection(Clipboard_T * if (!vim_open_clipboard()) return; - /* Check for vim's own clipboard format first. This only gets the type of - * the data, still need to use CF_UNICODETEXT or CF_TEXT for the text. */ + // Check for vim's own clipboard format first. This only gets the type of + // the data, still need to use CF_UNICODETEXT or CF_TEXT for the text. if (IsClipboardFormatAvailable(cbd->format)) { VimClipType_t *meta_p; HGLOBAL meta_h; - /* We have metadata on the clipboard; try to get it. */ + // We have metadata on the clipboard; try to get it. if ((meta_h = GetClipboardData(cbd->format)) != NULL && (meta_p = (VimClipType_t *)GlobalLock(meta_h)) != NULL) { - /* The size of "VimClipType_t" changed, "rawlen" was added later. - * Only copy what is available for backwards compatibility. */ + // The size of "VimClipType_t" changed, "rawlen" was added later. + // Only copy what is available for backwards compatibility. n = sizeof(VimClipType_t); if (GlobalSize(meta_h) < n) n = GlobalSize(meta_h); @@ -332,12 +332,12 @@ clip_mch_request_selection(Clipboard_T * } } - /* Check for Vim's raw clipboard format first. This is used without - * conversion, but only if 'encoding' matches. */ + // Check for Vim's raw clipboard format first. This is used without + // conversion, but only if 'encoding' matches. if (IsClipboardFormatAvailable(cbd->format_raw) && metadata.rawlen > (int)STRLEN(p_enc)) { - /* We have raw data on the clipboard; try to get it. */ + // We have raw data on the clipboard; try to get it. if ((rawh = GetClipboardData(cbd->format_raw)) != NULL) { char_u *rawp; @@ -358,7 +358,7 @@ clip_mch_request_selection(Clipboard_T * } if (str == NULL) { - /* Try to get the clipboard in Unicode if it's not an empty string. */ + // Try to get the clipboard in Unicode if it's not an empty string. if (IsClipboardFormatAvailable(CF_UNICODETEXT) && metadata.ucslen != 0) { HGLOBAL hMemW; @@ -367,8 +367,8 @@ clip_mch_request_selection(Clipboard_T * { WCHAR *hMemWstr = (WCHAR *)GlobalLock(hMemW); - /* Use the length of our metadata if possible, but limit it to - * the GlobalSize() for safety. */ + // Use the length of our metadata if possible, but limit it to + // the GlobalSize() for safety. maxlen = (int)(GlobalSize(hMemW) / sizeof(WCHAR)); if (metadata.ucslen >= 0) { @@ -387,15 +387,15 @@ clip_mch_request_selection(Clipboard_T * GlobalUnlock(hMemW); } } - /* Get the clipboard in the Active codepage. */ + // Get the clipboard in the Active codepage. else if (IsClipboardFormatAvailable(CF_TEXT)) { if ((hMem = GetClipboardData(CF_TEXT)) != NULL) { str = (char_u *)GlobalLock(hMem); - /* The length is either what our metadata says or the strlen(). - * But limit it to the GlobalSize() for safety. */ + // The length is either what our metadata says or the strlen(). + // But limit it to the GlobalSize() for safety. maxlen = (int)GlobalSize(hMem); if (metadata.txtlen >= 0) { @@ -411,8 +411,8 @@ clip_mch_request_selection(Clipboard_T * break; } - /* The text is in the active codepage. Convert to - * 'encoding', going through UTF-16. */ + // The text is in the active codepage. Convert to + // 'encoding', going through UTF-16. acp_to_enc(str, str_size, &to_free, &maxlen); if (to_free != NULL) { @@ -427,11 +427,11 @@ clip_mch_request_selection(Clipboard_T * { char_u *temp_clipboard; - /* If the type is not known detect it. */ + // If the type is not known detect it. if (metadata.type == -1) metadata.type = MAUTO; - /* Translate <CR><NL> into <NL>. */ + // Translate <CR><NL> into <NL>. temp_clipboard = crnl_to_nl(str, &str_size); if (temp_clipboard != NULL) { @@ -440,7 +440,7 @@ clip_mch_request_selection(Clipboard_T * } } - /* unlock the global object */ + // unlock the global object if (hMem != NULL) GlobalUnlock(hMem); if (rawh != NULL) @@ -463,12 +463,12 @@ clip_mch_set_selection(Clipboard_T *cbd) HGLOBAL hMemVim = NULL; HGLOBAL hMemW = NULL; - /* If the '*' register isn't already filled in, fill it in now */ + // If the '*' register isn't already filled in, fill it in now cbd->owned = TRUE; clip_get_selection(cbd); cbd->owned = FALSE; - /* Get the text to be put on the clipboard, with CR-LF. */ + // Get the text to be put on the clipboard, with CR-LF. metadata.type = clip_convert_selection(&str, &txtlen, cbd); if (metadata.type < 0) return; @@ -476,9 +476,9 @@ clip_mch_set_selection(Clipboard_T *cbd) metadata.ucslen = 0; metadata.rawlen = 0; - /* Always set the raw bytes: 'encoding', NUL and the text. This is used - * when copy/paste from/to Vim with the same 'encoding', so that illegal - * bytes can also be copied and no conversion is needed. */ + // Always set the raw bytes: 'encoding', NUL and the text. This is used + // when copy/paste from/to Vim with the same 'encoding', so that illegal + // bytes can also be copied and no conversion is needed. { LPSTR lpszMemRaw; @@ -500,15 +500,15 @@ clip_mch_set_selection(Clipboard_T *cbd) WCHAR *out; int len = metadata.txtlen; - /* Convert the text to UTF-16. This is put on the clipboard as - * CF_UNICODETEXT. */ + // Convert the text to UTF-16. This is put on the clipboard as + // CF_UNICODETEXT. out = (WCHAR *)enc_to_utf16(str, &len); if (out != NULL) { WCHAR *lpszMemW; - /* Convert the text for CF_TEXT to Active codepage. Otherwise it's - * p_enc, which has no relation to the Active codepage. */ + // Convert the text for CF_TEXT to Active codepage. Otherwise it's + // p_enc, which has no relation to the Active codepage. metadata.txtlen = WideCharToMultiByte(GetACP(), 0, out, len, NULL, 0, 0, 0); vim_free(str); @@ -516,13 +516,13 @@ clip_mch_set_selection(Clipboard_T *cbd) if (str == NULL) { vim_free(out); - return; /* out of memory */ + return; // out of memory } WideCharToMultiByte(GetACP(), 0, out, len, (LPSTR)str, metadata.txtlen, 0, 0); - /* Allocate memory for the UTF-16 text, add one NUL word to - * terminate the string. */ + // Allocate memory for the UTF-16 text, add one NUL word to + // terminate the string. hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (len + 1) * sizeof(WCHAR)); lpszMemW = (WCHAR *)GlobalLock(hMemW); @@ -537,8 +537,7 @@ clip_mch_set_selection(Clipboard_T *cbd) } } - /* Allocate memory for the text, add one NUL byte to terminate the string. - */ + // Allocate memory for the text, add one NUL byte to terminate the string. hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, metadata.txtlen + 1); { LPSTR lpszMem = (LPSTR)GlobalLock(hMem); @@ -550,7 +549,7 @@ clip_mch_set_selection(Clipboard_T *cbd) } } - /* Set up metadata: */ + // Set up metadata: { VimClipType_t *lpszMemVim = NULL; @@ -580,8 +579,8 @@ clip_mch_set_selection(Clipboard_T *cbd) if (SetClipboardData(CF_UNICODETEXT, hMemW) != NULL) hMemW = NULL; } - /* Always use CF_TEXT. On Win98 Notepad won't obtain the - * CF_UNICODETEXT text, only CF_TEXT. */ + // Always use CF_TEXT. On Win98 Notepad won't obtain the + // CF_UNICODETEXT text, only CF_TEXT. SetClipboardData(CF_TEXT, hMem); hMem = 0; } @@ -589,7 +588,7 @@ clip_mch_set_selection(Clipboard_T *cbd) } vim_free(str); - /* Free any allocations we didn't give to the clipboard: */ + // Free any allocations we didn't give to the clipboard: if (hMemRaw) GlobalFree(hMemRaw); if (hMem) @@ -600,7 +599,7 @@ clip_mch_set_selection(Clipboard_T *cbd) GlobalFree(hMemVim); } -#endif /* FEAT_CLIPBOARD */ +#endif // FEAT_CLIPBOARD /* * Note: the following two functions are only guaranteed to work when using @@ -631,16 +630,16 @@ enc_to_utf16(char_u *str, int *lenp) if (enc_codepage > 0) { - /* We can do any CP### -> UTF-16 in one pass, and we can do it - * without iconv() (convert_* may need iconv). */ + // We can do any CP### -> UTF-16 in one pass, and we can do it + // without iconv() (convert_* may need iconv). MultiByteToWideChar_alloc(enc_codepage, 0, (LPCSTR)str, *lenp, &ret, &length); } else { - /* Use "latin1" by default, we might be called before we have p_enc - * set up. Convert to utf-8 first, works better with iconv(). Does - * nothing if 'encoding' is "utf-8". */ + // Use "latin1" by default, we might be called before we have p_enc + // set up. Convert to utf-8 first, works better with iconv(). Does + // nothing if 'encoding' is "utf-8". conv.vc_type = CONV_NONE; if (convert_setup(&conv, p_enc ? p_enc : (char_u *)"latin1", (char_u *)"utf-8") == FAIL) @@ -691,7 +690,7 @@ utf16_to_enc(short_u *str, int *lenp) if (enc_codepage > 0) { - /* We can do any UTF-16 -> CP### in one pass. */ + // We can do any UTF-16 -> CP### in one pass. int length; WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp, @@ -700,19 +699,19 @@ utf16_to_enc(short_u *str, int *lenp) return enc_str; } - /* Avoid allocating zero bytes, it generates an error message. */ + // Avoid allocating zero bytes, it generates an error message. utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL)); if (utf8_str != NULL) { *lenp = utf16_to_utf8(str, *lenp, utf8_str); - /* We might be called before we have p_enc set up. */ + // We might be called before we have p_enc set up. conv.vc_type = CONV_NONE; convert_setup(&conv, (char_u *)"utf-8", p_enc? p_enc: (char_u *)"latin1"); if (conv.vc_type == CONV_NONE) { - /* p_enc is utf-8, so we're done. */ + // p_enc is utf-8, so we're done. enc_str = utf8_str; } else @@ -746,7 +745,7 @@ acp_to_enc( &widestr, outlen); if (widestr != NULL) { - ++*outlen; /* Include the 0 after the string */ + ++*outlen; // Include the 0 after the string *out = utf16_to_enc((short_u *)widestr, outlen); vim_free(widestr); }
--- a/src/window.c +++ b/src/window.c @@ -63,7 +63,7 @@ static int frame_check_width(frame_T *to static win_T *win_alloc(win_T *after, int hidden); -#define NOWIN (win_T *)-1 /* non-existing window */ +#define NOWIN (win_T *)-1 // non-existing window #define ROWS_AVAIL (Rows - p_ch - tabline_height()) @@ -108,7 +108,7 @@ log_frame_layout(frame_T *frame) do_window( int nchar, long Prenum, - int xchar) /* extra char from ":wincmd gx" or NUL */ + int xchar) // extra char from ":wincmd gx" or NUL { long Prenum1; win_T *wp; @@ -142,15 +142,15 @@ do_window( switch (nchar) { -/* split current window in two parts, horizontally */ +// split current window in two parts, horizontally case 'S': case Ctrl_S: case 's': CHECK_CMDWIN; - reset_VIsual_and_resel(); /* stop Visual mode */ + reset_VIsual_and_resel(); // stop Visual mode #ifdef FEAT_QUICKFIX - /* When splitting the quickfix window open a new buffer in it, - * don't replicate the quickfix buffer. */ + // When splitting the quickfix window open a new buffer in it, + // don't replicate the quickfix buffer. if (bt_quickfix(curbuf)) goto newwindow; #endif @@ -160,14 +160,14 @@ do_window( (void)win_split((int)Prenum, 0); break; -/* split current window in two parts, vertically */ +// split current window in two parts, vertically case Ctrl_V: case 'v': CHECK_CMDWIN; - reset_VIsual_and_resel(); /* stop Visual mode */ + reset_VIsual_and_resel(); // stop Visual mode #ifdef FEAT_QUICKFIX - /* When splitting the quickfix window open a new buffer in it, - * don't replicate the quickfix buffer. */ + // When splitting the quickfix window open a new buffer in it, + // don't replicate the quickfix buffer. if (bt_quickfix(curbuf)) goto newwindow; #endif @@ -177,11 +177,11 @@ do_window( (void)win_split((int)Prenum, WSP_VERT); break; -/* split current window and edit alternate file */ +// split current window and edit alternate file case Ctrl_HAT: case '^': CHECK_CMDWIN; - reset_VIsual_and_resel(); /* stop Visual mode */ + reset_VIsual_and_resel(); // stop Visual mode if (buflist_findnr(Prenum == 0 ? curwin->w_alt_fnum : Prenum) == NULL) @@ -199,16 +199,16 @@ do_window( (linenr_T)0, GETF_ALT, FALSE); break; -/* open new window */ +// open new window case Ctrl_N: case 'n': CHECK_CMDWIN; - reset_VIsual_and_resel(); /* stop Visual mode */ + reset_VIsual_and_resel(); // stop Visual mode #ifdef FEAT_QUICKFIX newwindow: #endif if (Prenum) - /* window height */ + // window height vim_snprintf((char *)cbuf, sizeof(cbuf) - 5, "%ld", Prenum); else cbuf[0] = NUL; @@ -220,32 +220,32 @@ newwindow: do_cmdline_cmd(cbuf); break; -/* quit current window */ +// quit current window case Ctrl_Q: case 'q': - reset_VIsual_and_resel(); /* stop Visual mode */ + reset_VIsual_and_resel(); // stop Visual mode cmd_with_count("quit", cbuf, sizeof(cbuf), Prenum); do_cmdline_cmd(cbuf); break; -/* close current window */ +// close current window case Ctrl_C: case 'c': - reset_VIsual_and_resel(); /* stop Visual mode */ + reset_VIsual_and_resel(); // stop Visual mode cmd_with_count("close", cbuf, sizeof(cbuf), Prenum); do_cmdline_cmd(cbuf); break; #if defined(FEAT_QUICKFIX) -/* close preview window */ +// close preview window case Ctrl_Z: case 'z': CHECK_CMDWIN; - reset_VIsual_and_resel(); /* stop Visual mode */ + reset_VIsual_and_resel(); // stop Visual mode do_cmdline_cmd((char_u *)"pclose"); break; -/* cursor to preview window */ +// cursor to preview window case 'P': FOR_ALL_WINDOWS(wp) if (wp->w_p_pvw) @@ -257,26 +257,26 @@ newwindow: break; #endif -/* close all but current window */ +// close all but current window case Ctrl_O: case 'o': CHECK_CMDWIN; - reset_VIsual_and_resel(); /* stop Visual mode */ + reset_VIsual_and_resel(); // stop Visual mode cmd_with_count("only", cbuf, sizeof(cbuf), Prenum); do_cmdline_cmd(cbuf); break; -/* cursor to next window with wrap around */ +// cursor to next window with wrap around case Ctrl_W: case 'w': -/* cursor to previous window with wrap around */ +// cursor to previous window with wrap around case 'W': CHECK_CMDWIN; - if (ONE_WINDOW && Prenum != 1) /* just one window */ + if (ONE_WINDOW && Prenum != 1) // just one window beep_flush(); else { - if (Prenum) /* go to specified window */ + if (Prenum) // go to specified window { for (wp = firstwin; --Prenum > 0; ) { @@ -288,24 +288,24 @@ newwindow: } else { - if (nchar == 'W') /* go to previous window */ + if (nchar == 'W') // go to previous window { wp = curwin->w_prev; if (wp == NULL) - wp = lastwin; /* wrap around */ + wp = lastwin; // wrap around } - else /* go to next window */ + else // go to next window { wp = curwin->w_next; if (wp == NULL) - wp = firstwin; /* wrap around */ + wp = firstwin; // wrap around } } win_goto(wp); } break; -/* cursor to window below */ +// cursor to window below case 'j': case K_DOWN: case Ctrl_J: @@ -313,7 +313,7 @@ newwindow: win_goto_ver(FALSE, Prenum1); break; -/* cursor to window above */ +// cursor to window above case 'k': case K_UP: case Ctrl_K: @@ -321,7 +321,7 @@ newwindow: win_goto_ver(TRUE, Prenum1); break; -/* cursor to left window */ +// cursor to left window case 'h': case K_LEFT: case Ctrl_H: @@ -330,7 +330,7 @@ newwindow: win_goto_hor(TRUE, Prenum1); break; -/* cursor to right window */ +// cursor to right window case 'l': case K_RIGHT: case Ctrl_L: @@ -338,7 +338,7 @@ newwindow: win_goto_hor(FALSE, Prenum1); break; -/* move window to new tab page */ +// move window to new tab page case 'T': if (one_window()) msg(_(m_onlyone)); @@ -347,8 +347,8 @@ newwindow: tabpage_T *oldtab = curtab; tabpage_T *newtab; - /* First create a new tab with the window, then go back to - * the old tab and close the window there. */ + // First create a new tab with the window, then go back to + // the old tab and close the window there. wp = curwin; if (win_new_tabpage((int)Prenum) == OK && valid_tabpage(oldtab)) @@ -363,19 +363,19 @@ newwindow: } break; -/* cursor to top-left window */ +// cursor to top-left window case 't': case Ctrl_T: win_goto(firstwin); break; -/* cursor to bottom-right window */ +// cursor to bottom-right window case 'b': case Ctrl_B: win_goto(lastwin); break; -/* cursor to last accessed (previous) window */ +// cursor to last accessed (previous) window case 'p': case Ctrl_P: if (!win_valid(prevwin)) @@ -384,29 +384,29 @@ newwindow: win_goto(prevwin); break; -/* exchange current and next window */ +// exchange current and next window case 'x': case Ctrl_X: CHECK_CMDWIN; win_exchange(Prenum); break; -/* rotate windows downwards */ +// rotate windows downwards case Ctrl_R: case 'r': CHECK_CMDWIN; - reset_VIsual_and_resel(); /* stop Visual mode */ - win_rotate(FALSE, (int)Prenum1); /* downwards */ + reset_VIsual_and_resel(); // stop Visual mode + win_rotate(FALSE, (int)Prenum1); // downwards break; -/* rotate windows upwards */ +// rotate windows upwards case 'R': CHECK_CMDWIN; - reset_VIsual_and_resel(); /* stop Visual mode */ - win_rotate(TRUE, (int)Prenum1); /* upwards */ + reset_VIsual_and_resel(); // stop Visual mode + win_rotate(TRUE, (int)Prenum1); // upwards break; -/* move window to the very top/bottom/left/right */ +// move window to the very top/bottom/left/right case 'K': case 'J': case 'H': @@ -417,7 +417,7 @@ newwindow: | ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT)); break; -/* make all windows the same height */ +// make all windows the same height case '=': #ifdef FEAT_GUI need_mouse_correct = TRUE; @@ -425,7 +425,7 @@ newwindow: win_equal(NULL, FALSE, 'b'); break; -/* increase current window height */ +// increase current window height case '+': #ifdef FEAT_GUI need_mouse_correct = TRUE; @@ -433,7 +433,7 @@ newwindow: win_setheight(curwin->w_height + (int)Prenum1); break; -/* decrease current window height */ +// decrease current window height case '-': #ifdef FEAT_GUI need_mouse_correct = TRUE; @@ -441,7 +441,7 @@ newwindow: win_setheight(curwin->w_height - (int)Prenum1); break; -/* set current window height */ +// set current window height case Ctrl__: case '_': #ifdef FEAT_GUI @@ -450,7 +450,7 @@ newwindow: win_setheight(Prenum ? (int)Prenum : 9999); break; -/* increase current window width */ +// increase current window width case '>': #ifdef FEAT_GUI need_mouse_correct = TRUE; @@ -458,7 +458,7 @@ newwindow: win_setwidth(curwin->w_width + (int)Prenum1); break; -/* decrease current window width */ +// decrease current window width case '<': #ifdef FEAT_GUI need_mouse_correct = TRUE; @@ -466,7 +466,7 @@ newwindow: win_setwidth(curwin->w_width - (int)Prenum1); break; -/* set current window width */ +// set current window width case '|': #ifdef FEAT_GUI need_mouse_correct = TRUE; @@ -474,7 +474,7 @@ newwindow: win_setwidth(Prenum != 0 ? (int)Prenum : 9999); break; -/* jump to tag and split window if tag exists (in preview window) */ +// jump to tag and split window if tag exists (in preview window) #if defined(FEAT_QUICKFIX) case '}': CHECK_CMDWIN; @@ -483,11 +483,11 @@ newwindow: else g_do_tagpreview = p_pvh; #endif - /* FALLTHROUGH */ + // FALLTHROUGH case ']': case Ctrl_RSB: CHECK_CMDWIN; - /* keep Visual mode, can select words to use as a tag */ + // keep Visual mode, can select words to use as a tag if (Prenum) postponed_split = Prenum; else @@ -497,13 +497,13 @@ newwindow: g_do_tagpreview = 0; #endif - /* Execute the command right here, required when "wincmd ]" - * was used in a function. */ + // Execute the command right here, required when "wincmd ]" + // was used in a function. do_nv_ident(Ctrl_RSB, NUL); break; #ifdef FEAT_SEARCHPATH -/* edit file name under cursor in a new window */ +// edit file name under cursor in a new window case 'f': case 'F': case Ctrl_F: @@ -525,8 +525,8 @@ wingotofile: if (do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE, NULL) == FAIL) { - /* Failed to open the file, close the window - * opened for it. */ + // Failed to open the file, close the window + // opened for it. win_close(curwin, FALSE); goto_tabpage_win(oldtab, oldwin); } @@ -543,14 +543,13 @@ wingotofile: #endif #ifdef FEAT_FIND_ID -/* Go to the first occurrence of the identifier under cursor along path in a - * new window -- webb - */ - case 'i': /* Go to any match */ +// Go to the first occurrence of the identifier under cursor along path in a +// new window -- webb + case 'i': // Go to any match case Ctrl_I: type = FIND_ANY; - /* FALLTHROUGH */ - case 'd': /* Go to definition, using 'define' */ + // FALLTHROUGH + case 'd': // Go to definition, using 'define' case Ctrl_D: CHECK_CMDWIN; if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) @@ -562,7 +561,7 @@ wingotofile: break; #endif -/* Quickfix window only: view the result under the cursor in a new split. */ +// Quickfix window only: view the result under the cursor in a new split. #if defined(FEAT_QUICKFIX) case K_KENTER: case CAR: @@ -571,15 +570,15 @@ wingotofile: break; #endif -/* CTRL-W g extended commands */ +// CTRL-W g extended commands case 'g': case Ctrl_G: CHECK_CMDWIN; #ifdef USE_ON_FLY_SCROLL - dont_scroll = TRUE; /* disallow scrolling here */ + dont_scroll = TRUE; // disallow scrolling here #endif ++no_mapping; - ++allow_keys; /* no mapping for xchar, but allow key codes */ + ++allow_keys; // no mapping for xchar, but allow key codes if (xchar == NUL) xchar = plain_vgetc(); LANGMAP_ADJUST(xchar, TRUE); @@ -598,23 +597,23 @@ wingotofile: else g_do_tagpreview = p_pvh; #endif - /* FALLTHROUGH */ + // FALLTHROUGH case ']': case Ctrl_RSB: - /* keep Visual mode, can select words to use as a tag */ + // keep Visual mode, can select words to use as a tag if (Prenum) postponed_split = Prenum; else postponed_split = -1; - /* Execute the command right here, required when - * "wincmd g}" was used in a function. */ + // Execute the command right here, required when + // "wincmd g}" was used in a function. do_nv_ident('g', xchar); break; #ifdef FEAT_SEARCHPATH - case 'f': /* CTRL-W gf: "gf" in a new tab page */ - case 'F': /* CTRL-W gF: "gF" in a new tab page */ + case 'f': // CTRL-W gf: "gf" in a new tab page + case 'F': // CTRL-W gF: "gF" in a new tab page cmdmod.tab = tabpage_index(curtab) + 1; nchar = xchar; goto wingotofile; @@ -788,11 +787,11 @@ win_split(int size, int flags) if (ERROR_IF_POPUP_WINDOW) return FAIL; - /* When the ":tab" modifier was used open a new tab page instead. */ + // When the ":tab" modifier was used open a new tab page instead. if (may_open_tabpage() == OK) return OK; - /* Add flags from ":vertical", ":topleft" and ":botright". */ + // Add flags from ":vertical", ":topleft" and ":botright". flags |= cmdmod.split; if ((flags & WSP_TOP) && (flags & WSP_BOT)) { @@ -802,8 +801,8 @@ win_split(int size, int flags) if (check_split_disallowed() == FAIL) return FAIL; - /* When creating the help window make a snapshot of the window layout. - * Otherwise clear the snapshot, it's now invalid. */ + // When creating the help window make a snapshot of the window layout. + // Otherwise clear the snapshot, it's now invalid. if (flags & WSP_HELP) make_snapshot(SNAP_HELP_IDX); else @@ -848,7 +847,7 @@ win_split_ins( else oldwin = curwin; - /* add a status line when p_ls == 1 and splitting the first window */ + // add a status line when p_ls == 1 and splitting the first window if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0) { if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL) @@ -860,7 +859,7 @@ win_split_ins( } #ifdef FEAT_GUI - /* May be needed for the scrollbars that are going to change. */ + // May be needed for the scrollbars that are going to change. if (gui.in_use) out_flush(); #endif @@ -876,7 +875,7 @@ win_split_ins( * Check if we are able to split the current window and compute its * width. */ - /* Current window requires at least 1 space. */ + // Current window requires at least 1 space. wmw1 = (p_wmw == 0 ? 1 : p_wmw); needed = wmw1 + 1; if (flags & WSP_ROOM) @@ -921,18 +920,18 @@ win_split_ins( if (new_size < wmw1) new_size = wmw1; - /* if it doesn't fit in the current window, need win_equal() */ + // if it doesn't fit in the current window, need win_equal() if (oldwin->w_width - new_size - 1 < p_wmw) do_equal = TRUE; - /* We don't like to take lines for the new window from a - * 'winfixwidth' window. Take them from a window to the left or right - * instead, if possible. Add one for the separator. */ + // We don't like to take lines for the new window from a + // 'winfixwidth' window. Take them from a window to the left or right + // instead, if possible. Add one for the separator. if (oldwin->w_p_wfw) win_setwidth_win(oldwin->w_width + new_size + 1, oldwin); - /* Only make all windows the same width if one of them (except oldwin) - * is wider than one of the split windows. */ + // Only make all windows the same width if one of them (except oldwin) + // is wider than one of the split windows. if (!do_equal && p_ea && size == 0 && *p_ead != 'v' && oldwin->w_frame->fr_parent != NULL) { @@ -959,7 +958,7 @@ win_split_ins( * Check if we are able to split the current window and compute its * height. */ - /* Current window requires at least 1 space. */ + // Current window requires at least 1 space. wmh1 = (p_wmh == 0 ? 1 : p_wmh) + WINBAR_HEIGHT(curwin); needed = wmh1 + STATUS_HEIGHT; if (flags & WSP_ROOM) @@ -1010,17 +1009,17 @@ win_split_ins( if (new_size < wmh1) new_size = wmh1; - /* if it doesn't fit in the current window, need win_equal() */ + // if it doesn't fit in the current window, need win_equal() if (oldwin_height - new_size - STATUS_HEIGHT < p_wmh) do_equal = TRUE; - /* We don't like to take lines for the new window from a - * 'winfixheight' window. Take them from a window above or below - * instead, if possible. */ + // We don't like to take lines for the new window from a + // 'winfixheight' window. Take them from a window above or below + // instead, if possible. if (oldwin->w_p_wfh) { - /* Set w_fraction now so that the cursor keeps the same relative - * vertical position using the old height. */ + // Set w_fraction now so that the cursor keeps the same relative + // vertical position using the old height. set_fraction(oldwin); did_set_fraction = TRUE; @@ -1031,8 +1030,8 @@ win_split_ins( oldwin_height -= STATUS_HEIGHT; } - /* Only make all windows the same height if one of them (except oldwin) - * is higher than one of the split windows. */ + // Only make all windows the same height if one of them (except oldwin) + // is higher than one of the split windows. if (!do_equal && p_ea && size == 0 && *p_ead != 'h' && oldwin->w_frame->fr_parent != NULL) { @@ -1061,7 +1060,7 @@ win_split_ins( || (!(flags & WSP_ABOVE) && ( (flags & WSP_VERT) ? p_spr : p_sb)))) { - /* new window below/right of current one */ + // new window below/right of current one if (new_wp == NULL) wp = win_alloc(oldwin, FALSE); else @@ -1087,7 +1086,7 @@ win_split_ins( return FAIL; } - /* make the contents of the new window the same as the current one */ + // make the contents of the new window the same as the current one win_init(wp, curwin, flags); } @@ -1122,7 +1121,7 @@ win_split_ins( } if (curfrp->fr_parent == NULL || curfrp->fr_parent->fr_layout != layout) { - /* Need to create a new frame in the tree to make a branch. */ + // Need to create a new frame in the tree to make a branch. frp = ALLOC_CLEAR_ONE(frame_T); *frp = *curfrp; curfrp->fr_layout = layout; @@ -1145,14 +1144,14 @@ win_split_ins( frp = new_wp->w_frame; frp->fr_parent = curfrp->fr_parent; - /* Insert the new frame at the right place in the frame list. */ + // Insert the new frame at the right place in the frame list. if (before) frame_insert(curfrp, frp); else frame_append(curfrp, frp); - /* Set w_fraction now so that the cursor keeps the same relative - * vertical position. */ + // Set w_fraction now so that the cursor keeps the same relative + // vertical position. if (!did_set_fraction) set_fraction(oldwin); wp->w_fraction = oldwin->w_fraction; @@ -1168,7 +1167,7 @@ win_split_ins( } if (flags & (WSP_TOP | WSP_BOT)) { - /* set height and row of new window to full height */ + // set height and row of new window to full height wp->w_winrow = tabline_height(); win_new_height(wp, curfrp->fr_height - (p_ls > 0) - WINBAR_HEIGHT(wp)); @@ -1176,15 +1175,15 @@ win_split_ins( } else { - /* height and row of new window is same as current window */ + // height and row of new window is same as current window wp->w_winrow = oldwin->w_winrow; win_new_height(wp, VISIBLE_HEIGHT(oldwin)); wp->w_status_height = oldwin->w_status_height; } frp->fr_height = curfrp->fr_height; - /* "new_size" of the current window goes to the new window, use - * one column for the vertical separator */ + // "new_size" of the current window goes to the new window, use + // one column for the vertical separator win_new_width(wp, new_size); if (before) wp->w_vsep_width = 1; @@ -1197,26 +1196,26 @@ win_split_ins( { if (flags & WSP_BOT) frame_add_vsep(curfrp); - /* Set width of neighbor frame */ + // Set width of neighbor frame frame_new_width(curfrp, curfrp->fr_width - (new_size + ((flags & WSP_TOP) != 0)), flags & WSP_TOP, FALSE); } else win_new_width(oldwin, oldwin->w_width - (new_size + 1)); - if (before) /* new window left of current one */ + if (before) // new window left of current one { wp->w_wincol = oldwin->w_wincol; oldwin->w_wincol += new_size + 1; } - else /* new window right of current one */ + else // new window right of current one wp->w_wincol = oldwin->w_wincol + oldwin->w_width + 1; frame_fix_width(oldwin); frame_fix_width(wp); } else { - /* width and column of new window is same as current window */ + // width and column of new window is same as current window if (flags & (WSP_TOP | WSP_BOT)) { wp->w_wincol = 0; @@ -1231,8 +1230,8 @@ win_split_ins( } frp->fr_width = curfrp->fr_width; - /* "new_size" of the current window goes to the new window, use - * one row for the status line */ + // "new_size" of the current window goes to the new window, use + // one row for the status line win_new_height(wp, new_size); if (flags & (WSP_TOP | WSP_BOT)) { @@ -1245,13 +1244,13 @@ win_split_ins( } else win_new_height(oldwin, oldwin_height - (new_size + STATUS_HEIGHT)); - if (before) /* new window above current one */ + if (before) // new window above current one { wp->w_winrow = oldwin->w_winrow; wp->w_status_height = STATUS_HEIGHT; oldwin->w_winrow += wp->w_height + STATUS_HEIGHT; } - else /* new window below current one */ + else // new window below current one { wp->w_winrow = oldwin->w_winrow + VISIBLE_HEIGHT(oldwin) + STATUS_HEIGHT; @@ -1280,10 +1279,10 @@ win_split_ins( { msg_row = Rows - 1; msg_col = sc_col; - msg_clr_eos_force(); /* Old command/ruler may still be there */ + msg_clr_eos_force(); // Old command/ruler may still be there comp_col(); msg_row = Rows - 1; - msg_col = 0; /* put position back at start of line */ + msg_col = 0; // put position back at start of line } /* @@ -1294,8 +1293,8 @@ win_split_ins( (flags & WSP_VERT) ? (dir == 'v' ? 'b' : 'h') : dir == 'h' ? 'b' : 'v'); - /* Don't change the window height/width to 'winheight' / 'winwidth' if a - * size was given. */ + // Don't change the window height/width to 'winheight' / 'winwidth' if a + // size was given. if (flags & WSP_VERT) { i = p_wiw; @@ -1303,7 +1302,7 @@ win_split_ins( p_wiw = size; # ifdef FEAT_GUI - /* When 'guioptions' includes 'L' or 'R' may have to add scrollbars. */ + // When 'guioptions' includes 'L' or 'R' may have to add scrollbars. if (gui.in_use) gui_init_which_components(NULL); # endif @@ -1316,7 +1315,7 @@ win_split_ins( } #ifdef FEAT_JUMPLIST - /* Keep same changelist position in new window. */ + // Keep same changelist position in new window. wp->w_changelistidx = oldwin->w_changelistidx; #endif @@ -1371,7 +1370,7 @@ win_init(win_T *newp, win_T *oldp, int f #ifdef FEAT_QUICKFIX if (flags & WSP_NEWLOC) { - /* Don't copy the location list. */ + // Don't copy the location list. newp->w_llist = NULL; newp->w_llist_ref = NULL; } @@ -1381,7 +1380,7 @@ win_init(win_T *newp, win_T *oldp, int f newp->w_localdir = (oldp->w_localdir == NULL) ? NULL : vim_strsave(oldp->w_localdir); - /* copy tagstack and folds */ + // copy tagstack and folds for (i = 0; i < oldp->w_tagstacklen; i++) { taggy_T *tag = &newp->w_tagstack[i]; @@ -1411,12 +1410,12 @@ win_init(win_T *newp, win_T *oldp, int f static void win_init_some(win_T *newp, win_T *oldp) { - /* Use the same argument list. */ + // Use the same argument list. newp->w_alist = oldp->w_alist; ++newp->w_alist->al_refcount; newp->w_arg_idx = oldp->w_arg_idx; - /* copy options from existing window */ + // copy options from existing window win_copy_options(oldp, newp); } @@ -1505,21 +1504,21 @@ win_count(void) int make_windows( int count, - int vertical UNUSED) /* split windows vertically if TRUE */ + int vertical UNUSED) // split windows vertically if TRUE { int maxcount; int todo; if (vertical) { - /* Each windows needs at least 'winminwidth' lines and a separator - * column. */ + // Each windows needs at least 'winminwidth' lines and a separator + // column. maxcount = (curwin->w_width + curwin->w_vsep_width - (p_wiw - p_wmw)) / (p_wmw + 1); } else { - /* Each window needs at least 'winminheight' lines and a status line. */ + // Each window needs at least 'winminheight' lines and a status line. maxcount = (VISIBLE_HEIGHT(curwin) + curwin->w_status_height - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); } @@ -1541,7 +1540,7 @@ make_windows( */ block_autocmds(); - /* todo is number of windows left to create */ + // todo is number of windows left to create for (todo = count - 1; todo > 0; --todo) if (vertical) { @@ -1559,7 +1558,7 @@ make_windows( unblock_autocmds(); - /* return actual number of windows */ + // return actual number of windows return (count - todo); } @@ -1596,13 +1595,13 @@ win_exchange(long Prenum) while (frp != NULL && --Prenum > 0) frp = frp->fr_next; } - else if (curwin->w_frame->fr_next != NULL) /* Swap with next */ + else if (curwin->w_frame->fr_next != NULL) // Swap with next frp = curwin->w_frame->fr_next; - else /* Swap last window in row/col with previous */ + else // Swap last window in row/col with previous frp = curwin->w_frame->fr_prev; - /* We can only exchange a window with another window, not with a frame - * containing windows. */ + // We can only exchange a window with another window, not with a frame + // containing windows. if (frp == NULL || frp->fr_win == NULL || frp->fr_win == curwin) return; wp = frp->fr_win; @@ -1641,8 +1640,8 @@ win_exchange(long Prenum) curwin->w_vsep_width = wp->w_vsep_width; wp->w_vsep_width = temp; - /* If the windows are not in the same frame, exchange the sizes to avoid - * messing up the window layout. Otherwise fix the frame sizes. */ + // If the windows are not in the same frame, exchange the sizes to avoid + // messing up the window layout. Otherwise fix the frame sizes. if (curwin->w_frame->fr_parent != wp->w_frame->fr_parent) { temp = curwin->w_height; @@ -1660,7 +1659,7 @@ win_exchange(long Prenum) frame_fix_width(wp); } - (void)win_comp_pos(); /* recompute window positions */ + (void)win_comp_pos(); // recompute window positions win_enter(wp, TRUE); redraw_all_later(NOT_VALID); @@ -1678,7 +1677,7 @@ win_rotate(int upwards, int count) frame_T *frp; int n; - if (ONE_WINDOW) /* nothing to do */ + if (ONE_WINDOW) // nothing to do { beep_flush(); return; @@ -1688,7 +1687,7 @@ win_rotate(int upwards, int count) need_mouse_correct = TRUE; #endif - /* Check if all frames in this row/col have one window. */ + // Check if all frames in this row/col have one window. FOR_ALL_FRAMES(frp, curwin->w_frame->fr_parent->fr_child) if (frp->fr_win == NULL) { @@ -1698,39 +1697,39 @@ win_rotate(int upwards, int count) while (count--) { - if (upwards) /* first window becomes last window */ + if (upwards) // first window becomes last window { - /* remove first window/frame from the list */ + // remove first window/frame from the list frp = curwin->w_frame->fr_parent->fr_child; wp1 = frp->fr_win; win_remove(wp1, NULL); frame_remove(frp); - /* find last frame and append removed window/frame after it */ + // find last frame and append removed window/frame after it for ( ; frp->fr_next != NULL; frp = frp->fr_next) ; win_append(frp->fr_win, wp1); frame_append(frp, wp1->w_frame); - wp2 = frp->fr_win; /* previously last window */ + wp2 = frp->fr_win; // previously last window } - else /* last window becomes first window */ + else // last window becomes first window { - /* find last window/frame in the list and remove it */ + // find last window/frame in the list and remove it for (frp = curwin->w_frame; frp->fr_next != NULL; frp = frp->fr_next) ; wp1 = frp->fr_win; - wp2 = wp1->w_prev; /* will become last window */ + wp2 = wp1->w_prev; // will become last window win_remove(wp1, NULL); frame_remove(frp); - /* append the removed window/frame before the first in the list */ + // append the removed window/frame before the first in the list win_append(frp->fr_parent->fr_child->fr_win->w_prev, wp1); frame_insert(frp->fr_parent->fr_child, frp); } - /* exchange status height and vsep width of old and new last window */ + // exchange status height and vsep width of old and new last window n = wp2->w_status_height; wp2->w_status_height = wp1->w_status_height; wp1->w_status_height = n; @@ -1742,7 +1741,7 @@ win_rotate(int upwards, int count) frame_fix_width(wp1); frame_fix_width(wp2); - /* recompute w_winrow and w_wincol for all windows */ + // recompute w_winrow and w_wincol for all windows (void)win_comp_pos(); } @@ -1766,13 +1765,13 @@ win_totop(int size, int flags) if (check_split_disallowed() == FAIL) return; - /* Remove the window and frame from the tree of frames. */ + // Remove the window and frame from the tree of frames. (void)winframe_remove(curwin, &dir, NULL); win_remove(curwin, NULL); - last_status(FALSE); /* may need to remove last status line */ - (void)win_comp_pos(); /* recompute window positions */ - - /* Split a window on the desired side and put the window there. */ + last_status(FALSE); // may need to remove last status line + (void)win_comp_pos(); // recompute window positions + + // Split a window on the desired side and put the window there. (void)win_split_ins(size, flags, curwin, dir); if (!(flags & WSP_VERT)) { @@ -1782,8 +1781,8 @@ win_totop(int size, int flags) } #if defined(FEAT_GUI) - /* When 'guioptions' includes 'L' or 'R' may have to remove or add - * scrollbars. Have to update them anyway. */ + // When 'guioptions' includes 'L' or 'R' may have to remove or add + // scrollbars. Have to update them anyway. gui_may_update_scrollbars(); #endif } @@ -1797,11 +1796,11 @@ win_move_after(win_T *win1, win_T *win2) { int height; - /* check if the arguments are reasonable */ + // check if the arguments are reasonable if (win1 == win2) return; - /* check if there is something to do */ + // check if there is something to do if (win2->w_next != win1) { if (win1->w_frame->fr_parent != win2->w_frame->fr_parent) @@ -1810,8 +1809,8 @@ win_move_after(win_T *win1, win_T *win2) return; } - /* may need move the status line/vertical separator of the last window - * */ + // may need move the status line/vertical separator of the last window + // if (win1 == lastwin) { height = win1->w_prev->w_status_height; @@ -1819,8 +1818,8 @@ win_move_after(win_T *win1, win_T *win2) win1->w_status_height = height; if (win1->w_prev->w_vsep_width == 1) { - /* Remove the vertical separator from the last-but-one window, - * add it to the last window. Adjust the frame widths. */ + // Remove the vertical separator from the last-but-one window, + // add it to the last window. Adjust the frame widths. win1->w_prev->w_vsep_width = 0; win1->w_prev->w_frame->fr_width -= 1; win1->w_vsep_width = 1; @@ -1834,8 +1833,8 @@ win_move_after(win_T *win1, win_T *win2) win2->w_status_height = height; if (win1->w_vsep_width == 1) { - /* Remove the vertical separator from win1, add it to the last - * window, win2. Adjust the frame widths. */ + // Remove the vertical separator from win1, add it to the last + // window, win2. Adjust the frame widths. win2->w_vsep_width = 1; win2->w_frame->fr_width += 1; win1->w_vsep_width = 0; @@ -1847,7 +1846,7 @@ win_move_after(win_T *win1, win_T *win2) win_append(win2, win1); frame_append(win2->w_frame, win1->w_frame); - (void)win_comp_pos(); /* recompute w_winrow for all windows */ + (void)win_comp_pos(); // recompute w_winrow for all windows redraw_later(NOT_VALID); } win_enter(win1, FALSE); @@ -1860,10 +1859,10 @@ win_move_after(win_T *win1, win_T *win2) */ void win_equal( - win_T *next_curwin, /* pointer to current window to be or NULL */ - int current, /* do only frame with current window */ - int dir) /* 'v' for vertically, 'h' for horizontally, - 'b' for both, 0 for using p_ead */ + win_T *next_curwin, // pointer to current window to be or NULL + int current, // do only frame with current window + int dir) // 'v' for vertically, 'h' for horizontally, + // 'b' for both, 0 for using p_ead { if (dir == 0) dir = *p_ead; @@ -1880,14 +1879,14 @@ win_equal( */ static void win_equal_rec( - win_T *next_curwin, /* pointer to current window to be or NULL */ - int current, /* do only frame with current window */ - frame_T *topfr, /* frame to set size off */ - int dir, /* 'v', 'h' or 'b', see win_equal() */ - int col, /* horizontal position for frame */ - int row, /* vertical position for frame */ - int width, /* new width of frame */ - int height) /* new height of frame */ + win_T *next_curwin, // pointer to current window to be or NULL + int current, // do only frame with current window + frame_T *topfr, // frame to set size off + int dir, // 'v', 'h' or 'b', see win_equal() + int col, // horizontal position for frame + int row, // vertical position for frame + int width, // new width of frame + int height) // new height of frame { int n, m; int extra_sep = 0; @@ -1901,8 +1900,8 @@ win_equal_rec( if (topfr->fr_layout == FR_LEAF) { - /* Set the width/height of this frame. - * Redraw when size or position changes */ + // Set the width/height of this frame. + // Redraw when size or position changes if (topfr->fr_height != height || topfr->fr_win->w_winrow != row || topfr->fr_width != width || topfr->fr_win->w_wincol != col ) @@ -1919,12 +1918,12 @@ win_equal_rec( topfr->fr_width = width; topfr->fr_height = height; - if (dir != 'v') /* equalize frame widths */ + if (dir != 'v') // equalize frame widths { - /* Compute the maximum number of windows horizontally in this - * frame. */ + // Compute the maximum number of windows horizontally in this + // frame. n = frame_minwidth(topfr, NOWIN); - /* add one for the rightmost window, it doesn't have a separator */ + // add one for the rightmost window, it doesn't have a separator if (col + width == Columns) extra_sep = 1; else @@ -1949,9 +1948,9 @@ win_equal_rec( next_curwin_size = -1; FOR_ALL_FRAMES(fr, topfr->fr_child) { - /* If 'winfixwidth' set keep the window width if - * possible. - * Watch out for this window being the next_curwin. */ + // If 'winfixwidth' set keep the window width if + // possible. + // Watch out for this window being the next_curwin. if (frame_fixed_width(fr)) { n = frame_minwidth(fr, NOWIN); @@ -1964,7 +1963,7 @@ win_equal_rec( new_size = p_wiw; } else - /* These windows don't use up room. */ + // These windows don't use up room. totwincount -= (n + (fr->fr_next == NULL ? extra_sep : 0)) / (p_wmw + 1); room -= new_size - n; @@ -1984,8 +1983,8 @@ win_equal_rec( && (room + (totwincount - 2)) / (totwincount - 1) > p_wiw) { - /* Can make all windows wider than 'winwidth', spread - * the room equally. */ + // Can make all windows wider than 'winwidth', spread + // the room equally. next_curwin_size = (room + p_wiw + (totwincount - 1) * p_wmw + (totwincount - 1)) / totwincount; @@ -1997,25 +1996,25 @@ win_equal_rec( } if (has_next_curwin) - --totwincount; /* don't count curwin */ + --totwincount; // don't count curwin } FOR_ALL_FRAMES(fr, topfr->fr_child) { wincount = 1; if (fr->fr_next == NULL) - /* last frame gets all that remains (avoid roundoff error) */ + // last frame gets all that remains (avoid roundoff error) new_size = width; else if (dir == 'v') new_size = fr->fr_width; else if (frame_fixed_width(fr)) { new_size = fr->fr_newwidth; - wincount = 0; /* doesn't count as a sizeable window */ + wincount = 0; // doesn't count as a sizeable window } else { - /* Compute the maximum number of windows horiz. in "fr". */ + // Compute the maximum number of windows horiz. in "fr". n = frame_minwidth(fr, NOWIN); wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) / (p_wmw + 1); @@ -2024,14 +2023,14 @@ win_equal_rec( hnc = frame_has_win(fr, next_curwin); else hnc = FALSE; - if (hnc) /* don't count next_curwin */ + if (hnc) // don't count next_curwin --wincount; if (totwincount == 0) new_size = room; else new_size = (wincount * room + ((unsigned)totwincount >> 1)) / totwincount; - if (hnc) /* add next_curwin size */ + if (hnc) // add next_curwin size { next_curwin_size -= p_wiw - (m - n); new_size += next_curwin_size; @@ -2042,8 +2041,8 @@ win_equal_rec( new_size += n; } - /* Skip frame that is full width when splitting or closing a - * window, unless equalizing all frames. */ + // Skip frame that is full width when splitting or closing a + // window, unless equalizing all frames. if (!current || dir != 'v' || topfr->fr_parent != NULL || (new_size != fr->fr_width) || frame_has_win(fr, next_curwin)) @@ -2054,16 +2053,16 @@ win_equal_rec( totwincount -= wincount; } } - else /* topfr->fr_layout == FR_COL */ + else // topfr->fr_layout == FR_COL { topfr->fr_width = width; topfr->fr_height = height; - if (dir != 'h') /* equalize frame heights */ + if (dir != 'h') // equalize frame heights { - /* Compute maximum number of windows vertically in this frame. */ + // Compute maximum number of windows vertically in this frame. n = frame_minheight(topfr, NOWIN); - /* add one for the bottom window if it doesn't have a statusline */ + // add one for the bottom window if it doesn't have a statusline if (row + height == cmdline_row && p_ls == 0) extra_sep = 1; else @@ -2080,8 +2079,8 @@ win_equal_rec( room = height - m; if (room < 0) { - /* The room is less then 'winheight', use all space for the - * current window. */ + // The room is less then 'winheight', use all space for the + // current window. next_curwin_size = p_wh + room; room = 0; } @@ -2090,9 +2089,9 @@ win_equal_rec( next_curwin_size = -1; FOR_ALL_FRAMES(fr, topfr->fr_child) { - /* If 'winfixheight' set keep the window height if - * possible. - * Watch out for this window being the next_curwin. */ + // If 'winfixheight' set keep the window height if + // possible. + // Watch out for this window being the next_curwin. if (frame_fixed_height(fr)) { n = frame_minheight(fr, NOWIN); @@ -2105,7 +2104,7 @@ win_equal_rec( new_size = p_wh; } else - /* These windows don't use up room. */ + // These windows don't use up room. totwincount -= (n + (fr->fr_next == NULL ? extra_sep : 0)) / (p_wmh + 1); room -= new_size - n; @@ -2125,8 +2124,8 @@ win_equal_rec( && (room + (totwincount - 2)) / (totwincount - 1) > p_wh) { - /* can make all windows higher than 'winheight', - * spread the room equally. */ + // can make all windows higher than 'winheight', + // spread the room equally. next_curwin_size = (room + p_wh + (totwincount - 1) * p_wmh + (totwincount - 1)) / totwincount; @@ -2138,25 +2137,25 @@ win_equal_rec( } if (has_next_curwin) - --totwincount; /* don't count curwin */ + --totwincount; // don't count curwin } FOR_ALL_FRAMES(fr, topfr->fr_child) { wincount = 1; if (fr->fr_next == NULL) - /* last frame gets all that remains (avoid roundoff error) */ + // last frame gets all that remains (avoid roundoff error) new_size = height; else if (dir == 'h') new_size = fr->fr_height; else if (frame_fixed_height(fr)) { new_size = fr->fr_newheight; - wincount = 0; /* doesn't count as a sizeable window */ + wincount = 0; // doesn't count as a sizeable window } else { - /* Compute the maximum number of windows vert. in "fr". */ + // Compute the maximum number of windows vert. in "fr". n = frame_minheight(fr, NOWIN); wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) / (p_wmh + 1); @@ -2165,14 +2164,14 @@ win_equal_rec( hnc = frame_has_win(fr, next_curwin); else hnc = FALSE; - if (hnc) /* don't count next_curwin */ + if (hnc) // don't count next_curwin --wincount; if (totwincount == 0) new_size = room; else new_size = (wincount * room + ((unsigned)totwincount >> 1)) / totwincount; - if (hnc) /* add next_curwin size */ + if (hnc) // add next_curwin size { next_curwin_size -= p_wh - (m - n); new_size += next_curwin_size; @@ -2182,8 +2181,8 @@ win_equal_rec( room -= new_size; new_size += n; } - /* Skip frame that is full width when splitting or closing a - * window, unless equalizing all frames. */ + // Skip frame that is full width when splitting or closing a + // window, unless equalizing all frames. if (!current || dir != 'h' || topfr->fr_parent != NULL || (new_size != fr->fr_height) || frame_has_win(fr, next_curwin)) @@ -2208,7 +2207,7 @@ leaving_window(win_T *win) // it when entering that window again. win->w_buffer->b_prompt_insert = restart_edit; if (restart_edit != 0 && mode_displayed) - clear_cmdline = TRUE; /* unshow mode later */ + clear_cmdline = TRUE; // unshow mode later restart_edit = NUL; // When leaving the window (or closing the window) was done from a @@ -2246,7 +2245,7 @@ entering_window(win_T *win) void close_windows( buf_T *buf, - int keep_curwin) /* don't close "curwin" */ + int keep_curwin) // don't close "curwin" { win_T *wp; tabpage_T *tp, *nexttp; @@ -2261,18 +2260,18 @@ close_windows( && !(wp->w_closing || wp->w_buffer->b_locked > 0)) { if (win_close(wp, FALSE) == FAIL) - /* If closing the window fails give up, to avoid looping - * forever. */ + // If closing the window fails give up, to avoid looping + // forever. break; - /* Start all over, autocommands may change the window layout. */ + // Start all over, autocommands may change the window layout. wp = firstwin; } else wp = wp->w_next; } - /* Also check windows in other tab pages. */ + // Also check windows in other tab pages. for (tp = first_tabpage; tp != NULL; tp = nexttp) { nexttp = tp->tp_next; @@ -2283,8 +2282,8 @@ close_windows( { win_close_othertab(wp, FALSE, tp); - /* Start all over, the tab page may be closed and - * autocommands may change the window layout. */ + // Start all over, the tab page may be closed and + // autocommands may change the window layout. nexttp = first_tabpage; break; } @@ -2358,8 +2357,8 @@ close_last_window_tabpage( goto_tabpage_tp(alt_tabpage(), FALSE, TRUE); redraw_tabline = TRUE; - /* Safety check: Autocommands may have closed the window when jumping - * to the other tab page. */ + // Safety check: Autocommands may have closed the window when jumping + // to the other tab page. if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win) { int h = tabline_height(); @@ -2371,8 +2370,8 @@ close_last_window_tabpage( #ifdef FEAT_JOB_CHANNEL entering_window(curwin); #endif - /* Since goto_tabpage_tp above did not trigger *Enter autocommands, do - * that now. */ + // Since goto_tabpage_tp above did not trigger *Enter autocommands, do + // that now. apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); @@ -2453,7 +2452,7 @@ win_close(win_T *win, int free_buf) if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_locked > 0)) - return FAIL; /* window is already being closed */ + return FAIL; // window is already being closed if (win_unlisted(win)) { emsg(_("E813: Cannot close autocmd or popup window")); @@ -2465,14 +2464,14 @@ win_close(win_T *win, int free_buf) return FAIL; } - /* When closing the last window in a tab page first go to another tab page - * and then close the window and the tab page to avoid that curwin and - * curtab are invalid while we are freeing memory. */ + // When closing the last window in a tab page first go to another tab page + // and then close the window and the tab page to avoid that curwin and + // curtab are invalid while we are freeing memory. if (close_last_window_tabpage(win, free_buf, prev_curtab)) return FAIL; - /* When closing the help window, try restoring a snapshot after closing - * the window. Otherwise clear the snapshot, it's now invalid. */ + // When closing the help window, try restoring a snapshot after closing + // the window. Otherwise clear the snapshot, it's now invalid. if (bt_help(win->w_buffer)) help_window = TRUE; else @@ -2512,7 +2511,7 @@ win_close(win_T *win, int free_buf) if (last_window()) return FAIL; #ifdef FEAT_EVAL - /* autocmds may abort script processing */ + // autocmds may abort script processing if (aborting()) return FAIL; #endif @@ -2535,24 +2534,24 @@ win_close(win_T *win, int free_buf) && (last_window() || curtab != prev_curtab || close_last_window_tabpage(win, free_buf, prev_curtab))) { - /* Autocommands have closed all windows, quit now. Restore - * curwin->w_buffer, otherwise writing viminfo may fail. */ + // Autocommands have closed all windows, quit now. Restore + // curwin->w_buffer, otherwise writing viminfo may fail. if (curwin->w_buffer == NULL) curwin->w_buffer = curbuf; getout(0); } - /* Autocommands may have moved to another tab page. */ + // Autocommands may have moved to another tab page. if (curtab != prev_curtab && win_valid_any_tab(win) && win->w_buffer == NULL) { - /* Need to close the window anyway, since the buffer is NULL. */ + // Need to close the window anyway, since the buffer is NULL. win_close_othertab(win, FALSE, prev_curtab); return FAIL; } - /* Autocommands may have closed the window already or closed the only - * other window. */ + // Autocommands may have closed the window already or closed the only + // other window. if (!win_valid(win) || last_window() || close_last_window_tabpage(win, free_buf, prev_curtab)) return FAIL; @@ -2561,13 +2560,13 @@ win_close(win_T *win, int free_buf) // to split a window to avoid trouble. ++split_disallowed; - /* Free the memory used for the window and get the window that received - * the screen space. */ + // Free the memory used for the window and get the window that received + // the screen space. wp = win_free_mem(win, &dir, NULL); - /* Make sure curwin isn't invalid. It can cause severe trouble when - * printing an error message. For win_equal() curbuf needs to be valid - * too. */ + // Make sure curwin isn't invalid. It can cause severe trouble when + // printing an error message. For win_equal() curbuf needs to be valid + // too. if (win == curwin) { curwin = wp; @@ -2597,13 +2596,13 @@ win_close(win_T *win, int free_buf) curbuf = curwin->w_buffer; close_curwin = TRUE; - /* The cursor position may be invalid if the buffer changed after last - * using the window. */ + // The cursor position may be invalid if the buffer changed after last + // using the window. check_cursor(); } if (p_ea && (*p_ead == 'b' || *p_ead == dir)) - /* If the frame of the closed window contains the new current window, - * only resize that frame. Otherwise resize all windows. */ + // If the frame of the closed window contains the new current window, + // only resize that frame. Otherwise resize all windows. win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir); else win_comp_pos(); @@ -2611,7 +2610,7 @@ win_close(win_T *win, int free_buf) { win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE); if (other_buffer) - /* careful: after this wp and win may be invalid! */ + // careful: after this wp and win may be invalid! apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); } @@ -2623,8 +2622,8 @@ win_close(win_T *win, int free_buf) */ last_status(FALSE); - /* After closing the help window, try restoring the window layout from - * before it was opened. */ + // After closing the help window, try restoring the window layout from + // before it was opened. if (help_window) restore_snapshot(SNAP_HELP_IDX, close_curwin); @@ -2646,7 +2645,7 @@ win_close(win_T *win, int free_buf) #endif #if defined(FEAT_GUI) - /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */ + // When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. if (gui.in_use && !win_hasvertsplit()) gui_init_which_components(NULL); #endif @@ -2670,30 +2669,30 @@ win_close_othertab(win_T *win, int free_ tabpage_T *ptp = NULL; int free_tp = FALSE; - /* Get here with win->w_buffer == NULL when win_close() detects the tab - * page changed. */ + // Get here with win->w_buffer == NULL when win_close() detects the tab + // page changed. if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_locked > 0)) - return; /* window is already being closed */ + return; // window is already being closed if (win->w_buffer != NULL) - /* Close the link to the buffer. */ + // Close the link to the buffer. close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE); - /* Careful: Autocommands may have closed the tab page or made it the - * current tab page. */ + // Careful: Autocommands may have closed the tab page or made it the + // current tab page. for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next) ; if (ptp == NULL || tp == curtab) return; - /* Autocommands may have closed the window already. */ + // Autocommands may have closed the window already. for (wp = tp->tp_firstwin; wp != NULL && wp != win; wp = wp->w_next) ; if (wp == NULL) return; - /* When closing the last window in a tab page remove the tab page. */ + // When closing the last window in a tab page remove the tab page. if (tp->tp_firstwin == tp->tp_lastwin) { if (tp == first_tabpage) @@ -2713,7 +2712,7 @@ win_close_othertab(win_T *win, int free_ free_tp = TRUE; } - /* Free the memory used for the window. */ + // Free the memory used for the window. win_free_mem(win, &dir, tp); if (free_tp) @@ -2727,20 +2726,20 @@ win_close_othertab(win_T *win, int free_ static win_T * win_free_mem( win_T *win, - int *dirp, /* set to 'v' or 'h' for direction if 'ea' */ - tabpage_T *tp) /* tab page "win" is in, NULL for current */ + int *dirp, // set to 'v' or 'h' for direction if 'ea' + tabpage_T *tp) // tab page "win" is in, NULL for current { frame_T *frp; win_T *wp; - /* Remove the window and its frame from the tree of frames. */ + // Remove the window and its frame from the tree of frames. frp = win->w_frame; wp = winframe_remove(win, dirp, tp); vim_free(frp); win_free(win, tp); - /* When deleting the current window of another tab page select a new - * current window. */ + // When deleting the current window of another tab page select a new + // current window. if (tp != NULL && win == tp->tp_curwin) tp->tp_curwin = wp; @@ -2768,8 +2767,8 @@ win_free_all(void) while (firstwin != NULL) (void)win_free_mem(firstwin, &dummy, NULL); - /* No window should be used after this. Set curwin to NULL to crash - * instead of using freed memory. */ + // No window should be used after this. Set curwin to NULL to crash + // instead of using freed memory. curwin = NULL; } #endif @@ -2781,8 +2780,8 @@ win_free_all(void) win_T * winframe_remove( win_T *win, - int *dirp UNUSED, /* set to 'v' or 'h' for direction if 'ea' */ - tabpage_T *tp) /* tab page "win" is in, NULL for current */ + int *dirp UNUSED, // set to 'v' or 'h' for direction if 'ea' + tabpage_T *tp) // tab page "win" is in, NULL for current { frame_T *frp, *frp2, *frp3; frame_T *frp_close = win->w_frame; @@ -2800,14 +2799,14 @@ winframe_remove( frp2 = win_altframe(win, tp); wp = frame2win(frp2); - /* Remove this frame from the list of frames. */ + // Remove this frame from the list of frames. frame_remove(frp_close); if (frp_close->fr_parent->fr_layout == FR_COL) { - /* When 'winfixheight' is set, try to find another frame in the column - * (as close to the closed frame as possible) to distribute the height - * to. */ + // When 'winfixheight' is set, try to find another frame in the column + // (as close to the closed frame as possible) to distribute the height + // to. if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfh) { frp = frp_close->fr_prev; @@ -2842,9 +2841,9 @@ winframe_remove( } else { - /* When 'winfixwidth' is set, try to find another frame in the column - * (as close to the closed frame as possible) to distribute the width - * to. */ + // When 'winfixwidth' is set, try to find another frame in the column + // (as close to the closed frame as possible) to distribute the width + // to. if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfw) { frp = frp_close->fr_prev; @@ -2878,8 +2877,8 @@ winframe_remove( *dirp = 'h'; } - /* If rows/columns go to a window below/right its positions need to be - * updated. Can only be done after the sizes have been updated. */ + // If rows/columns go to a window below/right its positions need to be + // updated. Can only be done after the sizes have been updated. if (frp2 == frp_close->fr_next) { int row = win->w_winrow; @@ -2890,8 +2889,8 @@ winframe_remove( if (frp2->fr_next == NULL && frp2->fr_prev == NULL) { - /* There is no other frame in this list, move its info to the parent - * and remove it. */ + // There is no other frame in this list, move its info to the parent + // and remove it. frp2->fr_parent->fr_layout = frp2->fr_layout; frp2->fr_parent->fr_child = frp2->fr_child; FOR_ALL_FRAMES(frp, frp2->fr_child) @@ -2907,8 +2906,8 @@ winframe_remove( frp2 = frp->fr_parent; if (frp2 != NULL && frp2->fr_layout == frp->fr_layout) { - /* The frame above the parent has the same layout, have to merge - * the frames into this list. */ + // The frame above the parent has the same layout, have to merge + // the frames into this list. if (frp2->fr_child == frp) frp2->fr_child = frp->fr_child; frp->fr_child->fr_prev = frp->fr_prev; @@ -2947,7 +2946,7 @@ winframe_remove( static frame_T * win_altframe( win_T *win, - tabpage_T *tp) /* tab page "win" is in, NULL for current */ + tabpage_T *tp) // tab page "win" is in, NULL for current { frame_T *frp; frame_T *other_fr, *target_fr; @@ -2970,8 +2969,8 @@ win_altframe( other_fr = frp->fr_next; } - /* If 'wfh' or 'wfw' is set for the target and not for the alternate - * window, reverse the selection. */ + // If 'wfh' or 'wfw' is set for the target and not for the alternate + // window, reverse the selection. if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW) { if (frame_fixed_width(target_fr) && !frame_fixed_width(other_fr)) @@ -2994,11 +2993,11 @@ alt_tabpage(void) { tabpage_T *tp; - /* Use the next tab page if possible. */ + // Use the next tab page if possible. if (curtab->tp_next != NULL) return curtab->tp_next; - /* Find the last but one tab page. */ + // Find the last but one tab page. for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) ; return tp; @@ -3040,9 +3039,9 @@ frame_has_win(frame_T *frp, win_T *wp) frame_new_height( frame_T *topfrp, int height, - int topfirst, /* resize topmost contained frame first */ - int wfh) /* obey 'winfixheight' when there is a choice; - may cause the height not to be set */ + int topfirst, // resize topmost contained frame first + int wfh) // obey 'winfixheight' when there is a choice; + // may cause the height not to be set { frame_T *frp; int extra_lines; @@ -3050,7 +3049,7 @@ frame_new_height( if (topfrp->fr_win != NULL) { - /* Simple case: just one window. */ + // Simple case: just one window. win_new_height(topfrp->fr_win, height - topfrp->fr_win->w_status_height - WINBAR_HEIGHT(topfrp->fr_win)); @@ -3059,13 +3058,13 @@ frame_new_height( { do { - /* All frames in this row get the same new height. */ + // All frames in this row get the same new height. FOR_ALL_FRAMES(frp, topfrp->fr_child) { frame_new_height(frp, height, topfirst, wfh); if (frp->fr_height > height) { - /* Could not fit the windows, make the whole row higher. */ + // Could not fit the windows, make the whole row higher. height = frp->fr_height; break; } @@ -3073,27 +3072,27 @@ frame_new_height( } while (frp != NULL); } - else /* fr_layout == FR_COL */ - { - /* Complicated case: Resize a column of frames. Resize the bottom - * frame first, frames above that when needed. */ + else // fr_layout == FR_COL + { + // Complicated case: Resize a column of frames. Resize the bottom + // frame first, frames above that when needed. frp = topfrp->fr_child; if (wfh) - /* Advance past frames with one window with 'wfh' set. */ + // Advance past frames with one window with 'wfh' set. while (frame_fixed_height(frp)) { frp = frp->fr_next; if (frp == NULL) - return; /* no frame without 'wfh', give up */ + return; // no frame without 'wfh', give up } if (!topfirst) { - /* Find the bottom frame of this column */ + // Find the bottom frame of this column while (frp->fr_next != NULL) frp = frp->fr_next; if (wfh) - /* Advance back for frames with one window with 'wfh' set. */ + // Advance back for frames with one window with 'wfh' set. while (frame_fixed_height(frp)) frp = frp->fr_prev; } @@ -3101,7 +3100,7 @@ frame_new_height( extra_lines = height - topfrp->fr_height; if (extra_lines < 0) { - /* reduce height of contained frames, bottom or top frame first */ + // reduce height of contained frames, bottom or top frame first while (frp != NULL) { h = frame_minheight(frp, NULL); @@ -3128,14 +3127,14 @@ frame_new_height( frp = frp->fr_prev; while (wfh && frp != NULL && frame_fixed_height(frp)); } - /* Increase "height" if we could not reduce enough frames. */ + // Increase "height" if we could not reduce enough frames. if (frp == NULL) height -= extra_lines; } } else if (extra_lines > 0) { - /* increase height of bottom or top frame */ + // increase height of bottom or top frame frame_new_height(frp, frp->fr_height + extra_lines, topfirst, wfh); } } @@ -3149,22 +3148,22 @@ frame_new_height( static int frame_fixed_height(frame_T *frp) { - /* frame with one window: fixed height if 'winfixheight' set. */ + // frame with one window: fixed height if 'winfixheight' set. if (frp->fr_win != NULL) return frp->fr_win->w_p_wfh; if (frp->fr_layout == FR_ROW) { - /* The frame is fixed height if one of the frames in the row is fixed - * height. */ + // The frame is fixed height if one of the frames in the row is fixed + // height. FOR_ALL_FRAMES(frp, frp->fr_child) if (frame_fixed_height(frp)) return TRUE; return FALSE; } - /* frp->fr_layout == FR_COL: The frame is fixed height if all of the - * frames in the row are fixed height. */ + // frp->fr_layout == FR_COL: The frame is fixed height if all of the + // frames in the row are fixed height. FOR_ALL_FRAMES(frp, frp->fr_child) if (!frame_fixed_height(frp)) return FALSE; @@ -3178,22 +3177,22 @@ frame_fixed_height(frame_T *frp) static int frame_fixed_width(frame_T *frp) { - /* frame with one window: fixed width if 'winfixwidth' set. */ + // frame with one window: fixed width if 'winfixwidth' set. if (frp->fr_win != NULL) return frp->fr_win->w_p_wfw; if (frp->fr_layout == FR_COL) { - /* The frame is fixed width if one of the frames in the row is fixed - * width. */ + // The frame is fixed width if one of the frames in the row is fixed + // width. FOR_ALL_FRAMES(frp, frp->fr_child) if (frame_fixed_width(frp)) return TRUE; return FALSE; } - /* frp->fr_layout == FR_ROW: The frame is fixed width if all of the - * frames in the row are fixed width. */ + // frp->fr_layout == FR_ROW: The frame is fixed width if all of the + // frames in the row are fixed width. FOR_ALL_FRAMES(frp, frp->fr_child) if (!frame_fixed_width(frp)) return FALSE; @@ -3214,20 +3213,20 @@ frame_add_statusline(frame_T *frp) wp = frp->fr_win; if (wp->w_status_height == 0) { - if (wp->w_height > 0) /* don't make it negative */ + if (wp->w_height > 0) // don't make it negative --wp->w_height; wp->w_status_height = STATUS_HEIGHT; } } else if (frp->fr_layout == FR_ROW) { - /* Handle all the frames in the row. */ + // Handle all the frames in the row. FOR_ALL_FRAMES(frp, frp->fr_child) frame_add_statusline(frp); } - else /* frp->fr_layout == FR_COL */ - { - /* Only need to handle the last frame in the column. */ + else // frp->fr_layout == FR_COL + { + // Only need to handle the last frame in the column. for (frp = frp->fr_child; frp->fr_next != NULL; frp = frp->fr_next) ; frame_add_statusline(frp); @@ -3242,9 +3241,9 @@ frame_add_statusline(frame_T *frp) frame_new_width( frame_T *topfrp, int width, - int leftfirst, /* resize leftmost contained frame first */ - int wfw) /* obey 'winfixwidth' when there is a choice; - may cause the width not to be set */ + int leftfirst, // resize leftmost contained frame first + int wfw) // obey 'winfixwidth' when there is a choice; + // may cause the width not to be set { frame_T *frp; int extra_cols; @@ -3253,9 +3252,9 @@ frame_new_width( if (topfrp->fr_layout == FR_LEAF) { - /* Simple case: just one window. */ + // Simple case: just one window. wp = topfrp->fr_win; - /* Find out if there are any windows right of this one. */ + // Find out if there are any windows right of this one. for (frp = topfrp; frp->fr_parent != NULL; frp = frp->fr_parent) if (frp->fr_parent->fr_layout == FR_ROW && frp->fr_next != NULL) break; @@ -3267,40 +3266,40 @@ frame_new_width( { do { - /* All frames in this column get the same new width. */ + // All frames in this column get the same new width. FOR_ALL_FRAMES(frp, topfrp->fr_child) { frame_new_width(frp, width, leftfirst, wfw); if (frp->fr_width > width) { - /* Could not fit the windows, make whole column wider. */ + // Could not fit the windows, make whole column wider. width = frp->fr_width; break; } } } while (frp != NULL); } - else /* fr_layout == FR_ROW */ - { - /* Complicated case: Resize a row of frames. Resize the rightmost - * frame first, frames left of it when needed. */ + else // fr_layout == FR_ROW + { + // Complicated case: Resize a row of frames. Resize the rightmost + // frame first, frames left of it when needed. frp = topfrp->fr_child; if (wfw) - /* Advance past frames with one window with 'wfw' set. */ + // Advance past frames with one window with 'wfw' set. while (frame_fixed_width(frp)) { frp = frp->fr_next; if (frp == NULL) - return; /* no frame without 'wfw', give up */ + return; // no frame without 'wfw', give up } if (!leftfirst) { - /* Find the rightmost frame of this row */ + // Find the rightmost frame of this row while (frp->fr_next != NULL) frp = frp->fr_next; if (wfw) - /* Advance back for frames with one window with 'wfw' set. */ + // Advance back for frames with one window with 'wfw' set. while (frame_fixed_width(frp)) frp = frp->fr_prev; } @@ -3308,7 +3307,7 @@ frame_new_width( extra_cols = width - topfrp->fr_width; if (extra_cols < 0) { - /* reduce frame width, rightmost frame first */ + // reduce frame width, rightmost frame first while (frp != NULL) { w = frame_minwidth(frp, NULL); @@ -3335,14 +3334,14 @@ frame_new_width( frp = frp->fr_prev; while (wfw && frp != NULL && frame_fixed_width(frp)); } - /* Increase "width" if we could not reduce enough frames. */ + // Increase "width" if we could not reduce enough frames. if (frp == NULL) width -= extra_cols; } } else if (extra_cols > 0) { - /* increase width of rightmost frame */ + // increase width of rightmost frame frame_new_width(frp, frp->fr_width + extra_cols, leftfirst, wfw); } } @@ -3363,20 +3362,20 @@ frame_add_vsep(frame_T *frp) wp = frp->fr_win; if (wp->w_vsep_width == 0) { - if (wp->w_width > 0) /* don't make it negative */ + if (wp->w_width > 0) // don't make it negative --wp->w_width; wp->w_vsep_width = 1; } } else if (frp->fr_layout == FR_COL) { - /* Handle all the frames in the column. */ + // Handle all the frames in the column. FOR_ALL_FRAMES(frp, frp->fr_child) frame_add_vsep(frp); } - else /* frp->fr_layout == FR_ROW */ - { - /* Only need to handle the last frame in the row. */ + else // frp->fr_layout == FR_ROW + { + // Only need to handle the last frame in the row. frp = frp->fr_child; while (frp->fr_next != NULL) frp = frp->fr_next; @@ -3422,12 +3421,12 @@ frame_minheight(frame_T *topfrp, win_T * m = p_wh + topfrp->fr_win->w_status_height; else { - /* window: minimal height of the window plus status line */ + // window: minimal height of the window plus status line m = p_wmh + topfrp->fr_win->w_status_height; if (topfrp->fr_win == curwin && next_curwin == NULL) { - /* Current window is minimal one line high and WinBar is - * visible. */ + // Current window is minimal one line high and WinBar is + // visible. if (p_wmh == 0) ++m; m += WINBAR_HEIGHT(curwin); @@ -3436,7 +3435,7 @@ frame_minheight(frame_T *topfrp, win_T * } else if (topfrp->fr_layout == FR_ROW) { - /* get the minimal height from each frame in this row */ + // get the minimal height from each frame in this row m = 0; FOR_ALL_FRAMES(frp, topfrp->fr_child) { @@ -3447,7 +3446,7 @@ frame_minheight(frame_T *topfrp, win_T * } else { - /* Add up the minimal heights for all frames in this column. */ + // Add up the minimal heights for all frames in this column. m = 0; FOR_ALL_FRAMES(frp, topfrp->fr_child) m += frame_minheight(frp, next_curwin); @@ -3465,7 +3464,7 @@ frame_minheight(frame_T *topfrp, win_T * static int frame_minwidth( frame_T *topfrp, - win_T *next_curwin) /* use p_wh and p_wiw for next_curwin */ + win_T *next_curwin) // use p_wh and p_wiw for next_curwin { frame_T *frp; int m, n; @@ -3476,16 +3475,16 @@ frame_minwidth( m = p_wiw + topfrp->fr_win->w_vsep_width; else { - /* window: minimal width of the window plus separator column */ + // window: minimal width of the window plus separator column m = p_wmw + topfrp->fr_win->w_vsep_width; - /* Current window is minimal one column wide */ + // Current window is minimal one column wide if (p_wmw == 0 && topfrp->fr_win == curwin && next_curwin == NULL) ++m; } } else if (topfrp->fr_layout == FR_COL) { - /* get the minimal width from each frame in this column */ + // get the minimal width from each frame in this column m = 0; FOR_ALL_FRAMES(frp, topfrp->fr_child) { @@ -3496,7 +3495,7 @@ frame_minwidth( } else { - /* Add up the minimal widths for all frames in this row. */ + // Add up the minimal widths for all frames in this row. m = 0; FOR_ALL_FRAMES(frp, topfrp->fr_child) m += frame_minwidth(frp, next_curwin); @@ -3516,7 +3515,7 @@ frame_minwidth( void close_others( int message, - int forceit) /* always hide all other windows */ + int forceit) // always hide all other windows { win_T *wp; win_T *nextwp; @@ -3529,16 +3528,16 @@ close_others( return; } - /* Be very careful here: autocommands may change the window layout. */ + // Be very careful here: autocommands may change the window layout. for (wp = firstwin; win_valid(wp); wp = nextwp) { nextwp = wp->w_next; - if (wp != curwin) /* don't close current window */ + if (wp != curwin) // don't close current window { - /* Check if it's allowed to abandon this window */ + // Check if it's allowed to abandon this window r = can_abandon(wp->w_buffer, forceit); - if (!win_valid(wp)) /* autocommands messed wp up */ + if (!win_valid(wp)) // autocommands messed wp up { nextwp = firstwin; continue; @@ -3549,7 +3548,7 @@ close_others( if (message && (p_confirm || cmdmod.confirm) && p_write) { dialog_changed(wp->w_buffer, FALSE); - if (!win_valid(wp)) /* autocommands messed wp up */ + if (!win_valid(wp)) // autocommands messed wp up { nextwp = firstwin; continue; @@ -3576,7 +3575,7 @@ win_init_empty(win_T *wp) wp->w_cursor.lnum = 1; wp->w_curswant = wp->w_cursor.col = 0; wp->w_cursor.coladd = 0; - wp->w_pcmark.lnum = 1; /* pcmark not cleared but set to line 1 */ + wp->w_pcmark.lnum = 1; // pcmark not cleared but set to line 1 wp->w_pcmark.col = 0; wp->w_prev_pcmark.lnum = 0; wp->w_prev_pcmark.col = 0; @@ -3670,8 +3669,8 @@ win_alloc_firstwin(win_T *oldwin) curwin = win_alloc(NULL, FALSE); if (oldwin == NULL) { - /* Very first window, need to create an empty buffer for it and - * initialize from scratch. */ + // Very first window, need to create an empty buffer for it and + // initialize from scratch. curbuf = buflist_new(NULL, NULL, 1L, BLN_LISTED); if (curwin == NULL || curbuf == NULL) return FAIL; @@ -3679,16 +3678,16 @@ win_alloc_firstwin(win_T *oldwin) #ifdef FEAT_SYN_HL curwin->w_s = &(curbuf->b_s); #endif - curbuf->b_nwindows = 1; /* there is one window */ + curbuf->b_nwindows = 1; // there is one window curwin->w_alist = &global_alist; - curwin_init(); /* init current window */ + curwin_init(); // init current window } else { - /* First window in new tab page, initialize it from "oldwin". */ + // First window in new tab page, initialize it from "oldwin". win_init(curwin, oldwin, 0); - /* We don't want cursor- and scroll-binding in the first window. */ + // We don't want cursor- and scroll-binding in the first window. RESET_BINDING(curwin); } @@ -3748,7 +3747,7 @@ alloc_tabpage(void) return NULL; # ifdef FEAT_EVAL - /* init t: variables */ + // init t: variables tp->tp_vars = dict_alloc(); if (tp->tp_vars == NULL) { @@ -3785,7 +3784,7 @@ free_tabpage(tabpage_T *tp) for (idx = 0; idx < SNAP_COUNT; ++idx) clear_snapshot(tp, idx); #ifdef FEAT_EVAL - vars_clear(&tp->tp_vars->dv_hashtab); /* free all t: variables */ + vars_clear(&tp->tp_vars->dv_hashtab); // free all t: variables hash_init(&tp->tp_vars->dv_hashtab); unref_var_dict(tp->tp_vars); #endif @@ -3821,7 +3820,7 @@ win_new_tabpage(int after) if (newtp == NULL) return FAIL; - /* Remember the current windows in this Tab page. */ + // Remember the current windows in this Tab page. if (leave_tabpage(curbuf, TRUE) == FAIL) { vim_free(newtp); @@ -3831,13 +3830,13 @@ win_new_tabpage(int after) newtp->tp_localdir = (tp->tp_localdir == NULL) ? NULL : vim_strsave(tp->tp_localdir); - /* Create a new empty window. */ + // Create a new empty window. if (win_alloc_firstwin(tp->tp_curwin) == OK) { - /* Make the new Tab page the new topframe. */ + // Make the new Tab page the new topframe. if (after == 1) { - /* New tab page becomes the first one. */ + // New tab page becomes the first one. newtp->tp_next = first_tabpage; first_tabpage = newtp; } @@ -3845,7 +3844,7 @@ win_new_tabpage(int after) { if (after > 0) { - /* Put new tab page before tab page "after". */ + // Put new tab page before tab page "after". n = 2; for (tp = first_tabpage; tp->tp_next != NULL && n < after; tp = tp->tp_next) @@ -3862,8 +3861,8 @@ win_new_tabpage(int after) last_status(FALSE); #if defined(FEAT_GUI) - /* When 'guioptions' includes 'L' or 'R' may have to remove or add - * scrollbars. Have to update them anyway. */ + // When 'guioptions' includes 'L' or 'R' may have to remove or add + // scrollbars. Have to update them anyway. gui_may_update_scrollbars(); #endif #ifdef FEAT_JOB_CHANNEL @@ -3878,7 +3877,7 @@ win_new_tabpage(int after) return OK; } - /* Failed, get back the previous Tab page */ + // Failed, get back the previous Tab page enter_tabpage(curtab, curbuf, TRUE, TRUE); return FAIL; } @@ -3895,7 +3894,7 @@ may_open_tabpage(void) if (n != 0) { - cmdmod.tab = 0; /* reset it to avoid doing it twice */ + cmdmod.tab = 0; // reset it to avoid doing it twice postponed_split_tab = 0; return win_new_tabpage(n); } @@ -3912,7 +3911,7 @@ make_tabpages(int maxcount) int count = maxcount; int todo; - /* Limit to 'tabpagemax' tabs. */ + // Limit to 'tabpagemax' tabs. if (count > p_tpm) count = p_tpm; @@ -3928,7 +3927,7 @@ make_tabpages(int maxcount) unblock_autocmds(); - /* return actual number of tab pages */ + // return actual number of tab pages return (count - todo); } @@ -3968,7 +3967,7 @@ valid_tabpage_win(tabpage_T *tpc) return FALSE; } } - /* shouldn't happen */ + // shouldn't happen return FALSE; } @@ -4039,8 +4038,8 @@ tabpage_index(tabpage_T *ftp) */ static int leave_tabpage( - buf_T *new_curbuf UNUSED, /* what is going to be the new curbuf, - NULL if unknown */ + buf_T *new_curbuf UNUSED, // what is going to be the new curbuf, + // NULL if unknown int trigger_leave_autocmds UNUSED) { tabpage_T *tp = curtab; @@ -4048,7 +4047,7 @@ leave_tabpage( #ifdef FEAT_JOB_CHANNEL leaving_window(curwin); #endif - reset_VIsual_and_resel(); /* stop Visual mode */ + reset_VIsual_and_resel(); // stop Visual mode if (trigger_leave_autocmds) { if (new_curbuf != curbuf) @@ -4065,7 +4064,7 @@ leave_tabpage( return FAIL; } #if defined(FEAT_GUI) - /* Remove the scrollbars. They may be added back later. */ + // Remove the scrollbars. They may be added back later. if (gui.in_use) gui_remove_scrollbars(); #endif @@ -4101,23 +4100,23 @@ enter_tabpage( lastwin = tp->tp_lastwin; topframe = tp->tp_topframe; - /* We would like doing the TabEnter event first, but we don't have a - * valid current window yet, which may break some commands. - * This triggers autocommands, thus may make "tp" invalid. */ + // We would like doing the TabEnter event first, but we don't have a + // valid current window yet, which may break some commands. + // This triggers autocommands, thus may make "tp" invalid. win_enter_ext(tp->tp_curwin, FALSE, TRUE, FALSE, trigger_enter_autocmds, trigger_leave_autocmds); prevwin = next_prevwin; - last_status(FALSE); /* status line may appear or disappear */ - (void)win_comp_pos(); /* recompute w_winrow for all windows */ + last_status(FALSE); // status line may appear or disappear + (void)win_comp_pos(); // recompute w_winrow for all windows #ifdef FEAT_DIFF diff_need_scrollbind = TRUE; #endif - /* The tabpage line may have appeared or disappeared, may need to resize - * the frames for that. When the Vim window was resized need to update - * frame sizes too. Use the stored value of p_ch, so that it can be - * different for each tab page. */ + // The tabpage line may have appeared or disappeared, may need to resize + // the frames for that. When the Vim window was resized need to update + // frame sizes too. Use the stored value of p_ch, so that it can be + // different for each tab page. if (p_ch != curtab->tp_ch_used) clear_cmdline = TRUE; p_ch = curtab->tp_ch_used; @@ -4128,16 +4127,16 @@ enter_tabpage( )) shell_new_rows(); if (curtab->tp_old_Columns != Columns && starting == 0) - shell_new_columns(); /* update window widths */ + shell_new_columns(); // update window widths #if defined(FEAT_GUI) - /* When 'guioptions' includes 'L' or 'R' may have to remove or add - * scrollbars. Have to update them anyway. */ + // When 'guioptions' includes 'L' or 'R' may have to remove or add + // scrollbars. Have to update them anyway. gui_may_update_scrollbars(); #endif - /* Apply autocommands after updating the display, when 'rows' and - * 'columns' have been set correctly. */ + // Apply autocommands after updating the display, when 'rows' and + // 'columns' have been set correctly. if (trigger_enter_autocmds) { apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); @@ -4161,12 +4160,12 @@ goto_tabpage(int n) if (text_locked()) { - /* Not allowed when editing the command line. */ + // Not allowed when editing the command line. text_locked_msg(); return; } - /* If there is only one it can't work. */ + // If there is only one it can't work. if (first_tabpage->tp_next == NULL) { if (n > 1) @@ -4176,7 +4175,7 @@ goto_tabpage(int n) if (n == 0) { - /* No count, go to next tab page, wrap around end. */ + // No count, go to next tab page, wrap around end. if (curtab->tp_next == NULL) tp = first_tabpage; else @@ -4184,8 +4183,8 @@ goto_tabpage(int n) } else if (n < 0) { - /* "gT": go to previous tab page, wrap around end. "N gT" repeats - * this N times. */ + // "gT": go to previous tab page, wrap around end. "N gT" repeats + // this N times. ttp = curtab; for (i = n; i < 0; ++i) { @@ -4197,13 +4196,13 @@ goto_tabpage(int n) } else if (n == 9999) { - /* Go to last tab page. */ + // Go to last tab page. for (tp = first_tabpage; tp->tp_next != NULL; tp = tp->tp_next) ; } else { - /* Go to tab page "n". */ + // Go to tab page "n". tp = find_tabpage(n); if (tp == NULL) { @@ -4232,7 +4231,7 @@ goto_tabpage_tp( int trigger_enter_autocmds, int trigger_leave_autocmds) { - /* Don't repeat a message in another tab page. */ + // Don't repeat a message in another tab page. set_keep_msg(NULL, 0); if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer, @@ -4286,7 +4285,7 @@ tabpage_move(int nr) tp_dst = tp; - /* Remove the current tab page from the list of tab pages. */ + // Remove the current tab page from the list of tab pages. if (curtab == first_tabpage) first_tabpage = curtab->tp_next; else @@ -4294,12 +4293,12 @@ tabpage_move(int nr) FOR_ALL_TABPAGES(tp) if (tp->tp_next == curtab) break; - if (tp == NULL) /* "cannot happen" */ + if (tp == NULL) // "cannot happen" return; tp->tp_next = curtab->tp_next; } - /* Re-insert it at the specified position. */ + // Re-insert it at the specified position. if (nr <= 0) { curtab->tp_next = first_tabpage; @@ -4311,7 +4310,7 @@ tabpage_move(int nr) tp_dst->tp_next = curtab; } - /* Need to redraw the tabline. Tab page contents doesn't change. */ + // Need to redraw the tabline. Tab page contents doesn't change. redraw_tabline = TRUE; } @@ -4440,7 +4439,7 @@ win_vert_neighbor(tabpage_T *tp, win_T * fr = nfr->fr_child; if (nfr->fr_layout == FR_ROW) { - /* Find the frame at the cursor row. */ + // Find the frame at the cursor row. while (fr->fr_next != NULL && frame2win(fr)->w_wincol + fr->fr_width <= wp->w_wincol + wp->w_wcol) @@ -4518,7 +4517,7 @@ win_horz_neighbor(tabpage_T *tp, win_T * fr = nfr->fr_child; if (nfr->fr_layout == FR_COL) { - /* Find the frame at the cursor row. */ + // Find the frame at the cursor row. while (fr->fr_next != NULL && frame2win(fr)->w_winrow + fr->fr_height <= wp->w_winrow + wp->w_wrow) @@ -4574,7 +4573,7 @@ win_enter_ext( { int other_buffer = FALSE; - if (wp == curwin && !curwin_invalid) /* nothing to do */ + if (wp == curwin && !curwin_invalid) // nothing to do return; #ifdef FEAT_JOB_CHANNEL @@ -4598,26 +4597,26 @@ win_enter_ext( if (!win_valid(wp)) return; #ifdef FEAT_EVAL - /* autocmds may abort script processing */ + // autocmds may abort script processing if (aborting()) return; #endif } - /* sync undo before leaving the current buffer */ + // sync undo before leaving the current buffer if (undo_sync && curbuf != wp->w_buffer) u_sync(FALSE); - /* Might need to scroll the old window before switching, e.g., when the - * cursor was moved. */ + // Might need to scroll the old window before switching, e.g., when the + // cursor was moved. update_topline(); - /* may have to copy the buffer options when 'cpo' contains 'S' */ + // may have to copy the buffer options when 'cpo' contains 'S' if (wp->w_buffer != curbuf) buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); if (!curwin_invalid) { - prevwin = curwin; /* remember for CTRL-W p */ + prevwin = curwin; // remember for CTRL-W p curwin->w_redr_status = TRUE; } curwin = wp; @@ -4625,7 +4624,7 @@ win_enter_ext( check_cursor(); if (!virtual_active()) curwin->w_cursor.coladd = 0; - changed_line_abv_curs(); /* assume cursor position needs updating */ + changed_line_abv_curs(); // assume cursor position needs updating if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL) { @@ -4651,8 +4650,8 @@ win_enter_ext( } else if (globaldir != NULL) { - /* Window doesn't have a local directory and we are not in the global - * directory: Change to the global directory. */ + // Window doesn't have a local directory and we are not in the global + // directory: Change to the global directory. vim_ignored = mch_chdir((char *)globaldir); VIM_CLEAR(globaldir); shorten_fnames(TRUE); @@ -4682,9 +4681,9 @@ win_enter_ext( #endif redraw_tabline = TRUE; if (restart_edit) - redraw_later(VALID); /* causes status line redraw */ - - /* set window height to desired minimal value */ + redraw_later(VALID); // causes status line redraw + + // set window height to desired minimal value if (curwin->w_height < p_wh && !curwin->w_p_wfh #ifdef FEAT_PROP_POPUP && !popup_is_popup(curwin) @@ -4694,13 +4693,13 @@ win_enter_ext( else if (curwin->w_height == 0) win_setheight(1); - /* set window width to desired minimal value */ + // set window width to desired minimal value if (curwin->w_width < p_wiw && !curwin->w_p_wfw) win_setwidth((int)p_wiw); setmouse(); // in case jumped to/from help buffer - /* Change directories when the 'acd' option is set. */ + // Change directories when the 'acd' option is set. DO_AUTOCHDIR; } @@ -4749,7 +4748,7 @@ buf_jump_open_tab(buf_T *buf) { goto_tabpage_win(tp, wp); if (curwin != wp) - wp = NULL; /* something went wrong */ + wp = NULL; // something went wrong break; } } @@ -4783,7 +4782,7 @@ win_alloc(win_T *after UNUSED, int hidde new_wp->w_id = ++last_win_id; #ifdef FEAT_EVAL - /* init w: variables */ + // init w: variables new_wp->w_vars = dict_alloc(); if (new_wp->w_vars == NULL) { @@ -4794,9 +4793,9 @@ win_alloc(win_T *after UNUSED, int hidde init_var_dict(new_wp->w_vars, &new_wp->w_winvar, VAR_SCOPE); #endif - /* Don't execute autocommands while the window is not properly - * initialized yet. gui_create_scrollbar() may trigger a FocusGained - * event. */ + // Don't execute autocommands while the window is not properly + // initialized yet. gui_create_scrollbar() may trigger a FocusGained + // event. block_autocmds(); /* @@ -4807,7 +4806,7 @@ win_alloc(win_T *after UNUSED, int hidde new_wp->w_wincol = 0; new_wp->w_width = Columns; - /* position the display and the cursor at the top of the file. */ + // position the display and the cursor at the top of the file. new_wp->w_topline = 1; #ifdef FEAT_DIFF new_wp->w_topfill = 0; @@ -4820,7 +4819,7 @@ win_alloc(win_T *after UNUSED, int hidde new_wp->w_p_so = -1; new_wp->w_p_siso = -1; - /* We won't calculate w_fraction until resizing the window */ + // We won't calculate w_fraction until resizing the window new_wp->w_fraction = 0; new_wp->w_prev_fraction_row = -1; @@ -4850,7 +4849,7 @@ win_alloc(win_T *after UNUSED, int hidde static void win_free( win_T *wp, - tabpage_T *tp) /* tab page "win" is in, NULL for current */ + tabpage_T *tp) // tab page "win" is in, NULL for current { int i; buf_T *buf; @@ -4860,11 +4859,11 @@ win_free( clearFolding(wp); #endif - /* reduce the reference count to the argument list. */ + // reduce the reference count to the argument list. alist_unlink(wp->w_alist); - /* Don't execute autocommands while the window is halfway being deleted. - * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */ + // Don't execute autocommands while the window is halfway being deleted. + // gui_mch_destroy_scrollbar() may trigger a FocusGained event. block_autocmds(); #ifdef FEAT_LUA @@ -4899,7 +4898,7 @@ win_free( clear_winopt(&wp->w_allbuf_opt); #ifdef FEAT_EVAL - vars_clear(&wp->w_vars->dv_hashtab); /* free all w: variables */ + vars_clear(&wp->w_vars->dv_hashtab); // free all w: variables hash_init(&wp->w_vars->dv_hashtab); unref_var_dict(wp->w_vars); #endif @@ -4922,8 +4921,8 @@ win_free( } vim_free(wp->w_localdir); - /* Remove the window from the b_wininfo lists, it may happen that the - * freed memory is re-used for another window. */ + // Remove the window from the b_wininfo lists, it may happen that the + // freed memory is re-used for another window. FOR_ALL_BUFFERS(buf) for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) if (wip->wi_win == wp) @@ -4947,7 +4946,7 @@ win_free( gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_LEFT]); gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_RIGHT]); } -#endif /* FEAT_GUI */ +#endif // FEAT_GUI #ifdef FEAT_MENU remove_winbar(wp); @@ -5020,7 +5019,7 @@ win_append(win_T *after, win_T *wp) { win_T *before; - if (after == NULL) /* after NULL is in front of the first */ + if (after == NULL) // after NULL is in front of the first before = firstwin; else before = after->w_next; @@ -5043,7 +5042,7 @@ win_append(win_T *after, win_T *wp) void win_remove( win_T *wp, - tabpage_T *tp) /* tab page "win" is in, NULL for current */ + tabpage_T *tp) // tab page "win" is in, NULL for current { if (wp->w_prev != NULL) wp->w_prev->w_next = wp->w_next; @@ -5099,7 +5098,7 @@ frame_remove(frame_T *frp) else { frp->fr_parent->fr_child = frp->fr_next; - /* special case: topframe->fr_child == frp */ + // special case: topframe->fr_child == frp if (topframe->fr_child == frp) topframe->fr_child = frp->fr_next; } @@ -5127,7 +5126,7 @@ win_alloc_lines(win_T *wp) void win_free_lsize(win_T *wp) { - /* TODO: why would wp be NULL here? */ + // TODO: why would wp be NULL here? if (wp != NULL) VIM_CLEAR(wp->w_lines); } @@ -5141,23 +5140,23 @@ shell_new_rows(void) { int h = (int)ROWS_AVAIL; - if (firstwin == NULL) /* not initialized yet */ + if (firstwin == NULL) // not initialized yet return; if (h < frame_minheight(topframe, NULL)) h = frame_minheight(topframe, NULL); - /* First try setting the heights of windows with 'winfixheight'. If - * that doesn't result in the right height, forget about that option. */ + // First try setting the heights of windows with 'winfixheight'. If + // that doesn't result in the right height, forget about that option. frame_new_height(topframe, h, FALSE, TRUE); if (!frame_check_height(topframe, h)) frame_new_height(topframe, h, FALSE, FALSE); - (void)win_comp_pos(); /* recompute w_winrow and w_wincol */ + (void)win_comp_pos(); // recompute w_winrow and w_wincol compute_cmdrow(); curtab->tp_ch_used = p_ch; #if 0 - /* Disabled: don't want making the screen smaller make a window larger. */ + // Disabled: don't want making the screen smaller make a window larger. if (p_ea) win_equal(curwin, FALSE, 'v'); #endif @@ -5169,18 +5168,18 @@ shell_new_rows(void) void shell_new_columns(void) { - if (firstwin == NULL) /* not initialized yet */ + if (firstwin == NULL) // not initialized yet return; - /* First try setting the widths of windows with 'winfixwidth'. If that - * doesn't result in the right width, forget about that option. */ + // First try setting the widths of windows with 'winfixwidth'. If that + // doesn't result in the right width, forget about that option. frame_new_width(topframe, (int)Columns, FALSE, TRUE); if (!frame_check_width(topframe, Columns)) frame_new_width(topframe, (int)Columns, FALSE, FALSE); - (void)win_comp_pos(); /* recompute w_winrow and w_wincol */ + (void)win_comp_pos(); // recompute w_winrow and w_wincol #if 0 - /* Disabled: don't want making the screen smaller make a window larger. */ + // Disabled: don't want making the screen smaller make a window larger. if (p_ea) win_equal(curwin, FALSE, 'h'); #endif @@ -5225,8 +5224,8 @@ win_size_restore(garray_T *gap) if (win_count() * 2 + 1 == gap->ga_len && ((int *)gap->ga_data)[0] == Rows) { - /* The order matters, because frames contain other frames, but it's - * difficult to get right. The easy way out is to do it twice. */ + // The order matters, because frames contain other frames, but it's + // difficult to get right. The easy way out is to do it twice. for (j = 0; j < 2; ++j) { i = 1; @@ -5236,11 +5235,11 @@ win_size_restore(garray_T *gap) win_setheight_win(((int *)gap->ga_data)[i++], wp); } } - /* recompute the window positions */ + // recompute the window positions (void)win_comp_pos(); } } -#endif /* FEAT_CMDWIN */ +#endif // FEAT_CMDWIN /* * Update the position for all windows, using the width and height of the @@ -5277,13 +5276,13 @@ frame_comp_pos(frame_T *topfrp, int *row { if (wp->w_winrow != *row || wp->w_wincol != *col) { - /* position changed, redraw */ + // position changed, redraw wp->w_winrow = *row; wp->w_wincol = *col; redraw_win_later(wp, NOT_VALID); wp->w_redr_status = TRUE; } - /* WinBar will not show if the window height is zero */ + // WinBar will not show if the window height is zero h = VISIBLE_HEIGHT(wp) + wp->w_status_height; *row += h > topfrp->fr_height ? topfrp->fr_height : h; *col += wp->w_width + wp->w_vsep_width; @@ -5295,9 +5294,9 @@ frame_comp_pos(frame_T *topfrp, int *row FOR_ALL_FRAMES(frp, topfrp->fr_child) { if (topfrp->fr_layout == FR_ROW) - *row = startrow; /* all frames are at the same row */ + *row = startrow; // all frames are at the same row else - *col = startcol; /* all frames are at the same col */ + *col = startcol; // all frames are at the same col frame_comp_pos(frp, row, col); } } @@ -5324,8 +5323,8 @@ win_setheight_win(int height, win_T *win if (win == curwin) { - /* Always keep current window at least one line high, even when - * 'winminheight' is zero. */ + // Always keep current window at least one line high, even when + // 'winminheight' is zero. if (height < p_wmh) height = p_wmh; if (height == 0) @@ -5335,7 +5334,7 @@ win_setheight_win(int height, win_T *win frame_setheight(win->w_frame, height + win->w_status_height); - /* recompute the window positions */ + // recompute the window positions row = win_comp_pos(); /* @@ -5367,21 +5366,21 @@ win_setheight_win(int height, win_T *win static void frame_setheight(frame_T *curfrp, int height) { - int room; /* total number of lines available */ - int take; /* number of lines taken from other windows */ - int room_cmdline; /* lines available from cmdline */ + int room; // total number of lines available + int take; // number of lines taken from other windows + int room_cmdline; // lines available from cmdline int run; frame_T *frp; int h; int room_reserved; - /* If the height already is the desired value, nothing to do. */ + // If the height already is the desired value, nothing to do. if (curfrp->fr_height == height) return; if (curfrp->fr_parent == NULL) { - /* topframe: can only change the command line */ + // topframe: can only change the command line if (height > ROWS_AVAIL) height = ROWS_AVAIL; if (height > 0) @@ -5389,8 +5388,8 @@ frame_setheight(frame_T *curfrp, int hei } else if (curfrp->fr_parent->fr_layout == FR_ROW) { - /* Row of frames: Also need to resize frames left and right of this - * one. First check for the minimal height of these. */ + // Row of frames: Also need to resize frames left and right of this + // one. First check for the minimal height of these. h = frame_minheight(curfrp->fr_parent, NULL); if (height < h) height = h; @@ -5451,18 +5450,18 @@ frame_setheight(frame_T *curfrp, int hei */ take = height - curfrp->fr_height; - /* If there is not enough room, also reduce the height of a window - * with 'winfixheight' set. */ + // If there is not enough room, also reduce the height of a window + // with 'winfixheight' set. if (height > room + room_cmdline - room_reserved) room_reserved = room + room_cmdline - height; - /* If there is only a 'winfixheight' window and making the - * window smaller, need to make the other window taller. */ + // If there is only a 'winfixheight' window and making the + // window smaller, need to make the other window taller. if (take < 0 && room - curfrp->fr_height < room_reserved) room_reserved = 0; if (take > 0 && room_cmdline > 0) { - /* use lines from cmdline first */ + // use lines from cmdline first if (take < room_cmdline) room_cmdline = take; take -= room_cmdline; @@ -5482,9 +5481,9 @@ frame_setheight(frame_T *curfrp, int hei for (run = 0; run < 2; ++run) { if (run == 0) - frp = curfrp->fr_next; /* 1st run: start with next window */ + frp = curfrp->fr_next; // 1st run: start with next window else - frp = curfrp->fr_prev; /* 2nd run: start with prev window */ + frp = curfrp->fr_prev; // 2nd run: start with prev window while (frp != NULL && take != 0) { h = frame_minheight(frp, NULL); @@ -5539,8 +5538,8 @@ win_setwidth(int width) void win_setwidth_win(int width, win_T *wp) { - /* Always keep current window at least one column wide, even when - * 'winminwidth' is zero. */ + // Always keep current window at least one column wide, even when + // 'winminwidth' is zero. if (wp == curwin) { if (width < p_wmw) @@ -5551,7 +5550,7 @@ win_setwidth_win(int width, win_T *wp) frame_setwidth(wp->w_frame, width + wp->w_vsep_width); - /* recompute the window positions */ + // recompute the window positions (void)win_comp_pos(); redraw_all_later(NOT_VALID); @@ -5567,25 +5566,25 @@ win_setwidth_win(int width, win_T *wp) static void frame_setwidth(frame_T *curfrp, int width) { - int room; /* total number of lines available */ - int take; /* number of lines taken from other windows */ + int room; // total number of lines available + int take; // number of lines taken from other windows int run; frame_T *frp; int w; int room_reserved; - /* If the width already is the desired value, nothing to do. */ + // If the width already is the desired value, nothing to do. if (curfrp->fr_width == width) return; if (curfrp->fr_parent == NULL) - /* topframe: can't change width */ + // topframe: can't change width return; if (curfrp->fr_parent->fr_layout == FR_COL) { - /* Column of frames: Also need to resize frames above and below of - * this one. First check for the minimal width of these. */ + // Column of frames: Also need to resize frames above and below of + // this one. First check for the minimal width of these. w = frame_minwidth(curfrp->fr_parent, NULL); if (width < w) width = w; @@ -5634,12 +5633,12 @@ frame_setwidth(frame_T *curfrp, int widt */ take = width - curfrp->fr_width; - /* If there is not enough room, also reduce the width of a window - * with 'winfixwidth' set. */ + // If there is not enough room, also reduce the width of a window + // with 'winfixwidth' set. if (width > room - room_reserved) room_reserved = room - width; - /* If there is only a 'winfixwidth' window and making the - * window smaller, need to make the other window narrower. */ + // If there is only a 'winfixwidth' window and making the + // window smaller, need to make the other window narrower. if (take < 0 && room - curfrp->fr_width < room_reserved) room_reserved = 0; @@ -5656,9 +5655,9 @@ frame_setwidth(frame_T *curfrp, int widt for (run = 0; run < 2; ++run) { if (run == 0) - frp = curfrp->fr_next; /* 1st run: start with next window */ + frp = curfrp->fr_next; // 1st run: start with next window else - frp = curfrp->fr_prev; /* 2nd run: start with prev window */ + frp = curfrp->fr_prev; // 2nd run: start with prev window while (frp != NULL && take != 0) { w = frame_minwidth(frp, NULL); @@ -5762,26 +5761,26 @@ win_drag_status_line(win_T *dragwin, int frame_T *fr; int room; int row; - int up; /* if TRUE, drag status line up, otherwise down */ + int up; // if TRUE, drag status line up, otherwise down int n; fr = dragwin->w_frame; curfr = fr; - if (fr != topframe) /* more than one window */ + if (fr != topframe) // more than one window { fr = fr->fr_parent; - /* When the parent frame is not a column of frames, its parent should - * be. */ + // When the parent frame is not a column of frames, its parent should + // be. if (fr->fr_layout != FR_COL) { curfr = fr; - if (fr != topframe) /* only a row of windows, may drag statusline */ + if (fr != topframe) // only a row of windows, may drag statusline fr = fr->fr_parent; } } - /* If this is the last frame in a column, may want to resize the parent - * frame instead (go two up to skip a row of frames). */ + // If this is the last frame in a column, may want to resize the parent + // frame instead (go two up to skip a row of frames). while (curfr != topframe && curfr->fr_next == NULL) { if (fr != topframe) @@ -5791,14 +5790,14 @@ win_drag_status_line(win_T *dragwin, int fr = fr->fr_parent; } - if (offset < 0) /* drag up */ + if (offset < 0) // drag up { up = TRUE; offset = -offset; - /* sum up the room of the current frame and above it */ + // sum up the room of the current frame and above it if (fr == curfr) { - /* only one window */ + // only one window room = fr->fr_height - frame_minheight(fr, NULL); } else @@ -5811,9 +5810,9 @@ win_drag_status_line(win_T *dragwin, int break; } } - fr = curfr->fr_next; /* put fr at frame that grows */ - } - else /* drag down */ + fr = curfr->fr_next; // put fr at frame that grows + } + else // drag down { up = FALSE; /* @@ -5826,14 +5825,14 @@ win_drag_status_line(win_T *dragwin, int room -= p_ch; if (room < 0) room = 0; - /* sum up the room of frames below of the current one */ + // sum up the room of frames below of the current one FOR_ALL_FRAMES(fr, curfr->fr_next) room += fr->fr_height - frame_minheight(fr, NULL); - fr = curfr; /* put fr at window that grows */ - } - - if (room < offset) /* Not enough room */ - offset = room; /* Move as far as we can */ + fr = curfr; // put fr at window that grows + } + + if (room < offset) // Not enough room + offset = room; // Move as far as we can if (offset <= 0) return; @@ -5845,9 +5844,9 @@ win_drag_status_line(win_T *dragwin, int frame_new_height(fr, fr->fr_height + offset, up, FALSE); if (up) - fr = curfr; /* current frame gets smaller */ + fr = curfr; // current frame gets smaller else - fr = curfr->fr_next; /* next frame gets smaller */ + fr = curfr->fr_next; // next frame gets smaller /* * Now make the other frames smaller. @@ -5890,25 +5889,25 @@ win_drag_vsep_line(win_T *dragwin, int o frame_T *curfr; frame_T *fr; int room; - int left; /* if TRUE, drag separator line left, otherwise right */ + int left; // if TRUE, drag separator line left, otherwise right int n; fr = dragwin->w_frame; - if (fr == topframe) /* only one window (cannot happen?) */ + if (fr == topframe) // only one window (cannot happen?) return; curfr = fr; fr = fr->fr_parent; - /* When the parent frame is not a row of frames, its parent should be. */ + // When the parent frame is not a row of frames, its parent should be. if (fr->fr_layout != FR_ROW) { - if (fr == topframe) /* only a column of windows (cannot happen?) */ + if (fr == topframe) // only a column of windows (cannot happen?) return; curfr = fr; fr = fr->fr_parent; } - /* If this is the last frame in a row, may want to resize a parent - * frame instead. */ + // If this is the last frame in a row, may want to resize a parent + // frame instead. while (curfr->fr_next == NULL) { if (fr == topframe) @@ -5922,11 +5921,11 @@ win_drag_vsep_line(win_T *dragwin, int o } } - if (offset < 0) /* drag left */ + if (offset < 0) // drag left { left = TRUE; offset = -offset; - /* sum up the room of the current frame and left of it */ + // sum up the room of the current frame and left of it room = 0; for (fr = fr->fr_child; ; fr = fr->fr_next) { @@ -5934,33 +5933,33 @@ win_drag_vsep_line(win_T *dragwin, int o if (fr == curfr) break; } - fr = curfr->fr_next; /* put fr at frame that grows */ - } - else /* drag right */ + fr = curfr->fr_next; // put fr at frame that grows + } + else // drag right { left = FALSE; - /* sum up the room of frames right of the current one */ + // sum up the room of frames right of the current one room = 0; FOR_ALL_FRAMES(fr, curfr->fr_next) room += fr->fr_width - frame_minwidth(fr, NULL); - fr = curfr; /* put fr at window that grows */ - } - - if (room < offset) /* Not enough room */ - offset = room; /* Move as far as we can */ - if (offset <= 0) /* No room at all, quit. */ + fr = curfr; // put fr at window that grows + } + + if (room < offset) // Not enough room + offset = room; // Move as far as we can + if (offset <= 0) // No room at all, quit. return; if (fr == NULL) - return; /* Safety check, should not happen. */ - - /* grow frame fr by offset lines */ + return; // Safety check, should not happen. + + // grow frame fr by offset lines frame_new_width(fr, fr->fr_width + offset, left, FALSE); - /* shrink other frames: current and at the left or at the right */ + // shrink other frames: current and at the left or at the right if (left) - fr = curfr; /* current frame gets smaller */ + fr = curfr; // current frame gets smaller else - fr = curfr->fr_next; /* next frame gets smaller */ + fr = curfr->fr_next; // next frame gets smaller while (fr != NULL && offset > 0) { @@ -6012,22 +6011,22 @@ win_new_height(win_T *wp, int height) { int prev_height = wp->w_height; - /* Don't want a negative height. Happens when splitting a tiny window. - * Will equalize heights soon to fix it. */ + // Don't want a negative height. Happens when splitting a tiny window. + // Will equalize heights soon to fix it. if (height < 0) height = 0; if (wp->w_height == height) - return; /* nothing to do */ + return; // nothing to do if (wp->w_height > 0) { if (wp == curwin) - /* w_wrow needs to be valid. When setting 'laststatus' this may - * call win_new_height() recursively. */ + // w_wrow needs to be valid. When setting 'laststatus' this may + // call win_new_height() recursively. validate_cursor(); if (wp->w_height != prev_height) - return; /* Recursive call already changed the size, bail out here - to avoid the following to mess things up. */ + return; // Recursive call already changed the size, bail out here + // to avoid the following to mess things up. if (wp->w_wrow != wp->w_prev_fraction_row) set_fraction(wp); } @@ -6035,8 +6034,8 @@ win_new_height(win_T *wp, int height) wp->w_height = height; wp->w_skipcol = 0; - /* There is no point in adjusting the scroll position when exiting. Some - * values might be invalid. */ + // There is no point in adjusting the scroll position when exiting. Some + // values might be invalid. if (!exiting) scroll_to_fraction(wp, prev_height); } @@ -6062,7 +6061,7 @@ scroll_to_fraction(win_T *wp, int prev_h * relative position in the window as before (more or less). */ lnum = wp->w_cursor.lnum; - if (lnum < 1) /* can happen when starting up */ + if (lnum < 1) // can happen when starting up lnum = 1; wp->w_wrow = ((long)wp->w_fraction * (long)height - 1L) / FRACTION_MULT; @@ -6071,7 +6070,7 @@ scroll_to_fraction(win_T *wp, int prev_h if (sline >= 0) { - /* Make sure the whole cursor line is visible, if possible. */ + // Make sure the whole cursor line is visible, if possible. int rows = plines_win(wp, lnum, FALSE); if (sline > wp->w_height - rows) @@ -6110,7 +6109,7 @@ scroll_to_fraction(win_T *wp, int prev_h hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); if (lnum == 1) { - /* first line in buffer is folded */ + // first line in buffer is folded line_size = 1; --sline; break; @@ -6153,7 +6152,7 @@ scroll_to_fraction(win_T *wp, int prev_h { if (get_scrolloff_value()) update_topline(); - curs_columns(FALSE); /* validate w_wrow */ + curs_columns(FALSE); // validate w_wrow } if (prev_height > 0) wp->w_prev_fraction_row = wp->w_wrow; @@ -6177,7 +6176,7 @@ win_new_width(win_T *wp, int width) if (wp == curwin) { update_topline(); - curs_columns(TRUE); /* validate w_wrow */ + curs_columns(TRUE); // validate w_wrow } redraw_win_later(wp, NOT_VALID); wp->w_redr_status = TRUE; @@ -6201,17 +6200,17 @@ command_height(void) frame_T *frp; int old_p_ch = curtab->tp_ch_used; - /* Use the value of p_ch that we remembered. This is needed for when the - * GUI starts up, we can't be sure in what order things happen. And when - * p_ch was changed in another tab page. */ + // Use the value of p_ch that we remembered. This is needed for when the + // GUI starts up, we can't be sure in what order things happen. And when + // p_ch was changed in another tab page. curtab->tp_ch_used = p_ch; - /* Find bottom frame with width of screen. */ + // Find bottom frame with width of screen. frp = lastwin->w_frame; while (frp->fr_width != Columns && frp->fr_parent != NULL) frp = frp->fr_parent; - /* Avoid changing the height of a window with 'winfixheight' set. */ + // Avoid changing the height of a window with 'winfixheight' set. while (frp->fr_prev != NULL && frp->fr_layout == FR_LEAF && frp->fr_win->w_p_wfh) frp = frp->fr_prev; @@ -6220,7 +6219,7 @@ command_height(void) { cmdline_row = Rows - p_ch; - if (p_ch > old_p_ch) /* p_ch got bigger */ + if (p_ch > old_p_ch) // p_ch got bigger { while (p_ch > old_p_ch) { @@ -6240,10 +6239,10 @@ command_height(void) frp = frp->fr_prev; } - /* Recompute window positions. */ + // Recompute window positions. (void)win_comp_pos(); - /* clear the lines added to cmdline */ + // clear the lines added to cmdline if (full_screen) screen_fill((int)(cmdline_row), (int)Rows, 0, (int)Columns, ' ', ' ', 0); @@ -6258,7 +6257,7 @@ command_height(void) } frame_add_height(frp, (int)(old_p_ch - p_ch)); - /* Recompute window positions. */ + // Recompute window positions. if (frp != lastwin->w_frame) (void)win_comp_pos(); } @@ -6286,9 +6285,9 @@ frame_add_height(frame_T *frp, int n) */ void last_status( - int morewin) /* pretend there are two or more windows */ + int morewin) // pretend there are two or more windows { - /* Don't make a difference between horizontal or vertical split. */ + // Don't make a difference between horizontal or vertical split. last_status_rec(topframe, (p_ls == 2 || (p_ls == 1 && (morewin || !ONE_WINDOW)))); } @@ -6304,14 +6303,14 @@ last_status_rec(frame_T *fr, int statusl wp = fr->fr_win; if (wp->w_status_height != 0 && !statusline) { - /* remove status line */ + // remove status line win_new_height(wp, wp->w_height + 1); wp->w_status_height = 0; comp_col(); } else if (wp->w_status_height == 0 && statusline) { - /* Find a frame to take a line from. */ + // Find a frame to take a line from. fp = fr; while (fp->fr_height <= frame_minheight(fp, NULL)) { @@ -6320,8 +6319,8 @@ last_status_rec(frame_T *fr, int statusl emsg(_(e_noroom)); return; } - /* In a column of frames: go to frame above. If already at - * the top or in a row of frames: go to parent. */ + // In a column of frames: go to frame above. If already at + // the top or in a row of frames: go to parent. if (fp->fr_parent->fr_layout == FR_COL && fp->fr_prev != NULL) fp = fp->fr_prev; else @@ -6342,13 +6341,13 @@ last_status_rec(frame_T *fr, int statusl } else if (fr->fr_layout == FR_ROW) { - /* vertically split windows, set status line for each one */ + // vertically split windows, set status line for each one FOR_ALL_FRAMES(fp, fr->fr_child) last_status_rec(fp, statusline); } else { - /* horizontally split window, set status line for last one */ + // horizontally split window, set status line for last one for (fp = fr->fr_child; fp->fr_next != NULL; fp = fp->fr_next) ; last_status_rec(fp, statusline); @@ -6362,7 +6361,7 @@ last_status_rec(frame_T *fr, int statusl tabline_height(void) { #ifdef FEAT_GUI_TABLINE - /* When the GUI has the tabline then this always returns zero. */ + // When the GUI has the tabline then this always returns zero. if (gui_use_tabline()) return 0; #endif @@ -6385,7 +6384,7 @@ min_rows(void) tabpage_T *tp; int n; - if (firstwin == NULL) /* not initialized yet */ + if (firstwin == NULL) // not initialized yet return MIN_LINES; total = 0; @@ -6396,7 +6395,7 @@ min_rows(void) total = n; } total += tabline_height(); - total += 1; /* count the room for the command line */ + total += 1; // count the room for the command line return total; } @@ -6411,7 +6410,7 @@ only_one_window(void) int count = 0; win_T *wp; - /* If there is another tab page there always is another window. */ + // If there is another tab page there always is another window. if (first_tabpage->tp_next != NULL) return FALSE; @@ -6544,7 +6543,7 @@ clear_snapshot_rec(frame_T *fr) void restore_snapshot( int idx, - int close_curwin) /* closing current window */ + int close_curwin) // closing current window { win_T *wp;
--- a/src/xpm_w32.c +++ b/src/xpm_w32.c @@ -16,7 +16,7 @@ #include "xpm_w32.h" -/* Engage Windows support in libXpm */ +// Engage Windows support in libXpm #define FOR_MSW #include "xpm.h" @@ -33,8 +33,8 @@ LoadXpmImage( HBITMAP *hImage, HBITMAP *hShape) { - XImage *img; /* loaded image */ - XImage *shp; /* shapeimage */ + XImage *img; // loaded image + XImage *shp; // shapeimage XpmAttributes attr; int res; HDC hdc = CreateCompatibleDC(NULL);