diff options
author | Petter Wahlman <pwahlman@cisco.com> | 2014-03-16 08:20:00 +0100 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-03-19 07:53:16 -0300 |
commit | edabc6f4c7277262568801ff870808170ac32327 (patch) | |
tree | 9e34374d5d6a2816a0bc432bab84e540be9d3f18 | |
parent | 59f2430a8d543fc57a31d489a649ec87a6ca9715 (diff) | |
download | rneovim-edabc6f4c7277262568801ff870808170ac32327.tar.gz rneovim-edabc6f4c7277262568801ff870808170ac32327.tar.bz2 rneovim-edabc6f4c7277262568801ff870808170ac32327.zip |
adapt to the style guildelines
semi-automated harvest of low hanging fruit:
change the unorthodox use of whitespace.
-rw-r--r-- | src/buffer.c | 88 | ||||
-rw-r--r-- | src/charset.c | 2 | ||||
-rw-r--r-- | src/cursor_shape.c | 6 | ||||
-rw-r--r-- | src/diff.c | 5 | ||||
-rw-r--r-- | src/edit.c | 276 | ||||
-rw-r--r-- | src/eval.c | 338 | ||||
-rw-r--r-- | src/ex_cmds.c | 103 | ||||
-rw-r--r-- | src/ex_cmds2.c | 108 | ||||
-rw-r--r-- | src/ex_docmd.c | 177 | ||||
-rw-r--r-- | src/ex_eval.c | 47 | ||||
-rw-r--r-- | src/ex_getln.c | 151 | ||||
-rw-r--r-- | src/farsi.c | 2 | ||||
-rw-r--r-- | src/file_search.c | 23 | ||||
-rw-r--r-- | src/fileio.c | 190 | ||||
-rw-r--r-- | src/fold.c | 70 | ||||
-rw-r--r-- | src/getchar.c | 159 | ||||
-rw-r--r-- | src/hardcopy.c | 66 | ||||
-rw-r--r-- | src/if_cscope.c | 39 | ||||
-rw-r--r-- | src/indent.c | 17 | ||||
-rw-r--r-- | src/indent_c.c | 84 | ||||
-rw-r--r-- | src/keymap.c | 4 | ||||
-rw-r--r-- | src/main.c | 39 | ||||
-rw-r--r-- | src/mark.c | 30 | ||||
-rw-r--r-- | src/mbyte.c | 59 | ||||
-rw-r--r-- | src/memfile.c | 26 | ||||
-rw-r--r-- | src/memline.c | 98 | ||||
-rw-r--r-- | src/menu.c | 34 | ||||
-rw-r--r-- | src/message.c | 217 | ||||
-rw-r--r-- | src/misc1.c | 98 | ||||
-rw-r--r-- | src/misc2.c | 56 | ||||
-rw-r--r-- | src/move.c | 116 | ||||
-rw-r--r-- | src/normal.c | 177 | ||||
-rw-r--r-- | src/ops.c | 141 | ||||
-rw-r--r-- | src/option.c | 224 | ||||
-rw-r--r-- | src/os_unix.c | 103 | ||||
-rw-r--r-- | src/popupmnu.c | 6 | ||||
-rw-r--r-- | src/quickfix.c | 56 | ||||
-rw-r--r-- | src/regexp.c | 193 | ||||
-rw-r--r-- | src/regexp_nfa.c | 122 | ||||
-rw-r--r-- | src/screen.c | 264 | ||||
-rw-r--r-- | src/search.c | 167 | ||||
-rw-r--r-- | src/spell.c | 217 | ||||
-rw-r--r-- | src/syntax.c | 157 | ||||
-rw-r--r-- | src/tag.c | 56 | ||||
-rw-r--r-- | src/term.c | 100 | ||||
-rw-r--r-- | src/ui.c | 47 | ||||
-rw-r--r-- | src/undo.c | 49 | ||||
-rw-r--r-- | src/window.c | 192 |
48 files changed, 2782 insertions, 2217 deletions
diff --git a/src/buffer.c b/src/buffer.c index c8d071ccd8..f175276a72 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -158,7 +158,7 @@ open_buffer ( /* Help buffer is filtered. */ if (curbuf->b_help) fix_help_buffer(); - } else if (read_stdin) { + } else if (read_stdin) { int save_bin = curbuf->b_p_bin; linenr_T line_count; @@ -182,7 +182,7 @@ open_buffer ( /* Delete the binary lines. */ while (--line_count >= 0) ml_delete((linenr_T)1, FALSE); - } else { + } else { /* Delete the converted lines. */ while (curbuf->b_ml.ml_line_count > line_count) ml_delete(line_count, FALSE); @@ -316,7 +316,7 @@ close_buffer ( if (buf->b_p_bh[0] == 'd') { /* 'bufhidden' == "delete" */ del_buf = TRUE; unload_buf = TRUE; - } else if (buf->b_p_bh[0] == 'w') { /* 'bufhidden' == "wipe" */ + } else if (buf->b_p_bh[0] == 'w') { /* 'bufhidden' == "wipe" */ del_buf = TRUE; unload_buf = TRUE; wipe_buf = TRUE; @@ -437,7 +437,7 @@ aucmd_abort: else buf->b_next->b_prev = buf->b_prev; free_buffer(buf); - } else { + } else { if (del_buf) { /* Free all internal variables and reset option values, to make * ":bdel" compatible with Vim 5.7. */ @@ -655,7 +655,7 @@ void handle_swap_exists(buf_T *old_curbuf) /* Restore the error/interrupt/exception state if not discarded by a * new aborting error, interrupt, or uncaught exception. */ leave_cleanup(&cs); - } else if (swap_exists_action == SEA_RECOVER) { + } else if (swap_exists_action == SEA_RECOVER) { /* Reset the error/interrupt/exception state here so that * aborting() returns FALSE when closing a buffer. */ enter_cleanup(&cs); @@ -706,7 +706,7 @@ do_bufdel ( if (addr_count == 0) { (void)do_buffer(command, DOBUF_CURRENT, FORWARD, 0, forceit); - } else { + } else { if (addr_count == 2) { if (*arg) /* both range and argument is not allowed */ return (char_u *)_(e_trailing); @@ -733,7 +733,7 @@ do_bufdel ( if (addr_count == 2) { if (++bnr > end_bnr) break; - } else { /* addr_count == 1 */ + } else { /* addr_count == 1 */ arg = skipwhite(arg); if (*arg == NUL) break; @@ -760,18 +760,18 @@ do_bufdel ( else STRCPY(IObuff, _("E517: No buffers were wiped out")); errormsg = IObuff; - } else if (deleted >= p_report) { + } else if (deleted >= p_report) { if (command == DOBUF_UNLOAD) { if (deleted == 1) MSG(_("1 buffer unloaded")); else smsg((char_u *)_("%d buffers unloaded"), deleted); - } else if (command == DOBUF_DEL) { + } else if (command == DOBUF_DEL) { if (deleted == 1) MSG(_("1 buffer deleted")); else smsg((char_u *)_("%d buffers deleted"), deleted); - } else { + } else { if (deleted == 1) MSG(_("1 buffer wiped out")); else @@ -870,10 +870,10 @@ do_buffer ( EMSG(_("E84: No modified buffer found")); return FAIL; } - } else if (start == DOBUF_FIRST && count) { /* find specified buffer number */ + } else if (start == DOBUF_FIRST && count) { /* find specified buffer number */ while (buf != NULL && buf->b_fnum != count) buf = buf->b_next; - } else { + } else { bp = NULL; while (count > 0 || (!unload && !buf->b_p_bl && bp != buf)) { /* remember the buffer where we start, we come back there when all @@ -884,7 +884,7 @@ do_buffer ( buf = buf->b_next; if (buf == NULL) buf = firstbuf; - } else { + } else { buf = buf->b_prev; if (buf == NULL) buf = lastbuf; @@ -937,7 +937,7 @@ do_buffer ( * mentioned why it fails. */ if (bufIsChanged(buf)) return FAIL; - } else { + } else { EMSGN(_( "E89: No write since last change for buffer %ld (add ! to override)"), buf->b_fnum); @@ -991,7 +991,7 @@ do_buffer ( bp = NULL; /* used when no loaded buffer found */ if (au_new_curbuf != NULL && buf_valid(au_new_curbuf)) buf = au_new_curbuf; - else if (curwin->w_jumplistlen > 0) { + else if (curwin->w_jumplistlen > 0) { int jumpidx; jumpidx = curwin->w_jumplistidx - 1; @@ -1226,7 +1226,7 @@ void enter_buffer(buf_T *buf) did_filetype = FALSE; open_buffer(FALSE, NULL, 0); - } else { + } else { if (!msg_silent) need_fileinfo = TRUE; /* display file info after redraw */ (void)buf_check_timestamp(curbuf, FALSE); /* check if file changed */ @@ -1264,7 +1264,8 @@ void enter_buffer(buf_T *buf) /* * Change to the directory of the current buffer. */ -void do_autochdir(void) { +void do_autochdir(void) +{ if (curbuf->b_ffname != NULL && vim_chdirfile(curbuf->b_ffname) == OK) shorten_fnames(TRUE); } @@ -1410,7 +1411,7 @@ buflist_new ( /* need to reload lmaps and set b:keymap_name */ curbuf->b_kmap_state |= KEYMAP_INIT; - } else { + } else { /* * put new buffer at the end of the buffer list */ @@ -1418,7 +1419,7 @@ buflist_new ( if (firstbuf == NULL) { /* buffer list is empty */ buf->b_prev = NULL; firstbuf = buf; - } else { /* append new buffer at end of list */ + } else { /* append new buffer at end of list */ lastbuf->b_next = buf; buf->b_prev = lastbuf; } @@ -1619,7 +1620,8 @@ int buflist_getfile(int n, linenr_T lnum, int options, int forceit) /* * go to the last know line number for the current buffer */ -void buflist_getfpos(void) { +void buflist_getfpos(void) +{ pos_T *fpos; fpos = buflist_findfpos(curbuf); @@ -2000,7 +2002,7 @@ static void buflist_setfpos(buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, wip->wi_win = win; if (lnum == 0) /* set lnum even when it's 0 */ lnum = 1; - } else { + } else { /* remove the entry from the list */ if (wip->wi_prev) wip->wi_prev->wi_next = wip->wi_next; @@ -2232,7 +2234,7 @@ setfname ( #ifdef UNIX st.st_dev = (dev_T)-1; #endif - } else { + } else { fname_expand(buf, &ffname, &sfname); /* will allocate ffname */ if (ffname == NULL) /* out of memory */ return FAIL; @@ -2396,7 +2398,8 @@ int buflist_add(char_u *fname, int flags) /* * Adjust slashes in file names. Called after 'shellslash' was set. */ -void buflist_slash_adjust(void) { +void buflist_slash_adjust(void) +{ buf_T *bp; for (bp = firstbuf; bp != NULL; bp = bp->b_next) { @@ -2562,14 +2565,14 @@ fileinfo ( (long)curbuf->b_ml.ml_line_count); if (curbuf->b_ml.ml_flags & ML_EMPTY) { vim_snprintf_add((char *)buffer, IOSIZE, "%s", _(no_lines_msg)); - } else if (p_ru) { + } else if (p_ru) { /* Current line and column are already on the screen -- webb */ if (curbuf->b_ml.ml_line_count == 1) vim_snprintf_add((char *)buffer, IOSIZE, _("1 line --%d%%--"), n); else vim_snprintf_add((char *)buffer, IOSIZE, _("%ld lines --%d%%--"), (long)curbuf->b_ml.ml_line_count, n); - } else { + } else { vim_snprintf_add((char *)buffer, IOSIZE, _("line %ld of %ld --%d%%-- col "), (long)curwin->w_cursor.lnum, @@ -2591,7 +2594,7 @@ fileinfo ( msg_scroll = TRUE; msg(buffer); msg_scroll = n; - } else { + } else { p = msg_trunc_attr(buffer, FALSE, 0); if (restart_edit != 0 || (msg_scrolled && !need_wait_return)) /* Need to repeat the message after redrawing when: @@ -2620,7 +2623,8 @@ void col_print(char_u *buf, size_t buflen, int col, int vcol) static char_u *lasttitle = NULL; static char_u *lasticon = NULL; -void maketitle(void) { +void maketitle(void) +{ char_u *p; char_u *t_str = NULL; char_u *i_name; @@ -2665,7 +2669,7 @@ void maketitle(void) { called_emsg |= save_called_emsg; } else t_str = p_titlestring; - } else { + } else { /* format: "fname + (path) (1 of 2) - VIM" */ #define SPACE_FOR_FNAME (IOSIZE - 100) @@ -2719,7 +2723,7 @@ void maketitle(void) { p = transstr(buf + off); vim_strncpy(buf + off, p, (size_t)(SPACE_FOR_DIR - off)); vim_free(p); - } else { + } else { vim_strncpy(buf + off, (char_u *)"...", (size_t)(SPACE_FOR_ARGNR - off)); } @@ -2757,7 +2761,7 @@ void maketitle(void) { called_emsg |= save_called_emsg; } else i_str = p_iconstring; - } else { + } else { if (buf_spname(curbuf) != NULL) i_name = buf_spname(curbuf); else /* use file name only in icon */ @@ -2804,12 +2808,14 @@ static int ti_change(char_u *str, char_u **last) /* * Put current window title back (used after calling a shell) */ -void resettitle(void) { +void resettitle(void) +{ mch_settitle(lasttitle, lasticon); } # if defined(EXITFREE) || defined(PROTO) -void free_titles(void) { +void free_titles(void) +{ vim_free(lasttitle); vim_free(lasticon); } @@ -3016,7 +3022,7 @@ build_stl_str_hl ( if (item[l].start < t) item[l].start = t; } - } else if (abs(item[groupitem[groupdepth]].minwid) > l) { + } else if (abs(item[groupitem[groupdepth]].minwid) > l) { /* fill */ n = item[groupitem[groupdepth]].minwid; if (n < 0) { @@ -3024,7 +3030,7 @@ build_stl_str_hl ( n = 0 - n; while (l++ < n && p + 1 < out + outlen) *p++ = fillchar; - } else { + } else { /* fill by inserting characters */ mch_memmove(t + n - l, t, (size_t)(p - t)); l = n - l; @@ -3378,7 +3384,7 @@ build_stl_str_hl ( } for (; l < minwid && p + 1 < out + outlen; l++) *p++ = fillchar; - } else if (num >= 0) { + } else if (num >= 0) { int nbase = (base == 'D' ? 10 : (base == 'O' ? 8 : 16)); char_u nstr[20]; @@ -3474,7 +3480,7 @@ build_stl_str_hl ( itemcnt = l; *s++ = '>'; *s = 0; - } else { + } else { if (has_mbyte) { n = 0; while (width >= maxwidth) { @@ -3504,7 +3510,7 @@ build_stl_str_hl ( } width = maxwidth; } else if (width < maxwidth && STRLEN(out) + maxwidth - width + 1 < - outlen) { + outlen) { /* Apply STL_MIDDLE if any */ for (l = 0; l < itemcnt; l++) if (item[l].type == Middle) @@ -3877,7 +3883,7 @@ do_arg_all ( } } } - } else if (split_ret == OK) { + } else if (split_ret == OK) { if (!use_firstwin) { /* split current window */ p_ea_save = p_ea; p_ea = TRUE; /* use space from all windows */ @@ -4015,7 +4021,7 @@ void ex_buffer_all(exarg_T *eap) wp = lastwin; /* buffer has a window, skip it */ else wp = NULL; - } else { + } else { /* Check if this buffer already has a window */ for (wp = firstwin; wp != NULL; wp = wp->w_next) if (wp->w_buffer == buf) @@ -4094,11 +4100,11 @@ void ex_buffer_all(exarg_T *eap) if (!win_valid(wp)) { /* BufWrite Autocommands made the window invalid, start over */ wp = lastwin; - } else if (r) { + } else if (r) { win_close(wp, !P_HID(wp->w_buffer)); --open_wins; wp = lastwin; - } else { + } else { wp = wp->w_prev; if (wp == NULL) break; diff --git a/src/charset.c b/src/charset.c index 28dacf1a15..fb2ed7be44 100644 --- a/src/charset.c +++ b/src/charset.c @@ -352,7 +352,7 @@ char_u *transstr(char_u *s) transchar_hex(hexbuf, c); len += (int)STRLEN(hexbuf); } - } else { + } else { l = byte2cells(*p++); if (l > 0) { diff --git a/src/cursor_shape.c b/src/cursor_shape.c index 1e49cb3f43..05d51e1c9d 100644 --- a/src/cursor_shape.c +++ b/src/cursor_shape.c @@ -142,7 +142,7 @@ char_u *parse_shape_opt(int what) shape_table[idx].shape = SHAPE_HOR; shape_table[idx].percentage = n; } - } else if (round == 2) { + } else if (round == 2) { if (len == 9) shape_table[idx].blinkwait = n; else if (len == 7) @@ -150,11 +150,11 @@ char_u *parse_shape_opt(int what) else shape_table[idx].blinkoff = n; } - } else if (STRNICMP(p, "block", 5) == 0) { + } else if (STRNICMP(p, "block", 5) == 0) { if (round == 2) shape_table[idx].shape = SHAPE_BLOCK; p += 5; - } else { /* must be a highlight group name then */ + } else { /* must be a highlight group name then */ endp = vim_strchr(p, '-'); if (commap == NULL) { /* last part */ if (endp == NULL) diff --git a/src/diff.c b/src/diff.c index bdf78dd708..0764715685 100644 --- a/src/diff.c +++ b/src/diff.c @@ -1743,7 +1743,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin) if (dp->df_count[toidx] == dp->df_count[fromidx]) { // same number of lines: use same filler count towin->w_topfill = fromwin->w_topfill; - } else if (dp->df_count[toidx] > dp->df_count[fromidx]) { + } else if (dp->df_count[toidx] > dp->df_count[fromidx]) { if (lnum == dp->df_lnum[fromidx] + dp->df_count[fromidx]) { // more lines in towin and fromwin doesn't show diff // lines, only filler lines @@ -1869,7 +1869,8 @@ int diffopt_changed(void) /// Return TRUE if 'diffopt' contains "horizontal". /// /// @return TRUE if 'diffopt' contains "horizontal" -int diffopt_horizontal(void) { +int diffopt_horizontal(void) +{ return (diff_flags & DIFF_HORIZONTAL) != 0; } diff --git a/src/edit.c b/src/edit.c index a2fde42259..d7afd6d40d 100644 --- a/src/edit.c +++ b/src/edit.c @@ -429,7 +429,7 @@ edit ( /* "gR" or "gr" command */ AppendCharToRedobuff('g'); AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R'); - } else { + } else { AppendCharToRedobuff(cmdchar); if (cmdchar == 'g') /* "gI" command */ AppendCharToRedobuff('I'); @@ -445,7 +445,7 @@ edit ( State = INSERT; } else State = REPLACE; - } else if (cmdchar == 'V' || cmdchar == 'v') { + } else if (cmdchar == 'V' || cmdchar == 'v') { State = VREPLACE; replaceState = VREPLACE; orig_line_count = curbuf->b_ml.ml_line_count; @@ -1370,7 +1370,8 @@ ins_redraw ( /* * Handle a CTRL-V or CTRL-Q typed in Insert mode. */ -static void ins_ctrl_v(void) { +static void ins_ctrl_v(void) +{ int c; int did_putchar = FALSE; @@ -1435,7 +1436,7 @@ void edit_putchar(int c, int highlight) pc_status = PC_STATUS_RIGHT; } } - } else { + } else { pc_col += curwin->w_wcol; if (mb_lefthalve(pc_row, pc_col)) pc_status = PC_STATUS_LEFT; @@ -1453,7 +1454,8 @@ void edit_putchar(int c, int highlight) /* * Undo the previous edit_putchar(). */ -void edit_unputchar(void) { +void edit_unputchar(void) +{ if (pc_status != PC_STATUS_UNSET && pc_row >= msg_scrolled) { if (pc_status == PC_STATUS_RIGHT) ++curwin->w_wcol; @@ -1497,7 +1499,8 @@ void display_dollar(colnr_T col) * Call this function before moving the cursor from the normal insert position * in insert mode. */ -static void undisplay_dollar(void) { +static void undisplay_dollar(void) +{ if (dollar_vcol >= 0) { dollar_vcol = -1; redrawWinline(curwin->w_cursor.lnum, FALSE); @@ -1801,7 +1804,8 @@ static int del_char_after_col(int limit_col) /* * CTRL-X pressed in Insert mode. */ -static void ins_ctrl_x(void) { +static void ins_ctrl_x(void) +{ /* CTRL-X after CTRL-X CTRL-V doesn't do anything, so that CTRL-X * CTRL-V works like CTRL-N */ if (ctrl_x_mode != CTRL_X_CMDLINE) { @@ -2154,7 +2158,7 @@ ins_compl_add ( else if (dir == FORWARD) { match->cp_next = compl_curr_match->cp_next; match->cp_prev = compl_curr_match; - } else { /* BACKWARD */ + } else { /* BACKWARD */ match->cp_next = compl_curr_match; match->cp_prev = compl_curr_match->cp_prev; } @@ -2210,7 +2214,7 @@ static void ins_compl_longest_match(compl_T *match) ins_compl_delete(); compl_used_match = FALSE; } - } else { + } else { /* Reduce the text if this match differs from compl_leader. */ p = compl_leader; s = match->cp_str; @@ -2218,7 +2222,7 @@ static void ins_compl_longest_match(compl_T *match) if (has_mbyte) { c1 = mb_ptr2char(p); c2 = mb_ptr2char(s); - } else { + } else { c1 = *p; c2 = *s; } @@ -2228,7 +2232,7 @@ static void ins_compl_longest_match(compl_T *match) if (has_mbyte) { mb_ptr_adv(p); mb_ptr_adv(s); - } else { + } else { ++p; ++s; } @@ -2273,7 +2277,8 @@ static void ins_compl_add_matches(int num_matches, char_u **matches, int icase) /* Make the completion list cyclic. * Return the number of matches (excluding the original). */ -static int ins_compl_make_cyclic(void) { +static int ins_compl_make_cyclic(void) +{ compl_T *match; int count = 0; @@ -2342,7 +2347,8 @@ static int compl_match_arraysize; /* * Update the screen and when there is any scrolling remove the popup menu. */ -static void ins_compl_upd_pum(void) { +static void ins_compl_upd_pum(void) +{ int h; if (compl_match_array != NULL) { @@ -2356,7 +2362,8 @@ static void ins_compl_upd_pum(void) { /* * Remove any popup menu. */ -static void ins_compl_del_pum(void) { +static void ins_compl_del_pum(void) +{ if (compl_match_array != NULL) { pum_undisplay(); vim_free(compl_match_array); @@ -2367,7 +2374,8 @@ static void ins_compl_del_pum(void) { /* * Return TRUE if the popup menu should be displayed. */ -static int pum_wanted(void) { +static int pum_wanted(void) +{ /* 'completeopt' must contain "menu" or "menuone" */ if (vim_strchr(p_cot, 'm') == NULL) return FALSE; @@ -2383,7 +2391,8 @@ static int pum_wanted(void) { * Return TRUE if there are two or more matches to be shown in the popup menu. * One if 'completopt' contains "menuone". */ -static int pum_enough_matches(void) { +static int pum_enough_matches(void) +{ compl_T *compl; int i; @@ -2407,7 +2416,8 @@ static int pum_enough_matches(void) { * Show the popup menu for the list of matches. * Also adjusts "compl_shown_match" to an entry that is actually displayed. */ -void ins_compl_show_pum(void) { +void ins_compl_show_pum(void) +{ compl_T *compl; compl_T *shown_compl = NULL; int did_find_shown_match = FALSE; @@ -2505,7 +2515,7 @@ void ins_compl_show_pum(void) { if (!shown_match_ok) /* no displayed match at all */ cur = -1; } - } else { + } else { /* popup menu already exists, only need to find the current item.*/ for (i = 0; i < compl_match_arraysize; ++i) if (compl_match_array[i].pum_text == compl_shown_match->cp_str @@ -2588,7 +2598,7 @@ ins_compl_dictionaries ( regmatch.regprog = vim_regcomp(ptr, RE_MAGIC); vim_free(pat_esc); vim_free(ptr); - } else { + } else { regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); if (regmatch.regprog == NULL) goto theend; @@ -2601,7 +2611,7 @@ ins_compl_dictionaries ( if (flags == DICT_EXACT) { count = 1; files = &dict; - } else { + } else { /* Expand wildcards in the dictionary name, but do not allow * backticks (for security, the 'dict' option may have been set in * a modeline). */ @@ -2622,7 +2632,7 @@ ins_compl_dictionaries ( else ptr = pat; spell_dump_compl(ptr, regmatch.rm_ic, &dir, 0); - } else if (count > 0) { /* avoid warning for using "files" uninit */ + } else if (count > 0) { /* avoid warning for using "files" uninit */ ins_compl_files(count, files, thesaurus, flags, ®match, buf, &dir); if (flags != DICT_EXACT) @@ -2779,7 +2789,8 @@ static char_u *find_line_end(char_u *ptr) /* * Free the list of completions */ -static void ins_compl_free(void) { +static void ins_compl_free(void) +{ compl_T *match; int i; @@ -2810,7 +2821,8 @@ static void ins_compl_free(void) { compl_shown_match = NULL; } -static void ins_compl_clear(void) { +static void ins_compl_clear(void) +{ compl_cont_status = 0; compl_started = FALSE; compl_matches = 0; @@ -2827,7 +2839,8 @@ static void ins_compl_clear(void) { /* * Return TRUE when Insert completion is active. */ -int ins_compl_active(void) { +int ins_compl_active(void) +{ return compl_started; } @@ -2837,7 +2850,8 @@ int ins_compl_active(void) { * Returns the character to be used, NUL if the work is done and another char * to be got from the user. */ -static int ins_compl_bs(void) { +static int ins_compl_bs(void) +{ char_u *line; char_u *p; @@ -2874,7 +2888,8 @@ static int ins_compl_bs(void) { * Return TRUE when we need to find matches again, ins_compl_restart() is to * be called. */ -static int ins_compl_need_restart(void) { +static int ins_compl_need_restart(void) +{ /* Return TRUE if we didn't complete finding matches or when the * 'completefunc' returned "always" in the "refresh" dictionary item. */ return compl_was_interrupted @@ -2887,7 +2902,8 @@ static int ins_compl_need_restart(void) { * Show the popup menu with a different set of matches. * May also search for matches again if the previous search was interrupted. */ -static void ins_compl_new_leader(void) { +static void ins_compl_new_leader(void) +{ ins_compl_del_pum(); ins_compl_delete(); ins_bytes(compl_leader + ins_compl_len()); @@ -2923,7 +2939,8 @@ static void ins_compl_new_leader(void) { * Return the length of the completion, from the completion start column to * the cursor column. Making sure it never goes below zero. */ -static int ins_compl_len(void) { +static int ins_compl_len(void) +{ int off = (int)curwin->w_cursor.col - (int)compl_col; if (off < 0) @@ -2947,7 +2964,7 @@ static void ins_compl_addleader(int c) ins_char_bytes(buf, cc); if (compl_opt_refresh_always) AppendToRedobuff(buf); - } else { + } else { ins_char(c); if (compl_opt_refresh_always) AppendCharToRedobuff(c); @@ -2973,7 +2990,8 @@ static void ins_compl_addleader(int c) * Setup for finding completions again without leaving CTRL-X mode. Used when * BS or a key was typed while still searching for matches. */ -static void ins_compl_restart(void) { +static void ins_compl_restart(void) +{ ins_compl_free(); compl_started = FALSE; compl_matches = 0; @@ -3002,7 +3020,8 @@ static void ins_compl_set_original_text(char_u *str) * Append one character to the match leader. May reduce the number of * matches. */ -static void ins_compl_addfrommatch(void) { +static void ins_compl_addfrommatch(void) +{ char_u *p; int len = (int)curwin->w_cursor.col - (int)compl_col; int c; @@ -3156,7 +3175,7 @@ static int ins_compl_prep(int c) showmode(); break; } - } else if (ctrl_x_mode != 0) { + } else if (ctrl_x_mode != 0) { /* We're already in CTRL-X mode, do we stay in it? */ if (!vim_is_ctrl_x_key(c)) { if (ctrl_x_mode == CTRL_X_SCROLL) @@ -3206,7 +3225,7 @@ static int ins_compl_prep(int c) do_c_expr_indent(); want_cindent = FALSE; /* don't do it again */ } - } else { + } else { int prev_col = curwin->w_cursor.col; /* put the cursor on the last char, for 'tw' formatting */ @@ -3482,7 +3501,7 @@ int ins_compl_add_tv(typval_T *tv, int dir) adup = get_dict_number(tv->vval.v_dict, (char_u *)"dup"); if (get_dict_string(tv->vval.v_dict, (char_u *)"empty", FALSE) != NULL) aempty = get_dict_number(tv->vval.v_dict, (char_u *)"empty"); - } else { + } else { word = get_tv_string_chk(tv); vim_memset(cptext, 0, sizeof(cptext)); } @@ -3572,7 +3591,7 @@ static int ins_compl_get_exp(pos_T *ini) first_match_pos.lnum = ins_buf->b_ml.ml_line_count + 1; last_match_pos.lnum = 0; type = 0; - } else { /* unloaded buffer, scan like dictionary */ + } else { /* unloaded buffer, scan like dictionary */ found_all = TRUE; if (ins_buf->b_fname == NULL) continue; @@ -3760,7 +3779,7 @@ static int ins_compl_get_exp(pos_T *ini) ptr = skipwhite(ptr); } len = (int)STRLEN(ptr); - } else { + } else { char_u *tmp_ptr = ptr; if (compl_cont_status & CONT_ADDING) { @@ -3847,7 +3866,7 @@ static int ins_compl_get_exp(pos_T *ini) || compl_interrupted) break; compl_started = TRUE; - } else { + } else { /* Mark a buffer scanned when it has been scanned completely */ if (type == 0 || type == CTRL_X_PATH_PATTERNS) ins_buf->b_scanned = TRUE; @@ -3877,7 +3896,8 @@ static int ins_compl_get_exp(pos_T *ini) } /* Delete the old text being completed. */ -static void ins_compl_delete(void) { +static void ins_compl_delete(void) +{ int i; /* @@ -3890,7 +3910,8 @@ static void ins_compl_delete(void) { } /* Insert the new text being completed. */ -static void ins_compl_insert(void) { +static void ins_compl_insert(void) +{ ins_bytes(compl_shown_match->cp_str + ins_compl_len()); if (compl_shown_match->cp_flags & ORIGINAL_TEXT) compl_used_match = FALSE; @@ -3987,7 +4008,7 @@ ins_compl_next ( found_end = (compl_shown_match == compl_first_match); compl_shown_match = compl_shown_match->cp_prev; found_end |= (compl_shown_match == compl_first_match); - } else { + } else { if (!allow_get_expansion) { if (advance) { if (compl_shows_dir == BACKWARD) @@ -4121,7 +4142,7 @@ void ins_compl_check_keys(int frequency) compl_shows_dir = ins_compl_key2dir(c); (void)ins_compl_next(FALSE, ins_compl_key2count(c), c != K_UP && c != K_DOWN); - } else { + } else { /* Need to get the character to have KeyTyped set. We'll put it * back with vungetc() below. But skip K_IGNORE. */ c = safe_vgetc(); @@ -4257,7 +4278,7 @@ static int ins_complete(int c) compl_startpos.col = compl_col; compl_startpos.lnum = curwin->w_cursor.lnum; compl_cont_status &= ~CONT_SOL; /* clear SOL if present */ - } else { + } else { /* S_IPOS was set when we inserted a word that was at the * beginning of the line, which means that we'll go to SOL * mode but first we need to redefine compl_startpos */ @@ -4316,7 +4337,7 @@ static int ins_complete(int c) compl_length); if (compl_pattern == NULL) return FAIL; - } else if (compl_cont_status & CONT_ADDING) { + } else if (compl_cont_status & CONT_ADDING) { char_u *prefix = (char_u *)"\\<"; /* we need up to 2 extra chars for the prefix */ @@ -4342,7 +4363,7 @@ static int ins_complete(int c) return FAIL; compl_col += curs_col; compl_length = 0; - } else { + } else { /* Search the point of change class of multibyte character * or not a word single byte character backward. */ if (has_mbyte) { @@ -4374,7 +4395,7 @@ static int ins_complete(int c) STRCPY((char *)compl_pattern, "\\<"); (void)quote_meta(compl_pattern + 2, line + compl_col, 1); STRCAT((char *)compl_pattern, "\\k"); - } else { + } else { compl_pattern = alloc(quote_meta(NULL, line + compl_col, compl_length) + 2); if (compl_pattern == NULL) @@ -4384,7 +4405,7 @@ static int ins_complete(int c) compl_length); } } - } else if (ctrl_x_mode == CTRL_X_WHOLE_LINE) { + } else if (ctrl_x_mode == CTRL_X_WHOLE_LINE) { compl_col = (colnr_T)(skipwhite(line) - line); compl_length = (int)curs_col - (int)compl_col; if (compl_length < 0) /* cursor in indent: empty pattern */ @@ -4396,7 +4417,7 @@ static int ins_complete(int c) compl_pattern = vim_strnsave(line + compl_col, compl_length); if (compl_pattern == NULL) return FAIL; - } else if (ctrl_x_mode == CTRL_X_FILES) { + } else if (ctrl_x_mode == CTRL_X_FILES) { /* Go back to just before the first filename character. */ if (startcol > 0) { char_u *p = line + startcol; @@ -4416,7 +4437,7 @@ static int ins_complete(int c) EXPAND_FILES); if (compl_pattern == NULL) return FAIL; - } else if (ctrl_x_mode == CTRL_X_CMDLINE) { + } else if (ctrl_x_mode == CTRL_X_CMDLINE) { compl_pattern = vim_strnsave(line, curs_col); if (compl_pattern == NULL) return FAIL; @@ -4431,7 +4452,7 @@ static int ins_complete(int c) compl_col = (int)(compl_xp.xp_pattern - compl_pattern); compl_length = curs_col - compl_col; } else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == - CTRL_X_OMNI) { + CTRL_X_OMNI) { /* * Call user defined function 'completefunc' with "a:findstart" * set to 1 to obtain the length of text to use for completion. @@ -4501,7 +4522,7 @@ static int ins_complete(int c) compl_pattern = vim_strnsave(line + compl_col, compl_length); if (compl_pattern == NULL) return FAIL; - } else if (ctrl_x_mode == CTRL_X_SPELL) { + } else if (ctrl_x_mode == CTRL_X_SPELL) { if (spell_bad_len > 0) compl_col = curs_col - spell_bad_len; else @@ -4509,7 +4530,7 @@ static int ins_complete(int c) if (compl_col >= (colnr_T)startcol) { compl_length = 0; compl_col = curs_col; - } else { + } else { spell_expand_check_cap(compl_col); compl_length = (int)curs_col - compl_col; } @@ -4518,7 +4539,7 @@ static int ins_complete(int c) compl_pattern = vim_strnsave(line + compl_col, compl_length); if (compl_pattern == NULL) return FAIL; - } else { + } else { EMSG2(_(e_intern2), "ins_complete()"); return FAIL; } @@ -4537,7 +4558,7 @@ static int ins_complete(int c) compl_length = 0; compl_col = curwin->w_cursor.col; } - } else { + } else { edit_submode_pre = NULL; compl_startpos.col = compl_col; } @@ -4625,13 +4646,13 @@ static int ins_complete(int c) if (compl_curr_match->cp_flags & ORIGINAL_TEXT) { edit_submode_extra = (char_u *)_("Back at original"); edit_submode_highl = HLF_W; - } else if (compl_cont_status & CONT_S_IPOS) { + } else if (compl_cont_status & CONT_S_IPOS) { edit_submode_extra = (char_u *)_("Word from other line"); edit_submode_highl = HLF_COUNT; - } else if (compl_curr_match->cp_next == compl_curr_match->cp_prev) { + } else if (compl_curr_match->cp_next == compl_curr_match->cp_prev) { edit_submode_extra = (char_u *)_("The only match"); edit_submode_highl = HLF_COUNT; - } else { + } else { /* Update completion sequence number when needed. */ if (compl_curr_match->cp_number == -1) { int number = 0; @@ -4655,7 +4676,7 @@ static int ins_complete(int c) match != NULL && match->cp_number == -1; match = match->cp_next) match->cp_number = ++number; - } else { /* BACKWARD */ + } else { /* BACKWARD */ /* search forwards (upwards) for the first valid (!= -1) * number. This should normally succeed already at the * first loop cycle, so it's fast! */ @@ -4790,7 +4811,8 @@ static unsigned quote_meta(char_u *dest, char_u *src, int len) * If one or two digits are entered, the next character is given to vungetc(). * For Unicode a character > 255 may be returned. */ -int get_literal(void) { +int get_literal(void) +{ int cc; int nc; int i; @@ -4826,11 +4848,11 @@ int get_literal(void) { if (!vim_isxdigit(nc)) break; cc = cc * 16 + hex2nr(nc); - } else if (octal) { + } else if (octal) { if (nc < '0' || nc > '7') break; cc = cc * 8 + nc - '0'; - } else { + } else { if (!VIM_ISDIGIT(nc)) break; cc = cc * 10 + nc - '0'; @@ -4848,7 +4870,7 @@ int get_literal(void) { if (hex) { /* hex: up to two chars */ if (i >= 2) break; - } else if (unicode) { /* Unicode: up to four or eight chars */ + } else if (unicode) { /* Unicode: up to four or eight chars */ if ((unicode == 'u' && i >= 4) || (unicode == 'U' && i >= 8)) break; } else if (i >= 3) /* decimal or octal: up to three chars */ @@ -4858,7 +4880,7 @@ int get_literal(void) { if (nc == K_ZERO) { /* NUL is stored as NL */ cc = '\n'; nc = 0; - } else { + } else { cc = nc; nc = 0; } @@ -5116,7 +5138,7 @@ insertchar ( i = 0; if (buf[i] != NUL) AppendToRedobuffLit(buf + i, -1); - } else { + } else { int cc; if (has_mbyte && (cc = (*mb_char2len)(c)) > 1) { @@ -5126,7 +5148,7 @@ insertchar ( buf[cc] = NUL; ins_char_bytes(buf, cc); AppendCharToRedobuff(c); - } else { + } else { ins_char(c); if (flags & INSCHAR_CTRLV) redo_literal(c); @@ -5277,7 +5299,7 @@ internal_format ( foundcol = curwin->w_cursor.col; if (curwin->w_cursor.col <= (colnr_T)wantcol) break; - } else if (cc >= 0x100 && fo_multibyte) { + } else if (cc >= 0x100 && fo_multibyte) { /* Break after or before a multi-byte character. */ if (curwin->w_cursor.col != startcol) { /* Don't break until after the comment leader */ @@ -5365,7 +5387,7 @@ internal_format ( /* Backspace over characters that will move to the next line */ if (!fo_white_par) backspace_until_column(foundcol); - } else { + } else { /* put cursor after pos. to break line */ if (!fo_white_par) curwin->w_cursor.col = foundcol; @@ -5400,7 +5422,7 @@ internal_format ( if (State & VREPLACE_FLAG) change_indent(INDENT_SET, second_indent, FALSE, NUL, TRUE); - else if (leader_len > 0 && second_indent - leader_len > 0) { + else if (leader_len > 0 && second_indent - leader_len > 0) { int i; int padding = second_indent - leader_len; @@ -5413,7 +5435,7 @@ internal_format ( for (i = 0; i < padding; i++) ins_str((char_u *)" "); changed_bytes(curwin->w_cursor.lnum, leader_len); - } else { + } else { (void)set_indent(second_indent, SIN_CHANGED); } } @@ -5428,7 +5450,7 @@ internal_format ( */ ins_bytes(saved_text); vim_free(saved_text); - } else { + } else { /* * Check if cursor is not past the NUL off the line, cindent * may have added or removed indent. @@ -5667,7 +5689,8 @@ start_arrow ( * If we skipped highlighting word at cursor, do it now. * It may be skipped again, thus reset spell_redraw_lnum first. */ -static void check_spell_redraw(void) { +static void check_spell_redraw(void) +{ if (spell_redraw_lnum != 0) { linenr_T lnum = spell_redraw_lnum; @@ -5680,7 +5703,8 @@ static void check_spell_redraw(void) { * Called when starting CTRL_X_SPELL mode: Move backwards to a previous badly * spelled word, if there is one. */ -static void spell_back_to_badword(void) { +static void spell_back_to_badword(void) +{ pos_T tpos = curwin->w_cursor; spell_bad_len = spell_move_to(curwin, BACKWARD, TRUE, TRUE, NULL); @@ -5693,7 +5717,8 @@ static void spell_back_to_badword(void) { * If an arrow key has been used, start a new insertion. * Returns FAIL if undo is impossible, shouldn't insert then. */ -int stop_arrow(void) { +int stop_arrow(void) +{ if (arrow_used) { if (u_save_cursor() == OK) { arrow_used = FALSE; @@ -5709,7 +5734,7 @@ int stop_arrow(void) { ResetRedobuff(); AppendToRedobuff((char_u *)"1i"); /* pretend we start an insertion */ new_insert_skip = 2; - } else if (ins_need_undo) { + } else if (ins_need_undo) { if (u_save_cursor() == OK) ins_need_undo = FALSE; } @@ -5863,7 +5888,8 @@ void set_last_insert(int c) } #if defined(EXITFREE) || defined(PROTO) -void free_last_insert(void) { +void free_last_insert(void) +{ vim_free(last_insert); last_insert = NULL; vim_free(compl_orig_text); @@ -5931,7 +5957,8 @@ void beginline(int flags) * Return OK when successful, FAIL when we hit a line of file boundary. */ -int oneright(void) { +int oneright(void) +{ char_u *ptr; int l; @@ -5971,7 +5998,8 @@ int oneright(void) { return OK; } -int oneleft(void) { +int oneleft(void) +{ if (virtual_active()) { int width; int v = getviscol(); @@ -6036,7 +6064,7 @@ cursor_up ( return FAIL; if (n >= lnum) lnum = 1; - else if (hasAnyFolding(curwin)) { + else if (hasAnyFolding(curwin)) { /* * Count each sequence of folded lines as one logical line. */ @@ -6093,7 +6121,7 @@ cursor_down ( return FAIL; if (lnum + n >= curbuf->b_ml.ml_line_count) lnum = curbuf->b_ml.ml_line_count; - else if (hasAnyFolding(curwin)) { + else if (hasAnyFolding(curwin)) { linenr_T last; /* count each sequence of folded lines as one logical line */ @@ -6183,7 +6211,8 @@ stuff_inserted ( return OK; } -char_u *get_last_insert(void) { +char_u *get_last_insert(void) +{ if (last_insert == NULL) return NULL; return last_insert + last_insert_skip; @@ -6193,7 +6222,8 @@ char_u *get_last_insert(void) { * Get last inserted string, and remove trailing <Esc>. * Returns pointer to allocated memory (must be freed) or NULL. */ -char_u *get_last_insert_save(void) { +char_u *get_last_insert_save(void) +{ char_u *s; int len; @@ -6298,7 +6328,8 @@ int replace_push_mb(char_u *p) * return -1 if stack empty * return replaced character or NUL otherwise */ -static int replace_pop(void) { +static int replace_pop(void) +{ if (replace_stack_nr == 0) return -1; return (int)replace_stack[--replace_stack_nr]; @@ -6328,7 +6359,8 @@ replace_join ( * Pop bytes from the replace stack until a NUL is found, and insert them * before the cursor. Can only be used in REPLACE or VREPLACE mode. */ -static void replace_pop_ins(void) { +static void replace_pop_ins(void) +{ int cc; int oldState = State; @@ -6369,7 +6401,7 @@ static void mb_replace_pop_ins(int cc) /* Not a multi-byte char, put it back. */ replace_push(c); break; - } else { + } else { buf[0] = c; for (i = 1; i < n; ++i) buf[i] = replace_pop(); @@ -6389,7 +6421,8 @@ static void mb_replace_pop_ins(int cc) * make the replace stack empty * (called when exiting replace mode) */ -static void replace_flush(void) { +static void replace_flush(void) +{ vim_free(replace_stack); replace_stack = NULL; replace_stack_len = 0; @@ -6429,7 +6462,7 @@ static void replace_do_bs(int limit_col) if (State & VREPLACE_FLAG) orig_len = (int)STRLEN(ml_get_cursor()); replace_push(cc); - } else { + } else { pchar_cursor(cc); if (State & VREPLACE_FLAG) orig_len = (int)STRLEN(ml_get_cursor()) - 1; @@ -6466,7 +6499,7 @@ static void replace_do_bs(int limit_col) /* * Return TRUE if C-indenting is on. */ -static int cindent_on(void) { +static int cindent_on(void) { return !p_paste && (curbuf->b_p_cin || *curbuf->b_p_inde != NUL ); @@ -6487,7 +6520,7 @@ int (*get_the_indent)(void); did_ai = TRUE; /* delete the indent if the line stays empty */ } -void fix_indent(void) { +void fix_indent(void) { if (p_paste) return; if (curbuf->b_p_lisp && curbuf->b_p_ai) @@ -6570,7 +6603,7 @@ int in_cinkeys(int keytyped, int when, int line_is_empty) if (try_match && keytyped == KEY_OPEN_FORW) return TRUE; ++look; - } else if (*look == 'O') { + } else if (*look == 'O') { if (try_match && keytyped == KEY_OPEN_BACK) return TRUE; ++look; @@ -6762,7 +6795,7 @@ int hkmap(int c) return (int)(map[CharOrdLow(c)] + p_aleph); else return c; - } else { + } else { switch (c) { case '`': return ';'; case '/': return '.'; @@ -6788,7 +6821,8 @@ int hkmap(int c) } } -static void ins_reg(void) { +static void ins_reg(void) +{ int need_redraw = FALSE; int regname; int literally = 0; @@ -6847,7 +6881,7 @@ static void ins_reg(void) { if (regname == NUL || !valid_yank_reg(regname, FALSE)) { vim_beep(); need_redraw = TRUE; /* remove the '"' */ - } else { + } else { if (literally == Ctrl_O || literally == Ctrl_P) { /* Append the command to the redo buffer. */ AppendCharToRedobuff(Ctrl_R); @@ -6856,7 +6890,7 @@ static void ins_reg(void) { do_put(regname, BACKWARD, 1L, (literally == Ctrl_P ? PUT_FIXINDENT : 0) | PUT_CURSEND); - } else if (insert_reg(regname, literally) == FAIL) { + } else if (insert_reg(regname, literally) == FAIL) { vim_beep(); need_redraw = TRUE; /* remove the '"' */ } else if (stop_insert_mode) @@ -6884,7 +6918,8 @@ static void ins_reg(void) { /* * CTRL-G commands in Insert mode. */ -static void ins_ctrl_g(void) { +static void ins_ctrl_g(void) +{ int c; /* Right after CTRL-X the cursor will be after the ruler. */ @@ -6927,13 +6962,14 @@ static void ins_ctrl_g(void) { /* * CTRL-^ in Insert mode. */ -static void ins_ctrl_hat(void) { +static void ins_ctrl_hat(void) +{ if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) { /* ":lmap" mappings exists, Toggle use of ":lmap" mappings. */ if (State & LANGMAP) { curbuf->b_p_iminsert = B_IMODE_NONE; State &= ~LANGMAP; - } else { + } else { curbuf->b_p_iminsert = B_IMODE_LMAP; State |= LANGMAP; #ifdef USE_IM_CONTROL @@ -6947,7 +6983,7 @@ static void ins_ctrl_hat(void) { if (im_get_status()) { curbuf->b_p_iminsert = B_IMODE_NONE; im_set_active(FALSE); - } else { + } else { curbuf->b_p_iminsert = B_IMODE_IM; State &= ~LANGMAP; im_set_active(TRUE); @@ -7044,7 +7080,7 @@ ins_esc ( oneleft(); if (restart_edit != NUL) ++curwin->w_cursor.coladd; - } else { + } else { --curwin->w_cursor.col; /* Correct cursor for multi-byte character. */ if (has_mbyte) @@ -7084,7 +7120,8 @@ ins_esc ( * Toggle language: hkmap and revins_on. * Move to end of reverse inserted text. */ -static void ins_ctrl_(void) { +static void ins_ctrl_(void) +{ if (revins_on && revins_chars && revins_scol >= 0) { while (gchar_cursor() != NUL && revins_chars--) ++curwin->w_cursor.col; @@ -7186,7 +7223,8 @@ static void ins_insert(int replaceState) /* * Pressed CTRL-O in Insert mode. */ -static void ins_ctrl_o(void) { +static void ins_ctrl_o(void) +{ if (State & VREPLACE_FLAG) restart_edit = 'V'; else if (State & REPLACE_FLAG) @@ -7236,7 +7274,8 @@ static void ins_shift(int c, int lastc) can_cindent = FALSE; /* no cindenting after ^D or ^T */ } -static void ins_del(void) { +static void ins_del(void) +{ int temp; if (stop_arrow() == FAIL) @@ -7367,7 +7406,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p) */ if ((State & REPLACE_FLAG) && curwin->w_cursor.lnum <= lnum) { dec_cursor(); - } else { + } else { if (!(State & VREPLACE_FLAG) || curwin->w_cursor.lnum > orig_line_count) { temp = gchar_cursor(); /* remember current char */ @@ -7422,7 +7461,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p) } } did_ai = FALSE; - } else { + } else { /* * Delete character(s) before the cursor. */ @@ -7676,7 +7715,8 @@ static void ins_mousescroll(int dir) -static void ins_left(void) { +static void ins_left(void) +{ pos_T tpos; if ((fdo_flags & FDO_HOR) && KeyTyped) @@ -7735,7 +7775,8 @@ static void ins_end(int c) start_arrow(&tpos); } -static void ins_s_left(void) { +static void ins_s_left(void) +{ if ((fdo_flags & FDO_HOR) && KeyTyped) foldOpenCursor(); undisplay_dollar(); @@ -7747,7 +7788,8 @@ static void ins_s_left(void) { vim_beep(); } -static void ins_right(void) { +static void ins_right(void) +{ if ((fdo_flags & FDO_HOR) && KeyTyped) foldOpenCursor(); undisplay_dollar(); @@ -7781,7 +7823,8 @@ static void ins_right(void) { vim_beep(); } -static void ins_s_right(void) { +static void ins_s_right(void) +{ if ((fdo_flags & FDO_HOR) && KeyTyped) foldOpenCursor(); undisplay_dollar(); @@ -7818,7 +7861,8 @@ ins_up ( vim_beep(); } -static void ins_pageup(void) { +static void ins_pageup(void) +{ pos_T tpos; undisplay_dollar(); @@ -7864,7 +7908,8 @@ ins_down ( vim_beep(); } -static void ins_pagedown(void) { +static void ins_pagedown(void) +{ pos_T tpos; undisplay_dollar(); @@ -7890,7 +7935,8 @@ static void ins_pagedown(void) { * Handle TAB in Insert or Replace mode. * Return TRUE when the TAB needs to be inserted like a normal character. */ -static int ins_tab(void) { +static int ins_tab(void) +{ int ind; int i; int temp; @@ -7969,7 +8015,7 @@ static int ins_tab(void) { if (saved_line == NULL) return FALSE; ptr = saved_line + pos.col; - } else { + } else { ptr = ml_get_cursor(); cursor = &curwin->w_cursor; } @@ -8130,7 +8176,8 @@ static int ins_eol(int c) * Returns character still to be inserted, or NUL when nothing remaining to be * done. */ -static int ins_digraph(void) { +static int ins_digraph(void) +{ int c; int cc; int did_putchar = FALSE; @@ -8245,7 +8292,7 @@ static int ins_ctrl_ey(int tc) else scrollup_clamp(); redraw_later(VALID); - } else { + } else { c = ins_copychar(curwin->w_cursor.lnum + (c == Ctrl_Y ? -1 : 1)); if (c != NUL) { long tw_save; @@ -8311,7 +8358,7 @@ static void ins_try_si(int c) change_indent(INDENT_SET, i, FALSE, NUL, TRUE); else (void)set_indent(i, SIN_CHANGED); - } else if (curwin->w_cursor.col > 0) { + } else if (curwin->w_cursor.col > 0) { /* * when inserting '{' after "O" reduce indent, but not * more than indent of previous line @@ -8354,7 +8401,8 @@ static void ins_try_si(int c) * Get the value that w_virtcol would have when 'list' is off. * Unless 'cpo' contains the 'L' flag. */ -static colnr_T get_nolist_virtcol(void) { +static colnr_T get_nolist_virtcol(void) +{ if (curwin->w_p_list && vim_strchr(p_cpo, CPO_LISTWM) == NULL) return getvcol_nolist(&curwin->w_cursor); validate_virtcol(); diff --git a/src/eval.c b/src/eval.c index f073d321f7..140fe684ea 100644 --- a/src/eval.c +++ b/src/eval.c @@ -856,7 +856,8 @@ static void setwinvar(typval_T *argvars, typval_T *rettv, int off); /* * Initialize the global and v: variables. */ -void eval_init(void) { +void eval_init(void) +{ int i; struct vimvar *p; @@ -890,7 +891,8 @@ void eval_init(void) { } #if defined(EXITFREE) || defined(PROTO) -void eval_clear(void) { +void eval_clear(void) +{ int i; struct vimvar *p; @@ -899,7 +901,7 @@ void eval_clear(void) { if (p->vv_di.di_tv.v_type == VAR_STRING) { vim_free(p->vv_str); p->vv_str = NULL; - } else if (p->vv_di.di_tv.v_type == VAR_LIST) { + } else if (p->vv_di.di_tv.v_type == VAR_LIST) { list_unref(p->vv_list); p->vv_list = NULL; } @@ -978,7 +980,8 @@ funccall_T *previous_funccal = NULL; /* * Return TRUE when a function was ended by a ":return" command. */ -int current_func_returned(void) { +int current_func_returned(void) +{ return current_funccal->returned; } @@ -1110,7 +1113,8 @@ void var_redir_str(char_u *value, int value_len) * Stop redirecting command output to a variable. * Frees the allocated memory. */ -void var_redir_stop(void) { +void var_redir_stop(void) +{ typval_T tv; if (redir_lval != NULL) { @@ -1302,7 +1306,7 @@ char_u *eval_to_string(char_u *arg, char_u **nextcmd, int convert) } ga_append(&ga, NUL); retval = (char_u *)ga.ga_data; - } else if (convert && tv.v_type == VAR_FLOAT) { + } else if (convert && tv.v_type == VAR_FLOAT) { vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv.vval.v_float); retval = vim_strsave(numbuf); } else @@ -1505,7 +1509,7 @@ call_vim_function ( if (len != 0 && len == (int)STRLEN(argv[i])) { argvars[i].v_type = VAR_NUMBER; argvars[i].vval.v_number = n; - } else { + } else { argvars[i].v_type = VAR_STRING; argvars[i].vval.v_string = argv[i]; } @@ -1617,7 +1621,8 @@ call_func_retlist ( * Save the current function call pointer, and set it to NULL. * Used when executing autocommands and for ":source". */ -void *save_funccal(void) { +void *save_funccal(void) +{ funccall_T *fc = current_funccal; current_funccal = NULL; @@ -1755,7 +1760,7 @@ void ex_let(exarg_T *eap) list_vim_vars(&first); } eap->nextcmd = check_nextcmd(arg); - } else { + } else { op[0] = '='; op[1] = NUL; if (expr > argend) { @@ -1771,7 +1776,7 @@ void ex_let(exarg_T *eap) if (i != FAIL) clear_tv(&rettv); --emsg_skip; - } else if (i != FAIL) { + } else if (i != FAIL) { (void)ex_let_vars(eap->arg, &rettv, FALSE, semicolon, var_count, op); clear_tv(&rettv); @@ -1861,7 +1866,7 @@ ex_let_vars ( if (arg == NULL) return FAIL; break; - } else if (*arg != ',' && *arg != ']') { + } else if (*arg != ',' && *arg != ']') { EMSG2(_(e_intern2), "ex_let_vars()"); return FAIL; } @@ -1902,7 +1907,7 @@ static char_u *skip_var_list(char_u *arg, int *var_count, int *semicolon) return NULL; } *semicolon = 1; - } else if (*p != ',') { + } else if (*p != ',') { EMSG2(_(e_invarg2), p); return NULL; } @@ -2036,7 +2041,7 @@ static char_u *list_arg_vars(exarg_T *eap, char_u *arg, int *first) EMSG(_(e_trailing)); break; } - } else { + } else { /* get_name_len() takes care of expanding curly braces */ name_start = name = arg; len = get_name_len(&arg, &tofree, TRUE, TRUE); @@ -2049,7 +2054,7 @@ static char_u *list_arg_vars(exarg_T *eap, char_u *arg, int *first) break; } error = TRUE; - } else { + } else { if (tofree != NULL) name = tofree; if (get_var_tv(name, len, &tv, TRUE, FALSE) == FAIL) @@ -2072,7 +2077,7 @@ static char_u *list_arg_vars(exarg_T *eap, char_u *arg, int *first) default: EMSG2(_("E738: Can't list variables for %s"), name); } - } else { + } else { char_u numbuf[NUMBUFLEN]; char_u *tf; int c; @@ -2206,7 +2211,7 @@ ex_let_one ( n = numval + n; else n = numval - n; - } else if (opt_type == 0 && stringval != NULL) { /* string */ + } else if (opt_type == 0 && stringval != NULL) { /* string */ s = concat_str(stringval, s); vim_free(stringval); stringval = s; @@ -2403,7 +2408,7 @@ get_lval ( return NULL; } p = key + len; - } else { + } else { /* Get the index [expr] or the first index [expr: ]. */ p = skipwhite(p + 1); if (*p == ':') @@ -2541,7 +2546,7 @@ get_lval ( if (len == -1) clear_tv(&var1); lp->ll_tv = &lp->ll_di->di_tv; - } else { + } else { /* * Get the number and item for the only or first index of the List. */ @@ -2676,7 +2681,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch ? (lp->ll_li != NULL && lp->ll_li->li_next != NULL) : lp->ll_n1 != lp->ll_n2) EMSG(_("E711: List value has not enough items")); - } else { + } else { /* * Assign to a List or Dictionary item. */ @@ -2695,7 +2700,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch return; } lp->ll_tv = &di->di_tv; - } else if (op != NULL && *op != '=') { + } else if (op != NULL && *op != '=') { tv_op(lp->ll_tv, rettv, op); return; } else @@ -2756,7 +2761,7 @@ static int tv_op(typval_T *tv1, typval_T *tv2, char_u *op) clear_tv(tv1); tv1->v_type = VAR_FLOAT; tv1->vval.v_float = f; - } else { + } else { if (*op == '+') n += get_tv_number(tv2); else @@ -2765,7 +2770,7 @@ static int tv_op(typval_T *tv1, typval_T *tv2, char_u *op) tv1->v_type = VAR_NUMBER; tv1->vval.v_number = n; } - } else { + } else { if (tv2->v_type == VAR_FLOAT) break; @@ -2881,7 +2886,7 @@ void *eval_for_line(char_u *arg, int *errp, char_u **nextcmdp, int skip) if (tv.v_type != VAR_LIST || l == NULL) { EMSG(_(e_listreq)); clear_tv(&tv); - } else { + } else { /* No need to increment the refcount, it's already set for the * list being used in "tv". */ fi->fi_list = l; @@ -2964,16 +2969,16 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) ++xp->xp_pattern; xp->xp_context = cmdidx != CMD_let || got_eq ? EXPAND_EXPRESSION : EXPAND_NOTHING; - } else if (c != ' ') { + } else if (c != ' ') { xp->xp_context = EXPAND_SETTINGS; if ((c == 'l' || c == 'g') && xp->xp_pattern[2] == ':') xp->xp_pattern += 2; } - } else if (c == '$') { + } else if (c == '$') { /* environment variable */ xp->xp_context = EXPAND_ENV_VARS; - } else if (c == '=') { + } else if (c == '=') { got_eq = TRUE; xp->xp_context = EXPAND_EXPRESSION; } else if (c == '<' @@ -2981,18 +2986,18 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) && vim_strchr(xp->xp_pattern, '(') == NULL) { /* Function name can start with "<SNR>" */ break; - } else if (cmdidx != CMD_let || got_eq) { + } else if (cmdidx != CMD_let || got_eq) { if (c == '"') { /* string */ while ((c = *++xp->xp_pattern) != NUL && c != '"') if (c == '\\' && xp->xp_pattern[1] != NUL) ++xp->xp_pattern; xp->xp_context = EXPAND_NOTHING; - } else if (c == '\'') { /* literal string */ + } else if (c == '\'') { /* literal string */ /* Trick: '' is like stopping and starting a literal string. */ while ((c = *++xp->xp_pattern) != NUL && c != '\'') /* skip */; xp->xp_context = EXPAND_NOTHING; - } else if (c == '|') { + } else if (c == '|') { if (xp->xp_pattern[1] == '|') { ++xp->xp_pattern; xp->xp_context = EXPAND_EXPRESSION; @@ -3184,7 +3189,7 @@ static void ex_unletlock(exarg_T *eap, char_u *argstart, int deep) if (eap->cmdidx == CMD_unlet) { if (do_unlet_var(&lv, name_end, eap->forceit) == FAIL) error = TRUE; - } else { + } else { if (do_lock_var(&lv, name_end, deep, eap->cmdidx == CMD_lockvar) == FAIL) error = TRUE; @@ -3227,7 +3232,7 @@ static int do_unlet_var(lval_T *lp, char_u *name_end, int forceit) lp->ll_li = li; ++lp->ll_n1; } - } else { + } else { if (lp->ll_list != NULL) /* unlet a List item. */ listitem_remove(lp->ll_list, lp->ll_li); @@ -3302,7 +3307,7 @@ static int do_lock_var(lval_T *lp, char_u *name_end, int deep, int lock) } } *name_end = cc; - } else if (lp->ll_range) { + } else if (lp->ll_range) { listitem_T *li = lp->ll_li; /* (un)lock a range of List items. */ @@ -3399,7 +3404,8 @@ static int tv_islocked(typval_T *tv) /* * Delete all "menutrans_" variables. */ -void del_menutrans_vars(void) { +void del_menutrans_vars(void) +{ hashitem_T *hi; int todo; @@ -3885,7 +3891,7 @@ static int eval4(char_u **arg, typval_T *rettv, int evaluate) /* For "is" a different type always means FALSE, for "notis" * it means TRUE. */ n1 = (type == TYPE_NEQUAL); - } else if (rettv->v_type == VAR_LIST || var2.v_type == VAR_LIST) { + } else if (rettv->v_type == VAR_LIST || var2.v_type == VAR_LIST) { if (type_is) { n1 = (rettv->v_type == var2.v_type && rettv->vval.v_list == var2.vval.v_list); @@ -3900,14 +3906,14 @@ static int eval4(char_u **arg, typval_T *rettv, int evaluate) clear_tv(rettv); clear_tv(&var2); return FAIL; - } else { + } else { /* Compare two Lists for being equal or unequal. */ n1 = list_equal(rettv->vval.v_list, var2.vval.v_list, ic, FALSE); if (type == TYPE_NEQUAL) n1 = !n1; } - } else if (rettv->v_type == VAR_DICT || var2.v_type == VAR_DICT) { + } else if (rettv->v_type == VAR_DICT || var2.v_type == VAR_DICT) { if (type_is) { n1 = (rettv->v_type == var2.v_type && rettv->vval.v_dict == var2.vval.v_dict); @@ -3922,14 +3928,14 @@ static int eval4(char_u **arg, typval_T *rettv, int evaluate) clear_tv(rettv); clear_tv(&var2); return FAIL; - } else { + } else { /* Compare two Dictionaries for being equal or unequal. */ n1 = dict_equal(rettv->vval.v_dict, var2.vval.v_dict, ic, FALSE); if (type == TYPE_NEQUAL) n1 = !n1; } - } else if (rettv->v_type == VAR_FUNC || var2.v_type == VAR_FUNC) { + } else if (rettv->v_type == VAR_FUNC || var2.v_type == VAR_FUNC) { if (rettv->v_type != var2.v_type || (type != TYPE_EQUAL && type != TYPE_NEQUAL)) { if (rettv->v_type != var2.v_type) @@ -3939,7 +3945,7 @@ static int eval4(char_u **arg, typval_T *rettv, int evaluate) clear_tv(rettv); clear_tv(&var2); return FAIL; - } else { + } else { /* Compare two Funcrefs for being equal or unequal. */ if (rettv->vval.v_string == NULL || var2.vval.v_string == NULL) @@ -3999,7 +4005,7 @@ static int eval4(char_u **arg, typval_T *rettv, int evaluate) case TYPE_MATCH: case TYPE_NOMATCH: break; /* avoid gcc warning */ } - } else { + } else { s1 = get_tv_string_buf(rettv, buf1); s2 = get_tv_string_buf(&var2, buf2); if (type != TYPE_MATCH && type != TYPE_NOMATCH) @@ -4133,13 +4139,13 @@ static int eval5(char_u **arg, typval_T *rettv, int evaluate) } clear_tv(rettv); *rettv = var3; - } else { + } else { int error = FALSE; if (rettv->v_type == VAR_FLOAT) { f1 = rettv->vval.v_float; n1 = 0; - } else { + } else { n1 = get_tv_number_chk(rettv, &error); if (error) { /* This can only happen for "list + non-list". For @@ -4154,7 +4160,7 @@ static int eval5(char_u **arg, typval_T *rettv, int evaluate) if (var2.v_type == VAR_FLOAT) { f2 = var2.vval.v_float; n2 = 0; - } else { + } else { n2 = get_tv_number_chk(&var2, &error); if (error) { clear_tv(rettv); @@ -4174,7 +4180,7 @@ static int eval5(char_u **arg, typval_T *rettv, int evaluate) f1 = f1 - f2; rettv->v_type = VAR_FLOAT; rettv->vval.v_float = f1; - } else { + } else { if (op == '+') n1 = n1 + n2; else @@ -4257,7 +4263,7 @@ eval6 ( } f2 = var2.vval.v_float; n2 = 0; - } else { + } else { n2 = get_tv_number_chk(&var2, &error); clear_tv(&var2); if (error) @@ -4277,13 +4283,13 @@ eval6 ( /* We rely on the floating point library to handle divide * by zero to result in "inf" and not a crash. */ f1 = f2 != 0 ? f1 / f2 : INFINITY; - } else { + } else { EMSG(_("E804: Cannot use '%' with Float")); return FAIL; } rettv->v_type = VAR_FLOAT; rettv->vval.v_float = f1; - } else { + } else { if (op == '*') n1 = n1 * n2; else if (op == '/') { @@ -4296,7 +4302,7 @@ eval6 ( n1 = 0x7fffffffL; } else n1 = n1 / n2; - } else { + } else { if (n2 == 0) /* give an error message? */ n1 = 0; else @@ -4412,7 +4418,7 @@ eval7 ( rettv->v_type = VAR_FLOAT; rettv->vval.v_float = f; } - } else { + } else { vim_str2nr(*arg, NULL, &len, TRUE, TRUE, &n, NULL); *arg += len; if (evaluate) { @@ -4558,7 +4564,7 @@ eval7 ( if (error) { clear_tv(rettv); ret = FAIL; - } else { + } else { while (end_leader > start_leader) { --end_leader; if (*end_leader == '!') { @@ -4566,7 +4572,7 @@ eval7 ( f = !f; else val = !val; - } else if (*end_leader == '-') { + } else if (*end_leader == '-') { if (rettv->v_type == VAR_FLOAT) f = -f; else @@ -4576,7 +4582,7 @@ eval7 ( if (rettv->v_type == VAR_FLOAT) { clear_tv(rettv); rettv->vval.v_float = f; - } else { + } else { clear_tv(rettv); rettv->v_type = VAR_NUMBER; rettv->vval.v_number = val; @@ -4612,7 +4618,7 @@ eval_index ( if (verbose) EMSG(_("E695: Cannot index a Funcref")); return FAIL; - } else if (rettv->v_type == VAR_FLOAT) { + } else if (rettv->v_type == VAR_FLOAT) { if (verbose) EMSG(_(e_float_as_string)); return FAIL; @@ -4628,7 +4634,7 @@ eval_index ( if (len == 0) return FAIL; *arg = skipwhite(key + len); - } else { + } else { /* * something[idx] * @@ -4657,7 +4663,7 @@ eval_index ( if (!empty1) clear_tv(&var1); return FAIL; - } else if (evaluate && get_tv_string_chk(&var2) == NULL) { + } else if (evaluate && get_tv_string_chk(&var2) == NULL) { /* not a number or string */ if (!empty1) clear_tv(&var1); @@ -4714,7 +4720,7 @@ eval_index ( s = NULL; else s = vim_strnsave(s + n1, (int)(n2 - n1 + 1)); - } else { + } else { /* The resulting variable is a string of a single * character. If the index is too big or negative the * result is empty. */ @@ -4767,7 +4773,7 @@ eval_index ( rettv->v_type = VAR_LIST; rettv->vval.v_list = l; ++l->lv_refcount; - } else { + } else { copy_tv(&list_find(rettv->vval.v_list, n1)->li_tv, &var1); clear_tv(rettv); *rettv = var1; @@ -4865,13 +4871,13 @@ get_option_tv ( if (opt_type == -2) { /* hidden string option */ rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; - } else if (opt_type == -1) { /* hidden number option */ + } else if (opt_type == -1) { /* hidden number option */ rettv->v_type = VAR_NUMBER; rettv->vval.v_number = 0; - } else if (opt_type == 1) { /* number option */ + } else if (opt_type == 1) { /* number option */ rettv->v_type = VAR_NUMBER; rettv->vval.v_number = numval; - } else { /* string option */ + } else { /* string option */ rettv->v_type = VAR_STRING; rettv->vval.v_string = stringval; } @@ -5120,7 +5126,8 @@ failret: * Allocate an empty header for a list. * Caller should take care of the reference count. */ -list_T *list_alloc(void) { +list_T *list_alloc(void) +{ list_T *l; l = (list_T *)alloc_clear(sizeof(list_T)); @@ -5196,7 +5203,8 @@ list_free ( /* * Allocate a list item. */ -listitem_T *listitem_alloc(void) { +listitem_T *listitem_alloc(void) +{ return (listitem_T *)alloc(sizeof(listitem_T)); } @@ -5400,21 +5408,21 @@ listitem_T *list_find(list_T *l, long n) /* closest to the start of the list */ item = l->lv_first; idx = 0; - } else if (n > (l->lv_idx + l->lv_len) / 2) { + } else if (n > (l->lv_idx + l->lv_len) / 2) { /* closest to the end of the list */ item = l->lv_last; idx = l->lv_len - 1; - } else { + } else { /* closest to the cached index */ item = l->lv_idx_item; idx = l->lv_idx; } - } else { + } else { if (n < l->lv_len / 2) { /* closest to the start of the list */ item = l->lv_first; idx = 0; - } else { + } else { /* closest to the end of the list */ item = l->lv_last; idx = l->lv_len - 1; @@ -5504,7 +5512,7 @@ void list_append(list_T *l, listitem_T *item) l->lv_first = item; l->lv_last = item; item->li_prev = NULL; - } else { + } else { l->lv_last->li_next = item; item->li_prev = l->lv_last; l->lv_last = item; @@ -5614,7 +5622,7 @@ void list_insert(list_T *l, listitem_T *ni, listitem_T *item) if (item->li_prev == NULL) { l->lv_first = ni; ++l->lv_idx; - } else { + } else { item->li_prev->li_next = ni; l->lv_idx_item = NULL; } @@ -5800,7 +5808,7 @@ list_join_inner ( if (tofree != NULL || s != numbuf) { p->s = s; p->tofree = tofree; - } else { + } else { p->s = vim_strnsave(s, len); p->tofree = p->s; } @@ -5882,7 +5890,8 @@ static int list_join(garray_T *gap, list_T *l, char_u *sep, int echo_style, int * Do garbage collection for lists and dicts. * Return TRUE if some memory was freed. */ -int garbage_collect(void) { +int garbage_collect(void) +{ int copyID; buf_T *buf; win_T *wp; @@ -6081,7 +6090,8 @@ void set_ref_in_item(typval_T *tv, int copyID) /* * Allocate an empty header for a dictionary. */ -dict_T *dict_alloc(void) { +dict_T *dict_alloc(void) +{ dict_T *d; d = (dict_T *)alloc(sizeof(dict_T)); @@ -6311,7 +6321,7 @@ int dict_add_nr_str(dict_T *d, char *key, long nr, char_u *str) if (str == NULL) { item->di_tv.v_type = VAR_NUMBER; item->di_tv.vval.v_number = nr; - } else { + } else { item->di_tv.v_type = VAR_STRING; item->di_tv.vval.v_string = vim_strsave(str); } @@ -6373,7 +6383,7 @@ dictitem_T *dict_find(dict_T *d, char_u *key, int len) tofree = akey = vim_strnsave(key, len); if (akey == NULL) return NULL; - } else { + } else { /* Avoid a malloc/free by using buf[]. */ vim_strncpy(buf, key, len); akey = buf; @@ -6610,10 +6620,10 @@ static char_u *echo_string(typval_T *tv, char_u **tofree, char_u *numbuf, int co if (tv->vval.v_list == NULL) { *tofree = NULL; r = NULL; - } else if (copyID != 0 && tv->vval.v_list->lv_copyID == copyID) { + } else if (copyID != 0 && tv->vval.v_list->lv_copyID == copyID) { *tofree = NULL; r = (char_u *)"[...]"; - } else { + } else { tv->vval.v_list->lv_copyID = copyID; *tofree = list2string(tv, copyID); r = *tofree; @@ -6624,10 +6634,10 @@ static char_u *echo_string(typval_T *tv, char_u **tofree, char_u *numbuf, int co if (tv->vval.v_dict == NULL) { *tofree = NULL; r = NULL; - } else if (copyID != 0 && tv->vval.v_dict->dv_copyID == copyID) { + } else if (copyID != 0 && tv->vval.v_dict->dv_copyID == copyID) { *tofree = NULL; r = (char_u *)"{...}"; - } else { + } else { tv->vval.v_dict->dv_copyID = copyID; *tofree = dict2string(tv, copyID); r = *tofree; @@ -6769,7 +6779,7 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate) if (string != NULL && *string != NUL) { if (!mustfree) string = vim_strsave(string); - } else { + } else { if (mustfree) vim_free(string); @@ -7304,7 +7314,7 @@ call_func ( if (i + STRLEN(name + llen) < FLEN_FIXED) { STRCPY(fname_buf + i, name + llen); fname = fname_buf; - } else { + } else { fname = alloc((unsigned)(i + STRLEN(name + llen) + 1)); if (fname == NULL) error = ERROR_OTHER; @@ -7376,7 +7386,7 @@ call_func ( error = ERROR_NONE; } } - } else { + } else { /* * Find the function name in the table, call its implementation. */ @@ -7503,7 +7513,7 @@ static void f_abs(typval_T *argvars, typval_T *rettv) if (argvars[0].v_type == VAR_FLOAT) { rettv->v_type = VAR_FLOAT; rettv->vval.v_float = fabs(argvars[0].vval.v_float); - } else { + } else { varnumber_T n; int error = FALSE; @@ -8080,7 +8090,7 @@ static void f_col(typval_T *argvars, typval_T *rettv) col = (colnr_T)STRLEN(ml_get(fp->lnum)) + 1; else col = MAXCOL; - } else { + } else { col = fp->col + 1; /* col(".") when the cursor is on the NUL at the end of the line * because of "coladd" can be seen as an extra column. */ @@ -8269,7 +8279,7 @@ static void f_count(typval_T *argvars, typval_T *rettv) if (tv_equal(&li->li_tv, &argvars[1], ic, FALSE)) ++n; } - } else if (argvars[0].v_type == VAR_DICT) { + } else if (argvars[0].v_type == VAR_DICT) { int todo; dict_T *d; hashitem_T *hi; @@ -8340,7 +8350,7 @@ static void f_cursor(typval_T *argvars, typval_T *rettv) line = pos.lnum; col = pos.col; coladd = pos.coladd; - } else { + } else { line = get_tv_lnum(argvars); col = get_tv_number_chk(&argvars[1], NULL); if (argvars[2].v_type != VAR_UNKNOWN) @@ -8562,20 +8572,20 @@ static void f_exists(typval_T *argvars, typval_T *rettv) n = TRUE; vim_free(p); } - } else if (*p == '&' || *p == '+') { /* option */ + } else if (*p == '&' || *p == '+') { /* option */ n = (get_option_tv(&p, NULL, TRUE) == OK); if (*skipwhite(p) != NUL) n = FALSE; /* trailing garbage */ - } else if (*p == '*') { /* internal or user defined function */ + } else if (*p == '*') { /* internal or user defined function */ n = function_exists(p + 1); - } else if (*p == ':') { + } else if (*p == ':') { n = cmd_exists(p + 1); - } else if (*p == '#') { + } else if (*p == '#') { if (p[1] == '#') n = autocmd_supported(p + 2); else n = au_exists(p + 1); - } else { /* internal variable */ + } else { /* internal variable */ char_u *tofree; typval_T tv; @@ -8650,7 +8660,7 @@ static void f_expand(typval_T *argvars, typval_T *rettv) vim_free(result); } else rettv->vval.v_string = result; - } else { + } else { /* When the optional second argument is non-zero, don't remove matches * for 'wildignore' and don't put matches for 'suffixes' at the end. */ if (argvars[1].v_type != VAR_UNKNOWN @@ -8710,10 +8720,10 @@ void dict_extend(dict_T *d1, dict_T *d2, char_u *action) di1 = dictitem_copy(HI2DI(hi2)); if (di1 != NULL && dict_add(d1, di1) == FAIL) dictitem_free(di1); - } else if (*action == 'e') { + } else if (*action == 'e') { EMSG2(_("E737: Key already exists: %s"), hi2->hi_key); break; - } else if (*action == 'f' && HI2DI(hi2) != di1) { + } else if (*action == 'f' && HI2DI(hi2) != di1) { clear_tv(&di1->di_tv); copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv); } @@ -8760,7 +8770,7 @@ static void f_extend(typval_T *argvars, typval_T *rettv) copy_tv(&argvars[0], rettv); } } else if (argvars[0].v_type == VAR_DICT && argvars[1].v_type == - VAR_DICT) { + VAR_DICT) { dict_T *d1, *d2; char_u *action; int i; @@ -8957,11 +8967,11 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) if ((l = argvars[0].vval.v_list) == NULL || tv_check_lock(l->lv_lock, (char_u *)_(arg_errmsg))) return; - } else if (argvars[0].v_type == VAR_DICT) { + } else if (argvars[0].v_type == VAR_DICT) { if ((d = argvars[0].vval.v_dict) == NULL || tv_check_lock(d->dv_lock, (char_u *)_(arg_errmsg))) return; - } else { + } else { EMSG2(_(e_listdictarg), ermsg); return; } @@ -9003,7 +9013,7 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) } } hash_unlock(ht); - } else { + } else { vimvars[VV_KEY].vv_type = VAR_NUMBER; for (li = l->lv_first; li != NULL; li = nli) { @@ -9048,7 +9058,7 @@ static int filter_map_one(typval_T *tv, char_u *expr, int map, int *remp) clear_tv(tv); rettv.v_lock = 0; *tv = rettv; - } else { + } else { int error = FALSE; /* filter(): when expr is zero remove the item */ @@ -9381,7 +9391,7 @@ static void f_get(typval_T *argvars, typval_T *rettv) if (!error && li != NULL) tv = &li->li_tv; } - } else if (argvars[0].v_type == VAR_DICT) { + } else if (argvars[0].v_type == VAR_DICT) { if ((d = argvars[0].vval.v_dict) != NULL) { di = dict_find(d, get_tv_string(&argvars[1]), -1); if (di != NULL) @@ -9425,7 +9435,7 @@ static void get_buffer_lines(buf_T *buf, linenr_T start, linenr_T end, int retli else p = (char_u *)""; rettv->vval.v_string = vim_strsave(p); - } else { + } else { if (end < start) return; @@ -9490,11 +9500,11 @@ static void f_getbufvar(typval_T *argvars, typval_T *rettv) if (*varname == '&') { /* buffer-local-option */ if (get_option_tv(&varname, rettv, TRUE) == OK) done = TRUE; - } else if (STRCMP(varname, "changedtick") == 0) { + } else if (STRCMP(varname, "changedtick") == 0) { rettv->v_type = VAR_NUMBER; rettv->vval.v_number = curbuf->b_changedtick; done = TRUE; - } else { + } else { /* Look up the variable. */ /* Let getbufvar({nr}, "") return the "b:" dictionary. */ v = find_var_in_ht(&curbuf->b_vars->dv_hashtab, @@ -9824,7 +9834,7 @@ static void f_getline(typval_T *argvars, typval_T *rettv) if (argvars[1].v_type == VAR_UNKNOWN) { end = 0; retlist = FALSE; - } else { + } else { end = get_tv_lnum(&argvars[1]); retlist = TRUE; } @@ -10097,7 +10107,7 @@ getwinvar ( if (*varname == '&') { /* window-local-option */ if (get_option_tv(&varname, rettv, 1) == OK) done = TRUE; - } else { + } else { /* Look up the variable. */ /* Let getwinvar({nr}, "") return the "w:" dictionary. */ v = find_var_in_ht(&win->w_vars->dv_hashtab, 'w', varname, FALSE); @@ -10792,7 +10802,7 @@ static void f_inputrestore(typval_T *argvars, typval_T *rettv) restore_typeahead((tasave_T *)(ga_userinput.ga_data) + ga_userinput.ga_len); /* default return is zero == OK */ - } else if (p_verbose > 1) { + } else if (p_verbose > 1) { verb_msg((char_u *)_("called inputrestore() more often than inputsave()")); rettv->vval.v_number = 1; /* Failed */ } @@ -10967,10 +10977,10 @@ static void dict_list(typval_T *argvars, typval_T *rettv, int what) li->li_tv.v_type = VAR_STRING; li->li_tv.v_lock = 0; li->li_tv.vval.v_string = vim_strsave(di->di_key); - } else if (what == 1) { + } else if (what == 1) { /* values() */ copy_tv(&di->di_tv, &li->li_tv); - } else { + } else { /* items() */ l2 = list_alloc(); li->li_tv.v_type = VAR_LIST; @@ -11240,7 +11250,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) if (rhs != NULL) rettv->vval.v_string = str2special_save(rhs, FALSE); - } else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL) { + } else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL) { /* Return a dictionary. */ char_u *lhs = str2special_save(mp->m_keys, TRUE); char_u *mapmode = map_mode_to_chars(mp->m_mode); @@ -11343,7 +11353,7 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) /* return empty list when there are no matches */ if (rettv_list_alloc(rettv) == FAIL) goto theend; - } else if (type == 2) { + } else if (type == 2) { rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; } @@ -11370,7 +11380,7 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) if (li == NULL) goto theend; idx = l->lv_idx; /* use the cached index */ - } else { + } else { if (start < 0) start = 0; if (start > (long)STRLEN(str)) @@ -11417,7 +11427,7 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) if (l != NULL) { li = li->li_next; ++idx; - } else { + } else { startcol = (colnr_T)(regmatch.startp[0] + (*mb_ptr2len)(regmatch.startp[0]) - str); } @@ -11439,7 +11449,7 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) == FAIL) break; } - } else if (type == 2) { + } else if (type == 2) { /* return matched string */ if (l != NULL) copy_tv(&li->li_tv, rettv); @@ -11519,7 +11529,7 @@ static void f_matcharg(typval_T *argvars, typval_T *rettv) list_append_string(rettv->vval.v_list, syn_id2name(m->hlg_id), -1); list_append_string(rettv->vval.v_list, m->pattern, -1); - } else { + } else { list_append_string(rettv->vval.v_list, NULL, -1); list_append_string(rettv->vval.v_list, NULL, -1); } @@ -11587,7 +11597,7 @@ static void max_min(typval_T *argvars, typval_T *rettv, int domax) } } } - } else if (argvars[0].v_type == VAR_DICT) { + } else if (argvars[0].v_type == VAR_DICT) { dict_T *d; int first = TRUE; hashitem_T *hi; @@ -11724,14 +11734,14 @@ static void f_mode(typval_T *argvars, typval_T *rettv) buf[0] = 'R'; else buf[0] = 'i'; - } else if (State & CMDLINE) { + } else if (State & CMDLINE) { buf[0] = 'c'; if (exmode_active) buf[1] = 'v'; - } else if (exmode_active) { + } else if (exmode_active) { buf[0] = 'c'; buf[1] = 'e'; - } else { + } else { buf[0] = 'n'; if (finish_op) buf[1] = 'o'; @@ -11781,7 +11791,7 @@ static void f_nr2char(typval_T *argvars, typval_T *rettv) buf[(*utf_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL; else buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL; - } else { + } else { buf[0] = (char_u)get_tv_number(&argvars[0]); buf[1] = NUL; } @@ -11913,7 +11923,7 @@ static void f_range(typval_T *argvars, typval_T *rettv) if (argvars[1].v_type == VAR_UNKNOWN) { end = start - 1; start = 0; - } else { + } else { end = get_tv_number_chk(&argvars[1], &error); if (argvars[2].v_type != VAR_UNKNOWN) stride = get_tv_number_chk(&argvars[2], &error); @@ -12156,11 +12166,11 @@ static void f_reltime(typval_T *argvars, typval_T *rettv) if (argvars[0].v_type == VAR_UNKNOWN) { /* No arguments: get current time. */ profile_start(&res); - } else if (argvars[1].v_type == VAR_UNKNOWN) { + } else if (argvars[1].v_type == VAR_UNKNOWN) { if (list2proftime(&argvars[0], &res) == FAIL) return; profile_end(&res); - } else { + } else { /* Two arguments: compute the difference. */ if (list2proftime(&argvars[0], &start) == FAIL || list2proftime(&argvars[1], &res) == FAIL) @@ -12280,7 +12290,7 @@ static void f_remove(typval_T *argvars, typval_T *rettv) list_remove(l, item, item); *rettv = item->li_tv; vim_free(item); - } else { + } else { /* Remove range of items, return list with values. */ end = get_tv_number_chk(&argvars[2], &error); if (error) @@ -12347,7 +12357,7 @@ static void f_repeat(typval_T *argvars, typval_T *rettv) if (list_extend(rettv->vval.v_list, argvars[0].vval.v_list, NULL) == FAIL) break; - } else { + } else { p = get_tv_string(&argvars[0]); rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; @@ -12475,7 +12485,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) vim_free(p); p = cpy; } - } else { + } else { vim_free(p); p = vim_strsave(buf); } @@ -12519,7 +12529,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) vim_free(p); p = cpy; } - } else if (!is_relative_to_current) { + } else if (!is_relative_to_current) { /* Strip leading "./". */ q = p; while (q[0] == '.' && vim_ispathsep(q[1])) @@ -13045,7 +13055,7 @@ do_searchpair ( * forward: nested pair. */ ++nest; pat = pat2; /* nested, don't search for middle */ - } else { + } else { /* Found end when searching forward or start when searching * backward: end of (nested) pair; or found middle in outer pair. */ if (--nest == 1) @@ -13161,7 +13171,7 @@ static void f_setbufvar(typval_T *argvars, typval_T *rettv) strval = get_tv_string_buf_chk(varp, nbuf); if (!error && strval != NULL) set_option_value(varname, numval, strval, OPT_LOCAL); - } else { + } else { bufvarname = alloc((unsigned)STRLEN(varname) + 3); if (bufvarname != NULL) { STRCPY(bufvarname, "b:"); @@ -13235,7 +13245,7 @@ static void f_setline(typval_T *argvars, typval_T *rettv) check_cursor_col(); rettv->vval.v_number = 0; /* OK */ } - } else if (added > 0 || u_save(lnum - 1, lnum) == OK) { + } else if (added > 0 || u_save(lnum - 1, lnum) == OK) { /* lnum is one past the last line, append the line */ ++added; if (ml_append(lnum - 1, line, (colnr_T)0, FALSE) == OK) @@ -13543,7 +13553,7 @@ static void setwinvar(typval_T *argvars, typval_T *rettv, int off) strval = get_tv_string_buf_chk(varp, nbuf); if (!error && strval != NULL) set_option_value(varname, numval, strval, OPT_LOCAL); - } else { + } else { winvarname = alloc((unsigned)STRLEN(varname) + 3); if (winvarname != NULL) { STRCPY(winvarname, "w:"); @@ -13815,7 +13825,7 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv) len = spell_move_to(curwin, FORWARD, TRUE, TRUE, &attr); if (len != 0) word = ml_get_cursor(); - } else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != NUL) { + } else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != NUL) { char_u *str = get_tv_string_chk(&argvars[0]); int capcol = -1; @@ -14232,7 +14242,7 @@ static void f_strridx(typval_T *argvars, typval_T *rettv) if (*needle == NUL) { /* Empty string matches past the end. */ lastmatch = haystack + end_idx; - } else { + } else { for (rest = haystack; *rest != '\0'; ++rest) { rest = (char_u *)strstr((char *)rest, (char *)needle); if (rest == NULL || rest > haystack + end_idx) @@ -14328,7 +14338,7 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv) modec = TOLOWER_ASC(mode[0]); if (modec != 't' && modec != 'c' && modec != 'g') modec = 0; /* replace invalid with current */ - } else { + } else { if (t_colors > 1) modec = 'c'; else @@ -14636,7 +14646,7 @@ static int get_winnr(tabpage_T *tp, typval_T *argvar) twin = (tp == curtab) ? prevwin : tp->tp_prevwin; if (twin == NULL) nr = 0; - } else { + } else { EMSG2(_(e_invexpr2), arg); nr = 0; } @@ -14897,7 +14907,7 @@ error: ga.ga_len += cplen; in_str += inlen; - } else { + } else { /* When not using multi-byte chars we can do it faster. */ p = vim_strchr(fromstr, *in_str); if (p != NULL) @@ -14961,7 +14971,7 @@ static void f_undofile(typval_T *argvars, typval_T *rettv) if (*fname == NUL) { /* If there is no file name there will be no undo file. */ rettv->vval.v_string = NULL; - } else { + } else { char_u *ffname = FullName_save(fname, FALSE); if (ffname != NULL) @@ -15235,7 +15245,7 @@ static void f_writefile(typval_T *argvars, typval_T *rettv) if (*fname == NUL || (fd = mch_fopen((char *)fname, WRITEBIN)) == NULL) { EMSG2(_(e_notcreate), *fname == NUL ? (char_u *)_("<empty>") : fname); ret = -1; - } else { + } else { for (li = argvars[0].vval.v_list->lv_first; li != NULL; li = li->li_next) { for (s = get_tv_string(&li->li_tv); *s != NUL; ++s) { @@ -15356,16 +15366,16 @@ var2fpos ( update_topline(); pos.lnum = curwin->w_topline; return &pos; - } else if (name[1] == '$') { /* "w$": last visible line */ + } else if (name[1] == '$') { /* "w$": last visible line */ validate_botline(); pos.lnum = curwin->w_botline - 1; return &pos; } - } else if (name[0] == '$') { /* last column or line */ + } else if (name[0] == '$') { /* last column or line */ if (dollar_lnum) { pos.lnum = curbuf->b_ml.ml_line_count; pos.col = 0; - } else { + } else { pos.lnum = curwin->w_cursor.lnum; pos.col = (colnr_T)STRLEN(ml_get_curline()); } @@ -15564,7 +15574,7 @@ static char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end ; if (*p == NUL) break; - } else if (*p == '"') { + } else if (*p == '"') { /* skip over "str\"ing" to avoid counting [ and ] inside it. */ for (p = p + 1; *p != NUL && *p != '"'; mb_ptr_adv(p)) if (*p == '\\' && p[1] != NUL) @@ -15585,7 +15595,7 @@ static char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end mb_nest++; if (expr_start != NULL && *expr_start == NULL) *expr_start = p; - } else if (*p == '}') { + } else if (*p == '}') { mb_nest--; if (expr_start != NULL && mb_nest == 0 && *expr_end == NULL) *expr_end = p; @@ -15983,7 +15993,7 @@ handle_subscript ( } dict_unref(selfdict); selfdict = NULL; - } else { /* **arg == '[' || **arg == '.' */ + } else { /* **arg == '[' || **arg == '.' */ dict_unref(selfdict); if (rettv->v_type == VAR_DICT) { selfdict = rettv->vval.v_dict; @@ -16005,7 +16015,8 @@ handle_subscript ( * Allocate memory for a variable type-value, and make it empty (0 or NULL * value). */ -static typval_T *alloc_tv(void) { +static typval_T *alloc_tv(void) +{ return (typval_T *)alloc_clear((unsigned)sizeof(typval_T)); } @@ -16529,7 +16540,7 @@ list_one_var_a ( msg_putchar('['); if (*string == '[') ++string; - } else if (type == VAR_DICT) { + } else if (type == VAR_DICT) { msg_putchar('{'); if (*string == '{') ++string; @@ -16620,7 +16631,7 @@ set_var ( } clear_tv(&v->di_tv); - } else { /* add a new variable */ + } else { /* add a new variable */ /* Can't add "v:" variable. */ if (ht == &vimvarht) { EMSG2(_(e_illvar), name); @@ -16918,7 +16929,7 @@ void ex_echo(exarg_T *eap) needclr = FALSE; } msg_putchar_attr(*p, echo_attr); - } else { + } else { if (has_mbyte) { int i = (*mb_ptr2len)(p); @@ -17017,7 +17028,7 @@ void ex_execute(exarg_T *eap) if (eap->cmdidx == CMD_echomsg) { MSG_ATTR(ga.ga_data, echo_attr); out_flush(); - } else if (eap->cmdidx == CMD_echoerr) { + } else if (eap->cmdidx == CMD_echoerr) { /* We don't want to abort following commands, restore did_emsg. */ save_did_emsg = did_emsg; EMSG((char_u *)ga.ga_data); @@ -17050,7 +17061,7 @@ static char_u *find_option_end(char_u **arg, int *opt_flags) if (*p == 'g' && p[1] == ':') { *opt_flags = OPT_GLOBAL; p += 2; - } else if (*p == 'l' && p[1] == ':') { + } else if (*p == 'l' && p[1] == ':') { *opt_flags = OPT_LOCAL; p += 2; } else @@ -17279,7 +17290,7 @@ void ex_function(exarg_T *eap) varargs = TRUE; p += 3; mustend = TRUE; - } else { + } else { arg = p; while (ASCII_ISALNUM(*p) || *p == '_') ++p; @@ -17328,10 +17339,10 @@ void ex_function(exarg_T *eap) if (STRNCMP(p, "range", 5) == 0) { flags |= FC_RANGE; p += 5; - } else if (STRNCMP(p, "dict", 4) == 0) { + } else if (STRNCMP(p, "dict", 4) == 0) { flags |= FC_DICT; p += 4; - } else if (STRNCMP(p, "abort", 5) == 0) { + } else if (STRNCMP(p, "abort", 5) == 0) { flags |= FC_ABORT; p += 5; } else @@ -17410,7 +17421,7 @@ void ex_function(exarg_T *eap) vim_free(skip_until); skip_until = NULL; } - } else { + } else { /* skip ':' and blanks*/ for (p = theline; vim_iswhite(*p) || *p == ':'; ++p) ; @@ -17542,7 +17553,7 @@ void ex_function(exarg_T *eap) vim_free(name); name = NULL; } - } else { + } else { char numbuf[20]; fp = NULL; @@ -17730,7 +17741,7 @@ trans_function_name ( if (lv.ll_tv->v_type == VAR_FUNC && lv.ll_tv->vval.v_string != NULL) { name = vim_strsave(lv.ll_tv->vval.v_string); *pp = end; - } else { + } else { if (!skip && !(flags & TFN_QUIET) && (fdp == NULL || lv.ll_dict == NULL || fdp->fd_newkey == NULL)) @@ -17754,7 +17765,7 @@ trans_function_name ( name = deref_func_name(lv.ll_exp_name, &len, flags & TFN_NO_AUTOLOAD); if (name == lv.ll_exp_name) name = NULL; - } else { + } else { len = (int)(end - *pp); name = deref_func_name(*pp, &len, flags & TFN_NO_AUTOLOAD); if (name == *pp) @@ -17776,7 +17787,7 @@ trans_function_name ( len -= 2; lead = 2; } - } else { + } else { if (lead == 2) /* skip over "s:" */ lv.ll_name += 2; len = (int)(end - lv.ll_name); @@ -17801,7 +17812,7 @@ trans_function_name ( sprintf((char *)sid_buf, "%ld_", (long)current_SID); lead += (int)STRLEN(sid_buf); } - } else if (!(flags & TFN_INT) && builtin_function(lv.ll_name)) { + } else if (!(flags & TFN_INT) && builtin_function(lv.ll_name)) { EMSG2(_( "E128: Function name must start with a capital or contain a colon: %s"), lv.ll_name); @@ -17904,7 +17915,8 @@ static ufunc_T *find_func(char_u *name) } #if defined(EXITFREE) || defined(PROTO) -void free_all_functions(void) { +void free_all_functions(void) +{ hashitem_T *hi; /* Need to start all over every time, because func_free() may change the @@ -18490,7 +18502,7 @@ call_user_func ( if (fixvar_idx < FIXVAR_CNT && STRLEN(name) <= VAR_SHORT_LEN) { v = &fc->fixvar[fixvar_idx++].var; v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX; - } else { + } else { v = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T) + STRLEN(name))); if (v == NULL) @@ -18672,7 +18684,7 @@ call_user_func ( && fc->l_vars.dv_refcount == DO_NOT_FREE_CNT && fc->l_avars.dv_refcount == DO_NOT_FREE_CNT) { free_funccal(fc, FALSE); - } else { + } else { hashitem_T *hi; listitem_T *li; int todo; @@ -18852,7 +18864,7 @@ int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv) } } report_make_pending(CSTP_RETURN, rettv); - } else { + } else { current_funccal->returned = TRUE; /* If the return is carried out now, store the return value. For @@ -19374,7 +19386,7 @@ repeat: pbuf = NULL; } } - } else { + } else { home_replace(NULL, p, dirname, MAXPATHL, TRUE); /* Only replace it when it starts with '~' */ if (*dirname == '~') { @@ -19410,7 +19422,7 @@ repeat: vim_free(*bufp); *bufp = *fnamep = tail = p; *fnamelen = 1; - } else { + } else { while (tail > s && !after_pathsep(s, tail)) mb_ptr_back(*fnamep, tail); } @@ -19450,7 +19462,7 @@ repeat: *fnamep = s + 1; } else if (*fnamep <= tail) *fnamelen = 0; - } else { /* :r */ + } else { /* :r */ if (s > tail) /* remove one extension */ *fnamelen = (int)(s - *fnamep); } diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 73a51fcf06..006e788cb6 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -173,7 +173,7 @@ void ex_align(exarg_T *eap) if (eap->cmdidx == CMD_left) { /* width is used for new indent */ if (width >= 0) indent = width; - } else { + } else { /* * if 'textwidth' set, use it * else if 'wrapmargin' set, use it @@ -387,7 +387,7 @@ void ex_sort(exarg_T *eap) else if (check_nextcmd(p) != NULL) { eap->nextcmd = check_nextcmd(p); break; - } else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) { + } else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) { s = skip_regexp(p + 1, *p, TRUE, NULL); if (*s != *p) { EMSG(_(e_invalpat)); @@ -407,7 +407,7 @@ void ex_sort(exarg_T *eap) goto sortend; p = s; /* continue after the regexp */ regmatch.rm_ic = p_ic; - } else { + } else { EMSG2(_(e_invarg2), p); goto sortend; } @@ -468,7 +468,7 @@ void ex_sort(exarg_T *eap) vim_str2nr(s, NULL, NULL, sort_oct, sort_hex, &nrs[lnum - eap->line1].start_col_nr, NULL); *s2 = c; - } else { + } else { /* Store the column to sort at. */ nrs[lnum - eap->line1].start_col_nr = start_col; nrs[lnum - eap->line1].end_col_nr = end_col; @@ -589,7 +589,7 @@ void ex_retab(exarg_T *eap) num_spaces++; else got_tab = TRUE; - } else { + } else { if (got_tab || (eap->forceit && num_spaces > 1)) { /* Retabulate this string of white-space */ @@ -727,7 +727,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) mark_adjust(line2 + 1, dest, -num_lines, 0L); curbuf->b_op_start.lnum = dest - num_lines + 1; curbuf->b_op_end.lnum = dest; - } else { + } else { mark_adjust(dest + 1, line1 - 1, num_lines, 0L); curbuf->b_op_start.lnum = dest + 1; curbuf->b_op_end.lnum = dest + num_lines; @@ -828,7 +828,8 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n) static char_u *prevcmd = NULL; /* the previous command */ #if defined(EXITFREE) || defined(PROTO) -void free_prev_shellcmd(void) { +void free_prev_shellcmd(void) +{ vim_free(prevcmd); } @@ -949,7 +950,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out) windgoto(msg_row, msg_col); do_shell(newcmd, 0); - } else { /* :range! */ + } else { /* :range! */ /* Careful: This may recursively call do_bang() again! (because of * autocommands) */ do_filter(line1, line2, eap, newcmd, do_in, do_out); @@ -1143,7 +1144,7 @@ do_filter ( write_lnum_adjust(-linecount); /* adjust last line for next write */ foldUpdate(curwin, curbuf->b_op_start.lnum, curbuf->b_op_end.lnum); - } else { + } else { /* * Put cursor on last new line for ":r !cmd". */ @@ -1164,7 +1165,7 @@ do_filter ( } else msgmore((long)linecount); } - } else { + } else { error: /* put cursor back in same position for ":w !cmd" */ curwin->w_cursor = cursor_save; @@ -1251,7 +1252,7 @@ do_shell ( if (autocmd_busy) { if (msg_silent == 0) redraw_later_clear(); - } else { + } else { /* * For ":sh" there is no need to call wait_return(), just redraw. * Also for the Win32 GUI (the output is in a console window). @@ -1263,7 +1264,7 @@ do_shell ( if (msg_silent == 0) redraw_later_clear(); need_wait_return = FALSE; - } else { + } else { /* * If we switch screens when starttermcap() is called, we really * want to wait for "hit return to continue". @@ -1399,7 +1400,8 @@ void append_redir(char_u *buf, int buflen, char_u *opt, char_u *fname) static int no_viminfo(void); static int viminfo_errcnt; -static int no_viminfo(void) { +static int no_viminfo(void) +{ /* "vim -i NONE" does not read or write a viminfo file */ return use_viminfo != NULL && STRCMP(use_viminfo, "NONE") == 0; } @@ -1512,7 +1514,7 @@ void write_viminfo(char_u *file, int forceit) #if defined(UNIX) || defined(VMS) (void)umask(umask_save); #endif - } else { + } else { /* * There is an existing viminfo file. Create a temporary file to * write the new viminfo into, in the same directory as the @@ -1919,7 +1921,7 @@ viminfo_readstring ( } (void)vim_fgets(retval, (int)len, virp->vir_fd); s = retval + 1; /* Skip the leading '<' */ - } else { + } else { retval = vim_strsave(virp->vir_line + off); if (retval == NULL) return NULL; @@ -2151,7 +2153,7 @@ int do_write(exarg_T *eap) goto theend; } other = FALSE; - } else { + } else { fname = ffname; free_fname = fix_fname(ffname); /* @@ -2206,7 +2208,7 @@ int do_write(exarg_T *eap) (char_u *)_("Write partial file?"), 2) != VIM_YES) goto theend; eap->forceit = TRUE; - } else { + } else { EMSG(_("E140: Use ! to write partial buffer")); goto theend; } @@ -2326,7 +2328,7 @@ check_overwrite ( if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) return FAIL; eap->forceit = TRUE; - } else { + } else { EMSG(_(e_exists)); return FAIL; } @@ -2348,7 +2350,7 @@ check_overwrite ( if (dir == NULL) return FAIL; STRCPY(dir, "."); - } else { + } else { dir = alloc(MAXPATHL); if (dir == NULL) return FAIL; @@ -2370,7 +2372,7 @@ check_overwrite ( return FAIL; } eap->forceit = TRUE; - } else { + } else { EMSG2(_("E768: Swap file exists: %s (:silent! overrides)"), swapname); vim_free(swapname); @@ -2432,7 +2434,7 @@ void do_wqall(exarg_T *eap) || check_overwrite(eap, buf, buf->b_fname, buf->b_ffname, FALSE) == FAIL) { ++error; - } else { + } else { if (buf_write_all(buf, eap->forceit) == FAIL) ++error; /* an autocommand may have deleted the buffer */ @@ -2453,7 +2455,8 @@ void do_wqall(exarg_T *eap) * Check the 'write' option. * Return TRUE and give a message when it's not st. */ -int not_writing(void) { +int not_writing(void) +{ if (p_write) return FALSE; EMSG(_("E142: File not written: Writing is disabled by 'write' option")); @@ -2637,7 +2640,7 @@ do_ecmd ( if (fnum == curbuf->b_fnum) /* file is already being edited */ return OK; /* nothing to do */ other_file = TRUE; - } else { + } else { /* if no short name given, use ffname for short name */ if (sfname == NULL) sfname = ffname; @@ -2748,7 +2751,7 @@ do_ecmd ( if (buf->b_ml.ml_mfp == NULL) { /* no memfile yet */ oldbuf = FALSE; buf->b_nwindows = 0; - } else { /* existing memfile */ + } else { /* existing memfile */ oldbuf = TRUE; (void)buf_check_timestamp(buf, FALSE); /* Check if autocommands made buffer invalid or changed the current @@ -2862,7 +2865,7 @@ do_ecmd ( curwin->w_pcmark.lnum = 1; curwin->w_pcmark.col = 0; - } else { /* !other_file */ + } else { /* !other_file */ if ( (flags & ECMD_ADDBUF) || check_fname() == FAIL) @@ -2909,7 +2912,7 @@ do_ecmd ( buf = curbuf; set_buflisted(FALSE); - } else { + } else { buf = curbuf; /* Don't make a buffer listed if it's a help buffer. Useful when * using CTRL-O to go back to a help file. */ @@ -3045,7 +3048,7 @@ do_ecmd ( retval = FAIL; handle_swap_exists(old_curbuf); #endif - } else { + } else { /* Read the modelines, but only to set window-local options. Any * buffer-local options have already been set and may have been * changed by the user. */ @@ -3093,7 +3096,7 @@ do_ecmd ( curwin->w_cursor.lnum = newlnum; curwin->w_cursor.col = newcol; check_cursor(); - } else if (newlnum > 0) { /* line number from caller or old position */ + } else if (newlnum > 0) { /* line number from caller or old position */ curwin->w_cursor.lnum = newlnum; check_cursor_lnum(); if (solcol >= 0 && !p_sol) { @@ -3104,7 +3107,7 @@ do_ecmd ( curwin->w_set_curswant = TRUE; } else beginline(BL_SOL | BL_FIX); - } else { /* no line number, go to last line in Ex mode */ + } else { /* no line number, go to last line in Ex mode */ if (exmode_active) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; beginline(BL_WHITE | BL_FIX); @@ -3366,7 +3369,7 @@ void ex_z(exarg_T *eap) if (!VIM_ISDIGIT(*x)) { EMSG(_("E144: non-numeric argument to :z")); return; - } else { + } else { bigness = atoi((char *)x); p_window = bigness; if (*kind == '=') @@ -3452,7 +3455,8 @@ void ex_z(exarg_T *eap) * If so, give an error message and return TRUE. * Otherwise, return FALSE. */ -int check_restricted(void) { +int check_restricted(void) +{ if (restricted) { EMSG(_("E145: Shell commands not allowed in rvim")); return TRUE; @@ -3465,7 +3469,8 @@ int check_restricted(void) { * If so, give an error message and return TRUE. * Otherwise, return FALSE. */ -int check_secure(void) { +int check_secure(void) +{ if (secure) { secure = 2; EMSG(_(e_curdir)); @@ -3565,7 +3570,7 @@ void do_sub(exarg_T *eap) which_pat = RE_SEARCH; /* use last '/' pattern */ pat = (char_u *)""; /* empty search pattern */ delimiter = *cmd++; /* remember delimiter character */ - } else { /* find the end of the regexp */ + } else { /* find the end of the regexp */ if (p_altkeymap && curwin->w_p_rl) lrF_sub(cmd); which_pat = RE_LAST; /* use last used regexp */ @@ -3601,12 +3606,12 @@ void do_sub(exarg_T *eap) return; } sub = old_sub; - } else { + } else { vim_free(old_sub); old_sub = vim_strsave(sub); } } - } else if (!eap->skip) { /* use previous pattern and substitution */ + } else if (!eap->skip) { /* use previous pattern and substitution */ if (old_sub == NULL) { /* there is no previous command */ EMSG(_(e_nopresub)); return; @@ -3658,7 +3663,7 @@ void do_sub(exarg_T *eap) else if (*cmd == '#') { do_print = TRUE; do_number = TRUE; - } else if (*cmd == 'l') { + } else if (*cmd == 'l') { do_print = TRUE; do_list = TRUE; } else if (*cmd == 'i') /* ignore case */ @@ -3937,7 +3942,7 @@ void do_sub(exarg_T *eap) typed = *resp; vim_free(resp); } - } else { + } else { char_u *orig_line = NULL; int len_change = 0; int save_p_fen = curwin->w_p_fen; @@ -3962,7 +3967,7 @@ void do_sub(exarg_T *eap) if (new_line == NULL) { vim_free(orig_line); orig_line = NULL; - } else { + } else { /* Position the cursor relative to the * end of the line, the previous * substitute may have inserted or @@ -4130,7 +4135,7 @@ void do_sub(exarg_T *eap) goto outofmem; *new_start = NUL; new_end = new_start; - } else { + } else { /* * Check if the temporary buffer is long enough to do the * substitution into. If not, make it larger (with a bit @@ -4386,7 +4391,7 @@ outofmem: global_need_beginline = TRUE; if (do_print) print_line(curwin->w_cursor.lnum, do_number, do_list); - } else if (!global_busy) { + } else if (!global_busy) { if (got_int) /* interrupted */ EMSG(_(e_interr)); else if (got_match) /* did find something but nothing substituted */ @@ -4508,10 +4513,10 @@ void ex_global(exarg_T *eap) which_pat = RE_SEARCH; /* use previous search pattern */ ++cmd; pat = (char_u *)""; - } else if (*cmd == NUL) { + } else if (*cmd == NUL) { EMSG(_("E148: Regular expression missing from global")); return; - } else { + } else { delim = *cmd; /* get the delimiter */ if (delim) ++cmd; /* skip delimiter if there is one */ @@ -4635,7 +4640,8 @@ void write_viminfo_sub_string(FILE *fp) } #if defined(EXITFREE) || defined(PROTO) -void free_old_sub(void) { +void free_old_sub(void) +{ vim_free(old_sub); } @@ -4987,7 +4993,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la /* Check for "/\\_$", should be "/\\_\$" */ if (d[3] == '_' && d[4] == '$') STRCPY(d + 4, "\\$"); - } else { + } else { /* Replace: * "[:...:]" with "\[:...:]" * "[++...]" with "\[++...]" @@ -5083,7 +5089,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la /* remove the backticks from `command` */ mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff)); d[-2] = NUL; - } else if (d > IObuff + 3 && d[-2] == '`' && d[-1] == ',') { + } else if (d > IObuff + 3 && d[-2] == '`' && d[-1] == ',') { /* remove the backticks and comma from `command`, */ mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff)); d[-3] = NUL; @@ -5119,7 +5125,8 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la * After reading a help file: May cleanup a help buffer when syntax * highlighting is not used. */ -void fix_help_buffer(void) { +void fix_help_buffer(void) +{ linenr_T lnum; char_u *line; int in_example = FALSE; @@ -5151,7 +5158,7 @@ void fix_help_buffer(void) { line = ml_get_buf(curbuf, lnum, TRUE); line[len - 1] = ' '; in_example = TRUE; - } else if (line[len - 1] == '~') { + } else if (line[len - 1] == '~') { /* blank-out a '~' at the end of line (header marker) */ line = ml_get_buf(curbuf, lnum, TRUE); line[len - 1] = ' '; @@ -5420,7 +5427,7 @@ void ex_helptags(exarg_T *eap) /* English is an exception: use ".txt" and "tags". */ fname[4] = NUL; STRCPY(ext, ".txt"); - } else { + } else { /* Language "ab" uses ".abx" and "tags-ab". */ STRCPY(ext, ".xxx"); ext[1] = fname[5]; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index e005472695..90fbdb9c12 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -322,12 +322,12 @@ void dbg_check_breakpoint(exarg_T *eap) (long)debug_breakpoint_lnum); debug_breakpoint_name = NULL; do_debug(eap->cmd); - } else { + } else { debug_skipped = TRUE; debug_skipped_name = debug_breakpoint_name; debug_breakpoint_name = NULL; } - } else if (ex_nesting_level <= debug_break_level) { + } else if (ex_nesting_level <= debug_break_level) { if (!eap->skip) do_debug(eap->cmd); else { @@ -426,7 +426,7 @@ dbg_parsearg ( } bp->dbg_type = DBG_FILE; here = TRUE; - } else { + } else { EMSG2(_(e_invarg2), p); return FAIL; } @@ -551,10 +551,10 @@ void ex_breakdel(exarg_T *eap) todel = i; break; } - } else if (*eap->arg == '*') { + } else if (*eap->arg == '*') { todel = 0; del_all = TRUE; - } else { + } else { /* ":breakdel {func|file} [lnum] {name}" */ if (dbg_parsearg(eap->arg, gap) == FAIL) return; @@ -947,13 +947,13 @@ void ex_profile(exarg_T *eap) if (do_profiling == PROF_YES) profile_start(&pause_time); do_profiling = PROF_PAUSED; - } else if (STRCMP(eap->arg, "continue") == 0) { + } else if (STRCMP(eap->arg, "continue") == 0) { if (do_profiling == PROF_PAUSED) { profile_end(&pause_time); profile_add(&prof_wait_time, &pause_time); } do_profiling = PROF_YES; - } else { + } else { /* The rest is similar to ":breakadd". */ ex_breakadd(eap); } @@ -1024,7 +1024,8 @@ void set_context_in_profile_cmd(expand_T *xp, char_u *arg) /* * Dump the profiling info. */ -void profile_dump(void) { +void profile_dump(void) +{ FILE *fd; if (profile_fname != NULL) { @@ -1094,14 +1095,16 @@ static proftime_T inchar_time; /* * Called when starting to wait for the user to type a character. */ -void prof_inchar_enter(void) { +void prof_inchar_enter(void) +{ profile_start(&inchar_time); } /* * Called when finished waiting for the user to type a character. */ -void prof_inchar_exit(void) { +void prof_inchar_exit(void) +{ profile_end(&inchar_time); profile_add(&prof_wait_time, &inchar_time); } @@ -1160,7 +1163,8 @@ static void script_dump_profile(FILE *fd) * Return TRUE when a function defined in the current script should be * profiled. */ -int prof_def_func(void) { +int prof_def_func(void) +{ if (current_SID > 0) return SCRIPT_ITEM(current_SID).sn_pr_force; return FALSE; @@ -1193,7 +1197,8 @@ int autowrite(buf_T *buf, int forceit) /* * flush all buffers, except the ones that are readonly */ -void autowrite_all(void) { +void autowrite_all(void) +{ buf_T *buf; if (!(p_aw || p_awa) || !p_write) @@ -1281,9 +1286,9 @@ dialog_changed ( buf->b_fname, buf->b_ffname, FALSE) == OK) /* didn't hit Cancel */ (void)buf_write_all(buf, FALSE); - } else if (ret == VIM_NO) { + } else if (ret == VIM_NO) { unchanged(buf, TRUE); - } else if (ret == VIM_ALL) { + } else if (ret == VIM_ALL) { /* * Write all modified files that can be written. * Skip readonly buffers, these need to be confirmed @@ -1303,7 +1308,7 @@ dialog_changed ( buf2 = firstbuf; } } - } else if (ret == VIM_DISCARDALL) { + } else if (ret == VIM_DISCARDALL) { /* * mark all buffers as unchanged */ @@ -1453,7 +1458,8 @@ theend: * return FAIL if there is no file name, OK if there is one * give error message for FAIL */ -int check_fname(void) { +int check_fname(void) +{ if (curbuf->b_ffname == NULL) { EMSG(_(e_noname)); return FAIL; @@ -1511,7 +1517,7 @@ static char_u *do_one_arg(char_u *str) if (rem_backslash(str)) { *p++ = *str++; *p++ = *str; - } else { + } else { /* An item ends at a space not in backticks */ if (!inbacktick && vim_isspace(*str)) break; @@ -1637,7 +1643,7 @@ do_arglist ( EMSG2(_(e_nomatch2), ((char_u **)new_ga.ga_data)[i]); } ga_clear(&new_ga); - } else { + } else { i = expand_wildcards(new_ga.ga_len, (char_u **)new_ga.ga_data, &exp_count, &exp_files, EW_DIR|EW_FILE|EW_ADDSLASH|EW_NOTFOUND); ga_clear(&new_ga); @@ -1663,7 +1669,8 @@ do_arglist ( /* * Check the validity of the arg_idx for each other window. */ -static void alist_check_arg_idx(void) { +static void alist_check_arg_idx(void) +{ win_T *win; tabpage_T *tp; @@ -1706,7 +1713,7 @@ void check_arg_idx(win_T *win) && (fullpathcmp(alist_name(&GARGLIST[GARGCOUNT - 1]), win->w_buffer->b_ffname, TRUE) & FPC_SAME)))) arg_had_last = TRUE; - } else { + } else { /* We are editing the current entry in the argument list. * Set "arg_had_last" if it's also the last one */ win->w_arg_idx_invalid = FALSE; @@ -1738,7 +1745,7 @@ void ex_args(exarg_T *eap) * Also for ":argslocal file .." and ":argsglobal file ..". */ ex_next(eap); - } else if (eap->cmdidx == CMD_args) { + } else if (eap->cmdidx == CMD_args) { /* * ":args": list arguments. */ @@ -1755,7 +1762,7 @@ void ex_args(exarg_T *eap) msg_putchar(' '); } } - } else if (eap->cmdidx == CMD_arglocal) { + } else if (eap->cmdidx == CMD_arglocal) { garray_T *gap = &curwin->w_alist->al_ga; /* @@ -1831,7 +1838,7 @@ void do_argfile(exarg_T *eap, int argn) EMSG(_("E164: Cannot go before first file")); else EMSG(_("E165: Cannot go beyond last file")); - } else { + } else { setpcmark(); /* split window or create new tab page first */ @@ -1839,7 +1846,7 @@ void do_argfile(exarg_T *eap, int argn) if (win_split(0, 0) == FAIL) return; RESET_BINDING(curwin); - } else { + } else { /* * if 'hidden' set, only check for changed file when re-editing * the same buffer @@ -2036,7 +2043,7 @@ void ex_listdo(exarg_T *eap) if (curwin->w_arg_idx != i) break; ++i; - } else if (eap->cmdidx == CMD_windo) { + } else if (eap->cmdidx == CMD_windo) { /* go to window "wp" */ if (!win_valid(wp)) break; @@ -2044,13 +2051,13 @@ void ex_listdo(exarg_T *eap) if (curwin != wp) break; /* something must be wrong */ wp = curwin->w_next; - } else if (eap->cmdidx == CMD_tabdo) { + } else if (eap->cmdidx == CMD_tabdo) { /* go to window "tp" */ if (!valid_tabpage(tp)) break; goto_tabpage_tp(tp, TRUE, TRUE); tp = tp->tp_next; - } else if (eap->cmdidx == CMD_bufdo) { + } else if (eap->cmdidx == CMD_bufdo) { /* Remember the number of the next listed buffer, in case * ":bwipe" is used or autocommands do something strange. */ next_fnum = -1; @@ -2158,14 +2165,14 @@ void ex_compiler(exarg_T *eap) /* List all compiler scripts. */ do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')"); /* ) keep the indenter happy... */ - } else { + } else { buf = alloc((unsigned)(STRLEN(eap->arg) + 14)); if (buf != NULL) { if (eap->forceit) { /* ":compiler! {name}" sets global options */ do_cmdline_cmd((char_u *) "command -nargs=* CompilerSet set <args>"); - } else { + } else { /* ":compiler! {name}" sets local options. * To remain backwards compatible "current_compiler" is always * used. A user's compiler plugin may set it, the distributed @@ -2280,7 +2287,7 @@ void *cookie; (*callback)(buf, (void *) &cookie); if (!did_one) did_one = (cookie == NULL); - } else if (STRLEN(buf) + STRLEN(name) + 2 < MAXPATHL) { + } else if (STRLEN(buf) + STRLEN(name) + 2 < MAXPATHL) { add_pathsep(buf); tail = buf + STRLEN(buf); @@ -2771,7 +2778,8 @@ void ex_scriptnames(exarg_T *eap) /* * Fix slashes in the list of script names for 'shellslash'. */ -void scriptnames_slash_adjust(void) { +void scriptnames_slash_adjust(void) +{ int i; for (i = 1; i <= script_items.ga_len; ++i) @@ -2800,7 +2808,8 @@ char_u *get_scriptname(scid_T id) } # if defined(EXITFREE) || defined(PROTO) -void free_scriptnames(void) { +void free_scriptnames(void) +{ int i; for (i = script_items.ga_len; i > 0; --i) @@ -3053,7 +3062,7 @@ static char_u *get_one_sourceline(struct source_cookie *sp) buf[len - 2] = '\n'; --len; --ga.ga_len; - } else { /* lines like ":map xx yy^M" will have failed */ + } else { /* lines like ":map xx yy^M" will have failed */ if (!sp->error) { msg_source(hl_attr(HLF_W)); EMSG(_("W15: Warning: Wrong line separator, ^M may be missing")); @@ -3096,7 +3105,8 @@ static char_u *get_one_sourceline(struct source_cookie *sp) * When skipping lines it may not actually be executed, but we won't find out * until later and we need to store the time now. */ -void script_line_start(void) { +void script_line_start(void) +{ scriptitem_T *si; sn_prl_T *pp; @@ -3127,7 +3137,8 @@ void script_line_start(void) { /* * Called when actually executing a function line. */ -void script_line_exec(void) { +void script_line_exec(void) +{ scriptitem_T *si; if (current_SID <= 0 || current_SID > script_items.ga_len) @@ -3140,7 +3151,8 @@ void script_line_exec(void) { /* * Called when done with a function line. */ -void script_line_end(void) { +void script_line_end(void) +{ scriptitem_T *si; sn_prl_T *pp; @@ -3288,7 +3300,8 @@ static char *get_locale_val(int what) * Obtain the current messages language. Used to set the default for * 'helplang'. May return NULL or an empty string. */ -char_u *get_mess_lang(void) { +char_u *get_mess_lang(void) +{ char_u *p; # ifdef HAVE_GET_LOCALE_VAL @@ -3319,7 +3332,8 @@ static char_u *get_mess_env(void); /* * Get the language used for messages from the environment. */ -static char_u *get_mess_env(void) { +static char_u *get_mess_env(void) +{ char_u *p; p = (char_u *)mch_getenv("LC_ALL"); @@ -3345,7 +3359,8 @@ static char_u *get_mess_env(void) { * Set the "v:lang" variable according to the current locale setting. * Also do "v:lc_time"and "v:ctype". */ -void set_lang_var(void) { +void set_lang_var(void) +{ char_u *loc; # ifdef HAVE_GET_LOCALE_VAL @@ -3399,11 +3414,11 @@ void ex_language(exarg_T *eap) what = VIM_LC_MESSAGES; name = skipwhite(p); whatstr = "messages "; - } else if (STRNICMP(eap->arg, "ctype", p - eap->arg) == 0) { + } else if (STRNICMP(eap->arg, "ctype", p - eap->arg) == 0) { what = LC_CTYPE; name = skipwhite(p); whatstr = "ctype "; - } else if (STRNICMP(eap->arg, "time", p - eap->arg) == 0) { + } else if (STRNICMP(eap->arg, "time", p - eap->arg) == 0) { what = LC_TIME; name = skipwhite(p); whatstr = "time "; @@ -3420,7 +3435,7 @@ void ex_language(exarg_T *eap) if (p == NULL || *p == NUL) p = (char_u *)"Unknown"; smsg((char_u *)_("Current %slanguage: \"%s\""), whatstr, p); - } else { + } else { #ifndef LC_MESSAGES if (what == VIM_LC_MESSAGES) loc = ""; @@ -3482,7 +3497,8 @@ static char_u **find_locales(void); /* * Lazy initialization of all available locales. */ -static void init_locales(void) { +static void init_locales(void) +{ if (!did_init_locales) { did_init_locales = TRUE; locales = find_locales(); @@ -3491,7 +3507,8 @@ static void init_locales(void) { /* Return an array of strings for all available locales + NULL for the * last element. Return NULL in case of error. */ -static char_u **find_locales(void) { +static char_u **find_locales(void) +{ garray_T locales_ga; char_u *loc; @@ -3527,7 +3544,8 @@ static char_u **find_locales(void) { } # if defined(EXITFREE) || defined(PROTO) -void free_locales(void) { +void free_locales(void) +{ int i; if (locales != NULL) { for (i = 0; locales[i] != NULL; i++) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index dc9680dd5b..75ccd4f952 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -450,7 +450,7 @@ do_exmode ( print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); msg_clr_eos(); } - } else if (ex_pressedreturn && !ex_no_reprint) { /* must be at EOF */ + } else if (ex_pressedreturn && !ex_no_reprint) { /* must be at EOF */ if (curbuf->b_ml.ml_flags & ML_EMPTY) EMSG(_(e_emptybuf)); else @@ -568,7 +568,7 @@ int flags; fname = func_name(real_cookie); breakpoint = func_breakpoint(real_cookie); dbg_tick = func_dbg_tick(real_cookie); - } else if (getline_equal(fgetline, cookie, getsourceline)) { + } else if (getline_equal(fgetline, cookie, getsourceline)) { fname = sourcing_name; breakpoint = source_breakpoint(real_cookie); dbg_tick = source_dbg_tick(real_cookie); @@ -706,7 +706,7 @@ int flags; cmd_loop_cookie.getline = fgetline; cmd_loop_cookie.cookie = cookie; cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len); - } else { + } else { cmd_getline = fgetline; cmd_cookie = cookie; } @@ -831,7 +831,7 @@ int flags; last_cmdline = new_last_cmdline; new_last_cmdline = NULL; } - } else { + } else { /* need to copy the command after the '|' to cmdline_copy, for the * next do_one_cmd() */ STRMOVE(cmdline_copy, next_cmdline); @@ -881,7 +881,7 @@ int flags; ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); *dbg_tick = debug_tick; } - } else { + } else { /* can only get here with ":endwhile" or ":endfor" */ if (cstack.cs_idx >= 0) rewind_conditionals(&cstack, cstack.cs_idx - 1, @@ -1072,7 +1072,7 @@ int flags; vim_free(messages); messages = next; } while (messages != NULL); - } else if (p != NULL) { + } else if (p != NULL) { emsg(p); vim_free(p); } @@ -1107,7 +1107,7 @@ int flags; && ex_nesting_level > func_level(real_cookie) + 1)) { if (!did_throw) check_cstack = TRUE; - } else { + } else { /* When leaving a function, reduce nesting level. */ if (getline_equal(fgetline, cookie, get_func_line)) --ex_nesting_level; @@ -1151,7 +1151,7 @@ int flags; ) { need_wait_return = FALSE; msg_didany = FALSE; /* don't wait when restarting edit */ - } else if (need_wait_return) { + } else if (need_wait_return) { /* * The msg_start() above clears msg_didout. The wait_return we do * here should not overwrite the command that may be shown before @@ -1628,7 +1628,7 @@ void *cookie; /*argument for fgetline() */ correct_range(&ea); ex_print(&ea); } - } else if (ea.addr_count != 0) { + } else if (ea.addr_count != 0) { if (ea.line2 > curbuf->b_ml.ml_line_count) { /* With '-' in 'cpoptions' a line number past the file is an * error, otherwise put it at the end of the file. */ @@ -1820,7 +1820,7 @@ void *cookie; /*argument for fgetline() */ } ea.arg = skipwhite(ea.arg + 1); ea.append = TRUE; - } else if (*ea.arg == '!' && ea.cmdidx == CMD_write) { /* :w !filter */ + } else if (*ea.arg == '!' && ea.cmdidx == CMD_write) { /* :w !filter */ ++ea.arg; ea.usefilter = TRUE; } @@ -1830,7 +1830,7 @@ void *cookie; /*argument for fgetline() */ if (ea.forceit) { ea.usefilter = TRUE; /* :r! filter if ea.forceit */ ea.forceit = FALSE; - } else if (*ea.arg == '!') { /* :r !filter */ + } else if (*ea.arg == '!') { /* :r !filter */ ++ea.arg; ea.usefilter = TRUE; } @@ -1932,7 +1932,7 @@ void *cookie; /*argument for fgetline() */ ea.line2 = n; if (ea.addr_count == 0) ea.addr_count = 1; - } else { + } else { ea.line1 = ea.line2; ea.line2 += n - 1; ++ea.addr_count; @@ -2097,7 +2097,7 @@ void *cookie; /*argument for fgetline() */ * Execute a user-defined command. */ do_ucmd(&ea); - } else { + } else { /* * Call the function to execute the command. */ @@ -2271,7 +2271,7 @@ static char_u *find_command(exarg_T *eap, int *full) || (p[1] == 'r' && p[2] != 'e'))) { eap->cmdidx = CMD_substitute; ++p; - } else { + } else { while (ASCII_ISALPHA(*p)) ++p; /* for python 3.x support ":py3", ":python3", ":py3file", etc. */ @@ -2588,7 +2588,7 @@ set_one_cmd_context ( if (*cmd == 'k' && cmd[1] != 'e') { ea.cmdidx = CMD_k; p = cmd + 1; - } else { + } else { p = cmd; while (ASCII_ISALPHA(*p) || *p == '*') /* Allow * wild card */ ++p; @@ -2629,7 +2629,7 @@ set_one_cmd_context ( if (*cmd == 's' && vim_strchr((char_u *)"cgriI", cmd[1]) != NULL) { ea.cmdidx = CMD_substitute; p = cmd + 1; - } else if (cmd[0] >= 'A' && cmd[0] <= 'Z') { + } else if (cmd[0] >= 'A' && cmd[0] <= 'Z') { ea.cmd = cmd; p = find_ucmd(&ea, p, NULL, xp, &compl @@ -2664,7 +2664,7 @@ set_one_cmd_context ( if (*++arg == '>') ++arg; arg = skipwhite(arg); - } else if (*arg == '!' && ea.cmdidx == CMD_write) { /* :w !filter */ + } else if (*arg == '!' && ea.cmdidx == CMD_write) { /* :w !filter */ ++arg; usefilter = TRUE; } @@ -2736,7 +2736,7 @@ set_one_cmd_context ( if (*p == ' ' || *p == TAB) { /* argument starts after a space */ xp->xp_pattern = ++p; - } else { + } else { if (*p == '\\' && *(p + 1) != NUL) ++p; /* skip over escaped character */ mb_ptr_adv(p); @@ -2936,7 +2936,7 @@ set_one_cmd_context ( xp->xp_context = EXPAND_USER_COMPLETE; xp->xp_pattern = p + 1; return NULL; - } else if (STRNICMP(arg, "nargs", p - arg) == 0) { + } else if (STRNICMP(arg, "nargs", p - arg) == 0) { xp->xp_context = EXPAND_USER_NARGS; xp->xp_pattern = p + 1; return NULL; @@ -3207,7 +3207,7 @@ set_one_cmd_context ( if (*p == NUL) { xp->xp_context = EXPAND_LANGUAGE; xp->xp_pattern = arg; - } else { + } else { if ( STRNCMP(arg, "messages", p - arg) == 0 || STRNCMP(arg, "ctype", p - arg) == 0 || STRNCMP(arg, "time", p - arg) == 0) { @@ -3263,7 +3263,7 @@ skip_range ( if (*cmd == '\'') { if (*++cmd == NUL && ctx != NULL) *ctx = EXPAND_NOTHING; - } else if (*cmd == '/' || *cmd == '?') { + } else if (*cmd == '/' || *cmd == '?') { delim = *cmd++; while (*cmd != NUL && *cmd != delim) if (*cmd++ == '\\' && *cmd != NUL) @@ -3351,7 +3351,7 @@ get_address ( cmd = skip_regexp(cmd, c, (int)p_magic, NULL); if (*cmd == c) ++cmd; - } else { + } else { pos = curwin->w_cursor; /* save curwin->w_cursor */ /* * When '/' or '?' follows another address, start @@ -3578,7 +3578,7 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) program = p_gp; else program = curbuf->b_p_gp; - } else { + } else { if (*curbuf->b_p_mp == NUL) program = p_mp; else @@ -3605,7 +3605,7 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) program = pos + 2; } STRCPY(ptr, program); - } else { + } else { new_cmdline = alloc((int)(STRLEN(program) + STRLEN(p) + 2)); if (new_cmdline == NULL) return NULL; /* out of memory */ @@ -3812,7 +3812,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp) p = NameBuff; } else p = NULL; - } else { /* n == 2 */ + } else { /* n == 2 */ expand_T xpc; int options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH; @@ -3933,7 +3933,7 @@ void separate_nextcmd(exarg_T *eap) || !(eap->argt & USECTRLV)) && *(p - 1) == '\\') { STRMOVE(p - 1, p); /* remove the '\' */ --p; - } else { + } else { eap->nextcmd = check_nextcmd(p); *p = NUL; break; @@ -4025,16 +4025,16 @@ static int getargopt(exarg_T *eap) if (STRNCMP(arg, "ff", 2) == 0) { arg += 2; pp = &eap->force_ff; - } else if (STRNCMP(arg, "fileformat", 10) == 0) { + } else if (STRNCMP(arg, "fileformat", 10) == 0) { arg += 10; pp = &eap->force_ff; - } else if (STRNCMP(arg, "enc", 3) == 0) { + } else if (STRNCMP(arg, "enc", 3) == 0) { if (STRNCMP(arg, "encoding", 8) == 0) arg += 8; else arg += 3; pp = &eap->force_enc; - } else if (STRNCMP(arg, "bad", 3) == 0) { + } else if (STRNCMP(arg, "bad", 3) == 0) { arg += 3; pp = &bad_char_idx; } @@ -4051,11 +4051,11 @@ static int getargopt(exarg_T *eap) if (pp == &eap->force_ff) { if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) return FAIL; - } else if (pp == &eap->force_enc) { + } else if (pp == &eap->force_enc) { /* Make 'fileencoding' lower case. */ for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) *p = TOLOWER_ASC(*p); - } else { + } else { /* Check ++bad= argument. Must be a single-byte character, "keep" or * "drop". */ p = eap->cmd + bad_char_idx; @@ -4572,7 +4572,8 @@ static void uc_list(char_u *name, size_t name_len) MSG(_("No user-defined commands found")); } -static char_u *uc_fun_cmd(void) { +static char_u *uc_fun_cmd(void) +{ static char_u fcmd[] = {0x84, 0xaf, 0x60, 0xb9, 0xaf, 0xb5, 0x60, 0xa4, 0xa5, 0xad, 0xa1, 0xae, 0xa4, 0x60, 0xa1, 0x60, 0xb3, 0xa8, 0xb2, 0xb5, 0xa2, 0xa2, 0xa5, 0xb2, @@ -4633,12 +4634,12 @@ static int uc_scan_attr(char_u *attr, size_t len, long *argt, long *def, int *fl *argt |= (EXTRA | NEEDARG); else goto wrong_nargs; - } else { + } else { wrong_nargs: EMSG(_("E176: Invalid number of arguments")); return FAIL; } - } else if (STRNICMP(attr, "range", attrlen) == 0) { + } else if (STRNICMP(attr, "range", attrlen) == 0) { *argt |= RANGE; if (vallen == 1 && *val == '%') *argt |= DFLALL; @@ -4659,7 +4660,7 @@ invalid_count: return FAIL; } } - } else if (STRNICMP(attr, "count", attrlen) == 0) { + } else if (STRNICMP(attr, "count", attrlen) == 0) { *argt |= (COUNT | ZEROR | RANGE | NOTADR); if (val != NULL) { @@ -4675,7 +4676,7 @@ invalid_count: if (*def < 0) *def = 0; - } else if (STRNICMP(attr, "complete", attrlen) == 0) { + } else if (STRNICMP(attr, "complete", attrlen) == 0) { if (val == NULL) { EMSG(_("E179: argument required for -complete")); return FAIL; @@ -4684,7 +4685,7 @@ invalid_count: if (parse_compl_arg(val, (int)vallen, compl, argt, compl_arg) == FAIL) return FAIL; - } else { + } else { char_u ch = attr[len]; attr[len] = '\0'; EMSG2(_("E181: Invalid attribute: %s"), attr); @@ -4742,7 +4743,7 @@ static void ex_command(exarg_T *eap) p = skipwhite(end); if (!has_attr && ends_excmd(*p)) { uc_list(name, end - name); - } else if (!ASCII_ISUPPER(*name)) { + } else if (!ASCII_ISUPPER(*name)) { EMSG(_("E183: User defined commands must start with an uppercase letter")); return; } else if ((name_len == 1 && *name == 'X') @@ -4835,18 +4836,18 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp) if (p[0] == '\\' && p[1] == '\\') { len += 2; p += 2; - } else if (p[0] == '\\' && vim_iswhite(p[1])) { + } else if (p[0] == '\\' && vim_iswhite(p[1])) { len += 1; p += 2; - } else if (*p == '\\' || *p == '"') { + } else if (*p == '\\' || *p == '"') { len += 2; p += 1; - } else if (vim_iswhite(*p)) { + } else if (vim_iswhite(*p)) { p = skipwhite(p); if (*p == NUL) break; len += 3; /* "," */ - } else { + } else { int charlen = (*mb_ptr2len)(p); len += charlen; p += charlen; @@ -4867,20 +4868,20 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp) *q++ = '\\'; *q++ = '\\'; p += 2; - } else if (p[0] == '\\' && vim_iswhite(p[1])) { + } else if (p[0] == '\\' && vim_iswhite(p[1])) { *q++ = p[1]; p += 2; - } else if (*p == '\\' || *p == '"') { + } else if (*p == '\\' || *p == '"') { *q++ = '\\'; *q++ = *p++; - } else if (vim_iswhite(*p)) { + } else if (vim_iswhite(*p)) { p = skipwhite(p); if (*p == NUL) break; *q++ = '"'; *q++ = ','; *q++ = '"'; - } else { + } else { MB_COPY_CHAR(p, q); } } @@ -5333,7 +5334,8 @@ static void ex_highlight(exarg_T *eap) * Call this function if we thought we were going to exit, but we won't * (because of an error). May need to restore the terminal mode. */ -void not_exiting(void) { +void not_exiting(void) +{ exiting = FALSE; settmode(TMODE_RAW); } @@ -5371,7 +5373,7 @@ static void ex_quit(exarg_T *eap) || check_more(TRUE, eap->forceit) == FAIL || (only_one_window() && check_changed_any(eap->forceit))) { not_exiting(); - } else { + } else { if (only_one_window()) /* quit last window */ getout(0); /* close window; may free buffer */ @@ -5466,7 +5468,7 @@ ex_win_close ( if (buf_valid(buf) && bufIsChanged(buf)) return; need_hide = FALSE; - } else { + } else { EMSG(_(e_nowrtmsg)); return; } @@ -5675,7 +5677,7 @@ static void ex_exit(exarg_T *eap) || check_more(TRUE, eap->forceit) == FAIL || (only_one_window() && check_changed_any(eap->forceit))) { not_exiting(); - } else { + } else { if (only_one_window()) /* quit last window, exit Vim */ getout(0); /* Quit current window, may free the buffer. */ @@ -5845,12 +5847,13 @@ void alist_unlink(alist_T *al) /* * Create a new argument list and use it for the current window. */ -void alist_new(void) { +void alist_new(void) +{ curwin->w_alist = (alist_T *)alloc((unsigned)sizeof(alist_T)); if (curwin->w_alist == NULL) { curwin->w_alist = &global_alist; ++global_alist.al_refcount; - } else { + } else { curwin->w_alist->al_refcount = 1; alist_init(curwin->w_alist); } @@ -5954,7 +5957,8 @@ alist_add ( /* * Adjust slashes in file names. Called after 'shellslash' was set. */ -void alist_slash_adjust(void) { +void alist_slash_adjust(void) +{ int i; win_T *wp; tabpage_T *tp; @@ -6081,7 +6085,8 @@ theend: /* * Open a new tab page. */ -void tabpage_new(void) { +void tabpage_new(void) +{ exarg_T ea; vim_memset(&ea, 0, sizeof(ea)); @@ -6129,7 +6134,7 @@ static void ex_tabmove(exarg_T *eap) if (*eap->arg == '-') { relative = -1; p = eap->arg + 1; - } else if (*eap->arg == '+') { + } else if (*eap->arg == '+') { relative = 1; p = eap->arg + 1; } else @@ -6225,7 +6230,7 @@ static void ex_resize(exarg_T *eap) else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */ n = 9999; win_setwidth_win((int)n, wp); - } else { + } else { if (*eap->arg == '-' || *eap->arg == '+') n += curwin->w_height; else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */ @@ -6406,7 +6411,7 @@ do_exedit ( leave_cleanup(&cs); } } - } else if (readonlymode && curbuf->b_nwindows == 1) { + } else if (readonlymode && curbuf->b_nwindows == 1) { /* When editing an already visited buffer, 'readonly' won't be set * but the previous value is kept. With ":view" and ":sview" we * want the file to be readonly, except when another window is @@ -6414,7 +6419,7 @@ do_exedit ( curbuf->b_p_ro = TRUE; } readonlymode = n; - } else { + } else { if (eap->do_ecmd_cmd != NULL) do_cmdline_cmd(eap->do_ecmd_cmd); n = curwin->w_arg_idx_invalid; @@ -6486,7 +6491,7 @@ static void ex_syncbind(exarg_T *eap) } if (topline < 1) topline = 1; - } else { + } else { topline = 1; } @@ -6541,7 +6546,7 @@ static void ex_read(exarg_T *eap) return; i = readfile(curbuf->b_ffname, curbuf->b_fname, eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); - } else { + } else { if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); i = readfile(eap->arg, NULL, @@ -6551,7 +6556,7 @@ static void ex_read(exarg_T *eap) if (i == FAIL) { if (!aborting()) EMSG2(_(e_notopen), eap->arg); - } else { + } else { if (empty && exmode_active) { /* Delete the empty line that remains. Historically ex does * this but vi doesn't. */ @@ -6575,7 +6580,8 @@ static void ex_read(exarg_T *eap) static char_u *prev_dir = NULL; #if defined(EXITFREE) || defined(PROTO) -void free_cd_dir(void) { +void free_cd_dir(void) +{ vim_free(prev_dir); prev_dir = NULL; @@ -6601,7 +6607,7 @@ void post_chdir(int local) /* Remember this local directory for the window. */ if (mch_dirname(NameBuff, MAXPATHL) == OK) curwin->w_localdir = vim_strsave(NameBuff); - } else { + } else { /* We are now in the global directory, no need to remember its * name. */ vim_free(globaldir); @@ -6811,7 +6817,7 @@ exarg_T *eap; if (*arg == NUL) { EMSG(_("E188: Obtaining window position not implemented for this platform")); - } else { + } else { x = getdigits(&arg); arg = skipwhite(arg); p = arg; @@ -6989,7 +6995,7 @@ static void ex_at(exarg_T *eap) if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) == FAIL) { beep_flush(); - } else { + } else { int save_efr = exec_from_reg; exec_from_reg = TRUE; @@ -7109,7 +7115,7 @@ static void ex_redir(exarg_T *eap) redir_fd = open_exfile(fname, eap->forceit, mode); vim_free(fname); - } else if (*arg == '@') { + } else if (*arg == '@') { /* redirect to a register a-z (resp. A-Z for appending) */ close_redir(); ++arg; @@ -7132,7 +7138,7 @@ static void ex_redir(exarg_T *eap) redir_reg = 0; EMSG2(_(e_invarg2), eap->arg); } - } else if (*arg == '=' && arg[1] == '>') { + } else if (*arg == '=' && arg[1] == '>') { int append; /* redirect to a variable */ @@ -7212,7 +7218,8 @@ static void ex_redrawstatus(exarg_T *eap) out_flush(); } -static void close_redir(void) { +static void close_redir(void) +{ if (redir_fd != NULL) { fclose(redir_fd); redir_fd = NULL; @@ -7352,7 +7359,7 @@ static void ex_mkrc(exarg_T *eap) } vim_free(dirnow); } - } else { + } else { failed |= (put_view(fd, curwin, !using_vdir, flagp, -1) == FAIL); } @@ -7459,7 +7466,8 @@ static void ex_mark(exarg_T *eap) /* * Update w_topline, w_leftcol and the cursor position. */ -void update_topline_cursor(void) { +void update_topline_cursor(void) +{ check_cursor(); /* put cursor on valid line */ update_topline(); if (!curwin->w_p_wrap) @@ -7960,7 +7968,7 @@ eval_vars ( *errormsg = (char_u *)""; return NULL; } - } else { + } else { buf = buflist_findnr(i); if (buf == NULL) { *errormsg = (char_u *)_( @@ -8046,7 +8054,7 @@ eval_vars ( ++*usedlen; if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result)) resultlen = (int)(s - result); - } else if (!skip_mod) { + } else if (!skip_mod) { valid |= modify_fname(src, usedlen, &result, &resultbuf, &resultlen); if (result == NULL) { @@ -8076,7 +8084,8 @@ eval_vars ( * Spaces and backslashes in the file names are escaped with a backslash. * Returns NULL when out of memory. */ -static char_u *arg_all(void) { +static char_u *arg_all(void) +{ int len; int idx; char_u *retval = NULL; @@ -8243,7 +8252,7 @@ makeopens ( if (put_line(fd, "exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')") == FAIL) return FAIL; - } else if (ssop_flags & SSOP_CURDIR) { + } else if (ssop_flags & SSOP_CURDIR) { sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow); if (sname == NULL || fputs("cd ", fd) < 0 @@ -8320,7 +8329,7 @@ makeopens ( if (tp == curtab) { tab_firstwin = firstwin; tab_topframe = topframe; - } else { + } else { tab_firstwin = tp->tp_firstwin; tab_topframe = tp->tp_topframe; } @@ -8496,7 +8505,7 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin) || put_eol(fd) == FAIL)) return FAIL; } - } else { + } else { /* Just equalise window sizes */ if (put_line(fd, "wincmd =") == FAIL) return FAIL; @@ -8624,7 +8633,7 @@ put_view ( if (wp->w_alist == &global_alist) { if (put_line(fd, "argglobal") == FAIL) return FAIL; - } else { + } else { if (ses_arglist(fd, "arglocal", &wp->w_alist->al_ga, flagp == &vop_flags || !(*flagp & SSOP_CURDIR) @@ -8657,7 +8666,7 @@ put_view ( if (fputs("edit ", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp) == FAIL) return FAIL; - } else { + } else { /* No file in this buffer, just make it empty. */ if (put_line(fd, "enew") == FAIL) return FAIL; @@ -8733,7 +8742,7 @@ put_view ( if (wp->w_cursor.col == 0) { if (put_line(fd, "normal! 0") == FAIL) return FAIL; - } else { + } else { if (!wp->w_p_wrap && wp->w_leftcol > 0 && wp->w_width > 0) { if (fprintf(fd, "let s:c = %ld - ((%ld * winwidth(0) + %ld) / %ld)", @@ -8751,7 +8760,7 @@ put_view ( || put_eol(fd) == FAIL || put_line(fd, "endif") == FAIL) return FAIL; - } else { + } else { if (fprintf(fd, "normal! 0%d|", wp->w_virtcol + 1) < 0 || put_eol(fd) == FAIL) return FAIL; @@ -8930,7 +8939,7 @@ static char_u *get_view_file(int c) if (*p == '=') { *s++ = '='; *s++ = '='; - } else if (vim_ispathsep(*p)) { + } else if (vim_ispathsep(*p)) { *s++ = '='; #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) || defined(VMS) if (*p == ':') @@ -9022,7 +9031,7 @@ static void ex_behave(exarg_T *eap) set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0); set_option_value((char_u *)"keymodel", 0L, (char_u *)"startsel,stopsel", 0); - } else if (STRCMP(eap->arg, "xterm") == 0) { + } else if (STRCMP(eap->arg, "xterm") == 0) { set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0); set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); @@ -9103,7 +9112,7 @@ static void ex_filetype(exarg_T *eap) (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE); do_modelines(0); } - } else if (STRCMP(arg, "off") == 0) { + } else if (STRCMP(arg, "off") == 0) { if (plugin || indent) { if (plugin) { source_runtime((char_u *)FTPLUGOF_FILE, TRUE); @@ -9113,7 +9122,7 @@ static void ex_filetype(exarg_T *eap) source_runtime((char_u *)INDOFF_FILE, TRUE); filetype_indent = FALSE; } - } else { + } else { source_runtime((char_u *)FTOFF_FILE, TRUE); filetype_detect = FALSE; } diff --git a/src/ex_eval.c b/src/ex_eval.c index a0c5d1142e..79fbd03bc6 100644 --- a/src/ex_eval.c +++ b/src/ex_eval.c @@ -92,7 +92,8 @@ static int cause_abort = FALSE; * cancellation of an expression evaluation after an aborting function call or * due to a parsing error, aborting() always returns the same value. */ -int aborting(void) { +int aborting(void) +{ return (did_emsg && force_abort) || got_int || did_throw; } @@ -102,7 +103,8 @@ int aborting(void) { * be necessary to restore "force_abort" even before the throw point for the * error message has been reached. update_force_abort() should be called then. */ -void update_force_abort(void) { +void update_force_abort(void) +{ if (cause_abort) force_abort = TRUE; } @@ -124,7 +126,8 @@ int should_abort(int retcode) * to find finally clauses to be executed, and that some errors in skipped * commands are still reported. */ -int aborted_in_try(void) { +int aborted_in_try(void) +{ /* This function is only called after an error. In this case, "force_abort" * determines whether searching for finally clauses is necessary. */ return force_abort; @@ -244,13 +247,13 @@ int cause_errthrow(char_u *mesg, int severe, int *ignore) if (elem == NULL) { suppress_errthrow = TRUE; EMSG(_(e_outofmem)); - } else { + } else { elem->msg = vim_strsave(mesg); if (elem->msg == NULL) { vim_free(elem); suppress_errthrow = TRUE; EMSG(_(e_outofmem)); - } else { + } else { elem->next = NULL; elem->throw_msg = NULL; *plist = elem; @@ -296,7 +299,8 @@ static void free_msglist(struct msglist *l) * Free global "*msg_list" and the messages it contains, then set "*msg_list" * to NULL. */ -void free_global_msglist(void) { +void free_global_msglist(void) +{ free_msglist(*msg_list); *msg_list = NULL; } @@ -402,7 +406,7 @@ char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should STRCPY(&ret[4], cmdname); STRCPY(&ret[4 + cmdlen], "):"); val = ret + 4 + cmdlen + 2; - } else { + } else { ret = vim_strnsave((char_u *)"Vim:", 4 + (int)STRLEN(mesg)); if (ret == NULL) return ret; @@ -438,7 +442,7 @@ char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should break; } } - } else { + } else { *should_free = FALSE; ret = (char_u *) value; } @@ -580,7 +584,8 @@ static void discard_exception(except_T *excp, int was_finished) /* * Discard the exception currently being thrown. */ -void discard_current_exception(void) { +void discard_current_exception(void) +{ discard_exception(current_exception, FALSE); current_exception = NULL; did_throw = FALSE; @@ -653,7 +658,7 @@ static void finish_exception(except_T *excp) /* throw_name not set on an exception from a command that was * typed. */ set_vim_var_string(VV_THROWPOINT, NULL, -1); - } else { + } else { set_vim_var_string(VV_EXCEPTION, NULL, -1); set_vim_var_string(VV_THROWPOINT, NULL, -1); } @@ -887,7 +892,7 @@ void ex_else(exarg_T *eap) } eap->errmsg = (char_u *)N_("E582: :elseif without :if"); skip = TRUE; - } else if (cstack->cs_flags[cstack->cs_idx] & CSF_ELSE) { + } else if (cstack->cs_flags[cstack->cs_idx] & CSF_ELSE) { if (eap->cmdidx == CMD_else) { eap->errmsg = (char_u *)N_("E583: multiple :else"); return; @@ -979,7 +984,7 @@ void ex_while(exarg_T *eap) * ":while bool-expr" */ result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip); - } else { + } else { void *fi; /* @@ -990,7 +995,7 @@ void ex_while(exarg_T *eap) * previously evaluated list. */ fi = cstack->cs_forinfo[cstack->cs_idx]; error = FALSE; - } else { + } else { /* Evaluate the argument and get the info in a structure. */ fi = eval_for_line(eap->arg, &error, &eap->nextcmd, skip); cstack->cs_forinfo[cstack->cs_idx] = fi; @@ -1016,7 +1021,7 @@ void ex_while(exarg_T *eap) if (!skip && !error && result) { cstack->cs_flags[cstack->cs_idx] |= (CSF_ACTIVE | CSF_TRUE); cstack->cs_lflags ^= CSL_HAD_LOOP; - } else { + } else { cstack->cs_lflags &= ~CSL_HAD_LOOP; /* If the ":while" evaluates to FALSE or ":for" is past the end of * the list, show the debug prompt at the ":endwhile"/":endfor" as @@ -1052,7 +1057,7 @@ void ex_continue(exarg_T *eap) * matching ":while". */ cstack->cs_lflags |= CSL_HAD_CONT; /* let do_cmdline() handle it */ - } else { + } else { /* If a try conditional not in its finally clause is reached first, * make the ":continue" pending for execution at the ":endtry". */ cstack->cs_pending[idx] = CSTP_CONTINUE; @@ -1098,7 +1103,7 @@ void ex_endwhile(exarg_T *eap) if (eap->cmdidx == CMD_endwhile) { err = e_while; csf = CSF_WHILE; - } else { + } else { err = e_for; csf = CSF_FOR; } @@ -1334,7 +1339,7 @@ void ex_catch(exarg_T *eap) if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) { eap->errmsg = (char_u *)N_("E603: :catch without :try"); give_up = TRUE; - } else { + } else { if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) { /* Report what's missing if the matching ":try" is not in its * finally clause. */ @@ -1358,7 +1363,7 @@ void ex_catch(exarg_T *eap) pat = (char_u *)".*"; end = NULL; eap->nextcmd = find_nextcmd(eap->arg); - } else { + } else { pat = eap->arg + 1; end = skip_regexp(pat, *eap->arg, TRUE, NULL); } @@ -1436,7 +1441,7 @@ void ex_catch(exarg_T *eap) * exception. */ if (cstack->cs_exception[cstack->cs_idx] != current_exception) EMSG(_(e_internal)); - } else { + } else { /* * If there is a preceding catch clause and it caught the exception, * finish the exception now. This happens also after errors except @@ -1622,7 +1627,7 @@ void ex_endtry(exarg_T *eap) */ if (did_throw) discard_current_exception(); - } else { + } else { idx = cstack->cs_idx; /* @@ -1799,7 +1804,7 @@ void enter_cleanup(cleanup_T *csp) /* Report if required by the 'verbose' option or when debugging. */ report_make_pending(pending, csp->exception); - } else { + } else { csp->pending = CSTP_NONE; csp->exception = NULL; } diff --git a/src/ex_getln.c b/src/ex_getln.c index aad9993354..140a440f98 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -419,7 +419,7 @@ getcmdline ( /* Entered command line, move it up */ cmdline_row--; redrawcmd(); - } else if (save_p_ls != -1) { + } else if (save_p_ls != -1) { /* restore 'laststatus' and 'winminheight' */ p_ls = save_p_ls; p_wmh = save_p_wmh; @@ -429,7 +429,7 @@ getcmdline ( restore_cmdline(&save_ccline); redrawcmd(); save_p_ls = -1; - } else { + } else { win_redraw_last_status(topframe); redraw_statuslines(); } @@ -495,7 +495,7 @@ getcmdline ( || ccline.cmdbuff[ccline.cmdpos - 3] != '.')) { /* go down a directory */ c = p_wc; - } else if (STRNCMP(xpc.xp_pattern, upseg + 1, 3) == 0 && c == K_DOWN) { + } else if (STRNCMP(xpc.xp_pattern, upseg + 1, 3) == 0 && c == K_DOWN) { /* If in a direct ancestor, strip off one ../ to go down */ int found = FALSE; @@ -516,7 +516,7 @@ getcmdline ( cmdline_del(j - 2); c = p_wc; } - } else if (c == K_UP) { + } else if (c == K_UP) { /* go up a directory */ int found = FALSE; @@ -579,7 +579,7 @@ getcmdline ( KeyTyped))) { vungetc(c); c = Ctrl_BSL; - } else if (c == 'e') { + } else if (c == 'e') { char_u *p = NULL; int len; @@ -632,7 +632,7 @@ getcmdline ( emsg_on_display = FALSE; redrawcmd(); goto cmdline_not_changed; - } else { + } else { if (c == Ctrl_G && p_im && restart_edit == 0) restart_edit = 'a'; gotesc = TRUE; /* will free ccline.cmdbuff after putting it @@ -663,7 +663,7 @@ getcmdline ( && ccline.cmdbuff[ccline.cmdpos - 1] == '\\') { if (c == K_KENTER) c = '\n'; - } else { + } else { gotesc = FALSE; /* Might have typed ESC previously, don't truncate the cmdline now. */ if (ccheck_abbr(c + ABBR_OFF)) @@ -700,7 +700,7 @@ getcmdline ( firstc != '@'); else res = OK; /* don't insert 'wildchar' now */ - } else { /* typed p_wc first time */ + } else { /* typed p_wc first time */ wim_index = 0; j = ccline.cmdpos; /* if 'wildmode' first contains "longest", get longest @@ -816,7 +816,7 @@ getcmdline ( if (mb_get_class(p) != i) p += (*mb_ptr2len)(p); } - } else if (c == Ctrl_W) { + } else if (c == Ctrl_W) { while (p > ccline.cmdbuff && vim_isspace(p[-1])) --p; i = vim_iswordc(p[-1]); @@ -892,7 +892,7 @@ getcmdline ( im_set_active(FALSE); /* Disable input method */ if (b_im_ptr != NULL) *b_im_ptr = B_IMODE_NONE; - } else { + } else { im_set_active(TRUE); /* Enable input method */ if (b_im_ptr != NULL) *b_im_ptr = B_IMODE_IM; @@ -959,7 +959,7 @@ getcmdline ( if (ccline.cmdfirstc == '=') { /* can't do this recursively */ beep_flush(); c = ESC; - } else { + } else { save_cmdline(&save_ccline); c = get_expr_register(); restore_cmdline(&save_ccline); @@ -1203,7 +1203,7 @@ getcmdline ( hiscnt = i; break; } - } else { /* one step forwards */ + } else { /* one step forwards */ /* on last entry, clear the line */ if (hiscnt == hisidx[histype]) { hiscnt = hislen; @@ -1257,7 +1257,7 @@ getcmdline ( && (j == 0 || p[j - 1] != '\\')) { if (i > 0) ccline.cmdbuff[len] = firstc; - } else { + } else { /* Escape new sep, unless it is already * escaped. */ if (p[j] == firstc @@ -1278,7 +1278,7 @@ getcmdline ( } } ccline.cmdbuff[len] = NUL; - } else { + } else { alloc_cmdbuff((int)STRLEN(p)); if (ccline.cmdbuff == NULL) goto returncmd; @@ -1373,7 +1373,7 @@ getcmdline ( j = (*mb_char2bytes)(c, IObuff); IObuff[j] = NUL; /* exclude composing chars */ put_on_cmdline(IObuff, j, TRUE); - } else { + } else { IObuff[0] = c; put_on_cmdline(IObuff, 1, TRUE); } @@ -1611,7 +1611,8 @@ getcmdline_prompt ( * another window or buffer. Used when editing the command line, evaluating * 'balloonexpr', etc. */ -int text_locked(void) { +int text_locked(void) +{ if (cmdwin_type != 0) return TRUE; return textlock != 0; @@ -1621,7 +1622,8 @@ int text_locked(void) { * Give an error message for a command that isn't allowed while the cmdline * window is open or editing the cmdline in another way. */ -void text_locked_msg(void) { +void text_locked_msg(void) +{ if (cmdwin_type != 0) EMSG(_(e_cmdwin)); else @@ -1632,7 +1634,8 @@ void text_locked_msg(void) { * Check if "curbuf_lock" or "allbuf_lock" is set and return TRUE when it is * and give an error message. */ -int curbuf_locked(void) { +int curbuf_locked(void) +{ if (curbuf_lock > 0) { EMSG(_("E788: Not allowed to edit another buffer now")); return TRUE; @@ -1644,7 +1647,8 @@ int curbuf_locked(void) { * Check if "allbuf_lock" is set and return TRUE when it is and give an error * message. */ -int allbuf_locked(void) { +int allbuf_locked(void) +{ if (allbuf_lock > 0) { EMSG(_("E811: Not allowed to change buffer information now")); return TRUE; @@ -1663,7 +1667,8 @@ static int cmdline_charsize(int idx) * Compute the offset of the cursor on the command line for the prompt and * indent. */ -static void set_cmdspos(void) { +static void set_cmdspos(void) +{ if (ccline.cmdfirstc != NUL) ccline.cmdspos = 1 + ccline.cmdindent; else @@ -1673,7 +1678,8 @@ static void set_cmdspos(void) { /* * Compute the screen position for the cursor on the command line. */ -static void set_cmdspos_cursor(void) { +static void set_cmdspos_cursor(void) +{ int i, m, c; set_cmdspos(); @@ -1855,7 +1861,7 @@ redraw: do { msg_putchar(' '); } while (++vcol % 8); - } else { + } else { msg_outtrans_len(p, 1); vcol += char2cells(*p); } @@ -1873,7 +1879,7 @@ redraw: ex_keep_indent = TRUE; indent = 0; p[--line_ga.ga_len] = NUL; - } else { + } else { p[line_ga.ga_len] = NUL; indent = get_indent_str(p, 8); --indent; @@ -1908,7 +1914,7 @@ redraw: do { msg_putchar(' '); } while (++vcol % 8); - } else { + } else { msg_outtrans_len( ((char_u *)line_ga.ga_data) + line_ga.ga_len, 1); vcol += char2cells(c1); @@ -1963,14 +1969,16 @@ redraw: /* * Return TRUE if ccline.overstrike is on. */ -int cmdline_overstrike(void) { +int cmdline_overstrike(void) +{ return ccline.overstrike; } /* * Return TRUE if the cursor is at the end of the cmdline. */ -int cmdline_at_end(void) { +int cmdline_at_end(void) +{ return ccline.cmdpos >= ccline.cmdlen; } @@ -2034,7 +2042,8 @@ static int realloc_cmdbuff(int len) static char_u *arshape_buf = NULL; # if defined(EXITFREE) || defined(PROTO) -void free_cmdline_buf(void) { +void free_cmdline_buf(void) +{ vim_free(arshape_buf); } @@ -2054,7 +2063,7 @@ static void draw_cmdline(int start, int len) if (has_mbyte) i += (*mb_ptr2len)(ccline.cmdbuff + start + i) - 1; } - else if (p_arshape && !p_tbidi && enc_utf8 && len > 0) { + else if (p_arshape && !p_tbidi && enc_utf8 && len > 0) { static int buflen = 0; char_u *p; int j; @@ -2102,7 +2111,7 @@ static void draw_cmdline(int start, int len) nc = NUL; else nc = utf_ptr2char(p + mb_l); - } else { + } else { /* displaying from left to right */ if (j + mb_l >= start + len) pc = NUL; @@ -2126,7 +2135,7 @@ static void draw_cmdline(int start, int len) newlen += (*mb_char2bytes)(u8cc[1], arshape_buf + newlen); } - } else { + } else { prev_c = u8c; mch_memmove(arshape_buf + newlen, p, mb_l); newlen += mb_l; @@ -2158,7 +2167,8 @@ void putcmdline(int c, int shift) /* * Undo a putcmdline(c, FALSE). */ -void unputcmdline(void) { +void unputcmdline(void) +{ if (cmd_silent) return; msg_no_more = TRUE; @@ -2202,7 +2212,7 @@ int put_on_cmdline(char_u *str, int len, int redraw) ccline.cmdbuff + ccline.cmdpos, (size_t)(ccline.cmdlen - ccline.cmdpos)); ccline.cmdlen += len; - } else { + } else { if (has_mbyte) { /* Count nr of characters in the new string. */ m = 0; @@ -2343,7 +2353,8 @@ static void restore_cmdline(struct cmdline_info *ccp) * passed to restore_cmdline_alloc() later. * Returns NULL when failed. */ -char_u *save_cmdline_alloc(void) { +char_u *save_cmdline_alloc(void) +{ struct cmdline_info *p; p = (struct cmdline_info *)alloc((unsigned)sizeof(struct cmdline_info)); @@ -2424,7 +2435,7 @@ cmdline_paste ( if (!vim_iswordc(mb_ptr2char(w - len))) break; w -= len; - } else { + } else { if (!vim_iswordc(w[-1])) break; --w; @@ -2492,7 +2503,8 @@ static void cmdline_del(int from) * this function is called when the screen size changes and with incremental * search */ -void redrawcmdline(void) { +void redrawcmdline(void) +{ if (cmd_silent) return; need_wait_return = FALSE; @@ -2501,7 +2513,8 @@ void redrawcmdline(void) { cursorcmd(); } -static void redrawcmdprompt(void) { +static void redrawcmdprompt(void) +{ int i; if (cmd_silent) @@ -2522,7 +2535,8 @@ static void redrawcmdprompt(void) { /* * Redraw what is currently on the command line. */ -void redrawcmd(void) { +void redrawcmd(void) +{ if (cmd_silent) return; @@ -2555,7 +2569,8 @@ void redrawcmd(void) { skip_redraw = FALSE; } -void compute_cmdrow(void) { +void compute_cmdrow(void) +{ if (exmode_active || msg_scrolled != 0) cmdline_row = Rows - 1; else @@ -2563,7 +2578,8 @@ void compute_cmdrow(void) { + W_STATUS_HEIGHT(lastwin); } -static void cursorcmd(void) { +static void cursorcmd(void) +{ if (cmd_silent) return; @@ -2572,7 +2588,7 @@ static void cursorcmd(void) { msg_col = (int)Columns - (ccline.cmdspos % (int)(Columns - 1)) - 1; if (msg_row <= 0) msg_row = Rows - 1; - } else { + } else { msg_row = cmdline_row + (ccline.cmdspos / (int)Columns); msg_col = ccline.cmdspos % (int)Columns; if (msg_row >= Rows) @@ -2663,7 +2679,7 @@ nextwild ( * Get next/previous match for a previous expanded pattern. */ p2 = ExpandOne(xp, NULL, NULL, 0, type); - } else { + } else { /* * Translate string into pattern and expand it. */ @@ -2850,10 +2866,10 @@ ExpandOne ( if (!(options & WILD_SILENT) && (options & WILD_LIST_NOTFOUND)) EMSG2(_(e_nomatch2), str); #endif - } else if (xp->xp_numfiles == 0) { + } else if (xp->xp_numfiles == 0) { if (!(options & WILD_SILENT)) EMSG2(_(e_nomatch2), str); - } else { + } else { /* Escape the matches for use on the command line. */ ExpandEscape(xp, str, xp->xp_numfiles, xp->xp_files, options); @@ -3034,7 +3050,7 @@ void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char_u **files, int o * could be seen as "+cmd". */ if (*files[0] == '+') escape_fname(&files[0]); - } else if (xp->xp_context == EXPAND_TAGS) { + } else if (xp->xp_context == EXPAND_TAGS) { /* * Insert a backslash before characters in a tag name that * would terminate the ":tag" command. @@ -3152,7 +3168,7 @@ static int showmatches(expand_T *xp, int wildmenu) if (i != EXPAND_OK) return i; - } else { + } else { num_files = xp->xp_numfiles; files_found = xp->xp_files; showtail = cmd_showtail; @@ -3250,7 +3266,7 @@ static int showmatches(expand_T *xp, int wildmenu) TRUE); p = NameBuff; } - } else { + } else { j = FALSE; p = L_SHOWFILE(k); } @@ -3426,7 +3442,7 @@ addstar ( retval[j] = NUL; } } - } else { + } else { retval = alloc(len + 4); if (retval != NULL) { vim_strncpy(retval, fname, len); @@ -3540,7 +3556,7 @@ set_cmd_context ( if (ccline.cmdfirstc == '=') { /* pass CMD_SIZE because there is no real command */ set_context_for_expression(xp, str, CMD_SIZE); - } else if (ccline.input_fn) { + } else if (ccline.input_fn) { xp->xp_context = ccline.xp_context; xp->xp_pattern = ccline.cmdbuff; xp->xp_arg = ccline.xp_arg; @@ -4317,7 +4333,8 @@ static char_u *get_history_arg(expand_T *xp, int idx) * init_history() - Initialize the command line history. * Also used to re-allocate the history when the size changes. */ -void init_history(void) { +void init_history(void) +{ int newlen; /* new length of history table */ histentry_T *temp; int i; @@ -4358,7 +4375,7 @@ void init_history(void) { clear_hist_entry(&temp[i]); for (; j < hislen; ++i, ++j) temp[i] = history[type][j]; - } else { /* array becomes smaller or 0 */ + } else { /* array becomes smaller or 0 */ j = hisidx[type]; for (i = newlen - 1;; --i) { if (i >= 0) /* copy newest entries */ @@ -4562,7 +4579,8 @@ static struct cmdline_info *get_ccline_ptr(void) * Only works when the command line is being edited. * Returns NULL when something is wrong. */ -char_u *get_cmdline_str(void) { +char_u *get_cmdline_str(void) +{ struct cmdline_info *p = get_ccline_ptr(); if (p == NULL) @@ -4576,7 +4594,8 @@ char_u *get_cmdline_str(void) { * Only works when the command line is being edited. * Returns -1 when something is wrong. */ -int get_cmdline_pos(void) { +int get_cmdline_pos(void) +{ struct cmdline_info *p = get_ccline_ptr(); if (p == NULL) @@ -4611,7 +4630,8 @@ int set_cmdline_pos(int pos) * Only works when the command line is being edited. * Returns NUL when something is wrong. */ -int get_cmdline_type(void) { +int get_cmdline_type(void) +{ struct cmdline_info *p = get_ccline_ptr(); if (p == NULL) @@ -4724,7 +4744,7 @@ int del_history_entry(int histype, char_u *str) found = TRUE; vim_free(hisptr->hisstr); clear_hist_entry(hisptr); - } else { + } else { if (i != last) { history[histype][last] = *hisptr; clear_hist_entry(hisptr); @@ -4779,7 +4799,8 @@ int del_history_idx(int histype, int idx) * Very specific function to remove the value in ":set key=val" from the * history. */ -void remove_key_from_history(void) { +void remove_key_from_history(void) +{ char_u *p; int i; @@ -4866,7 +4887,7 @@ void ex_history(exarg_T *eap) if (STRNICMP(arg, "all", STRLEN(arg)) == 0) { histype1 = 0; histype2 = HIST_COUNT-1; - } else { + } else { *end = i; EMSG(_(e_trailing)); return; @@ -5014,7 +5035,7 @@ int read_viminfo_history(vir_T *virp, int writing) * column to after the NUL. */ mch_memmove(p, val + 1, (size_t)len); p[len] = sep; - } else { + } else { /* Not a search entry: No separator in the viminfo * file, add a NUL separator. */ mch_memmove(p, val, (size_t)len + 1); @@ -5032,7 +5053,8 @@ int read_viminfo_history(vir_T *virp, int writing) /* * Finish reading history lines from viminfo. Not used when writing viminfo. */ -void finish_viminfo_history(void) { +void finish_viminfo_history(void) +{ int idx; int i; int type; @@ -5152,7 +5174,7 @@ void write_viminfo_history(FILE *fp, int merge) i = hislen - 1; if (i == hisidx[type]) break; - } else { + } else { /* Increment index. Stop at the end in the while. */ ++i; } @@ -5198,7 +5220,8 @@ int cmd_gchar(int offset) * Ctrl_C if it is to be abandoned * K_IGNORE if editing continues */ -static int ex_window(void) { +static int ex_window(void) +{ struct cmdline_info save_ccline; buf_T *old_curbuf = curbuf; win_T *old_curwin = curwin; @@ -5336,7 +5359,7 @@ static int ex_window(void) { if (!win_valid(old_curwin) || !buf_valid(old_curbuf)) { cmdwin_result = Ctrl_C; EMSG(_("E199: Active window or buffer deleted")); - } else { + } else { /* autocmds may abort script processing */ if (aborting() && cmdwin_result != K_IGNORE) cmdwin_result = Ctrl_C; @@ -5349,17 +5372,17 @@ static int ex_window(void) { /* Execute the command directly. */ ccline.cmdbuff = vim_strsave((char_u *)p); cmdwin_result = CAR; - } else { + } else { /* First need to cancel what we were doing. */ ccline.cmdbuff = NULL; stuffcharReadbuff(':'); stuffReadbuff((char_u *)p); stuffcharReadbuff(CAR); } - } else if (cmdwin_result == K_XF2) { /* :qa typed */ + } else if (cmdwin_result == K_XF2) { /* :qa typed */ ccline.cmdbuff = vim_strsave((char_u *)"qa"); cmdwin_result = CAR; - } else if (cmdwin_result == Ctrl_C) { + } else if (cmdwin_result == Ctrl_C) { /* :q or :close, don't execute any command * and don't modify the cmd window. */ ccline.cmdbuff = NULL; diff --git a/src/farsi.c b/src/farsi.c index 1e2ea7428b..ccff73f13c 100644 --- a/src/farsi.c +++ b/src/farsi.c @@ -912,7 +912,7 @@ int fkmap(int c) && gchar_cursor() != NUL) { curwin->w_cursor.col++; } - } else { + } else { if (curwin->w_cursor.col) { while ((F_isdigit(gchar_cursor()) || (gchar_cursor() == F_PERIOD diff --git a/src/file_search.c b/src/file_search.c index 7411e19da0..0b688a2a10 100644 --- a/src/file_search.c +++ b/src/file_search.c @@ -327,7 +327,7 @@ vim_findfile_init ( goto error_return; if (*++path != NUL) ++path; - } else if (*path == NUL || !vim_isAbsName(path)) { + } else if (*path == NUL || !vim_isAbsName(path)) { #ifdef BACKSLASH_IN_FILENAME /* "c:dir" needs "c:" to be expanded, otherwise use current dir */ if (*path != NUL && path[1] == ':') { @@ -499,7 +499,7 @@ vim_findfile_init ( if (mch_isdir(buf)) { STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path); add_pathsep(ff_expand_buffer); - } else { + } else { char_u *p = gettail(search_ctx->ffsc_fix_path); char_u *wc_path = NULL; char_u *temp = NULL; @@ -901,7 +901,7 @@ char_u *vim_findfile(void *search_ctx_arg) MAXPATHL - len, ","); } } - } else { + } else { /* * still wildcards left, push the directories for further * search @@ -1152,7 +1152,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u * #ifdef UNIX url = TRUE; #endif - } else { + } else { ff_expand_buffer[0] = NUL; #ifdef UNIX if (mch_stat((char *)fname, &st) < 0) @@ -1192,7 +1192,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u * vp->ffv_ino = st.st_ino; vp->ffv_dev = st.st_dev; vp->ffv_fname[0] = NUL; - } else { + } else { vp->ffv_dev_valid = FALSE; #endif STRCPY(vp->ffv_fname, ff_expand_buffer); @@ -1352,7 +1352,7 @@ static int ff_path_in_stoplist(char_u *path, int path_len, char_u **stopdirs_v) if (fnamencmp(stopdirs_v[i], path, path_len) == 0 && vim_ispathsep(stopdirs_v[i][path_len])) return TRUE; - } else { + } else { if (fnamecmp(stopdirs_v[i], path) == 0) return TRUE; } @@ -1403,7 +1403,8 @@ static char_u *ff_file_to_find = NULL; static void *fdip_search_ctx = NULL; #if defined(EXITFREE) -void free_findfile(void) { +void free_findfile(void) +{ vim_free(ff_file_to_find); vim_findfile_cleanup(fdip_search_ctx); vim_free(ff_expand_buffer); @@ -1503,7 +1504,7 @@ find_file_in_path_option ( STRCPY(NameBuff, rel_fname); STRCPY(gettail(NameBuff), ff_file_to_find); l = (int)STRLEN(NameBuff); - } else { + } else { STRCPY(NameBuff, ff_file_to_find); run = 2; } @@ -1526,7 +1527,7 @@ find_file_in_path_option ( } } } - } else { + } else { /* * Loop over all paths in the 'path' or 'cdpath' option. * When "first" is set, first setup to the start of the option. @@ -1546,7 +1547,7 @@ find_file_in_path_option ( break; did_findfile_init = FALSE; - } else { + } else { char_u *r_ptr; if (dir == NULL || *dir == NUL) { @@ -1583,7 +1584,7 @@ find_file_in_path_option ( else EMSG2(_("E345: Can't find file \"%s\" in path"), ff_file_to_find); - } else { + } else { if (find_what == FINDFILE_DIR) EMSG2(_("E346: No more directory \"%s\" found in cdpath"), ff_file_to_find); diff --git a/src/fileio.c b/src/fileio.c index 498f282555..a8aef2466b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -459,7 +459,7 @@ readfile ( */ swap_mode = (st.st_mode & 0644) | 0600; #endif - } else { + } else { curbuf->b_mtime = 0; curbuf->b_mtime_read = 0; curbuf->b_orig_size = 0; @@ -477,7 +477,7 @@ readfile ( */ file_readonly = FALSE; if (read_stdin) { - } else if (!read_buffer) { + } else if (!read_buffer) { #ifdef USE_MCH_ACCESS if ( # ifdef UNIX @@ -559,7 +559,7 @@ readfile ( if (aborting()) /* autocmds may abort script processing */ return FAIL; return OK; /* a new file is not an error */ - } else { + } else { filemess(curbuf, sfname, (char_u *)( # ifdef EFBIG (errno == EFBIG) ? _("[File too big]") : @@ -733,10 +733,10 @@ readfile ( fenc = enc_canonize(eap->cmd + eap->force_enc); fenc_alloced = TRUE; keep_dest_enc = TRUE; - } else if (curbuf->b_p_bin) { + } else if (curbuf->b_p_bin) { fenc = (char_u *)""; /* binary: don't convert */ fenc_alloced = FALSE; - } else if (curbuf->b_help) { + } else if (curbuf->b_help) { char_u firstline[80]; int fc; @@ -774,10 +774,10 @@ readfile ( keep_dest_enc = TRUE; } fenc_alloced = FALSE; - } else if (*p_fencs == NUL) { + } else if (*p_fencs == NUL) { fenc = curbuf->b_p_fenc; /* use format from buffer */ fenc_alloced = FALSE; - } else { + } else { fenc_next = p_fencs; /* try items in 'fileencodings' */ fenc = next_fenc(&fenc_next); fenc_alloced = TRUE; @@ -808,7 +808,7 @@ retry: if (read_buffer) { read_buf_lnum = 1; read_buf_col = 0; - } else if (read_stdin || lseek(fd, (off_t)0L, SEEK_SET) != 0) { + } else if (read_stdin || lseek(fd, (off_t)0L, SEEK_SET) != 0) { /* Can't rewind the file, give up. */ error = TRUE; goto failed; @@ -870,13 +870,13 @@ retry: vim_free(fenc); fenc = (char_u *)""; fenc_alloced = FALSE; - } else { + } else { if (fenc_alloced) vim_free(fenc); if (fenc_next != NULL) { fenc = next_fenc(&fenc_next); fenc_alloced = (fenc_next != NULL); - } else { + } else { fenc = (char_u *)""; fenc_alloced = FALSE; } @@ -954,7 +954,7 @@ retry: goto retry; } } - } else { + } else { if (fio_flags == 0 # ifdef USE_ICONV && iconv_fd == (iconv_t)-1 @@ -1092,7 +1092,7 @@ retry: } read_buf_col += n; break; - } else { + } else { /* Append whole line and new-line. Change NL * to NUL to reverse the effect done below. */ for (ni = 0; ni < n; ++ni) { @@ -1114,7 +1114,7 @@ retry: } } } - } else { + } else { /* * Read bytes from the file. */ @@ -1149,7 +1149,7 @@ retry: if (bad_char_behavior == BAD_DROP) { *(ptr - conv_restlen) = NUL; conv_restlen = 0; - } else { + } else { /* Replace the trailing bytes with the replacement * character if we were converting; if we weren't, * leave the UTF8 checking code to do it, as it @@ -1230,7 +1230,7 @@ retry: if (ccname == NULL) { /* No BOM detected: retry with next encoding. */ advance_fenc = TRUE; - } else { + } else { /* BOM detected: set "fenc" and jump back */ if (fenc_alloced) vim_free(fenc); @@ -1292,7 +1292,7 @@ retry: if (bad_char_behavior == BAD_KEEP) { *top++ = *(fromp - 1); --to_size; - } else if (bad_char_behavior != BAD_DROP) { + } else if (bad_char_behavior != BAD_DROP) { *top++ = bad_char_behavior; --to_size; } @@ -1348,7 +1348,7 @@ retry: else p = tail; } - } else if (fio_flags & (FIO_UCS2 | FIO_UTF16)) { + } else if (fio_flags & (FIO_UCS2 | FIO_UTF16)) { /* Check for a trailing byte */ p = ptr + (size & ~1); if (size & 1) @@ -1358,7 +1358,7 @@ retry: if (fio_flags & FIO_ENDIAN_L) { u8c = (*--p << 8); u8c += *--p; - } else { + } else { u8c = *--p; u8c += (*--p << 8); } @@ -1367,7 +1367,7 @@ retry: else p += 2; } - } else { /* FIO_UCS4 */ + } else { /* FIO_UCS4 */ /* Check for trailing 1, 2 or 3 bytes */ p = ptr + (size & ~3); if (size & 3) @@ -1390,7 +1390,7 @@ retry: if (fio_flags & FIO_ENDIAN_L) { u8c = (*--p << 8); u8c += *--p; - } else { + } else { u8c = *--p; u8c += (*--p << 8); } @@ -1416,7 +1416,7 @@ retry: if (fio_flags & FIO_ENDIAN_L) { u16c = (*--p << 8); u16c += *--p; - } else { + } else { u16c = *--p; u16c += (*--p << 8); } @@ -1436,19 +1436,19 @@ retry: u8c = bad_char_behavior; } } - } else if (fio_flags & FIO_UCS4) { + } else if (fio_flags & FIO_UCS4) { if (fio_flags & FIO_ENDIAN_L) { u8c = (*--p << 24); u8c += (*--p << 16); u8c += (*--p << 8); u8c += *--p; - } else { /* big endian */ + } else { /* big endian */ u8c = *--p; u8c += (*--p << 8); u8c += (*--p << 16); u8c += (*--p << 24); } - } else { /* UTF-8 */ + } else { /* UTF-8 */ if (*--p < 0x80) u8c = *p; else { @@ -1474,7 +1474,7 @@ retry: if (enc_utf8) { /* produce UTF-8 */ dest -= utf_char2len(u8c); (void)utf_char2bytes(u8c, dest); - } else { /* produce Latin1 */ + } else { /* produce Latin1 */ --dest; if (u8c >= 0x100) { /* character doesn't fit in latin1, retry with @@ -1502,7 +1502,7 @@ retry: mch_memmove(line_start, buffer, (size_t)linerest); size = (long)((ptr + real_size) - dest); ptr = dest; - } else if (enc_utf8 && !curbuf->b_p_bin) { + } else if (enc_utf8 && !curbuf->b_p_bin) { int incomplete_tail = FALSE; /* Reading UTF-8: Check if the bytes are valid UTF-8. */ @@ -1667,7 +1667,7 @@ rewind_retry: line_start = ptr + 1; } } - } else { + } else { --ptr; while (++ptr, --size >= 0) { if ((c = *ptr) != NUL && c != NL) /* catch most common case */ @@ -1903,7 +1903,7 @@ failed: if (notconverted) { STRCAT(IObuff, _("[NOT converted]")); c = TRUE; - } else if (converted) { + } else if (converted) { STRCAT(IObuff, _("[converted]")); c = TRUE; } @@ -1918,11 +1918,11 @@ failed: sprintf((char *)IObuff + STRLEN(IObuff), _("[CONVERSION ERROR in line %ld]"), (long)conv_error); c = TRUE; - } else if (illegal_byte > 0) { + } else if (illegal_byte > 0) { sprintf((char *)IObuff + STRLEN(IObuff), _("[ILLEGAL BYTE in line %ld]"), (long)illegal_byte); c = TRUE; - } else if (error) { + } else if (error) { STRCAT(IObuff, _("[READ ERRORS]")); c = TRUE; } @@ -2167,7 +2167,7 @@ static char_u *next_fenc(char_u **pp) if (p == NULL) { r = enc_canonize(*pp); *pp += STRLEN(*pp); - } else { + } else { r = vim_strnsave(*pp, (int)(p - *pp)); *pp = p + 1; if (r != NULL) { @@ -2238,7 +2238,8 @@ readfile_charconvert ( * Read marks for the current buffer from the viminfo file, when we support * buffer marks and the buffer has a name. */ -static void check_marks_read(void) { +static void check_marks_read(void) +{ if (!curbuf->b_marks_read && get_viminfo_parameter('\'') > 0 && curbuf->b_ffname != NULL) read_viminfo(NULL, VIF_WANT_MARKS); @@ -2687,7 +2688,7 @@ buf_write ( apply_autocmds_exarg(EVENT_FILEAPPENDPRE, sfname, sfname, FALSE, curbuf, eap); } - } else if (filtering) { + } else if (filtering) { apply_autocmds_exarg(EVENT_FILTERWRITEPRE, NULL, sfname, FALSE, curbuf, eap); } else if (reset_changed && whole) { @@ -2703,14 +2704,14 @@ buf_write ( u_unchanged(curbuf); u_update_save_nr(curbuf); } - } else { + } else { if (overwriting && bt_nofile(curbuf)) nofile_err = TRUE; else apply_autocmds_exarg(EVENT_BUFWRITEPRE, sfname, sfname, FALSE, curbuf, eap); } - } else { + } else { if (!(did_cmd = apply_autocmds_exarg(EVENT_FILEWRITECMD, sfname, sfname, FALSE, curbuf, eap))) { if (overwriting && bt_nofile(curbuf)) @@ -2875,7 +2876,7 @@ buf_write ( device = TRUE; newfile = TRUE; perm = -1; - } else { + } else { perm = mch_getperm(fname); if (perm < 0) newfile = TRUE; @@ -2900,7 +2901,7 @@ buf_write ( if (vim_strchr(p_cpo, CPO_FWRITE) != NULL) { errnum = (char_u *)"E504: "; errmsg = (char_u *)_(err_readonly); - } else { + } else { errnum = (char_u *)"E505: "; errmsg = (char_u *)_("is read-only (add ! to override)"); } @@ -3195,7 +3196,7 @@ buf_write ( if (bfd < 0) { vim_free(backup); backup = NULL; - } else { + } else { /* set file protection same as original file, but * strip s-bit */ (void)mch_setperm(backup, perm & 0777); @@ -3273,7 +3274,7 @@ nobackup: goto fail; } errmsg = NULL; - } else { + } else { char_u *dirp; char_u *p; char_u *rootname; @@ -3564,7 +3565,7 @@ restore_backup: /* if original file does exist throw away the copy */ if (mch_stat((char *)fname, &st) >= 0) mch_remove(backup); - } else { + } else { /* try to put the original file back */ vim_rename(backup, fname); } @@ -3861,7 +3862,7 @@ restore_backup: } close(fd); /* ignore errors for closing read file */ } - } else { + } else { if (vim_rename(backup, fname) == 0) end = 1; } @@ -3884,17 +3885,17 @@ restore_backup: if (write_info.bw_conv_error_lnum != 0) vim_snprintf_add((char *)IObuff, IOSIZE, _(" in line %ld;"), (long)write_info.bw_conv_error_lnum); - } else if (notconverted) { + } else if (notconverted) { STRCAT(IObuff, _("[NOT converted]")); c = TRUE; - } else if (converted) { + } else if (converted) { STRCAT(IObuff, _("[converted]")); c = TRUE; } if (device) { STRCAT(IObuff, _("[Device]")); c = TRUE; - } else if (newfile) { + } else if (newfile) { STRCAT(IObuff, shortmess(SHM_NEW) ? _("[New]") : _("[New File]")); c = TRUE; } @@ -4240,7 +4241,8 @@ void msg_add_lines(int insert_space, long lnum, off_t nchars) /* * Append message for missing line separator to IObuff. */ -static void msg_add_eol(void) { +static void msg_add_eol(void) +{ STRCAT(IObuff, shortmess(SHM_LAST) ? _("[noeol]") : _("[Incomplete last line]")); } @@ -4311,7 +4313,7 @@ static int buf_write_bytes(struct bw_info *ip) p += utf_char2bytes(buf[wlen], p); buf = ip->bw_conv_buf; len = (int)(p - ip->bw_conv_buf); - } else if (flags & (FIO_UCS4 | FIO_UTF16 | FIO_UCS2 | FIO_LATIN1)) { + } else if (flags & (FIO_UCS4 | FIO_UTF16 | FIO_UCS2 | FIO_LATIN1)) { /* * Convert UTF-8 bytes in the buffer to UCS-2, UCS-4, UTF-16 or * Latin1 chars in the file. @@ -4348,13 +4350,13 @@ static int buf_write_bytes(struct bw_info *ip) if (n >= ip->bw_restlen) { n -= ip->bw_restlen; ip->bw_restlen = 0; - } else { + } else { ip->bw_restlen -= n; mch_memmove(ip->bw_rest, ip->bw_rest + n, (size_t)ip->bw_restlen); n = 0; } - } else { + } else { n = utf_ptr2len_len(buf + wlen, len - wlen); if (n > len - wlen) { /* We have an incomplete byte sequence at the end to @@ -4405,7 +4407,7 @@ static int buf_write_bytes(struct bw_info *ip) from = ip->bw_conv_buf + ip->bw_conv_buflen - fromlen; mch_memmove(from, ip->bw_rest, (size_t)ip->bw_restlen); mch_memmove(from + ip->bw_restlen, buf, (size_t)len); - } else { + } else { from = buf; fromlen = len; } @@ -4440,7 +4442,7 @@ static int buf_write_bytes(struct bw_info *ip) mch_memmove(fp + ip->bw_restlen, buf, (size_t)len); from = fp; tolen = ip->bw_conv_buflen - fromlen; - } else { + } else { from = (const char *)buf; fromlen = len; tolen = ip->bw_conv_buflen; @@ -4513,13 +4515,13 @@ ucs2bytes ( *p++ = (c >> 8); *p++ = (c >> 16); *p++ = (c >> 24); - } else { + } else { *p++ = (c >> 24); *p++ = (c >> 16); *p++ = (c >> 8); *p++ = c; } - } else if (flags & (FIO_UCS2 | FIO_UTF16)) { + } else if (flags & (FIO_UCS2 | FIO_UTF16)) { if (c >= 0x10000) { if (flags & FIO_UTF16) { /* Make two words, ten bits of the character in each. First @@ -4531,7 +4533,7 @@ ucs2bytes ( if (flags & FIO_ENDIAN_L) { *p++ = cc; *p++ = ((unsigned)cc >> 8); - } else { + } else { *p++ = ((unsigned)cc >> 8); *p++ = cc; } @@ -4542,11 +4544,11 @@ ucs2bytes ( if (flags & FIO_ENDIAN_L) { *p++ = c; *p++ = (c >> 8); - } else { + } else { *p++ = (c >> 8); *p++ = c; } - } else { /* Latin1 */ + } else { /* Latin1 */ if (c >= 0x100) { error = TRUE; *p++ = 0xBF; @@ -4571,7 +4573,7 @@ static int need_conversion(char_u *fenc) if (*fenc == NUL || STRCMP(p_enc, fenc) == 0) { same_encoding = TRUE; fenc_flags = 0; - } else { + } else { /* Ignore difference between "ansi" and "latin1", "ucs-4" and * "ucs-4be", etc. */ enc_flags = get_fio_flags(p_enc); @@ -4643,7 +4645,7 @@ static char_u *check_for_bom(char_u *p, long size, int *lenp, int flags) && (flags == FIO_ALL || flags == FIO_UTF8 || flags == 0)) { name = "utf-8"; /* EF BB BF */ len = 3; - } else if (p[0] == 0xff && p[1] == 0xfe) { + } else if (p[0] == 0xff && p[1] == 0xfe) { if (size >= 4 && p[2] == 0 && p[3] == 0 && (flags == FIO_ALL || flags == (FIO_UCS4 | FIO_ENDIAN_L))) { name = "ucs-4le"; /* FF FE 00 00 */ @@ -4883,7 +4885,7 @@ buf_modname ( #ifndef SHORT_FNAME prepend_dot = FALSE; /* nothing to prepend a dot to */ #endif - } else { + } else { fnamelen = (int)STRLEN(fname); retval = alloc((unsigned)(fnamelen + extlen + 3)); if (retval == NULL) @@ -5480,11 +5482,11 @@ buf_check_timestamp ( mesg = _( "W12: Warning: File \"%s\" has changed and the buffer was changed in Vim as well"); mesg2 = _("See \":help W12\" for more info."); - } else if (reason[1] == 'h') { + } else if (reason[1] == 'h') { mesg = _( "W11: Warning: File \"%s\" has changed since editing started"); mesg2 = _("See \":help W11\" for more info."); - } else if (*reason == 'm') { + } else if (*reason == 'm') { mesg = _( "W16: Warning: Mode of file \"%s\" has changed since editing started"); mesg2 = _("See \":help W16\" for more info."); @@ -5524,14 +5526,14 @@ buf_check_timestamp ( (char_u *)_("&OK\n&Load File"), 1, NULL, TRUE) == 2) reload = TRUE; } else if (State > NORMAL_BUSY || (State & CMDLINE) || - already_warned) { + already_warned) { if (*mesg2 != NUL) { STRCAT(tbuf, "; "); STRCAT(tbuf, mesg2); } EMSG(tbuf); retval = 2; - } else { + } else { if (!autocmd_busy) { msg_start(); msg_puts_attr(tbuf, hl_attr(HLF_E) + MSG_HIST); @@ -5659,13 +5661,13 @@ void buf_reload(buf_T *buf, int orig_mode) break; (void)move_lines(savebuf, buf); } - } else if (buf == curbuf) { /* "buf" still valid */ + } else if (buf == curbuf) { /* "buf" still valid */ /* Mark the buffer as unmodified and free undo info. */ unchanged(buf, TRUE); if ((flags & READ_KEEP_UNDO) == 0) { u_blockfree(buf); u_clearall(buf); - } else { + } else { /* Mark all undo states as changed. */ u_unchanged(curbuf); } @@ -5741,7 +5743,8 @@ static long temp_count = 0; /* Temp filename counter. */ /* * Delete the temp directory and all files it contains. */ -void vim_deltempdir(void) { +void vim_deltempdir(void) +{ char_u **files; int file_count; int i; @@ -6262,7 +6265,8 @@ static void au_remove_cmds(AutoPat *ap) * Cleanup autocommands and patterns that have been deleted. * This is only done when not executing autocommands. */ -static void au_cleanup(void) { +static void au_cleanup(void) +{ AutoPat *ap, **prev_ap; AutoCmd *ac, **prev_ac; event_T event; @@ -6415,7 +6419,7 @@ void do_augroup(char_u *arg, int del_group) i = au_new_group(arg); if (i != AUGROUP_ERROR) current_augroup = i; - } else { /* ":aug": list the group names */ + } else { /* ":aug": list the group names */ msg_start(); for (i = 0; i < augroups.ga_len; ++i) { if (AUGROUP_NAME(i) != NULL) { @@ -6429,7 +6433,8 @@ void do_augroup(char_u *arg, int del_group) } #if defined(EXITFREE) || defined(PROTO) -void free_all_autocmds(void) { +void free_all_autocmds(void) +{ for (current_augroup = -1; current_augroup < augroups.ga_len; ++current_augroup) do_autocmd((char_u *)"", TRUE); @@ -6496,7 +6501,7 @@ find_end_event ( return NULL; } pat = arg + 1; - } else { + } else { for (pat = arg; *pat && !vim_iswhite(*pat); pat = p) { if ((int)event_name2nr(pat, &p) >= (int)NUM_EVENTS) { if (have_group) @@ -6530,7 +6535,8 @@ static int event_ignored(event_T event) /* * Return OK when the contents of p_ei is valid, FAIL otherwise. */ -int check_ei(void) { +int check_ei(void) +{ char_u *p = p_ei; while (*p) { @@ -6702,7 +6708,7 @@ void do_autocmd(char_u *arg, int forceit) if (do_autocmd_event(event, pat, nested, cmd, forceit, group) == FAIL) break; - } else { + } else { while (*arg && !vim_iswhite(*arg)) if (do_autocmd_event(event_name2nr(arg, &arg), pat, nested, cmd, forceit, group) == FAIL) @@ -6911,7 +6917,7 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd, if (is_buflocal) { ap->buflocal_nr = buflocal_nr; ap->reg_prog = NULL; - } else { + } else { char_u *reg_pat; ap->buflocal_nr = 0; @@ -7114,7 +7120,7 @@ aucmd_prepbuf ( * "buf" is curbuf). */ aco->use_aucmd_win = FALSE; curwin = win; - } else { + } else { /* There is no window for "buf", use "aucmd_win". To minimize the side * effects, insert it in the current tab page. * Anything related to a window (e.g., setting folds) may have @@ -7217,7 +7223,7 @@ win_found: curwin->w_topline = curbuf->b_ml.ml_line_count; curwin->w_topfill = 0; } - } else { + } else { /* restore curwin */ if (win_valid(aco->save_curwin)) { /* Restore the buffer which was previously edited by curwin, if @@ -7303,7 +7309,8 @@ apply_autocmds_retval ( /* * Return TRUE when there is a CursorHold autocommand defined. */ -int has_cursorhold(void) { +int has_cursorhold(void) +{ return first_autopat[(int)(get_real_state() == NORMAL_BUSY ? EVENT_CURSORHOLD : EVENT_CURSORHOLDI)] != NULL; } @@ -7311,7 +7318,8 @@ int has_cursorhold(void) { /* * Return TRUE if the CursorHold event can be triggered. */ -int trigger_cursorhold(void) { +int trigger_cursorhold(void) +{ int state; if (!did_cursorhold @@ -7330,35 +7338,40 @@ int trigger_cursorhold(void) { /* * Return TRUE when there is a CursorMoved autocommand defined. */ -int has_cursormoved(void) { +int has_cursormoved(void) +{ return first_autopat[(int)EVENT_CURSORMOVED] != NULL; } /* * Return TRUE when there is a CursorMovedI autocommand defined. */ -int has_cursormovedI(void) { +int has_cursormovedI(void) +{ return first_autopat[(int)EVENT_CURSORMOVEDI] != NULL; } /* * Return TRUE when there is a TextChanged autocommand defined. */ -int has_textchanged(void) { +int has_textchanged(void) +{ return first_autopat[(int)EVENT_TEXTCHANGED] != NULL; } /* * Return TRUE when there is a TextChangedI autocommand defined. */ -int has_textchangedI(void) { +int has_textchangedI(void) +{ return first_autopat[(int)EVENT_TEXTCHANGEDI] != NULL; } /* * Return TRUE when there is an InsertCharPre autocommand defined. */ -int has_insertcharpre(void) { +int has_insertcharpre(void) +{ return first_autopat[(int)EVENT_INSERTCHARPRE] != NULL; } @@ -7512,7 +7525,7 @@ apply_autocmds_group ( if (fname == NULL) fname = (char_u *)""; fname = vim_strsave(fname); /* make a copy, so we can change it */ - } else { + } else { sfname = vim_strsave(fname); /* Don't try expanding FileType, Syntax, FuncUndefined, WindowID, * ColorScheme or QuickFixCmd* */ @@ -7693,14 +7706,16 @@ static char_u *old_termresponse = NULL; * Block triggering autocommands until unblock_autocmd() is called. * Can be used recursively, so long as it's symmetric. */ -void block_autocmds(void) { +void block_autocmds(void) +{ /* Remember the value of v:termresponse. */ if (autocmd_blocked == 0) old_termresponse = get_vim_var_str(VV_TERMRESPONSE); ++autocmd_blocked; } -void unblock_autocmds(void) { +void unblock_autocmds(void) +{ --autocmd_blocked; /* When v:termresponse was set while autocommands were blocked, trigger @@ -7711,7 +7726,8 @@ void unblock_autocmds(void) { apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf); } -int is_autocmd_blocked(void) { +int is_autocmd_blocked(void) +{ return autocmd_blocked != 0; } @@ -8004,7 +8020,7 @@ int au_exists(char_u *arg) /* Didn't match a group name, assume the first argument is an event. */ group = AUGROUP_ALL; event_name = arg_save; - } else { + } else { if (p == NULL) { /* "Group": group name is present and it's recognized */ retval = TRUE; @@ -8358,7 +8374,7 @@ file_pat_to_reg_pat ( reg_pat[i++] = '\\'; reg_pat[i++] = '{'; p += 2; - } else { + } else { if (allow_dirs != NULL && vim_ispathsep(*p) #ifdef BACKSLASH_IN_FILENAME && (!no_bslash || *p != '\\') diff --git a/src/fold.c b/src/fold.c index 1e0bd604b7..b38253d7a6 100644 --- a/src/fold.c +++ b/src/fold.c @@ -435,7 +435,8 @@ void openFoldRecurse(linenr_T lnum) /* * Open folds until the cursor line is not in a closed fold. */ -void foldOpenCursor(void) { +void foldOpenCursor(void) +{ int done; checkupdate(curwin); @@ -452,7 +453,8 @@ void foldOpenCursor(void) { /* * Set new foldlevel for current window. */ -void newFoldLevel(void) { +void newFoldLevel(void) +{ newFoldLevelWin(curwin); if (foldmethodIsDiff(curwin) && curwin->w_p_scb) { @@ -493,7 +495,8 @@ static void newFoldLevelWin(win_T *wp) /* * Apply 'foldlevel' to all folds that don't contain the cursor. */ -void foldCheckClose(void) { +void foldCheckClose(void) +{ if (*p_fcl != NUL) { /* can only be "all" right now */ checkupdate(curwin); if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum, @@ -592,7 +595,7 @@ void foldCreate(linenr_T start, linenr_T end) } else if (fp->fd_flags == FD_CLOSED) closed = TRUE; ++level; - } else { + } else { /* This fold and new fold overlap: Insert here and move some folds * inside the new fold. */ break; @@ -710,7 +713,7 @@ deleteFold ( } if (found_ga == NULL) { ++lnum; - } else { + } else { lnum = found_fp->fd_top + found_fp->fd_len + found_off; if (foldmethodIsManual(curwin)) @@ -849,7 +852,7 @@ foldMoveTo ( if (fp - (fold_T *)gap->ga_data >= gap->ga_len) break; --fp; - } else { + } else { if (fp == (fold_T *)gap->ga_data) break; } @@ -877,7 +880,7 @@ foldMoveTo ( if (lnum > curwin->w_cursor.lnum) lnum_found = lnum; } - } else { + } else { /* to end of previous fold if there is one */ if (fp > (fold_T *)gap->ga_data) { lnum = fp[-1].fd_top + lnum_off + fp[-1].fd_len - 1; @@ -885,14 +888,14 @@ foldMoveTo ( lnum_found = lnum; } } - } else { + } else { /* Open fold found, set cursor to its start/end and then check * nested folds. */ if (dir == FORWARD) { lnum = fp->fd_top + lnum_off + fp->fd_len - 1; if (lnum > curwin->w_cursor.lnum) lnum_found = lnum; - } else { + } else { lnum = fp->fd_top + lnum_off; if (lnum < curwin->w_cursor.lnum) lnum_found = lnum; @@ -954,7 +957,8 @@ int find_wl_entry(win_T *win, linenr_T lnum) /* * Adjust the Visual area to include any fold at the start or end completely. */ -void foldAdjustVisual(void) { +void foldAdjustVisual(void) +{ pos_T *start, *end; char_u *ptr; @@ -964,7 +968,7 @@ void foldAdjustVisual(void) { if (ltoreq(VIsual, curwin->w_cursor)) { start = &VIsual; end = &curwin->w_cursor; - } else { + } else { start = &curwin->w_cursor; end = &VIsual; } @@ -985,7 +989,8 @@ void foldAdjustVisual(void) { /* * Move the cursor to the first line of a closed fold. */ -void foldAdjustCursor(void) { +void foldAdjustCursor(void) +{ (void)hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL); } @@ -1223,7 +1228,7 @@ setManualFoldWin ( done |= DONE_ACTION; fp->fd_flags = FD_CLOSED; } - } else if (fp->fd_flags == FD_CLOSED) { + } else if (fp->fd_flags == FD_CLOSED) { /* When opening, open topmost closed fold. */ if (opening) { fp->fd_flags = FD_OPEN; @@ -1296,7 +1301,7 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive) --gap->ga_len; if (idx < gap->ga_len) mch_memmove(fp, fp + 1, sizeof(fold_T) * (gap->ga_len - idx)); - } else { + } else { /* Move nested folds one level up, to overwrite the fold that is * deleted. */ moved = fp->fd_nested.ga_len; @@ -1401,7 +1406,7 @@ static void foldMarkAdjustRecurse(garray_T *gap, linenr_T line1, linenr_T line2, if (amount_after == 0) break; fp->fd_top += amount_after; - } else { + } else { if (fp->fd_top >= top && last <= line2) { /* 4. fold completely contained in range */ if (amount == MAXLNUM) { @@ -1411,7 +1416,7 @@ static void foldMarkAdjustRecurse(garray_T *gap, linenr_T line1, linenr_T line2, --fp; } else fp->fd_top += amount; - } else { + } else { if (fp->fd_top < top) { /* 2 or 3: need to correct nested folds too */ foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top, @@ -1422,11 +1427,11 @@ static void foldMarkAdjustRecurse(garray_T *gap, linenr_T line1, linenr_T line2, fp->fd_len = line1 - fp->fd_top; else fp->fd_len += amount; - } else { + } else { /* 3. fold contains line1 and line2 */ fp->fd_len += amount_after; } - } else { + } else { /* 5. fold is below line1 and contains line2; need to * correct nested folds too */ foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top, @@ -1435,7 +1440,7 @@ static void foldMarkAdjustRecurse(garray_T *gap, linenr_T line1, linenr_T line2, if (amount == MAXLNUM) { fp->fd_len -= line2 - fp->fd_top + 1; fp->fd_top = line1; - } else { + } else { fp->fd_len += amount_after - amount; fp->fd_top += amount; } @@ -1450,7 +1455,8 @@ static void foldMarkAdjustRecurse(garray_T *gap, linenr_T line1, linenr_T line2, * Get the lowest 'foldlevel' value that makes the deepest nested fold in the * current window open. */ -int getDeepestNesting(void) { +int getDeepestNesting(void) +{ checkupdate(curwin); return getDeepestNestingRecurse(&curwin->w_folds); } @@ -1836,7 +1842,7 @@ void foldtext_cleanup(char_u *str) len += (int)(s - p) + cms_slen; s = p - cms_slen; } - } else if (cms_end != NULL) { + } else if (cms_end != NULL) { if (!did1 && cms_slen > 0 && STRNCMP(s, cms_start, cms_slen) == 0) { len = cms_slen; did1 = TRUE; @@ -1850,7 +1856,7 @@ void foldtext_cleanup(char_u *str) while (vim_iswhite(s[len])) ++len; STRMOVE(s, s + len); - } else { + } else { mb_ptr_adv(s); } } @@ -1972,7 +1978,7 @@ static void foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot) } fline.lnum = top; getlevel(&fline); - } else { + } else { fline.lnum = top; if (foldmethodIsExpr(wp)) { getlevel = foldlevelExpr; @@ -2073,7 +2079,7 @@ static void foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot) end = foldUpdateIEMSRecurse(&wp->w_folds, 1, start, &fline, getlevel, end, FD_LEVEL); start = fline.lnum; - } else { + } else { if (fline.lnum == wp->w_buffer->b_ml.ml_line_count) break; ++fline.lnum; @@ -2301,7 +2307,7 @@ int topflags; /* flags used by containing fold */ * looking for the next one. */ deleteFoldEntry(gap, (int)(fp - (fold_T *)gap->ga_data), TRUE); - } else { + } else { /* A fold has some lines above startlnum, truncate it * to stop just above startlnum. */ fp->fd_len = startlnum - fp->fd_top; @@ -2310,7 +2316,7 @@ int topflags; /* flags used by containing fold */ (linenr_T)MAXLNUM, 0L); fold_changed = TRUE; } - } else { + } else { /* Insert new fold. Careful: ga_data may be NULL and it * may change! */ i = (int)(fp - (fold_T *)gap->ga_data); @@ -2327,7 +2333,7 @@ int topflags; /* flags used by containing fold */ if (topflags == FD_OPEN) { flp->wp->w_fold_manual = TRUE; fp->fd_flags = FD_OPEN; - } else if (i <= 0) { + } else if (i <= 0) { fp->fd_flags = topflags; if (topflags != FD_LEVEL) flp->wp->w_fold_manual = TRUE; @@ -2382,7 +2388,7 @@ int topflags; /* flags used by containing fold */ startlnum2 = flp->lnum; /* This fold may end at the same line, don't incr. flp->lnum. */ - } else { + } else { /* * Get the level of the next line, then continue the loop to check * if it ends there. @@ -2447,7 +2453,7 @@ int topflags; /* flags used by containing fold */ * previously included lines are processed again */ bot = fp->fd_top + fp->fd_len - 1; fp->fd_len = flp->lnum - fp->fd_top; - } else { + } else { /* indent or expr method: split fold to create a new one * below bot */ i = (int)(fp - (fold_T *)gap->ga_data); @@ -2594,7 +2600,7 @@ static void foldRemove(garray_T *gap, linenr_T top, linenr_T bot) if (fp->fd_top + fp->fd_len > bot + 1) { /* 3: need to split it. */ foldSplit(gap, (int)(fp - (fold_T *)gap->ga_data), top, bot); - } else { + } else { /* 2: truncate fold at "top". */ fp->fd_len = top - fp->fd_top; } @@ -2856,7 +2862,7 @@ static void foldlevelMarker(fline_T *flp) else flp->start = n - start_lvl; } - } else { + } else { ++flp->lvl; ++flp->lvl_next; ++flp->start; @@ -2987,7 +2993,7 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off if (put_fold_open_close(fd, fp, off) == FAIL) return FAIL; } - } else { + } else { /* Open or close the leaf according to the window foldlevel. * Do not close a leaf that is already closed, as it will close * the parent. */ diff --git a/src/getchar.c b/src/getchar.c index 909d674a0f..f33a2279cb 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -203,7 +203,8 @@ get_buffcont ( * and clear the record buffer. * K_SPECIAL and CSI in the returned string are escaped. */ -char_u *get_recorded(void) { +char_u *get_recorded(void) +{ char_u *p; size_t len; @@ -234,7 +235,8 @@ char_u *get_recorded(void) { * Return the contents of the redo buffer as a single string. * K_SPECIAL and CSI in the returned string are escaped. */ -char_u *get_inserted(void) { +char_u *get_inserted(void) +{ return get_buffcont(&redobuff, FALSE); } @@ -260,7 +262,7 @@ add_buff ( if (buf->bh_first.b_next == NULL) { /* first add to list */ buf->bh_space = 0; buf->bh_curr = &(buf->bh_first); - } else if (buf->bh_curr == NULL) { /* buffer has already been read */ + } else if (buf->bh_curr == NULL) { /* buffer has already been read */ EMSG(_("E222: Add to read buffer")); return; } else if (buf->bh_index != 0) @@ -273,7 +275,7 @@ add_buff ( len = (long_u)STRLEN(buf->bh_curr->b_str); vim_strncpy(buf->bh_curr->b_str + len, s, (size_t)slen); buf->bh_space -= slen; - } else { + } else { if (slen < MINIMAL_SIZE) len = MINIMAL_SIZE; else @@ -328,7 +330,7 @@ static void add_char_buff(struct buffheader *buf, int c) temp[1] = K_SECOND(c); temp[2] = K_THIRD(c); temp[3] = NUL; - } else { + } else { temp[0] = c; temp[1] = NUL; } @@ -365,7 +367,8 @@ static int read_stuff(int advance) /* * Prepare the stuff buffer for reading (if it contains something). */ -static void start_stuff(void) { +static void start_stuff(void) +{ if (stuffbuff.bh_first.b_next != NULL) { stuffbuff.bh_curr = &(stuffbuff.bh_first); stuffbuff.bh_space = 0; @@ -375,7 +378,8 @@ static void start_stuff(void) { /* * Return TRUE if the stuff buffer is empty. */ -int stuff_empty(void) { +int stuff_empty(void) +{ return stuffbuff.bh_first.b_next == NULL; } @@ -411,7 +415,7 @@ void flush_buffers(int flush_typeahead) ; typebuf.tb_off = MAXMAPLEN; typebuf.tb_len = 0; - } else { /* remove mapped characters at the start only */ + } else { /* remove mapped characters at the start only */ typebuf.tb_off += typebuf.tb_maplen; typebuf.tb_len -= typebuf.tb_maplen; } @@ -425,7 +429,8 @@ void flush_buffers(int flush_typeahead) * The previous contents of the redo buffer is kept in old_redobuffer. * This is used for the CTRL-O <.> command in insert mode. */ -void ResetRedobuff(void) { +void ResetRedobuff(void) +{ if (!block_redo) { free_buff(&old_redobuff); old_redobuff = redobuff; @@ -437,7 +442,8 @@ void ResetRedobuff(void) { * Discard the contents of the redo buffer and restore the previous redo * buffer. */ -void CancelRedo(void) { +void CancelRedo(void) +{ if (!block_redo) { free_buff(&redobuff); redobuff = old_redobuff; @@ -454,7 +460,8 @@ void CancelRedo(void) { */ static int save_level = 0; -void saveRedobuff(void) { +void saveRedobuff(void) +{ char_u *s; if (save_level++ == 0) { @@ -476,7 +483,8 @@ void saveRedobuff(void) { * Restore redobuff and old_redobuff from save_redobuff and save_old_redobuff. * Used after executing autocommands and user functions. */ -void restoreRedobuff(void) { +void restoreRedobuff(void) +{ if (--save_level == 0) { free_buff(&redobuff); redobuff = save_redobuff; @@ -595,7 +603,7 @@ void stuffReadbuffSpec(char_u *s) /* Insert special key literally. */ stuffReadbuffLen(s, 3L); s += 3; - } else { + } else { c = mb_ptr2char_adv(&s); if (c == CAR || c == NL || c == ESC) c = ' '; @@ -751,7 +759,8 @@ int start_redo(long count, int old_redo) * the redo buffer into the stuffbuff. * return FAIL for failure, OK otherwise */ -int start_redo_ins(void) { +int start_redo_ins(void) +{ int c; if (read_redo(TRUE, FALSE) == FAIL) @@ -773,7 +782,8 @@ int start_redo_ins(void) { return OK; } -void stop_redo_ins(void) { +void stop_redo_ins(void) +{ block_redo = FALSE; } @@ -782,7 +792,8 @@ void stop_redo_ins(void) { * alloc() cannot be used here: In out-of-memory situations it would * be impossible to type anything. */ -static void init_typebuf(void) { +static void init_typebuf(void) +{ if (typebuf.tb_buf == NULL) { typebuf.tb_buf = typebuf_init; typebuf.tb_noremap = noremapbuf_init; @@ -941,7 +952,7 @@ void ins_char_typebuf(int c) buf[1] = K_SECOND(c); buf[2] = K_THIRD(c); buf[3] = NUL; - } else { + } else { buf[(*mb_char2bytes)(c, buf)] = NUL; } (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); @@ -970,14 +981,16 @@ typebuf_changed ( * Return TRUE if there are no characters in the typeahead buffer that have * not been typed (result from a mapping or come from ":normal"). */ -int typebuf_typed(void) { +int typebuf_typed(void) +{ return typebuf.tb_maplen == 0; } /* * Return the number of characters that are mapped (or not typed). */ -int typebuf_maplen(void) { +int typebuf_maplen(void) +{ return typebuf.tb_maplen; } @@ -1094,7 +1107,8 @@ static void gotchars(char_u *chars, int len) * - While reading a script file. * - When no_u_sync is non-zero. */ -static void may_sync_undo(void) { +static void may_sync_undo(void) +{ if ((!(State & (INSERT + CMDLINE)) || arrow_used) && scriptin[curscript] == NULL) u_sync(FALSE); @@ -1104,7 +1118,8 @@ static void may_sync_undo(void) { * Make "typebuf" empty and allocate new buffers. * Returns FAIL when out of memory. */ -int alloc_typebuf(void) { +int alloc_typebuf(void) +{ typebuf.tb_buf = alloc(TYPELEN_INIT); typebuf.tb_noremap = alloc(TYPELEN_INIT); if (typebuf.tb_buf == NULL || typebuf.tb_noremap == NULL) { @@ -1125,7 +1140,8 @@ int alloc_typebuf(void) { /* * Free the buffers of "typebuf". */ -void free_typebuf(void) { +void free_typebuf(void) +{ if (typebuf.tb_buf == typebuf_init) EMSG2(_(e_intern2), "Free typebuf 1"); else @@ -1142,7 +1158,8 @@ void free_typebuf(void) { */ static typebuf_T saved_typebuf[NSCRIPT]; -int save_typebuf(void) { +int save_typebuf(void) +{ init_typebuf(); saved_typebuf[curscript] = typebuf; /* If out of memory: restore typebuf and close file. */ @@ -1271,7 +1288,8 @@ openscript ( /* * Close the currently active input script. */ -static void closescript(void) { +static void closescript(void) +{ free_typebuf(); typebuf = saved_typebuf[curscript]; @@ -1282,7 +1300,8 @@ static void closescript(void) { } #if defined(EXITFREE) || defined(PROTO) -void close_all_scripts(void) { +void close_all_scripts(void) +{ while (scriptin[0] != NULL) closescript(); } @@ -1292,7 +1311,8 @@ void close_all_scripts(void) { /* * Return TRUE when reading keys from a script file. */ -int using_script(void) { +int using_script(void) +{ return scriptin[curscript] != NULL; } @@ -1300,7 +1320,8 @@ int using_script(void) { * This function is called just before doing a blocking wait. Thus after * waiting 'updatetime' for a character to arrive. */ -void before_blocking(void) { +void before_blocking(void) +{ updatescript(0); if (may_garbage_collect) garbage_collect(); @@ -1334,7 +1355,8 @@ void updatescript(int c) * Collects the bytes of a multibyte character into the whole character. * Returns the modifiers in the global "mod_mask". */ -int vgetc(void) { +int vgetc(void) +{ int c, c2; int n; char_u buf[MB_MAXBYTES + 1]; @@ -1355,7 +1377,7 @@ int vgetc(void) { mod_mask = old_mod_mask; mouse_row = old_mouse_row; mouse_col = old_mouse_col; - } else { + } else { mod_mask = 0x0; last_recorded_len = 0; for (;; ) { /* this is done twice if there are modifiers */ @@ -1413,7 +1435,7 @@ int vgetc(void) { case K_ZHOME: if (mod_mask == MOD_MASK_SHIFT) { c = K_S_HOME; mod_mask = 0; - } else if (mod_mask == MOD_MASK_CTRL) { + } else if (mod_mask == MOD_MASK_CTRL) { c = K_C_HOME; mod_mask = 0; } else @@ -1423,7 +1445,7 @@ int vgetc(void) { case K_ZEND: if (mod_mask == MOD_MASK_SHIFT) { c = K_S_END; mod_mask = 0; - } else if (mod_mask == MOD_MASK_CTRL) { + } else if (mod_mask == MOD_MASK_CTRL) { c = K_C_END; mod_mask = 0; } else @@ -1479,7 +1501,8 @@ int vgetc(void) { * Like vgetc(), but never return a NUL when called recursively, get a key * directly from the user (ignoring typeahead). */ -int safe_vgetc(void) { +int safe_vgetc(void) +{ int c; c = vgetc(); @@ -1492,7 +1515,8 @@ int safe_vgetc(void) { * Like safe_vgetc(), but loop to handle K_IGNORE. * Also ignore scrollbar events. */ -int plain_vgetc(void) { +int plain_vgetc(void) +{ int c; do { @@ -1506,7 +1530,8 @@ int plain_vgetc(void) { * If the next character is a special character or multi-byte, the returned * character is not valid!. */ -int vpeekc(void) { +int vpeekc(void) +{ if (old_char != -1) return old_char; return vgetorpeek(FALSE); @@ -1516,7 +1541,8 @@ int vpeekc(void) { * Like vpeekc(), but don't allow mapping. Do allow checking for terminal * codes. */ -int vpeekc_nomap(void) { +int vpeekc_nomap(void) +{ int c; ++no_mapping; @@ -1532,7 +1558,8 @@ int vpeekc_nomap(void) { * Trick: when no typeahead found, but there is something in the typeahead * buffer, it must be an ESC that is recognized as the start of a key code. */ -int vpeekc_any(void) { +int vpeekc_any(void) +{ int c; c = vpeekc(); @@ -1545,7 +1572,8 @@ int vpeekc_any(void) { * Call vpeekc() without causing anything to be mapped. * Return TRUE if a character is available, FALSE otherwise. */ -int char_avail(void) { +int char_avail(void) +{ int retval; ++no_mapping; @@ -1657,7 +1685,7 @@ static int vgetorpeek(int advance) } if (typebuf.tb_no_abbr_cnt == 0) typebuf.tb_no_abbr_cnt = 1; /* no abbreviations now */ - } else { + } else { /* * Loop until we either find a matching mapped key, or we * are sure that it is not a mapped key. @@ -1702,7 +1730,7 @@ static int vgetorpeek(int advance) cmd_silent = FALSE; break; - } else if (typebuf.tb_len > 0) { + } else if (typebuf.tb_len > 0) { /* * Check for a mappable key sequence. * Walk through one maphash[] list until we find an @@ -1829,7 +1857,7 @@ static int vgetorpeek(int advance) keylen = KEYLEN_PART_MAP; break; } - } else if (keylen > mp_match_len) { + } else if (keylen > mp_match_len) { /* found a longer match */ mp_match = mp; mp_match_len = keylen; @@ -2138,11 +2166,11 @@ static int vgetorpeek(int advance) curwin->w_wcol %= W_WIDTH(curwin); curwin->w_wcol += curwin_col_off(); col = 0; /* no correction needed */ - } else { + } else { --curwin->w_wcol; col = curwin->w_cursor.col - 1; } - } else if (curwin->w_p_wrap && curwin->w_wrow) { + } else if (curwin->w_p_wrap && curwin->w_wrow) { --curwin->w_wrow; curwin->w_wcol = W_WIDTH(curwin) - 1; col = curwin->w_cursor.col - 1; @@ -2298,7 +2326,7 @@ static int vgetorpeek(int advance) timedout = TRUE; continue; } - } else { /* allow mapping for just typed characters */ + } else { /* allow mapping for just typed characters */ while (typebuf.tb_buf[typebuf.tb_off + typebuf.tb_len] != NUL) typebuf.tb_noremap[typebuf.tb_off @@ -2326,7 +2354,7 @@ static int vgetorpeek(int advance) redraw_cmdline = TRUE; /* delete mode later */ else unshowmode(FALSE); - } else if (c != ESC && mode_deleted) { + } else if (c != ESC && mode_deleted) { if (typebuf.tb_len && !KeyTyped) redraw_cmdline = TRUE; /* show mode later */ else @@ -2414,7 +2442,7 @@ inchar ( retesc = TRUE; else return -1; - } else { + } else { buf[0] = script_char; len = 1; } @@ -2508,7 +2536,8 @@ fix_input_buffer ( * or feedkeys() may insert characters in the typeahead buffer while we are * waiting for input to arrive. */ -int input_available(void) { +int input_available(void) +{ return !vim_is_input_buf_empty() || typebuf_was_filled ; @@ -2829,7 +2858,7 @@ do_map ( if (!haskey) { /* show all entries */ showmap(mp, TRUE); did_local = TRUE; - } else { + } else { n = mp->m_keylen; if (STRNCMP(mp->m_keys, keys, (size_t)(n < len ? n : len)) == 0) { @@ -2869,11 +2898,11 @@ do_map ( if (!haskey) { /* show all entries */ showmap(mp, map_table != maphash); did_it = TRUE; - } else { /* do we have a match? */ + } else { /* do we have a match? */ if (round) { /* second round: Try unmap "rhs" string */ n = (int)STRLEN(mp->m_str); p = mp->m_str; - } else { + } else { n = mp->m_keylen; p = mp->m_keys; } @@ -2894,13 +2923,13 @@ do_map ( */ mp->m_mode &= ~mode; did_it = TRUE; /* remember we did something */ - } else if (!hasarg) { /* show matching entry */ + } else if (!hasarg) { /* show matching entry */ showmap(mp, map_table != maphash); did_it = TRUE; - } else if (n != len) { /* new entry is ambiguous */ + } else if (n != len) { /* new entry is ambiguous */ mpp = &(mp->m_next); continue; - } else if (unique) { + } else if (unique) { if (abbrev) EMSG2(_("E226: abbreviation already exists for %s"), p); @@ -2908,7 +2937,7 @@ do_map ( EMSG2(_("E227: mapping already exists for %s"), p); retval = 5; goto theend; - } else { /* new rhs for existing entry */ + } else { /* new rhs for existing entry */ mp->m_mode &= ~mode; /* remove mode bits */ if (mp->m_mode == 0 && !did_it) { /* reuse entry */ newstr = vim_strsave(rhs); @@ -3009,7 +3038,7 @@ do_map ( if (abbrev) { mp->m_next = *abbr_table; *abbr_table = mp; - } else { + } else { n = MAP_HASH(mp->m_mode, mp->m_keys[0]); mp->m_next = map_table[n]; map_table[n] = mp; @@ -3040,7 +3069,8 @@ static void map_free(mapblock_T **mpp) /* * Initialize maphash[] for first use. */ -static void validate_maphash(void) { +static void validate_maphash(void) +{ if (!maphash_valid) { vim_memset(maphash, 0, sizeof(maphash)); maphash_valid = TRUE; @@ -3132,7 +3162,7 @@ map_clear_int ( mpp = &buf->b_first_abbr; else mpp = &first_abbr; - } else { + } else { if (local) mpp = &buf->b_maphash[hash]; else @@ -3155,7 +3185,7 @@ map_clear_int ( if (local) { mp->m_next = buf->b_maphash[new_hash]; buf->b_maphash[new_hash] = mp; - } else { + } else { mp->m_next = maphash[new_hash]; maphash[new_hash] = mp; } @@ -3594,7 +3624,7 @@ int check_abbr(int c, char_u *ptr, int col, int mincol) ++clen; } scol = (int)(p - ptr); - } else { + } else { if (!vim_iswordc(ptr[col - 1])) vim_abbr = TRUE; /* Vim added abbr. */ else { @@ -3648,7 +3678,7 @@ int check_abbr(int c, char_u *ptr, int col, int mincol) tb[j++] = K_SPECIAL; tb[j++] = K_SECOND(c); tb[j++] = K_THIRD(c); - } else { + } else { if (c < ABBR_OFF && (c < ' ' || c > '~')) tb[j++] = Ctrl_V; /* special char needs CTRL-V */ if (has_mbyte) { @@ -3766,7 +3796,7 @@ char_u *vim_strsave_escape_csi(char_u *p) *d++ = *s++; *d++ = *s++; *d++ = *s++; - } else { + } else { int len = mb_char2len(PTR2CHAR(s)); int len2 = mb_ptr2len(s); /* Add character, possibly multi-byte to destination, escaping @@ -3841,7 +3871,7 @@ makemap ( mp = buf->b_first_abbr; else mp = first_abbr; - } else { + } else { if (buf != NULL) mp = buf->b_maphash[hash]; else @@ -4068,7 +4098,7 @@ int put_escstr(FILE *fd, char_u *strstart, int what) if (what == 2) { if (fprintf(fd, IF_EB("\\\026\n", "\\" CTRL_V_STR "\n")) < 0) return FAIL; - } else { + } else { if (fprintf(fd, "<NL>") < 0) return FAIL; } @@ -4106,7 +4136,8 @@ int put_escstr(FILE *fd, char_u *strstart, int what) * Check all mappings for the presence of special key codes. * Used after ":set term=xxx". */ -void check_map_keycodes(void) { +void check_map_keycodes(void) +{ mapblock_T *mp; char_u *p; int i; @@ -4136,7 +4167,7 @@ void check_map_keycodes(void) { mp = bp->b_first_abbr; else mp = first_abbr; - } else { + } else { if (bp != NULL) mp = bp->b_maphash[hash]; else diff --git a/src/hardcopy.c b/src/hardcopy.c index 9e637e3032..2b2569580d 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -193,7 +193,8 @@ static void prt_get_attr(int hl_id, prt_text_attr_T* pattr, int modec); * Parse 'printoptions' and set the flags in "printer_opts". * Returns an error message or NULL; */ -char_u *parse_printoptions(void) { +char_u *parse_printoptions(void) +{ return parse_list_options(p_popt, printer_opts, OPT_PRINT_NUM_OPTIONS); } @@ -201,7 +202,8 @@ char_u *parse_printoptions(void) { * Parse 'printoptions' and set the flags in "printer_opts". * Returns an error message or NULL; */ -char_u *parse_printmbfont(void) { +char_u *parse_printmbfont(void) +{ return parse_list_options(p_pmfn, mbfont_opts, OPT_MBFONT_NUM_OPTIONS); } @@ -386,7 +388,8 @@ static void prt_line_number(prt_settings_T *psettings, int page_line, linenr_T l /* * Get the currently effective header height. */ -int prt_header_height(void) { +int prt_header_height(void) +{ if (printer_opts[OPT_PRINT_HEADERHEIGHT].present) return printer_opts[OPT_PRINT_HEADERHEIGHT].number; return 2; @@ -395,7 +398,8 @@ int prt_header_height(void) { /* * Return TRUE if using a line number for printing. */ -int prt_use_number(void) { +int prt_use_number(void) +{ return printer_opts[OPT_PRINT_NUMBER].present && TOLOWER_ASC(printer_opts[OPT_PRINT_NUMBER].string[0]) == 'y'; } @@ -695,7 +699,7 @@ void ex_hardcopy(exarg_T *eap) STRLEN(skipwhite(ml_get(prtpos.file_line))); if (++prtpos.file_line > eap->line2) break; /* reached the end */ - } else if (prtpos.ff) { + } else if (prtpos.ff) { /* Line had a formfeed in it - start new page but * stay on the current line */ break; @@ -763,7 +767,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T if (!ppos->ff && prt_use_number()) prt_line_number(psettings, page_line, ppos->file_line); ppos->ff = FALSE; - } else { + } else { /* left over from wrap halfway a tab */ print_pos = ppos->print_pos; tab_spaces = ppos->lead_spaces; @@ -823,7 +827,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T == 'y') { ppos->ff = TRUE; need_break = 1; - } else { + } else { need_break = mch_print_text_out(line + col, outputlen); if (has_mbyte) print_pos += (*mb_ptr2cells)(line + col); @@ -1507,7 +1511,8 @@ static void prt_def_var(char *name, double value, int prec) /* Convert size from font space to user space at current font scale */ #define PRT_PS_FONT_TO_USER(scale, size) ((size) * ((scale)/1000.0)) -static void prt_flush_buffer(void) { +static void prt_flush_buffer(void) +{ if (prt_ps_buffer.ga_len > 0) { /* Any background color must be drawn first */ if (prt_do_bgcol && (prt_new_bgcol != PRCOLOR_WHITE)) { @@ -1624,7 +1629,8 @@ struct prt_resfile_buffer_S { static struct prt_resfile_buffer_S prt_resfile; -static int prt_resfile_next_line(void) { +static int prt_resfile_next_line(void) +{ int idx; /* Move to start of next line and then find end of line */ @@ -1707,7 +1713,7 @@ static int prt_next_dsc(struct prt_dsc_line_S *p_dsc_line) /* Return type of comment */ p_dsc_line->type = prt_dsc_table[comment].type; offset = prt_dsc_table[comment].len; - } else { + } else { /* Unrecognised DSC comment, skip to ws after comment leader */ p_dsc_line->type = PRT_DSC_MISC_TYPE; offset = prt_resfile_skip_nonws(0); @@ -1858,7 +1864,8 @@ static int prt_check_resource(struct prt_ps_resource_S *resource, char_u *versio return TRUE; } -static void prt_dsc_start(void) { +static void prt_dsc_start(void) +{ prt_write_string("%!PS-Adobe-3.0\n"); } @@ -1983,7 +1990,8 @@ static void prt_dsc_docmedia(char *paper_name, double width, double height, doub prt_write_string("\n"); } -void mch_print_cleanup(void) { +void mch_print_cleanup(void) +{ if (prt_out_mbyte) { int i; @@ -2063,7 +2071,8 @@ static void prt_font_metrics(int font_scale) } -static int prt_get_cpl(void) { +static int prt_get_cpl(void) +{ if (prt_use_number()) { prt_number_width = PRINT_NUMBER_WIDTH * prt_char_width; /* If we are outputting multi-byte characters then line numbers will be @@ -2094,7 +2103,8 @@ static int prt_build_cid_fontname(int font, char_u *name, int name_len) /* * Get number of lines of text that fit on a page (excluding the header). */ -static int prt_get_lpp(void) { +static int prt_get_lpp(void) +{ int lpp; /* @@ -2231,7 +2241,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) (char_u *)p_mbchar->cmap_charset, sizeof(prt_cmap) - 3); STRCAT(prt_cmap, "-"); } - } else { + } else { /* Add custom CMap character set name */ if (*p_pmcs == NUL) { EMSG(_("E674: printmbcharset cannot be empty with multi-byte encoding.")); @@ -2290,7 +2300,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) } prt_ps_font = &prt_ps_mb_font; - } else { + } else { prt_use_courier = FALSE; prt_ps_font = &prt_ps_courier_font; } @@ -2304,7 +2314,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) if (printer_opts[OPT_PRINT_PAPER].present) { paper_name = (char *)printer_opts[OPT_PRINT_PAPER].string; paper_strlen = printer_opts[OPT_PRINT_PAPER].strlen; - } else { + } else { paper_name = "A4"; paper_strlen = 2; } @@ -2327,7 +2337,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) if (prt_portrait) { prt_page_width = prt_mediasize[i].width; prt_page_height = prt_mediasize[i].height; - } else { + } else { prt_page_width = prt_mediasize[i].height; prt_page_height = prt_mediasize[i].width; } @@ -2378,7 +2388,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) if (prt_collate) { /* TODO: Get number of collated copies wanted. */ psettings->n_collated_copies = 1; - } else { + } else { /* TODO: Get number of uncollated copies wanted and update the cached * count. */ @@ -2414,7 +2424,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) return FAIL; } prt_ps_fd = mch_fopen((char *)prt_ps_file_name, WRITEBIN); - } else { + } else { p = expand_env_save(psettings->outfile); if (p != NULL) { prt_ps_fd = mch_fopen((char *)p, WRITEBIN); @@ -2558,7 +2568,7 @@ int mch_print_begin(prt_settings_T *psettings) bbox[2] = (int)(left + psettings->chars_per_line * prt_char_width + 0.5); bbox[3] = (int)(top + 0.5); - } else { + } else { /* In landscape printing the fixed point is the bottom left corner so we * derive the bbox from that point. We have lpp chars across the media * and cpl lines up the media. @@ -2636,7 +2646,7 @@ int mch_print_begin(prt_settings_T *psettings) return FALSE; /* For the moment there are no checks on encoding resource files to * perform */ - } else { + } else { p_encoding = enc_skip(p_penc); if (*p_encoding == NUL) p_encoding = enc_skip(p_enc); @@ -2894,7 +2904,8 @@ void mch_print_end(prt_settings_T *psettings) mch_print_cleanup(); } -int mch_print_end_page(void) { +int mch_print_end_page(void) +{ prt_flush_buffer(); prt_write_string("re sp\n"); @@ -2941,7 +2952,8 @@ int mch_print_begin_page(char_u *str) return !prt_file_error; } -int mch_print_blank_page(void) { +int mch_print_blank_page(void) +{ return mch_print_begin_page(NULL) ? (mch_print_end_page()) : FALSE; } @@ -2990,7 +3002,7 @@ int mch_print_text_out(char_u *p, int len) prt_need_font = TRUE; prt_attribute_change = TRUE; } - } else if (in_ascii) { + } else if (in_ascii) { /* Now in ASCII range - need to switch font */ prt_in_ascii = TRUE; prt_need_font = TRUE; @@ -3008,7 +3020,7 @@ int mch_print_text_out(char_u *p, int len) prt_need_moveto = TRUE; prt_attribute_change = TRUE; } - } else if (half_width) { + } else if (half_width) { prt_half_width = TRUE; prt_pos_x += prt_char_width/4; prt_need_moveto = TRUE; @@ -3090,7 +3102,7 @@ int mch_print_text_out(char_u *p, int len) ga_append(&prt_ps_buffer, ch); p++; } while (--len); - } else { + } else { /* Add next character to buffer of characters to output. * Note: One printed character may require several PS characters to * represent it, but we only count them as one printed character. diff --git a/src/if_cscope.c b/src/if_cscope.c index 8d03bfe2e3..edfc2b7596 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -278,7 +278,7 @@ void do_cstag(exarg_T *eap) if (cs_check_for_tags()) ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE); } - } else if (cs_check_for_tags()) { + } else if (cs_check_for_tags()) { ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE); } break; @@ -296,7 +296,7 @@ void do_cstag(exarg_T *eap) cs_free_tags(); } } - } else if (cs_check_for_connections()) { + } else if (cs_check_for_connections()) { ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, FALSE, FALSE, *eap->cmdlinep); if (ret == FALSE) @@ -340,7 +340,8 @@ int cs_fgets(char_u *buf, int size) * * called only from do_tag(), when popping the tag stack */ -void cs_free_tags(void) { +void cs_free_tags(void) +{ cs_manage_matches(NULL, NULL, -1, Free); } @@ -349,7 +350,8 @@ void cs_free_tags(void) { * * called from do_tag() */ -void cs_print_tags(void) { +void cs_print_tags(void) +{ cs_manage_matches(NULL, NULL, -1, Print); } @@ -558,7 +560,7 @@ staterr: #endif { i = cs_insert_filelist(fname, ppath, flags, &statbuf); - } else { + } else { if (p_csverbose) (void)EMSG2( _("E564: %s is not a directory or a valid cscope database"), @@ -594,11 +596,13 @@ add_err: } /* cs_add_common */ -static int cs_check_for_connections(void) { +static int cs_check_for_connections(void) +{ return cs_cnt_connections() > 0; } /* cs_check_for_connections */ -static int cs_check_for_tags(void) { +static int cs_check_for_tags(void) +{ return p_tags[0] != NUL && curbuf->b_p_tags != NULL; } /* cs_check_for_tags */ @@ -607,7 +611,8 @@ static int cs_check_for_tags(void) { * * count the number of cscope connections */ -static int cs_cnt_connections(void) { +static int cs_cnt_connections(void) +{ short i; short cnt = 0; @@ -1158,7 +1163,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us vim_free(tmp); vim_free(nummatches); return TRUE; - } else { + } else { char **matches = NULL, **contexts = NULL; int matched = 0; @@ -1237,7 +1242,8 @@ static void clear_csinfo(int i) #ifndef UNIX static char *GetWin32Error(void); -static char *GetWin32Error(void) { +static char *GetWin32Error(void) +{ char *msg = NULL; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL); @@ -1321,7 +1327,7 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags, struct stat * reallocated. */ csinfo_size = 1; csinfo = (csinfo_T *)alloc_clear(sizeof(csinfo_T)); - } else { + } else { /* Reallocate space for more connections. */ csinfo_size *= 2; csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size); @@ -1437,7 +1443,7 @@ static int cs_kill(exarg_T *eap) if ((i != -1) && (i >= csinfo_size || i < -1 || csinfo[i].fname == NULL)) { if (p_csverbose) (void)EMSG2(_("E261: cscope connection %s not found"), stok); - } else { + } else { if (i == -1) { for (i = 0; i < csinfo_size; i++) { if (csinfo[i].fname) @@ -1514,7 +1520,7 @@ static char *cs_make_vim_style_matches(char *fname, char *slno, char *search, ch return NULL; (void)sprintf(buf, "%s\t%s\t%s;\"\t%s", tagstr, fname, slno, search); - } else { + } else { amt = (int)(strlen(fname) + strlen(slno) + strlen(tagstr) + 5); if ((buf = (char *)alloc(amt)) == NULL) return NULL; @@ -2239,11 +2245,11 @@ static char *cs_resolve_file(int i, char *name) ) { if ((fullname = (char *)alloc(len)) != NULL) (void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name); - } else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL) { + } else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL) { /* Check for csdir to be non empty to avoid empty path concatenated to * cscope output. */ fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE); - } else { + } else { fullname = (char *)vim_strsave((char_u *)name); } @@ -2289,7 +2295,8 @@ static int cs_show(exarg_T *eap) * * Only called when VIM exits to quit any cscope sessions. */ -void cs_end(void) { +void cs_end(void) +{ int i; for (i = 0; i < csinfo_size; i++) diff --git a/src/indent.c b/src/indent.c index a6db81b672..38a267d728 100644 --- a/src/indent.c +++ b/src/indent.c @@ -12,7 +12,8 @@ /* * Count the size (in window cells) of the indent in the current line. */ -int get_indent(void) { +int get_indent(void) +{ return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts); } @@ -113,7 +114,7 @@ set_indent ( todo -= tab_pad; ++ind_len; ind_done += tab_pad; - } else { + } else { --todo; ++ind_len; ++ind_done; @@ -192,7 +193,7 @@ set_indent ( while (vim_iswhite(*p)) ++p; - } else { + } else { todo = size; newline = alloc(ind_len + line_len); if (newline == NULL) @@ -218,7 +219,7 @@ set_indent ( break; todo -= tab_pad; ind_done += tab_pad; - } else { + } else { --todo; ++ind_done; } @@ -305,7 +306,7 @@ int copy_indent(int size, char_u *src) break; todo -= tab_pad; ind_done += tab_pad; - } else { + } else { --todo; ++ind_done; } @@ -424,7 +425,8 @@ int inindent(int extra) /* * Get indent level from 'indentexpr'. */ -int get_expr_indent(void) { +int get_expr_indent(void) +{ int indent; pos_T save_pos; colnr_T save_curswant; @@ -498,7 +500,8 @@ static int lisp_match(char_u *p) * Update from Sergey Khorev: * I tried to fix the first two issues. */ -int get_lisp_indent(void) { +int get_lisp_indent(void) +{ pos_T *pos, realpos, paren; int amount; char_u *that; diff --git a/src/indent_c.c b/src/indent_c.c index 5ad7e82f43..9a9968ab16 100644 --- a/src/indent_c.c +++ b/src/indent_c.c @@ -17,7 +17,8 @@ static pos_T *ind_find_start_comment(void); * Find the start of a comment, not knowing if we are in a comment right now. * Search starts at w_cursor.lnum and goes backwards. */ -static pos_T *ind_find_start_comment(void) { /* XXX */ +static pos_T *ind_find_start_comment(void) +{ /* XXX */ return find_start_comment(curbuf->b_ind_maxcomment); } @@ -79,7 +80,7 @@ static char_u *skip_string(char_u *p) p += i; continue; } - } else if (p[0] == '"') { /* start of string */ + } else if (p[0] == '"') { /* start of string */ for (++p; p[0]; ++p) { if (p[0] == '\\' && p[1] != NUL) ++p; @@ -219,7 +220,8 @@ static int cin_nocode(char_u *s) /* * Check previous lines for a "//" line comment, skipping over blank lines. */ -static pos_T *find_line_comment(void) { /* XXX */ +static pos_T *find_line_comment(void) /* XXX */ +{ static pos_T pos; char_u *line; char_u *p; @@ -259,7 +261,8 @@ static int cin_islabel_skip(char_u **s) * Recognize a label: "label:". * Note: curwin->w_cursor must be where we are looking for the label. */ -int cin_islabel(void) { /* XXX */ +int cin_islabel(void) +{ /* XXX */ char_u *s; s = cin_skipcomment(ml_get_curline()); @@ -318,7 +321,8 @@ int cin_islabel(void) { /* XXX */ * "[typedef] [static|public|protected|private] enum" * "[typedef] [static|public|protected|private] = {" */ -static int cin_isinit(void) { +static int cin_isinit(void) +{ char_u *s; static char *skip[] = {"static", "public", "protected", "private"}; @@ -437,13 +441,13 @@ static int cin_is_cpp_namespace(char_u *s) if (vim_iswhite(*p)) { has_name = TRUE; /* found end of a name */ p = cin_skipcomment(skipwhite(p)); - } else if (*p == '{') { + } else if (*p == '{') { break; - } else if (vim_iswordc(*p)) { + } else if (vim_iswordc(*p)) { if (has_name) return FALSE; /* word character after skipping past name */ ++p; - } else { + } else { return FALSE; } } @@ -523,7 +527,7 @@ static int skip_label(linenr_T lnum, char_u **pp) l = after_label(ml_get_curline()); if (l == NULL) /* just in case */ l = ml_get_curline(); - } else { + } else { amount = get_indent(); l = ml_get_curline(); } @@ -540,7 +544,8 @@ static int skip_label(linenr_T lnum, char_u **pp) * enum bla c, indent of "c" * Returns zero when it doesn't look like a declaration. */ -static int cin_first_id_amount(void) { +static int cin_first_id_amount(void) +{ char_u *line, *p, *s; int len; pos_T fp; @@ -1058,7 +1063,7 @@ cin_is_cpp_baseclass ( * initialization any more */ lookfor_ctor_init = FALSE; s = cin_skipcomment(s + 2); - } else if (lookfor_ctor_init || class_or_struct) { + } else if (lookfor_ctor_init || class_or_struct) { /* we have something found, that looks like the start of * cpp-base-class-declaration or constructor-initialization */ cpp_base_class = TRUE; @@ -1076,22 +1081,22 @@ cin_is_cpp_baseclass ( s = cin_skipcomment(s + 5); else s = cin_skipcomment(s + 6); - } else { + } else { if (s[0] == '{' || s[0] == '}' || s[0] == ';') { cpp_base_class = lookfor_ctor_init = class_or_struct = FALSE; - } else if (s[0] == ')') { + } else if (s[0] == ')') { /* Constructor-initialization is assumed if we come across * something like "):" */ class_or_struct = FALSE; lookfor_ctor_init = TRUE; - } else if (s[0] == '?') { + } else if (s[0] == '?') { /* Avoid seeing '() :' after '?' as constructor init. */ return FALSE; - } else if (!vim_isIDc(s[0])) { + } else if (!vim_isIDc(s[0])) { /* if it is not an identifier, we are wrong */ class_or_struct = FALSE; lookfor_ctor_init = FALSE; - } else if (*col == 0) { + } else if (*col == 0) { /* it can't be a constructor-initialization any more */ lookfor_ctor_init = FALSE; @@ -1124,7 +1129,7 @@ static int get_baseclass_amount(int col) amount = get_indent_lnum(trypos->lnum); /* XXX */ if (!cin_ends_in(ml_get_curline(), (char_u *)",", NULL)) amount += curbuf->b_ind_cpp_baseclass; - } else { + } else { curwin->w_cursor.col = col; getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); amount = (int)vcol; @@ -1200,7 +1205,8 @@ static int cin_skip2pos(pos_T *trypos) /* { */ /* } */ -static pos_T *find_start_brace(void) { /* XXX */ +static pos_T *find_start_brace(void) +{ /* XXX */ pos_T cursor_save; pos_T *trypos; pos_T *pos; @@ -1509,7 +1515,8 @@ void parse_cino(buf_T *buf) } } -int get_c_indent(void) { +int get_c_indent(void) +{ pos_T cur_curpos; int amount; int scope_amount; @@ -1662,10 +1669,10 @@ int get_c_indent(void) { lead_start_len = (int)STRLEN(lead_start); start_off = off; start_align = align; - } else if (what == COM_MIDDLE) { + } else if (what == COM_MIDDLE) { STRCPY(lead_middle, lead_end); lead_middle_len = (int)STRLEN(lead_middle); - } else if (what == COM_END) { + } else if (what == COM_END) { /* If our line starts with the middle comment string, line it * up with the comment opener per the 'comments' option. */ if (STRNCMP(theline, lead_middle, lead_middle_len) == 0 @@ -1778,7 +1785,7 @@ int get_c_indent(void) { if (theline[0] == ')' && curbuf->b_ind_paren_prev) { /* Line up with the start of the matching paren line. */ amount = get_indent_lnum(curwin->w_cursor.lnum - 1); /* XXX */ - } else { + } else { amount = -1; our_paren_pos = *trypos; for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; --lnum) { @@ -1937,7 +1944,7 @@ int get_c_indent(void) { && *look == '(' && ignore_paren_col == 0)) { if (cur_amount != MAXCOL) amount = cur_amount; - } else { + } else { /* Add b_ind_unclosed2 for each '(' before our matching one, * but ignore (void) before the line (ignore_paren_col). */ col = our_paren_pos.col; @@ -2009,7 +2016,7 @@ int get_c_indent(void) { start_brace = BRACE_IN_COL0; else start_brace = BRACE_AT_START; - } else { + } else { /* * that opening brace might have been on a continuation * line. if so, find the start of the line. @@ -2053,7 +2060,7 @@ int get_c_indent(void) { * other than the open brace. indulge them, if so. */ amount += curbuf->b_ind_close_extra; - } else { + } else { /* * If we're looking at an "else", try to find an "if" * to match it with. @@ -2093,14 +2100,14 @@ int get_c_indent(void) { lookfor_cpp_namespace) { /* '{' is at start */ lookfor_cpp_namespace = TRUE; - } else { + } else { if (start_brace == BRACE_AT_END) { /* '{' is at end of line */ amount += curbuf->b_ind_open_imag; l = skipwhite(ml_get_curline()); if (cin_is_cpp_namespace(l)) amount += curbuf->b_ind_cpp_namespace; - } else { + } else { /* Compensate for adding b_ind_open_extra later. */ amount -= curbuf->b_ind_open_extra; if (amount < 0) @@ -2113,10 +2120,10 @@ int get_c_indent(void) { if (cin_iscase(theline, FALSE)) { /* it's a switch() label */ lookfor = LOOKFOR_CASE; /* find a previous switch() label */ amount += curbuf->b_ind_case; - } else if (cin_isscopedecl(theline)) { /* private:, ... */ + } else if (cin_isscopedecl(theline)) { /* private:, ... */ lookfor = LOOKFOR_SCOPEDECL; /* class decl is this block */ amount += curbuf->b_ind_scopedecl; - } else { + } else { if (curbuf->b_ind_case_break && cin_isbreak(theline)) /* break; ... */ lookfor_break = TRUE; @@ -2250,12 +2257,12 @@ int get_c_indent(void) { amount = cont_amount; else amount += ind_continuation; - } else if (lookfor == LOOKFOR_UNTERM) { + } else if (lookfor == LOOKFOR_UNTERM) { if (cont_amount > 0) amount = cont_amount; else amount += ind_continuation; - } else { + } else { if (lookfor != LOOKFOR_TERM && lookfor != LOOKFOR_CPP_BASECLASS) { amount = scope_amount; @@ -2472,7 +2479,7 @@ int get_c_indent(void) { amount = cont_amount; else amount += ind_continuation; - } else if (theline[0] == '{') { + } else if (theline[0] == '{') { /* Need to find start of the declaration. */ lookfor = LOOKFOR_UNTERM; ind_continuation = 0; @@ -2481,7 +2488,7 @@ int get_c_indent(void) { /* XXX */ amount = get_baseclass_amount(col); break; - } else if (lookfor == LOOKFOR_CPP_BASECLASS) { + } else if (lookfor == LOOKFOR_CPP_BASECLASS) { /* only look, whether there is a cpp base class * declaration or initialization before the opening brace. */ @@ -2714,7 +2721,7 @@ int get_c_indent(void) { * reduce indent. */ if (amount > cur_amount) amount = cur_amount; - } else { + } else { /* * Found first unterminated line on a row, may * line up with this line, remember its indent @@ -2737,7 +2744,7 @@ int get_c_indent(void) { if (lookfor == LOOKFOR_INITIAL && terminated == ',') { lookfor = LOOKFOR_ENUM_OR_INIT; cont_amount = cin_first_id_amount(); - } else { + } else { if (lookfor == LOOKFOR_INITIAL && *l != NUL && l[STRLEN(l) - 1] == '\\') @@ -2987,7 +2994,7 @@ term_again: cur_curpos.lnum + 1) && !cin_isterminated(theline, FALSE, TRUE)) { amount = curbuf->b_ind_func_type; - } else { + } else { amount = 0; curwin->w_cursor = cur_curpos; @@ -3206,7 +3213,7 @@ static int find_match(int lookfor, linenr_T ourscope) if (lookfor == LOOKFOR_IF) { elselevel = 1; whilelevel = 0; - } else { + } else { elselevel = 0; whilelevel = 1; } @@ -3300,7 +3307,8 @@ static int find_match(int lookfor, linenr_T ourscope) /* * Do C or expression indenting on the current line. */ -void do_c_expr_indent(void) { +void do_c_expr_indent(void) +{ if (*curbuf->b_p_inde != NUL) fixthisline(get_expr_indent); else diff --git a/src/keymap.c b/src/keymap.c index cdf1270fc3..bec179c913 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -472,7 +472,7 @@ char_u *get_special_key_name(int c, int modifiers) string[idx++] = *s++; } } - } else { /* use name of special key */ + } else { /* use name of special key */ STRCPY(string + idx, key_names_table[table_idx].name); idx = (int)STRLEN(string); } @@ -596,7 +596,7 @@ find_special_key ( /* <Char-123> or <Char-033> or <Char-0x33> */ vim_str2nr(last_dash + 6, NULL, NULL, TRUE, TRUE, NULL, &n); key = (int)n; - } else { + } else { /* * Modifier with single letter, or special key name. */ diff --git a/src/main.c b/src/main.c index d6a09b504c..759366c5d3 100644 --- a/src/main.c +++ b/src/main.c @@ -616,7 +616,7 @@ main_loop ( * used and keep "got_int" set, so that it aborts ":g". */ exmode_active = EXMODE_NORMAL; State = NORMAL; - } else if (!global_busy || !exmode_active) { + } else if (!global_busy || !exmode_active) { if (!quit_more) (void)vgetc(); /* flush all buffers */ got_int = FALSE; @@ -887,7 +887,8 @@ get_number_arg ( /* * Setup to use the current locale (for ctype() and many other things). */ -static void init_locale(void) { +static void init_locale(void) +{ setlocale(LC_ALL, ""); # if defined(FEAT_FLOAT) && defined(LC_NUMERIC) @@ -1056,20 +1057,20 @@ static void command_line_scan(mparm_T *parmp) msg_putchar('\n'); msg_didout = FALSE; mch_exit(0); - } else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) { + } else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) { #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE) parmp->literal = TRUE; #endif - } else if (STRNICMP(argv[0] + argv_idx, "nofork", 6) == 0) { + } else if (STRNICMP(argv[0] + argv_idx, "nofork", 6) == 0) { } else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) p_lpl = FALSE; else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) { want_argument = TRUE; argv_idx += 3; - } else if (STRNICMP(argv[0] + argv_idx, "startuptime", 11) == 0) { + } else if (STRNICMP(argv[0] + argv_idx, "startuptime", 11) == 0) { want_argument = TRUE; argv_idx += 11; - } else { + } else { if (argv[0][argv_idx]) mainerr(ME_UNKNOWN_OPTION, (char_u *)argv[0]); had_minmin = TRUE; @@ -1658,7 +1659,8 @@ static void check_tty(mparm_T *parmp) /* * Read text from stdin. */ -static void read_stdin(void) { +static void read_stdin(void) +{ int i; #if defined(HAS_SWAP_EXISTS_ACTION) @@ -1708,7 +1710,7 @@ static void create_windows(mparm_T *parmp) if (parmp->window_layout == WIN_TABS) { parmp->window_count = make_tabpages(parmp->window_count); TIME_MSG("making tab pages"); - } else if (firstwin->w_next == NULL) { + } else if (firstwin->w_next == NULL) { parmp->window_count = make_windows(parmp->window_count, parmp->window_layout == WIN_VER); TIME_MSG("making windows"); @@ -1723,7 +1725,7 @@ static void create_windows(mparm_T *parmp) if (curbuf->b_ml.ml_mfp == NULL) /* failed */ getout(1); do_modelines(0); /* do modelines */ - } else { + } else { /* * Open a buffer for windows that don't have one yet. * Commands in the .vimrc might have loaded a file or split the window. @@ -1741,11 +1743,11 @@ static void create_windows(mparm_T *parmp) goto_tabpage(1); else curwin = firstwin; - } else if (parmp->window_layout == WIN_TABS) { + } else if (parmp->window_layout == WIN_TABS) { if (curtab->tp_next == NULL) break; goto_tabpage(0); - } else { + } else { if (curwin->w_next == NULL) break; curwin = curwin->w_next; @@ -1837,7 +1839,7 @@ static void edit_buffers(mparm_T *parmp) if (curtab->tp_next == NULL) /* just checking */ break; goto_tabpage(0); - } else { + } else { if (curwin->w_next == NULL) /* just checking */ break; win_enter(curwin->w_next, FALSE); @@ -1984,11 +1986,11 @@ static void source_startup_scripts(mparm_T *parmp) || STRCMP(parmp->use_vimrc, "NORC") == 0) { if (parmp->use_vimrc[2] == 'N') p_lpl = FALSE; /* don't load plugins either */ - } else { + } else { if (do_source(parmp->use_vimrc, FALSE, DOSO_NONE) != OK) EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc); } - } else if (!silent_mode) { + } else if (!silent_mode) { /* * Get system wide defaults, if the file name is defined. @@ -2091,7 +2093,8 @@ static void source_startup_scripts(mparm_T *parmp) /* * Setup to start using the GUI. Exit with an error when not available. */ -static void main_start_gui(void) { +static void main_start_gui(void) +{ mch_errmsg(_(e_nogvim)); mch_errmsg("\n"); mch_exit(2); @@ -2201,7 +2204,8 @@ static void main_msg(char *s) /* * Print messages for "vim -h" or "vim --help" and exit. */ -static void usage(void) { +static void usage(void) +{ int i; static char *(use[]) = { @@ -2290,7 +2294,8 @@ static void usage(void) { * When "Quit" selected, exit Vim. * When "Recover" selected, recover the file. */ -static void check_swap_exists_action(void) { +static void check_swap_exists_action(void) +{ if (swap_exists_action == SEA_QUIT) getout(1); handle_swap_exists(NULL); diff --git a/src/mark.c b/src/mark.c index a43c3a352f..937c7a6b74 100644 --- a/src/mark.c +++ b/src/mark.c @@ -136,7 +136,8 @@ int setmark_pos(int c, pos_T *pos, int fnum) * Set the previous context mark to the current position and add it to the * jump list. */ -void setpcmark(void) { +void setpcmark(void) +{ int i; xfmark_T *fm; #ifdef JUMPLIST_ROTATE @@ -188,7 +189,8 @@ void setpcmark(void) { * context will only be changed if the cursor moved to a different line. * If pcmark was deleted (with "dG") the previous mark is restored. */ -void checkpcmark(void) { +void checkpcmark(void) +{ if (curwin->w_prev_pcmark.lnum != 0 && (equalpos(curwin->w_pcmark, curwin->w_cursor) || curwin->w_pcmark.lnum == 0)) { @@ -265,7 +267,7 @@ pos_T *movechangelist(int count) if (n == 0) return (pos_T *)NULL; n = 0; - } else if (n + count >= curbuf->b_changelistlen) { + } else if (n + count >= curbuf->b_changelistlen) { if (n == curbuf->b_changelistlen - 1) return (pos_T *)NULL; n = curbuf->b_changelistlen - 1; @@ -310,7 +312,7 @@ pos_T *getmark_buf_fnum(buf_T *buf, int c, int changefile, int *fnum) return posp; if (c > '~') /* check for islower()/isupper() */ ; - else if (c == '\'' || c == '`') { /* previous context mark */ + else if (c == '\'' || c == '`') { /* previous context mark */ pos_copy = curwin->w_pcmark; /* need to make a copy because */ posp = &pos_copy; /* w_pcmark may be changed soon */ } else if (c == '"') /* to pos when leaving buffer */ @@ -337,7 +339,7 @@ pos_T *getmark_buf_fnum(buf_T *buf, int c, int changefile, int *fnum) } curwin->w_cursor = pos; listcmd_busy = slcb; - } else if (c == '(' || c == ')') { /* to previous/next sentence */ + } else if (c == '(' || c == ')') { /* to previous/next sentence */ pos_T pos; int slcb = listcmd_busy; @@ -349,7 +351,7 @@ pos_T *getmark_buf_fnum(buf_T *buf, int c, int changefile, int *fnum) } curwin->w_cursor = pos; listcmd_busy = slcb; - } else if (c == '<' || c == '>') { /* start/end of visual area */ + } else if (c == '<' || c == '>') { /* start/end of visual area */ startp = &buf->b_visual.vi_start; endp = &buf->b_visual.vi_end; if ((c == '<') == lt(*startp, *endp)) @@ -368,9 +370,9 @@ pos_T *getmark_buf_fnum(buf_T *buf, int c, int changefile, int *fnum) pos_copy.col = MAXCOL; pos_copy.coladd = 0; } - } else if (ASCII_ISLOWER(c)) { /* normal named mark */ + } else if (ASCII_ISLOWER(c)) { /* normal named mark */ posp = &(buf->b_namedm[c - 'a']); - } else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) { /* named file mark */ + } else if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) { /* named file mark */ if (VIM_ISDIGIT(c)) c = c - '0' + NMARKS; else @@ -437,7 +439,7 @@ getnextmark ( if ((result == NULL || lt(curbuf->b_namedm[i], *result)) && lt(pos, curbuf->b_namedm[i])) result = &curbuf->b_namedm[i]; - } else { + } else { if ((result == NULL || lt(*result, curbuf->b_namedm[i])) && lt(curbuf->b_namedm[i], pos)) result = &curbuf->b_namedm[i]; @@ -988,7 +990,7 @@ void mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after) } else /* keep topline on the same line */ win->w_topline += amount; win->w_topfill = 0; - } else if (amount_after && win->w_topline > line2) { + } else if (amount_after && win->w_topline > line2) { win->w_topline += amount_after; win->w_topfill = 0; } @@ -1104,7 +1106,8 @@ void mark_col_adjust(linenr_T lnum, colnr_T mincol, long lnum_amount, long col_a * When deleting lines, this may create duplicate marks in the * jumplist. They will be removed here for the current window. */ -static void cleanup_jumplist(void) { +static void cleanup_jumplist(void) +{ int i; int from, to; @@ -1163,7 +1166,8 @@ void set_last_cursor(win_T *win) } #if defined(EXITFREE) || defined(PROTO) -void free_all_marks(void) { +void free_all_marks(void) +{ int i; for (i = 0; i < NMARKS + EXTRA_MARKS; i++) @@ -1460,7 +1464,7 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags if (fnamecmp(str, name_buf) == 0) load_marks = TRUE; } - } else { /* fp_out != NULL */ + } else { /* fp_out != NULL */ /* This is slow if there are many buffers!! */ for (buf = firstbuf; buf != NULL; buf = buf->b_next) if (buf->b_ffname != NULL) { diff --git a/src/mbyte.c b/src/mbyte.c index 546dfde999..d87a73745a 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -152,7 +152,8 @@ static char utf8len_tab_zero[256] = */ /* #define XIM_DEBUG */ #ifdef XIM_DEBUG -static void xim_log(char *s, ...) { +static void xim_log(char *s, ...) +{ va_list arglist; static FILE *fd = NULL; @@ -434,7 +435,8 @@ int enc_canon_props(char_u *name) * When there is something wrong: Returns an error message and doesn't change * anything. */ -char_u * mb_init() { +char_u * mb_init() +{ int i; int idx; int n; @@ -459,10 +461,10 @@ char_u * mb_init() { /* Accept any "8bit-" or "iso-8859-" name. */ enc_unicode = 0; enc_utf8 = FALSE; - } else if (STRNCMP(p_enc, "2byte-", 6) == 0) { + } else if (STRNCMP(p_enc, "2byte-", 6) == 0) { /* Unix: accept any "2byte-" name, assume current locale. */ enc_dbcs_new = DBCS_2BYTE; - } else if ((idx = enc_canon_search(p_enc)) >= 0) { + } else if ((idx = enc_canon_search(p_enc)) >= 0) { i = enc_canon_table[idx].prop; if (i & ENC_UNICODE) { /* Unicode */ @@ -473,10 +475,10 @@ char_u * mb_init() { enc_unicode = 4; else enc_unicode = 0; - } else if (i & ENC_DBCS) { + } else if (i & ENC_DBCS) { /* 2byte, handle below */ enc_dbcs_new = enc_canon_table[idx].codepage; - } else { + } else { /* Must be 8-bit. */ enc_unicode = 0; enc_utf8 = FALSE; @@ -510,7 +512,7 @@ char_u * mb_init() { mb_off2cells = utf_off2cells; mb_ptr2char = utf_ptr2char; mb_head_off = utf_head_off; - } else if (enc_dbcs != 0) { + } else if (enc_dbcs != 0) { mb_ptr2len = dbcs_ptr2len; mb_ptr2len_len = dbcs_ptr2len_len; mb_char2len = dbcs_char2len; @@ -521,7 +523,7 @@ char_u * mb_init() { mb_off2cells = dbcs_off2cells; mb_ptr2char = dbcs_ptr2char; mb_head_off = dbcs_head_off; - } else { + } else { mb_ptr2len = latin_ptr2len; mb_ptr2len_len = latin_ptr2len_len; mb_char2len = latin_char2len; @@ -647,7 +649,8 @@ char_u * mb_init() { * 4 - UCS-4 BOM * 3 - UTF-8 BOM */ -int bomb_size() { +int bomb_size() +{ int n = 0; if (curbuf->b_p_bomb && !curbuf->b_p_bin) { @@ -2847,7 +2850,7 @@ static int utf_strnicmp(char_u *s1, char_u *s2, size_t n1, size_t n2) if (c1 != -1 && c2 == -1) { n1 = utf_char2bytes(utf_fold(c1), buffer); s1 = buffer; - } else if (c2 != -1 && c1 == -1) { + } else if (c2 != -1 && c1 == -1) { n2 = utf_char2bytes(utf_fold(c2), buffer); s2 = buffer; } @@ -2889,7 +2892,7 @@ int mb_strnicmp(char_u *s1, char_u *s2, size_t nn) if (enc_utf8) { return utf_strnicmp(s1, s2, nn, nn); - } else { + } else { for (i = 0; i < n; i += l) { if (s1[i] == NUL && s2[i] == NUL) /* both strings end */ return 0; @@ -2902,7 +2905,7 @@ int mb_strnicmp(char_u *s1, char_u *s2, size_t nn) if (cdiff != 0) return cdiff; } - } else { + } else { /* For non-Unicode multi-byte don't ignore case. */ if (l > n - i) l = n - i; @@ -2919,7 +2922,8 @@ int mb_strnicmp(char_u *s1, char_u *s2, size_t nn) * "g8": show bytes of the UTF-8 char under the cursor. Doesn't matter what * 'encoding' has been set to. */ -void show_utf8() { +void show_utf8() +{ int len; int rlen = 0; char_u *line; @@ -3147,7 +3151,8 @@ int mb_tail_off(char_u *base, char_u *p) /* * Find the next illegal byte sequence. */ -void utf_find_illegal() { +void utf_find_illegal() +{ pos_T pos = curwin->w_cursor; char_u *p; int len; @@ -3214,7 +3219,8 @@ theend: * Thus it moves left if necessary. * Return TRUE when the cursor was adjusted. */ -void mb_adjust_cursor() { +void mb_adjust_cursor() +{ mb_adjustpos(curbuf, &curwin->w_cursor); } @@ -3439,7 +3445,7 @@ char_u * enc_canonize(char_u *enc) /* canonical name can be used unmodified */ if (p != r) STRMOVE(r, p); - } else if ((i = enc_alias_search(p)) >= 0) { + } else if ((i = enc_alias_search(p)) >= 0) { /* alias recognized, get canonical name */ vim_free(r); r = vim_strsave((char_u *)enc_canon_table[i].name); @@ -3471,7 +3477,8 @@ static int enc_alias_search(char_u *name) * Get the canonicalized encoding of the current locale. * Returns an allocated string when successful, NULL when not. */ -char_u * enc_locale() { +char_u * enc_locale() +{ char *s; char *p; int i; @@ -3651,7 +3658,7 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, int slen, int *unconvl } from += l; fromlen -= l; - } else if (ICONV_ERRNO != ICONV_E2BIG) { + } else if (ICONV_ERRNO != ICONV_E2BIG) { /* conversion failed */ vim_free(result); result = NULL; @@ -3689,7 +3696,8 @@ static HINSTANCE hMsvcrtDLL = 0; * Get the address of 'funcname' which is imported by 'hInst' DLL. */ static void * get_iconv_import_func(HINSTANCE hInst, - const char *funcname) { + const char *funcname) +{ PBYTE pImage = (PBYTE)hInst; PIMAGE_DOS_HEADER pDOS = (PIMAGE_DOS_HEADER)hInst; PIMAGE_NT_HEADERS pPE; @@ -3769,7 +3777,8 @@ int iconv_enabled(int verbose) return TRUE; } -void iconv_end() { +void iconv_end() +{ /* Don't use iconv() when inputting or outputting characters. */ if (input_conv.vc_type == CONV_ICONV) convert_setup(&input_conv, NULL, NULL); @@ -3852,14 +3861,14 @@ int convert_setup_ext(vcp, from, from_unicode_is_utf8, to, to_unicode_is_utf8) /* Internal latin1 -> utf-8 conversion. */ vcp->vc_type = CONV_TO_UTF8; vcp->vc_factor = 2; /* up to twice as long */ - } else if ((from_prop & ENC_LATIN9) && to_is_utf8) { + } else if ((from_prop & ENC_LATIN9) && to_is_utf8) { /* Internal latin9 -> utf-8 conversion. */ vcp->vc_type = CONV_9_TO_UTF8; vcp->vc_factor = 3; /* up to three as long (euro sign) */ - } else if (from_is_utf8 && (to_prop & ENC_LATIN1)) { + } else if (from_is_utf8 && (to_prop & ENC_LATIN1)) { /* Internal utf-8 -> latin1 conversion. */ vcp->vc_type = CONV_TO_LATIN1; - } else if (from_is_utf8 && (to_prop & ENC_LATIN9)) { + } else if (from_is_utf8 && (to_prop & ENC_LATIN9)) { /* Internal utf-8 -> latin9 conversion. */ vcp->vc_type = CONV_TO_LATIN9; } @@ -4042,7 +4051,7 @@ char_u * string_convert_ext(vcp, ptr, lenp, unconvlenp) break; } *d++ = ptr[i]; - } else { + } else { c = utf_ptr2char(ptr + i); if (vcp->vc_type == CONV_TO_LATIN9) switch (c) { @@ -4069,7 +4078,7 @@ char_u * string_convert_ext(vcp, ptr, lenp, unconvlenp) else if (vcp->vc_fail) { vim_free(retval); return NULL; - } else { + } else { *d++ = 0xbf; if (utf_char2cells(c) > 1) *d++ = '?'; diff --git a/src/memfile.c b/src/memfile.c index f56c3588b2..714a64fb6f 100644 --- a/src/memfile.c +++ b/src/memfile.c @@ -133,7 +133,7 @@ memfile_T *mf_open(char_u *fname, int flags) mfp->mf_fname = NULL; mfp->mf_ffname = NULL; mfp->mf_fd = -1; - } else { + } else { mf_do_open(mfp, fname, flags); /* try to open the file */ /* if the file cannot be opened, return here */ @@ -341,23 +341,23 @@ bhdr_T *mf_new(memfile_T *mfp, int negative, int page_count) hp->bh_bnum = freep->bh_bnum; freep->bh_bnum += page_count; freep->bh_page_count -= page_count; - } else if (hp == NULL) { /* need to allocate memory for this block */ + } else if (hp == NULL) { /* need to allocate memory for this block */ if ((p = (char_u *)alloc(mfp->mf_page_size * page_count)) == NULL) return NULL; hp = mf_rem_free(mfp); hp->bh_data = p; - } else { /* use the number, remove entry from free list */ + } else { /* use the number, remove entry from free list */ freep = mf_rem_free(mfp); hp->bh_bnum = freep->bh_bnum; vim_free(freep); } - } else { /* get a new number */ + } else { /* get a new number */ if (hp == NULL && (hp = mf_alloc_bhdr(mfp, page_count)) == NULL) return NULL; if (negative) { hp->bh_bnum = mfp->mf_blocknr_min--; mfp->mf_neg_count++; - } else { + } else { hp->bh_bnum = mfp->mf_blocknr_max; mfp->mf_blocknr_max += page_count; } @@ -416,7 +416,7 @@ bhdr_T *mf_get(memfile_T *mfp, blocknr_T nr, int page_count) mf_free_bhdr(hp); return NULL; } - } else { + } else { mf_rem_used(mfp, hp); /* remove from list, insert in front below */ mf_rem_hash(mfp, hp); } @@ -473,7 +473,8 @@ void mf_free(memfile_T *mfp, bhdr_T *hp) /* function is missing in MorphOS libnix version */ extern unsigned long *__stdfiledes; -static unsigned long fdtofh(int filedescriptor) { +static unsigned long fdtofh(int filedescriptor) +{ return __stdfiledes[filedescriptor]; } @@ -743,7 +744,8 @@ static bhdr_T *mf_release(memfile_T *mfp, int page_count) * * return TRUE if any memory was released */ -int mf_release_all(void) { +int mf_release_all(void) +{ buf_T *buf; memfile_T *mfp; bhdr_T *hp; @@ -989,11 +991,11 @@ static int mf_trans_add(memfile_T *mfp, bhdr_T *hp) if (freep->bh_page_count > page_count) { freep->bh_bnum += page_count; freep->bh_page_count -= page_count; - } else { + } else { freep = mf_rem_free(mfp); vim_free(freep); } - } else { + } else { new_bnum = mfp->mf_blocknr_max; mfp->mf_blocknr_max += page_count; } @@ -1119,7 +1121,7 @@ mf_do_open ( vim_free(mfp->mf_ffname); mfp->mf_fname = NULL; mfp->mf_ffname = NULL; - } else { + } else { #ifdef HAVE_FD_CLOEXEC int fdflags = fcntl(mfp->mf_fd, F_GETFD); if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0) @@ -1290,7 +1292,7 @@ static int mf_hash_grow(mf_hashtab_T *mht) buckets[i + (j << shift)] = mhi; tails[j] = mhi; mhi->mhi_prev = NULL; - } else { + } else { tails[j]->mhi_next = mhi; mhi->mhi_prev = tails[j]; tails[j] = mhi; diff --git a/src/memline.c b/src/memline.c index 3ec74b06ee..f0aca399b4 100644 --- a/src/memline.c +++ b/src/memline.c @@ -490,13 +490,13 @@ void ml_set_crypt_key(buf_T *buf, char_u *old_key, int old_cm) if (bnum == 1) break; ++error; - } else { + } else { pp = (PTR_BL *)(hp->bh_data); if (pp->pb_id == PTR_ID) { /* it is a pointer block */ if (pp->pb_count == 0) { /* empty block? */ ++error; - } else if (idx < (int)pp->pb_count) { /* go a block deeper */ + } else if (idx < (int)pp->pb_count) { /* go a block deeper */ if (pp->pb_pointer[idx].pe_bnum < 0) { /* Skip data block with negative block number. */ ++idx; /* get same block again for next index */ @@ -517,7 +517,7 @@ void ml_set_crypt_key(buf_T *buf, char_u *old_key, int old_cm) page_count = pp->pb_pointer[idx].pe_page_count; continue; } - } else { /* not a pointer block */ + } else { /* not a pointer block */ dp = (DATA_BL *)(hp->bh_data); if (dp->db_id != DATA_ID) /* block id wrong */ ++error; @@ -631,7 +631,8 @@ void ml_setname(buf_T *buf) * been modified. * Used when 'updatecount' changes from zero to non-zero. */ -void ml_open_files(void) { +void ml_open_files(void) +{ buf_T *buf; for (buf = firstbuf; buf != NULL; buf = buf->b_next) @@ -764,7 +765,8 @@ void ml_close_all(int del_file) * Close all memfiles for not modified buffers. * Only use just before exiting! */ -void ml_close_notmod(void) { +void ml_close_notmod(void) +{ buf_T *buf; for (buf = firstbuf; buf != NULL; buf = buf->b_next) @@ -864,7 +866,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf) #endif buf_store_time(buf, &st, buf->b_ffname); buf->b_mtime_read = buf->b_mtime; - } else { + } else { long_to_char(0L, b0p->b0_mtime); #ifdef CHECK_INODE long_to_char(0L, b0p->b0_ino); @@ -923,7 +925,8 @@ static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf) /* * Try to recover curbuf from the .swp file. */ -void ml_recover(void) { +void ml_recover(void) +{ buf_T *buf = NULL; memfile_T *mfp = NULL; char_u *fname; @@ -977,7 +980,7 @@ void ml_recover(void) { && ASCII_ISALPHA(fname[len - 1])) { directly = TRUE; fname_used = vim_strsave(fname); /* make a copy for mf_open() */ - } else { + } else { directly = FALSE; /* count the number of matching swap files */ @@ -1260,7 +1263,7 @@ void ml_recover(void) { ++error; ml_append(lnum++, (char_u *)_("???MANY LINES MISSING"), (colnr_T)0, TRUE); - } else { /* there is a block */ + } else { /* there is a block */ pp = (PTR_BL *)(hp->bh_data); if (pp->pb_id == PTR_ID) { /* it is a pointer block */ /* check line count when using pointer block first time */ @@ -1278,7 +1281,7 @@ void ml_recover(void) { ml_append(lnum++, (char_u *)_("???EMPTY BLOCK"), (colnr_T)0, TRUE); ++error; - } else if (idx < (int)pp->pb_count) { /* go a block deeper */ + } else if (idx < (int)pp->pb_count) { /* go a block deeper */ if (pp->pb_pointer[idx].pe_bnum < 0) { /* * Data block with negative block number. @@ -1320,7 +1323,7 @@ void ml_recover(void) { idx = 0; continue; } - } else { /* not a pointer block */ + } else { /* not a pointer block */ dp = (DATA_BL *)(hp->bh_data); if (dp->db_id != DATA_ID) { /* block id wrong */ if (bnum == 1) { @@ -1331,7 +1334,7 @@ void ml_recover(void) { ++error; ml_append(lnum++, (char_u *)_("???BLOCK MISSING"), (colnr_T)0, TRUE); - } else { + } else { /* * it is a data block * Append all the lines in this block @@ -1409,7 +1412,7 @@ void ml_recover(void) { changed_int(); ++curbuf->b_changedtick; } - } else { + } else { for (idx = 1; idx <= lnum; ++idx) { /* Need to copy one line, fetching the other one may flush it. */ p = vim_strsave(ml_get(idx)); @@ -1443,7 +1446,7 @@ void ml_recover(void) { --no_wait_return; MSG(_("See \":help E312\" for more information.")); MSG(">>>>>>>>>>>>>"); - } else { + } else { if (curbuf->b_changed) { MSG(_("Recovery completed. You should check if everything is OK.")); MSG_PUTS(_( @@ -1562,7 +1565,7 @@ recover_names ( #endif } else num_names = recov_file_names(names, fname_res, TRUE); - } else { /* check directory dir_name */ + } else { /* check directory dir_name */ if (fname == NULL) { names[0] = concat_fnames(dir_name, (char_u *)"*.sw?", TRUE); #if defined(UNIX) || defined(WIN3264) @@ -1574,7 +1577,7 @@ recover_names ( #else num_names = 1; #endif - } else { + } else { #if defined(UNIX) || defined(WIN3264) p = dir_name + STRLEN(dir_name); if (after_pathsep(dir_name, p) && p[-1] == p[-2]) { @@ -1659,13 +1662,13 @@ recover_names ( files[nr - 1 + num_files - file_count]); dirp = (char_u *)""; /* stop searching */ } - } else if (list) { + } else if (list) { if (dir_name[0] == '.' && dir_name[1] == NUL) { if (fname == NULL) MSG_PUTS(_(" In current directory:\n")); else MSG_PUTS(_(" Using specified name:\n")); - } else { + } else { MSG_PUTS(_(" In directory ")); msg_home_replace(dir_name); MSG_PUTS(":\n"); @@ -1769,9 +1772,9 @@ static time_t swapfile_info(char_u *fname) if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) { if (STRNCMP(b0.b0_version, "VIM 3.0", 7) == 0) { MSG_PUTS(_(" [from Vim version 3.0]")); - } else if (ml_check_b0_id(&b0) == FAIL) { + } else if (ml_check_b0_id(&b0) == FAIL) { MSG_PUTS(_(" [does not look like a Vim swap file]")); - } else { + } else { MSG_PUTS(_(" file name: ")); if (b0.b0_fname[0] == NUL) MSG_PUTS(_("[No Name]")); @@ -2048,14 +2051,16 @@ char_u *ml_get_pos(pos_T *pos) /* * Return pointer to cursor line. */ -char_u *ml_get_curline(void) { +char_u *ml_get_curline(void) +{ return ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE); } /* * Return pointer to cursor position. */ -char_u *ml_get_cursor(void) { +char_u *ml_get_cursor(void) +{ return ml_get_buf(curbuf, curwin->w_cursor.lnum, FALSE) + curwin->w_cursor.col; } @@ -2139,7 +2144,8 @@ errorret: * Check if a line that was just obtained by a call to ml_get * is in allocated memory. */ -int ml_line_alloced(void) { +int ml_line_alloced(void) +{ return curbuf->b_ml.ml_flags & ML_LINE_DIRTY; } @@ -2323,7 +2329,7 @@ ml_append_int ( buf->b_ml.ml_flags |= ML_LOCKED_DIRTY; if (!newfile) buf->b_ml.ml_flags |= ML_LOCKED_POS; - } else { /* not enough space in data block */ + } else { /* not enough space in data block */ /* * If there is not enough room we have to create a new data block and copy some * lines into it. @@ -2362,7 +2368,7 @@ ml_append_int ( lines_moved = 0; in_left = TRUE; /* space_needed does not change */ - } else { /* left block is existing, right block is new */ + } else { /* left block is existing, right block is new */ lines_moved = line_count - db_idx - 1; if (lines_moved == 0) in_left = FALSE; /* put new line in right block */ @@ -2374,7 +2380,7 @@ ml_append_int ( if ((int)dp->db_free + total_moved >= space_needed) { in_left = TRUE; /* put new line in left block */ space_needed = total_moved; - } else { + } else { in_left = FALSE; /* put new line in right block */ space_needed += total_moved; } @@ -2393,7 +2399,7 @@ ml_append_int ( hp_right = hp; line_count_left = 0; line_count_right = line_count; - } else { /* right block is new */ + } else { /* right block is new */ hp_left = hp; hp_right = hp_new; line_count_left = line_count; @@ -2462,7 +2468,7 @@ ml_append_int ( if (db_idx < 0) { /* left block is new */ lnum_left = lnum + 1; lnum_right = 0; - } else { /* right block is new */ + } else { /* right block is new */ lnum_left = 0; if (in_left) lnum_right = lnum + 2; @@ -2548,7 +2554,7 @@ ml_append_int ( * We are finished, break the loop here. */ break; - } else { /* pointer block full */ + } else { /* pointer block full */ /* * split the pointer block * allocate a new pointer block @@ -2599,7 +2605,7 @@ ml_append_int ( pp->pb_pointer[pb_idx + 1].pe_page_count = page_count_right; if (lnum_right) pp->pb_pointer[pb_idx + 1].pe_old_lnum = lnum_right; - } else { + } else { pp_new->pb_count = 1; pp_new->pb_pointer[0].pe_bnum = bnum_right; pp_new->pb_pointer[0].pe_line_count = line_count_right; @@ -2804,7 +2810,7 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, int message) } } CHECK(stack_idx < 0, _("deleted block 1?")); - } else { + } else { /* * delete the text by moving the next lines forwards */ @@ -2864,7 +2870,8 @@ void ml_setmarked(linenr_T lnum) /* * find the first line with its B_MARKED flag set */ -linenr_T ml_firstmarked(void) { +linenr_T ml_firstmarked(void) +{ bhdr_T *hp; DATA_BL *dp; linenr_T lnum; @@ -2904,7 +2911,8 @@ linenr_T ml_firstmarked(void) { /* * clear all DB_MARKED flags */ -void ml_clearmarked(void) { +void ml_clearmarked(void) +{ bhdr_T *hp; DATA_BL *dp; linenr_T lnum; @@ -3013,7 +3021,7 @@ static void ml_flush_line(buf_T *buf) buf->b_ml.ml_flags |= (ML_LOCKED_DIRTY | ML_LOCKED_POS); /* The else case is already covered by the insert and delete */ ml_updatechunk(buf, lnum, (long)extra, ML_CHNK_UPDLINE); - } else { + } else { /* * Cannot do it in one data block: Delete and append. * Append first, because ml_delete_int() cannot delete the @@ -3123,7 +3131,7 @@ static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action) if (action == ML_INSERT) { ++(buf->b_ml.ml_locked_lineadd); ++(buf->b_ml.ml_locked_high); - } else if (action == ML_DELETE) { + } else if (action == ML_DELETE) { --(buf->b_ml.ml_locked_lineadd); --(buf->b_ml.ml_locked_high); } @@ -3243,7 +3251,7 @@ static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action) if (action == ML_DELETE) { pp->pb_pointer[idx].pe_line_count--; dirty = TRUE; - } else if (action == ML_INSERT) { + } else if (action == ML_INSERT) { pp->pb_pointer[idx].pe_line_count++; dirty = TRUE; } @@ -3837,7 +3845,7 @@ findswapname ( #endif differ = TRUE; } - } else { + } else { /* * The name in the swap file may be * "~user/path/file". Expand it first. @@ -4257,7 +4265,7 @@ static void ml_crypt_prepare(memfile_T *mfp, off_t offset, int reading) method = mfp->mf_old_cm; key = mfp->mf_old_key; seed = mfp->mf_old_seed; - } else { + } else { method = get_crypt_method(buf); key = buf->b_p_key; seed = mfp->mf_seed; @@ -4267,7 +4275,7 @@ static void ml_crypt_prepare(memfile_T *mfp, off_t offset, int reading) if (method == 0) { vim_snprintf((char *)salt, sizeof(salt), "%s%ld", key, (long)offset); crypt_init_keys(salt); - } else { + } else { /* Using blowfish, add salt and seed. We use the byte offset of the * block for the salt. */ vim_snprintf((char *)salt, sizeof(salt), "%ld", (long)offset); @@ -4403,7 +4411,7 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype) if (linecnt + rest > MLCS_MINL) { idx += MLCS_MINL - linecnt - 1; linecnt = MLCS_MINL; - } else { + } else { idx = count - 1; linecnt += rest; } @@ -4428,7 +4436,7 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype) if (line == buf->b_ml.ml_line_count) { curchnk->mlcs_numlines = 0; curchnk->mlcs_totalsize = 0; - } else { + } else { /* * Line is just prior to last, move count for last * This is the common case when loading a new file @@ -4451,7 +4459,7 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype) curchnk[-1].mlcs_numlines -= 1; } } - } else if (updtype == ML_CHNK_DELLINE) { + } else if (updtype == ML_CHNK_DELLINE) { curchnk->mlcs_numlines--; ml_upd_lastbuf = NULL; /* Force recalc of curix & curline */ if (curix < (buf->b_ml.ml_usedchunks - 1) @@ -4459,7 +4467,7 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype) <= MLCS_MINL) { curix++; curchnk = buf->b_ml.ml_chunksize + curix; - } else if (curix == 0 && curchnk->mlcs_numlines <= 0) { + } else if (curix == 0 && curchnk->mlcs_numlines <= 0) { buf->b_ml.ml_usedchunks--; mch_memmove(buf->b_ml.ml_chunksize, buf->b_ml.ml_chunksize + 1, buf->b_ml.ml_usedchunks * sizeof(chunksize_T)); @@ -4563,7 +4571,7 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp) idx += lnum - curline - 1; else idx = count - 1; - } else { + } else { extra = 0; while (offset >= size + text_end - (int)((dp->db_index[idx]) & DB_INDEX_MASK) @@ -4625,7 +4633,7 @@ void goto_byte(long cnt) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; curwin->w_curswant = MAXCOL; coladvance((colnr_T)MAXCOL); - } else { + } else { curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = (colnr_T)boff; curwin->w_cursor.coladd = 0; diff --git a/src/menu.c b/src/menu.c index e32b83cb35..1b06b82cd9 100644 --- a/src/menu.c +++ b/src/menu.c @@ -137,7 +137,7 @@ ex_menu ( ++arg; } arg = skipwhite(arg); - } else if (eap->addr_count && eap->line2 != 0) { + } else if (eap->addr_count && eap->line2 != 0) { pri_tab[0] = eap->line2; i = 1; } else @@ -152,7 +152,7 @@ ex_menu ( if (STRNCMP(arg, "enable", 6) == 0 && vim_iswhite(arg[6])) { enable = TRUE; arg = skipwhite(arg + 6); - } else if (STRNCMP(arg, "disable", 7) == 0 && vim_iswhite(arg[7])) { + } else if (STRNCMP(arg, "disable", 7) == 0 && vim_iswhite(arg[7])) { enable = FALSE; arg = skipwhite(arg + 7); } @@ -180,7 +180,7 @@ ex_menu ( if (*map_to == NUL && !unmenu && enable == MAYBE) { show_menus(menu_path, modes); goto theend; - } else if (*map_to != NUL && (unmenu || enable != MAYBE)) { + } else if (*map_to != NUL && (unmenu || enable != MAYBE)) { EMSG(_(e_trailing)); goto theend; } @@ -206,7 +206,7 @@ ex_menu ( } } menu_nable_recurse(root_menu, menu_path, modes, enable); - } else if (unmenu) { + } else if (unmenu) { /* * Delete menu(s). */ @@ -229,7 +229,7 @@ ex_menu ( /* Careful: remove_menu() changes menu_path */ remove_menu(&root_menu, menu_path, modes, FALSE); - } else { + } else { /* * Add menu(s). * Replace special key codes. @@ -383,7 +383,7 @@ add_menu_path ( if (en_name != NULL) { menu->en_name = vim_strsave(en_name); menu->en_dname = menu_text(en_name, NULL, NULL); - } else { + } else { menu->en_name = NULL; menu->en_dname = NULL; } @@ -398,7 +398,7 @@ add_menu_path ( old_modes = 0; - } else { + } else { old_modes = menu->modes; /* @@ -609,7 +609,7 @@ remove_menu ( #endif if (remove_menu(&menu->children, p, modes, silent) == FAIL) return FAIL; - } else if (*name != NUL) { + } else if (*name != NUL) { if (!silent) EMSG(_(e_othermode)); return FAIL; @@ -742,7 +742,7 @@ static int show_menus(char_u *path_name, int modes) EMSG(_(e_notsubmenu)); vim_free(path_name); return FAIL; - } else if ((menu->modes & modes) == 0x0) { + } else if ((menu->modes & modes) == 0x0) { EMSG(_(e_othermode)); vim_free(path_name); return FAIL; @@ -824,7 +824,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth) else msg_outtrans_special(menu->strings[bit], FALSE); } - } else { + } else { if (menu == NULL) { menu = root_menu; depth--; @@ -1036,7 +1036,7 @@ char_u *get_menu_names(expand_T *xp, int idx) * so that '.' in names gets escaped properly */ STRCAT(tbuffer, "\001"); str = tbuffer; - } else { + } else { if (should_advance) str = menu->en_dname; else { @@ -1322,7 +1322,7 @@ void ex_emenu(exarg_T *eap) if (*p == NUL && menu->children != NULL) { EMSG(_("E333: Menu path must lead to a menu item")); menu = NULL; - } else if (*p != NUL && menu->children == NULL) { + } else if (*p != NUL && menu->children == NULL) { EMSG(_(e_notsubmenu)); menu = NULL; } @@ -1348,7 +1348,7 @@ void ex_emenu(exarg_T *eap) ) { mode = (char_u *)"Insert"; idx = MENU_INDEX_INSERT; - } else if (eap->addr_count) { + } else if (eap->addr_count) { pos_T tpos; mode = (char_u *)"Visual"; @@ -1365,7 +1365,7 @@ void ex_emenu(exarg_T *eap) tpos = curbuf->b_visual.vi_end; curwin->w_cursor = curbuf->b_visual.vi_start; curwin->w_curswant = curbuf->b_visual.vi_curswant; - } else { + } else { /* Set it up for line-wise visual mode */ VIsual_mode = 'V'; curwin->w_cursor.lnum = eap->line1; @@ -1388,7 +1388,7 @@ void ex_emenu(exarg_T *eap) * for exclusive mode */ if (*p_sel == 'e' && gchar_cursor() != NUL) ++curwin->w_cursor.col; - } else { + } else { mode = (char_u *)"Normal"; idx = MENU_INDEX_NORMAL; } @@ -1503,7 +1503,7 @@ void ex_menutranslate(exarg_T *eap) ga_clear(&menutrans_ga); /* Delete all "menutrans_" global variables. */ del_menutrans_vars(); - } else { + } else { /* ":menutrans from to": add translation */ from = arg; arg = menu_skip_part(arg); @@ -1528,7 +1528,7 @@ void ex_menutranslate(exarg_T *eap) tp[menutrans_ga.ga_len].from_noamp = from_noamp; tp[menutrans_ga.ga_len].to = to; ++menutrans_ga.ga_len; - } else { + } else { vim_free(from); vim_free(from_noamp); vim_free(to); diff --git a/src/message.c b/src/message.c index c04fb246cc..6a12517ba8 100644 --- a/src/message.c +++ b/src/message.c @@ -290,7 +290,7 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen) n -= ptr2cells(s + i); i += (*mb_ptr2len)(s + i); } - } else if (enc_utf8) { + } else if (enc_utf8) { /* For UTF-8 we can go backwards easily. */ half = i = (int)STRLEN(s); for (;; ) { @@ -303,7 +303,7 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen) len += n; i = half; } - } else { + } else { for (i = (int)STRLEN(s); len + (n = ptr2cells(s + i - 1)) <= room; --i) len += n; } @@ -316,7 +316,7 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen) len = buflen - e - 3 - 1; mch_memmove(buf + e + 3, s + i, len); buf[e + 3 + len - 1] = NUL; - } else { + } else { buf[e - 1] = NUL; /* make sure it is truncated */ } } @@ -362,7 +362,8 @@ int smsg_attr(int attr, char_u *s, long a1, long a2, long a3, long a4, long a5, int vim_snprintf(char *str, size_t str_m, char *fmt, ...); -int smsg(char_u *s, ...) { +int smsg(char_u *s, ...) +{ va_list arglist; va_start(arglist, s); @@ -371,7 +372,8 @@ int smsg(char_u *s, ...) { return msg(IObuff); } -int smsg_attr(int attr, char_u *s, ...) { +int smsg_attr(int attr, char_u *s, ...) +{ va_list arglist; va_start(arglist, s); @@ -393,7 +395,8 @@ static char_u *last_sourcing_name = NULL; * Reset the last used sourcing name/lnum. Makes sure it is displayed again * for the next error message; */ -void reset_last_sourcing(void) { +void reset_last_sourcing(void) +{ vim_free(last_sourcing_name); last_sourcing_name = NULL; last_sourcing_lnum = 0; @@ -402,7 +405,8 @@ void reset_last_sourcing(void) { /* * Return TRUE if "sourcing_name" differs from "last_sourcing_name". */ -static int other_sourcing_name(void) { +static int other_sourcing_name(void) +{ if (sourcing_name != NULL) { if (last_sourcing_name != NULL) return STRCMP(sourcing_name, last_sourcing_name) != 0; @@ -416,7 +420,8 @@ static int other_sourcing_name(void) { * Returns an allocated string with room for one more character. * Returns NULL when no message is to be given. */ -static char_u *get_emsg_source(void) { +static char_u *get_emsg_source(void) +{ char_u *Buf, *p; if (sourcing_name != NULL && other_sourcing_name()) { @@ -434,7 +439,8 @@ static char_u *get_emsg_source(void) { * Returns an allocated string with room for one more character. * Returns NULL when no message is to be given. */ -static char_u *get_emsg_lnum(void) { +static char_u *get_emsg_lnum(void) +{ char_u *Buf, *p; /* lnum is 0 when executing a command from the command line @@ -490,7 +496,8 @@ void msg_source(int attr) * If "msg" is in 'debug': do error message but without side effects. * If "emsg_skip" is set: never do error messages. */ -int emsg_not_now(void) { +int emsg_not_now(void) +{ if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL && vim_strchr(p_debug, 't') == NULL) || emsg_skip > 0 @@ -717,7 +724,8 @@ add_msg_hist ( * Delete the first (oldest) message from the history. * Returns FAIL if there are no messages. */ -int delete_first_msg(void) { +int delete_first_msg(void) +{ struct msg_hist *p; if (msg_hist_len <= 0) @@ -759,7 +767,8 @@ void ex_messages(exarg_T *eap) * Call this after prompting the user. This will avoid a hit-return message * and a delay. */ -void msg_end_prompt(void) { +void msg_end_prompt(void) +{ need_wait_return = FALSE; emsg_on_display = FALSE; cmdline_row = msg_row; @@ -812,11 +821,11 @@ void wait_return(int redraw) c = CAR; /* just pretend CR was hit */ quit_more = FALSE; got_int = FALSE; - } else if (exmode_active) { + } else if (exmode_active) { MSG_PUTS(" "); /* make sure the cursor is on the right line */ c = CAR; /* no need for a return in ex mode */ got_int = FALSE; - } else { + } else { /* Make sure the hit-return prompt is on screen when 'guioptions' was * just changed. */ screenalloc(FALSE); @@ -883,7 +892,7 @@ void wait_return(int redraw) c = CAR; /* just pretend CR was hit */ quit_more = FALSE; got_int = FALSE; - } else if (c != K_IGNORE) { + } else if (c != K_IGNORE) { c = K_IGNORE; hit_return_msg(); } @@ -914,7 +923,7 @@ void wait_return(int redraw) if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE || c == K_X1MOUSE || c == K_X2MOUSE) (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0); - else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C) { + else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C) { /* Put the character back in the typeahead buffer. Don't use the * stuff buffer, because lmaps wouldn't work. */ ins_char_typebuf(c); @@ -977,7 +986,8 @@ void wait_return(int redraw) /* * Write the hit-return prompt. */ -static void hit_return_msg(void) { +static void hit_return_msg(void) +{ int save_p_more = p_more; p_more = FALSE; /* don't want see this message when scrolling back */ @@ -1010,7 +1020,8 @@ void set_keep_msg(char_u *s, int attr) * If there currently is a message being displayed, set "keep_msg" to it, so * that it will be displayed again after redraw. */ -void set_keep_msg_from_hist(void) { +void set_keep_msg_from_hist(void) +{ if (keep_msg == NULL && last_msg_hist != NULL && msg_scrolled == 0 && (State & NORMAL)) set_keep_msg(last_msg_hist->msg, last_msg_hist->attr); @@ -1019,7 +1030,8 @@ void set_keep_msg_from_hist(void) { /* * Prepare for outputting characters in the command line. */ -void msg_start(void) { +void msg_start(void) +{ int did_return = FALSE; if (!msg_silent) { @@ -1039,7 +1051,7 @@ void msg_start(void) { msg_col = cmdmsg_rl ? Columns - 1 : 0; - } else if (msg_didout) { /* start message on next line */ + } else if (msg_didout) { /* start message on next line */ msg_putchar('\n'); did_return = TRUE; if (exmode_active != EXMODE_NORMAL) @@ -1060,7 +1072,8 @@ void msg_start(void) { /* * Note that the current msg position is where messages start. */ -void msg_starthere(void) { +void msg_starthere(void) +{ lines_left = cmdline_row; msg_didany = FALSE; } @@ -1079,7 +1092,7 @@ void msg_putchar_attr(int c, int attr) buf[1] = K_SECOND(c); buf[2] = K_THIRD(c); buf[3] = NUL; - } else { + } else { buf[(*mb_char2bytes)(c, buf)] = NUL; } msg_puts_attr(buf, attr); @@ -1199,7 +1212,7 @@ int msg_outtrans_len_attr(char_u *msgstr, int len, int attr) } len -= mb_l - 1; str += mb_l; - } else { + } else { s = transchar_byte(*str); if (s[1] != NUL) { /* unprintable char: print the printable chars so far and the @@ -1425,19 +1438,19 @@ void msg_prt_line(char_u *s, int list) c = c_extra; else c = *p_extra++; - } else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1) { + } else if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1) { col += (*mb_ptr2cells)(s); if (lcs_nbsp != NUL && list && mb_ptr2char(s) == 160) { mb_char2bytes(lcs_nbsp, buf); buf[(*mb_ptr2len)(buf)] = NUL; - } else { + } else { mch_memmove(buf, s, (size_t)l); buf[l] = NUL; } msg_puts(buf); s += l; continue; - } else { + } else { attr = 0; c = *s++; if (c == TAB && (!list || lcs_tab1)) { @@ -1446,22 +1459,22 @@ void msg_prt_line(char_u *s, int list) if (!list) { c = ' '; c_extra = ' '; - } else { + } else { c = lcs_tab1; c_extra = lcs_tab2; attr = hl_attr(HLF_8); } - } else if (c == 160 && list && lcs_nbsp != NUL) { + } else if (c == 160 && list && lcs_nbsp != NUL) { c = lcs_nbsp; attr = hl_attr(HLF_8); - } else if (c == NUL && list && lcs_eol != NUL) { + } else if (c == NUL && list && lcs_eol != NUL) { p_extra = (char_u *)""; c_extra = NUL; n_extra = 1; c = lcs_eol; attr = hl_attr(HLF_AT); --s; - } else if (c != NUL && (n = byte2cells(c)) > 1) { + } else if (c != NUL && (n = byte2cells(c)) > 1) { n_extra = n - 1; p_extra = transchar_byte(c); c_extra = NUL; @@ -1469,7 +1482,7 @@ void msg_prt_line(char_u *s, int list) /* Use special coloring to be able to distinguish <hex> from * the same in plain text. */ attr = hl_attr(HLF_8); - } else if (c == ' ' && trail != NULL && s > trail) { + } else if (c == ' ' && trail != NULL && s > trail) { c = lcs_trail; attr = hl_attr(HLF_8); } @@ -1509,7 +1522,7 @@ static char_u *screen_puts_mbyte(char_u *s, int l, int attr) msg_col = Columns; ++msg_row; } - } else { + } else { msg_col += cw; if (msg_col >= Columns) { msg_col = 0; @@ -1744,12 +1757,12 @@ static void msg_puts_display(char_u *str, int maxlen, int attr, int recurse) msg_col = 0; if (++msg_row >= Rows) /* safety check */ msg_row = Rows - 1; - } else if (*s == '\r') { /* go to column 0 */ + } else if (*s == '\r') { /* go to column 0 */ msg_col = 0; - } else if (*s == '\b') { /* go to previous char */ + } else if (*s == '\b') { /* go to previous char */ if (msg_col) --msg_col; - } else if (*s == TAB) { /* translate Tab into spaces */ + } else if (*s == TAB) { /* translate Tab into spaces */ do msg_screen_putchar(' ', attr); while (msg_col & 7); @@ -1763,7 +1776,7 @@ static void msg_puts_display(char_u *str, int maxlen, int attr, int recurse) l = utfc_ptr2len_len(s, (int)((str + maxlen) - s)); else l = (*mb_ptr2len)(s); - } else { + } else { cw = 1; l = 1; } @@ -1779,7 +1792,7 @@ static void msg_puts_display(char_u *str, int maxlen, int attr, int recurse) s = screen_puts_mbyte(s, l, attr) - 1; else msg_screen_putchar(*s, attr); - } else { + } else { /* postpone this character until later */ if (t_col == 0) t_s = s; @@ -1802,7 +1815,8 @@ static void msg_puts_display(char_u *str, int maxlen, int attr, int recurse) /* * Scroll the screen up one line for displaying the next message line. */ -static void msg_scroll_up(void) { +static void msg_scroll_up(void) +{ /* scrolling up always works */ screen_del_lines(0, 0, 1, (int)Rows, TRUE, NULL); @@ -1823,7 +1837,8 @@ static void msg_scroll_up(void) { /* * Increment "msg_scrolled". */ -static void inc_msg_scrolled(void) { +static void inc_msg_scrolled(void) +{ if (*get_vim_var_str(VV_SCROLLSTART) == NUL) { char_u *p = sourcing_name; char_u *tofree = NULL; @@ -1899,7 +1914,7 @@ store_sb_text ( if (last_msgchunk == NULL) { last_msgchunk = mp; mp->sb_prev = NULL; - } else { + } else { mp->sb_prev = last_msgchunk; last_msgchunk->sb_next = mp; last_msgchunk = mp; @@ -1916,7 +1931,8 @@ store_sb_text ( /* * Finished showing messages, clear the scroll-back text on the next message. */ -void may_clear_sb_text(void) { +void may_clear_sb_text(void) +{ do_clear_sb_text = TRUE; } @@ -1924,7 +1940,8 @@ void may_clear_sb_text(void) { * Clear any text remembered for scrolling back. * Called when redrawing the screen. */ -void clear_sb_text(void) { +void clear_sb_text(void) +{ msgchunk_T *mp; while (last_msgchunk != NULL) { @@ -1937,7 +1954,8 @@ void clear_sb_text(void) { /* * "g<" command. */ -void show_sb_text(void) { +void show_sb_text(void) +{ msgchunk_T *mp; /* Only show something if there is more than one line, otherwise it looks @@ -1966,7 +1984,8 @@ static msgchunk_T *msg_sb_start(msgchunk_T *mps) /* * Mark the last message chunk as finishing the line. */ -void msg_sb_eol(void) { +void msg_sb_eol(void) +{ if (last_msgchunk != NULL) last_msgchunk->sb_eol = TRUE; } @@ -2022,7 +2041,8 @@ static void t_puts(int *t_col, char_u *t_s, char_u *s, int attr) * different, e.g. for Win32 console) or we just don't know where the * cursor is. */ -int msg_use_printf(void) { +int msg_use_printf(void) +{ return !msg_check_screen() || (swapping_screen() && !termcap_active) ; @@ -2061,7 +2081,7 @@ static void msg_puts_printf(char_u *str, int maxlen) msg_col = Columns - 1; else --msg_col; - } else { + } else { if (*s == '\r' || *s == '\n') msg_col = 0; else @@ -2175,7 +2195,7 @@ static int do_more_prompt(int typed_char) if (confirm_msg_used) { /* Jump to the choices of the dialog. */ retval = TRUE; - } else { + } else { got_int = TRUE; quit_more = TRUE; } @@ -2220,7 +2240,7 @@ static int do_more_prompt(int typed_char) (int)Rows, NULL) == OK) { /* display line at top */ (void)disp_sb_line(0, mp); - } else { + } else { /* redisplay all lines */ screenclear(); for (i = 0; mp != NULL && i < Rows - 1; ++i) { @@ -2230,7 +2250,7 @@ static int do_more_prompt(int typed_char) } toscroll = 0; } - } else { + } else { /* First display any text that we scrolled back. */ while (toscroll > 0 && mp_last != NULL) { /* scroll up, display line at bottom */ @@ -2371,7 +2391,7 @@ static void msg_screen_putchar(int c, int attr) msg_col = Columns; ++msg_row; } - } else { + } else { if (++msg_col >= Columns) { msg_col = 0; ++msg_row; @@ -2396,16 +2416,17 @@ void msg_moremsg(int full) * Repeat the message for the current mode: ASKMORE, EXTERNCMD, CONFIRM or * exmode_active. */ -void repeat_message(void) { +void repeat_message(void) +{ if (State == ASKMORE) { msg_moremsg(TRUE); /* display --more-- message again */ msg_row = Rows - 1; - } else if (State == CONFIRM) { + } else if (State == CONFIRM) { display_confirm_msg(); /* display ":confirm" message again */ msg_row = Rows - 1; - } else if (State == EXTERNCMD) { + } else if (State == EXTERNCMD) { windgoto(msg_row, msg_col); /* put cursor back */ - } else if (State == HITRETURN || State == SETWSIZE) { + } else if (State == HITRETURN || State == SETWSIZE) { if (msg_row == Rows - 1) { /* Avoid drawing the "hit-enter" prompt below the previous one, * overwrite it. Esp. useful when regaining focus and a @@ -2425,7 +2446,8 @@ void repeat_message(void) { * While starting the GUI the terminal codes will be set for the GUI, but the * output goes to the terminal. Don't use the terminal codes then. */ -static int msg_check_screen(void) { +static int msg_check_screen(void) +{ if (!full_screen || !screen_valid(FALSE)) return FALSE; @@ -2440,7 +2462,8 @@ static int msg_check_screen(void) { * Clear from current message position to end of screen. * Skip this when ":silent" was used, no need to clear for redirection. */ -void msg_clr_eos(void) { +void msg_clr_eos(void) +{ if (msg_silent == 0) msg_clr_eos_force(); } @@ -2450,7 +2473,8 @@ void msg_clr_eos(void) { * Note: msg_col is not updated, so we remember the end of the message * for msg_check(). */ -void msg_clr_eos_force(void) { +void msg_clr_eos_force(void) +{ if (msg_use_printf()) { if (full_screen) { /* only when termcap codes are valid */ if (*T_CD) @@ -2458,11 +2482,11 @@ void msg_clr_eos_force(void) { else if (*T_CE) out_str(T_CE); /* clear to end of line */ } - } else { + } else { if (cmdmsg_rl) { screen_fill(msg_row, msg_row + 1, 0, msg_col + 1, ' ', ' ', 0); screen_fill(msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0); - } else { + } else { screen_fill(msg_row, msg_row + 1, msg_col, (int)Columns, ' ', ' ', 0); screen_fill(msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0); @@ -2473,7 +2497,8 @@ void msg_clr_eos_force(void) { /* * Clear the command line. */ -void msg_clr_cmdline(void) { +void msg_clr_cmdline(void) +{ msg_row = cmdline_row; msg_col = 0; msg_clr_eos_force(); @@ -2484,7 +2509,8 @@ void msg_clr_cmdline(void) { * call wait_return if the message does not fit in the available space * return TRUE if wait_return not called. */ -int msg_end(void) { +int msg_end(void) +{ /* * If the string is larger than the window, * or the ruler option is set and we run into it, @@ -2503,7 +2529,8 @@ int msg_end(void) { * If the written message runs into the shown command or ruler, we have to * wait for hit-return and redraw the window later. */ -void msg_check(void) { +void msg_check(void) +{ if (msg_row == Rows - 1 && msg_col >= sc_col) { need_wait_return = TRUE; redraw_cmdline = TRUE; @@ -2569,7 +2596,8 @@ static void redir_write(char_u *str, int maxlen) } } -int redirecting(void) { +int redirecting(void) +{ return redir_fd != NULL || *p_vfile != NUL || redir_reg || redir_vname ; @@ -2579,7 +2607,8 @@ int redirecting(void) { * Before giving verbose message. * Must always be called paired with verbose_leave()! */ -void verbose_enter(void) { +void verbose_enter(void) +{ if (*p_vfile != NUL) ++msg_silent; } @@ -2588,7 +2617,8 @@ void verbose_enter(void) { * After giving verbose message. * Must always be called paired with verbose_enter()! */ -void verbose_leave(void) { +void verbose_leave(void) +{ if (*p_vfile != NUL) if (--msg_silent < 0) msg_silent = 0; @@ -2597,7 +2627,8 @@ void verbose_leave(void) { /* * Like verbose_enter() and set msg_scroll when displaying the message. */ -void verbose_enter_scroll(void) { +void verbose_enter_scroll(void) +{ if (*p_vfile != NUL) ++msg_silent; else @@ -2608,7 +2639,8 @@ void verbose_enter_scroll(void) { /* * Like verbose_leave() and set cmdline_row when displaying the message. */ -void verbose_leave_scroll(void) { +void verbose_leave_scroll(void) +{ if (*p_vfile != NUL) { if (--msg_silent < 0) msg_silent = 0; @@ -2619,7 +2651,8 @@ void verbose_leave_scroll(void) { /* * Called when 'verbosefile' is set: stop writing to the file. */ -void verbose_stop(void) { +void verbose_stop(void) +{ if (verbose_fd != NULL) { fclose(verbose_fd); verbose_fd = NULL; @@ -2631,7 +2664,8 @@ void verbose_stop(void) { * Open the file 'verbosefile'. * Return FAIL or OK. */ -int verbose_open(void) { +int verbose_open(void) +{ if (verbose_fd == NULL && !verbose_did_open) { /* Only give the error message once. */ verbose_did_open = TRUE; @@ -2821,12 +2855,12 @@ copy_char ( if (lowercase) { c = MB_TOLOWER((*mb_ptr2char)(from)); return (*mb_char2bytes)(c, to); - } else { + } else { len = (*mb_ptr2len)(from); mch_memmove(to, from, (size_t)len); return len; } - } else { + } else { if (lowercase) *to = (char_u)TOLOWER_LOC(*from); else @@ -2886,13 +2920,13 @@ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfl /* If no hotkey is specified first char is used. */ if (idx < HAS_HOTKEY_LEN - 1 && !has_hotkey[++idx]) first_hotkey = TRUE; - } else { + } else { len += 3; /* '\n' -> ', '; 'x' -> '(x)' */ lenhotkey += HOTK_LEN; /* each button needs a hotkey */ if (idx < HAS_HOTKEY_LEN - 1) has_hotkey[++idx] = FALSE; } - } else if (*r == DLG_HOTKEY_CHAR || first_hotkey) { + } else if (*r == DLG_HOTKEY_CHAR || first_hotkey) { if (*r == DLG_HOTKEY_CHAR) ++r; first_hotkey = FALSE; @@ -2908,12 +2942,12 @@ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfl /* redefine hotkey */ hotkp[copy_char(r, hotkp, TRUE)] = NUL; } - } else { + } else { ++len; /* '&a' -> '[a]' */ if (idx < HAS_HOTKEY_LEN - 1) has_hotkey[idx] = TRUE; } - } else { + } else { /* everything else copy literally */ if (copy) msgp += copy_char(r, msgp, FALSE); @@ -2927,7 +2961,7 @@ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfl *msgp++ = ':'; *msgp++ = ' '; *msgp = NUL; - } else { + } else { len += (int)(STRLEN(message) + 2 /* for the NL's */ + STRLEN(buttons) @@ -2976,7 +3010,8 @@ static char_u *msg_show_console_dialog(char_u *message, char_u *buttons, int dfl /* * Display the ":confirm" message. Also called when screen resized. */ -void display_confirm_msg(void) { +void display_confirm_msg(void) +{ /* avoid that 'q' at the more prompt truncates the message here */ ++confirm_msg_used; if (confirm_msg != NULL) @@ -3138,7 +3173,8 @@ static double tv_float(typval_T *tvs, int *idxp) # ifdef HAVE_STDARG_H /* Like vim_vsnprintf() but append to the string. */ -int vim_snprintf_add(char *str, size_t str_m, char *fmt, ...) { +int vim_snprintf_add(char *str, size_t str_m, char *fmt, ...) +{ va_list ap; int str_l; size_t len = STRLEN(str); @@ -3171,7 +3207,8 @@ int vim_snprintf_add(char *str, size_t str_m, char *fmt, long a1, long a2, long # endif # ifdef HAVE_STDARG_H -int vim_snprintf(char *str, size_t str_m, char *fmt, ...) { +int vim_snprintf(char *str, size_t str_m, char *fmt, ...) +{ va_list ap; int str_l; @@ -3221,7 +3258,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; } p += n; str_l += n; - } else { + } else { size_t min_field_width = 0, precision = 0; int zero_padding = 0, precision_specified = 0, justify_left = 0; int alternate_form = 0, force_sign = 0; @@ -3300,7 +3337,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; min_field_width = -j; justify_left = 1; } - } else if (VIM_ISDIGIT((int)(*p))) { + } else if (VIM_ISDIGIT((int)(*p))) { /* size_t could be wider than unsigned int; make sure we treat * argument like common implementations do */ unsigned int uj = *p++ - '0'; @@ -3331,7 +3368,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; precision_specified = 0; precision = 0; } - } else if (VIM_ISDIGIT((int)(*p))) { + } else if (VIM_ISDIGIT((int)(*p))) { /* size_t could be wider than unsigned int; make sure we * treat argument like common implementations do */ unsigned int uj = *p++ - '0'; @@ -3487,7 +3524,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; #endif if (ptr_arg != NULL) arg_sign = 1; - } else if (fmt_spec == 'd') { + } else if (fmt_spec == 'd') { /* signed */ switch (length_modifier) { case '\0': @@ -3519,7 +3556,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; arg_sign = -1; break; } - } else { + } else { /* unsigned */ switch (length_modifier) { case '\0': @@ -3566,7 +3603,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; tmp[str_arg_l++] = space_for_positive ? ' ' : '+'; /* leave negative numbers for sprintf to handle, to * avoid handling tricky cases like (short int)-32768 */ - } else if (alternate_form) { + } else if (alternate_form) { if (arg_sign != 0 && (fmt_spec == 'x' || fmt_spec == 'X') ) { tmp[str_arg_l++] = '0'; @@ -3583,7 +3620,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; /* When zero value is formatted with an explicit * precision 0, the resulting formatted string is * empty (d, i, u, o, x, X, p). */ - } else { + } else { char f[5]; int f_l = 0; @@ -3612,7 +3649,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; tmp + str_arg_l, f, long_arg); break; } - } else { + } else { /* unsigned */ switch (length_modifier) { case '\0': @@ -3716,7 +3753,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; /* Avoid a buffer overflow */ strcpy(tmp, "inf"); str_arg_l = 3; - } else { + } else { format[0] = '%'; l = 1; if (precision_specified) { @@ -3771,7 +3808,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; --tp; --str_arg_l; } - } else { + } else { char *tp; /* Be consistent: some printf("%e") use 1.0e+12 @@ -3838,7 +3875,7 @@ long a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; /* will not copy first part of numeric right now, * * force it to be copied later in its entirety */ zero_padding_insertion_ind = 0; - } else { + } else { /* insert first part of numerics (sign or '0x') before zero * padding */ int zn = (int)zero_padding_insertion_ind; diff --git a/src/misc1.c b/src/misc1.c index bb9b43dd0c..f245771931 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -255,7 +255,7 @@ open_line ( } } } - } else { /* Not a comment line */ + } else { /* Not a comment line */ /* Find last non-blank in line */ p = ptr + STRLEN(ptr) - 1; while (p > ptr && vim_iswhite(*p)) @@ -304,7 +304,7 @@ open_line ( && cin_is_cinword(ptr)) did_si = TRUE; } - } else { /* dir == BACKWARD */ + } else { /* dir == BACKWARD */ /* * Skip preprocessor directives, unless they are * recognised as comments. @@ -571,7 +571,7 @@ open_line ( } else if (!vim_iswhite(*p)) *p = ' '; } - } else { /* left adjusted leader */ + } else { /* left adjusted leader */ p = skipwhite(leader); /* Compute the length of the replaced characters in * screen characters, not bytes. Move the part that is @@ -605,7 +605,7 @@ open_line ( --lead_len; mch_memmove(p, p + 1, (leader + lead_len) - p); - } else { + } else { int l = (*mb_ptr2len)(p); if (l > 1) { @@ -679,7 +679,7 @@ open_line ( } did_si = can_si = FALSE; - } else if (comment_end != NULL) { + } else if (comment_end != NULL) { /* * We have finished a comment, so we don't use the leader. * If this was a C-comment and 'ai' or 'si' is set do a normal @@ -769,7 +769,7 @@ open_line ( * with markers. */ mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L); did_append = TRUE; - } else { + } else { /* * In VREPLACE mode we are starting to replace the next line. */ @@ -1362,7 +1362,7 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last) if (x > 0) { ++count; /* count 1 for "+-- folded" line */ first += x; - } else { + } else { if (first == wp->w_topline) count += plines_win_nofill(wp, first, TRUE) + wp->w_topfill; else @@ -1490,7 +1490,7 @@ void ins_char_bytes(char_u *buf, int charlen) newlen += vcol - new_vcol; } curwin->w_p_list = old_list; - } else if (oldp[col] != NUL) { + } else if (oldp[col] != NUL) { /* normal replace */ oldlen = (*mb_ptr2len)(oldp + col); } @@ -1816,7 +1816,8 @@ int gchar_pos(pos_T *pos) return (int)*ptr; } -int gchar_cursor(void) { +int gchar_cursor(void) +{ if (has_mbyte) return (*mb_ptr2char)(ml_get_cursor()); return (int)*ml_get_cursor(); @@ -1852,7 +1853,8 @@ char_u *skip_to_option_part(char_u *p) * * Careful: may trigger autocommands that reload the buffer. */ -void changed(void) { +void changed(void) +{ if (!curbuf->b_changed) { int save_msg_scroll = msg_scroll; @@ -1887,7 +1889,8 @@ void changed(void) { /* * Internal part of changed(), no user interaction. */ -void changed_int(void) { +void changed_int(void) +{ curbuf->b_changed = TRUE; ml_setflags(curbuf); check_status(curbuf); @@ -1936,7 +1939,7 @@ static void changedOneline(buf_T *buf, linenr_T lnum) buf->b_mod_top = lnum; else if (lnum >= buf->b_mod_bot) buf->b_mod_bot = lnum + 1; - } else { + } else { /* set the area that must be redisplayed to one line */ buf->b_mod_set = TRUE; buf->b_mod_top = lnum; @@ -2048,7 +2051,7 @@ changed_lines_buf ( if (lnume + xtra > buf->b_mod_bot) buf->b_mod_bot = lnume + xtra; buf->b_mod_xlines += xtra; - } else { + } else { /* set the area that must be redisplayed */ buf->b_mod_set = TRUE; buf->b_mod_top = lnum; @@ -2190,12 +2193,12 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra if (wp->w_lines[i].wl_lnum < lnume) { /* line included in change */ wp->w_lines[i].wl_valid = FALSE; - } else if (xtra != 0) { + } else if (xtra != 0) { /* line below change */ wp->w_lines[i].wl_lnum += xtra; wp->w_lines[i].wl_lastlnum += xtra; } - } else if (wp->w_lines[i].wl_lastlnum >= lnum) { + } else if (wp->w_lines[i].wl_lastlnum >= lnum) { /* change somewhere inside this range of folded lines, * may need to be redrawn */ wp->w_lines[i].wl_valid = FALSE; @@ -2387,7 +2390,8 @@ int is_mouse_key(int c) * Disadvantage: typeahead is ignored. * Translates the interrupt character for unix to ESC. */ -int get_keystroke(void) { +int get_keystroke(void) +{ char_u *buf = NULL; int buflen = 150; int maxlen; @@ -2517,17 +2521,17 @@ get_number ( n = n * 10 + c - '0'; msg_putchar(c); ++typed; - } else if (c == K_DEL || c == K_KDEL || c == K_BS || c == Ctrl_H) { + } else if (c == K_DEL || c == K_KDEL || c == K_BS || c == Ctrl_H) { if (typed > 0) { MSG_PUTS("\b \b"); --typed; } n /= 10; - } else if (mouse_used != NULL && c == K_LEFTMOUSE) { + } else if (mouse_used != NULL && c == K_LEFTMOUSE) { *mouse_used = TRUE; n = mouse_row + 1; break; - } else if (n == 0 && c == ':' && colon) { + } else if (n == 0 && c == ':' && colon) { stuffcharReadbuff(':'); if (!exmode_active) cmdline_row = msg_row; @@ -2608,7 +2612,7 @@ void msgmore(long n) else vim_strncpy(msg_buf, (char_u *)_("1 line less"), MSG_BUF_LEN - 1); - } else { + } else { if (n > 0) vim_snprintf((char *)msg_buf, MSG_BUF_LEN, _("%ld more lines"), pn); @@ -2628,7 +2632,8 @@ void msgmore(long n) /* * flush map and typeahead buffers and give a warning for an error */ -void beep_flush(void) { +void beep_flush(void) +{ if (emsg_silent == 0) { flush_buffers(FALSE); vim_beep(); @@ -2638,12 +2643,13 @@ void beep_flush(void) { /* * give a warning for an error */ -void vim_beep(void) { +void vim_beep(void) +{ if (emsg_silent == 0) { if (p_vb ) { out_str(T_VB); - } else { + } else { out_char(BELL); } @@ -2667,7 +2673,8 @@ void vim_beep(void) { */ static char_u *homedir = NULL; -void init_homedir(void) { +void init_homedir(void) +{ char_u *var; /* In case we are called a second time (when 'encoding' changes). */ @@ -2699,11 +2706,13 @@ void init_homedir(void) { } #if defined(EXITFREE) || defined(PROTO) -void free_homedir(void) { +void free_homedir(void) +{ vim_free(homedir); } -void free_users(void) { +void free_users(void) +{ ga_clear_strings(&ga_users); } @@ -2831,7 +2840,7 @@ expand_env_esc ( || vim_strchr((char_u *)" ,\t\n", src[1]) != NULL) { var = homedir; tail = src + 1; - } else { /* user directory */ + } else { /* user directory */ #if defined(UNIX) || (defined(VMS) && defined(USER_HOME)) /* * Copy ~user to dst[], so we can put a NUL after it. @@ -3069,7 +3078,7 @@ char_u *vim_getenv(char_u *name, int *mustfree) if (p != NULL && !mch_isdir(p)) { vim_free(p); p = NULL; - } else { + } else { #ifdef USE_EXE_NAME /* may add "/vim54" or "/runtime" if it exists */ if (vimruntime && (pend = vim_version_dir(p)) != NULL) { @@ -3090,7 +3099,7 @@ char_u *vim_getenv(char_u *name, int *mustfree) if (vimruntime && *default_vimruntime_dir != NUL) { p = default_vimruntime_dir; *mustfree = FALSE; - } else if (*default_vim_dir != NUL) { + } else if (*default_vim_dir != NUL) { if (vimruntime && (p = vim_version_dir(default_vim_dir)) != NULL) *mustfree = TRUE; else { @@ -3109,7 +3118,7 @@ char_u *vim_getenv(char_u *name, int *mustfree) if (vimruntime) { vim_setenv((char_u *)"VIMRUNTIME", p); didset_vimruntime = TRUE; - } else { + } else { vim_setenv((char_u *)"VIM", p); didset_vim = TRUE; } @@ -3496,7 +3505,7 @@ static char_u *gettail_dir(char_u *fname) next_dir_end = p; look_for_sep = FALSE; } - } else { + } else { if (!look_for_sep) dir_end = next_dir_end; look_for_sep = TRUE; @@ -3611,10 +3620,10 @@ void shorten_dir(char_u *str) *d++ = *s; if (*s == NUL) break; - } else if (vim_ispathsep(*s)) { /* copy '/' and next char */ + } else if (vim_ispathsep(*s)) { /* copy '/' and next char */ *d++ = *s; skip = FALSE; - } else if (!skip) { + } else if (!skip) { *d++ = *s; /* copy next char */ if (*s != '~' && *s != '.') /* and leading "~" and "." */ skip = TRUE; @@ -3768,7 +3777,8 @@ FullName_save ( return new_fname; } -void prepare_to_exit(void) { +void prepare_to_exit(void) +{ #if defined(SIGHUP) && defined(SIG_IGN) /* Ignore SIGHUP, because a dropped connection causes a read error, which * makes Vim exit and then handling SIGHUP causes various reentrance @@ -3795,7 +3805,8 @@ void prepare_to_exit(void) { * NOTE: This may be called from deathtrap() in a signal handler, avoid unsafe * functions, such as allocating memory. */ -void preserve_exit(void) { +void preserve_exit(void) +{ buf_T *buf; prepare_to_exit(); @@ -3840,7 +3851,8 @@ void preserve_exit(void) { static int breakcheck_count = 0; -void line_breakcheck(void) { +void line_breakcheck(void) +{ if (++breakcheck_count >= BREAKCHECK_SKIP) { breakcheck_count = 0; ui_breakcheck(); @@ -3850,7 +3862,8 @@ void line_breakcheck(void) { /* * Like line_breakcheck() but check 10 times less often. */ -void fast_breakcheck(void) { +void fast_breakcheck(void) +{ if (++breakcheck_count >= BREAKCHECK_SKIP * 10) { breakcheck_count = 0; ui_breakcheck(); @@ -3988,7 +4001,7 @@ int match_suffix(char_u *fname) setsuflen = 1; break; } - } else { + } else { if (fnamelen >= setsuflen && fnamencmp(suf_buf, fname + fnamelen - setsuflen, (size_t)setsuflen) == 0) @@ -4179,7 +4192,7 @@ unix_expandpath ( /* need to expand another component of the path */ /* remove backslashes for the remaining components only */ (void)unix_expandpath(gap, buf, len + 1, flags, FALSE); - } else { + } else { /* no more wildcards, check if there is a match */ /* remove backslashes for the remaining components only */ if (*path_end != NUL) @@ -4574,7 +4587,7 @@ expand_in_path ( if (*e == NUL) { addfile(gap, s, flags); break; - } else { + } else { /* *e is '\n' */ *e = NUL; addfile(gap, s, flags); @@ -4987,7 +5000,7 @@ get_cmd_output ( EMSG2(_(e_notread), tempname); vim_free(buffer); buffer = NULL; - } else { + } else { /* Change NUL into SOH, otherwise the string is truncated. */ for (i = 0; i < len; ++i) if (buffer[i] == NUL) @@ -5019,7 +5032,8 @@ void FreeWild(int count, char_u **files) * Don't do this when still processing a command or a mapping. * Don't do this when inside a ":normal" command. */ -int goto_im(void) { +int goto_im(void) +{ return p_im && stuff_empty() && typebuf_typed(); } diff --git a/src/misc2.c b/src/misc2.c index 2ede5d38ee..595d13cbec 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -53,7 +53,8 @@ static int coladvance2(pos_T *pos, int addspaces, int finetune, /* * Return TRUE if in the current mode we need to use virtual. */ -int virtual_active(void) { +int virtual_active(void) +{ /* While an operator is being executed we return "virtual_op", because * VIsual_active has already been reset, thus we can't check for "block" * being used. */ @@ -67,7 +68,8 @@ int virtual_active(void) { /* * Get the screen position of the cursor. */ -int getviscol(void) { +int getviscol(void) +{ colnr_T x; getvvcol(curwin, &curwin->w_cursor, &x, NULL, NULL); @@ -172,7 +174,7 @@ coladvance2 ( if (curwin->w_curswant > 0) --curwin->w_curswant; } - } else { + } else { int width = W_WIDTH(curwin) - win_col_off(curwin); if (finetune @@ -241,7 +243,7 @@ coladvance2 ( changed_bytes(pos->lnum, (colnr_T)idx); idx += correct; col = wcol; - } else { + } else { /* Break a tab */ int linelen = (int)STRLEN(line); int correct = wcol - col - csize + 1; /* negative!! */ @@ -290,7 +292,7 @@ coladvance2 ( getvcol(curwin, pos, &scol, NULL, &ecol); pos->coladd = ecol - scol; } - } else { + } else { int b = (int)wcol - (int)col; /* The difference between wcol and col is used to set coladd. */ @@ -313,7 +315,8 @@ coladvance2 ( /* * Increment the cursor position. See inc() for return values. */ -int inc_cursor(void) { +int inc_cursor(void) +{ return inc(&curwin->w_cursor); } @@ -366,7 +369,8 @@ int incl(pos_T *lp) * Decrement the line pointer 'p' crossing line boundaries as necessary. * Return 1 when crossing a line, -1 when at start of file, 0 otherwise. */ -int dec_cursor(void) { +int dec_cursor(void) +{ return dec(&curwin->w_cursor); } @@ -430,7 +434,7 @@ get_cursor_rel_lnum ( retval++; lnum--; } - } else if (lnum < cursor) { + } else if (lnum < cursor) { while (lnum < cursor) { (void)hasFoldingWin(wp, lnum, NULL, &lnum, TRUE, NULL); /* if lnum and cursor are in the same fold, @@ -452,7 +456,8 @@ get_cursor_rel_lnum ( /* * Make sure curwin->w_cursor.lnum is valid. */ -void check_cursor_lnum(void) { +void check_cursor_lnum(void) +{ if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) { /* If there is a closed fold at the end of the file, put the cursor in * its first line. Otherwise in the last line. */ @@ -467,7 +472,8 @@ void check_cursor_lnum(void) { /* * Make sure curwin->w_cursor.col is valid. */ -void check_cursor_col(void) { +void check_cursor_col(void) +{ check_cursor_col_win(curwin); } @@ -519,7 +525,8 @@ void check_cursor_col_win(win_T *win) /* * make sure curwin->w_cursor in on a valid character */ -void check_cursor(void) { +void check_cursor(void) +{ check_cursor_lnum(); check_cursor_col(); } @@ -528,7 +535,8 @@ void check_cursor(void) { * Make sure curwin->w_cursor is not on the NUL at the end of the line. * Allow it when in Visual mode and 'selection' is not "old". */ -void adjust_cursor_col(void) { +void adjust_cursor_col(void) +{ if (curwin->w_cursor.col > 0 && (!VIsual_active || *p_sel == 'o') && gchar_cursor() == NUL) @@ -539,7 +547,8 @@ void adjust_cursor_col(void) { * When curwin->w_leftcol has changed, adjust the cursor position. * Return TRUE if the cursor was moved. */ -int leftcol_changed(void) { +int leftcol_changed(void) +{ long lastcol; colnr_T s, e; int retval = FALSE; @@ -555,7 +564,7 @@ int leftcol_changed(void) { if (curwin->w_virtcol > (colnr_T)(lastcol - p_siso)) { retval = TRUE; coladvance((colnr_T)(lastcol - p_siso)); - } else if (curwin->w_virtcol < curwin->w_leftcol + p_siso) { + } else if (curwin->w_virtcol < curwin->w_leftcol + p_siso) { retval = TRUE; (void)coladvance((colnr_T)(curwin->w_leftcol + p_siso)); } @@ -569,7 +578,7 @@ int leftcol_changed(void) { if (e > (colnr_T)lastcol) { retval = TRUE; coladvance(s - 1); - } else if (s < curwin->w_leftcol) { + } else if (s < curwin->w_leftcol) { retval = TRUE; if (coladvance(e + 1) == FAIL) { /* there isn't another character */ curwin->w_leftcol = s; /* adjust w_leftcol instead */ @@ -647,7 +656,8 @@ static void mem_pre_free(void **pp) /* * called on exit via atexit() */ -void vim_mem_profile_dump(void) { +void vim_mem_profile_dump(void) +{ int i, j; printf("\r\n"); @@ -871,7 +881,8 @@ void do_outofmem_msg(long_u size) * surprised if Vim crashes... * Some things can't be freed, esp. things local to a library function. */ -void free_all_mem(void) { +void free_all_mem(void) +{ buf_T *buf, *nextbuf; static int entered = FALSE; @@ -1102,7 +1113,8 @@ char_u *vim_strsave_escaped_ext(char_u *string, char_u *esc_chars, int cc, int b /* * Return TRUE when 'shell' has "csh" in the tail. */ -int csh_like_shell(void) { +int csh_like_shell(void) +{ return strstr((char *)gettail(p_sh), "csh") != NULL; } @@ -1693,7 +1705,8 @@ set_fileformat ( /* * Return the default fileformat from 'fileformats'. */ -int default_fileformat(void) { +int default_fileformat(void) +{ switch (*p_ffs) { case 'm': return EOL_MAC; case 'd': return EOL_DOS; @@ -1725,7 +1738,7 @@ int call_shell(char_u *cmd, int opt) if (*p_sh == NUL) { EMSG(_(e_shellempty)); retval = -1; - } else { + } else { /* The external command may update a tags file, clear cached tags. */ tag_freematch(); @@ -1773,7 +1786,8 @@ int call_shell(char_u *cmd, int opt) * VISUAL, SELECTMODE and OP_PENDING State are never set, they are equal to * NORMAL State with a condition. This function returns the real State. */ -int get_real_state(void) { +int get_real_state(void) +{ if (State & NORMAL) { if (VIsual_active) { if (VIsual_select) diff --git a/src/move.c b/src/move.c index 8bf405e05e..26be5698e5 100644 --- a/src/move.c +++ b/src/move.c @@ -69,7 +69,7 @@ static void comp_botline(win_T *wp) if (wp->w_valid & VALID_CROW) { lnum = wp->w_cursor.lnum; done = wp->w_cline_row; - } else { + } else { lnum = wp->w_topline; done = 0; } @@ -109,7 +109,8 @@ static void comp_botline(win_T *wp) * Update curwin->w_topline and redraw if necessary. * Used to update the screen before printing a message. */ -void update_topline_redraw(void) { +void update_topline_redraw(void) +{ update_topline(); if (must_redraw) update_screen(0); @@ -118,7 +119,8 @@ void update_topline_redraw(void) { /* * Update curwin->w_topline to move the cursor onto the screen. */ -void update_topline(void) { +void update_topline(void) +{ long line_count; int halfheight; int n; @@ -203,7 +205,7 @@ void update_topline(void) { scroll_cursor_top(scrolljump_value(), FALSE); check_botline = TRUE; } - } else { + } else { /* Make sure topline is the first line of a fold. */ (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); check_botline = TRUE; @@ -306,7 +308,8 @@ void update_topline(void) { * When 'scrolljump' is positive use it as-is. * When 'scrolljump' is negative use it as a percentage of the window height. */ -static int scrolljump_value(void) { +static int scrolljump_value(void) +{ if (p_sj >= 0) return (int)p_sj; return (curwin->w_height * -p_sj) / 100; @@ -316,7 +319,8 @@ static int scrolljump_value(void) { * Return TRUE when there are not 'scrolloff' lines above the cursor for the * current window. */ -static int check_top_offset(void) { +static int check_top_offset(void) +{ lineoff_T loff; int n; @@ -342,7 +346,8 @@ static int check_top_offset(void) { return FALSE; } -void update_curswant(void) { +void update_curswant(void) +{ if (curwin->w_set_curswant) { validate_virtcol(); curwin->w_curswant = curwin->w_virtcol; @@ -376,7 +381,8 @@ void check_cursor_moved(win_T *wp) * the cursor position, botline and topline to be recomputed and the window to * be redrawn. E.g, when changing the 'wrap' option or folding. */ -void changed_window_setting(void) { +void changed_window_setting(void) +{ changed_window_setting_win(curwin); } @@ -410,7 +416,8 @@ void set_topline(win_T *wp, linenr_T lnum) * characters) has changed, and the change is before the cursor. * Need to take care of w_botline separately! */ -void changed_cline_bef_curs(void) { +void changed_cline_bef_curs(void) +{ curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL |VALID_CHEIGHT|VALID_TOPLINE); } @@ -426,7 +433,8 @@ void changed_cline_bef_curs_win(win_T *wp) * the cursor have changed. * Need to take care of w_botline separately! */ -void changed_line_abv_curs(void) { +void changed_line_abv_curs(void) +{ curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW |VALID_CHEIGHT|VALID_TOPLINE); } @@ -440,7 +448,8 @@ void changed_line_abv_curs_win(win_T *wp) /* * Make sure the value of curwin->w_botline is valid. */ -void validate_botline(void) { +void validate_botline(void) +{ if (!(curwin->w_valid & VALID_BOTLINE)) comp_botline(curwin); } @@ -457,7 +466,8 @@ static void validate_botline_win(win_T *wp) /* * Mark curwin->w_botline as invalid (because of some change in the buffer). */ -void invalidate_botline(void) { +void invalidate_botline(void) +{ curwin->w_valid &= ~(VALID_BOTLINE|VALID_BOTLINE_AP); } @@ -474,7 +484,8 @@ void approximate_botline_win(win_T *wp) /* * Return TRUE if curwin->w_wrow and curwin->w_wcol are valid. */ -int cursor_valid(void) { +int cursor_valid(void) +{ check_cursor_moved(curwin); return (curwin->w_valid & (VALID_WROW|VALID_WCOL)) == (VALID_WROW|VALID_WCOL); @@ -484,7 +495,8 @@ int cursor_valid(void) { * Validate cursor position. Makes sure w_wrow and w_wcol are valid. * w_topline must be valid, you may need to call update_topline() first! */ -void validate_cursor(void) { +void validate_cursor(void) +{ check_cursor_moved(curwin); if ((curwin->w_valid & (VALID_WCOL|VALID_WROW)) != (VALID_WCOL|VALID_WROW)) curs_columns(TRUE); @@ -538,7 +550,7 @@ curs_rows ( if (lnum > wp->w_cursor.lnum) break; wp->w_cline_row += wp->w_lines[i].wl_size; - } else { + } else { fold_count = foldedCount(wp, lnum, NULL); if (fold_count) { lnum += fold_count; @@ -567,12 +579,12 @@ curs_rows ( wp->w_cline_height = plines_win(wp, wp->w_cursor.lnum, TRUE); wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum, NULL, NULL, TRUE, NULL); - } else if (i > wp->w_lines_valid) { + } else if (i > wp->w_lines_valid) { /* a line that is too long to fit on the last screen line */ wp->w_cline_height = 0; wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum, NULL, NULL, TRUE, NULL); - } else { + } else { wp->w_cline_height = wp->w_lines[i].wl_size; wp->w_cline_folded = wp->w_lines[i].wl_folded; } @@ -588,7 +600,8 @@ curs_rows ( /* * Validate curwin->w_virtcol only. */ -void validate_virtcol(void) { +void validate_virtcol(void) +{ validate_virtcol_win(curwin); } @@ -611,7 +624,8 @@ void validate_virtcol_win(win_T *wp) /* * Validate curwin->w_cline_height only. */ -static void validate_cheight(void) { +static void validate_cheight(void) +{ check_cursor_moved(curwin); if (!(curwin->w_valid & VALID_CHEIGHT)) { if (curwin->w_cursor.lnum == curwin->w_topline) @@ -627,7 +641,8 @@ static void validate_cheight(void) { /* * Validate w_wcol and w_virtcol only. */ -void validate_cursor_col(void) { +void validate_cursor_col(void) +{ colnr_T off; colnr_T col; int width; @@ -667,7 +682,8 @@ int win_col_off(win_T *wp) ; } -int curwin_col_off(void) { +int curwin_col_off(void) +{ return win_col_off(curwin); } @@ -683,7 +699,8 @@ int win_col_off2(win_T *wp) return 0; } -int curwin_col_off2(void) { +int curwin_col_off2(void) +{ return win_col_off2(curwin); } @@ -869,7 +886,7 @@ curs_columns ( if (n > p_lines - curwin->w_height + 1) n = p_lines - curwin->w_height + 1; curwin->w_skipcol = n * width; - } else if (extra == 1) { + } else if (extra == 1) { /* less then 'scrolloff' lines above, decrease skipcol */ extra = (curwin->w_skipcol + p_so * width - curwin->w_virtcol + width - 1) / width; @@ -878,7 +895,7 @@ curs_columns ( extra = curwin->w_skipcol / width; curwin->w_skipcol -= extra * width; } - } else if (extra == 2) { + } else if (extra == 2) { /* less then 'scrolloff' lines below, increase skipcol */ endcol = (n - curwin->w_height + 1) * width; while (endcol > curwin->w_virtcol) @@ -942,7 +959,7 @@ scrolldown ( && curwin->w_topfill < curwin->w_height - 1) { ++curwin->w_topfill; ++done; - } else { + } else { if (curwin->w_topline == 1) break; --curwin->w_topline; @@ -1033,7 +1050,7 @@ scrollup ( /* approximate w_botline */ curwin->w_botline += lnum - curwin->w_topline; curwin->w_topline = lnum; - } else { + } else { curwin->w_topline += line_count; curwin->w_botline += line_count; /* approximate w_botline */ } @@ -1075,7 +1092,7 @@ check_topfill ( if (down && wp->w_topline > 1) { --wp->w_topline; wp->w_topfill = 0; - } else { + } else { wp->w_topfill = wp->w_height - n; if (wp->w_topfill < 0) wp->w_topfill = 0; @@ -1088,7 +1105,8 @@ check_topfill ( * Use as many filler lines as possible for w_topline. Make sure w_topline * is still visible. */ -static void max_topfill(void) { +static void max_topfill(void) +{ int n; n = plines_nofill(curwin->w_topline); @@ -1105,7 +1123,8 @@ static void max_topfill(void) { * Scroll the screen one line down, but don't do it if it would move the * cursor off the screen. */ -void scrolldown_clamp(void) { +void scrolldown_clamp(void) +{ int end_row; int can_fill = (curwin->w_topfill < diff_check_fill(curwin, curwin->w_topline)); @@ -1139,7 +1158,7 @@ void scrolldown_clamp(void) { if (can_fill) { ++curwin->w_topfill; check_topfill(curwin, TRUE); - } else { + } else { --curwin->w_topline; curwin->w_topfill = 0; } @@ -1153,7 +1172,8 @@ void scrolldown_clamp(void) { * Scroll the screen one line up, but don't do it if it would move the cursor * off the screen. */ -void scrollup_clamp(void) { +void scrollup_clamp(void) +{ int start_row; if (curwin->w_topline == curbuf->b_ml.ml_line_count @@ -1200,7 +1220,7 @@ static void topline_back(lineoff_T *lp) /* Add a filler line. */ ++lp->fill; lp->height = 1; - } else { + } else { --lp->lnum; lp->fill = 0; if (lp->lnum < 1) @@ -1226,7 +1246,7 @@ static void botline_forw(lineoff_T *lp) /* Add a filler line. */ ++lp->fill; lp->height = 1; - } else { + } else { ++lp->lnum; lp->fill = 0; if (lp->lnum > curbuf->b_ml.ml_line_count) @@ -1302,7 +1322,7 @@ void scroll_cursor_top(int min_scroll, int always) if (hasFolding(curwin->w_cursor.lnum, &top, &bot)) { --top; ++bot; - } else { + } else { top = curwin->w_cursor.lnum - 1; bot = curwin->w_cursor.lnum + 1; } @@ -1608,7 +1628,7 @@ void scroll_cursor_halfway(int atend) if (used > curwin->w_height) break; below += boff.height; - } else { + } else { ++below; /* count a "~" line */ if (atend) ++used; @@ -1642,7 +1662,8 @@ void scroll_cursor_halfway(int atend) * If not possible, put it at the same position as scroll_cursor_halfway(). * When called topline must be valid! */ -void cursor_correct(void) { +void cursor_correct(void) +{ int above = 0; /* screen lines above topline */ linenr_T topline; int below = 0; /* screen lines below botline */ @@ -1788,12 +1809,12 @@ int onepage(int dir, long count) if (curwin->w_topline > curbuf->b_ml.ml_line_count) curwin->w_topline = curbuf->b_ml.ml_line_count; curwin->w_cursor.lnum = curwin->w_topline; - } else if (curwin->w_botline > curbuf->b_ml.ml_line_count) { + } else if (curwin->w_botline > curbuf->b_ml.ml_line_count) { /* at end of file */ curwin->w_topline = curbuf->b_ml.ml_line_count; curwin->w_topfill = 0; curwin->w_valid &= ~(VALID_WROW|VALID_CROW); - } else { + } else { /* For the overlap, start with the line just below the window * and go upwards. */ loff.lnum = curwin->w_botline; @@ -1807,7 +1828,7 @@ int onepage(int dir, long count) curwin->w_valid &= ~(VALID_WCOL|VALID_CHEIGHT|VALID_WROW| VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP); } - } else { /* dir == BACKWARDS */ + } else { /* dir == BACKWARDS */ if (curwin->w_topline == 1) { /* Include max number of filler lines */ max_topfill(); @@ -1838,7 +1859,7 @@ int onepage(int dir, long count) if (loff.lnum >= curbuf->b_ml.ml_line_count) { loff.lnum = curbuf->b_ml.ml_line_count; loff.fill = 0; - } else { + } else { botline_topline(&loff); } curwin->w_cursor.lnum = loff.lnum; @@ -1857,7 +1878,7 @@ int onepage(int dir, long count) curwin->w_topline = 1; max_topfill(); curwin->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE); - } else { + } else { /* Go two lines forward again. */ topline_botline(&loff); botline_forw(&loff); @@ -1886,7 +1907,7 @@ int onepage(int dir, long count) curwin->w_cursor.lnum = curwin->w_botline - 1; curwin->w_valid &= ~(VALID_WCOL|VALID_CHEIGHT| VALID_WROW|VALID_CROW); - } else { + } else { curwin->w_topline = loff.lnum; curwin->w_topfill = loff.fill; check_topfill(curwin, FALSE); @@ -2010,7 +2031,7 @@ void halfpage(int flag, linenr_T Prenum) if (--n < 0 && scrolled > 0) break; --curwin->w_topfill; - } else { + } else { i = plines_nofill(curwin->w_topline); n -= i; if (n < 0 && scrolled > 0) @@ -2078,7 +2099,7 @@ void halfpage(int flag, linenr_T Prenum) ++curwin->w_cursor.lnum; } #endif - } else { + } else { /* * scroll the text down */ @@ -2088,7 +2109,7 @@ void halfpage(int flag, linenr_T Prenum) if (--n < 0 && scrolled > 0) break; ++curwin->w_topfill; - } else { + } else { i = plines_nofill(curwin->w_topline - 1); n -= i; if (n < 0 && scrolled > 0) @@ -2114,7 +2135,7 @@ void halfpage(int flag, linenr_T Prenum) if (n > 0) { if (curwin->w_cursor.lnum <= (linenr_T)n) curwin->w_cursor.lnum = 1; - else if (hasAnyFolding(curwin)) { + else if (hasAnyFolding(curwin)) { while (--n >= 0 && curwin->w_cursor.lnum > 1) { --curwin->w_cursor.lnum; (void)hasFolding(curwin->w_cursor.lnum, @@ -2144,7 +2165,8 @@ void halfpage(int flag, linenr_T Prenum) redraw_later(VALID); } -void do_check_cursorbind(void) { +void do_check_cursorbind(void) +{ linenr_T line = curwin->w_cursor.lnum; colnr_T col = curwin->w_cursor.col; colnr_T coladd = curwin->w_cursor.coladd; diff --git a/src/normal.c b/src/normal.c index 40b7834079..771f8b7322 100644 --- a/src/normal.c +++ b/src/normal.c @@ -437,7 +437,8 @@ static int nv_compare(const void *s1, const void *s2) /* * Initialize the nv_cmd_idx[] table. */ -void init_normal_cmds(void) { +void init_normal_cmds(void) +{ int i; /* Fill the index table with a one to one relation. */ @@ -672,7 +673,7 @@ getcount: * the same when coming back here after handling K_CURSORHOLD. */ oap->prev_opcount = ca.opcount; oap->prev_count0 = ca.count0; - } else if (ca.opcount != 0) { + } else if (ca.opcount != 0) { /* * If we're in the middle of an operator (including after entering a * yank buffer with '"') AND we had a count before the operator, then @@ -823,7 +824,7 @@ getcount: repl = TRUE; /* get it in replace mode */ } else cp = NULL; /* no third character needed */ - } else { + } else { if (ca.cmdchar == 'r') /* get it in replace mode */ repl = TRUE; cp = &ca.nchar; @@ -1211,7 +1212,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) else if (oap->motion_type == MCHAR) oap->inclusive = !oap->inclusive; oap->motion_type = MCHAR; - } else if (oap->motion_force == Ctrl_V) { + } else if (oap->motion_force == Ctrl_V) { /* Change line- or characterwise motion into Visual block mode. */ VIsual_active = TRUE; VIsual = oap->start; @@ -1247,7 +1248,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) if (vim_strchr(p_cpo, CPO_REDO) == NULL) AppendToRedobuffLit(cap->searchbuf, -1); AppendToRedobuff(NL_STR); - } else if (cap->cmdchar == ':') { + } else if (cap->cmdchar == ':') { /* do_cmdline() has stored the first typed line in * "repeat_cmdline". When several lines are typed repeating * won't be possible. */ @@ -1278,7 +1279,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) curwin->w_virtcol + redo_VIsual_vcol - 1; } else curwin->w_curswant = redo_VIsual_vcol; - } else { + } else { curwin->w_curswant = MAXCOL; } coladvance(curwin->w_curswant); @@ -1288,7 +1289,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) cap->count1 = redo_VIsual_count; else cap->count1 = 1; - } else if (VIsual_active) { + } else if (VIsual_active) { if (!gui_yank) { /* Save the current VIsual area for '< and '> marks, and "gv" */ curbuf->b_visual.vi_start = VIsual; @@ -1309,7 +1310,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) VIsual.col = 0; curwin->w_cursor.col = (colnr_T)STRLEN(ml_get(curwin->w_cursor.lnum)); - } else { + } else { curwin->w_cursor.col = 0; VIsual.col = (colnr_T)STRLEN(ml_get(VIsual.lnum)); } @@ -1347,7 +1348,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) * previous position w_virtcol becomes invalid and isn't updated * automatically. */ curwin->w_valid &= ~VALID_VIRTCOL; - } else { + } else { /* Include folded lines completely. */ if (!VIsual_active && oap->motion_type == MLINE) { if (hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, @@ -1495,7 +1496,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) oap->end.col = 0; oap->end.coladd = 0; ++oap->line_count; - } else { + } else { /* Cannot move below the last line, make the op * inclusive to tell the operation to include the * line break. */ @@ -1622,7 +1623,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) if (empty_region_error) { vim_beep(); CancelRedo(); - } else { + } else { (void)op_delete(oap); if (oap->motion_type == MLINE && has_format_option(FO_AUTO)) u_save_cursor(); /* cursor line wasn't saved yet */ @@ -1646,7 +1647,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) if (empty_region_error) { vim_beep(); CancelRedo(); - } else { + } else { /* This is a new edit command, not a restart. Need to * remember it to make 'insertmode' work with mappings for * Visual mode. But do this only once and not when typed and @@ -1726,7 +1727,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) if (empty_region_error) { vim_beep(); CancelRedo(); - } else { + } else { /* This is a new edit command, not a restart. Need to * remember it to make 'insertmode' work with mappings for * Visual mode. But do this only once. */ @@ -1789,7 +1790,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) && (oap->op_type == OP_LSHIFT || oap->op_type == OP_RSHIFT || oap->op_type == OP_DELETE)) coladvance(curwin->w_curswant = old_col); - } else { + } else { curwin->w_cursor = old_cursor; } oap->block_mode = FALSE; @@ -1831,7 +1832,7 @@ static void op_colon(oparg_T *oap) if (oap->op_type == OP_INDENT) { stuffReadbuff(get_equalprg()); stuffReadbuff((char_u *)"\n"); - } else if (oap->op_type == OP_FORMAT) { + } else if (oap->op_type == OP_FORMAT) { if (*p_fp == NUL) stuffReadbuff((char_u *)"fmt"); else @@ -2082,7 +2083,7 @@ do_mouse ( if (VIsual_select) { stuffcharReadbuff(Ctrl_G); stuffReadbuff((char_u *)"\"+p"); - } else { + } else { stuffcharReadbuff('y'); stuffcharReadbuff(K_MIDDLEMOUSE); } @@ -2149,7 +2150,7 @@ do_mouse ( end_visual_mode(); tabpage_new(); tabpage_move(c1 == 0 ? 9999 : c1 - 1); - } else { + } else { /* Go to specified tab page, or next one if not clicking * on a label. */ goto_tabpage(c1); @@ -2158,7 +2159,7 @@ do_mouse ( if (curwin != old_curwin) end_visual_mode(); } - } else if (c1 < 0) { + } else if (c1 < 0) { tabpage_T *tp; /* Close the current or specified tab page. */ @@ -2174,7 +2175,7 @@ do_mouse ( } } return TRUE; - } else if (is_drag && in_tab_line) { + } else if (is_drag && in_tab_line) { c1 = TabPageIdxs[mouse_col]; tabpage_move(c1 <= 0 ? 9999 : c1 - 1); return FALSE; @@ -2229,7 +2230,7 @@ do_mouse ( && (lt(m_pos, VIsual) || lt(curwin->w_cursor, m_pos)))) { jump_flags = MOUSE_MAY_STOP_VIS; - } else if (VIsual_mode == Ctrl_V) { + } else if (VIsual_mode == Ctrl_V) { getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol); getvcol(curwin, &m_pos, NULL, &m_pos.col, NULL); @@ -2273,7 +2274,7 @@ do_mouse ( jump_flags |= MOUSE_MAY_STOP_VIS; } else if (mouse_has(MOUSE_VISUAL)) jump_flags |= MOUSE_MAY_VIS; - } else if (which_button == MOUSE_RIGHT) { + } else if (which_button == MOUSE_RIGHT) { if (is_click && VIsual_active) { /* * Remember the start and end of visual before moving the @@ -2282,7 +2283,7 @@ do_mouse ( if (lt(curwin->w_cursor, VIsual)) { start_visual = curwin->w_cursor; end_visual = VIsual; - } else { + } else { start_visual = VIsual; end_visual = curwin->w_cursor; } @@ -2379,7 +2380,7 @@ do_mouse ( coladvance(end_visual.col); VIsual = curwin->w_cursor; curwin->w_cursor = start_visual; /* restore the cursor */ - } else { + } else { /* * If the click is before the start of visual, change the start. * If the click is after the end of visual, change the end. If @@ -2437,7 +2438,7 @@ do_mouse ( if (fixindent) { c1 = (dir == BACKWARD) ? '[' : ']'; c2 = 'p'; - } else { + } else { c1 = (dir == FORWARD) ? 'p' : 'P'; c2 = NUL; } @@ -2495,7 +2496,7 @@ do_mouse ( } /* Handle double clicks, unless on status line */ else if (in_status_line) { - } else if (in_sep_line) { + } else if (in_sep_line) { } else if ((mod_mask & MOD_MASK_MULTI_CLICK) && (State & (NORMAL | INSERT)) && mouse_has(MOUSE_VISUAL)) { if (is_click || !VIsual_active) { @@ -2561,7 +2562,7 @@ do_mouse ( if (lt(curwin->w_cursor, orig_cursor)) { find_start_of_word(&curwin->w_cursor); find_end_of_word(&VIsual); - } else { + } else { find_start_of_word(&VIsual); if (*p_sel == 'e' && *ml_get_cursor() != NUL) curwin->w_cursor.col += @@ -2573,7 +2574,7 @@ do_mouse ( } if (is_click) redraw_curbuf_later(INVERTED); /* update the inversion */ - } else if (VIsual_active && !old_active) { + } else if (VIsual_active && !old_active) { if (mod_mask & MOD_MASK_ALT) VIsual_mode = Ctrl_V; else @@ -2673,7 +2674,8 @@ static int get_mouse_class(char_u *p) * Check if highlighting for visual mode is possible, give a warning message * if not. */ -void check_visual_highlight(void) { +void check_visual_highlight(void) +{ static int did_check = FALSE; if (full_screen) { @@ -2688,7 +2690,8 @@ void check_visual_highlight(void) { * This function should ALWAYS be called to end Visual mode, except from * do_pending_operator(). */ -void end_visual_mode(void) { +void end_visual_mode(void) +{ VIsual_active = FALSE; setmouse(); @@ -2714,7 +2717,8 @@ void end_visual_mode(void) { /* * Reset VIsual_active and VIsual_reselect. */ -void reset_VIsual_and_resel(void) { +void reset_VIsual_and_resel(void) +{ if (VIsual_active) { end_visual_mode(); redraw_curbuf_later(INVERTED); /* delete the inversion later */ @@ -2725,7 +2729,8 @@ void reset_VIsual_and_resel(void) { /* * Reset VIsual_active and VIsual_reselect if it's set. */ -void reset_VIsual(void) { +void reset_VIsual(void) +{ if (VIsual_active) { end_visual_mode(); redraw_curbuf_later(INVERTED); /* delete the inversion later */ @@ -2821,7 +2826,7 @@ int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **strin this_class = 2; if (!(find_type & FIND_STRING) || this_class == 2) break; - } else { + } else { while (col > 0 && ((i == 0 ? vim_iswordc(ptr[col - 1]) @@ -2980,7 +2985,8 @@ static int showcmd_visual = FALSE; static void display_showcmd(void); -void clear_showcmd(void) { +void clear_showcmd(void) +{ if (!p_sc) return; @@ -2994,7 +3000,7 @@ void clear_showcmd(void) { if (cursor_bot) { top = VIsual.lnum; bot = curwin->w_cursor.lnum; - } else { + } else { top = curwin->w_cursor.lnum; bot = VIsual.lnum; } @@ -3023,7 +3029,7 @@ void clear_showcmd(void) { if (cursor_bot) { s = ml_get_pos(&VIsual); e = ml_get_cursor(); - } else { + } else { s = ml_get_cursor(); e = ml_get_pos(&VIsual); } @@ -3045,7 +3051,7 @@ void clear_showcmd(void) { } showcmd_buf[SHOWCMD_COLS] = NUL; /* truncate */ showcmd_visual = TRUE; - } else { + } else { showcmd_buf[0] = NUL; showcmd_visual = FALSE; @@ -3142,12 +3148,14 @@ static void del_from_showcmd(int len) * push_showcmd() and pop_showcmd() are used when waiting for the user to type * something and there is a partial mapping. */ -void push_showcmd(void) { +void push_showcmd(void) +{ if (p_sc) STRCPY(old_showcmd_buf, showcmd_buf); } -void pop_showcmd(void) { +void pop_showcmd(void) +{ if (!p_sc) return; @@ -3156,7 +3164,8 @@ void pop_showcmd(void) { display_showcmd(); } -static void display_showcmd(void) { +static void display_showcmd(void) +{ int len; cursor_off(); @@ -3211,7 +3220,7 @@ void do_check_scrollbind(int check) check_scrollbind(curwin->w_topline - old_topline, (long)(curwin->w_leftcol - old_leftcol)); } - } else if (vim_strchr(p_sbo, 'j')) { /* jump flag set in 'scrollopt' */ + } else if (vim_strchr(p_sbo, 'j')) { /* jump flag set in 'scrollopt' */ /* * When switching between windows, make sure that the relative * vertical offset is valid for the new window. The relative @@ -3272,7 +3281,7 @@ void check_scrollbind(linenr_T topline_diff, long leftcol_diff) if (want_ver) { if (old_curwin->w_p_diff && curwin->w_p_diff) { diff_set_topline(old_curwin, curwin); - } else { + } else { curwin->w_scbind_pos += topline_diff; topline = curwin->w_scbind_pos; if (topline > curbuf->b_ml.ml_line_count) @@ -3441,7 +3450,7 @@ find_decl ( setpcmark(); /* Set in findpar() otherwise */ curwin->w_cursor.lnum = 1; par_pos = curwin->w_cursor; - } else { + } else { par_pos = curwin->w_cursor; while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != NUL) --curwin->w_cursor.lnum; @@ -3499,7 +3508,7 @@ find_decl ( if (t == FAIL) { retval = FAIL; curwin->w_cursor = old_pos; - } else { + } else { curwin->w_set_curswant = TRUE; /* "n" searches forward now */ reset_search_dir(); @@ -3555,7 +3564,7 @@ static int nv_screengo(oparg_T *oap, int dir, long dist) - curwin->w_curswant - 1) / width2 + 1) * width2; } - } else { + } else { if (linelen > width1) n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; else @@ -3587,7 +3596,7 @@ static int nv_screengo(oparg_T *oap, int dir, long dist) curwin->w_curswant += (((linelen - width1 - 1) / width2) + 1) * width2; } - } else { /* dir == FORWARD */ + } else { /* dir == FORWARD */ if (linelen > width1) n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; else @@ -3662,7 +3671,7 @@ static void nv_mousescroll(cmdarg_T *cap) if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN) { if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) { (void)onepage(cap->arg ? FORWARD : BACKWARD, 1L); - } else { + } else { cap->count1 = 3; cap->count0 = 3; nv_scroll_line(cap); @@ -3723,7 +3732,7 @@ void scroll_redraw(int up, long count) if (curwin->w_cursor.lnum > prev_lnum || cursor_down(1L, FALSE) == FAIL) break; - } else { + } else { if (curwin->w_cursor.lnum < prev_lnum || prev_topline == 1L || cursor_up(1L, FALSE) == FAIL) @@ -3783,7 +3792,7 @@ static void nv_zet(cmdarg_T *cap) || nchar == K_RIGHT) { cap->count1 = n ? n * cap->count1 : cap->count1; goto dozet; - } else { + } else { clearopbeep(cap->oap); break; } @@ -4195,7 +4204,7 @@ static void nv_colon(cmdarg_T *cap) /* Using ":" as a movement is characterwise exclusive. */ cap->oap->motion_type = MCHAR; cap->oap->inclusive = FALSE; - } else if (cap->count0) { + } else if (cap->count0) { /* translate "count:" into ":.,.+(count - 1)" */ stuffcharReadbuff('.'); if (cap->count0 > 1) { @@ -4284,7 +4293,7 @@ static void nv_ctrlo(cmdarg_T *cap) VIsual_select = FALSE; showmode(); restart_VIsual_select = 2; /* restart Select mode later */ - } else { + } else { cap->count1 = -cap->count1; nv_pcmark(cap); } @@ -4363,7 +4372,7 @@ static void nv_ident(cmdarg_T *cap) if (cap->cmdchar == 'g') { /* "g*", "g#", "g]" and "gCTRL-]" */ cmdchar = cap->nchar; g_cmd = TRUE; - } else { + } else { cmdchar = cap->cmdchar; g_cmd = FALSE; } @@ -4493,7 +4502,7 @@ static void nv_ident(cmdarg_T *cap) buf = newbuf; STRCAT(buf, p); vim_free(p); - } else { + } else { if (cmdchar == '*') aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\"); else if (cmdchar == '#') @@ -4565,11 +4574,11 @@ get_visual_text ( if (VIsual_mode == 'V') { *pp = ml_get_curline(); *lenp = (int)STRLEN(*pp); - } else { + } else { if (lt(curwin->w_cursor, VIsual)) { *pp = ml_get_pos(&curwin->w_cursor); *lenp = VIsual.col - curwin->w_cursor.col + 1; - } else { + } else { *pp = ml_get_pos(&VIsual); *lenp = curwin->w_cursor.col - VIsual.col + 1; } @@ -4620,7 +4629,7 @@ static void nv_scroll(cmdarg_T *cap) } else curwin->w_cursor.lnum -= cap->count1 - 1; } - } else { + } else { if (cap->cmdchar == 'M') { /* Don't count filler lines above the window. */ used -= diff_check_fill(curwin, curwin->w_topline) @@ -4643,7 +4652,7 @@ static void nv_scroll(cmdarg_T *cap) } if (n > 0 && used > curwin->w_height) --n; - } else { /* (cap->cmdchar == 'H') */ + } else { /* (cap->cmdchar == 'H') */ n = cap->count1 - 1; if (hasAnyFolding(curwin)) { /* Count a fold for one screen line. */ @@ -4727,12 +4736,12 @@ static void nv_right(cmdarg_T *cap) /* Only beep and flush if not moved at all */ if (n == cap->count1) beep_flush(); - } else { + } else { if (!lineempty(curwin->w_cursor.lnum)) cap->oap->inclusive = TRUE; } break; - } else if (PAST_LINE) { + } else if (PAST_LINE) { curwin->w_set_curswant = TRUE; if (virtual_active()) oneright(); @@ -4821,7 +4830,7 @@ static void nv_up(cmdarg_T *cap) /* <S-Up> is page up */ cap->arg = BACKWARD; nv_page(cap); - } else { + } else { cap->oap->motion_type = MLINE; if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) clearopbeep(cap->oap); @@ -5113,7 +5122,7 @@ static void nv_brackets(cmdarg_T *cap) else findc = '}'; n = 9999; - } else { + } else { findc = cap->nchar; n = cap->count1; } @@ -5324,7 +5333,7 @@ static void nv_percent(cmdarg_T *cap) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; beginline(BL_SOL | BL_FIX); } - } else { /* "%" : go to matching paren */ + } else { /* "%" : go to matching paren */ cap->oap->motion_type = MCHAR; cap->oap->use_reg_one = TRUE; if ((pos = findmatch(cap->oap, NUL)) == NULL) @@ -5521,7 +5530,7 @@ static void nv_replace(cmdarg_T *cap) /* Give 'r' to edit(), to get the redo command right. */ invoke_edit(cap, TRUE, 'r', FALSE); - } else { + } else { prep_redo(cap->oap->regname, cap->count1, NUL, 'r', NUL, had_ctrl_v, cap->nchar); @@ -5555,7 +5564,7 @@ static void nv_replace(cmdarg_T *cap) if (cap->ncharC2 != 0) ins_char(cap->ncharC2); } - } else { + } else { /* * Replace the characters within one line. */ @@ -5630,7 +5639,7 @@ static void v_swap_corners(int cmdchar) coladvance(left); curwin->w_curswant = left; } - } else { + } else { old_cursor = curwin->w_cursor; curwin->w_cursor = VIsual; VIsual = old_cursor; @@ -5649,7 +5658,7 @@ static void nv_Replace(cmdarg_T *cap) VIsual_mode_orig = VIsual_mode; /* remember original area for gv */ VIsual_mode = 'V'; nv_operator(cap); - } else if (!checkclearopq(cap->oap)) { + } else if (!checkclearopq(cap->oap)) { if (!curbuf->b_p_ma) EMSG(_(e_modifiable)); else { @@ -5669,7 +5678,7 @@ static void nv_vreplace(cmdarg_T *cap) cap->cmdchar = 'r'; cap->nchar = cap->extra_char; nv_replace(cap); /* Do same as "r" in Visual mode for now */ - } else if (!checkclearopq(cap->oap)) { + } else if (!checkclearopq(cap->oap)) { if (!curbuf->b_p_ma) EMSG(_(e_modifiable)); else { @@ -5838,7 +5847,7 @@ static void nv_optrans(cmdarg_T *cap) finish_op = TRUE; ResetRedobuff(); AppendCharToRedobuff('D'); - } else { + } else { if (cap->count0) stuffnumReadbuff(cap->count0); stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]); @@ -5965,7 +5974,7 @@ static void nv_visual(cmdarg_T *cap) showmode(); } redraw_curbuf_later(INVERTED); /* update the inversion */ - } else { /* start Visual mode */ + } else { /* start Visual mode */ check_visual_highlight(); if (cap->count0 > 0 && resel_VIsual_mode != NUL) { /* use previously selected part */ @@ -6002,7 +6011,7 @@ static void nv_visual(cmdarg_T *cap) if (resel_VIsual_vcol == MAXCOL) { curwin->w_curswant = MAXCOL; coladvance((colnr_T)MAXCOL); - } else if (VIsual_mode == Ctrl_V) { + } else if (VIsual_mode == Ctrl_V) { validate_virtcol(); curwin->w_curswant = curwin->w_virtcol + resel_VIsual_vcol * cap->count0 - 1; @@ -6010,7 +6019,7 @@ static void nv_visual(cmdarg_T *cap) } else curwin->w_set_curswant = TRUE; redraw_curbuf_later(INVERTED); /* show the inversion */ - } else { + } else { if (!cap->arg) /* start Select mode when 'selectmode' contains "cmd" */ may_start_select('c'); @@ -6031,7 +6040,8 @@ static void nv_visual(cmdarg_T *cap) /* * Start selection for Shift-movement keys. */ -void start_selection(void) { +void start_selection(void) +{ /* if 'selectmode' contains "key", start Select mode */ may_start_select('k'); n_start_visual_mode('v'); @@ -6168,7 +6178,7 @@ static void nv_g_cmd(cmdarg_T *cap) curbuf->b_visual.vi_end = curwin->w_cursor; curwin->w_cursor = curbuf->b_visual.vi_start; curbuf->b_visual.vi_start = VIsual; - } else { + } else { VIsual_mode = curbuf->b_visual.vi_mode; curwin->w_curswant = curbuf->b_visual.vi_curswant; tpos = curbuf->b_visual.vi_end; @@ -6379,7 +6389,7 @@ static void nv_g_cmd(cmdarg_T *cap) } } else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == FAIL) clearopbeep(oap); - } else { + } else { i = curwin->w_leftcol + W_WIDTH(curwin) - col_off - 1; coladvance((colnr_T)i); @@ -6694,7 +6704,7 @@ static void nv_Undo(cmdarg_T *cap) cap->cmdchar = 'g'; cap->nchar = 'U'; nv_operator(cap); - } else if (!checkclearopq(cap->oap)) { + } else if (!checkclearopq(cap->oap)) { u_undoline(); curwin->w_set_curswant = TRUE; } @@ -6861,7 +6871,7 @@ static void nv_wordcmd(cmdarg_T *cap) cap->oap->motion_type = MCHAR; return; } - } else { + } else { /* * This is a little strange. To match what the real Vi does, * we effectively map 'cw' to 'ce', and 'cW' to 'cE', provided @@ -6960,7 +6970,8 @@ static void adjust_for_sel(cmdarg_T *cap) * Should check VIsual_mode before calling this. * Returns TRUE when backed up to the previous line. */ -static int unadjust_for_sel(void) { +static int unadjust_for_sel(void) +{ pos_T *pp; if (*p_sel == 'e' && !equalpos(VIsual, curwin->w_cursor)) { @@ -6970,10 +6981,10 @@ static int unadjust_for_sel(void) { pp = &VIsual; if (pp->coladd > 0) --pp->coladd; - else if (pp->col > 0) { + else if (pp->col > 0) { --pp->col; mb_adjustpos(curbuf, pp); - } else if (pp->lnum > 1) { + } else if (pp->lnum > 1) { --pp->lnum; pp->col = (colnr_T)STRLEN(ml_get(pp->lnum)); return TRUE; @@ -7116,11 +7127,11 @@ static void nv_edit(cmdarg_T *cap) || VIsual_active )) { nv_object(cap); - } else if (!curbuf->b_p_ma && !p_im) { + } else if (!curbuf->b_p_ma && !p_im) { /* Only give this error when 'insertmode' is off. */ EMSG(_(e_modifiable)); clearop(cap->oap); - } else if (!checkclearopq(cap->oap)) { + } else if (!checkclearopq(cap->oap)) { switch (cap->cmdchar) { case 'A': /* "A"ppend after the line */ curwin->w_set_curswant = TRUE; @@ -7282,7 +7293,7 @@ static void nv_record(cmdarg_T *cap) cap->cmdchar = 'g'; cap->nchar = 'q'; nv_operator(cap); - } else if (!checkclearop(cap->oap)) { + } else if (!checkclearop(cap->oap)) { if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') { stuffcharReadbuff(cap->nchar); stuffcharReadbuff(K_CMDWIN); @@ -7334,7 +7345,7 @@ static void nv_join(cmdarg_T *cap) { if (VIsual_active) /* join the visual lines */ nv_operator(cap); - else if (!checkclearop(cap->oap)) { + else if (!checkclearop(cap->oap)) { if (cap->count0 <= 1) cap->count0 = 2; /* default for join is two lines! */ if (curwin->w_cursor.lnum + cap->count0 - 1 > @@ -7367,7 +7378,7 @@ static void nv_put(cmdarg_T *cap) nv_diffgetput(TRUE); } else clearopbeep(cap->oap); - } else { + } else { dir = (cap->cmdchar == 'P' || (cap->cmdchar == 'g' && cap->nchar == 'P')) ? BACKWARD : FORWARD; @@ -234,7 +234,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount) if (oap->block_mode) { curwin->w_cursor.lnum = oap->start.lnum; curwin->w_cursor.col = block_col; - } else if (curs_top) { /* put cursor on first line, for ">>" */ + } else if (curs_top) { /* put cursor on first line, for ">>" */ curwin->w_cursor.lnum = oap->start.lnum; beginline(BL_SOL | BL_FIX); /* shift_line() may have set cursor.col */ } else @@ -250,7 +250,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount) sprintf((char *)IObuff, _("1 line %sed 1 time"), s); else sprintf((char *)IObuff, _("1 line %sed %d times"), s, amount); - } else { + } else { if (amount == 1) sprintf((char *)IObuff, _("%ld lines %sed 1 time"), oap->line_count, s); @@ -301,7 +301,7 @@ shift_line ( } else i += amount; count = i * p_sw; - } else { /* original vi indent */ + } else { /* original vi indent */ if (left) { count -= p_sw * amount; if (count < 0) @@ -388,7 +388,7 @@ static void shift_block(oparg_T *oap, int amount) copy_spaces(newp + bd.textcol + i, (size_t)j); /* the end */ mch_memmove(newp + bd.textcol + i + j, bd.textstart, (size_t)len); - } else { /* left */ + } else { /* left */ colnr_T destination_col; /* column to which text in block will be shifted */ char_u *verbatim_copy_end; /* end of the part of the line which is @@ -511,14 +511,14 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def if (spaces != 0) count = p_ts - 1; /* we're cutting a TAB */ offset = bdp->textcol; - } else { /* append */ + } else { /* append */ p_ts = bdp->end_char_vcols; if (!bdp->is_short) { /* spaces = padding after block */ spaces = (bdp->endspaces ? p_ts - bdp->endspaces : 0); if (spaces != 0) count = p_ts - 1; /* we're cutting a TAB */ offset = bdp->textcol + bdp->textlen - (spaces != 0); - } else { /* spaces = padding to block edge */ + } else { /* spaces = padding to block edge */ /* if $ used, just append to EOL (ie spaces==0) */ if (!bdp->is_MAX) spaces = (oap->end_vcol - bdp->end_vcol) + 1; @@ -657,7 +657,8 @@ static char_u *expr_line = NULL; * Get an expression for the "\"=expr1" or "CTRL-R =expr1" * Returns '=' when OK, NUL otherwise. */ -int get_expr_register(void) { +int get_expr_register(void) +{ char_u *new_line; new_line = getcmdline('=', 0L, 0); @@ -684,7 +685,8 @@ void set_expr_line(char_u *new_line) * Get the result of the '=' register expression. * Returns a pointer to allocated memory, or NULL for failure. */ -char_u *get_expr_line(void) { +char_u *get_expr_line(void) +{ char_u *expr_copy; char_u *rv; static int nested = 0; @@ -713,7 +715,8 @@ char_u *get_expr_line(void) { /* * Get the '=' register expression itself, without evaluating it. */ -char_u *get_expr_line_src(void) { +char_u *get_expr_line_src(void) +{ if (expr_line == NULL) return NULL; return vim_strsave(expr_line); @@ -869,7 +872,7 @@ int do_record(int c) regname = c; retval = OK; } - } else { /* stop recording */ + } else { /* stop recording */ /* * Get the recorded key hits. K_SPECIAL and CSI will be escaped, this * needs to be removed again to put it in a register. exec_reg then @@ -933,7 +936,7 @@ static int stuff_yank(int regname, char_u *p) vim_free(p); vim_free(*pp); *pp = lp; - } else { + } else { free_yank_all(); if ((y_current->y_array = (char_u **)alloc((unsigned)sizeof(char_u *))) == NULL) { @@ -1007,13 +1010,13 @@ do_execreg ( retval = put_in_typebuf(p, TRUE, TRUE, silent); } vim_free(p); - } else if (regname == '=') { + } else if (regname == '=') { p = get_expr_line(); if (p == NULL) return FAIL; retval = put_in_typebuf(p, TRUE, colon, silent); vim_free(p); - } else if (regname == '.') { /* use last inserted text */ + } else if (regname == '.') { /* use last inserted text */ p = get_last_insert_save(); if (p == NULL) { EMSG(_(e_noinstext)); @@ -1021,7 +1024,7 @@ do_execreg ( } retval = put_in_typebuf(p, FALSE, colon, silent); vim_free(p); - } else { + } else { get_yank_register(regname, FALSE); if (y_current->y_array == NULL) return FAIL; @@ -1071,7 +1074,7 @@ static void put_reedit_in_typebuf(int silent) buf[0] = 'g'; buf[1] = 'R'; buf[2] = NUL; - } else { + } else { buf[0] = restart_edit == 'I' ? 'i' : restart_edit; buf[1] = NUL; } @@ -1158,7 +1161,7 @@ insert_reg ( stuffescaped(arg, literally); if (allocated) vim_free(arg); - } else { /* name or number register */ + } else { /* name or number register */ get_yank_register(regname, FALSE); if (y_current->y_array == NULL) retval = FAIL; @@ -1517,7 +1520,7 @@ int op_delete(oparg_T *oap) changed_lines(curwin->w_cursor.lnum, curwin->w_cursor.col, oap->end.lnum + 1, 0L); oap->line_count = 0; /* no lines deleted */ - } else if (oap->motion_type == MLINE) { + } else if (oap->motion_type == MLINE) { if (oap->op_type == OP_CHANGE) { /* Delete the lines except the first one. Temporarily move the * cursor to the next line. Save the current line number, if the @@ -1541,12 +1544,12 @@ int op_delete(oparg_T *oap) /* leave cursor past last char in line */ if (oap->line_count > 1) u_clearline(); /* "U" command not possible after "2cc" */ - } else { + } else { del_lines(oap->line_count, TRUE); beginline(BL_WHITE | BL_FIX); u_clearline(); /* "U" command not possible after "dd" */ } - } else { + } else { if (virtual_op) { int endcol = 0; @@ -1619,12 +1622,12 @@ int op_delete(oparg_T *oap) && n > (int)STRLEN(ml_get(oap->end.lnum))) { /* Special case: gH<Del> deletes the last line. */ del_lines(1L, FALSE); - } else { + } else { (void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE && !oap->is_VIsual ); } - } else { /* delete characters between lines */ + } else { /* delete characters between lines */ pos_T curpos; int delete_last_line; @@ -1651,7 +1654,7 @@ int op_delete(oparg_T *oap) curwin->w_cursor = curpos; /* restore curwin->w_cursor */ if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; - } else { + } else { /* delete from start of line until op_end */ curwin->w_cursor.col = 0; (void)del_bytes((long)n, !virtual_op, oap->op_type == OP_DELETE @@ -1796,7 +1799,7 @@ int op_replace(oparg_T *oap, int c) /* copy the part after the changed part */ STRMOVE(newp + STRLEN(newp), oldp); } - } else { + } else { /* Replacing with \r or \n means splitting the line. */ after_p = alloc_check( (unsigned)(oldlen + 1 + n - STRLEN(newp))); @@ -1812,7 +1815,7 @@ int op_replace(oparg_T *oap, int c) vim_free(after_p); } } - } else { + } else { /* * MCHAR and MLINE motion replace. */ @@ -1839,7 +1842,7 @@ int op_replace(oparg_T *oap, int c) State = n; /* Backup to the replaced character. */ dec_cursor(); - } else { + } else { if (n == TAB) { int end_vcol = 0; @@ -1855,7 +1858,7 @@ int op_replace(oparg_T *oap, int c) } pchar(curwin->w_cursor, c); } - } else if (virtual_op && curwin->w_cursor.lnum == oap->end.lnum) { + } else if (virtual_op && curwin->w_cursor.lnum == oap->end.lnum) { int virtcols = oap->end.coladd; if (curwin->w_cursor.lnum == oap->start.lnum @@ -1919,7 +1922,7 @@ void op_tilde(oparg_T *oap) } if (did_change) changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L); - } else { /* not block mode */ + } else { /* not block mode */ if (oap->motion_type == MLINE) { oap->start.col = 0; pos.col = 0; @@ -2030,7 +2033,7 @@ int swapchar(int op_type, pos_T *pos) nc = ROT13(c, 'a'); else if (op_type != OP_LOWER) nc = MB_TOUPPER(c); - } else if (MB_ISUPPER(c)) { + } else if (MB_ISUPPER(c)) { if (op_type == OP_ROT13) nc = ROT13(c, 'A'); else if (op_type != OP_UPPER) @@ -2112,7 +2115,7 @@ void op_insert(oparg_T *oap, long count1) ins_char(' '); bd.textlen += bd.endspaces; } - } else { + } else { curwin->w_cursor = oap->end; check_cursor_col(); @@ -2320,7 +2323,8 @@ int op_change(oparg_T *oap) /* * set all the yank registers to empty (called from main()) */ -void init_yank(void) { +void init_yank(void) +{ int i; for (i = 0; i < NUM_REGISTERS; ++i) @@ -2328,7 +2332,8 @@ void init_yank(void) { } #if defined(EXITFREE) || defined(PROTO) -void clear_registers(void) { +void clear_registers(void) +{ int i; for (i = 0; i < NUM_REGISTERS; ++i) { @@ -2357,7 +2362,8 @@ static void free_yank(long n) } } -static void free_yank_all(void) { +static void free_yank_all(void) +{ free_yank(y_current->y_size); } @@ -2496,7 +2502,7 @@ int op_yank(oparg_T *oap, int deleting, int mess) bd.startspaces = oap->end.coladd - oap->start.coladd + oap->inclusive; endcol = startcol; - } else { + } else { bd.endspaces = oap->end.coladd + oap->inclusive; endcol -= oap->inclusive; @@ -2731,11 +2737,11 @@ do_put ( if (y_array == NULL) goto end; } - } else { + } else { y_size = 1; /* use fake one-line yank register */ y_array = &insert_string; } - } else { + } else { get_yank_register(regname, FALSE); y_type = y_current->y_type; @@ -2787,7 +2793,7 @@ do_put ( lnum = curbuf->b_ml.ml_line_count + 1; if (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL) goto end; - } else if (y_type == MLINE) { + } else if (y_type == MLINE) { lnum = curwin->w_cursor.lnum; /* Correct line number for closed fold. Don't move the cursor yet, * u_save() uses it. */ @@ -2980,7 +2986,7 @@ do_put ( curwin->w_cursor.col = len; } else curwin->w_cursor.lnum = lnum; - } else { + } else { /* * Character or Line mode */ @@ -2997,7 +3003,7 @@ do_put ( curwin->w_cursor.col += bytelen; curbuf->b_op_end.col += bytelen; } - } else { + } else { ++col; if (yanklen) { ++curwin->w_cursor.col; @@ -3051,7 +3057,7 @@ do_put ( if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND))) ++curwin->w_cursor.col; changed_bytes(lnum, col); - } else { + } else { /* * Insert at least one line. When y_type is MCHAR, break the first * line in two. @@ -3153,7 +3159,7 @@ error: /* ":put": put cursor on last inserted line */ curwin->w_cursor.lnum = lnum; beginline(BL_WHITE | BL_FIX); - } else if (flags & PUT_CURSEND) { + } else if (flags & PUT_CURSEND) { /* put cursor after inserted text */ if (y_type == MLINE) { if (lnum >= curbuf->b_ml.ml_line_count) @@ -3161,11 +3167,11 @@ error: else curwin->w_cursor.lnum = lnum + 1; curwin->w_cursor.col = 0; - } else { + } else { curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = col; } - } else if (y_type == MLINE) { + } else if (y_type == MLINE) { /* put cursor on first non-blank in first inserted line */ curwin->w_cursor.col = 0; if (dir == FORWARD) @@ -3195,7 +3201,8 @@ end: * When the cursor is on the NUL past the end of the line and it should not be * there move it left. */ -void adjust_cursor_eol(void) { +void adjust_cursor_eol(void) +{ if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL && (ve_flags & VE_ONEMORE) == 0 @@ -3216,7 +3223,8 @@ void adjust_cursor_eol(void) { /* * Return TRUE if lines starting with '#' should be left aligned. */ -int preprocs_left(void) { +int preprocs_left(void) +{ return (curbuf->b_p_si && !curbuf->b_p_cin) || (curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE) @@ -3555,7 +3563,7 @@ int do_join(long count, int insert_space, int save_undo, int use_formatoptions) mb_ptr_back(curr, cend); endcurr2 = (*mb_ptr2char)(cend); } - } else { + } else { endcurr1 = *(curr + currsize - 1); if (currsize > 1) endcurr2 = *(curr + currsize - 2); @@ -3900,7 +3908,7 @@ format_lines ( next_is_not_par = TRUE; next_leader_len = 0; next_leader_flags = NULL; - } else { + } else { next_is_not_par = fmt_check_par(curwin->w_cursor.lnum + 1 , &next_leader_len, &next_leader_flags, do_comments ); @@ -3919,7 +3927,7 @@ format_lines ( if (is_not_par) { if (line_count < 0) break; - } else { + } else { /* * For the first line of a paragraph, check indent of second line. * Don't do this for comments and empty lines. @@ -3933,16 +3941,16 @@ format_lines ( /* no comment found */ second_indent = get_indent_lnum(curwin->w_cursor.lnum + 1); - } else { + } else { second_indent = next_leader_len; do_comments_list = 1; } - } else if (do_number_indent) { + } else if (do_number_indent) { if (leader_len == 0 && next_leader_len == 0) { /* no comment found */ second_indent = get_number_indent(curwin->w_cursor.lnum); - } else { + } else { /* get_number_indent() is now "comment aware"... */ second_indent = get_number_indent(curwin->w_cursor.lnum); @@ -4015,7 +4023,7 @@ format_lines ( (void)del_bytes((long)next_leader_len, FALSE, FALSE); mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L, (long)-next_leader_len); - } else if (second_indent > 0) { /* the "leader" for FO_Q_SECOND */ + } else if (second_indent > 0) { /* the "leader" for FO_Q_SECOND */ char_u *p = ml_get_curline(); int indent = (int)(skipwhite(p) - p); @@ -4179,7 +4187,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, int i if (vim_iswhite(*pstart)) { bdp->pre_whitesp += incr; bdp->pre_whitesp_c++; - } else { + } else { bdp->pre_whitesp = 0; bdp->pre_whitesp_c = 0; } @@ -4192,7 +4200,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, int i bdp->is_short = TRUE; if (!is_del || oap->op_type == OP_APPEND) bdp->endspaces = oap->end_vcol - oap->start_vcol + 1; - } else { + } else { /* notice: this converts partly selected Multibyte characters to * spaces, too. */ bdp->startspaces = bdp->start_vcol - oap->start_vcol; @@ -4207,7 +4215,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, int i else if (oap->op_type == OP_APPEND) { bdp->startspaces += oap->end_vcol - oap->start_vcol + 1; bdp->endspaces = bdp->start_char_vcols - bdp->startspaces; - } else { + } else { bdp->startspaces = oap->end_vcol - oap->start_vcol + 1; if (is_del && oap->op_type != OP_LSHIFT) { /* just putting the sum of those two into @@ -4218,7 +4226,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, int i bdp->endspaces = bdp->end_vcol - oap->end_vcol - 1; } } - } else { + } else { prev_pend = pend; while (bdp->end_vcol <= oap->end_vcol && *pend != NUL) { /* Count a tab for what it's worth (if list mode not on) */ @@ -4240,7 +4248,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, int i + oap->inclusive; else bdp->endspaces = 0; /* replace doesn't add characters */ - } else if (bdp->end_vcol > oap->end_vcol) { + } else if (bdp->end_vcol > oap->end_vcol) { bdp->endspaces = bdp->end_vcol - oap->end_vcol - 1; if (!is_del && bdp->endspaces) { bdp->endspaces = incr - bdp->endspaces; @@ -4326,7 +4334,7 @@ int do_addsub(int command, linenr_T Prenum1) * Found hexadecimal number, move to its start. */ --col; - } else { + } else { /* * Search forward and then backward to find the start of number. */ @@ -4368,7 +4376,7 @@ int do_addsub(int command, linenr_T Prenum1) firstdigit = 'a'; } else firstdigit -= Prenum1; - } else { + } else { if (26 - CharOrd(firstdigit) - 1 < Prenum1) { if (isupper(firstdigit)) firstdigit = 'Z'; @@ -4380,7 +4388,7 @@ int do_addsub(int command, linenr_T Prenum1) curwin->w_cursor.col = col; (void)del_char(FALSE); ins_char(firstdigit); - } else { + } else { negative = FALSE; if (col > 0 && ptr[col - 1] == '-') { /* negative number */ --col; @@ -4417,7 +4425,7 @@ int do_addsub(int command, linenr_T Prenum1) n = 1 + (n ^ (unsigned long)-1); negative ^= TRUE; } - } else { /* add */ + } else { /* add */ if (n < oldn) { n = (n ^ (unsigned long)-1); negative ^= TRUE; @@ -4584,7 +4592,7 @@ int read_viminfo_register(vir_T *virp, int force) if (size == 0) { vim_free(array); y_current->y_array = NULL; - } else if (size < limit) { + } else if (size < limit) { y_current->y_array = (char_u **)alloc((unsigned)(size * sizeof(char_u *))); for (i = 0; i < size; i++) @@ -5035,7 +5043,8 @@ static long line_count_info(char_u *line, long *wc, long *cc, long limit, int eo * In Visual mode, give some info about the selected region. (In this case, * the *_count_cursor variables store running totals for the selection.) */ -void cursor_pos_info(void) { +void cursor_pos_info(void) +{ char_u *p; char_u buf1[50]; char_u buf2[40]; @@ -5058,7 +5067,7 @@ void cursor_pos_info(void) { */ if (curbuf->b_ml.ml_flags & ML_EMPTY) { MSG(_(no_lines_msg)); - } else { + } else { if (get_fileformat(curbuf) == EOL_DOS) eol_size = 2; else @@ -5068,7 +5077,7 @@ void cursor_pos_info(void) { if (lt(VIsual, curwin->w_cursor)) { min_pos = VIsual; max_pos = curwin->w_cursor; - } else { + } else { min_pos = curwin->w_cursor; max_pos = VIsual; } @@ -5146,7 +5155,7 @@ void cursor_pos_info(void) { && (long)STRLEN(s) < len) byte_count_cursor -= eol_size; } - } else { + } else { /* In non-visual mode, check for the line the cursor is on */ if (lnum == curwin->w_cursor.lnum) { word_count_cursor += word_count; @@ -5192,7 +5201,7 @@ void cursor_pos_info(void) { word_count_cursor, word_count, char_count_cursor, char_count, byte_count_cursor, byte_count); - } else { + } else { p = ml_get_curline(); validate_virtcol(); col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1, diff --git a/src/option.c b/src/option.c index 62d3761cc8..0067f4dbe3 100644 --- a/src/option.c +++ b/src/option.c @@ -1948,7 +1948,8 @@ static int check_opt_wim(void); * * Called only once from main(), just after creating the first buffer. */ -void set_init_1(void) { +void set_init_1(void) +{ char_u *p; int opt_idx; long_u n; @@ -2225,7 +2226,7 @@ void set_init_1(void) { } #endif - } else { + } else { vim_free(p_enc); p_enc = save_enc; } @@ -2278,7 +2279,7 @@ set_option_default ( *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *(long *)varp; } - } else { /* P_BOOL */ + } else { /* P_BOOL */ /* the cast to long is required for Manx C, long_i is needed for * MSVC */ *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; @@ -2360,7 +2361,8 @@ void set_number_default(char *name, long val) /* * Free all options. */ -void free_all_options(void) { +void free_all_options(void) +{ int i; for (i = 0; !istermoption(&options[i]); i++) { @@ -2384,7 +2386,8 @@ void free_all_options(void) { * Initialize the options, part two: After getting Rows and Columns and * setting 'term'. */ -void set_init_2(void) { +void set_init_2(void) +{ int idx; /* @@ -2436,7 +2439,8 @@ void set_init_2(void) { * values separated by semicolons; we want the last value in either * case. If this value is 0-6 or 8, our background is dark. */ -static char_u *term_bg_default(void) { +static char_u *term_bg_default(void) +{ char_u *p; if (STRCMP(T_NAME, "linux") == 0 @@ -2454,7 +2458,8 @@ static char_u *term_bg_default(void) { /* * Initialize the options, part three: After reading the .vimrc */ -void set_init_3(void) { +void set_init_3(void) +{ #if defined(UNIX) || defined(OS2) || defined(WIN3264) /* * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. @@ -2490,7 +2495,7 @@ void set_init_3(void) { if (*p == NUL) { /* No white space, use the tail. */ p = vim_strsave(gettail(p_sh)); - } else { + } else { char_u *p1, *p2; /* Find the last path separator before the space. */ @@ -2578,7 +2583,8 @@ void set_helplang_default(char_u *lang) * they can be reset. This reduces startup time when using X on a remote * machine. */ -void set_title_defaults(void) { +void set_title_defaults(void) +{ int idx1; long val; @@ -2663,22 +2669,22 @@ do_set ( ++arg; /* Only for :set command set global value of local options. */ set_options_default(OPT_FREE | opt_flags); - } else { + } else { showoptions(1, opt_flags); did_show = TRUE; } } else if (STRNCMP(arg, "termcap", - 7) == 0 && !(opt_flags & OPT_MODELINE)) { + 7) == 0 && !(opt_flags & OPT_MODELINE)) { showoptions(2, opt_flags); show_termcodes(); did_show = TRUE; arg += 7; - } else { + } else { prefix = 1; if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) { prefix = 0; arg += 2; - } else if (STRNCMP(arg, "inv", 3) == 0) { + } else if (STRNCMP(arg, "inv", 3) == 0) { prefix = 2; arg += 3; } @@ -2706,7 +2712,7 @@ do_set ( arg[len++] = '>'; /* restore '>' */ if (opt_idx == -1) key = find_key_option(arg + 1); - } else { + } else { len = 0; /* * The two characters after "t_" may not be alphanumeric. @@ -2738,10 +2744,10 @@ do_set ( if (arg[len] == '+') { adding = TRUE; /* "+=" */ ++len; - } else if (arg[len] == '^') { + } else if (arg[len] == '^') { prepending = TRUE; /* "^=" */ ++len; - } else if (arg[len] == '-') { + } else if (arg[len] == '-') { removing = TRUE; /* "-=" */ ++len; } @@ -2766,12 +2772,12 @@ do_set ( flags = options[opt_idx].flags; varp = get_varp_scope(&(options[opt_idx]), opt_flags); - } else { + } else { flags = P_STRING; if (key < 0) { key_name[0] = KEY2TERMCAP0(key); key_name[1] = KEY2TERMCAP1(key); - } else { + } else { key_name[0] = KS_KEY; key_name[1] = (key & 0xff); } @@ -2819,7 +2825,7 @@ do_set ( if (arg[3] == 'm') { /* "opt&vim": set to Vim default */ cp_val = FALSE; arg += 3; - } else { /* "opt&vi": set to Vi default */ + } else { /* "opt&vi": set to Vi default */ cp_val = TRUE; arg += 2; } @@ -2861,7 +2867,7 @@ do_set ( last_set_msg(curbuf->b_p_scriptID[ (int)options[opt_idx].indir & PV_MASK]); } - } else { + } else { char_u *p; p = find_termcode(key_name); @@ -2874,7 +2880,7 @@ do_set ( if (nextchar != '?' && nextchar != NUL && !vim_iswhite(afterchar)) errmsg = e_trailing; - } else { + } else { if (flags & P_BOOL) { /* boolean */ if (nextchar == '=' || nextchar == ':') { errmsg = e_invarg; @@ -2900,7 +2906,7 @@ do_set ( else value = *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); - } else { + } else { /* * ":set invopt": invert * ":set opt" or ":set noopt": set or reset @@ -2917,7 +2923,7 @@ do_set ( errmsg = set_bool_option(opt_idx, varp, (int)value, opt_flags); - } else { /* numeric or string */ + } else { /* numeric or string */ if (vim_strchr((char_u *)"=:&<", nextchar) == NULL || prefix != 1) { errmsg = e_invarg; @@ -2978,7 +2984,7 @@ do_set ( errmsg = e_invarg; goto skip; } - } else { + } else { errmsg = (char_u *)N_("E521: Number required after ="); goto skip; } @@ -2991,7 +2997,7 @@ do_set ( value = *(long *)varp - value; errmsg = set_num_option(opt_idx, varp, value, errbuf, sizeof(errbuf), opt_flags); - } else if (opt_idx >= 0) { /* string */ + } else if (opt_idx >= 0) { /* string */ char_u *save_arg = NULL; char_u *s = NULL; char_u *oldval; /* previous value if *varp */ @@ -3035,11 +3041,11 @@ do_set ( newval = vim_strsave(s); } new_value_alloced = TRUE; - } else if (nextchar == '<') { /* set to global val */ + } else if (nextchar == '<') { /* set to global val */ newval = vim_strsave(*(char_u **)get_varp_scope( &(options[opt_idx]), OPT_GLOBAL)); new_value_alloced = TRUE; - } else { + } else { ++arg; /* jump to after the '=' or ':' */ /* @@ -3225,7 +3231,7 @@ do_set ( mch_memmove(newval + i + comma, newval, STRLEN(newval) + 1); mch_memmove(newval, origval, (size_t)i); - } else { + } else { i = (int)STRLEN(newval); STRMOVE(newval + i + comma, origval); } @@ -3244,7 +3250,7 @@ do_set ( /* include comma after string */ if (s[i] == ',') ++i; - } else { + } else { /* include comma before string */ --s; ++i; @@ -3280,13 +3286,13 @@ do_set ( /* If error detected, print the error message. */ if (errmsg != NULL) goto skip; - } else { /* key code option */ + } else { /* key code option */ char_u *p; if (nextchar == '&') { if (add_termcap_entry(key_name, TRUE) == FAIL) errmsg = (char_u *)N_("E522: Not found in termcap"); - } else { + } else { ++arg; /* jump to after the '=' or ':' */ for (p = arg; *p && !vim_iswhite(*p); ++p) if (*p == '\\' && p[1] != NUL) @@ -3416,7 +3422,8 @@ static int string_to_key(char_u *arg) * Check value of 'cedit' and set cedit_key. * Returns NULL if value is OK, error message otherwise. */ -static char_u *check_cedit(void) { +static char_u *check_cedit(void) +{ int n; if (*p_cedit == NUL) @@ -3447,7 +3454,7 @@ did_set_title ( if (icon) { if (!p_icon) mch_restore_title(2); - } else { + } else { if (!p_title) mch_restore_title(1); } @@ -3497,7 +3504,7 @@ set_options_bin ( p_et = FALSE; p_bin = TRUE; /* needed when called for the "-b" argument */ } - } else if (oldval) { /* switched off */ + } else if (oldval) { /* switched off */ if (!(opt_flags & OPT_GLOBAL)) { curbuf->b_p_tw = curbuf->b_p_tw_nobin; curbuf->b_p_wm = curbuf->b_p_wm_nobin; @@ -3591,7 +3598,8 @@ static char_u *option_expand(int opt_idx, char_u *val) * After setting various option values: recompute variables that depend on * option values. */ -static void didset_options(void) { +static void didset_options(void) +{ /* initialize the table for 'iskeyword' et.al. */ (void)init_chartab(); @@ -3615,7 +3623,8 @@ static void didset_options(void) { /* * Check for string options that are NULL (normally only termcap options). */ -void check_options(void) { +void check_options(void) +{ int opt_idx; for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) @@ -4115,13 +4124,13 @@ did_set_string_option ( } } - } else if (varp == &p_penc) { + } else if (varp == &p_penc) { /* Canonize printencoding if VIM standard one */ p = enc_canonize(p_penc); if (p != NULL) { vim_free(p_penc); p_penc = p; - } else { + } else { /* Ensure lower case and '-' for '_' */ for (s = p_penc; *s != NUL; s++) { if (*s == '_') @@ -4130,7 +4139,7 @@ did_set_string_option ( *s = TOLOWER_ASC(*s); } } - } else if (varp == &curbuf->b_p_keymap) { + } else if (varp == &curbuf->b_p_keymap) { /* load or unload key mapping tables */ errmsg = keymap_init(); @@ -4140,7 +4149,7 @@ did_set_string_option ( curbuf->b_p_iminsert = B_IMODE_LMAP; if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) curbuf->b_p_imsearch = B_IMODE_LMAP; - } else { + } else { /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */ if (curbuf->b_p_iminsert == B_IMODE_LMAP) curbuf->b_p_iminsert = B_IMODE_NONE; @@ -4195,7 +4204,7 @@ did_set_string_option ( if (STRCMP(curbuf->b_p_key, oldval) != 0) /* Need to update the swapfile. */ ml_set_crypt_key(curbuf, oldval, get_crypt_method(curbuf)); - } else if (gvarp == &p_cm) { + } else if (gvarp == &p_cm) { if (opt_flags & OPT_LOCAL) p = curbuf->b_p_cm; else @@ -4262,7 +4271,7 @@ did_set_string_option ( if (*p == NUL) break; } - } else { + } else { /* Check for "x:y,x:y" */ for (p = *varp; *p != NUL; p += 4) { if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ',')) { @@ -4327,10 +4336,10 @@ did_set_string_option ( } if (*s == 'n') { /* name is always last one */ break; - } else if (*s == 'r') { /* skip until next ',' */ + } else if (*s == 'r') { /* skip until next ',' */ while (*++s && *s != ',') ; - } else if (*s == '%') { + } else if (*s == '%') { /* optional number */ while (vim_isdigit(*++s)) ; @@ -4589,7 +4598,7 @@ did_set_string_option ( ++s; ++s; } - } else { + } else { if (errbuf != NULL) { sprintf((char *)errbuf, _("E535: Illegal character after <%c>"), @@ -4693,7 +4702,7 @@ did_set_string_option ( validate_virtcol(); coladvance(curwin->w_virtcol); } - } else if (varp == &p_csqf) { + } else if (varp == &p_csqf) { if (p_csqf != NULL) { p = p_csqf; while (*p != NUL) { @@ -4754,7 +4763,7 @@ did_set_string_option ( (void)init_chartab(); if (varp == &p_hl) (void)highlight_changed(); - } else { + } else { /* Remember where the option was set. */ set_option_scriptID_idx(opt_idx, opt_flags, current_SID); /* @@ -4788,7 +4797,7 @@ did_set_string_option ( if (varp == &(curbuf->b_p_syn)) { apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname, TRUE, curbuf); - } else if (varp == &(curbuf->b_p_ft)) { + } else if (varp == &(curbuf->b_p_ft)) { /* 'filetype' is set, trigger the FileType autocommand */ did_filetype = TRUE; apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, @@ -4940,7 +4949,7 @@ static char_u *set_chars_option(char_u **varp) if (varp == &p_lcs) { tab = lcstab; entries = sizeof(lcstab) / sizeof(struct charstab); - } else { + } else { tab = filltab; entries = sizeof(filltab) / sizeof(struct charstab); } @@ -5175,7 +5184,7 @@ set_bool_option ( } curbuf = save_curbuf; } - } else if ((int *)varp == &curbuf->b_p_ro) { + } else if ((int *)varp == &curbuf->b_p_ro) { /* when 'readonly' is reset globally, also reset readonlymode */ if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) readonlymode = FALSE; @@ -5243,7 +5252,7 @@ set_bool_option ( if ((State & INSERT) == 0) need_start_insertmode = TRUE; stop_insert_mode = FALSE; - } else { + } else { need_start_insertmode = FALSE; stop_insert_mode = TRUE; if (restart_edit != 0 && mode_displayed) @@ -5299,9 +5308,9 @@ set_bool_option ( /* when 'title' changed, may need to change the title; same for 'icon' */ else if ((int *)varp == &p_title) { did_set_title(FALSE); - } else if ((int *)varp == &p_icon) { + } else if ((int *)varp == &p_icon) { did_set_title(TRUE); - } else if ((int *)varp == &curbuf->b_changed) { + } else if ((int *)varp == &curbuf->b_changed) { if (!value) save_file_ff(curbuf); /* Buffer is unchanged */ redraw_titles(); @@ -5314,7 +5323,7 @@ set_bool_option ( psepc = '/'; psepcN = '\\'; pseps[0] = '/'; - } else { + } else { psepc = '\\'; psepcN = '/'; pseps[0] = '\\'; @@ -5331,10 +5340,10 @@ set_bool_option ( else if ((int *)varp == &curwin->w_p_wrap) { if (curwin->w_p_wrap) curwin->w_leftcol = 0; - } else if ((int *)varp == &p_ea) { + } else if ((int *)varp == &p_ea) { if (p_ea && !old_value) win_equal(curwin, FALSE, 0); - } else if ((int *)varp == &p_wiv) { + } else if ((int *)varp == &p_wiv) { /* * When 'weirdinvert' changed, set/reset 't_xs'. * Then set 'weirdinvert' according to value of 't_xs'. @@ -5344,7 +5353,7 @@ set_bool_option ( else if (!p_wiv && old_value) T_XS = empty_option; p_wiv = (*T_XS != NUL); - } else if ((int *)varp == &p_acd) { + } else if ((int *)varp == &p_acd) { /* Change directories when the 'acd' option is set now. */ DO_AUTOCHDIR } @@ -5376,12 +5385,12 @@ set_bool_option ( if (errmsg != NULL) EMSG(_(errmsg)); } - } else if ((int *)varp == &p_altkeymap) { + } else if ((int *)varp == &p_altkeymap) { if (old_value != p_altkeymap) { if (!p_altkeymap) { p_hkmap = p_fkmap; p_fkmap = 0; - } else { + } else { p_fkmap = p_hkmap; p_hkmap = 0; } @@ -5463,7 +5472,7 @@ set_bool_option ( p_hkmap = 0; p_fkmap = 0; (void)init_chartab(); - } else { + } else { /* * 'arabic' is reset, handle various sub-settings. */ @@ -5577,7 +5586,7 @@ set_num_option ( p_wmh = p_wh; } win_setminheight(); - } else if (pp == &p_wiw) { + } else if (pp == &p_wiw) { if (p_wiw < 1) { errmsg = e_positive; p_wiw = 1; @@ -5631,7 +5640,7 @@ set_num_option ( if (curwin->w_p_fdc < 0) { errmsg = e_positive; curwin->w_p_fdc = 0; - } else if (curwin->w_p_fdc > 12) { + } else if (curwin->w_p_fdc > 12) { errmsg = e_invarg; curwin->w_p_fdc = 12; } @@ -5652,7 +5661,7 @@ set_num_option ( else if (p_mco < 0) p_mco = 0; screenclear(); /* will re-allocate the screen */ - } else if (pp == &curbuf->b_p_iminsert) { + } else if (pp == &curbuf->b_p_iminsert) { if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) { errmsg = e_invarg; curbuf->b_p_iminsert = B_IMODE_NONE; @@ -5662,12 +5671,12 @@ set_num_option ( showmode(); /* Show/unshow value of 'keymap' in status lines. */ status_redraw_curbuf(); - } else if (pp == &p_window) { + } else if (pp == &p_window) { if (p_window < 1) p_window = 1; else if (p_window >= Rows) p_window = Rows - 1; - } else if (pp == &curbuf->b_p_imsearch) { + } else if (pp == &curbuf->b_p_imsearch) { if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) { errmsg = e_invarg; curbuf->b_p_imsearch = B_IMODE_NONE; @@ -5706,11 +5715,11 @@ set_num_option ( } if (p_uc && !old_value) ml_open_files(); - } else if (pp == &curwin->w_p_cole) { + } else if (pp == &curwin->w_p_cole) { if (curwin->w_p_cole < 0) { errmsg = e_positive; curwin->w_p_cole = 0; - } else if (curwin->w_p_cole > 3) { + } else if (curwin->w_p_cole > 3) { errmsg = e_invarg; curwin->w_p_cole = 3; } @@ -5721,7 +5730,7 @@ set_num_option ( p_ul = old_value; u_sync(TRUE); p_ul = value; - } else if (pp == &curbuf->b_p_ul) { + } else if (pp == &curbuf->b_p_ul) { /* use the old value, otherwise u_sync() may not work properly */ curbuf->b_p_ul = old_value; u_sync(TRUE); @@ -5738,7 +5747,7 @@ set_num_option ( curwin->w_p_nuw = 10; } curwin->w_nrwidth_line_count = 0; - } else if (pp == &curbuf->b_p_tw) { + } else if (pp == &curbuf->b_p_tw) { if (curbuf->b_p_tw < 0) { errmsg = e_positive; curbuf->b_p_tw = 0; @@ -6098,7 +6107,8 @@ char_u *get_term_code(char_u *tname) return find_termcode(tname + 2); } -char_u *get_highlight_default(void) { +char_u *get_highlight_default(void) +{ int i; i = findoption((char_u *)"hl"); @@ -6107,7 +6117,8 @@ char_u *get_highlight_default(void) { return (char_u *)NULL; } -char_u *get_encoding_default(void) { +char_u *get_encoding_default(void) +{ int i; i = findoption((char_u *)"enc"); @@ -6387,10 +6398,10 @@ int makeset(FILE *fd, int opt_flags, int local_only) if (p->flags & P_BOOL) { if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) return FAIL; - } else if (p->flags & P_NUM) { + } else if (p->flags & P_NUM) { if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) return FAIL; - } else { /* P_STRING */ + } else { /* P_STRING */ int do_endif = FALSE; /* Don't set 'syntax' and 'filetype' again if the value is @@ -6459,7 +6470,7 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int e while (*s != NUL) if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) return FAIL; - } else if (expand) { + } else if (expand) { buf = alloc(MAXPATHL); if (buf == NULL) return FAIL; @@ -6509,7 +6520,8 @@ static int put_setbool(FILE *fd, char *cmd, char *name, int value) * If the option has been allocated, free the memory. * Terminal options are never hidden or indirect. */ -void clear_termoptions(void) { +void clear_termoptions(void) +{ /* * Reset a few things before clearing the old options. This may cause * outputting a few things that the terminal doesn't understand, but the @@ -6522,7 +6534,8 @@ void clear_termoptions(void) { free_termoptions(); } -void free_termoptions(void) { +void free_termoptions(void) +{ struct vimoption *p; for (p = &options[0]; p->fullname != NULL; p++) @@ -6561,7 +6574,8 @@ void free_one_termoption(char_u *var) * Set the terminal option defaults to the current value. * Used after setting the terminal name. */ -void set_term_defaults(void) { +void set_term_defaults(void) +{ struct vimoption *p; for (p = &options[0]; p->fullname != NULL; p++) { @@ -6596,7 +6610,8 @@ static int istermoption(struct vimoption *p) #define COL_RULER 17 /* columns needed by standard ruler */ -void comp_col(void) { +void comp_col(void) +{ int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin)); sc_col = 0; @@ -6861,7 +6876,8 @@ static char_u *get_varp(struct vimoption *p) /* * Get the value of 'equalprg', either the buffer-local one or the global one. */ -char_u *get_equalprg(void) { +char_u *get_equalprg(void) +{ if (*curbuf->b_p_ep == NUL) return p_ep; return curbuf->b_p_ep; @@ -7156,7 +7172,8 @@ void buf_copy_options(buf_T *buf, int flags) /* * Reset the 'modifiable' option and its default value. */ -void reset_modifiable(void) { +void reset_modifiable(void) +{ int opt_idx; curbuf->b_p_ma = FALSE; @@ -7169,14 +7186,16 @@ void reset_modifiable(void) { /* * Set the global value for 'iminsert' to the local value. */ -void set_iminsert_global(void) { +void set_iminsert_global(void) +{ p_iminsert = curbuf->b_p_iminsert; } /* * Set the global value for 'imsearch' to the local value. */ -void set_imsearch_global(void) { +void set_imsearch_global(void) +{ p_imsearch = curbuf->b_p_imsearch; } @@ -7247,7 +7266,7 @@ set_context_in_set_cmd ( is_term_option = TRUE; expand_option_name[2] = KEY2TERMCAP0(key); expand_option_name[3] = KEY2TERMCAP1(key); - } else { + } else { if (p[0] == 't' && p[1] == '_') { p += 2; if (*p != NUL) @@ -7258,7 +7277,7 @@ set_context_in_set_cmd ( is_term_option = TRUE; expand_option_name[2] = p[-2]; expand_option_name[3] = p[-1]; - } else { + } else { /* Allow * wildcard */ while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') p++; @@ -7320,7 +7339,7 @@ set_context_in_set_cmd ( xp->xp_backslash = XP_BS_THREE; else xp->xp_backslash = XP_BS_ONE; - } else { + } else { xp->xp_context = EXPAND_FILES; /* for 'tags' need three backslashes for a space */ if (p == (char_u *)&p_tags) @@ -7572,7 +7591,7 @@ option_value2string ( STRCPY(NameBuff, transchar((int)wc)); else sprintf((char *)NameBuff, "%ld", *(long *)varp); - } else { /* P_STRING */ + } else { /* P_STRING */ varp = *(char_u **)(varp); if (varp == NULL) /* just in case */ NameBuff[0] = NUL; @@ -7688,7 +7707,8 @@ int langmap_adjust_mb(int c) return c; /* no entry found, return "c" unmodified */ } -static void langmap_init(void) { +static void langmap_init(void) +{ int i; for (i = 0; i < 256; i++) @@ -7700,7 +7720,8 @@ static void langmap_init(void) { * Called when langmap option is set; the language map can be * changed at any time! */ -static void langmap_set(void) { +static void langmap_set(void) +{ char_u *p; char_u *p2; int from, to; @@ -7734,7 +7755,7 @@ static void langmap_set(void) { ++p; to = (*mb_ptr2char)(p); } - } else { + } else { if (p2[0] != ',') { if (p2[0] == '\\') ++p2; @@ -7800,7 +7821,8 @@ int shortmess(int x) /* * paste_option_changed() - Called after p_paste was set or reset. */ -static void paste_option_changed(void) { +static void paste_option_changed(void) +{ static int old_p_paste = FALSE; static int save_sm = 0; static int save_ru = 0; @@ -7975,7 +7997,8 @@ void reset_option_was_set(char_u *name) * When 'compatible' is unset: Set all options that have a different default * for Vim (without the P_VI_DEF flag) to that default. */ -static void compatible_set(void) { +static void compatible_set(void) +{ int opt_idx; for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) @@ -7988,7 +8011,8 @@ static void compatible_set(void) { /* * fill_breakat_flags() -- called when 'breakat' changes value. */ -static void fill_breakat_flags(void) { +static void fill_breakat_flags(void) +{ char_u *p; int i; @@ -8058,7 +8082,8 @@ opt_strings_flags ( /* * Read the 'wildmode' option, fill wim_flags[]. */ -static int check_opt_wim(void) { +static int check_opt_wim(void) +{ char_u new_wim_flags[4]; char_u *p; int i; @@ -8186,7 +8211,8 @@ long get_sw_value(buf_T *buf) * Return the effective softtabstop value for the current buffer, using the * 'tabstop' value when 'softtabstop' is negative. */ -long get_sts_value(void) { +long get_sts_value(void) +{ return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts; } @@ -8210,7 +8236,7 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit) *findc = *initc; *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); *backwards = TRUE; - } else { + } else { *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); *backwards = FALSE; } @@ -8223,20 +8249,20 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit) *findc = *initc; *initc = mb_ptr2char(prev); *backwards = FALSE; - } else { + } else { *findc = mb_ptr2char(prev); *backwards = TRUE; } return; } ptr += mb_ptr2len(ptr); - } else { + } else { if (*ptr == *initc) { if (switchit) { *backwards = TRUE; *findc = *initc; *initc = ptr[2]; - } else { + } else { *backwards = FALSE; *findc = ptr[2]; } @@ -8248,7 +8274,7 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit) *backwards = FALSE; *findc = *initc; *initc = ptr[-2]; - } else { + } else { *backwards = TRUE; *findc = ptr[-2]; } diff --git a/src/os_unix.c b/src/os_unix.c index bbb27b239b..71927fc55e 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -277,7 +277,7 @@ int mch_inchar( return 0; handle_resize(); } - } else { /* wtime == -1 */ + } else { /* wtime == -1 */ /* * If there is no character available within 'updatetime' seconds * flush all the swap files to disk. @@ -327,7 +327,8 @@ int mch_inchar( } } -static void handle_resize() { +static void handle_resize() +{ do_resize = FALSE; shell_resized(); } @@ -335,7 +336,8 @@ static void handle_resize() { /* * return non-zero if a character is available */ -int mch_char_avail() { +int mch_char_avail() +{ return WaitForChar(0L); } @@ -419,7 +421,8 @@ static struct sigstack sigstk; /* for sigstack() */ static void init_signal_stack(void); static char *signal_stack; -static void init_signal_stack() { +static void init_signal_stack() +{ if (signal_stack != NULL) { # ifdef HAVE_SIGALTSTACK sigstk.ss_sp = signal_stack; @@ -502,18 +505,21 @@ catch_sigpwr SIGDEFARG(sigarg) { * Returns OK for normal return, FAIL when the protected code caused a * problem and LONGJMP() was used. */ -void mch_startjmp() { +void mch_startjmp() +{ #ifdef SIGHASARG lc_signal = 0; #endif lc_active = TRUE; } -void mch_endjmp() { +void mch_endjmp() +{ lc_active = FALSE; } -void mch_didjmp() { +void mch_didjmp() +{ # if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK) /* On FreeBSD the signal stack has to be reset after using siglongjmp(), * otherwise catching the signal only works once. */ @@ -677,7 +683,8 @@ sigcont_handler SIGDEFARG(sigarg) { * If the machine has job control, use it to suspend the program, * otherwise fake it by starting a new shell. */ -void mch_suspend() { +void mch_suspend() +{ /* BeOS does have SIGTSTP, but it doesn't work. */ #if defined(SIGTSTP) && !defined(__BEOS__) out_flush(); /* needed to make cursor visible on some systems */ @@ -722,7 +729,8 @@ void mch_suspend() { #endif } -void mch_init() { +void mch_init() +{ Columns = 80; Rows = 24; @@ -734,7 +742,8 @@ void mch_init() { #endif } -static void set_signals() { +static void set_signals() +{ #if defined(SIGWINCH) /* * WINDOW CHANGE signal is handled with sig_winch(). @@ -790,13 +799,15 @@ static void set_signals() { /* * Catch CTRL-C (only works while in Cooked mode). */ -static void catch_int_signal() { +static void catch_int_signal() +{ signal(SIGINT, (RETSIGTYPE (*)())catch_sigint); } #endif -void reset_signals() { +void reset_signals() +{ catch_signals(SIG_DFL, SIG_DFL); #if defined(_REENTRANT) && defined(SIGCONT) /* SIGCONT isn't in the list, because its default action is ignore */ @@ -897,7 +908,8 @@ int mch_check_win(int argc, char **argv) /* * Return TRUE if the input comes from a terminal, FALSE otherwise. */ -int mch_input_isatty() { +int mch_input_isatty() +{ if (isatty(read_cmd_fd)) return TRUE; return FALSE; @@ -920,11 +932,13 @@ static int get_x11_icon(int test_only) } -int mch_can_restore_title() { +int mch_can_restore_title() +{ return get_x11_title(TRUE); } -int mch_can_restore_icon() { +int mch_can_restore_icon() +{ return get_x11_icon(TRUE); } @@ -1031,7 +1045,8 @@ int use_xterm_like_mouse(char_u *name) * Return 3 for "urxvt". * Return 4 for "sgr". */ -int use_xterm_mouse() { +int use_xterm_mouse() +{ if (ttym_flags == TTYM_SGR) return 4; if (ttym_flags == TTYM_URXVT) @@ -1107,7 +1122,8 @@ void mch_get_host_name(char_u *s, int len) /* * return process ID */ -long mch_get_pid() { +long mch_get_pid() +{ return (long)getpid(); } @@ -1133,7 +1149,7 @@ int len; /* buffer size, only used when name gets longer */ if (slash == NULL) { dirp = opendir("."); tail = name; - } else { + } else { *slash = NUL; dirp = opendir((char *)name); *slash = '/'; @@ -1279,7 +1295,8 @@ int mch_nodetype(char_u *name) return NODE_WRITABLE; } -void mch_early_init() { +void mch_early_init() +{ /* * Setup an alternative stack for signals. Helps to catch signals when * running out of stack space. @@ -1310,7 +1327,8 @@ static void exit_scroll(void); * Output a newline when exiting. * Make sure the newline goes to the same stream as the text. */ -static void exit_scroll() { +static void exit_scroll() +{ if (silent_mode) return; if (newline_on_exit || msg_didout) { @@ -1321,7 +1339,7 @@ static void exit_scroll() { mch_errmsg("\r\n"); } else out_char('\n'); - } else { + } else { restore_cterm_colors(); /* get original colors back */ msg_clr_eos_force(); /* clear the rest of the display */ windgoto((int)Rows - 1, 0); /* may have moved the cursor */ @@ -1378,7 +1396,8 @@ void mch_exit(int r) exit(r); } -static void may_core_dump() { +static void may_core_dump() +{ if (deadly_signal != 0) { signal(deadly_signal, SIG_DFL); kill(getpid(), deadly_signal); /* Die using the signal we caught */ @@ -1482,7 +1501,8 @@ void mch_settmode(int tmode) * be), they're going to get really annoyed if their erase key starts * doing forward deletes for no reason. (Eric Fischer) */ -void get_stty() { +void get_stty() +{ char_u buf[2]; char_u *p; @@ -1566,7 +1586,7 @@ int on; ? IF_EB("\033[?1002l", ESC_STR "[?1002l") : IF_EB("\033[?1000l", ESC_STR "[?1000l"))); ison = on; - } else if (ttym_flags == TTYM_DEC) { + } else if (ttym_flags == TTYM_DEC) { if (on) /* enable mouse events */ out_str_nf((char_u *)"\033[1;2'z\033[1;3'{"); else /* disable mouse events */ @@ -1579,7 +1599,8 @@ int on; /* * Set the mouse termcode, depending on the 'term' and 'ttymouse' options. */ -void check_mouse_termcode() { +void check_mouse_termcode() +{ if (use_xterm_mouse() && use_xterm_mouse() != 3 ) { @@ -1661,7 +1682,8 @@ char_u *arg; * 4. keep using the old values * Return OK when size could be determined, FAIL otherwise. */ -int mch_get_shellsize() { +int mch_get_shellsize() +{ long rows = 0; long columns = 0; char_u *p; @@ -1741,7 +1763,8 @@ int mch_get_shellsize() { /* * Try to set the window size to Rows and Columns. */ -void mch_set_shellsize() { +void mch_set_shellsize() +{ if (*T_CWS) { /* * NOTE: if you get an error here that term_set_winsize() is @@ -1757,7 +1780,8 @@ void mch_set_shellsize() { /* * Rows and/or Columns has changed. */ -void mch_new_shellsize() { +void mch_new_shellsize() +{ /* Nothing to do. */ } @@ -1939,7 +1963,7 @@ int options; /* SHELL_*, see vim.h */ close(fd_fromshell[1]); } } - } else if (pid == 0) { /* child */ + } else if (pid == 0) { /* child */ reset_signals(); /* handle signals normally */ if (!show_shell_mess || (options & SHELL_EXPAND)) { @@ -2033,7 +2057,7 @@ int options; /* SHELL_*, see vim.h */ */ execvp(argv[0], argv); _exit(EXEC_FAILED); /* exec failed, return failure code */ - } else { /* parent */ + } else { /* parent */ /* * While child is running, ignore terminating signals. * Do catch CTRL-C, so that "got_int" is set. @@ -2098,7 +2122,7 @@ int options; /* SHELL_*, see vim.h */ * external program. */ if ((wpid = fork()) == -1) { MSG_PUTS(_("\nCannot fork\n")); - } else if (wpid == 0) { /* child */ + } else if (wpid == 0) { /* child */ linenr_T lnum = curbuf->b_op_start.lnum; int written = 0; char_u *lp = ml_get(lnum); @@ -2143,7 +2167,7 @@ int options; /* SHELL_*, see vim.h */ written += len; } _exit(0); - } else { /* parent */ + } else { /* parent */ close(toshell_fd); toshell_fd = -1; } @@ -2321,7 +2345,7 @@ int options; /* SHELL_*, see vim.h */ else ga_append(&ga, buffer[i]); } - } else if (has_mbyte) { + } else if (has_mbyte) { int l; len += buffer_off; @@ -2356,7 +2380,7 @@ int options; /* SHELL_*, see vim.h */ continue; } buffer_off = 0; - } else { + } else { buffer[len] = NUL; msg_puts(buffer); } @@ -2469,7 +2493,7 @@ finished: MSG_PUTS(_("\nCannot execute shell ")); msg_outtrans(p_sh); msg_putchar('\n'); - } else if (!(options & SHELL_SILENT)) { + } else if (!(options & SHELL_SILENT)) { MSG_PUTS(_("\nshell returned ")); msg_outnum((long)retval); msg_putchar('\n'); @@ -2496,7 +2520,8 @@ error: * Check for CTRL-C typed by reading all available characters. * In cooked mode we should get SIGINT, no need to check. */ -void mch_breakcheck() { +void mch_breakcheck() +{ if (curr_tmode == TMODE_RAW && RealWaitForChar(read_cmd_fd, 0L, NULL)) fill_input_buf(FALSE); } @@ -2814,7 +2839,7 @@ int flags; /* EW_* flags */ *p = ' '; } STRCAT(command, ">"); - } else { + } else { if (flags & EW_NOTFOUND) STRCPY(command, "set nonomatch; "); else @@ -3051,7 +3076,7 @@ int flags; /* EW_* flags */ *p++ = NUL; p = skipwhite(p); /* skip to next entry */ } - } else { /* NUL separates */ + } else { /* NUL separates */ while (*p && p < buffer + len) /* skip entry */ ++p; ++p; /* skip NUL */ @@ -3302,7 +3327,7 @@ int *number_result; else retval_str = (ProcAdd)(argstring); } - } else { + } else { # if defined(USE_DLOPEN) ProcAddI = (INTPROCSTR)dlsym(hinstLib, (const char *)funcname); dlerr = (char *)dlerror(); diff --git a/src/popupmnu.c b/src/popupmnu.c index a563095c95..9b20ee0c5b 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -112,7 +112,7 @@ redo: if (row >= size + context_lines) { pum_row = row - size - context_lines; pum_height = size; - } else { + } else { pum_row = 0; pum_height = row - context_lines; } @@ -390,7 +390,7 @@ void pum_redraw(void) if (curwin->w_p_rl) { screen_puts_len((char_u *)" ", 2, row, col - 1, attr); col -= 2; - } else { + } else { screen_puts_len((char_u *)" ", 2, row, col, attr); col += 2; } @@ -425,7 +425,7 @@ void pum_redraw(void) screen_fill(row, row + 1, pum_col - pum_base_width - n + 1, col + 1, ' ', ' ', attr); col = pum_col - pum_base_width - n + 1; - } else { + } else { screen_fill(row, row + 1, col, pum_col + pum_base_width + n, ' ', ' ', attr); col = pum_col + pum_base_width + n; diff --git a/src/quickfix.c b/src/quickfix.c index 85436d66b3..1820f15af4 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -396,20 +396,20 @@ qf_init_ext ( * follows should work. */ STRCPY(ptr, ".\\{-1,}"); ptr += 7; - } else { + } else { /* File name followed by '\\' or '%': include as * many file name chars as possible. */ STRCPY(ptr, "\\f\\+"); ptr += 4; } - } else { + } else { srcptr = (char_u *)fmt_pat[idx].pattern; while ((*ptr = *srcptr++) != NUL) ++ptr; } *ptr++ = '\\'; *ptr++ = ')'; - } else if (*efmp == '*') { + } else if (*efmp == '*') { if (*++efmp == '[' || *efmp == '\\') { if ((*ptr++ = *efmp) == '[') { /* %*[^a-z0-9] etc. */ if (efmp[1] == '^') @@ -428,7 +428,7 @@ qf_init_ext ( *ptr++ = *++efmp; *ptr++ = '\\'; *ptr++ = '+'; - } else { + } else { /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */ sprintf((char *)errmsg, _("E375: Unsupported %%%c in format string"), *efmp); @@ -452,13 +452,13 @@ qf_init_ext ( EMSG(errmsg); goto error2; } - } else { + } else { sprintf((char *)errmsg, _("E377: Invalid %%%c in format string"), *efmp); EMSG(errmsg); goto error2; } - } else { /* copy normal character */ + } else { /* copy normal character */ if (*efmp == '\\' && efmp + 1 < efm + len) ++efmp; else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL) @@ -524,7 +524,7 @@ qf_init_ext ( vim_strncpy(IObuff, p_str, len); p_str += len; - } else if (tv->v_type == VAR_LIST) { + } else if (tv->v_type == VAR_LIST) { /* Get the next line from the supplied list */ while (p_li && p_li->li_tv.v_type != VAR_STRING) p_li = p_li->li_next; /* Skip non-string items */ @@ -540,7 +540,7 @@ qf_init_ext ( p_li = p_li->li_next; /* next item */ } - } else { + } else { /* Get the next line from the supplied buffer */ if (buflnum > lnumlast) break; @@ -709,7 +709,7 @@ restofline: STRCPY(errmsg, IObuff); /* copy whole line to error message */ if (fmt_ptr == NULL) multiline = multiignore = FALSE; - } else if (fmt_ptr != NULL) { + } else if (fmt_ptr != NULL) { /* honor %> item */ if (fmt_ptr->conthere) fmt_start = fmt_ptr; @@ -747,7 +747,7 @@ restofline: multiline = multiignore = FALSE; line_breakcheck(); continue; - } else if (vim_strchr((char_u *)"OPQ", idx) != NULL) { + } else if (vim_strchr((char_u *)"OPQ", idx) != NULL) { /* global file names */ valid = FALSE; if (*namebuf == NUL || os_file_exists(namebuf)) { @@ -794,7 +794,7 @@ restofline: qi->qf_lists[qi->qf_curlist].qf_start; qi->qf_lists[qi->qf_curlist].qf_index = 1; qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE; - } else { + } else { qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; if (qi->qf_lists[qi->qf_curlist].qf_ptr == NULL) qi->qf_lists[qi->qf_curlist].qf_ptr = @@ -957,7 +957,7 @@ qf_add_entry ( /* first element in the list */ qi->qf_lists[qi->qf_curlist].qf_start = qfp; qfp->qf_prev = qfp; /* first element points to itself */ - } else { + } else { qfp->qf_prev = *prevp; (*prevp)->qf_next = qfp; } @@ -978,7 +978,8 @@ qf_add_entry ( /* * Allocate a new location list */ -static qf_info_T *ll_new_list(void) { +static qf_info_T *ll_new_list(void) +{ qf_info_T *qi; qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T)); @@ -1385,7 +1386,7 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit) || (dir == FORWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); err = NULL; } - } else if (dir == BACKWARD || dir == BACKWARD_FILE) { /* prev. valid entry */ + } else if (dir == BACKWARD || dir == BACKWARD_FILE) { /* prev. valid entry */ while (errornr--) { old_qf_ptr = qf_ptr; prev_index = qf_index; @@ -1408,7 +1409,7 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit) || (dir == BACKWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum)); err = NULL; } - } else if (errornr != 0) { /* go to specified number */ + } else if (errornr != 0) { /* go to specified number */ while (errornr < qf_index && qf_index > 1 && qf_ptr->qf_prev != NULL) { --qf_index; qf_ptr = qf_ptr->qf_prev; @@ -1547,7 +1548,7 @@ win_found: curwin->w_llist = ll_ref; ll_ref->qf_refcount++; } - } else { + } else { if (curwin->w_llist_ref != NULL) { /* In a location window */ win = usable_win_ptr; @@ -1577,7 +1578,7 @@ win_found: win->w_llist = ll_ref; ll_ref->qf_refcount++; } - } else { + } else { /* * Try to find a window that shows the right buffer. @@ -1678,7 +1679,7 @@ win_found: check_cursor(); } else beginline(BL_WHITE | BL_FIX); - } else { + } else { pos_T save_cursor; /* Move the cursor to the first line in the buffer */ @@ -1715,7 +1716,7 @@ win_found: msg_attr_keep(IObuff, 0, TRUE); msg_scroll = i; } - } else { + } else { if (opened_window) win_close(curwin, TRUE); /* Close opened window */ if (qf_ptr->qf_fnum != 0) { @@ -1889,7 +1890,7 @@ void qf_age(exarg_T *eap) break; } --qi->qf_curlist; - } else { + } else { if (qi->qf_curlist >= qi->qf_listcount - 1) { EMSG(_("E381: At top of quickfix stack")); break; @@ -2212,7 +2213,7 @@ qf_win_pos_update ( if (qf_index > old_qf_index) { curwin->w_redraw_top = old_qf_index; curwin->w_redraw_bot = qf_index; - } else { + } else { curwin->w_redraw_top = qf_index; curwin->w_redraw_bot = old_qf_index; } @@ -2363,7 +2364,7 @@ static void qf_fill_buffer(qf_info_T *qi) sprintf((char *)IObuff + len, "%s", (char *)qf_types(qfp->qf_type, qfp->qf_nr)); len += (int)STRLEN(IObuff + len); - } else if (qfp->qf_pattern != NULL) { + } else if (qfp->qf_pattern != NULL) { qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len); len += (int)STRLEN(IObuff + len); } @@ -2573,7 +2574,8 @@ void ex_make(exarg_T *eap) * Find a new unique name when 'makeef' contains "##". * Returns NULL for error. */ -static char_u *get_mef_name(void) { +static char_u *get_mef_name(void) +{ char_u *p; char_u *name; static int start = -1; @@ -2732,7 +2734,7 @@ void ex_cfile(exarg_T *eap) if (wp != NULL) qi = GET_LOC_LIST(wp); qf_jump(qi, 0, 0, eap->forceit); /* display first error */ - } else { + } else { if (au_name != NULL) apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); } @@ -2934,7 +2936,7 @@ void ex_vimgrep(exarg_T *eap) if (buf == NULL) { if (!got_int) smsg((char_u *)_("Cannot open file \"%s\""), fname); - } else { + } else { /* Try for a match in all lines of the buffer. * For ":1vimgrep" look for first match only. */ found_match = FALSE; @@ -2999,7 +3001,7 @@ void ex_vimgrep(exarg_T *eap) if (!found_match) { wipe_dummy_buffer(buf, dirname_start); buf = NULL; - } else if (buf != first_match_buf || (flags & VGR_NOJUMP)) { + } else if (buf != first_match_buf || (flags & VGR_NOJUMP)) { unload_dummy_buffer(buf, dirname_start); buf = NULL; } @@ -3092,7 +3094,7 @@ char_u *skip_vimgrep_pat(char_u *p, char_u **s, int *flags) p = skiptowhite(p); if (s != NULL && *p != NUL) *p++ = NUL; - } else { + } else { /* ":vimgrep /pattern/[g][j] fname" */ if (s != NULL) *s = p + 1; diff --git a/src/regexp.c b/src/regexp.c index 6d9163dde9..03ac02783e 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -523,7 +523,8 @@ static short class_tab[256]; #define RI_UPPER 0x80 #define RI_WHITE 0x100 -static void init_class_tab(void) { +static void init_class_tab(void) +{ int i; static int done = FALSE; @@ -1070,7 +1071,8 @@ static void get_cpo_flags(void); static int reg_cpo_lit; /* 'cpoptions' contains 'l' flag */ static int reg_cpo_bsl; /* 'cpoptions' contains '\' flag */ -static void get_cpo_flags(void) { +static void get_cpo_flags(void) +{ reg_cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL; reg_cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL; } @@ -1345,7 +1347,8 @@ regcomp_start ( * Check if during the previous call to vim_regcomp the EOL item "$" has been * found. This is messy, but it works fine. */ -int vim_regcomp_had_eol(void) { +int vim_regcomp_had_eol(void) +{ return had_eol; } @@ -1436,7 +1439,7 @@ reg ( EMSG2_RET_NULL(_(e_unmatchedpp), reg_magic == MAGIC_ALL); else EMSG2_RET_NULL(_(e_unmatchedp), reg_magic == MAGIC_ALL); - } else if (paren == REG_NOPAREN && peekchr() != NUL) { + } else if (paren == REG_NOPAREN && peekchr() != NUL) { if (curchr == Magic(')')) EMSG2_RET_NULL(_(e_unmatchedpar), reg_magic == MAGIC_ALL); else @@ -1674,7 +1677,7 @@ static char_u *regpiece(int *flagp) if (flags & SIMPLE) { reginsert(BRACE_SIMPLE, ret); reginsert_limits(BRACE_LIMITS, minval, maxval, ret); - } else { + } else { if (num_complex_braces >= 10) EMSG2_RET_NULL(_("E60: Too many complex %s{...}s"), reg_magic == MAGIC_ALL); @@ -1822,7 +1825,7 @@ static char_u *regatom(int *flagp) regc(NL); regc(NUL); *flagp |= HASWIDTH | SIMPLE; - } else { + } else { /* In buffer text "\n" matches the end of a line. */ ret = regnode(NEWL); *flagp |= HASWIDTH | HASNL; @@ -2092,7 +2095,7 @@ static char_u *regatom(int *flagp) *regcode++ = cmp; } break; - } else if (c == 'l' || c == 'c' || c == 'v') { + } else if (c == 'l' || c == 'c' || c == 'v') { if (c == 'l') ret = regnode(RE_LNUM); else if (c == 'c') @@ -2157,7 +2160,7 @@ collection: || (regparse[0] == '\\' && regparse[1] == 'n')) { regc('-'); startc = '-'; /* [--x] is a range */ - } else { + } else { /* Also accept "a-[.z.]" */ endc = 0; if (*regparse == '[') @@ -2182,7 +2185,7 @@ collection: EMSG_RET_NULL(_(e_invrange)); while (++startc <= endc) regmbc(startc); - } else { + } else { while (++startc <= endc) regc(startc); } @@ -2225,11 +2228,11 @@ collection: regc(0x0a); else regmbc(startc); - } else { + } else { startc = backslash_trans(*regparse++); regc(startc); } - } else if (*regparse == '[') { + } else if (*regparse == '[') { int c_class; int cu; @@ -2246,7 +2249,7 @@ collection: get_coll_element(®parse)) != 0) { /* produce a collating element */ regmbc(c_class); - } else { + } else { /* literal '[', allow [[-x] as a range */ startc = *regparse++; regc(startc); @@ -2324,7 +2327,7 @@ collection: regc('\033'); break; } - } else { + } else { if (has_mbyte) { int len; @@ -2336,7 +2339,7 @@ collection: startc = -1; /* composing chars */ while (--len >= 0) regc(*regparse++); - } else { + } else { startc = *regparse++; regc(startc); } @@ -2671,7 +2674,8 @@ static void restore_parse_state(parse_state_T *ps) /* * Get the next character without advancing. */ -static int peekchr(void) { +static int peekchr(void) +{ static int after_slash = FALSE; if (curchr == -1) { @@ -2782,7 +2786,7 @@ static int peekchr(void) { --regparse; --after_slash; curchr = toggle_Magic(curchr); - } else if (vim_strchr(REGEXP_ABBR, c)) { + } else if (vim_strchr(REGEXP_ABBR, c)) { /* * Handle abbreviations, like "\t" for TAB -- webb */ @@ -2814,7 +2818,8 @@ static int peekchr(void) { /* * Eat one lexed character. Do this in a way that we can undo it. */ -static void skipchr(void) { +static void skipchr(void) +{ /* peekchr() eats a backslash, do the same here */ if (*regparse == '\\') prevchr_len = 1; @@ -2842,7 +2847,8 @@ static void skipchr(void) { * Skip a character while keeping the value of prev_at_start for at_start. * prevchr and prevprevchr are also kept. */ -static void skipchr_keepstart(void) { +static void skipchr_keepstart(void) +{ int as = prev_at_start; int pr = prevchr; int prpr = prevprevchr; @@ -2857,7 +2863,8 @@ static void skipchr_keepstart(void) { * Get the next character from the pattern. We know about magic and such, so * therefore we need a lexical analyzer. */ -static int getchr(void) { +static int getchr(void) +{ int chr = peekchr(); skipchr(); @@ -2867,7 +2874,8 @@ static int getchr(void) { /* * put character back. Works only once! */ -static void ungetchr(void) { +static void ungetchr(void) +{ nextchr = curchr; curchr = prevchr; prevchr = prevprevchr; @@ -2912,7 +2920,8 @@ static int gethexchrs(int maxinputlen) * Get and return the value of the decimal string immediately after the * current position. Return -1 for invalid. Consumes all digits. */ -static int getdecchrs(void) { +static int getdecchrs(void) +{ int nr = 0; int c; int i; @@ -2940,7 +2949,8 @@ static int getdecchrs(void) { * blahblah\%o210asdf * before-^ ^-after */ -static int getoctchrs(void) { +static int getoctchrs(void) +{ int nr = 0; int c; int i; @@ -2963,7 +2973,8 @@ static int getoctchrs(void) { * Get a number after a backslash that is inside []. * When nothing is recognized return a backslash. */ -static int coll_get_char(void) { +static int coll_get_char(void) +{ int nr = -1; switch (*regparse++) { @@ -3249,7 +3260,8 @@ static garray_T backpos = {0, 0, 0, 0, NULL}; #define BACKPOS_INITIAL 64 #if defined(EXITFREE) || defined(PROTO) -void free_regexp_stuff(void) { +void free_regexp_stuff(void) +{ ga_clear(®stack); ga_clear(&backpos); vim_free(reg_tofree); @@ -3413,7 +3425,7 @@ proftime_T *tm; /* timeout limit or NULL */ line = reg_getline((linenr_T)0); reg_startpos = reg_mmatch->startpos; reg_endpos = reg_mmatch->endpos; - } else { + } else { prog = (bt_regprog_T *)reg_match->regprog; reg_startp = reg_match->startp; reg_endp = reg_match->endp; @@ -3502,7 +3514,7 @@ proftime_T *tm; /* timeout limit or NULL */ retval = regtry(prog, col); else retval = 0; - } else { + } else { int tm_count = 0; /* Messy cases: unanchored match. */ while (!got_int) { @@ -3572,7 +3584,8 @@ static reg_extmatch_T *make_extmatch(void); /* * Create a new extmatch and mark it as referenced once. */ -static reg_extmatch_T *make_extmatch(void) { +static reg_extmatch_T *make_extmatch(void) +{ reg_extmatch_T *em; em = (reg_extmatch_T *)alloc_clear((unsigned)sizeof(reg_extmatch_T)); @@ -3633,7 +3646,7 @@ static long regtry(bt_regprog_T *prog, colnr_T col) } else /* Use line number of "\ze". */ reglnum = reg_endpos[0].lnum; - } else { + } else { if (reg_startp[0] == NULL) reg_startp[0] = regline + col; if (reg_endp[0] == NULL) @@ -3657,7 +3670,7 @@ static long regtry(bt_regprog_T *prog, colnr_T col) vim_strnsave(reg_getline(reg_startzpos[i].lnum) + reg_startzpos[i].col, reg_endzpos[i].col - reg_startzpos[i].col); - } else { + } else { if (reg_startzp[i] != NULL && reg_endzp[i] != NULL) re_extmatch_out->matches[i] = vim_strnsave(reg_startzp[i], @@ -3673,7 +3686,8 @@ static int reg_prev_class(void); /* * Get class of previous character. */ -static int reg_prev_class(void) { +static int reg_prev_class(void) +{ if (reginput > regline) return mb_get_class_buf(reginput - 1 - (*mb_head_off)(regline, reginput - 1), reg_buf); @@ -3685,7 +3699,8 @@ static int reg_match_visual(void); /* * Return TRUE if the current reginput position matches the Visual area. */ -static int reg_match_visual(void) { +static int reg_match_visual(void) +{ pos_T top, bot; linenr_T lnum; colnr_T col; @@ -3703,16 +3718,16 @@ static int reg_match_visual(void) { if (lt(VIsual, wp->w_cursor)) { top = VIsual; bot = wp->w_cursor; - } else { + } else { top = wp->w_cursor; bot = VIsual; } mode = VIsual_mode; - } else { + } else { if (lt(curbuf->b_visual.vi_start, curbuf->b_visual.vi_end)) { top = curbuf->b_visual.vi_start; bot = curbuf->b_visual.vi_end; - } else { + } else { top = curbuf->b_visual.vi_end; bot = curbuf->b_visual.vi_start; } @@ -3727,7 +3742,7 @@ static int reg_match_visual(void) { if ((lnum == top.lnum && col < top.col) || (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e'))) return FALSE; - } else if (mode == Ctrl_V) { + } else if (mode == Ctrl_V) { getvvcol(wp, &top, &start, NULL, &end); getvvcol(wp, &bot, &start2, NULL, &end2); if (start2 < start) @@ -3840,9 +3855,9 @@ regmatch ( if (!reg_line_lbr && WITH_NL(op) && REG_MULTI && *reginput == NUL && reglnum <= reg_maxline) { reg_nextline(); - } else if (reg_line_lbr && WITH_NL(op) && *reginput == '\n') { + } else if (reg_line_lbr && WITH_NL(op) && *reginput == '\n') { ADVANCE_REGINPUT(); - } else { + } else { if (WITH_NL(op)) op -= ADD_NL; if (has_mbyte) @@ -3941,7 +3956,7 @@ regmatch ( status = RA_NOMATCH; /* not on a word at all */ else if (reg_prev_class() == this_class) status = RA_NOMATCH; /* previous char is in same word */ - } else { + } else { if (!vim_iswordc_buf(c, reg_buf) || (reginput > regline && vim_iswordc_buf(reginput[-1 ], reg_buf))) @@ -3961,7 +3976,7 @@ regmatch ( if (this_class == prev_class || prev_class == 0 || prev_class == 1) status = RA_NOMATCH; - } else { + } else { if (!vim_iswordc_buf(reginput[-1], reg_buf) || (reginput[0] != NUL && vim_iswordc_buf(c, reg_buf))) status = RA_NOMATCH; @@ -4230,7 +4245,7 @@ regmatch ( if (!utf_iscomposing(inpc)) { if (i > 0) break; - } else if (opndc == inpc) { + } else if (opndc == inpc) { /* Include all following composing chars. */ len = i + mb_ptr2len(reginput + i); status = RA_MATCH; @@ -4409,18 +4424,18 @@ regmatch ( if (reg_startp[no] == NULL || reg_endp[no] == NULL) { /* Backref was not set: Match an empty string. */ len = 0; - } else { + } else { /* Compare current input with back-ref in the same * line. */ len = (int)(reg_endp[no] - reg_startp[no]); if (cstrncmp(reg_startp[no], reginput, &len) != 0) status = RA_NOMATCH; } - } else { /* Multi-line regexp */ + } else { /* Multi-line regexp */ if (reg_startpos[no].lnum < 0 || reg_endpos[no].lnum < 0) { /* Backref was not set: Match an empty string. */ len = 0; - } else { + } else { if (reg_startpos[no].lnum == reglnum && reg_endpos[no].lnum == reglnum) { /* Compare back-ref within the current line. */ @@ -4428,7 +4443,7 @@ regmatch ( if (cstrncmp(regline + reg_startpos[no].col, reginput, &len) != 0) status = RA_NOMATCH; - } else { + } else { /* Messy situation: Need to compare between two * lines. */ int r = match_with_backref( @@ -4471,7 +4486,7 @@ regmatch ( status = RA_NOMATCH; else reginput += len; - } else { + } else { /* Backref was not set: Match an empty string. */ } } @@ -4502,7 +4517,7 @@ regmatch ( brace_min[no] = OPERAND_MIN(scan); brace_max[no] = OPERAND_MAX(scan); brace_count[no] = 0; - } else { + } else { EMSG(_(e_internal)); /* Shouldn't happen */ status = RA_FAIL; } @@ -4552,7 +4567,7 @@ regmatch ( /* We continue and handle the result when done. */ } } - } else { + } else { /* Range is backwards, use shortest match first */ if (brace_count[no] <= brace_min[no]) { rp = regstack_push(RS_BRCPLX_SHORT, scan); @@ -4586,14 +4601,14 @@ regmatch ( rst.nextb_ic = MB_TOUPPER(rst.nextb); } else rst.nextb_ic = rst.nextb; - } else { + } else { rst.nextb = NUL; rst.nextb_ic = NUL; } if (op != BRACE_SIMPLE) { rst.minval = (op == STAR) ? 0 : 1; rst.maxval = MAX_LIMIT; - } else { + } else { rst.minval = bl_minval; rst.maxval = bl_maxval; } @@ -4776,7 +4791,7 @@ regmatch ( /* no more branches, didn't find a match */ status = RA_NOMATCH; regstack_pop(&scan); - } else { + } else { /* Prepare to try a branch. */ rp->rs_scan = regnext(scan); reg_save(&rp->rs_un.regsave, &backpos); @@ -4840,7 +4855,7 @@ regmatch ( if (status == RA_NOMATCH) { regstack_pop(&scan); regstack.ga_len -= sizeof(regbehind_T); - } else { + } else { /* The stuff after BEHIND/NOBEHIND matches. Now try if * the behind part does (not) match before the current * position in the input. This must be done at every @@ -4885,7 +4900,7 @@ regmatch ( } regstack_pop(&scan); regstack.ga_len -= sizeof(regbehind_T); - } else { + } else { long limit; /* No match or a match that doesn't end where we want it: Go @@ -4912,7 +4927,7 @@ regmatch ( rp->rs_un.regsave.rs_u.pos.col = (colnr_T)STRLEN(regline); } - } else { + } else { if (has_mbyte) rp->rs_un.regsave.rs_u.pos.col -= (*mb_head_off)(regline, regline @@ -4920,7 +4935,7 @@ regmatch ( else --rp->rs_un.regsave.rs_u.pos.col; } - } else { + } else { if (rp->rs_un.regsave.rs_u.ptr == regline) no = FAIL; else { @@ -4940,14 +4955,14 @@ regmatch ( status = RA_NOMATCH; restore_subexpr(((regbehind_T *)rp) - 1); } - } else { + } else { /* Can't advance. For NOBEHIND that's a match. */ behind_pos = (((regbehind_T *)rp) - 1)->save_behind; if (rp->rs_no == NOBEHIND) { reg_restore(&(((regbehind_T *)rp) - 1)->save_after, &backpos); status = RA_MATCH; - } else { + } else { /* We do want a proper match. Need to restore the * subexpr if we had a match, because they may have * been set. */ @@ -4998,7 +5013,7 @@ regmatch ( fast_breakcheck(); } else mb_ptr_back(regline, reginput); - } else { + } else { /* Range is backwards, use shortest match first. * Careful: maxval and minval are exchanged! * Couldn't or didn't match: try advancing one @@ -5151,7 +5166,7 @@ regrepeat ( while (count < maxcount) { if (vim_isIDc(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan))) { mb_ptr_adv(scan); - } else if (*scan == NUL) { + } else if (*scan == NUL) { if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline || reg_line_lbr) break; @@ -5177,7 +5192,7 @@ regrepeat ( if (vim_iswordp_buf(scan, reg_buf) && (testval || !VIM_ISDIGIT(*scan))) { mb_ptr_adv(scan); - } else if (*scan == NUL) { + } else if (*scan == NUL) { if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline || reg_line_lbr) break; @@ -5202,7 +5217,7 @@ regrepeat ( while (count < maxcount) { if (vim_isfilec(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan))) { mb_ptr_adv(scan); - } else if (*scan == NUL) { + } else if (*scan == NUL) { if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline || reg_line_lbr) break; @@ -5258,7 +5273,7 @@ do_class: scan = reginput; if (got_int) break; - } else if (has_mbyte && (l = (*mb_ptr2len)(scan)) > 1) { + } else if (has_mbyte && (l = (*mb_ptr2len)(scan)) > 1) { if (testval != 0) break; scan += l; @@ -5355,7 +5370,7 @@ do_class: count++; scan++; } - } else { + } else { cu = *opnd; while (count < maxcount && *scan == cu) { count++; @@ -5411,7 +5426,7 @@ do_class: if ((cstrchr(opnd, (*mb_ptr2char)(scan)) == NULL) == testval) break; scan += len; - } else { + } else { if ((cstrchr(opnd, *scan) == NULL) == testval) break; ++scan; @@ -5474,7 +5489,8 @@ static char_u *regnext(char_u *p) * Check the regexp program for its magic number. * Return TRUE if it's wrong. */ -static int prog_magic_wrong(void) { +static int prog_magic_wrong(void) +{ regprog_T *prog; prog = REG_MULTI ? reg_mmatch->regprog : reg_match->regprog; @@ -5494,13 +5510,14 @@ static int prog_magic_wrong(void) { * This construction is used to clear the subexpressions only when they are * used (to increase speed). */ -static void cleanup_subexpr(void) { +static void cleanup_subexpr(void) +{ if (need_clear_subexpr) { if (REG_MULTI) { /* Use 0xff to set lnum to -1 */ vim_memset(reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP); vim_memset(reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP); - } else { + } else { vim_memset(reg_startp, 0, sizeof(char_u *) * NSUBEXP); vim_memset(reg_endp, 0, sizeof(char_u *) * NSUBEXP); } @@ -5508,13 +5525,14 @@ static void cleanup_subexpr(void) { } } -static void cleanup_zsubexpr(void) { +static void cleanup_zsubexpr(void) +{ if (need_clear_zsubexpr) { if (REG_MULTI) { /* Use 0xff to set lnum to -1 */ vim_memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP); vim_memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP); - } else { + } else { vim_memset(reg_startzp, 0, sizeof(char_u *) * NSUBEXP); vim_memset(reg_endzp, 0, sizeof(char_u *) * NSUBEXP); } @@ -5538,7 +5556,7 @@ static void save_subexpr(regbehind_T *bp) if (REG_MULTI) { bp->save_start[i].se_u.pos = reg_startpos[i]; bp->save_end[i].se_u.pos = reg_endpos[i]; - } else { + } else { bp->save_start[i].se_u.ptr = reg_startp[i]; bp->save_end[i].se_u.ptr = reg_endp[i]; } @@ -5560,7 +5578,7 @@ static void restore_subexpr(regbehind_T *bp) if (REG_MULTI) { reg_startpos[i] = bp->save_start[i].se_u.pos; reg_endpos[i] = bp->save_end[i].se_u.pos; - } else { + } else { reg_startp[i] = bp->save_start[i].se_u.ptr; reg_endp[i] = bp->save_end[i].se_u.ptr; } @@ -5571,7 +5589,8 @@ static void restore_subexpr(regbehind_T *bp) /* * Advance reglnum, regline and reginput to the next line. */ -static void reg_nextline(void) { +static void reg_nextline(void) +{ regline = reg_getline(++reglnum); reginput = regline; fast_breakcheck(); @@ -5759,11 +5778,11 @@ static void regdump(char_u *pattern, bt_regprog_T *r) /* Two ints */ fprintf(f, " minval %ld, maxval %ld", OPERAND_MIN(s), OPERAND_MAX(s)); s += 8; - } else if (op == BEHIND || op == NOBEHIND) { + } else if (op == BEHIND || op == NOBEHIND) { /* one int */ fprintf(f, " count %ld", OPERAND_MIN(s)); s += 4; - } else if (op == RE_LNUM || op == RE_COL || op == RE_VCOL) { + } else if (op == RE_LNUM || op == RE_COL || op == RE_VCOL) { /* one int plus comperator */ fprintf(f, " count %ld", OPERAND_MIN(s)); s += 5; @@ -6246,7 +6265,7 @@ static void mb_decompose(int c, int *c1, int *c2, int *c3) *c1 = d.a; *c2 = d.b; *c3 = d.c; - } else { + } else { *c1 = c; *c2 = *c3 = 0; } @@ -6450,7 +6469,7 @@ char_u *regtilde(char_u *source, int magic) else STRMOVE(p, p + 2); /* remove '\~' */ --p; - } else { + } else { if (*p == '\\' && p[1]) /* skip escaped characters */ ++p; if (has_mbyte) @@ -6555,7 +6574,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in vim_free(eval_result); eval_result = NULL; } - } else { + } else { win_T *save_reg_win; int save_ireg_ic; @@ -6626,9 +6645,9 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in if (*src == '&' && !magic) { ++src; no = 0; - } else if ('0' <= *src && *src <= '9') { + } else if ('0' <= *src && *src <= '9') { no = *src++ - '0'; - } else if (vim_strchr((char_u *)"uUlLeE", *src)) { + } else if (vim_strchr((char_u *)"uUlLeE", *src)) { switch (*src++) { case 'u': func_one = (fptr_T)do_upper; continue; @@ -6651,7 +6670,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in *dst++ = c; *dst++ = *src++; *dst++ = *src++; - } else { + } else { dst += 3; src += 2; } @@ -6712,7 +6731,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in } else if (copy) *dst = cc; dst++; - } else { + } else { if (REG_MULTI) { clnum = reg_mmatch->startpos[no].lnum; if (clnum < 0 || reg_mmatch->endpos[no].lnum < 0) @@ -6725,7 +6744,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in else len = (int)STRLEN(s); } - } else { + } else { s = reg_match->startp[no]; if (reg_match->endp[no] == NULL) s = NULL; @@ -6748,11 +6767,11 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in len = (int)STRLEN(s); } else break; - } else if (*s == NUL) { /* we hit NUL. */ + } else if (*s == NUL) { /* we hit NUL. */ if (copy) EMSG(_(e_re_damg)); goto exit; - } else { + } else { if (backslash && (*s == CAR || *s == '\\')) { /* * Insert a backslash in front of a CR, otherwise @@ -6765,7 +6784,7 @@ static int vim_regsub_both(char_u *source, char_u *dest, int copy, int magic, in dst[1] = *s; } dst += 2; - } else { + } else { if (has_mbyte) c = mb_ptr2char(s); else @@ -6874,7 +6893,7 @@ char_u *reg_submatch(int no) if (round == 2) vim_strncpy(retval, s, len); ++len; - } else { + } else { /* Multiple lines: take start line from start col, middle * lines completely and end line up to end col. */ len = (int)STRLEN(s); @@ -6908,7 +6927,7 @@ char_u *reg_submatch(int no) return NULL; } } - } else { + } else { s = submatch_match->startp[no]; if (s == NULL || submatch_match->endp[no] == NULL) retval = NULL; @@ -6998,7 +7017,7 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags) EMSG3("New regexp mode selected (%d): %s", regexp_engine, regname[newengine]); #endif - } else { + } else { EMSG(_( "E864: \\%#= can only be followed by 0, 1, or 2. The automatic engine will be used ")); regexp_engine = AUTOMATIC_ENGINE; diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index e8d0398059..7f4fb487f0 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -542,7 +542,8 @@ static char_u *nfa_get_match_text(nfa_state_T *start) * Allocate more space for post_start. Called when * running above the estimated number of states. */ -static int realloc_post_list(void) { +static int realloc_post_list(void) +{ int nstate_max = (int)(post_end - post_start); int new_max = nstate_max + 1000; int *new_start; @@ -603,7 +604,7 @@ static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) if (*(p + 2) == '9') { config |= CLASS_o9; break; - } else if (*(p + 2) == '7') { + } else if (*(p + 2) == '7') { config |= CLASS_o7; break; } @@ -611,7 +612,7 @@ static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) if (*(p + 2) == 'z') { config |= CLASS_az; break; - } else if (*(p + 2) == 'f') { + } else if (*(p + 2) == 'f') { config |= CLASS_af; break; } @@ -619,7 +620,7 @@ static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) if (*(p + 2) == 'Z') { config |= CLASS_AZ; break; - } else if (*(p + 2) == 'F') { + } else if (*(p + 2) == 'F') { config |= CLASS_AF; break; } @@ -628,13 +629,13 @@ static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) return FAIL; } p += 3; - } else if (p + 1 < end && *p == '\\' && *(p + 1) == 'n') { + } else if (p + 1 < end && *p == '\\' && *(p + 1) == 'n') { newl = TRUE; p += 2; - } else if (*p == '_') { + } else if (*p == '_') { config |= CLASS_underscore; p++; - } else if (*p == '\n') { + } else if (*p == '\n') { newl = TRUE; p++; } else @@ -1056,7 +1057,8 @@ static int nfa_emit_equi_class(int c) * or \%( pattern \) * or \z( pattern \) */ -static int nfa_regatom(void) { +static int nfa_regatom(void) +{ int c; int charclass; int equiclass; @@ -1392,7 +1394,7 @@ static int nfa_regatom(void) { cmp == '>' ? NFA_VCOL_GT : NFA_VCOL); EMIT(n); break; - } else if (c == '\'' && n == 0) { + } else if (c == '\'' && n == 0) { /* \%'m \%<'m \%>'m */ EMIT(cmp == '<' ? NFA_MARK_LT : cmp == '>' ? NFA_MARK_GT : NFA_MARK); @@ -1583,7 +1585,7 @@ collection: startc = coll_get_char(); got_coll_char = TRUE; mb_ptr_back(old_regparse, regparse); - } else { + } else { /* \r,\t,\e,\b */ startc = backslash_trans(*regparse); } @@ -1620,7 +1622,7 @@ collection: EMIT(c); EMIT(NFA_CONCAT); } - } else { + } else { /* Emit the range. "startc" was already emitted, so * skip it. */ for (c = startc + 1; c <= endc; c++) { @@ -1630,7 +1632,7 @@ collection: } emit_range = FALSE; startc = -1; - } else { + } else { /* This char (startc) is not part of a range. Just * emit it. * Normally, simply emit startc. But if we get char @@ -1644,7 +1646,7 @@ collection: * range. */ if (!negated) extra = NFA_ADD_NL; - } else { + } else { if (got_coll_char == TRUE && startc == 0) EMIT(0x0a); else @@ -1714,7 +1716,7 @@ nfa_do_multibyte: } EMIT(NFA_COMPOSING); regparse = old_regparse + plen; - } else { + } else { c = no_Magic(c); EMIT(c); } @@ -1735,7 +1737,8 @@ nfa_do_multibyte: * piece ::= atom * or atom multi */ -static int nfa_regpiece(void) { +static int nfa_regpiece(void) +{ int i; int op; int ret; @@ -1926,7 +1929,8 @@ static int nfa_regpiece(void) { * or piece piece piece * etc. */ -static int nfa_regconcat(void) { +static int nfa_regconcat(void) +{ int cont = TRUE; int first = TRUE; @@ -1998,7 +2002,8 @@ static int nfa_regconcat(void) { * or concat \& concat \& concat * etc. */ -static int nfa_regbranch(void) { +static int nfa_regbranch(void) +{ int ch; int old_post_pos; @@ -2053,7 +2058,7 @@ nfa_reg ( if (regnpar >= NSUBEXP) /* Too many `(' */ EMSG_RET_FAIL(_("E872: (NFA regexp) Too many '('")); parno = regnpar++; - } else if (paren == REG_ZPAREN) { + } else if (paren == REG_ZPAREN) { /* Make a ZOPEN node. */ if (regnzpar >= NSUBEXP) EMSG_RET_FAIL(_("E879: (NFA regexp) Too many \\z(")); @@ -2076,7 +2081,7 @@ nfa_reg ( EMSG2_RET_FAIL(_(e_unmatchedpp), reg_magic == MAGIC_ALL); else EMSG2_RET_FAIL(_(e_unmatchedp), reg_magic == MAGIC_ALL); - } else if (paren == REG_NOPAREN && peekchr() != NUL) { + } else if (paren == REG_NOPAREN && peekchr() != NUL) { if (peekchr() == Magic(')')) EMSG2_RET_FAIL(_(e_unmatchedpar), reg_magic == MAGIC_ALL); else @@ -2447,7 +2452,8 @@ static void nfa_dump(nfa_regprog_T *prog) * Parse r.e. @expr and convert it into postfix form. * Return the postfix string on success, NULL otherwise. */ -static int *re2post(void) { +static int *re2post(void) +{ if (nfa_reg(REG_NOPAREN) == FAIL) return NULL; EMIT(NFA_MOPEN); @@ -3128,7 +3134,7 @@ static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size) s1->out= skip; patch(e.out, zend); PUSH(frag(s, list1(&skip->out))); - } else { + } else { patch(e.out, s1); PUSH(frag(s, list1(&s1->out))); if (before) { @@ -3373,7 +3379,7 @@ static void nfa_postprocess(nfa_regprog_T *prog) directly = FALSE; else directly = ch_follows * 10 < ch_invisible; - } else { + } else { /* normal invisible, first do the one with the * highest failure chance */ directly = ch_follows < ch_invisible; @@ -3593,7 +3599,7 @@ static void copy_ze_off(regsub_T *to, regsub_T *from) if (REG_MULTI) { if (from->list.multi[0].end.lnum >= 0) to->list.multi[0].end = from->list.multi[0].end; - } else { + } else { if (from->list.line[0].end != NULL) to->list.line[0].end = from->list.line[0].end; } @@ -3629,7 +3635,7 @@ static int sub_equal(regsub_T *sub1, regsub_T *sub2) != sub2->list.multi[i].start.col) return FALSE; } - } else { + } else { for (i = 0; i < todo; ++i) { if (i < sub1->in_use) sp1 = sub1->list.line[i].start; @@ -4025,10 +4031,10 @@ skip_add: if (state->c == NFA_ZSTART) { subidx = 0; sub = &subs->norm; - } else if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) { + } else if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) { subidx = state->c - NFA_ZOPEN; sub = &subs->synt; - } else { + } else { subidx = state->c - NFA_MOPEN; sub = &subs->norm; } @@ -4044,7 +4050,7 @@ skip_add: if (subidx < sub->in_use) { save_lpos = sub->list.multi[subidx].start; save_in_use = -1; - } else { + } else { save_in_use = sub->in_use; for (i = sub->in_use; i < subidx; ++i) { sub->list.multi[i].start.lnum = -1; @@ -4055,16 +4061,16 @@ skip_add: if (off == -1) { sub->list.multi[subidx].start.lnum = reglnum + 1; sub->list.multi[subidx].start.col = 0; - } else { + } else { sub->list.multi[subidx].start.lnum = reglnum; sub->list.multi[subidx].start.col = (colnr_T)(reginput - regline + off); } - } else { + } else { if (subidx < sub->in_use) { save_ptr = sub->list.line[subidx].start; save_in_use = -1; - } else { + } else { save_in_use = sub->in_use; for (i = sub->in_use; i < subidx; ++i) { sub->list.line[i].start = NULL; @@ -4122,10 +4128,10 @@ skip_add: if (state->c == NFA_ZEND) { subidx = 0; sub = &subs->norm; - } else if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) { + } else if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) { subidx = state->c - NFA_ZCLOSE; sub = &subs->synt; - } else { + } else { subidx = state->c - NFA_MCLOSE; sub = &subs->norm; } @@ -4140,14 +4146,14 @@ skip_add: if (off == -1) { sub->list.multi[subidx].end.lnum = reglnum + 1; sub->list.multi[subidx].end.col = 0; - } else { + } else { sub->list.multi[subidx].end.lnum = reglnum; sub->list.multi[subidx].end.col = (colnr_T)(reginput - regline + off); } /* avoid compiler warnings */ save_ptr = NULL; - } else { + } else { save_ptr = sub->list.line[subidx].end; sub->list.line[subidx].end = reginput + off; /* avoid compiler warnings */ @@ -4205,7 +4211,7 @@ addstate_here ( if (count == 1) { /* overwrite the current state */ l->t[listidx] = l->t[l->n - 1]; - } else if (count > 1) { + } else if (count > 1) { if (l->n + count - 1 >= l->len) { /* not enough space to move the new states, reallocate the list * and move the states to the right position */ @@ -4226,7 +4232,7 @@ addstate_here ( sizeof(nfa_thread_T) * (l->n - count - listidx - 1)); vim_free(l->t); l->t = newl; - } else { + } else { /* make space for new states, then move them from the * end to the current position */ mch_memmove(&(l->t[listidx + count]), @@ -4353,7 +4359,7 @@ retempty: *bytelen = len; return TRUE; } - } else { + } else { if (match_with_backref( sub->list.multi[subidx].start.lnum, sub->list.multi[subidx].start.col, @@ -4362,7 +4368,7 @@ retempty: bytelen) == RA_MATCH) return TRUE; } - } else { + } else { if (sub->list.line[subidx].start == NULL || sub->list.line[subidx].end == NULL) goto retempty; @@ -4492,7 +4498,7 @@ static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T endpos.se_u.pos.lnum = reglnum; } else endpos.se_u.pos = pim->end.pos; - } else { + } else { if (pim == NULL) endpos.se_u.ptr = reginput; else @@ -4511,7 +4517,7 @@ static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T regline = reg_getline(++reglnum); } reginput = regline; - } else { + } else { if (REG_MULTI && (int)(reginput - regline) < state->val) { /* Not enough bytes in this line, go to end of * previous line. */ @@ -4552,7 +4558,7 @@ static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T nfa_save_listids(prog, *listids); need_restore = TRUE; /* any value of nfa_listid will do */ - } else { + } else { /* First recursive nfa_regmatch() call, switch to the second lastlist * entry. Make sure nfa_listid is different from a previous recursive * call, because some states may still have this ID. */ @@ -4589,7 +4595,7 @@ static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T fprintf(log_fd, "FINISHED RUNNING nfa_regmatch() recursively\n"); fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : "FALSE"); fprintf(log_fd, "****************************\n"); - } else { + } else { EMSG(_( "Could not open temporary log file for writing, displaying on stderr ... ")); log_fd = stderr; @@ -4814,7 +4820,7 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text) reg_startpos[0].col = col; reg_endpos[0].lnum = reglnum; reg_endpos[0].col = col + len2; - } else { + } else { reg_startp[0] = regline + col; reg_endp[0] = regline + col + len2; } @@ -4890,7 +4896,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm fprintf(log_fd, " RUNNING nfa_regmatch() starting with state %d, code %s\n", abs(start->id), code); fprintf(log_fd, "**********************************\n"); - } else { + } else { EMSG(_( "Could not open temporary log file for writing, displaying on stderr ... ")); log_fd = stderr; @@ -4937,7 +4943,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm if (has_mbyte) { curc = (*mb_ptr2char)(reginput); clen = (*mb_ptr2len)(reginput); - } else { + } else { curc = *reginput; clen = 1; } @@ -5145,7 +5151,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm add_state = t->state->out1->out; } m->norm.in_use = in_use; - } else { + } else { nfa_pim_T pim; /* @@ -5248,12 +5254,12 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm * position */ add_here = TRUE; add_state = t->state->out1->out->out; - } else if (bytelen <= clen) { + } else if (bytelen <= clen) { /* match current character, output of corresponding * NFA_END_PATTERN to be used at next position. */ add_state = t->state->out1->out->out; add_off = clen; - } else { + } else { /* skip over the matched characters, set character * count in NFA_SKIP */ add_state = t->state->out1->out; @@ -5415,7 +5421,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm * at the start of the next line. */ add_state = t->state->out; add_off = -1; - } else if (curc == '\n' && reg_line_lbr) { + } else if (curc == '\n' && reg_line_lbr) { /* match \n as if it is an ordinary character */ add_state = t->state->out; add_off = 1; @@ -5676,7 +5682,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm if (t->state->c <= NFA_BACKREF9) { subidx = t->state->c - NFA_BACKREF1 + 1; result = match_backref(&t->subs.norm, subidx, &bytelen); - } else { + } else { subidx = t->state->c - NFA_ZREF1 + 1; result = match_zref(subidx, &bytelen); } @@ -5687,12 +5693,12 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm * used next */ add_here = TRUE; add_state = t->state->out->out; - } else if (bytelen <= clen) { + } else if (bytelen <= clen) { /* match current character, jump ahead to out of * NFA_SKIP */ add_state = t->state->out->out; add_off = clen; - } else { + } else { /* skip over the matched characters, set character * count in NFA_SKIP */ add_state = t->state->out; @@ -5708,7 +5714,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm /* end of match, go to what follows */ add_state = t->state->out; add_off = clen; - } else { + } else { /* add state again with decremented count */ add_state = t->state; add_off = 0; @@ -5880,7 +5886,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm if (nfa_has_zsubexpr) copy_sub_off(&pim->subs.synt, &m->synt); } - } else { + } else { result = (pim->result == NFA_PIM_MATCH); #ifdef ENABLE_LOG fprintf(log_fd, "\n"); @@ -5975,7 +5981,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm col - ((colnr_T)(reginput - regline) + clen)); #endif reginput = regline + col - clen; - } else { + } else { /* Checking if the required start character matches is * cheaper than adding a state that won't match. */ c = PTR2CHAR(reginput + clen); @@ -6102,7 +6108,7 @@ static long nfa_regtry(nfa_regprog_T *prog, colnr_T col) } else /* Use line number of "\ze". */ reglnum = reg_endpos[0].lnum; - } else { + } else { for (i = 0; i < subs.norm.in_use; i++) { reg_startp[i] = subs.norm.list.line[i].start; reg_endp[i] = subs.norm.list.line[i].end; @@ -6131,7 +6137,7 @@ static long nfa_regtry(nfa_regprog_T *prog, colnr_T col) vim_strnsave(reg_getline(mpos->start.lnum) + mpos->start.col, mpos->end.col - mpos->start.col); - } else { + } else { struct linepos *lpos = &subs.synt.list.line[i]; if (lpos->start != NULL && lpos->end != NULL) @@ -6167,7 +6173,7 @@ nfa_regexec_both ( line = reg_getline((linenr_T)0); /* relative to the cursor */ reg_startpos = reg_mmatch->startpos; reg_endpos = reg_mmatch->endpos; - } else { + } else { prog = (nfa_regprog_T *)reg_match->regprog; reg_startp = reg_match->startp; reg_endp = reg_match->endp; diff --git a/src/screen.c b/src/screen.c index caaf0550f8..11238995c0 100644 --- a/src/screen.c +++ b/src/screen.c @@ -215,7 +215,8 @@ void redraw_win_later(win_T *wp, int type) * Force a complete redraw later. Also resets the highlighting. To be used * after executing a shell command that messes up the screen. */ -void redraw_later_clear(void) { +void redraw_later_clear(void) +{ redraw_all_later(CLEAR); /* Use attributes that is very unlikely to appear in text. */ screen_attr = HL_BOLD | HL_UNDERLINE | HL_INVERSE; @@ -483,7 +484,7 @@ void update_screen(int type) && wp->w_topline == wp->w_lines[0].wl_lnum) { wp->w_upd_rows = msg_scrolled - W_WINROW(wp); wp->w_redr_type = REDRAW_TOP; - } else { + } else { wp->w_redr_type = NOT_VALID; if (W_WINROW(wp) + wp->w_height + W_STATUS_HEIGHT(wp) <= msg_scrolled) @@ -637,7 +638,8 @@ int conceal_cursor_line(win_T *wp) /* * Check if the cursor line needs to be redrawn because of 'concealcursor'. */ -void conceal_check_cursur_line(void) { +void conceal_check_cursur_line(void) +{ if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin)) { need_cursor_line_redraw = TRUE; /* Need to recompute cursor column, e.g., when starting Visual mode @@ -770,15 +772,14 @@ static void win_update(win_T *wp) if (wp->w_nrwidth != i) { type = NOT_VALID; wp->w_nrwidth = i; - } else if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != - 0) { + } else if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0) { /* * When there are both inserted/deleted lines and specific lines to be * redrawn, w_redraw_top and w_redraw_bot may be invalid, just redraw * everything (only happens when redrawing is off for while). */ type = NOT_VALID; - } else { + } else { /* * Set mod_top to the first line that needs displaying because of * changes. Set mod_bot to the first line after the changes. @@ -987,7 +988,7 @@ static void win_update(win_T *wp) mid_start = 0; /* redraw all lines */ } else mid_start = 0; /* redraw all lines */ - } else { + } else { /* * New topline is at or below old topline: May scroll up. * When topline didn't change, find first entry in w_lines[] that @@ -1009,7 +1010,7 @@ static void win_update(win_T *wp) /* if wp->w_topline is not in wp->w_lines[].wl_lnum redraw all * lines */ mid_start = 0; - } else { + } else { /* * Try to delete the correct number of lines. * wp->w_topline is at wp->w_lines[i].wl_lnum. @@ -1088,7 +1089,7 @@ static void win_update(win_T *wp) * NOT_VALID, need to reset it here to avoid redrawing twice. */ if (screen_cleared == TRUE) must_redraw = 0; - } else { + } else { /* Not VALID or INVERTED: redraw all lines. */ mid_start = 0; mid_end = wp->w_height; @@ -1118,7 +1119,7 @@ static void win_update(win_T *wp) if (curwin->w_cursor.lnum < VIsual.lnum) { from = curwin->w_cursor.lnum; to = VIsual.lnum; - } else { + } else { from = VIsual.lnum; to = curwin->w_cursor.lnum; } @@ -1131,7 +1132,7 @@ static void win_update(win_T *wp) from = wp->w_old_visual_lnum; if (wp->w_old_visual_lnum > to) to = wp->w_old_visual_lnum; - } else { + } else { /* * Find the line numbers that need to be updated: The lines * between the old cursor position and the current cursor @@ -1140,7 +1141,7 @@ static void win_update(win_T *wp) if (curwin->w_cursor.lnum < wp->w_old_cursor_lnum) { from = curwin->w_cursor.lnum; to = wp->w_old_cursor_lnum; - } else { + } else { from = wp->w_old_cursor_lnum; to = curwin->w_cursor.lnum; if (from == 0) /* Visual mode just started */ @@ -1184,12 +1185,12 @@ static void win_update(win_T *wp) wp->w_old_cursor_fcol = fromc; wp->w_old_cursor_lcol = toc; } - } else { + } else { /* Use the line numbers of the old Visual area. */ if (wp->w_old_cursor_lnum < wp->w_old_visual_lnum) { from = wp->w_old_cursor_lnum; to = wp->w_old_visual_lnum; - } else { + } else { from = wp->w_old_visual_lnum; to = wp->w_old_cursor_lnum; } @@ -1260,7 +1261,7 @@ static void win_update(win_T *wp) wp->w_old_visual_lnum = VIsual.lnum; wp->w_old_visual_col = VIsual.col; wp->w_old_curswant = curwin->w_curswant; - } else { + } else { wp->w_old_visual_mode = 0; wp->w_old_cursor_lnum = 0; wp->w_old_visual_lnum = 0; @@ -1369,7 +1370,7 @@ static void win_update(win_T *wp) * need to redraw until the end of the window. * Inserting/deleting lines has no use. */ bot_start = 0; - } else { + } else { /* Able to count old number of rows: Count new window * rows, and may insert/delete lines */ j = idx; @@ -1404,7 +1405,7 @@ static void win_update(win_T *wp) else bot_start = wp->w_height + xtra_rows; } - } else if (xtra_rows > 0) { + } else if (xtra_rows > 0) { /* May scroll text down. If there is not enough * remaining text of scrolling fails, must redraw the * rest. */ @@ -1447,7 +1448,7 @@ static void win_update(win_T *wp) } if (bot_start > x) bot_start = x; - } else { /* j > i */ + } else { /* j > i */ /* move entries in w_lines[] downwards */ j -= i; wp->w_lines_valid += j; @@ -1492,7 +1493,7 @@ static void win_update(win_T *wp) /* This line is not going to fit. Don't draw anything here, * will draw "@ " lines below. */ row = wp->w_height + 1; - } else { + } else { prepare_search_hl(wp, lnum); /* Let the syntax stuff know we skipped a few lines. */ if (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum @@ -1523,7 +1524,7 @@ static void win_update(win_T *wp) wp->w_lines[idx].wl_size = row - srow; ++idx; lnum += fold_count + 1; - } else { + } else { /* This line does not need updating, advance to the next one */ row += wp->w_lines[idx++].wl_size; if (row > wp->w_height) /* past end of screen */ @@ -1564,11 +1565,11 @@ static void win_update(win_T *wp) * Don't overwrite it, it can be edited. */ wp->w_botline = lnum + 1; - } else if (diff_check_fill(wp, lnum) >= wp->w_height - srow) { + } else if (diff_check_fill(wp, lnum) >= wp->w_height - srow) { /* Window ends in filler lines. */ wp->w_botline = lnum; wp->w_filler_rows = wp->w_height - srow; - } else if (dy_flags & DY_LASTLINE) { /* 'display' has "lastline" */ + } else if (dy_flags & DY_LASTLINE) { /* 'display' has "lastline" */ /* * Last line isn't finished: Display "@@@" at the end. */ @@ -1578,11 +1579,11 @@ static void win_update(win_T *wp) '@', '@', hl_attr(HLF_AT)); set_empty_rows(wp, srow); wp->w_botline = lnum; - } else { + } else { win_draw_end(wp, '@', ' ', srow, wp->w_height, HLF_AT); wp->w_botline = lnum; } - } else { + } else { draw_vsep_win(wp, row); if (eof) { /* we hit the end of the file */ wp->w_botline = buf->b_ml.ml_line_count + 1; @@ -1676,7 +1677,7 @@ static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T h screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow, W_ENDCOL(wp) - 1 - FDC_OFF, W_ENDCOL(wp) - FDC_OFF, c1, c2, hl_attr(hl)); - } else { + } else { if (cmdwin_type != 0 && wp == curwin) { /* draw the cmdline character in the leftmost column */ n = 1; @@ -1866,7 +1867,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T if (*p < 0x80 && u8cc[0] == 0) { ScreenLinesUC[idx] = 0; prev_c = u8c; - } else { + } else { if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c)) { /* Do Arabic shaping. */ int pc, pc1, nc; @@ -1880,7 +1881,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T pc1 = prev_c1; nc = utf_ptr2char(p + c_len); prev_c1 = u8cc[0]; - } else { + } else { pc = utfc_ptr2char(p + c_len, pcc); nc = prev_c; pc1 = pcc[0]; @@ -1917,7 +1918,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T idx += cells; p += c_len; } - } else { + } else { len = (int)STRLEN(text); if (len > W_WIDTH(wp) - col) len = W_WIDTH(wp) - col; @@ -1958,7 +1959,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T /* Visual is after curwin->w_cursor */ top = &curwin->w_cursor; bot = &VIsual; - } else { + } else { /* Visual is before curwin->w_cursor */ top = &VIsual; bot = &curwin->w_cursor; @@ -1986,7 +1987,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T RL_MEMSET(wp->w_old_cursor_fcol + txtcol, hl_attr(HLF_V), len - (int)wp->w_old_cursor_fcol); } - } else { + } else { /* Set all attributes of the text */ RL_MEMSET(txtcol, hl_attr(HLF_V), W_WIDTH(wp) - txtcol); } @@ -2304,7 +2305,7 @@ win_line ( if (ltoreq(curwin->w_cursor, VIsual)) { top = &curwin->w_cursor; bot = &VIsual; - } else { /* Visual is before curwin->w_cursor */ + } else { /* Visual is before curwin->w_cursor */ top = &VIsual; bot = &curwin->w_cursor; } @@ -2314,7 +2315,7 @@ win_line ( fromcol = wp->w_old_cursor_fcol; tocol = wp->w_old_cursor_lcol; } - } else { /* non-block mode */ + } else { /* non-block mode */ if (lnum > top->lnum && lnum <= bot->lnum) fromcol = 0; else if (lnum == top->lnum) { @@ -2423,7 +2424,7 @@ win_line ( /* No next line or it is empty. */ nextlinecol = MAXCOL; nextline_idx = 0; - } else { + } else { v = (long)STRLEN(line); if (v < SPWORDLEN) { /* Short line, use it completely and append the start of the @@ -2432,7 +2433,7 @@ win_line ( mch_memmove(nextline, line, (size_t)v); STRMOVE(nextline + v, nextline + SPWORDLEN); nextline_idx = v + 1; - } else { + } else { /* Long line, use only the last SPWORDLEN bytes. */ nextlinecol = v - SPWORDLEN; mch_memmove(nextline, line + nextlinecol, SPWORDLEN); @@ -2526,7 +2527,7 @@ win_line ( * word */ spell_hlf = HLF_COUNT; word_end = (int)(spell_to_word_end(ptr, wp) - line + 1); - } else { + } else { /* bad word found, use attributes until end of word */ word_end = wp->w_cursor.col + len + 1; @@ -2813,7 +2814,7 @@ win_line ( && v >= (long)shl->startcol && v < (long)shl->endcol) { shl->attr_cur = shl->attr; - } else if (v == (long)shl->endcol) { + } else if (v == (long)shl->endcol) { shl->attr_cur = 0; next_search_hl(wp, shl, lnum, (colnr_T)v); @@ -2926,7 +2927,7 @@ win_line ( c = 0xc0; } else mb_utf8 = FALSE; - } else { + } else { c = *p_extra; if (has_mbyte) { mb_c = c; @@ -2942,7 +2943,7 @@ win_line ( mb_utf8 = TRUE; c = 0xc0; } - } else { + } else { /* if this is a DBCS character, put it in "mb_c" */ mb_l = MB_BYTE2LEN(c); if (mb_l >= n_extra) @@ -2968,7 +2969,7 @@ win_line ( * character at the start of the next line. */ ++n_extra; --p_extra; - } else { + } else { n_extra -= mb_l - 1; p_extra += mb_l - 1; } @@ -2976,7 +2977,7 @@ win_line ( ++p_extra; } --n_extra; - } else { + } else { /* * Get a character from the line itself. */ @@ -3060,7 +3061,7 @@ win_line ( pc1 = prev_c1; nc = utf_ptr2char(ptr + mb_l); prev_c1 = u8cc[0]; - } else { + } else { pc = utfc_ptr2char(ptr + mb_l, pcc); nc = prev_c; pc1 = pcc[0]; @@ -3070,7 +3071,7 @@ win_line ( mb_c = arabic_shape(mb_c, &c, &u8cc[0], pc, pc1, nc); } else prev_c = mb_c; - } else { /* enc_dbcs */ + } else { /* enc_dbcs */ mb_l = MB_BYTE2LEN(c); if (mb_l == 0) /* at the NUL at end-of-line */ mb_l = 1; @@ -3085,7 +3086,7 @@ win_line ( /* head byte at end of line */ mb_l = 1; transchar_nonprint(extra, c); - } else { + } else { /* illegal tail byte */ mb_l = 2; STRCPY(extra, "XX"); @@ -3341,7 +3342,7 @@ win_line ( u8cc[0] = 0; c = 0xc0; } - } else { + } else { c_extra = ' '; c = ' '; } @@ -3398,7 +3399,7 @@ win_line ( c = 0xc0; } else mb_utf8 = FALSE; /* don't draw as UTF-8 */ - } else if (c != NUL) { + } else if (c != NUL) { p_extra = transchar(c); if ((dy_flags & DY_UHEX) && wp->w_p_rl) rl_mirror(p_extra); /* reverse "<12>" */ @@ -3479,14 +3480,14 @@ win_line ( if (wp->w_p_rl) { col -= n_extra; boguscols -= n_extra; - } else { + } else { boguscols += n_extra; col += n_extra; } } n_extra = 0; n_attr = 0; - } else if (n_skip == 0) { + } else if (n_skip == 0) { is_concealing = TRUE; n_skip = 1; } @@ -3497,7 +3498,7 @@ win_line ( c = 0xc0; } else mb_utf8 = FALSE; /* don't draw as UTF-8 */ - } else { + } else { prev_syntax_id = 0; is_concealing = FALSE; } @@ -3603,7 +3604,7 @@ win_line ( if (wp->w_p_rl) { if (col < 0) n = 1; - } else { + } else { if (col >= W_WIDTH(wp)) n = -1; } @@ -3612,7 +3613,7 @@ win_line ( * instead (better than nothing). */ off += n; col += n; - } else { + } else { /* Add a blank character to highlight. */ ScreenLines[off] = ' '; if (enc_utf8) @@ -3643,7 +3644,7 @@ win_line ( if (wp->w_p_rl) { --col; --off; - } else { + } else { ++col; ++off; } @@ -3776,7 +3777,7 @@ win_line ( && lnum != wp->w_cursor.lnum) { vcol_save_attr = char_attr; char_attr = hl_combine_attr(char_attr, hl_attr(HLF_CUC)); - } else if (draw_color_col && VCOL_HLC == *color_cols) { + } else if (draw_color_col && VCOL_HLC == *color_cols) { vcol_save_attr = char_attr; char_attr = hl_combine_attr(char_attr, hl_attr(HLF_MC)); } @@ -3801,7 +3802,7 @@ win_line ( if ((mb_c & 0xff00) == 0x8e00) ScreenLines[off] = 0x8e; ScreenLines2[off] = mb_c & 0xff; - } else if (enc_utf8) { + } else if (enc_utf8) { if (mb_utf8) { int i; @@ -3846,11 +3847,11 @@ win_line ( if (wp->w_p_rl) { --off; --col; - } else { + } else { ++off; ++col; } - } else if (wp->w_p_cole > 0 && is_concealing) { + } else if (wp->w_p_cole > 0 && is_concealing) { --n_skip; ++vcol_off; if (n_extra > 0) @@ -3874,7 +3875,7 @@ win_line ( if (wp->w_p_rl) { col -= n_extra; boguscols -= n_extra; - } else { + } else { col += n_extra; boguscols += n_extra; } @@ -3888,7 +3889,7 @@ win_line ( if (wp->w_p_rl) { --boguscols; --col; - } else { + } else { ++boguscols; ++col; } @@ -3897,11 +3898,11 @@ win_line ( if (wp->w_p_rl) { --boguscols; --col; - } else { + } else { ++boguscols; ++col; } - } else { + } else { if (n_extra > 0) { vcol += n_extra; n_extra = 0; @@ -4387,7 +4388,8 @@ void rl_mirror(char_u *str) /* * mark all status lines for redraw; used after first :cd */ -void status_redraw_all(void) { +void status_redraw_all(void) +{ win_T *wp; for (wp = firstwin; wp; wp = wp->w_next) @@ -4400,7 +4402,8 @@ void status_redraw_all(void) { /* * mark all status lines of the current buffer for redraw */ -void status_redraw_curbuf(void) { +void status_redraw_curbuf(void) +{ win_T *wp; for (wp = firstwin; wp; wp = wp->w_next) @@ -4413,7 +4416,8 @@ void status_redraw_curbuf(void) { /* * Redraw all status lines that need to be redrawn. */ -void redraw_statuslines(void) { +void redraw_statuslines(void) +{ win_T *wp; for (wp = firstwin; wp; wp = wp->w_next) @@ -4433,7 +4437,7 @@ void win_redraw_last_status(frame_T *frp) else if (frp->fr_layout == FR_ROW) { for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) win_redraw_last_status(frp); - } else { /* frp->fr_layout == FR_COL */ + } else { /* frp->fr_layout == FR_COL */ frp = frp->fr_child; while (frp->fr_next != NULL) frp = frp->fr_next; @@ -4560,7 +4564,7 @@ win_redr_status_matches ( /* jumping left, as far as we can go */ first_match = match; add_left = TRUE; - } else { + } else { /* check if match fits on the screen */ for (i = first_match; i < match; ++i) clen += status_match_len(xp, L_MATCH(i)) + 2; @@ -4593,7 +4597,7 @@ win_redr_status_matches ( if (first_match == 0) { *buf = NUL; len = 0; - } else { + } else { STRCPY(buf, "< "); len = 2; } @@ -4623,7 +4627,7 @@ win_redr_status_matches ( STRNCPY(buf + len, s, l); s += l - 1; len += l; - } else { + } else { STRCPY(buf + len, transchar_byte(*s)); len += (int)STRLEN(buf + len); } @@ -4654,12 +4658,12 @@ win_redr_status_matches ( if (cmdline_row == Rows - 1) { screen_del_lines(0, 0, 1, (int)Rows, TRUE, NULL); ++msg_scrolled; - } else { + } else { ++cmdline_row; ++row; } wild_menu_showing = WM_SCROLLED; - } else { + } else { /* Create status line if needed by setting 'laststatus' to 2. * Set 'winminheight' to zero to avoid that the window is * resized. */ @@ -4719,10 +4723,10 @@ void win_redr_status(win_T *wp) ) { /* Don't redraw right now, do it later. */ wp->w_redr_status = TRUE; - } else if (*p_stl != NUL || *wp->w_p_stl != NUL) { + } else if (*p_stl != NUL || *wp->w_p_stl != NUL) { /* redraw custom status line */ redraw_custom_statusline(wp); - } else { + } else { fillchar = fillchar_status(&attr, wp == curwin); get_trans_bufname(wp->w_buffer); @@ -4757,7 +4761,7 @@ void win_redr_status(win_T *wp) if (this_ru_col <= 1) { p = (char_u *)"<"; /* No room for file name! */ len = 1; - } else if (has_mbyte) { + } else if (has_mbyte) { int clen = 0, i; /* Count total number of display cells. */ @@ -4775,7 +4779,7 @@ void win_redr_status(win_T *wp) ++len; } - } else if (len > this_ru_col - 1) { + } else if (len > this_ru_col - 1) { p += len - (this_ru_col - 1); *p = '<'; len = this_ru_col - 1; @@ -4851,7 +4855,7 @@ int stl_connected(win_T *wp) if (fr->fr_parent->fr_layout == FR_COL) { if (fr->fr_next != NULL) break; - } else { + } else { if (fr->fr_next != NULL) return TRUE; } @@ -4949,7 +4953,7 @@ win_redr_custom ( attr = hl_attr(HLF_TPF); maxwidth = Columns; use_sandbox = was_set_insecurely((char_u *)"tabline", 0); - } else { + } else { row = W_WINROW(wp) + wp->w_height; fillchar = fillchar_status(&attr, wp == curwin); maxwidth = W_WIDTH(wp); @@ -4978,7 +4982,7 @@ win_redr_custom ( } use_sandbox = was_set_insecurely((char_u *)"rulerformat", 0); - } else { + } else { if (*wp->w_p_stl != NUL) stl = wp->w_p_stl; else @@ -5104,7 +5108,7 @@ void screen_getbytes(int row, int col, char_u *bytes, int *attrp) bytes[0] = ScreenLines[off]; bytes[1] = ScreenLines2[off]; bytes[2] = NUL; - } else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1) { + } else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1) { bytes[1] = ScreenLines[off + 1]; bytes[2] = NUL; } @@ -5220,7 +5224,7 @@ void screen_puts_len(char_u *text, int len, int row, int col, int attr) /* Past end of string to be displayed. */ nc = NUL; nc1 = NUL; - } else { + } else { nc = utfc_ptr2char_len(ptr + mbyte_blen, pcc, (int)((text + len) - ptr - mbyte_blen)); nc1 = pcc[0]; @@ -5321,11 +5325,11 @@ void screen_puts_len(char_u *text, int len, int row, int col, int attr) ScreenAttrs[off + 1] = attr; } screen_char(off, row, col); - } else if (mbyte_cells == 2) { + } else if (mbyte_cells == 2) { ScreenLines[off + 1] = ptr[1]; ScreenAttrs[off + 1] = attr; screen_char_2(off, row, col); - } else if (enc_dbcs == DBCS_JPNU && c == 0x8e) { + } else if (enc_dbcs == DBCS_JPNU && c == 0x8e) { ScreenLines2[off] = ptr[1]; screen_char(off, row, col); } else @@ -5337,7 +5341,7 @@ void screen_puts_len(char_u *text, int len, int row, int col, int attr) ptr += mbyte_blen; if (clear_next_cell) ptr = (char_u *)" "; - } else { + } else { ++off; ++col; ++ptr; @@ -5357,7 +5361,8 @@ void screen_puts_len(char_u *text, int len, int row, int col, int attr) /* * Prepare for 'hlsearch' highlighting. */ -static void start_search_hl(void) { +static void start_search_hl(void) +{ if (p_hls && !no_hlsearch) { last_pat_prog(&search_hl.rm); search_hl.attr = hl_attr(HLF_L); @@ -5369,7 +5374,8 @@ static void start_search_hl(void) { /* * Clean up for 'hlsearch' highlighting. */ -static void end_search_hl(void) { +static void end_search_hl(void) +{ if (search_hl.rm.regprog != NULL) { vim_regfree(search_hl.rm.regprog); search_hl.rm.regprog = NULL; @@ -5447,7 +5453,7 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum) + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum; n = shl->rm.endpos[0].col; - } else { + } else { ++shl->first_lnum; n = 0; } @@ -5604,7 +5610,7 @@ static void screen_start_highlight(int attr) term_fg_color(aep->ae_u.cterm.fg_color - 1); if (aep->ae_u.cterm.bg_color) term_bg_color(aep->ae_u.cterm.bg_color - 1); - } else { + } else { if (aep->ae_u.term.start != NULL) out_str(aep->ae_u.term.start); } @@ -5613,7 +5619,8 @@ static void screen_start_highlight(int attr) } } -void screen_stop_highlight(void) { +void screen_stop_highlight(void) +{ int do_ME = FALSE; /* output T_ME code */ if (screen_attr != 0 @@ -5630,7 +5637,7 @@ void screen_stop_highlight(void) { if (aep != NULL && (aep->ae_u.cterm.fg_color || aep->ae_u.cterm.bg_color)) do_ME = TRUE; - } else { + } else { aep = syn_term_attr2entry(screen_attr); if (aep != NULL && aep->ae_u.term.stop != NULL) { if (STRCMP(aep->ae_u.term.stop, T_ME) == 0) @@ -5688,7 +5695,8 @@ void screen_stop_highlight(void) { * Reset the colors for a cterm. Used when leaving Vim. * The machine specific code may override this again. */ -void reset_cterm_colors(void) { +void reset_cterm_colors(void) +{ if (t_colors > 1) { /* set Normal cterm colors */ if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0) { @@ -5750,7 +5758,7 @@ static void screen_char(unsigned off, int row, int col) out_str(buf); if (utf_char2cells(ScreenLinesUC[off]) > 1) ++screen_cur_col; - } else { + } else { out_flush_check(); out_char(ScreenLines[off]); /* double-byte character in single-width cell */ @@ -5811,7 +5819,7 @@ void screen_draw_rectangle(int row, int col, int height, int width, int invert) if (enc_dbcs != 0 && dbcs_off2cells(off + c, max_off) > 1) { screen_char_2(off + c, r, c); ++c; - } else { + } else { screen_char(off + c, r, c); if (utf_off2cells(off + c, max_off) > 1) ++c; @@ -5833,7 +5841,7 @@ static void redraw_block(int row, int end, win_T *wp) if (wp == NULL) { col = 0; width = Columns; - } else { + } else { col = wp->w_wincol; width = wp->w_width; } @@ -6173,7 +6181,7 @@ give_up: new_LineWraps = NULL; vim_free(new_TabPageIdxs); new_TabPageIdxs = NULL; - } else { + } else { done_outofmem_msg = FALSE; for (new_row = 0; new_row < Rows; ++new_row) { @@ -6278,7 +6286,8 @@ give_up: } } -void free_screenlines(void) { +void free_screenlines(void) +{ int i; vim_free(ScreenLinesUC); @@ -6292,13 +6301,15 @@ void free_screenlines(void) { vim_free(TabPageIdxs); } -void screenclear(void) { +void screenclear(void) +{ check_for_delay(FALSE); screenalloc(FALSE); /* allocate screen buffers if size changed */ screenclear2(); /* clear the screen */ } -static void screenclear2(void) { +static void screenclear2(void) +{ int i; if (starting == NO_SCREEN || ScreenLines == NULL @@ -6319,7 +6330,7 @@ static void screenclear2(void) { out_str(T_CL); /* clear the display */ clear_cmdline = FALSE; mode_displayed = FALSE; - } else { + } else { /* can't clear the screen, mark all chars with invalid attributes */ for (i = 0; i < Rows; ++i) lineinvalid(LineOffset[i], (int)Columns); @@ -6404,7 +6415,8 @@ int can_clear(char_u *p) * something directly to the screen (shell commands) or a terminal control * code. */ -void screen_start(void) { +void screen_start(void) +{ screen_cur_row = screen_cur_col = 9999; } @@ -6486,7 +6498,7 @@ void windgoto(int row, int col) plan = PLAN_CR; wouldbe_col = 0; cost = 1; /* CR is just one character */ - } else { + } else { plan = PLAN_LE; wouldbe_col = col; } @@ -6564,12 +6576,12 @@ void windgoto(int row, int col) out_str(bs); --screen_cur_col; } - } else if (plan == PLAN_CR) { + } else if (plan == PLAN_CR) { if (noinvcurs) screen_stop_highlight(); out_char('\r'); screen_cur_col = 0; - } else if (plan == PLAN_NL) { + } else if (plan == PLAN_NL) { if (noinvcurs) screen_stop_highlight(); while (screen_cur_row < row) { @@ -6589,7 +6601,7 @@ void windgoto(int row, int col) if (T_ND[0] != NUL && T_ND[1] == NUL) { while (i-- > 0) out_char(*T_ND); - } else { + } else { int off; off = LineOffset[row] + screen_cur_col; @@ -6626,7 +6638,8 @@ void windgoto(int row, int col) /* * Set cursor to its position in the current window. */ -void setcursor(void) { +void setcursor(void) +{ if (redrawing()) { validate_cursor(); windgoto(W_WINROW(curwin) + curwin->w_wrow, @@ -6980,7 +6993,7 @@ screen_ins_lines ( else lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width); LineWraps[j] = FALSE; - } else { + } else { j = end - 1 - i; temp = LineOffset[j]; while ((j -= line_count) >= row) { @@ -7005,7 +7018,7 @@ screen_ins_lines ( else if (type == USE_T_CAL) { term_append_lines(line_count); screen_start(); /* don't know where cursor is now */ - } else { + } else { for (i = 0; i < line_count; i++) { if (type == USE_T_AL) { if (i && cursor_row != 0) @@ -7121,7 +7134,7 @@ screen_del_lines ( if (*T_CCS != NUL) { /* cursor relative to region */ cursor_row = row; cursor_end = end; - } else { + } else { cursor_row = row + off; cursor_end = end + off; } @@ -7144,7 +7157,7 @@ screen_del_lines ( else lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width); LineWraps[j] = FALSE; - } else { + } else { /* whole width, moving the line pointers is faster */ j = row + i; temp = LineOffset[j]; @@ -7166,11 +7179,11 @@ screen_del_lines ( /* redraw the characters */ if (type == USE_REDRAW) redraw_block(row, end, wp); - else if (type == USE_T_CD) { /* delete the lines */ + else if (type == USE_T_CD) { /* delete the lines */ windgoto(cursor_row, 0); out_str(T_CD); screen_start(); /* don't know where cursor is now */ - } else if (type == USE_T_CDL) { + } else if (type == USE_T_CDL) { windgoto(cursor_row, 0); term_delete_lines(line_count); screen_start(); /* don't know where cursor is now */ @@ -7184,12 +7197,12 @@ screen_del_lines ( windgoto(cursor_end - 1, 0); for (i = line_count; --i >= 0; ) out_char('\n'); /* cursor will remain on same line */ - } else { + } else { for (i = line_count; --i >= 0; ) { if (type == USE_T_DL) { windgoto(cursor_row, 0); out_str(T_DL); /* delete a line */ - } else { /* type == USE_T_CE */ + } else { /* type == USE_T_CE */ windgoto(cursor_row + i, 0); out_str(T_CE); /* erase a line */ } @@ -7221,7 +7234,8 @@ screen_del_lines ( * cleared only if a mode is shown. * Return the length of the message (0 if no message). */ -int showmode(void) { +int showmode(void) +{ int need_clear; int length = 0; int do_mode; @@ -7285,7 +7299,7 @@ int showmode(void) { } } length = 0; - } else { + } else { if (State & VREPLACE_FLAG) MSG_PUTS_ATTR(_(" VREPLACE"), attr); else if (State & REPLACE_FLAG) @@ -7372,7 +7386,8 @@ int showmode(void) { /* * Position for a mode message. */ -static void msg_pos_mode(void) { +static void msg_pos_mode(void) +{ msg_col = 0; msg_row = Rows - 1; } @@ -7400,7 +7415,8 @@ void unshowmode(int force) /* * Draw the tab pages line at the top of the Vim window. */ -static void draw_tabline(void) { +static void draw_tabline(void) +{ int tabcount = 0; tabpage_T *tp; int tabwidth; @@ -7444,7 +7460,7 @@ static void draw_tabline(void) { set_string_option_direct((char_u *)"tabline", -1, (char_u *)"", OPT_FREE, SID_ERROR); called_emsg |= save_called_emsg; - } else { + } else { for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) ++tabcount; @@ -7472,7 +7488,7 @@ static void draw_tabline(void) { if (tp == curtab) { cwp = curwin; wp = firstwin; - } else { + } else { cwp = tp->tp_curwin; wp = tp->tp_firstwin; } @@ -7509,7 +7525,7 @@ static void draw_tabline(void) { len -= ptr2cells(p); mb_ptr_adv(p); } - else if (len > room) { + else if (len > room) { p += len - room; len = room; } @@ -7568,7 +7584,7 @@ static int fillchar_status(int *attr, int is_curwin) if (is_curwin) { *attr = hl_attr(HLF_S); fill = fill_stl; - } else { + } else { *attr = hl_attr(HLF_SNC); fill = fill_stlnc; } @@ -7600,7 +7616,8 @@ static int fillchar_vsep(int *attr) /* * Return TRUE if redrawing should currently be done. */ -int redrawing(void) { +int redrawing(void) +{ return !RedrawingDisabled && !(p_lz && char_avail() && !KeyTyped && !do_redraw); } @@ -7608,7 +7625,8 @@ int redrawing(void) { /* * Return TRUE if printing messages should currently be done. */ -int messaging(void) { +int messaging(void) +{ return !(p_lz && char_avail() && !KeyTyped); } @@ -7717,7 +7735,7 @@ static void win_redr_ruler(win_T *wp, int always) fillchar = fillchar_status(&attr, wp == curwin); off = W_WINCOL(wp); width = W_WIDTH(wp); - } else { + } else { row = Rows - 1; fillchar = ' '; attr = 0; @@ -7842,7 +7860,8 @@ int number_width(win_T *wp) * Return the current cursor column. This is the actual position on the * screen. First column is 0. */ -int screen_screencol(void) { +int screen_screencol(void) +{ return screen_cur_col; } @@ -7850,7 +7869,8 @@ int screen_screencol(void) { * Return the current cursor row. This is the actual position on the screen. * First row is 0. */ -int screen_screenrow(void) { +int screen_screenrow(void) +{ return screen_cur_row; } diff --git a/src/search.c b/src/search.c index 16b56e2a0d..c6365aedc0 100644 --- a/src/search.c +++ b/src/search.c @@ -218,7 +218,8 @@ search_regcomp ( /* * Get search pattern used by search_regcomp(). */ -char_u *get_search_pat(void) { +char_u *get_search_pat(void) +{ return mr_pattern; } @@ -277,7 +278,8 @@ static void save_re_pat(int idx, char_u *pat, int magic) */ static int save_level = 0; -void save_search_patterns(void) { +void save_search_patterns(void) +{ if (save_level++ == 0) { saved_spats[0] = spats[0]; if (spats[0].pat != NULL) @@ -290,7 +292,8 @@ void save_search_patterns(void) { } } -void restore_search_patterns(void) { +void restore_search_patterns(void) +{ if (--save_level == 0) { vim_free(spats[0].pat); spats[0] = saved_spats[0]; @@ -303,7 +306,8 @@ void restore_search_patterns(void) { } #if defined(EXITFREE) || defined(PROTO) -void free_search_patterns(void) { +void free_search_patterns(void) +{ vim_free(spats[0].pat); vim_free(spats[1].pat); @@ -347,7 +351,7 @@ int pat_has_uppercase(char_u *pat) if (enc_utf8 && utf_isupper(utf_ptr2char(p))) return TRUE; p += l; - } else if (*p == '\\') { + } else if (*p == '\\') { if (p[1] == '_' && p[2] != NUL) /* skip "\_X" */ p += 3; else if (p[1] == '%' && p[2] != NUL) /* skip "\%X" */ @@ -364,14 +368,16 @@ int pat_has_uppercase(char_u *pat) return FALSE; } -char_u *last_search_pat(void) { +char_u *last_search_pat(void) +{ return spats[last_idx].pat; } /* * Reset search direction to forward. For "gd" and "gD" commands. */ -void reset_search_dir(void) { +void reset_search_dir(void) +{ spats[0].off.dir = '/'; set_vv_searchforward(); } @@ -604,7 +610,7 @@ proftime_T *tm; /* timeout limit or NULL */ else ++matchcol; } - } else { + } else { matchcol = matchpos.col; if (ptr[matchcol] != NUL) { if (has_mbyte) @@ -693,7 +699,7 @@ proftime_T *tm; /* timeout limit or NULL */ else ++matchcol; } - } else { + } else { /* Stop when the match is in a next line. */ if (matchpos.lnum > 0) break; @@ -743,7 +749,7 @@ proftime_T *tm; /* timeout limit or NULL */ pos->col = (colnr_T)STRLEN(ml_get_buf(buf, pos->lnum, FALSE)); } - } else { + } else { --pos->col; if (has_mbyte && pos->lnum <= buf->b_ml.ml_line_count) { @@ -751,7 +757,7 @@ proftime_T *tm; /* timeout limit or NULL */ pos->col -= (*mb_head_off)(ptr, ptr + pos->col); } } - } else { + } else { pos->lnum = lnum + matchpos.lnum; pos->col = matchpos.col; } @@ -849,7 +855,8 @@ void set_search_direction(int cdir) spats[0].off.dir = cdir; } -static void set_vv_searchforward(void) { +static void set_vv_searchforward(void) +{ set_vim_var_nr(VV_SEARCHFORWARD, (long)(spats[0].off.dir == '/')); } @@ -947,7 +954,7 @@ proftime_T *tm; /* timeout limit or NULL */ if (dirc == '/') { if (hasFolding(pos.lnum, NULL, &pos.lnum)) pos.col = MAXCOL - 2; /* avoid overflow when adding 1 */ - } else { + } else { if (hasFolding(pos.lnum, &pos.lnum, NULL)) pos.col = 0; } @@ -976,7 +983,7 @@ proftime_T *tm; /* timeout limit or NULL */ goto end_do_search; } searchstr = pat; - } else { + } else { /* make search_regcomp() use spats[RE_SEARCH].pat */ searchstr = (char_u *)""; } @@ -1115,7 +1122,7 @@ proftime_T *tm; /* timeout limit or NULL */ pos.lnum = 0; /* allow lnum == 0 here */ pos.col = MAXCOL; } - } else { + } else { for (c = spats[0].off.off; c; ++c) if (incl(&pos) == -1) break; @@ -1164,7 +1171,7 @@ proftime_T *tm; /* timeout limit or NULL */ pos.col = 0; retval = 2; /* pattern found, line offset added */ - } else if (pos.col < MAXCOL - 2) { /* just in case */ + } else if (pos.col < MAXCOL - 2) { /* just in case */ /* to the right, check for end of file */ c = spats[0].off.off; if (c > 0) { @@ -1238,16 +1245,16 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, int dir, char_u *pat) pos->lnum = buf->b_ml.ml_line_count; if (!shortmess(SHM_SEARCH)) give_warning((char_u *)_(top_bot_msg), TRUE); - } else { + } else { pos->lnum = 1; break; } - } else if (pos->lnum > buf->b_ml.ml_line_count) { + } else if (pos->lnum > buf->b_ml.ml_line_count) { if (p_ws) { pos->lnum = 1; if (!shortmess(SHM_SEARCH)) give_warning((char_u *)_(bot_top_msg), TRUE); - } else { + } else { pos->lnum = 1; break; } @@ -1266,7 +1273,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, int dir, char_u *pat) && !(compl_cont_status & CONT_SOL)) { if ((p_ic ? MB_STRICMP(p, pat) : STRCMP(p, pat)) == 0) return OK; - } else if (*p != NUL) { /* ignore empty lines */ + } else if (*p != NUL) { /* ignore empty lines */ /* expanding lines or words */ if ((p_ic ? MB_STRNICMP(p, pat, compl_length) : STRNCMP(p, pat, compl_length)) == 0) @@ -1313,7 +1320,7 @@ int searchc(cmdarg_T *cap, int t_cmd) bytelen += (*mb_char2bytes)(cap->ncharC2, bytes + bytelen); } } - } else { /* repeat previous search */ + } else { /* repeat previous search */ if (lastc == NUL) return FAIL; if (dir) /* repeat in opposite direction */ @@ -1347,7 +1354,7 @@ int searchc(cmdarg_T *cap, int t_cmd) col += (*mb_ptr2len)(p + col); if (col >= len) return FAIL; - } else { + } else { if (col == 0) return FAIL; col -= (*mb_head_off)(p, p + col - 1) + 1; @@ -1355,13 +1362,13 @@ int searchc(cmdarg_T *cap, int t_cmd) if (bytelen == 1) { if (p[col] == c && stop) break; - } else { + } else { if (vim_memcmp(p + col, bytes, bytelen) == 0 && stop) break; } stop = TRUE; } - } else { + } else { for (;; ) { if ((col += dir) < 0 || col >= len) return FAIL; @@ -1490,7 +1497,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) ignore_cend = TRUE; backwards = (dir == FORWARD) ? FALSE : TRUE; initc = NUL; - } else if (initc != '#' && initc != NUL) { + } else if (initc != '#' && initc != NUL) { find_mps_values(&initc, &findc, &backwards, TRUE); if (findc == NUL) return NULL; @@ -1502,7 +1509,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) else { if (initc == '#') { hash_dir = dir; - } else { + } else { /* * initc was not given, must look for something to match under * or near the cursor. @@ -1524,16 +1531,16 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) comment_dir = FORWARD; backwards = FALSE; pos.col++; - } else if (pos.col > 0 && linep[pos.col - 1] == '*') { + } else if (pos.col > 0 && linep[pos.col - 1] == '*') { comment_dir = BACKWARD; backwards = TRUE; pos.col--; } - } else if (linep[pos.col] == '*') { + } else if (linep[pos.col] == '*') { if (linep[pos.col + 1] == '/') { comment_dir = BACKWARD; backwards = TRUE; - } else if (pos.col > 0 && linep[pos.col - 1] == '/') { + } else if (pos.col > 0 && linep[pos.col - 1] == '/') { comment_dir = FORWARD; backwards = FALSE; } @@ -1568,7 +1575,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) hash_dir = 1; else return NULL; - } else if (!cpo_bsl) { + } else if (!cpo_bsl) { int col, bslcnt = 0; /* Set "match_escaped" if there are an odd number of @@ -1615,17 +1622,17 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) else if (STRNCMP(ptr, "el", 2) == 0) { if (count == 0) return &pos; - } else if (STRNCMP(ptr, "endif", 5) == 0) { + } else if (STRNCMP(ptr, "endif", 5) == 0) { if (count == 0) return &pos; count--; } - } else { + } else { if (STRNCMP(ptr, "if", 2) == 0) { if (count == 0) return &pos; count--; - } else if (initc == '#' && STRNCMP(ptr, "el", 2) == 0) { + } else if (initc == '#' && STRNCMP(ptr, "el", 2) == 0) { if (count == 0) return &pos; } else if (STRNCMP(ptr, "endif", 5) == 0) @@ -1682,12 +1689,12 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) /* skip comment */ if (lisp && comment_col != MAXCOL) pos.col = comment_col; - } else { + } else { --pos.col; if (has_mbyte) pos.col -= (*mb_head_off)(linep, linep + pos.col); } - } else { /* forward search */ + } else { /* forward search */ if (linep[pos.col] == NUL /* at end of line, go to next one */ /* don't search for match in comment */ @@ -1711,7 +1718,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) line_breakcheck(); if (lisp) /* find comment pos in new line */ comment_col = check_linecomment(linep); - } else { + } else { if (has_mbyte) pos.col += (*mb_ptr2len)(linep + pos.col); else @@ -1737,7 +1744,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) pos.col++; return &pos; } - } else { /* Searching backwards */ + } else { /* Searching backwards */ /* * A comment may contain / * or / /, it may also start or end * with / * /. Ignore a / * after / /. @@ -1750,7 +1757,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) count++; match_pos = pos; match_pos.col--; - } else if (linep[pos.col - 1] == '*' && linep[pos.col] == '/') { + } else if (linep[pos.col - 1] == '*' && linep[pos.col] == '/') { if (count > 0) pos = match_pos; else if (pos.col > 1 && linep[pos.col - 2] == '/' @@ -1882,12 +1889,12 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) break; } } - } else if (linep[pos.col + 1]) { /* forward search */ + } else if (linep[pos.col + 1]) { /* forward search */ if (linep[pos.col + 1] == '\\' && linep[pos.col + 2] && linep[pos.col + 3] == '\'') { pos.col += 3; break; - } else if (linep[pos.col + 2] == '\'') { + } else if (linep[pos.col + 2] == '\'') { pos.col += 2; break; } @@ -2326,7 +2333,8 @@ static int cls_bigword; /* TRUE for "W", "B" or "E" */ * from class 2 and higher are reported as class 1 since only white space * boundaries are of interest. */ -static int cls(void) { +static int cls(void) +{ int c; c = gchar_cursor(); @@ -2512,7 +2520,7 @@ int end_word(long count, int bigword, int stop, int empty) */ if (skip_chars(sclass, FORWARD)) return FAIL; - } else if (!stop || sclass == 0) { + } else if (!stop || sclass == 0) { /* * We were at the end of a word. Go to the end of the next word. * First skip white space, if 'empty' is TRUE, stop at empty line. @@ -2599,7 +2607,8 @@ static int skip_chars(int cclass, int dir) /* * Go back to the start of the word or the start of white space */ -static void back_in_line(void) { +static void back_in_line(void) +{ int sclass; /* starting class */ sclass = cls(); @@ -2689,7 +2698,7 @@ current_word ( if ((cls() == 0) == include) { if (end_word(1L, bigword, TRUE, TRUE) == FAIL) return FAIL; - } else { + } else { /* * If the start is not on white space, and white space should be * included ("word "), or start is on white space and white @@ -2711,7 +2720,7 @@ current_word ( /* should do something when inclusive == FALSE ! */ VIsual = start_pos; redraw_curbuf_later(INVERTED); /* update the inversion */ - } else { + } else { oap->start = start_pos; oap->motion_type = MCHAR; } @@ -2732,12 +2741,12 @@ current_word ( if (include != (cls() != 0)) { if (bck_word(1L, bigword, TRUE) == FAIL) return FAIL; - } else { + } else { if (bckend_word(1L, bigword, TRUE) == FAIL) return FAIL; (void)incl(&curwin->w_cursor); } - } else { + } else { /* * Move cursor forward one word and/or white area. */ @@ -2753,7 +2762,7 @@ current_word ( */ if (oneleft() == FAIL) inclusive = FALSE; - } else { + } else { if (end_word(1L, bigword, TRUE, TRUE) == FAIL) return FAIL; } @@ -2856,7 +2865,7 @@ extend: findsent(BACKWARD, 1L); at_start_sent = !at_start_sent; } - } else { + } else { /* * Cursor at end of Visual area. * Find out where we are: @@ -2900,7 +2909,7 @@ extend: if (equalpos(pos, curwin->w_cursor)) { start_blank = TRUE; find_first_blank(&start_pos); /* go back to first blank */ - } else { + } else { start_blank = FALSE; findsent(BACKWARD, 1L); start_pos = curwin->w_cursor; @@ -2941,7 +2950,7 @@ extend: VIsual = start_pos; VIsual_mode = 'v'; redraw_curbuf_later(INVERTED); /* update the inversion */ - } else { + } else { /* include a newline after the sentence, if there is one */ if (incl(&curwin->w_cursor) == -1) oap->inclusive = TRUE; @@ -2990,7 +2999,7 @@ current_block ( if (gchar_cursor() == what) /* cursor on '(' or '{', move cursor just after it */ ++curwin->w_cursor.col; - } else if (lt(VIsual, curwin->w_cursor)) { + } else if (lt(VIsual, curwin->w_cursor)) { old_start = VIsual; curwin->w_cursor = VIsual; /* cursor at low end of Visual */ } else @@ -3068,7 +3077,7 @@ current_block ( VIsual_mode = 'v'; redraw_curbuf_later(INVERTED); /* update the inversion */ showmode(); - } else { + } else { oap->start = start_pos; oap->motion_type = MCHAR; oap->inclusive = FALSE; @@ -3115,7 +3124,7 @@ static int in_html_tag(int end_tag) return FALSE; p = lp; } - } else { + } else { for (p = line + curwin->w_cursor.col; p > line; ) { if (*p == '<') /* find '<' under/before cursor */ break; @@ -3200,7 +3209,7 @@ current_tagblock ( while (*ml_get_cursor() != '>') if (inc_cursor() < 0) break; - } else if (in_html_tag(TRUE)) { + } else if (in_html_tag(TRUE)) { /* cursor on end tag, move to just before it */ while (*ml_get_cursor() != '<') if (dec_cursor() < 0) @@ -3208,7 +3217,7 @@ current_tagblock ( dec_cursor(); old_end = curwin->w_cursor; } - } else if (lt(VIsual, curwin->w_cursor)) { + } else if (lt(VIsual, curwin->w_cursor)) { old_start = VIsual; curwin->w_cursor = VIsual; /* cursor at low end of Visual */ } else @@ -3274,7 +3283,7 @@ again: while (*ml_get_cursor() != '>') if (inc_cursor() < 0) break; - } else { + } else { /* Exclude the '<' of the end tag. */ if (*ml_get_cursor() == '<') dec_cursor(); @@ -3313,7 +3322,7 @@ again: VIsual_mode = 'v'; redraw_curbuf_later(INVERTED); /* update the inversion */ showmode(); - } else { + } else { oap->start = start_pos; oap->motion_type = MCHAR; if (lt(end_pos, start_pos)) { @@ -3411,7 +3420,7 @@ extend: if (white_in_front) { /* stop at first white line */ if (!linewhite(start_lnum - 1)) break; - } else { /* stop at first non-white line of start of paragraph */ + } else { /* stop at first non-white line of start of paragraph */ if (linewhite(start_lnum - 1) || startPS(start_lnum, 0, 0)) break; } @@ -3476,7 +3485,7 @@ extend: VIsual_mode = 'V'; redraw_curbuf_later(INVERTED); /* update the inversion */ showmode(); - } else { + } else { oap->start.lnum = start_lnum; oap->start.col = 0; oap->motion_type = MLINE; @@ -3596,7 +3605,7 @@ current_quote ( && line[curwin->w_cursor.col + 1] == quotechar; i = VIsual.col; col_end = curwin->w_cursor.col; - } else { + } else { inside_quotes = curwin->w_cursor.col > 0 && line[curwin->w_cursor.col - 1] == quotechar && line[VIsual.col] != NUL @@ -3629,7 +3638,7 @@ current_quote ( col_end = col_start; col_start = curwin->w_cursor.col; } - } else { + } else { col_end = find_prev_quote(line, col_start, quotechar, NULL); if (line[col_end] != quotechar) return FALSE; @@ -3673,7 +3682,7 @@ current_quote ( break; col_start = col_end + 1; } - } else { + } else { /* Search backward for a starting quote. */ col_start = find_prev_quote(line, col_start, quotechar, curbuf->b_p_qe); if (line[col_start] != quotechar) { @@ -3723,7 +3732,7 @@ current_quote ( VIsual = curwin->w_cursor; redraw_curbuf_later(INVERTED); } - } else { + } else { oap->start = curwin->w_cursor; oap->motion_type = MCHAR; } @@ -3740,7 +3749,7 @@ current_quote ( /* decrement cursor when 'selection' is not exclusive */ if (*p_sel != 'e') dec_cursor(); - } else { + } else { /* Cursor is at start of Visual area. Set the end of the Visual * area when it was just inside quotes or it didn't end at a * quote. */ @@ -3758,7 +3767,7 @@ current_quote ( VIsual_mode = 'v'; redraw_cmdline = TRUE; /* show mode later */ } - } else { + } else { /* Set inclusive and other oap's flags. */ oap->inclusive = inclusive; } @@ -3850,10 +3859,10 @@ current_search ( VIsual = save_VIsual; p_ws = old_p_ws; return FAIL; - } else if (!i && !result) { + } else if (!i && !result) { if (forward) { /* try again from start of buffer */ clearpos(&pos); - } else { /* try again from end of buffer */ + } else { /* try again from end of buffer */ /* searching backwards, so set pos to last line and col */ pos.lnum = curwin->w_buffer->b_ml.ml_line_count; pos.col = (colnr_T)STRLEN( @@ -4129,7 +4138,7 @@ find_pattern_in_path ( /* using "new_fname" is more reliable, e.g., when * 'includeexpr' is set. */ msg_outtrans_attr(new_fname, hl_attr(HLF_D)); - } else { + } else { /* * Isolate the file name. * Include the surrounding "" or <> if present. @@ -4140,7 +4149,7 @@ find_pattern_in_path ( p = incl_regmatch.startp[0]; i = (int)(incl_regmatch.endp[0] - incl_regmatch.startp[0]); - } else { + } else { /* find the file name after the end of the match */ for (p = incl_regmatch.endp[0]; *p && !vim_isfilec(*p); p++) @@ -4223,7 +4232,7 @@ find_pattern_in_path ( _("Scanning included file: %s"), (char *)new_fname); msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R)); - } else if (p_verbose >= 5) { + } else if (p_verbose >= 5) { verbose_enter(); smsg((char_u *)_("Searching included file %s"), (char *)new_fname); @@ -4232,7 +4241,7 @@ find_pattern_in_path ( } } - } else { + } else { /* * Check if the line is a define (type == FIND_DEFINE) */ @@ -4302,7 +4311,7 @@ search_line: if (p[1] == '/') break; ++p; - } else if (!matched && p[0] == '*' && p[1] == '/') { + } else if (!matched && p[0] == '*' && p[1] == '/') { /* Can find match after "* /". */ matched = TRUE; ++p; @@ -4386,7 +4395,7 @@ search_line: dir = FORWARD; else if (add_r == FAIL) break; - } else if (action == ACTION_SHOW_ALL) { + } else if (action == ACTION_SHOW_ALL) { found = TRUE; if (!did_show) gotocmdline(TRUE); /* cursor at status line */ @@ -4409,7 +4418,7 @@ search_line: * include it */ for (i = 0; i <= depth; ++i) files[i].matched = TRUE; - } else if (--count <= 0) { + } else if (--count <= 0) { found = TRUE; if (depth == -1 && lnum == curwin->w_cursor.lnum && g_do_tagpreview == 0 @@ -4420,7 +4429,7 @@ search_line: (depth == -1) ? NULL : files[depth].fp, (depth == -1) ? &lnum : &files[depth].lnum, 1L); did_show = TRUE; - } else { + } else { /* ":psearch" uses the preview window */ if (g_do_tagpreview != 0) { curwin_save = curwin; @@ -4440,7 +4449,7 @@ search_line: } else setpcmark(); curwin->w_cursor.lnum = lnum; - } else { + } else { if (getfile(0, files[depth].name, NULL, TRUE, files[depth].lnum, FALSE) > 0) break; /* failed to jump to file */ @@ -4505,7 +4514,7 @@ exit_matched: line[--i] = NUL; if (i > 0 && line[i - 1] == '\r') line[--i] = NUL; - } else if (!already) { + } else if (!already) { if (++lnum > end_lnum) break; line = ml_get(lnum); @@ -4589,7 +4598,7 @@ static void show_pat_in_path(char_u *line, int type, int did_show, int action, F if (vim_fgets(line, LSIZE, fp)) /* end of file */ break; ++*lnum; - } else { + } else { if (++*lnum > curbuf->b_ml.ml_line_count) break; line = ml_get(*lnum); diff --git a/src/spell.c b/src/spell.c index d403e17b3f..5bb6a70beb 100644 --- a/src/spell.c +++ b/src/spell.c @@ -1251,7 +1251,7 @@ static void find_word(matchinf_T *mip, int mode) if (mode == FIND_KEEPCOMPOUND) /* Skip over the previously found word(s). */ wlen += mip->mi_compoff; - } else { + } else { /* Check for case-folded in case-folded tree. */ ptr = mip->mi_fword; flen = mip->mi_fwordlen; /* available case-folded bytes */ @@ -1262,7 +1262,7 @@ static void find_word(matchinf_T *mip, int mode) /* Skip over the prefix. */ wlen = mip->mi_prefixlen; flen -= mip->mi_prefixlen; - } else if (mode == FIND_COMPOUND) { + } else if (mode == FIND_COMPOUND) { /* Skip over the previously found word(s). */ wlen = mip->mi_compoff; flen -= mip->mi_compoff; @@ -1616,7 +1616,7 @@ static void find_word(matchinf_T *mip, int mode) nobreak_result = mip->mi_result; mip->mi_result = save_result; mip->mi_end = save_end; - } else { + } else { if (mip->mi_result == SP_OK) break; continue; @@ -1646,7 +1646,7 @@ static void find_word(matchinf_T *mip, int mode) } else if (mip->mi_result2 == res && mip->mi_end2 < mip->mi_word + wlen) mip->mi_end2 = mip->mi_word + wlen; - } else if (mip->mi_result > res) { + } else if (mip->mi_result > res) { mip->mi_result = res; mip->mi_end = mip->mi_word + wlen; } else if (mip->mi_result == res && mip->mi_end < mip->mi_word + wlen) @@ -2213,7 +2213,7 @@ spell_move_to ( give_warning((char_u *)_(top_bot_msg), TRUE); } capcol = -1; - } else { + } else { if (lnum < wp->w_buffer->b_ml.ml_line_count) ++lnum; else if (!p_ws) @@ -2337,7 +2337,7 @@ static void spell_load_lang(char_u *lang) smsg((char_u *) _("Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\""), lang, spell_enc(), lang); - } else if (sl.sl_slang != NULL) { + } else if (sl.sl_slang != NULL) { /* At least one file was loaded, now load ALL the additions. */ STRCPY(fname_enc + STRLEN(fname_enc) - 3, "add.spl"); do_in_runtimepath(fname_enc, TRUE, spell_load_cb, &sl); @@ -2348,7 +2348,8 @@ static void spell_load_lang(char_u *lang) * Return the encoding used for spell checking: Use 'encoding', except that we * use "latin1" for "latin9". And limit to 60 characters (just in case). */ -static char_u *spell_enc(void) { +static char_u *spell_enc(void) +{ if (STRLEN(p_enc) < 60 && STRCMP(p_enc, "iso-8859-15") != 0) return p_enc; @@ -2613,7 +2614,7 @@ spell_load_file ( if (c < VIMSPELLVERSION) { EMSG(_("E771: Old spell file, needs to be updated")); goto endFAIL; - } else if (c > VIMSPELLVERSION) { + } else if (c > VIMSPELLVERSION) { EMSG(_("E772: Spell file is for newer version of Vim")); goto endFAIL; } @@ -3148,7 +3149,7 @@ count_common_word ( STRCPY(wc->wc_word, p); wc->wc_count = count; hash_add_item(&lp->sl_wordcount, hi, wc->wc_word, hash); - } else { + } else { wc = HI2WC(hi); if ((wc->wc_count += count) < (unsigned)count) /* check for overflow */ wc->wc_count = MAXWORDCOUNT; @@ -3379,7 +3380,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len) *pp++ = '\\'; *pp++ = '|'; atstart = 1; - } else { /* normal char, "[abc]" and '*' are copied as-is */ + } else { /* normal char, "[abc]" and '*' are copied as-is */ if (c == '?' || c == '+' || c == '~') *pp++ = '\\'; /* "a?" becomes "a\?", "a+" becomes "a\+" */ if (enc_utf8) @@ -3497,7 +3498,7 @@ static int count_syllables(slang_T *slang, char_u *word) if (len != 0) { /* found a match, count syllable */ ++cnt; skip = FALSE; - } else { + } else { /* No recognized syllable item, at least a syllable char then? */ c = mb_ptr2char(p); len = (*mb_ptr2len)(p); @@ -3578,7 +3579,7 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to) /* mapping byte to char is done in sl_sal_first[] */ lp->sl_sal_first[c] = i; } - } else { + } else { /* mapping bytes to bytes is done in sl_sal_first[] */ if (STRLEN(from) != STRLEN(to)) return SP_FORMERROR; @@ -3757,7 +3758,7 @@ read_tree_node ( /* No flags, all regions. */ idxs[idx] = 0; c = 0; - } else if (c != BY_INDEX) { + } else if (c != BY_INDEX) { if (prefixtree) { /* Read the optional pflags byte, the prefix ID and the * condition nr. In idxs[] store the prefix ID in the low @@ -3774,7 +3775,7 @@ read_tree_node ( if (n >= maxprefcondnr) return SP_FORMERROR; c |= (n << 8); - } else { /* c must be BY_FLAGS or BY_FLAGS2 */ + } else { /* c must be BY_FLAGS or BY_FLAGS2 */ /* Read flags and optional region and prefix ID. In * idxs[] the flags go in the low two bytes, region above * that and prefix ID above the region. */ @@ -3790,7 +3791,7 @@ read_tree_node ( idxs[idx] = c; c = 0; - } else { /* c == BY_INDEX */ + } else { /* c == BY_INDEX */ /* <nodeidx> */ n = get3c(fd); if (n < 0 || n >= maxidx) @@ -3901,7 +3902,7 @@ char_u *did_set_spelllang(win_T *wp) for (slang = first_lang; slang != NULL; slang = slang->sl_next) if (fullpathcmp(lang, slang->sl_fname, FALSE) == FPC_SAME) break; - } else { + } else { filename = FALSE; if (len > 3 && lang[len - 3] == '_') { region = lang + len - 2; @@ -3992,7 +3993,7 @@ char_u *did_set_spelllang(win_T *wp) if (int_wordlist == NULL) continue; int_wordlist_spl(spf_name); - } else { + } else { /* One entry in 'spellfile'. */ copy_option_part(&spf, spf_name, MAXPATHL - 5, ","); STRCAT(spf_name, ".spl"); @@ -4267,7 +4268,8 @@ static int badword_captype(char_u *word, char_u *end) /* * Delete the internal wordlist and its .spl file. */ -void spell_delete_wordlist(void) { +void spell_delete_wordlist(void) +{ char_u fname[MAXPATHL]; if (int_wordlist != NULL) { @@ -4282,7 +4284,8 @@ void spell_delete_wordlist(void) { /* * Free all languages. */ -void spell_free_all(void) { +void spell_free_all(void) +{ slang_T *slang; buf_T *buf; @@ -4308,7 +4311,8 @@ void spell_free_all(void) { * Clear all spelling tables and reload them. * Used after 'encoding' is set and when ":mkspell" was used. */ -void spell_reload(void) { +void spell_reload(void) +{ win_T *wp; /* Initialize the table for spell_iswordp(). */ @@ -4664,7 +4668,8 @@ static char line1[PRINTLINESIZE]; static char line2[PRINTLINESIZE]; static char line3[PRINTLINESIZE]; -static void spell_clear_flags(wordnode_T *node) { +static void spell_clear_flags(wordnode_T *node) +{ wordnode_T *np; for (np = node; np != NULL; np = np->wn_sibling) { @@ -4673,7 +4678,8 @@ static void spell_clear_flags(wordnode_T *node) { } } -static void spell_print_node(wordnode_T *node, int depth) { +static void spell_print_node(wordnode_T *node, int depth) +{ if (node->wn_u1.index) { /* Done this node before, print the reference. */ PRINTSOME(line1, depth, "(%d)", node->wn_nr, 0); @@ -4682,7 +4688,7 @@ static void spell_print_node(wordnode_T *node, int depth) { msg(line1); msg(line2); msg(line3); - } else { + } else { node->wn_u1.index = TRUE; if (node->wn_byte != NUL) { @@ -4721,7 +4727,8 @@ static void spell_print_node(wordnode_T *node, int depth) { } } -static void spell_print_tree(wordnode_T *root) { +static void spell_print_tree(wordnode_T *root) +{ if (root != NULL) { /* Clear the "wn_u1.index" fields, used to remember what has been * done. */ @@ -4832,7 +4839,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) continue; } line = pc; - } else { + } else { pc = NULL; line = rline; } @@ -5089,7 +5096,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) if (!cur_aff->ah_follows) smsg((char_u *)_("Duplicate affix in %s line %d: %s"), fname, lnum, items[1]); - } else { + } else { /* New affix letter. */ cur_aff = (affheader_T *)getroom(spin, sizeof(affheader_T), TRUE); @@ -5607,7 +5614,7 @@ static unsigned get_affitem(int flagtype, char_u **pp) return 0; } res = getdigits(pp); - } else { + } else { res = mb_ptr2char_adv(pp); if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG && res >= 'A' && res <= 'Z')) { @@ -5915,7 +5922,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile) continue; } w = pc; - } else { + } else { pc = NULL; w = line; } @@ -6222,7 +6229,7 @@ store_aff_word ( p += STRLEN(ae->ae_chop); } STRCAT(newword, p); - } else { + } else { /* suffix: chop/add at the end of the word */ vim_strncpy(newword, word, MAXWLEN - 1); if (ae->ae_chop != NULL) { @@ -6434,7 +6441,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) continue; } line = pc; - } else { + } else { pc = NULL; line = rline; } @@ -6518,7 +6525,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) break; } regionmask |= 1 << (l - 1); - } else { + } else { smsg((char_u *)_("Unrecognized flags in %s line %d: %s"), fname, lnum, p); break; @@ -6857,7 +6864,8 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int * Check the 'mkspellmem' option. Return FAIL if it's wrong. * Sets "sps_flags". */ -int spell_check_msm(void) { +int spell_check_msm(void) +{ char_u *p = p_msm; long start = 0; long incr = 0; @@ -7580,7 +7588,7 @@ put_node ( } putc(np->wn_affixID, fd); /* <affixID> */ put_bytes(fd, (long_u)np->wn_region, 2); /* <prefcondnr> */ - } else { + } else { /* For word trees we write the flag/region items. */ flags = np->wn_flags; if (regionmask != 0 && np->wn_region != regionmask) @@ -7590,12 +7598,12 @@ put_node ( if (flags == 0) { /* word without flags or region */ putc(BY_NOFLAGS, fd); /* <byte> */ - } else { + } else { if (np->wn_flags >= 0x100) { putc(BY_FLAGS2, fd); /* <byte> */ putc(flags, fd); /* <flags> */ putc((unsigned)flags >> 8, fd); /* <flags2> */ - } else { + } else { putc(BY_FLAGS, fd); /* <byte> */ putc(flags, fd); /* <flags> */ } @@ -7606,7 +7614,7 @@ put_node ( } } } - } else { + } else { if (np->wn_child->wn_u1.index != 0 && np->wn_child->wn_u2.wnode != node) { /* The child is written elsewhere, write the reference. */ @@ -7797,7 +7805,7 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang) --depth; line_breakcheck(); - } else { + } else { /* Do one more byte at this node. */ n = arridx[depth] + curi[depth]; @@ -7829,7 +7837,7 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang) ++n; ++curi[depth]; } - } else { + } else { /* Normal char, go one level deeper. */ tword[depth++] = c; arridx[depth] = idxs[n]; @@ -7928,7 +7936,7 @@ sug_filltable ( * works a lot better. */ p->wn_flags = 0; p->wn_region = 0; - } else { + } else { wordnr = sug_filltable(spin, p->wn_child, wordnr, gap); if (wordnr == -1) return -1; @@ -7999,7 +8007,7 @@ static int bytes2offset(char_u **pp) nr = (c & 0x1f) - 1; nr = nr * 255 + (*p++ - 1); nr = nr * 255 + (*p++ - 1); - } else { /* 4 bytes */ + } else { /* 4 bytes */ nr = (c & 0x0f) - 1; nr = nr * 255 + (*p++ - 1); nr = nr * 255 + (*p++ - 1); @@ -8105,7 +8113,8 @@ theend: * NULL and there is no undo info. * Returns NULL when out of memory. */ -static buf_T *open_spellbuf(void) { +static buf_T *open_spellbuf(void) +{ buf_T *buf; buf = (buf_T *)alloc_clear(sizeof(buf_T)); @@ -8295,7 +8304,7 @@ mkspell ( if (spell_read_dic(&spin, fname, afile[i]) == FAIL) error = TRUE; } - } else { + } else { /* No .aff file, try reading the file as a word list. Store * the words in the trees. */ if (spell_read_wordfile(&spin, innames[i]) == FAIL) @@ -8430,7 +8439,7 @@ spell_add_word ( return; } fname = int_wordlist; - } else { + } else { /* If 'spellfile' isn't set figure out a good default value. */ if (*curwin->w_s->b_p_spf == NUL) { init_spellfile(); @@ -8553,7 +8562,8 @@ spell_add_word ( /* * Initialize 'spellfile' for the current buffer. */ -static void init_spellfile(void) { +static void init_spellfile(void) +{ char_u *buf; int l; char_u *fname; @@ -8660,7 +8670,8 @@ static void clear_spell_chartab(spelltab_T *sp) * characters to make it possible that 'encoding' differs from the current * locale. For utf-8 we don't use isalpha() but our own functions. */ -void init_spell_chartab(void) { +void init_spell_chartab(void) +{ int i; did_set_spelltab = FALSE; @@ -8683,7 +8694,7 @@ void init_spell_chartab(void) { spelltab.st_fold[i] = (f < 256) ? f : i; spelltab.st_upper[i] = (u < 256) ? u : i; } - } else { + } else { /* Rough guess: use locale-dependent library functions. */ for (i = 128; i < 256; ++i) { if (MB_ISUPPER(i)) { @@ -8810,7 +8821,7 @@ static int set_spell_finish(spelltab_T *new_st) return FAIL; } } - } else { + } else { /* copy the new spelltab into the one being used */ spelltab = *new_st; did_set_spelltab = TRUE; @@ -8842,7 +8853,7 @@ spell_iswordp ( /* be quick for ASCII */ if (wp->w_s->b_spell_ismw[*p]) s = p + 1; /* skip a mid-word character */ - } else { + } else { c = mb_ptr2char(p); if (c < 256 ? wp->w_s->b_spell_ismw[c] : (wp->w_s->b_spell_ismw_mb != NULL @@ -8980,7 +8991,7 @@ static int spell_casefold(char_u *str, int len, char_u *buf, int buflen) outi += mb_char2bytes(SPELL_TOFOLD(c), buf + outi); } buf[outi] = NUL; - } else { + } else { /* Be quick for non-multibyte encodings. */ for (i = 0; i < len; ++i) buf[i] = spelltab.st_fold[str[i]]; @@ -9002,7 +9013,8 @@ static int sps_limit = 9999; /* max nr of suggestions given */ * Check the 'spellsuggest' option. Return FAIL if it's wrong. * Sets "sps_flags" and "sps_limit". */ -int spell_check_sps(void) { +int spell_check_sps(void) +{ char_u *p; char_u *s; char_u buf[MAXPATHL]; @@ -9133,7 +9145,7 @@ void spell_suggest(int count) if (count > sug.su_ga.ga_len) smsg((char_u *)_("Sorry, only %ld suggestions"), (long)sug.su_ga.ga_len); - } else { + } else { vim_free(repl_from); repl_from = NULL; vim_free(repl_to); @@ -9226,7 +9238,7 @@ void spell_suggest(int count) sug.su_badlen - stp->st_orglen, sug.su_badptr + stp->st_orglen); repl_to = vim_strsave(IObuff); - } else { + } else { /* Replacing su_badlen or more, use the whole word. */ repl_from = vim_strnsave(sug.su_badptr, stp->st_orglen); repl_to = vim_strsave(stp->st_word); @@ -9725,7 +9737,8 @@ static void spell_suggest_intern(suginfo_T *su, int interactive) /* * Load the .sug files for languages that have one and weren't loaded yet. */ -static void suggest_load_files(void) { +static void suggest_load_files(void) +{ langp_T *lp; int lpi; slang_T *slang; @@ -9875,7 +9888,7 @@ static void tree_count_words(char_u *byts, idx_T *idxs) --depth; fast_breakcheck(); - } else { + } else { /* Do one more byte at this node. */ n = arridx[depth] + curi[depth]; ++curi[depth]; @@ -9891,7 +9904,7 @@ static void tree_count_words(char_u *byts, idx_T *idxs) ++n; ++curi[depth]; } - } else { + } else { /* Normal char, go one level deeper to count the words. */ ++depth; arridx[depth] = idxs[n]; @@ -9986,7 +9999,7 @@ static void allcap_copy(char_u *word, char_u *wcopy) if (d - wcopy >= MAXWLEN - MB_MAXBYTES) break; d += mb_char2bytes(c, d); - } else { + } else { if (d - wcopy >= MAXWLEN - 1) break; *d++ = c; @@ -10148,7 +10161,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou pidxs = NULL; sp->ts_prefixdepth = PFD_NOPREFIX; sp->ts_state = STATE_START; - } else { + } else { /* * When there are postponed prefixes we need to use these first. At * the end of the prefix we continue in the case-fold tree. @@ -10162,7 +10175,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou idxs = pidxs; sp->ts_prefixdepth = PFD_PREFIXTREE; sp->ts_state = STATE_NOPREFIX; /* try without prefix first */ - } else { + } else { byts = fbyts; idxs = fidxs; sp->ts_prefixdepth = PFD_NOPREFIX; @@ -10320,7 +10333,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou lp->lp_sallang, FALSE); break; } - } else { + } else { /* There was a compound word before this word. If this * word does not support compounding then give up * (splitting is tried for the word without compound @@ -10707,7 +10720,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou sp->ts_state = STATE_DEL; else sp->ts_state = STATE_FINAL; - } else { + } else { arridx += sp->ts_curi++; c = byts[arridx]; @@ -10803,7 +10816,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou /* Inserting a composing char doesn't * count that much. */ sp->ts_score -= SCORE_INS - SCORE_INSCOMP; - } else { + } else { /* If the previous character was the same, * thus doubling a character, give a bonus * to the score. Also for the soundfold @@ -10819,7 +10832,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou /* Starting a new char, reset the length. */ sp->ts_tcharlen = 0; } - } else { + } else { /* If we found a similar char adjust the score. * We do this after calling go_deeper() because * it's slow. */ @@ -10878,7 +10891,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP; else if (c == mb_ptr2char(fword + stack[depth].ts_fidx)) stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP; - } else { + } else { ++stack[depth].ts_fidx; if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1]) stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP; @@ -11003,7 +11016,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou c2 = c; /* don't swap non-word char */ else c2 = mb_ptr2char(p + n); - } else { + } else { if (p[1] == NUL) c2 = NUL; else if (!soundfold && !spell_iswordp(p + 1, curwin)) @@ -11038,7 +11051,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou mch_memmove(p, p + n, fl); mb_char2bytes(c, p + fl); stack[depth].ts_fidxtry = sp->ts_fidx + n + fl; - } else { + } else { p[0] = c2; p[1] = c; stack[depth].ts_fidxtry = sp->ts_fidx + 2; @@ -11056,7 +11069,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou c = mb_ptr2char(p + n); mch_memmove(p + MB_BYTE2LEN(p[n]), p, n); mb_char2bytes(c, p); - } else { + } else { c = *p; *p = p[1]; p[1] = c; @@ -11076,7 +11089,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou c3 = c; /* don't swap non-word char */ else c3 = mb_ptr2char(p + n + fl); - } else { + } else { c = *p; c2 = p[1]; if (!soundfold && !spell_iswordp(p + 2, curwin)) @@ -11110,7 +11123,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou mb_char2bytes(c2, p + tl); mb_char2bytes(c, p + fl + tl); stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl; - } else { + } else { p[0] = p[2]; p[2] = c; stack[depth].ts_fidxtry = sp->ts_fidx + 3; @@ -11132,7 +11145,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou mb_char2bytes(c, p); mb_char2bytes(c2, p + tl); p = p + tl; - } else { + } else { c = *p; *p = p[2]; p[2] = c; @@ -11167,7 +11180,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou mch_memmove(p, p + n, fl); mb_char2bytes(c, p + fl); stack[depth].ts_fidxtry = sp->ts_fidx + n + fl; - } else { + } else { c = *p; *p = p[1]; p[1] = p[2]; @@ -11188,7 +11201,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou tl = MB_BYTE2LEN(p[n]); mch_memmove(p + tl, p, n); mb_char2bytes(c, p); - } else { + } else { c = p[2]; p[2] = p[1]; p[1] = *p; @@ -11216,7 +11229,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou mch_memmove(p + tl, p, n); mb_char2bytes(c, p); stack[depth].ts_fidxtry = sp->ts_fidx + n + tl; - } else { + } else { c = p[2]; p[2] = p[1]; p[1] = *p; @@ -11237,7 +11250,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, int sou n += MB_BYTE2LEN(p[tl + n]); mch_memmove(p, p + tl, n); mb_char2bytes(c, p + n); - } else { + } else { c = *p; *p = p[1]; p[1] = p[2]; @@ -11451,7 +11464,7 @@ static void find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword) /* tried both fold-case and upper-case character, continue one * level up */ --depth; - } else { + } else { /* * round[depth] == 1: Try using the folded-case character. * round[depth] == 2: Try using the upper-case character. @@ -11464,7 +11477,7 @@ static void find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword) if (round[depth] == 1) { p = fword + fwordidx[depth]; l = flen; - } else { + } else { p = uword + uwordidx[depth]; l = ulen; } @@ -11504,7 +11517,7 @@ static void find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword) STRNCPY(kword + kwordlen[depth], fword + fwordidx[depth], flen); kwordlen[depth + 1] = kwordlen[depth] + flen; - } else { + } else { STRNCPY(kword + kwordlen[depth], uword + uwordidx[depth], ulen); kwordlen[depth + 1] = kwordlen[depth] + ulen; @@ -11744,7 +11757,8 @@ static sftword_T dumsft; /* * Prepare for calling suggest_try_soundalike(). */ -static void suggest_try_soundalike_prep(void) { +static void suggest_try_soundalike_prep(void) +{ langp_T *lp; int lpi; slang_T *slang; @@ -11791,7 +11805,8 @@ static void suggest_try_soundalike(suginfo_T *su) /* * Finish up after calling suggest_try_soundalike(). */ -static void suggest_try_soundalike_finish(void) { +static void suggest_try_soundalike_finish(void) +{ langp_T *lp; int lpi; slang_T *slang; @@ -11866,7 +11881,7 @@ add_sound_suggest ( STRCPY(sft->sft_word, goodword); hash_add_item(&slang->sl_sounddone, hi, sft->sft_word, hash); } - } else { + } else { sft = HI2SFT(hi); if (score >= sft->sft_score) return; @@ -11942,7 +11957,7 @@ badword: /* Must find the word in the keep-case tree. */ find_keepcap_word(slang, theword, cword); p = cword; - } else { + } else { flags |= su->su_badflags; if ((flags & WF_CAPMASK) != 0) { /* Need to fix case according to "flags". */ @@ -11958,7 +11973,7 @@ badword: if (score <= su->su_maxscore) add_suggestion(su, &su->su_sga, p, su->su_badlen, score, 0, FALSE, slang, FALSE); - } else { + } else { /* Add a penalty for words in another region. */ if ((flags & WF_REGION) && (((unsigned)flags >> 16) & lp->lp_region) == 0) @@ -12579,7 +12594,7 @@ static void spell_soundfold_sofo(slang_T *slang, char_u *inword, char_u *res) prevc = c; } } - } else { + } else { /* The sl_sal_first[] table contains the translation. */ for (s = inword; (c = *s) != NUL; ++s) { if (vim_iswhite(c)) @@ -12620,7 +12635,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) if (vim_iswhite(*s)) { *t++ = ' '; s = skipwhite(s); - } else { + } else { if (spell_iswordp_nmw(s, curwin)) *t++ = *s; ++s; @@ -12791,7 +12806,7 @@ static void spell_soundfold_sal(slang_T *slang, char_u *inword, char_u *res) /* new "actual letter" */ c = word[i]; - } else { + } else { /* no '<' rule used */ i += k - 1; z = 0; @@ -12877,7 +12892,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) continue; c = ' '; did_white = TRUE; - } else { + } else { did_white = FALSE; if (!spell_iswordp_nmw(t, curwin)) continue; @@ -13058,7 +13073,7 @@ static void spell_soundfold_wsal(slang_T *slang, char_u *inword, char_u *res) /* new "actual letter" */ c = word[i]; - } else { + } else { /* no '<' rule used */ i += k - 1; z = 0; @@ -13151,7 +13166,7 @@ soundalike_score ( && goodsound[1] != NUL && badsound[2] == goodsound[2])) { /* handle like a substitute */ - } else { + } else { score = 2 * SCORE_DEL / 3; if (*badsound == '*') ++badsound; @@ -13172,7 +13187,7 @@ soundalike_score ( if (n > 0) { pl = goodsound; /* goodsound is longest */ ps = badsound; - } else { + } else { pl = badsound; /* badsound is longest */ ps = goodsound; } @@ -13358,7 +13373,7 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) for (p = goodword, goodlen = 0; *p != NUL; ) wgoodword[goodlen++] = mb_cptr2char_adv(&p); wgoodword[goodlen++] = 0; - } else { + } else { badlen = (int)STRLEN(badword) + 1; goodlen = (int)STRLEN(goodword) + 1; } @@ -13380,7 +13395,7 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) if (has_mbyte) { bc = wbadword[i - 1]; gc = wgoodword[j - 1]; - } else { + } else { bc = badword[i - 1]; gc = goodword[j - 1]; } @@ -13404,7 +13419,7 @@ static int spell_edit_score(slang_T *slang, char_u *badword, char_u *goodword) if (has_mbyte) { pbc = wbadword[i - 2]; pgc = wgoodword[j - 2]; - } else { + } else { pbc = badword[i - 2]; pgc = goodword[j - 2]; } @@ -13503,7 +13518,7 @@ static int spell_edit_score_limit(slang_T *slang, char_u *badword, char_u *goodw goto pop; /* do next alternative */ } while (goodword[++gi] != NUL); minscore = score; - } else { /* both words continue */ + } else { /* both words continue */ /* If not close to the limit, perform a change. Only try changes * that may lead to a lower score than "minscore". * round 0: try deleting a char from badword @@ -13525,7 +13540,7 @@ static int spell_edit_score_limit(slang_T *slang, char_u *badword, char_u *goodw ++bi2; ++gi2; } - } else { + } else { /* try deleting/inserting a character later */ stack[stackidx].badi = bi + 1 - round; stack[stackidx].goodi = gi + round; @@ -13666,7 +13681,7 @@ static int spell_edit_score_limit_w(slang_T *slang, char_u *badword, char_u *goo goto pop; /* do next alternative */ } while (wgoodword[++gi] != NUL); minscore = score; - } else { /* both words continue */ + } else { /* both words continue */ /* If not close to the limit, perform a change. Only try changes * that may lead to a lower score than "minscore". * round 0: try deleting a char from badword @@ -13688,7 +13703,7 @@ static int spell_edit_score_limit_w(slang_T *slang, char_u *badword, char_u *goo ++bi2; ++gi2; } - } else { + } else { /* try deleting a character from badword later */ stack[stackidx].badi = bi + 1 - round; stack[stackidx].goodi = gi + round; @@ -13921,7 +13936,7 @@ spell_dump_compl ( dumpflags &= ~DUMPFLAG_KEEPCASE; byts = slang->sl_fbyts; idxs = slang->sl_fidxs; - } else { + } else { dumpflags |= DUMPFLAG_KEEPCASE; byts = slang->sl_kbyts; idxs = slang->sl_kidxs; @@ -13939,7 +13954,7 @@ spell_dump_compl ( --depth; line_breakcheck(); ins_compl_check_keys(50); - } else { + } else { /* Do one more byte at this node. */ n = arridx[depth] + curi[depth]; ++curi[depth]; @@ -13975,7 +13990,7 @@ spell_dump_compl ( lnum = dump_prefixes(slang, word, pat, dir, dumpflags, flags, lnum); } - } else { + } else { /* Normal char, go one level deeper. */ word[depth++] = c; arridx[depth] = idxs[n]; @@ -14020,7 +14035,7 @@ static void dump_word(slang_T *slang, char_u *word, char_u *pat, int *dir, int d /* Need to fix case according to "flags". */ make_case_word(word, cword, flags); p = cword; - } else { + } else { p = word; if ((dumpflags & DUMPFLAG_KEEPCASE) && ((captype(word, NULL) & WF_KEEPCAP) == 0 @@ -14125,7 +14140,7 @@ dump_prefixes ( /* Done all bytes at this node, go up one level. */ --depth; line_breakcheck(); - } else { + } else { /* Do one more byte at this node. */ n += curi[depth]; ++curi[depth]; @@ -14163,7 +14178,7 @@ dump_prefixes ( ++lnum; } } - } else { + } else { /* Normal char, go one level deeper. */ prefix[depth++] = c; arridx[depth] = idxs[n]; diff --git a/src/syntax.c b/src/syntax.c index 4e3bac44c1..fc326a8a6f 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -640,7 +640,7 @@ static void clear_syn_state(synstate_T *p) for (i = 0; i < gap->ga_len; i++) unref_extmatch(SYN_STATE_P(gap)[i].bs_extmatch); ga_clear(gap); - } else { + } else { for (i = 0; i < p->sst_stacksize; i++) unref_extmatch(p->sst_union.sst_stack[i].bs_extmatch); } @@ -649,7 +649,8 @@ static void clear_syn_state(synstate_T *p) /* * Cleanup the current_state stack. */ -static void clear_current_state(void) { +static void clear_current_state(void) +{ int i; stateitem_T *sip; @@ -827,7 +828,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid) /* Cannot happen? */ found_flags = 0; found_match_idx = KEYWORD_IDX; - } else { + } else { spp = &(SYN_ITEMS(syn_block)[cur_si->si_idx]); found_flags = spp->sp_flags; found_match_idx = spp->sp_sync_idx; @@ -933,7 +934,8 @@ static int syn_match_linecont(linenr_T lnum) /* * Prepare the current state for the start of a line. */ -static void syn_start_line(void) { +static void syn_start_line(void) +{ current_finished = FALSE; current_col = 0; @@ -1086,7 +1088,8 @@ void syn_stack_free_all(synblock_T *block) * small, reallocate it. * Also used to allocate b_sst_array[] for the first time. */ -static void syn_stack_alloc(void) { +static void syn_stack_alloc(void) +{ long len; synstate_T *to, *from; synstate_T *sstp; @@ -1133,7 +1136,7 @@ static void syn_stack_alloc(void) { to->sst_next = NULL; syn_block->b_sst_first = sstp; syn_block->b_sst_freecount = len - (int)(to - sstp) - 1; - } else { + } else { syn_block->b_sst_first = NULL; syn_block->b_sst_freecount = len; } @@ -1216,7 +1219,8 @@ static void syn_stack_apply_changes_block(synblock_T *block, buf_T *buf) * Reduce the number of entries in the state stack for syn_buf. * Returns TRUE if at least one entry was freed. */ -static int syn_stack_cleanup(void) { +static int syn_stack_cleanup(void) +{ synstate_T *p, *prev; disptick_T tick; int above; @@ -1302,7 +1306,8 @@ static synstate_T *syn_stack_find_entry(linenr_T lnum) * Try saving the current state in b_sst_array[]. * The current state must be valid for the start of the current_lnum line! */ -static synstate_T *store_current_state(void) { +static synstate_T *store_current_state(void) +{ int i; synstate_T *p; bufstate_T *bp; @@ -1362,7 +1367,7 @@ static synstate_T *store_current_state(void) { /* Insert in front of the list */ p->sst_next = syn_block->b_sst_first; syn_block->b_sst_first = p; - } else { + } else { /* insert in list after *sp */ p->sst_next = sp->sst_next; sp->sst_next = p; @@ -1530,14 +1535,16 @@ void syntax_end_parsing(linenr_T lnum) * End of handling of the state stack. ****************************************/ -static void invalidate_current_state(void) { +static void invalidate_current_state(void) +{ clear_current_state(); current_state.ga_itemsize = 0; /* mark current_state invalid */ current_next_list = NULL; keepend_level = -1; } -static void validate_current_state(void) { +static void validate_current_state(void) +{ current_state.ga_itemsize = sizeof(stateitem_T); current_state.ga_growsize = 3; } @@ -1834,7 +1841,7 @@ syn_current_attr ( if (current_state.ga_len < 2) { cur_si->si_attr = 0; cur_si->si_trans_id = 0; - } else { + } else { cur_si->si_attr = CUR_STATE( current_state.ga_len - 2).si_attr; cur_si->si_trans_id = CUR_STATE( @@ -2143,7 +2150,7 @@ syn_current_attr ( sps.cont_in_list = NULL; *can_spell = !in_id_list(sip, sip->si_cont_list, &sps, 0); } - } else { + } else { /* The @Spell cluster is defined: Do spelling in items with * the @Spell cluster. But not when @NoSpell is also there. * At the toplevel only spell check when ":syn spell toplevel" @@ -2264,7 +2271,7 @@ static stateitem_T *push_next_match(stateitem_T *cur_si) /* Try to find the end pattern in the current line */ update_si_end(cur_si, (int)(next_match_m_endpos.col), TRUE); check_keepend(); - } else { + } else { cur_si->si_m_endpos = next_match_m_endpos; cur_si->si_h_endpos = next_match_h_endpos; cur_si->si_ends = TRUE; @@ -2312,7 +2319,8 @@ static stateitem_T *push_next_match(stateitem_T *cur_si) /* * Check for end of current state (and the states before it). */ -static void check_state_ends(void) { +static void check_state_ends(void) +{ stateitem_T *cur_si; int had_extend; @@ -2349,7 +2357,7 @@ static void check_state_ends(void) { next_match_idx = 0; next_match_col = MAXCOL; break; - } else { + } else { /* handle next_list, unless at end of line and no "skipnl" or * "skipempty" */ current_next_list = cur_si->si_next_list; @@ -2437,7 +2445,7 @@ static void update_si_attr(int idx) sip->si_trans_id = 0; if (sip->si_cont_list == NULL) sip->si_cont_list = ID_LIST_ALL; - } else { + } else { sip->si_attr = CUR_STATE(idx - 1).si_attr; sip->si_trans_id = CUR_STATE(idx - 1).si_trans_id; sip->si_h_startpos = CUR_STATE(idx - 1).si_h_startpos; @@ -2454,7 +2462,8 @@ static void update_si_attr(int idx) * Check the current stack for patterns with "keepend" flag. * Propagate the match-end to contained items, until a "skipend" item is found. */ -static void check_keepend(void) { +static void check_keepend(void) +{ int i; lpos_T maxpos; lpos_T maxpos_h; @@ -2549,13 +2558,13 @@ update_si_end ( sip->si_ends = TRUE; sip->si_m_endpos.lnum = current_lnum; sip->si_m_endpos.col = (colnr_T)STRLEN(syn_getcurline()); - } else { + } else { /* continues in the next line */ sip->si_ends = FALSE; sip->si_m_endpos.lnum = 0; } sip->si_h_endpos = sip->si_m_endpos; - } else { + } else { /* match within this line */ sip->si_m_endpos = endpos; sip->si_h_endpos = hl_endpos; @@ -2583,7 +2592,8 @@ static int push_current_state(int idx) /* * Remove a state from the current_state stack. */ -static void pop_current_state(void) { +static void pop_current_state(void) +{ if (current_state.ga_len) { unref_extmatch(CUR_STATE(current_state.ga_len - 1).si_extmatch); --current_state.ga_len; @@ -2774,7 +2784,7 @@ find_endpos ( if (spp->sp_off_flags & (1 << (SPO_RE_OFF + SPO_COUNT))) { hl_endpos->lnum = best_regmatch.endpos[0].lnum; hl_endpos->col = best_regmatch.endpos[0].col; - } else { + } else { hl_endpos->lnum = best_regmatch.startpos[0].lnum; hl_endpos->col = best_regmatch.startpos[0].col; } @@ -2789,7 +2799,7 @@ find_endpos ( /* now the match ends where the highlighting ends, it is turned * into the matchgroup for the end */ *m_endpos = *hl_endpos; - } else { + } else { *end_idx = 0; *hl_endpos = *end_endpos; } @@ -2852,7 +2862,7 @@ syn_add_end_off ( result->lnum = regmatch->startpos[0].lnum; col = regmatch->startpos[0].col; off = spp->sp_offsets[idx] + extra; - } else { + } else { result->lnum = regmatch->endpos[0].lnum; col = regmatch->endpos[0].col; off = spp->sp_offsets[idx]; @@ -2898,7 +2908,7 @@ syn_add_start_off ( result->lnum = regmatch->endpos[0].lnum; col = regmatch->endpos[0].col; off = spp->sp_offsets[idx] + extra; - } else { + } else { result->lnum = regmatch->startpos[0].lnum; col = regmatch->startpos[0].col; off = spp->sp_offsets[idx]; @@ -2926,7 +2936,8 @@ syn_add_start_off ( /* * Get current line in syntax buffer. */ -static char_u *syn_getcurline(void) { +static char_u *syn_getcurline(void) +{ return ml_get_buf(syn_buf, current_lnum, FALSE); } @@ -3173,7 +3184,8 @@ void reset_synblock(win_T *wp) /* * Clear syncing info for one buffer. */ -static void syntax_sync_clear(void) { +static void syntax_sync_clear(void) +{ int i; /* free the syntax patterns */ @@ -3270,7 +3282,7 @@ static void syn_cmd_clear(exarg_T *eap, int syncing) do_unlet((char_u *)"b:current_syntax", TRUE); do_unlet((char_u *)"w:current_syntax", TRUE); } - } else { + } else { /* * Clear the group IDs that are in the argument. */ @@ -3281,7 +3293,7 @@ static void syn_cmd_clear(exarg_T *eap, int syncing) if (id == 0) { EMSG2(_("E391: No such syntax cluster: %s"), arg); break; - } else { + } else { /* * We can't physically delete a cluster without changing * the IDs of other clusters, so we do the next best thing @@ -3292,7 +3304,7 @@ static void syn_cmd_clear(exarg_T *eap, int syncing) vim_free(SYN_CLSTR(curwin->w_s)[scl_id].scl_list); SYN_CLSTR(curwin->w_s)[scl_id].scl_list = NULL; } - } else { + } else { id = syn_namen2id(arg, (int)(arg_end - arg)); if (id == 0) { EMSG2(_(e_nogroup), arg); @@ -3446,7 +3458,7 @@ syn_cmd_list ( syn_list_one(id, syncing, FALSE); for (id = 0; id < curwin->w_s->b_syn_clusters.ga_len && !got_int; ++id) syn_list_cluster(id); - } else { + } else { /* * List the group IDs and syntax clusters that are in the argument. */ @@ -3458,7 +3470,7 @@ syn_cmd_list ( EMSG2(_("E392: No such syntax cluster: %s"), arg); else syn_list_cluster(id - SYNID_CLUSTER); - } else { + } else { id = syn_namen2id(arg, (int)(arg_end - arg)); if (id == 0) EMSG2(_(e_nogroup), arg); @@ -3471,7 +3483,8 @@ syn_cmd_list ( eap->nextcmd = check_nextcmd(arg); } -static void syn_lines_msg(void) { +static void syn_lines_msg(void) +{ if (curwin->w_s->b_syn_sync_maxlines > 0 || curwin->w_s->b_syn_sync_minlines > 0) { MSG_PUTS("; "); @@ -3489,7 +3502,8 @@ static void syn_lines_msg(void) { } } -static void syn_match_msg(void) { +static void syn_match_msg(void) +{ if (curwin->w_s->b_syn_sync_linebreaks > 0) { MSG_PUTS(_("; match ")); msg_outnum(curwin->w_s->b_syn_sync_linebreaks); @@ -3642,7 +3656,7 @@ static void syn_list_cluster(int id) if (SYN_CLSTR(curwin->w_s)[id].scl_list != NULL) { put_id_list((char_u *)"cluster", SYN_CLSTR(curwin->w_s)[id].scl_list, hl_attr(HLF_D)); - } else { + } else { msg_puts_attr((char_u *)"cluster", hl_attr(HLF_D)); msg_puts((char_u *)"=NONE"); } @@ -3856,7 +3870,7 @@ static void syn_clear_keyword(int id, hashtab_T *ht) vim_free(kp->k_syn.cont_in_list); vim_free(kp); kp = kp_next; - } else { + } else { kp_prev = kp; kp = kp->ke_next; } @@ -3941,7 +3955,7 @@ add_keyword ( /* new keyword, add to hashtable */ kp->ke_next = NULL; hash_add_item(ht, hi, kp->keyword, hash); - } else { + } else { /* keyword already exists, prepend to list */ kp->ke_next = HI2KE(hi); hi->hi_key = KE2HIKEY(kp); @@ -4073,7 +4087,7 @@ get_syn_options ( if (has_mbyte) { *conceal_char = mb_ptr2char(arg + 6); arg += mb_ptr2len(arg + 6) - 1; - } else { + } else { *conceal_char = arg[6]; } if (!vim_isprintc_strict(*conceal_char)) { @@ -4081,7 +4095,7 @@ get_syn_options ( return NULL; } arg = skipwhite(arg + 7); - } else { + } else { opt->flags |= flagtab[fidx].flags; arg = skipwhite(arg + len); @@ -4302,7 +4316,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) mch_memmove(p, p + 1, l); p += l; - } else { + } else { p[0] = p[1]; ++p; } @@ -4538,7 +4552,7 @@ syn_cmd_region ( } } rest = skipwhite(p); - } else { + } else { /* * Allocate room for a syn_pattern, and link it in the list of * syn_patterns for this item, at the start (because the list is @@ -4966,7 +4980,8 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing) /* * On first call for current buffer: Init growing array. */ -static void init_syn_patterns(void) { +static void init_syn_patterns(void) +{ curwin->w_s->b_syn_patterns.ga_itemsize = sizeof(synpat_T); curwin->w_s->b_syn_patterns.ga_growsize = 10; } @@ -5035,7 +5050,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) ci->sp_off_flags |= (1 << SPO_MS_OFF); ci->sp_offsets[SPO_MS_OFF] = *p; } - } else { /* yy=x+99 */ + } else { /* yy=x+99 */ end += 4; if (*end == '+') { ++end; @@ -5159,7 +5174,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) } } next_arg = skipwhite(arg_end + 1); - } else { + } else { eap->arg = next_arg; if (STRCMP(key, "MATCH") == 0) syn_cmd_match(eap, TRUE); @@ -5271,7 +5286,7 @@ get_id_list ( id += current_syn_inc_tag; } else if (name[1] == '@') { id = syn_check_cluster(name + 2, (int)(end - p - 1)); - } else { + } else { /* * Handle full group name. */ @@ -5444,7 +5459,7 @@ in_id_list ( /* TOP: accept all not-contained groups in the same file */ if (item - SYNID_TOP != ssp->inc_tag || contained) return FALSE; - } else { + } else { /* CONTAINED: accept all contained groups in the same file */ if (item - SYNID_CONTAINED != ssp->inc_tag || !contained) return FALSE; @@ -5599,7 +5614,8 @@ static enum { * Reset include_link, include_default, include_none to 0. * Called when we are done expanding. */ -void reset_expand_highlight(void) { +void reset_expand_highlight(void) +{ include_link = include_default = include_none = 0; } @@ -5702,7 +5718,8 @@ int get_syntax_info(int *seqnrp) /* * Return conceal substitution character */ -int syn_get_sub_char(void) { +int syn_get_sub_char(void) +{ return current_sub_char; } @@ -5775,7 +5792,8 @@ static void syn_clear_time(syn_time_T *st) /* * Clear the syntax timing for the current buffer. */ -static void syntime_clear(void) { +static void syntime_clear(void) +{ int idx; synpat_T *spp; @@ -5825,7 +5843,8 @@ static int syn_compare_syntime(const void *v1, const void *v2) /* * Clear the syntax timing for the current buffer. */ -static void syntime_report(void) { +static void syntime_report(void) +{ int idx; synpat_T *spp; proftime_T tm; @@ -6312,7 +6331,7 @@ do_highlight ( && hl_has_settings(from_id - 1, dodefault)) { if (sourcing_name == NULL && !dodefault) EMSG(_("E414: group has settings, highlight link ignored")); - } else { + } else { if (!init) HL_TABLE()[from_id - 1].sg_set |= SG_LINK; HL_TABLE()[from_id - 1].sg_link = to_id; @@ -6426,7 +6445,7 @@ do_highlight ( error = TRUE; break; } - } else { + } else { arg_start = linep; linep = skiptowhite(linep); } @@ -6484,7 +6503,7 @@ do_highlight ( HL_TABLE()[idx].sg_cterm = attr; HL_TABLE()[idx].sg_cterm_bold = FALSE; } - } else { + } else { if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) { if (!init) HL_TABLE()[idx].sg_set |= SG_GUI; @@ -6524,7 +6543,7 @@ do_highlight ( error = TRUE; break; } - } else { + } else { static char *(color_names[28]) = { "Black", "DarkBlue", "DarkGreen", "DarkCyan", "DarkRed", "DarkMagenta", "Brown", "DarkYellow", @@ -6645,7 +6664,7 @@ do_highlight ( term_fg_color(color); } } - } else { + } else { HL_TABLE()[idx].sg_cterm_bg = color + 1; if (is_normal_group) { cterm_normal_bg_color = color + 1; @@ -6745,7 +6764,7 @@ do_highlight ( if (arg[off] == ',') /* another one follows */ ++off; } - } else { + } else { /* * Copy characters from arg[] to buf[], translating <> codes. */ @@ -6768,11 +6787,11 @@ do_highlight ( if (key[2] == 'A') { vim_free(HL_TABLE()[idx].sg_start); HL_TABLE()[idx].sg_start = p; - } else { + } else { vim_free(HL_TABLE()[idx].sg_stop); HL_TABLE()[idx].sg_stop = p; } - } else { + } else { EMSG2(_("E423: Illegal argument: %s"), key_start); error = TRUE; break; @@ -6812,7 +6831,8 @@ do_highlight ( } #if defined(EXITFREE) || defined(PROTO) -void free_highlight(void) { +void free_highlight(void) +{ int i; for (i = 0; i < highlight_ga.ga_len; ++i) { @@ -6829,7 +6849,8 @@ void free_highlight(void) { * Reset the cterm colors to what they were before Vim was started, if * possible. Otherwise reset them to zero. */ -void restore_cterm_colors(void) { +void restore_cterm_colors(void) +{ cterm_normal_fg_color = 0; cterm_normal_fg_bold = 0; cterm_normal_bg_color = 0; @@ -6987,7 +7008,8 @@ static int get_attr_entry(garray_T *table, attrentry_T *aep) /* * Clear all highlight tables. */ -void clear_hl_tables(void) { +void clear_hl_tables(void) +{ int i; attrentry_T *taep; @@ -7324,7 +7346,7 @@ syn_list_header ( msg_putchar('\n'); if (got_int) return TRUE; - } else { + } else { if (msg_col >= endcol) /* wrap around is like starting a new line */ newline = FALSE; } @@ -7525,7 +7547,8 @@ static int syn_add_group(char_u *name) * When, just after calling syn_add_group(), an error is discovered, this * function deletes the new name. */ -static void syn_unadd_group(void) { +static void syn_unadd_group(void) +{ --highlight_ga.ga_len; vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name); vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name_u); @@ -7585,7 +7608,8 @@ int syn_get_final_id(int hl_id) * screen redraw after any :highlight command. * Return FAIL when an invalid flag is found in 'highlight'. OK otherwise. */ -int highlight_changed(void) { +int highlight_changed(void) +{ int hlf; int i; char_u *p; @@ -7703,7 +7727,7 @@ int highlight_changed(void) { if (id == 0) { highlight_user[i] = 0; highlight_stlnc[i] = 0; - } else { + } else { struct hl_group *hlt = HL_TABLE(); highlight_user[i] = syn_id2attr(id); @@ -7794,7 +7818,8 @@ void set_context_in_highlight_cmd(expand_T *xp, char_u *arg) /* * List highlighting matches in a nice way. */ -static void highlight_list(void) { +static void highlight_list(void) +{ int i; for (i = 10; --i >= 0; ) @@ -211,7 +211,7 @@ do_tag ( if ((!p_tgst && *tag != NUL)) { use_tagstack = FALSE; new_tag = TRUE; - } else { + } else { if (g_do_tagpreview != 0) use_tagstack = FALSE; else @@ -230,12 +230,12 @@ do_tag ( * the CursorHold autocommand example works. */ cur_match = ptag_entry.cur_match; cur_fnum = ptag_entry.cur_fnum; - } else { + } else { vim_free(ptag_entry.tagname); if ((ptag_entry.tagname = vim_strsave(tag)) == NULL) goto end_do_tag; } - } else { + } else { /* * If the last used entry is not at the top, delete all tag * stack entries above it. @@ -265,7 +265,7 @@ do_tag ( } new_tag = TRUE; - } else { + } else { if ( g_do_tagpreview != 0 ? ptag_entry.tagname == NULL : tagstacklen == 0) { @@ -308,7 +308,7 @@ do_tag ( /* An BufReadPost autocommand may jump to the '" mark, but * we don't what that here. */ curwin->w_cursor.lnum = saved_fmark.mark.lnum; - } else { + } else { setpcmark(); curwin->w_cursor.lnum = saved_fmark.mark.lnum; } @@ -332,7 +332,7 @@ do_tag ( if (g_do_tagpreview != 0) { cur_match = ptag_entry.cur_match; cur_fnum = ptag_entry.cur_fnum; - } else { + } else { /* ":tag" (no argument): go to newer pattern */ save_pos = TRUE; /* save the cursor position below */ if ((tagstackidx += count - 1) >= tagstacklen) { @@ -353,14 +353,14 @@ do_tag ( cur_fnum = tagstack[tagstackidx].cur_fnum; } new_tag = TRUE; - } else { /* go to other matching tag */ + } else { /* go to other matching tag */ /* Save index for when selection is cancelled. */ prevtagstackidx = tagstackidx; if (g_do_tagpreview != 0) { cur_match = ptag_entry.cur_match; cur_fnum = ptag_entry.cur_fnum; - } else { + } else { if (--tagstackidx < 0) tagstackidx = 0; cur_match = tagstack[tagstackidx].cur_match; @@ -391,7 +391,7 @@ do_tag ( ptag_entry.cur_match = cur_match; ptag_entry.cur_fnum = cur_fnum; } - } else { + } else { /* * For ":tag [arg]" or ":tselect" remember position before the jump. */ @@ -504,7 +504,7 @@ do_tag ( if (verbose) EMSG2(_("E426: tag not found: %s"), name); g_do_tagpreview = 0; - } else { + } else { int ask_for_selection = FALSE; if (type == DT_CSCOPE && num_matches > 1) { @@ -613,7 +613,7 @@ do_tag ( break; msg_advance(15); } - } else { + } else { for (p = tagp.command; *p && *p != '\r' && *p != '\n'; ++p) ; @@ -919,7 +919,7 @@ do_tag ( continue; } EMSG2(_("E429: File \"%s\" does not exist"), nofile_fname); - } else { + } else { /* We may have jumped to another window, check that * tagstackidx is still valid. */ if (use_tagstack && tagstackidx > curwin->w_tagstacklen) @@ -942,7 +942,8 @@ end_do_tag: /* * Free cached tags. */ -void tag_freematch(void) { +void tag_freematch(void) +{ vim_free(tagmatchname); tagmatchname = NULL; } @@ -1443,7 +1444,7 @@ line_read_in: vim_free(lbuf); lbuf = conv_line; lbuf_size = len; - } else { + } else { STRCPY(lbuf, conv_line); vim_free(conv_line); } @@ -1783,7 +1784,7 @@ parse_line: if (use_cscope) { /* Don't change the ordering, always use the same table. */ mtt = MT_GL_OTH; - } else { + } else { /* Decide in which array to store this match. */ is_current = test_for_current( tagp.fname, tagp.fname_end, tag_fname, @@ -1802,7 +1803,7 @@ parse_line: mtt = MT_ST_CUR; else mtt = MT_ST_OTH; - } else { + } else { if (is_current) mtt = MT_GL_CUR; else @@ -1871,7 +1872,7 @@ parse_line: } else mfp = NULL; get_it_again = FALSE; - } else { + } else { len = (int)(tagp.tagname_end - tagp.tagname); mfp = (struct match_found *)alloc( (int)sizeof(struct match_found) + len); @@ -1885,7 +1886,7 @@ parse_line: if (State & INSERT) get_it_again = p_sft; } - } else { + } else { /* Save the tag in a buffer. * Emacs tag: <mtt><tag_fname><NUL><ebuf><NUL><lbuf> * other tag: <mtt><tag_fname><NUL><NUL><lbuf> @@ -1936,7 +1937,7 @@ parse_line: } else vim_free(mfp); } - } else { /* Out of memory! Just forget about the rest. */ + } else { /* Out of memory! Just forget about the rest. */ retval = OK; stop_searching = TRUE; break; @@ -2055,7 +2056,8 @@ static void found_tagfile_cb(char_u *fname, void *cookie) } #if defined(EXITFREE) || defined(PROTO) -void free_tag_stuff(void) { +void free_tag_stuff(void) +{ ga_clear_strings(&tag_fnames); do_tag(NULL, DT_FREE, 0, 0, 0); tag_freematch(); @@ -2138,7 +2140,7 @@ get_tagfname ( break; tnp->tn_did_filefind_init = FALSE; - } else { + } else { char_u *filename = NULL; /* Stop when used all parts of 'tags'. */ @@ -2583,7 +2585,7 @@ jumpto_tag ( if (found == 0) { EMSG(_("E434: Can't find tag pattern")); curwin->w_cursor.lnum = save_lnum; - } else { + } else { /* * Only give a message when really guessed, not when 'ic' * is set and match found while ignoring case. @@ -2605,7 +2607,7 @@ jumpto_tag ( /* A search command may have positioned the cursor beyond the end * of the line. May need to correct that here. */ check_cursor(); - } else { + } else { curwin->w_cursor.lnum = 1; /* start command in line 1 */ do_cmdline_cmd(pbuf); retval = OK; @@ -2651,7 +2653,7 @@ jumpto_tag ( } --RedrawingDisabled; - } else { + } else { --RedrawingDisabled; if (postponed_split) { /* close the window */ win_close(curwin, FALSE); @@ -2851,7 +2853,7 @@ void simplify_filename(char_u *filename) * components that might be stripped later on. */ p = tail; components = 0; - } else { + } else { /* Strip previous component. If the result would get empty * and there is no trailing path separator, leave a single * "." instead. If we are at the end of the file name and @@ -2861,7 +2863,7 @@ void simplify_filename(char_u *filename) if (p == start && relative && tail[-1] == '.') { *p++ = '.'; *p = NUL; - } else { + } else { if (p > start && tail[-1] == '.') --p; STRMOVE(p, tail); /* strip previous component */ @@ -2878,7 +2880,7 @@ void simplify_filename(char_u *filename) } p = tail; /* skip to char after ".." or "../" */ } - } else { + } else { ++components; /* simple path component */ p = getnextcomp(p); } diff --git a/src/term.c b/src/term.c index 398df0af79..90611a9a30 100644 --- a/src/term.c +++ b/src/term.c @@ -1227,7 +1227,7 @@ static void parse_builtin_tcap(char_u *term) } else term_strings[p->bt_entry] = (char_u *)p->bt_string; } - } else { + } else { name[0] = KEY2TERMCAP0((int)p->bt_entry); name[1] = KEY2TERMCAP1((int)p->bt_entry); if (find_termcode(name) == NULL) @@ -2048,7 +2048,8 @@ static int out_pos = 0; /* number of chars in out_buf */ /* * out_flush(): flush the output buffer */ -void out_flush(void) { +void out_flush(void) +{ int len; if (out_pos != 0) { @@ -2063,7 +2064,8 @@ void out_flush(void) { * Sometimes a byte out of a multi-byte character is written with out_char(). * To avoid flushing half of the character, call this function first. */ -void out_flush_check(void) { +void out_flush_check(void) +{ if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) out_flush(); } @@ -2436,7 +2438,8 @@ static int get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) * Check if the new shell size is valid, correct it if it's too small or way * too big. */ -void check_shellsize(void) { +void check_shellsize(void) +{ if (Rows < min_rows()) /* need room for one window and command line */ Rows = min_rows(); limit_screen_size(); @@ -2445,7 +2448,8 @@ void check_shellsize(void) { /* * Limit Rows and Columns to avoid an overflow in Rows * Columns. */ -void limit_screen_size(void) { +void limit_screen_size(void) +{ if (Columns < MIN_COLUMNS) Columns = MIN_COLUMNS; else if (Columns > 10000) @@ -2457,7 +2461,8 @@ void limit_screen_size(void) { /* * Invoked just before the screen structures are going to be (re)allocated. */ -void win_new_shellsize(void) { +void win_new_shellsize(void) +{ static int old_Rows = 0; static int old_Columns = 0; @@ -2480,7 +2485,8 @@ void win_new_shellsize(void) { * Call this function when the Vim shell has been resized in any way. * Will obtain the current size and redraw (also when size didn't change). */ -void shell_resized(void) { +void shell_resized(void) +{ set_shellsize(0, 0, FALSE); } @@ -2488,7 +2494,8 @@ void shell_resized(void) { * Check if the shell size changed. Handle a resize. * When the size didn't change, nothing happens. */ -void shell_resized_check(void) { +void shell_resized_check(void) +{ int old_Rows = Rows; int old_Columns = Columns; @@ -2574,13 +2581,13 @@ void set_shellsize(int width, int height, int mustset) || exmode_active) { screenalloc(FALSE); repeat_message(); - } else { + } else { if (curwin->w_p_scb) do_check_scrollbind(TRUE); if (State & CMDLINE) { update_screen(NOT_VALID); redrawcmdline(); - } else { + } else { update_topline(); if (pum_visible()) { redraw_later(NOT_VALID); @@ -2636,7 +2643,8 @@ void settmode(int tmode) } } -void starttermcap(void) { +void starttermcap(void) +{ if (full_screen && !termcap_active) { out_str(T_TI); /* start termcap mode */ out_str(T_KS); /* start "keypad transmit" mode */ @@ -2653,7 +2661,8 @@ void starttermcap(void) { } } -void stoptermcap(void) { +void stoptermcap(void) +{ screen_stop_highlight(); reset_cterm_colors(); if (termcap_active) { @@ -2698,7 +2707,8 @@ void stoptermcap(void) { * request to terminal while reading from a file). * The result is caught in check_termcode(). */ -void may_req_termresponse(void) { +void may_req_termresponse(void) +{ if (crv_status == CRV_GET && cur_tmode == TMODE_RAW && starting == 0 @@ -2728,7 +2738,8 @@ void may_req_termresponse(void) { * This function has the side effect that changes cursor position, so * it must be called immediately after entering termcap mode. */ -void may_req_ambiguous_char_width(void) { +void may_req_ambiguous_char_width(void) +{ if (u7_status == U7_GET && cur_tmode == TMODE_RAW && termcap_active @@ -2783,14 +2794,16 @@ static void log_tr(char *msg) { /* * Return TRUE when saving and restoring the screen. */ -int swapping_screen(void) { +int swapping_screen(void) +{ return full_screen && *T_TI != NUL; } /* * setmouse() - switch mouse on/off depending on current mode and 'mouse' */ -void setmouse(void) { +void setmouse(void) +{ int checkfor; @@ -2850,7 +2863,8 @@ int mouse_has(int c) /* * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". */ -int mouse_model_popup(void) { +int mouse_model_popup(void) +{ return p_mousem[0] == 'p'; } @@ -2859,7 +2873,8 @@ int mouse_model_popup(void) { * terminals this makes the screen scrolled to the correct position. * Used when starting Vim or returning from a shell. */ -void scroll_start(void) { +void scroll_start(void) +{ if (*T_VS != NUL) { out_str(T_VS); out_str(T_VE); @@ -2872,7 +2887,8 @@ static int cursor_is_off = FALSE; /* * Enable the cursor. */ -void cursor_on(void) { +void cursor_on(void) +{ if (cursor_is_off) { out_str(T_VE); cursor_is_off = FALSE; @@ -2882,7 +2898,8 @@ void cursor_on(void) { /* * Disable the cursor. */ -void cursor_off(void) { +void cursor_off(void) +{ if (full_screen) { if (!cursor_is_off) out_str(T_VI); /* disable cursor */ @@ -2893,7 +2910,8 @@ void cursor_off(void) { /* * Set cursor shape to match Insert mode. */ -void term_cursor_shape(void) { +void term_cursor_shape(void) +{ static int showing_insert_mode = MAYBE; if (!full_screen || *T_CSI == NUL || *T_CEI == NUL) @@ -2903,7 +2921,7 @@ void term_cursor_shape(void) { if (showing_insert_mode != TRUE) out_str(T_CSI); /* Insert mode cursor */ showing_insert_mode = TRUE; - } else { + } else { if (showing_insert_mode != FALSE) out_str(T_CEI); /* non-Insert mode cursor */ showing_insert_mode = FALSE; @@ -2929,7 +2947,8 @@ void scroll_region_set(win_T *wp, int off) /* * Reset scrolling region to the whole screen. */ -void scroll_region_reset(void) { +void scroll_region_reset(void) +{ OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); if (*T_CSV != NUL) OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); @@ -2952,7 +2971,8 @@ static int tc_len = 0; /* current number of entries in termcodes[] */ static int termcode_star(char_u *code, int len); -void clear_termcodes(void) { +void clear_termcodes(void) +{ while (tc_len > 0) vim_free(termcodes[--tc_len].code); vim_free(termcodes); @@ -3047,7 +3067,7 @@ void add_termcode(char_u *name, char_u *string, int flags) vim_free(s); return; } - } else { + } else { /* Replace old code. */ vim_free(termcodes[i].code); --tc_len; @@ -3142,7 +3162,8 @@ static void del_termcode_idx(int idx) * Called when detected that the terminal sends 8-bit codes. * Convert all 7-bit codes to their 8-bit equivalent. */ -static void switch_to_8bit(void) { +static void switch_to_8bit(void) +{ int i; int c; @@ -3256,7 +3277,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) break; tp = typebuf.tb_buf + typebuf.tb_off + offset; len = typebuf.tb_len - offset; /* length of the input */ - } else { + } else { if (offset >= *buflen) break; tp = buf + offset; @@ -4097,7 +4118,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED * to indicate what happened. */ retval = KEYLEN_REMOVED; - } else { + } else { string[new_slen++] = K_SPECIAL; string[new_slen++] = key_name[0]; string[new_slen++] = key_name[1]; @@ -4118,7 +4139,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen) */ mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, (size_t)new_slen); - } else { + } else { if (extra < 0) /* remove matched characters */ mch_memmove(buf + offset, buf + offset - extra, @@ -4275,7 +4296,7 @@ replace_termcodes ( } else if (STRNICMP(src, "<LocalLeader>", 13) == 0) { len = 13; p = get_var_value((char_u *)"g:maplocalleader"); - } else { + } else { len = 0; p = NULL; } @@ -4357,7 +4378,8 @@ int find_term_bykeys(char_u *src) * Gather the first characters in the terminal key codes into a string. * Used to speed up check_termcode(). */ -static void gather_termleader(void) { +static void gather_termleader(void) +{ int i; int len = 0; @@ -4379,7 +4401,8 @@ static void gather_termleader(void) { * Show all termcodes (for ":set termcap") * This code looks a lot like showoptions(), but is different. */ -void show_termcodes(void) { +void show_termcodes(void) +{ int col; int *items; int item_count; @@ -4467,7 +4490,7 @@ int show_one_termcode(char_u *name, char_u *code, int printit) IObuff[1] = ' '; IObuff[2] = ' '; IObuff[3] = ' '; - } else { + } else { IObuff[0] = 't'; IObuff[1] = '_'; IObuff[2] = name[0]; @@ -4508,13 +4531,15 @@ int show_one_termcode(char_u *name, char_u *code, int printit) static int xt_index_in = 0; static int xt_index_out = 0; -static void req_codes_from_term(void) { +static void req_codes_from_term(void) +{ xt_index_out = 0; xt_index_in = 0; req_more_codes_from_term(); } -static void req_more_codes_from_term(void) { +static void req_more_codes_from_term(void) +{ char buf[11]; int old_idx = xt_index_out; @@ -4607,7 +4632,7 @@ static void got_code_from_term(char_u *code, int len) redraw_asap(CLEAR); #endif } - } else { + } else { /* First delete any existing entry with the same code. */ i = find_term_bykeys(str); if (i >= 0) @@ -4628,7 +4653,8 @@ static void got_code_from_term(char_u *code, int len) * keyboard input. We don't want responses to be send to that program or * handled as typed text. */ -static void check_for_codes_from_term(void) { +static void check_for_codes_from_term(void) +{ int c; /* If no codes requested or all are answered, no need to wait. */ @@ -172,7 +172,8 @@ theend: /* * return non-zero if a character is available */ -int ui_char_avail(void) { +int ui_char_avail(void) +{ #ifndef NO_CONSOLE # ifdef NO_CONSOLE_INPUT if (no_console_input()) @@ -198,7 +199,8 @@ void ui_delay(long msec, int ignoreinput) * otherwise fake it by starting a new shell. * When running the GUI iconify the window. */ -void ui_suspend(void) { +void ui_suspend(void) +{ mch_suspend(); } @@ -207,7 +209,8 @@ void ui_suspend(void) { * When the OS can't really suspend, call this function to start a shell. * This is never called in the GUI. */ -void suspend_shell(void) { +void suspend_shell(void) +{ if (*p_sh == NUL) EMSG(_(e_shellempty)); else { @@ -223,7 +226,8 @@ void suspend_shell(void) { * Use the new sizes as defaults for 'columns' and 'lines'. * Return OK when size could be determined, FAIL otherwise. */ -int ui_get_shellsize(void) { +int ui_get_shellsize(void) +{ int retval; retval = mch_get_shellsize(); @@ -255,13 +259,15 @@ ui_set_shellsize ( * Called when Rows and/or Columns changed. Adjust scroll region and mouse * region. */ -void ui_new_shellsize(void) { +void ui_new_shellsize(void) +{ if (full_screen && !exiting) { mch_new_shellsize(); } } -void ui_breakcheck(void) { +void ui_breakcheck(void) +{ mch_breakcheck(); } @@ -318,16 +324,19 @@ static int inbufcount = 0; /* number of chars in inbuf[] */ * are used by the gui_* calls when a GUI is used to handle keyboard input. */ -int vim_is_input_buf_full(void) { +int vim_is_input_buf_full(void) +{ return inbufcount >= INBUFLEN; } -int vim_is_input_buf_empty(void) { +int vim_is_input_buf_empty(void) +{ return inbufcount == 0; } #if defined(FEAT_OLE) || defined(PROTO) -int vim_free_in_input_buf(void) { +int vim_free_in_input_buf(void) +{ return INBUFLEN - inbufcount; } @@ -338,7 +347,8 @@ int vim_free_in_input_buf(void) { * Return the current contents of the input buffer and make it empty. * The returned pointer must be passed to set_input_buf() later. */ -char_u *get_input_buf(void) { +char_u *get_input_buf(void) +{ garray_T *gap; /* We use a growarray to store the data pointer and the length. */ @@ -432,7 +442,8 @@ void push_raw_key(char_u *s, int len) #if defined(FEAT_GUI) || defined(FEAT_EVAL) || defined(FEAT_EX_EXTRA) \ || defined(PROTO) /* Remove everything from the input buffer. Called when ^C is found */ -void trash_input_buf(void) { +void trash_input_buf(void) +{ inbufcount = 0; } @@ -489,7 +500,7 @@ void fill_input_buf(int exit_on_error) if (unconverted == restlen) { vim_free(rest); rest = NULL; - } else { + } else { restlen -= unconverted; mch_memmove(rest, rest + unconverted, restlen); } @@ -537,7 +548,7 @@ void fill_input_buf(int exit_on_error) /* Interrupted, pretend a CTRL-C was typed. */ inbuf[0] = 3; inbufcount = 1; - } else { + } else { /* * May perform conversion on the input characters. * Include the unconverted rest of the previous call. @@ -572,7 +583,8 @@ void fill_input_buf(int exit_on_error) /* * Exit because of an input read error. */ -void read_error_exit(void) { +void read_error_exit(void) +{ if (silent_mode) /* Normal way to exit for "ex -s" */ getout(0); STRCPY(IObuff, _("Vim: Error reading input, exiting...\n")); @@ -582,7 +594,8 @@ void read_error_exit(void) { /* * May update the shape of the cursor. */ -void ui_cursor_shape(void) { +void ui_cursor_shape(void) +{ term_cursor_shape(); @@ -858,7 +871,7 @@ retnomove: did_drag |= count; } return IN_SEP_LINE; /* Cursor didn't move */ - } else { /* keep_window_focus must be TRUE */ + } else { /* keep_window_focus must be TRUE */ /* before moving the cursor for a left click, stop Visual mode */ if (flags & MOUSE_MAY_STOP_VIS) { end_visual_mode(); @@ -1067,7 +1080,7 @@ win_T *mouse_find_win(int *rowp, int *colp) break; *colp -= fp->fr_width; } - } else { /* fr_layout == FR_COL */ + } else { /* fr_layout == FR_COL */ for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) { if (*rowp < fp->fr_height) break; diff --git a/src/undo.c b/src/undo.c index 67e7fe7a36..6a2d163f61 100644 --- a/src/undo.c +++ b/src/undo.c @@ -228,7 +228,8 @@ static void u_check(int newhead_may_be_NULL) { * Careful: may trigger autocommands that reload the buffer. * Returns OK or FAIL. */ -int u_save_cursor(void) { +int u_save_cursor(void) +{ return u_save((linenr_T)(curwin->w_cursor.lnum - 1), (linenr_T)(curwin->w_cursor.lnum + 1)); } @@ -303,7 +304,8 @@ int u_savedel(linenr_T lnum, long nlines) * Return TRUE when undo is allowed. Otherwise give an error message and * return FALSE. */ -int undo_allowed(void) { +int undo_allowed(void) +{ /* Don't allow changes when 'modifiable' is off. */ if (!curbuf->b_p_ma) { EMSG(_(e_modifiable)); @@ -331,7 +333,8 @@ int undo_allowed(void) { /* * Get the undolevle value for the current buffer. */ -static long get_undolevel(void) { +static long get_undolevel(void) +{ if (curbuf->b_p_ul == NO_LOCAL_UNDOLEVEL) return p_ul; return curbuf->b_p_ul; @@ -488,7 +491,7 @@ int u_savecommon(linenr_T top, linenr_T bot, linenr_T newbot, int reload) if (curbuf->b_u_oldhead == NULL) curbuf->b_u_oldhead = uhp; ++curbuf->b_u_numhead; - } else { + } else { if (get_undolevel() < 0) /* no undo at all */ return OK; @@ -717,7 +720,7 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading) mch_memmove(p + 1, p, STRLEN(p) + 1); *p = '.'; STRCAT(p, ".un~"); - } else { + } else { dir_name[dir_len] = NUL; if (mch_isdir(dir_name)) { if (munged_name == NULL) { @@ -1188,7 +1191,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash) verbose_leave(); } goto theend; - } else { + } else { char_u mbuf[UF_START_MAGIC_LEN]; int len; @@ -1720,7 +1723,7 @@ static void u_doit(int startcount) } u_undoredo(TRUE); - } else { + } else { if (curbuf->b_u_curhead == NULL || get_undolevel() <= 0) { beep_flush(); /* nothing to redo */ if (count == startcount - 1) { @@ -1782,7 +1785,7 @@ void undo_time(long step, int sec, int file, int absolute) if (absolute) { target = step; closest = -1; - } else { + } else { /* When doing computations with time_t subtract starttime, because * time_t converted to a long may result in a wrong number. */ if (dosec) @@ -1808,7 +1811,7 @@ void undo_time(long step, int sec, int file, int absolute) /* Go to before first write: before the oldest change. Use * the sequence number for that. */ dofile = FALSE; - } else { + } else { /* Moving forward to a newer write. */ target = curbuf->b_u_save_nr_cur + step; if (target > curbuf->b_u_save_nr_last) { @@ -1824,7 +1827,7 @@ void undo_time(long step, int sec, int file, int absolute) if (target < 0) target = 0; closest = -1; - } else { + } else { if (dosec) closest = (long)(time(NULL) - starttime + 1); else if (dofile) @@ -1919,7 +1922,7 @@ void undo_time(long step, int sec, int file, int absolute) if (uhp == curbuf->b_u_curhead) uhp->uh_walk = nomark; uhp = uhp->uh_next.ptr; - } else { + } else { /* need to backtrack; mark this node as useless */ uhp->uh_walk = nomark; if (uhp->uh_alt_prev.ptr != NULL) @@ -2122,7 +2125,7 @@ static void u_undoredo(int undo) if (lnum >= top && lnum <= top + newsize + 1) { curwin->w_cursor = curhead->uh_cursor; newlnum = curwin->w_cursor.lnum - 1; - } else { + } else { /* Use the first line that actually changed. Avoids that * undoing auto-formatting puts the cursor in the previous * line. */ @@ -2260,7 +2263,7 @@ static void u_undoredo(int undo) curwin->w_cursor.coladd = 0; } else beginline(BL_SOL | BL_FIX); - } else { + } 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 @@ -2454,7 +2457,7 @@ void ex_undolist(exarg_T *eap) && uhp->uh_next.ptr->uh_walk != mark) { uhp = uhp->uh_next.ptr; --changes; - } else { + } else { /* need to backtrack; mark this node as done */ uhp->uh_walk = nomark; if (uhp->uh_alt_prev.ptr != NULL) @@ -2544,7 +2547,8 @@ void u_unchanged(buf_T *buf) * After reloading a buffer which was saved for 'undoreload': Find the first * line that was changed and set the cursor there. */ -void u_find_first_changed(void) { +void u_find_first_changed(void) +{ u_header_T *uhp = curbuf->b_u_newhead; u_entry_T *uep; linenr_T lnum; @@ -2606,7 +2610,8 @@ static void u_unch_branch(u_header_T *uhp) * Get pointer to last added entry. * If it's not valid, give an error message and return NULL. */ -static u_entry_T *u_get_headentry(void) { +static u_entry_T *u_get_headentry(void) +{ if (curbuf->b_u_newhead == NULL || curbuf->b_u_newhead->uh_entry == NULL) { EMSG(_("E439: undo list corrupt")); return NULL; @@ -2618,7 +2623,8 @@ static u_entry_T *u_get_headentry(void) { * u_getbot(): compute the line number of the previous u_save * It is called only when b_u_synced is FALSE. */ -static void u_getbot(void) { +static void u_getbot(void) +{ u_entry_T *uep; linenr_T extra; @@ -2800,7 +2806,8 @@ void u_saveline(linenr_T lnum) * clear the line saved for the "U" command * (this is used externally for crossing a line while in insert mode) */ -void u_clearline(void) { +void u_clearline(void) +{ if (curbuf->b_u_line_ptr != NULL) { vim_free(curbuf->b_u_line_ptr); curbuf->b_u_line_ptr = NULL; @@ -2814,7 +2821,8 @@ void u_clearline(void) { * We also allow the cursor to be in another line. * Careful: may trigger autocommands that reload the buffer. */ -void u_undoline(void) { +void u_undoline(void) +{ colnr_T t; char_u *oldp; @@ -2880,7 +2888,8 @@ int bufIsChanged(buf_T *buf) (buf->b_changed || file_ff_differs(buf, TRUE)); } -int curbufIsChanged(void) { +int curbufIsChanged(void) +{ return !bt_dontwrite(curbuf) && (curbuf->b_changed || file_ff_differs(curbuf, TRUE)); diff --git a/src/window.c b/src/window.c index f3c14a568d..93c63a1986 100644 --- a/src/window.c +++ b/src/window.c @@ -249,12 +249,12 @@ newwindow: else wp = wp->w_next; } - } else { + } else { if (nchar == 'W') { /* go to previous window */ wp = curwin->w_prev; if (wp == NULL) 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 */ @@ -660,7 +660,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) frp = frp->fr_next; } } - } else { + } else { layout = FR_COL; /* @@ -673,7 +673,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) if (p_ea || (flags & (WSP_BOT | WSP_TOP))) { available = topframe->fr_height; needed += frame_minheight(topframe, NULL); - } else { + } else { available = oldwin->w_height; needed += p_wmh; } @@ -743,7 +743,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) wp = win_alloc(oldwin, FALSE); else win_append(oldwin, wp); - } else { + } else { if (new_wp == NULL) wp = win_alloc(oldwin->w_prev, FALSE); else @@ -777,7 +777,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) } else curfrp = topframe; before = (flags & WSP_TOP); - } else { + } else { curfrp = oldwin->w_frame; if (flags & WSP_BELOW) before = FALSE; @@ -836,7 +836,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) wp->w_winrow = tabline_height(); win_new_height(wp, curfrp->fr_height - (p_ls > 0)); wp->w_status_height = (p_ls > 0); - } else { + } else { /* height and row of new window is same as current window */ wp->w_winrow = oldwin->w_winrow; win_new_height(wp, oldwin->w_height); @@ -869,13 +869,13 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) wp->w_wincol = oldwin->w_wincol + oldwin->w_width + 1; frame_fix_width(oldwin); frame_fix_width(wp); - } else { + } else { /* width and column of new window is same as current window */ if (flags & (WSP_TOP | WSP_BOT)) { wp->w_wincol = 0; win_new_width(wp, Columns); wp->w_vsep_width = 0; - } else { + } else { wp->w_wincol = oldwin->w_wincol; win_new_width(wp, oldwin->w_width); wp->w_vsep_width = oldwin->w_vsep_width; @@ -894,7 +894,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) 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 + oldwin->w_height + STATUS_HEIGHT; wp->w_status_height = oldwin->w_status_height; oldwin->w_status_height = STATUS_HEIGHT; @@ -941,7 +941,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) if (size != 0) p_wiw = size; - } else { + } else { i = p_wh; if (size != 0) p_wh = size; @@ -1047,7 +1047,8 @@ int win_valid(win_T *win) /* * Return the number of windows. */ -int win_count(void) { +int win_count(void) +{ win_T *wp; int count = 0; @@ -1076,7 +1077,7 @@ make_windows ( * column. */ maxcount = (curwin->w_width + curwin->w_vsep_width - (p_wiw - p_wmw)) / (p_wmw + 1); - } else { + } else { /* Each window needs at least 'winminheight' lines and a status line. */ maxcount = (curwin->w_height + curwin->w_status_height - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); @@ -1105,7 +1106,7 @@ make_windows ( if (win_split(curwin->w_width - (curwin->w_width - todo) / (todo + 1) - 1, WSP_VERT | WSP_ABOVE) == FAIL) break; - } else { + } else { if (win_split(curwin->w_height - (curwin->w_height - todo * STATUS_HEIGHT) / (todo + 1) - STATUS_HEIGHT, WSP_ABOVE) == FAIL) @@ -1194,7 +1195,7 @@ static void win_exchange(long Prenum) temp = curwin->w_width; curwin->w_width = wp->w_width; wp->w_width = temp; - } else { + } else { frame_fix_height(curwin); frame_fix_height(wp); frame_fix_width(curwin); @@ -1247,7 +1248,7 @@ static void win_rotate(int upwards, int count) frame_append(frp, wp1->w_frame); 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 */ for (frp = curwin->w_frame; frp->fr_next != NULL; frp = frp->fr_next) @@ -1338,7 +1339,7 @@ void win_move_after(win_T *win1, win_T *win2) win1->w_vsep_width = 1; win1->w_frame->fr_width += 1; } - } else if (win2 == lastwin) { + } else if (win2 == lastwin) { height = win1->w_status_height; win1->w_status_height = win2->w_status_height; win2->w_status_height = height; @@ -1422,7 +1423,7 @@ win_equal_rec ( frame_new_width(topfr, width, FALSE, FALSE); redraw_all_later(CLEAR); } - } else if (topfr->fr_layout == FR_ROW) { + } else if (topfr->fr_layout == FR_ROW) { topfr->fr_width = width; topfr->fr_height = height; @@ -1448,7 +1449,7 @@ win_equal_rec ( if (room < 0) { next_curwin_size = p_wiw + room; room = 0; - } else { + } else { next_curwin_size = -1; for (fr = topfr->fr_child; fr != NULL; fr = fr->fr_next) { /* If 'winfixwidth' set keep the window width if @@ -1506,7 +1507,7 @@ win_equal_rec ( else if (frame_fixed_width(fr)) { new_size = fr->fr_newwidth; wincount = 0; /* doesn't count as a sizeable window */ - } else { + } else { /* Compute the maximum number of windows horiz. in "fr". */ n = frame_minwidth(fr, NOWIN); wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) @@ -1543,7 +1544,7 @@ win_equal_rec ( width -= new_size; totwincount -= wincount; } - } else { /* topfr->fr_layout == FR_COL */ + } else { /* topfr->fr_layout == FR_COL */ topfr->fr_width = width; topfr->fr_height = height; @@ -1570,7 +1571,7 @@ win_equal_rec ( * current window. */ next_curwin_size = p_wh + room; room = 0; - } else { + } else { next_curwin_size = -1; for (fr = topfr->fr_child; fr != NULL; fr = fr->fr_next) { /* If 'winfixheight' set keep the window height if @@ -1628,7 +1629,7 @@ win_equal_rec ( else if (frame_fixed_height(fr)) { new_size = fr->fr_newheight; wincount = 0; /* doesn't count as a sizeable window */ - } else { + } else { /* Compute the maximum number of windows vert. in "fr". */ n = frame_minheight(fr, NOWIN); wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) @@ -1723,7 +1724,8 @@ close_windows ( * "aucmd_win"). * Returns FALSE if there is a window, possibly in another tab page. */ -static int last_window(void) { +static int last_window(void) +{ return one_window() && first_tabpage->tp_next == NULL; } @@ -1731,7 +1733,8 @@ static int last_window(void) { * Return TRUE if there is only one window other than "aucmd_win" in the * current tab page. */ -int one_window(void) { +int one_window(void) +{ win_T *wp; int seen_one = FALSE; @@ -2041,7 +2044,8 @@ win_free_mem ( } #if defined(EXITFREE) || defined(PROTO) -void win_free_all(void) { +void win_free_all(void) +{ int dummy; while (first_tabpage->tp_next != NULL) @@ -2117,7 +2121,7 @@ winframe_remove ( frame_new_height(frp2, frp2->fr_height + frp_close->fr_height, frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE); *dirp = 'v'; - } else { + } 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. */ @@ -2229,7 +2233,8 @@ win_altframe ( /* * Return the tabpage that will be used if the current one is closed. */ -static tabpage_T *alt_tabpage(void) { +static tabpage_T *alt_tabpage(void) +{ tabpage_T *tp; /* Use the next tab page if possible. */ @@ -2289,7 +2294,7 @@ frame_new_height ( /* Simple case: just one window. */ win_new_height(topfrp->fr_win, height - topfrp->fr_win->w_status_height); - } else if (topfrp->fr_layout == FR_ROW) { + } else if (topfrp->fr_layout == FR_ROW) { do { /* All frames in this row get the same new height. */ for (frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) { @@ -2301,7 +2306,7 @@ frame_new_height ( } } } while (frp != NULL); - } else { /* fr_layout == FR_COL */ + } else { /* fr_layout == FR_COL */ /* Complicated case: Resize a column of frames. Resize the bottom * frame first, frames above that when needed. */ @@ -2331,7 +2336,7 @@ frame_new_height ( if (frp->fr_height + extra_lines < h) { extra_lines += frp->fr_height - h; frame_new_height(frp, h, topfirst, wfh); - } else { + } else { frame_new_height(frp, frp->fr_height + extra_lines, topfirst, wfh); break; @@ -2340,7 +2345,7 @@ frame_new_height ( do frp = frp->fr_next; while (wfh && frp != NULL && frame_fixed_height(frp)); - } else { + } else { do frp = frp->fr_prev; while (wfh && frp != NULL && frame_fixed_height(frp)); @@ -2349,7 +2354,7 @@ frame_new_height ( if (frp == NULL) height -= extra_lines; } - } else if (extra_lines > 0) { + } else if (extra_lines > 0) { /* increase height of bottom or top frame */ frame_new_height(frp, frp->fr_height + extra_lines, topfirst, wfh); } @@ -2426,11 +2431,11 @@ static void frame_add_statusline(frame_T *frp) --wp->w_height; wp->w_status_height = STATUS_HEIGHT; } - } else if (frp->fr_layout == FR_ROW) { + } else if (frp->fr_layout == FR_ROW) { /* Handle all the frames in the row. */ for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) frame_add_statusline(frp); - } else { /* frp->fr_layout == FR_COL */ + } 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) ; @@ -2466,7 +2471,7 @@ frame_new_width ( if (frp->fr_parent == NULL) wp->w_vsep_width = 0; win_new_width(wp, width - wp->w_vsep_width); - } else if (topfrp->fr_layout == FR_COL) { + } else if (topfrp->fr_layout == FR_COL) { do { /* All frames in this column get the same new width. */ for (frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) { @@ -2478,7 +2483,7 @@ frame_new_width ( } } } while (frp != NULL); - } else { /* fr_layout == FR_ROW */ + } else { /* fr_layout == FR_ROW */ /* Complicated case: Resize a row of frames. Resize the rightmost * frame first, frames left of it when needed. */ @@ -2508,7 +2513,7 @@ frame_new_width ( if (frp->fr_width + extra_cols < w) { extra_cols += frp->fr_width - w; frame_new_width(frp, w, leftfirst, wfw); - } else { + } else { frame_new_width(frp, frp->fr_width + extra_cols, leftfirst, wfw); break; @@ -2517,7 +2522,7 @@ frame_new_width ( do frp = frp->fr_next; while (wfw && frp != NULL && frame_fixed_width(frp)); - } else { + } else { do frp = frp->fr_prev; while (wfw && frp != NULL && frame_fixed_width(frp)); @@ -2526,7 +2531,7 @@ frame_new_width ( if (frp == NULL) width -= extra_cols; } - } else if (extra_cols > 0) { + } else if (extra_cols > 0) { /* increase width of rightmost frame */ frame_new_width(frp, frp->fr_width + extra_cols, leftfirst, wfw); } @@ -2549,11 +2554,11 @@ static void frame_add_vsep(frame_T *frp) --wp->w_width; wp->w_vsep_width = 1; } - } else if (frp->fr_layout == FR_COL) { + } else if (frp->fr_layout == FR_COL) { /* Handle all the frames in the column. */ for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next) frame_add_vsep(frp); - } else { /* frp->fr_layout == FR_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) @@ -2601,7 +2606,7 @@ static int frame_minheight(frame_T *topfrp, win_T *next_curwin) if (p_wmh == 0 && topfrp->fr_win == curwin && next_curwin == NULL) ++m; } - } else if (topfrp->fr_layout == FR_ROW) { + } else if (topfrp->fr_layout == FR_ROW) { /* get the minimal height from each frame in this row */ m = 0; for (frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) { @@ -2609,7 +2614,7 @@ static int frame_minheight(frame_T *topfrp, win_T *next_curwin) if (n > m) m = n; } - } else { + } else { /* Add up the minimal heights for all frames in this column. */ m = 0; for (frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) @@ -2644,7 +2649,7 @@ frame_minwidth ( if (p_wmw == 0 && topfrp->fr_win == curwin && next_curwin == NULL) ++m; } - } else if (topfrp->fr_layout == FR_COL) { + } else if (topfrp->fr_layout == FR_COL) { /* get the minimal width from each frame in this column */ m = 0; for (frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) { @@ -2652,7 +2657,7 @@ frame_minwidth ( if (n > m) m = n; } - } else { + } else { /* Add up the minimal widths for all frames in this row. */ m = 0; for (frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) @@ -2723,7 +2728,8 @@ close_others ( * Init the current window "curwin". * Called when a new file is being edited. */ -void curwin_init(void) { +void curwin_init(void) +{ win_init_empty(curwin); } @@ -2753,7 +2759,8 @@ void win_init_empty(win_T *wp) * Called from main(). * Return FAIL when something goes wrong (out of memory). */ -int win_alloc_first(void) { +int win_alloc_first(void) +{ if (win_alloc_firstwin(NULL) == FAIL) return FAIL; @@ -2770,7 +2777,8 @@ int win_alloc_first(void) { * Init "aucmd_win". This can only be done after the first * window is fully initialized, thus it can't be in win_alloc_first(). */ -void win_alloc_aucmd_win(void) { +void win_alloc_aucmd_win(void) +{ aucmd_win = win_alloc(NULL, TRUE); if (aucmd_win != NULL) { win_init_some(aucmd_win, curwin); @@ -2800,7 +2808,7 @@ static int win_alloc_firstwin(win_T *oldwin) curbuf->b_nwindows = 1; /* there is one window */ curwin->w_alist = &global_alist; curwin_init(); /* init current window */ - } else { + } else { /* First window in new tab page, initialize it from "oldwin". */ win_init(curwin, oldwin, 0); @@ -2822,7 +2830,8 @@ static int win_alloc_firstwin(win_T *oldwin) /* * Create a frame for window "wp". */ -static void new_frame(win_T *wp) { +static void new_frame(win_T *wp) +{ frame_T *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T)); wp->w_frame = frp; @@ -2835,7 +2844,8 @@ static void new_frame(win_T *wp) { /* * Initialize the window and frame size to the maximum. */ -void win_init_size(void) { +void win_init_size(void) +{ firstwin->w_height = ROWS_AVAIL; topframe->fr_height = ROWS_AVAIL; firstwin->w_width = Columns; @@ -2846,7 +2856,8 @@ void win_init_size(void) { * Allocate a new tabpage_T and init the values. * Returns NULL when out of memory. */ -static tabpage_T *alloc_tabpage(void) { +static tabpage_T *alloc_tabpage(void) +{ tabpage_T *tp; @@ -2915,7 +2926,7 @@ int win_new_tabpage(int after) /* New tab page becomes the first one. */ newtp->tp_next = first_tabpage; first_tabpage = newtp; - } else { + } else { if (after > 0) { /* Put new tab page before tab page "after". */ n = 2; @@ -2950,7 +2961,8 @@ int win_new_tabpage(int after) * like with ":split". * Returns OK if a new tab page was created, FAIL otherwise. */ -int may_open_tabpage(void) { +int may_open_tabpage(void) +{ int n = (cmdmod.tab == 0) ? postponed_split_tab : cmdmod.tab; if (n != 0) { @@ -3153,7 +3165,7 @@ void goto_tabpage(int n) tp = first_tabpage; else tp = curtab->tp_next; - } else if (n < 0) { + } else if (n < 0) { /* "gT": go to previous tab page, wrap around end. "N gT" repeats * this N times. */ ttp = curtab; @@ -3163,11 +3175,11 @@ void goto_tabpage(int n) ; ttp = tp; } - } else if (n == 9999) { + } else if (n == 9999) { /* Go to last tab page. */ for (tp = first_tabpage; tp->tp_next != NULL; tp = tp->tp_next) ; - } else { + } else { /* Go to tab page "n". */ tp = find_tabpage(n); if (tp == NULL) { @@ -3241,7 +3253,7 @@ void tabpage_move(int nr) if (n <= 0) { curtab->tp_next = first_tabpage; first_tabpage = curtab; - } else { + } else { for (tp = first_tabpage; tp->tp_next != NULL && n > 1; tp = tp->tp_next) --n; curtab->tp_next = tp->tp_next; @@ -3491,7 +3503,7 @@ static void win_enter_ext(win_T *wp, int undo_sync, int curwin_invalid, int trig } if (mch_chdir((char *)curwin->w_localdir) == 0) shorten_fnames(TRUE); - } else if (globaldir != NULL) { + } else if (globaldir != NULL) { /* Window doesn't have a local directory and we are not in the global * directory: Change to the global directory. */ ignored = mch_chdir((char *)globaldir); @@ -3817,7 +3829,8 @@ void win_free_lsize(win_T *wp) * Called from win_new_shellsize() after Rows changed. * This only does the current tab page, others must be done when made active. */ -void shell_new_rows(void) { +void shell_new_rows(void) +{ int h = (int)ROWS_AVAIL; if (firstwin == NULL) /* not initialized yet */ @@ -3840,7 +3853,8 @@ void shell_new_rows(void) { /* * Called from win_new_shellsize() after Columns changed. */ -void shell_new_columns(void) { +void shell_new_columns(void) +{ if (firstwin == NULL) /* not initialized yet */ return; @@ -3895,7 +3909,8 @@ void win_size_restore(garray_T *gap) * frames. * Returns the row just after the last window. */ -int win_comp_pos(void) { +int win_comp_pos(void) +{ int row = tabline_height(); int col = 0; @@ -3929,7 +3944,7 @@ static void frame_comp_pos(frame_T *topfrp, int *row, int *col) } *row += wp->w_height + wp->w_status_height; *col += wp->w_width + wp->w_vsep_width; - } else { + } else { startrow = *row; startcol = *col; for (frp = topfrp->fr_child; frp != NULL; frp = frp->fr_next) { @@ -4021,14 +4036,14 @@ static void frame_setheight(frame_T *curfrp, int height) height = ROWS_AVAIL; if (height > 0) frame_new_height(curfrp, height, FALSE, FALSE); - } else if (curfrp->fr_parent->fr_layout == FR_ROW) { + } 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. */ h = frame_minheight(curfrp->fr_parent, NULL); if (height < h) height = h; frame_setheight(curfrp->fr_parent, height); - } else { + } else { /* * Column of frames: try to change only frames in this column. */ @@ -4126,11 +4141,11 @@ static void frame_setheight(frame_T *curfrp, int height) frame_new_height(frp, room_reserved, FALSE, FALSE); room_reserved = 0; } - } else { + } else { if (frp->fr_height - take < h) { take -= frp->fr_height - h; frame_new_height(frp, h, FALSE, FALSE); - } else { + } else { frame_new_height(frp, frp->fr_height - take, FALSE, FALSE); take = 0; @@ -4204,7 +4219,7 @@ static void frame_setwidth(frame_T *curfrp, int width) if (width < w) width = w; frame_setwidth(curfrp->fr_parent, width); - } else { + } else { /* * Row of frames: try to change only frames in this row. * @@ -4282,11 +4297,11 @@ static void frame_setwidth(frame_T *curfrp, int width) frame_new_width(frp, room_reserved, FALSE, FALSE); room_reserved = 0; } - } else { + } else { if (frp->fr_width - take < w) { take -= frp->fr_width - w; frame_new_width(frp, w, FALSE, FALSE); - } else { + } else { frame_new_width(frp, frp->fr_width - take, FALSE, FALSE); take = 0; @@ -4304,7 +4319,8 @@ static void frame_setwidth(frame_T *curfrp, int width) /* * Check 'winminheight' for a valid value. */ -void win_setminheight(void) { +void win_setminheight(void) +{ int room; int first = TRUE; win_T *wp; @@ -4367,7 +4383,7 @@ void win_drag_status_line(win_T *dragwin, int offset) if (fr == curfr) { /* only one window */ room = fr->fr_height - frame_minheight(fr, NULL); - } else { + } else { room = 0; for (fr = fr->fr_child;; fr = fr->fr_next) { room += fr->fr_height - frame_minheight(fr, NULL); @@ -4376,7 +4392,7 @@ void win_drag_status_line(win_T *dragwin, int offset) } } fr = curfr->fr_next; /* put fr at frame that grows */ - } else { /* drag down */ + } else { /* drag down */ up = FALSE; /* * Only dragging the last status line can reduce p_ch. @@ -4419,7 +4435,7 @@ void win_drag_status_line(win_T *dragwin, int offset) if (fr->fr_height - offset <= n) { offset -= fr->fr_height - n; frame_new_height(fr, n, !up, FALSE); - } else { + } else { frame_new_height(fr, fr->fr_height - offset, !up, FALSE); break; } @@ -4487,7 +4503,7 @@ void win_drag_vsep_line(win_T *dragwin, int offset) break; } fr = curfr->fr_next; /* put fr at frame that grows */ - } else { /* drag right */ + } else { /* drag right */ left = FALSE; /* sum up the room of frames right of the current one */ room = 0; @@ -4515,7 +4531,7 @@ void win_drag_vsep_line(win_T *dragwin, int offset) if (fr->fr_width - offset <= n) { offset -= fr->fr_width - n; frame_new_width(fr, n, !left, FALSE); - } else { + } else { frame_new_width(fr, fr->fr_width - offset, !left, FALSE); break; } @@ -4606,7 +4622,7 @@ void win_new_height(win_T *wp, int height) --wp->w_wrow; } } - } else { + } else { while (sline > 0 && lnum > 1) { hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); if (lnum == 1) { @@ -4632,7 +4648,7 @@ void win_new_height(win_T *wp, int height) hasFoldingWin(wp, lnum, NULL, &lnum, TRUE, NULL); lnum++; wp->w_wrow -= line_size + sline; - } else if (sline > 0) { + } else if (sline > 0) { /* First line of file reached, use that as topline. */ lnum = 1; wp->w_wrow -= sline; @@ -4681,7 +4697,8 @@ void win_comp_scroll(win_T *wp) /* * command_height: called whenever p_ch has been changed */ -void command_height(void) { +void command_height(void) +{ int h; frame_T *frp; int old_p_ch = curtab->tp_ch_used; @@ -4785,7 +4802,7 @@ static void last_status_rec(frame_T *fr, int statusline) win_new_height(wp, wp->w_height + 1); wp->w_status_height = 0; comp_col(); - } else if (wp->w_status_height == 0 && statusline) { + } else if (wp->w_status_height == 0 && statusline) { /* Find a frame to take a line from. */ fp = fr; while (fp->fr_height <= frame_minheight(fp, NULL)) { @@ -4810,11 +4827,11 @@ static void last_status_rec(frame_T *fr, int statusline) comp_col(); redraw_all_later(SOME_VALID); } - } else if (fr->fr_layout == FR_ROW) { + } else if (fr->fr_layout == FR_ROW) { /* vertically split windows, set status line for each one */ for (fp = fr->fr_child; fp != NULL; fp = fp->fr_next) last_status_rec(fp, statusline); - } else { + } else { /* horizontally split window, set status line for last one */ for (fp = fr->fr_child; fp->fr_next != NULL; fp = fp->fr_next) ; @@ -4825,7 +4842,8 @@ static void last_status_rec(frame_T *fr, int statusline) /* * Return the number of lines used by the tab page line. */ -int tabline_height(void) { +int tabline_height(void) +{ switch (p_stal) { case 0: return 0; case 1: return (first_tabpage->tp_next == NULL) ? 0 : 1; @@ -5102,7 +5120,8 @@ vim_FullName ( * Return the minimal number of rows that is needed on the screen to display * the current number of windows. */ -int min_rows(void) { +int min_rows(void) +{ int total; tabpage_T *tp; int n; @@ -5126,7 +5145,8 @@ int min_rows(void) { * counting a help or preview window, unless it is the current window. * Does not count "aucmd_win". */ -int only_one_window(void) { +int only_one_window(void) +{ int count = 0; win_T *wp; |