mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.1208: code is indented more than necessary
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11819)
This commit is contained in:
parent
450c7a97d1
commit
a41e221935
@ -938,14 +938,14 @@ nb_partialremove(linenr_T lnum, colnr_T first, colnr_T last)
|
||||
if (lastbyte >= oldlen)
|
||||
lastbyte = oldlen - 1;
|
||||
newtext = alloc(oldlen - (int)(lastbyte - first));
|
||||
if (newtext != NULL)
|
||||
{
|
||||
if (newtext == NULL)
|
||||
return;
|
||||
|
||||
mch_memmove(newtext, oldtext, first);
|
||||
STRMOVE(newtext + first, oldtext + lastbyte + 1);
|
||||
nbdebug((" NEW LINE %ld: %s\n", lnum, newtext));
|
||||
ml_replace(lnum, newtext, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace the "first" line with the concatenation of the "first" and
|
||||
@ -960,13 +960,13 @@ nb_joinlines(linenr_T first, linenr_T other)
|
||||
len_first = (int)STRLEN(ml_get(first));
|
||||
len_other = (int)STRLEN(ml_get(other));
|
||||
p = alloc(len_first + len_other + 1);
|
||||
if (p != NULL)
|
||||
{
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
mch_memmove(p, ml_get(first), len_first);
|
||||
mch_memmove(p + len_first, ml_get(other), len_other + 1);
|
||||
ml_replace(first, p, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
#define SKIP_STOP 2
|
||||
#define streq(a,b) (strcmp(a,b) == 0)
|
||||
@ -2247,14 +2247,15 @@ nb_do_cmd(
|
||||
static void
|
||||
nb_set_curbuf(buf_T *buf)
|
||||
{
|
||||
if (curbuf != buf) {
|
||||
if (curbuf == buf)
|
||||
return;
|
||||
|
||||
if (buf_jump_open_win(buf) != NULL)
|
||||
return;
|
||||
if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL)
|
||||
return;
|
||||
set_curbuf(buf, DOBUF_GOTO);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a vim colon command.
|
||||
@ -2364,15 +2365,15 @@ nb_init_graphics(void)
|
||||
{
|
||||
static int did_init = FALSE;
|
||||
|
||||
if (!did_init)
|
||||
{
|
||||
if (did_init)
|
||||
return;
|
||||
|
||||
coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black"
|
||||
" ctermbg=LightCyan ctermfg=Black");
|
||||
coloncmd(":sign define %d linehl=NBGuarded", GUARDED);
|
||||
|
||||
did_init = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert key to netbeans name. This uses the global "mod_mask".
|
||||
@ -2468,8 +2469,9 @@ netbeans_beval_cb(
|
||||
if (!can_use_beval() || !NETBEANS_OPEN)
|
||||
return;
|
||||
|
||||
if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
|
||||
{
|
||||
if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) != OK)
|
||||
return;
|
||||
|
||||
// Send debugger request. Only when the text is of reasonable
|
||||
// length.
|
||||
if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL)
|
||||
@ -2491,7 +2493,6 @@ netbeans_beval_cb(
|
||||
}
|
||||
vim_free(text);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -2555,12 +2556,12 @@ set_ref_in_nb_channel(int copyID)
|
||||
int abort = FALSE;
|
||||
typval_T tv;
|
||||
|
||||
if (nb_channel != NULL)
|
||||
{
|
||||
if (nb_channel == NULL)
|
||||
return FALSE;
|
||||
|
||||
tv.v_type = VAR_CHANNEL;
|
||||
tv.vval.v_channel = nb_channel;
|
||||
abort = set_ref_in_item(&tv, copyID, NULL, NULL);
|
||||
}
|
||||
return abort;
|
||||
}
|
||||
#endif
|
||||
@ -2827,8 +2828,9 @@ netbeans_button_release(int button)
|
||||
|
||||
bufno = nb_getbufno(curbuf);
|
||||
|
||||
if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf)
|
||||
{
|
||||
if (bufno < 0 || curwin == NULL || curwin->w_buffer != curbuf)
|
||||
return;
|
||||
|
||||
int col = mouse_col - curwin->w_wincol
|
||||
- ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1);
|
||||
long off = pos2off(curbuf, &curwin->w_cursor);
|
||||
@ -2843,7 +2845,6 @@ netbeans_button_release(int button)
|
||||
nbdebug(("EVT: %s", buf));
|
||||
nb_send(buf, "netbeans_button_release");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -3308,8 +3309,7 @@ get_buf_size(buf_T *bufp)
|
||||
|
||||
if (bufp->b_ml.ml_flags & ML_EMPTY)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
|
||||
if (get_fileformat(bufp) == EOL_DOS)
|
||||
eol_size = 2;
|
||||
else
|
||||
@ -3330,7 +3330,6 @@ get_buf_size(buf_T *bufp)
|
||||
// Correction for when last line doesn't have an EOL.
|
||||
if (!bufp->b_p_eol && (bufp->b_p_bin || !bufp->b_p_fixeol))
|
||||
char_count -= eol_size;
|
||||
}
|
||||
|
||||
return char_count;
|
||||
}
|
||||
@ -3393,12 +3392,12 @@ pos2off(buf_T *buf, pos_T *pos)
|
||||
{
|
||||
long offset = 0;
|
||||
|
||||
if (!(buf->b_ml.ml_flags & ML_EMPTY))
|
||||
{
|
||||
if (buf->b_ml.ml_flags & ML_EMPTY)
|
||||
return 0;
|
||||
|
||||
if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0)
|
||||
return 0;
|
||||
offset += pos->col;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
158
src/normal.c
158
src/normal.c
@ -186,15 +186,14 @@ find_command(int cmdchar)
|
||||
static int
|
||||
check_text_locked(oparg_T *oap)
|
||||
{
|
||||
if (text_locked())
|
||||
{
|
||||
if (!text_locked())
|
||||
return FALSE;
|
||||
|
||||
if (oap != NULL)
|
||||
clearopbeep(oap);
|
||||
text_locked_msg();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* If text is locked, "curbuf_lock" or "allbuf_lock" is set:
|
||||
@ -206,14 +205,14 @@ check_text_or_curbuf_locked(oparg_T *oap)
|
||||
{
|
||||
if (check_text_locked(oap))
|
||||
return TRUE;
|
||||
if (curbuf_locked())
|
||||
{
|
||||
|
||||
if (!curbuf_locked())
|
||||
return FALSE;
|
||||
|
||||
if (oap != NULL)
|
||||
clearop(oap);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle the count before a normal command and set cap->count0.
|
||||
@ -2030,8 +2029,9 @@ nv_addsub(cmdarg_T *cap)
|
||||
static void
|
||||
nv_page(cmdarg_T *cap)
|
||||
{
|
||||
if (!checkclearop(cap->oap))
|
||||
{
|
||||
if (checkclearop(cap->oap))
|
||||
return;
|
||||
|
||||
if (mod_mask & MOD_MASK_CTRL)
|
||||
{
|
||||
// <C-PageUp>: tab page back; <C-PageDown>: tab page forward
|
||||
@ -2043,7 +2043,6 @@ nv_page(cmdarg_T *cap)
|
||||
else
|
||||
(void)onepage(cap->arg, cap->count1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of "gd" and "gD" command.
|
||||
@ -2062,9 +2061,9 @@ nv_gd(
|
||||
== FAIL)
|
||||
{
|
||||
clearopbeep(oap);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#ifdef FEAT_FOLDING
|
||||
if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP)
|
||||
foldOpenCursor();
|
||||
@ -2073,7 +2072,6 @@ nv_gd(
|
||||
if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT))
|
||||
clear_cmdline = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if line[offset] is not inside a C-style comment or string, FALSE
|
||||
@ -3157,9 +3155,11 @@ nv_colon(cmdarg_T *cap)
|
||||
int flags;
|
||||
|
||||
if (VIsual_active && !is_cmdkey)
|
||||
nv_operator(cap);
|
||||
else
|
||||
{
|
||||
nv_operator(cap);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cap->oap->op_type != OP_NOP)
|
||||
{
|
||||
// Using ":" as a movement is characterwise exclusive.
|
||||
@ -3211,7 +3211,6 @@ nv_colon(cmdarg_T *cap)
|
||||
// The start of the operator has become invalid by the Ex command.
|
||||
clearopbeep(cap->oap);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle CTRL-G command.
|
||||
@ -3251,8 +3250,9 @@ nv_ctrlh(cmdarg_T *cap)
|
||||
static void
|
||||
nv_clear(cmdarg_T *cap)
|
||||
{
|
||||
if (!checkclearop(cap->oap))
|
||||
{
|
||||
if (checkclearop(cap->oap))
|
||||
return;
|
||||
|
||||
#ifdef FEAT_SYN_HL
|
||||
// Clear all syntax states to force resyncing.
|
||||
syn_stack_free_all(curwin->w_s);
|
||||
@ -3273,7 +3273,6 @@ nv_clear(cmdarg_T *cap)
|
||||
resize_console_buf();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CTRL-O: In Select mode: switch to Visual mode for one command.
|
||||
@ -3314,8 +3313,9 @@ nv_hat(cmdarg_T *cap)
|
||||
static void
|
||||
nv_Zet(cmdarg_T *cap)
|
||||
{
|
||||
if (!checkclearopq(cap->oap))
|
||||
{
|
||||
if (checkclearopq(cap->oap))
|
||||
return;
|
||||
|
||||
switch (cap->nchar)
|
||||
{
|
||||
// "ZZ": equivalent to ":x".
|
||||
@ -3329,7 +3329,6 @@ nv_Zet(cmdarg_T *cap)
|
||||
default: clearopbeep(cap->oap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Call nv_ident() as if "c1" was used, with "c2" as next character.
|
||||
@ -3982,16 +3981,15 @@ nv_up(cmdarg_T *cap)
|
||||
// <S-Up> is page up
|
||||
cap->arg = BACKWARD;
|
||||
nv_page(cap);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
cap->oap->motion_type = MLINE;
|
||||
if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL)
|
||||
clearopbeep(cap->oap);
|
||||
else if (cap->arg)
|
||||
beginline(BL_WHITE | BL_FIX);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Cursor down commands.
|
||||
@ -4249,9 +4247,11 @@ nv_csearch(cmdarg_T *cap)
|
||||
|
||||
cap->oap->motion_type = MCHAR;
|
||||
if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL)
|
||||
clearopbeep(cap->oap);
|
||||
else
|
||||
{
|
||||
clearopbeep(cap->oap);
|
||||
return;
|
||||
}
|
||||
|
||||
curwin->w_set_curswant = TRUE;
|
||||
// Include a Tab for "tx" and for "dfx".
|
||||
if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD
|
||||
@ -4270,7 +4270,6 @@ nv_csearch(cmdarg_T *cap)
|
||||
foldOpenCursor();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "[{", "[(", "]}" or "])": go to Nth unclosed '{', '(', '}' or ')'
|
||||
@ -4654,9 +4653,11 @@ nv_brace(cmdarg_T *cap)
|
||||
curwin->w_set_curswant = TRUE;
|
||||
|
||||
if (findsent(cap->arg, cap->count1) == FAIL)
|
||||
clearopbeep(cap->oap);
|
||||
else
|
||||
{
|
||||
clearopbeep(cap->oap);
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't leave the cursor on the NUL past end of line.
|
||||
adjust_cursor(cap->oap);
|
||||
curwin->w_cursor.coladd = 0;
|
||||
@ -4665,7 +4666,6 @@ nv_brace(cmdarg_T *cap)
|
||||
foldOpenCursor();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "m" command: Mark a position.
|
||||
@ -4673,12 +4673,12 @@ nv_brace(cmdarg_T *cap)
|
||||
static void
|
||||
nv_mark(cmdarg_T *cap)
|
||||
{
|
||||
if (!checkclearop(cap->oap))
|
||||
{
|
||||
if (checkclearop(cap->oap))
|
||||
return;
|
||||
|
||||
if (setmark(cap->nchar) == FAIL)
|
||||
clearopbeep(cap->oap);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "{" and "}" commands.
|
||||
@ -4692,16 +4692,17 @@ nv_findpar(cmdarg_T *cap)
|
||||
cap->oap->use_reg_one = TRUE;
|
||||
curwin->w_set_curswant = TRUE;
|
||||
if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE))
|
||||
clearopbeep(cap->oap);
|
||||
else
|
||||
{
|
||||
clearopbeep(cap->oap);
|
||||
return;
|
||||
}
|
||||
|
||||
curwin->w_cursor.coladd = 0;
|
||||
#ifdef FEAT_FOLDING
|
||||
if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
|
||||
foldOpenCursor();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "u" command: Undo or make lower case.
|
||||
@ -4726,8 +4727,9 @@ nv_undo(cmdarg_T *cap)
|
||||
static void
|
||||
nv_kundo(cmdarg_T *cap)
|
||||
{
|
||||
if (!checkclearopq(cap->oap))
|
||||
{
|
||||
if (checkclearopq(cap->oap))
|
||||
return;
|
||||
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
if (bt_prompt(curbuf))
|
||||
{
|
||||
@ -4738,7 +4740,6 @@ nv_kundo(cmdarg_T *cap)
|
||||
u_undo((int)cap->count1);
|
||||
curwin->w_set_curswant = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle the "r" command.
|
||||
@ -5008,9 +5009,12 @@ nv_Replace(cmdarg_T *cap)
|
||||
VIsual_mode_orig = VIsual_mode; // remember original area for gv
|
||||
VIsual_mode = 'V';
|
||||
nv_operator(cap);
|
||||
return;
|
||||
}
|
||||
else if (!checkclearopq(cap->oap))
|
||||
{
|
||||
|
||||
if (checkclearopq(cap->oap))
|
||||
return;
|
||||
|
||||
if (!curbuf->b_p_ma)
|
||||
emsg(_(e_cannot_make_changes_modifiable_is_off));
|
||||
else
|
||||
@ -5020,7 +5024,6 @@ nv_Replace(cmdarg_T *cap)
|
||||
invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "gr".
|
||||
@ -5033,9 +5036,12 @@ 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
|
||||
return;
|
||||
}
|
||||
else if (!checkclearopq(cap->oap))
|
||||
{
|
||||
|
||||
if (checkclearopq(cap->oap))
|
||||
return;
|
||||
|
||||
if (!curbuf->b_p_ma)
|
||||
emsg(_(e_cannot_make_changes_modifiable_is_off));
|
||||
else
|
||||
@ -5049,7 +5055,6 @@ nv_vreplace(cmdarg_T *cap)
|
||||
invoke_edit(cap, TRUE, 'v', FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Swap case for "~" command, when it does not work like an operator.
|
||||
@ -5345,8 +5350,9 @@ nv_pcmark(cmdarg_T *cap)
|
||||
int old_KeyTyped = KeyTyped; // getting file may reset it
|
||||
#endif
|
||||
|
||||
if (!checkclearopq(cap->oap))
|
||||
{
|
||||
if (checkclearopq(cap->oap))
|
||||
return;
|
||||
|
||||
if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL)
|
||||
{
|
||||
if (goto_tabpage_lastused() == FAIL)
|
||||
@ -5383,7 +5389,6 @@ nv_pcmark(cmdarg_T *cap)
|
||||
foldOpenCursor();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle '"' command.
|
||||
@ -6237,8 +6242,9 @@ n_opencmd(cmdarg_T *cap)
|
||||
linenr_T oldline = curwin->w_cursor.lnum;
|
||||
#endif
|
||||
|
||||
if (!checkclearopq(cap->oap))
|
||||
{
|
||||
if (checkclearopq(cap->oap))
|
||||
return;
|
||||
|
||||
#ifdef FEAT_FOLDING
|
||||
if (cap->cmdchar == 'O')
|
||||
// Open above the first line of a folded sequence of lines
|
||||
@ -6273,7 +6279,6 @@ n_opencmd(cmdarg_T *cap)
|
||||
invoke_edit(cap, FALSE, cap->cmdchar, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "." command: redo last change.
|
||||
@ -6281,15 +6286,15 @@ n_opencmd(cmdarg_T *cap)
|
||||
static void
|
||||
nv_dot(cmdarg_T *cap)
|
||||
{
|
||||
if (!checkclearopq(cap->oap))
|
||||
{
|
||||
if (checkclearopq(cap->oap))
|
||||
return;
|
||||
|
||||
// If "restart_edit" is TRUE, the last but one command is repeated
|
||||
// instead of the last command (inserting text). This is used for
|
||||
// CTRL-O <.> in insert mode.
|
||||
if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL)
|
||||
clearopbeep(cap->oap);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CTRL-R: undo undo or specify register in select mode
|
||||
@ -6316,12 +6321,12 @@ nv_redo_or_register(cmdarg_T *cap)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkclearopq(cap->oap))
|
||||
{
|
||||
if (checkclearopq(cap->oap))
|
||||
return;
|
||||
|
||||
u_redo((int)cap->count1);
|
||||
curwin->w_set_curswant = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle "U" command.
|
||||
@ -6336,13 +6341,15 @@ nv_Undo(cmdarg_T *cap)
|
||||
cap->cmdchar = 'g';
|
||||
cap->nchar = 'U';
|
||||
nv_operator(cap);
|
||||
return;
|
||||
}
|
||||
else if (!checkclearopq(cap->oap))
|
||||
{
|
||||
|
||||
if (checkclearopq(cap->oap))
|
||||
return;
|
||||
|
||||
u_undoline();
|
||||
curwin->w_set_curswant = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* '~' command: If tilde is not an operator and Visual is off: swap case of a
|
||||
@ -7146,9 +7153,12 @@ nv_record(cmdarg_T *cap)
|
||||
cap->cmdchar = 'g';
|
||||
cap->nchar = 'q';
|
||||
nv_operator(cap);
|
||||
return;
|
||||
}
|
||||
else if (!checkclearop(cap->oap))
|
||||
{
|
||||
|
||||
if (checkclearop(cap->oap))
|
||||
return;
|
||||
|
||||
if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?')
|
||||
{
|
||||
if (cmdwin_type != 0)
|
||||
@ -7165,7 +7175,6 @@ nv_record(cmdarg_T *cap)
|
||||
if (reg_executing == 0 && do_record(cap->nchar) == FAIL)
|
||||
clearopbeep(cap->oap);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle the "@r" command.
|
||||
@ -7214,9 +7223,14 @@ nv_halfpage(cmdarg_T *cap)
|
||||
nv_join(cmdarg_T *cap)
|
||||
{
|
||||
if (VIsual_active) // join the visual lines
|
||||
nv_operator(cap);
|
||||
else if (!checkclearop(cap->oap))
|
||||
{
|
||||
nv_operator(cap);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkclearop(cap->oap))
|
||||
return;
|
||||
|
||||
if (cap->count0 <= 1)
|
||||
cap->count0 = 2; // default for join is two lines!
|
||||
if (curwin->w_cursor.lnum + cap->count0 - 1 >
|
||||
@ -7236,7 +7250,6 @@ nv_join(cmdarg_T *cap)
|
||||
NUL, cap->cmdchar, NUL, NUL, cap->nchar);
|
||||
(void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "P", "gP", "p" and "gp" commands.
|
||||
@ -7274,15 +7287,17 @@ nv_put_opt(cmdarg_T *cap, int fix_indent)
|
||||
else
|
||||
#endif
|
||||
clearopbeep(cap->oap);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
else if (bt_prompt(curbuf) && !prompt_curpos_editable())
|
||||
if (bt_prompt(curbuf) && !prompt_curpos_editable())
|
||||
{
|
||||
clearopbeep(cap->oap);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
|
||||
if (fix_indent)
|
||||
{
|
||||
dir = (cap->cmdchar == ']' && cap->nchar == 'p')
|
||||
@ -7399,7 +7414,6 @@ nv_put_opt(cmdarg_T *cap, int fix_indent)
|
||||
}
|
||||
auto_format(FALSE, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "o" and "O" commands.
|
||||
|
21
src/ops.c
21
src/ops.c
@ -989,12 +989,12 @@ mb_adjust_opend(oparg_T *oap)
|
||||
{
|
||||
char_u *p;
|
||||
|
||||
if (oap->inclusive)
|
||||
{
|
||||
if (!oap->inclusive)
|
||||
return;
|
||||
|
||||
p = ml_get(oap->end.lnum);
|
||||
oap->end.col += mb_tail_off(p, p + oap->end.col);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace the character under the cursor with "c".
|
||||
@ -1869,11 +1869,13 @@ adjust_cursor_eol(void)
|
||||
{
|
||||
unsigned int cur_ve_flags = get_ve_flags();
|
||||
|
||||
if (curwin->w_cursor.col > 0
|
||||
int adj_cursor = (curwin->w_cursor.col > 0
|
||||
&& gchar_cursor() == NUL
|
||||
&& (cur_ve_flags & VE_ONEMORE) == 0
|
||||
&& !(restart_edit || (State & MODE_INSERT)))
|
||||
{
|
||||
&& !(restart_edit || (State & MODE_INSERT)));
|
||||
if (!adj_cursor)
|
||||
return;
|
||||
|
||||
// Put the cursor on the last character in the line.
|
||||
dec_cursor();
|
||||
|
||||
@ -1886,7 +1888,6 @@ adjust_cursor_eol(void)
|
||||
curwin->w_cursor.coladd = ecol - scol + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If "process" is TRUE and the line begins with a comment leader (possibly
|
||||
@ -2235,13 +2236,13 @@ reset_lbr(void)
|
||||
static void
|
||||
restore_lbr(int lbr_saved)
|
||||
{
|
||||
if (!curwin->w_p_lbr && lbr_saved)
|
||||
{
|
||||
if (curwin->w_p_lbr || !lbr_saved)
|
||||
return;
|
||||
|
||||
// changing 'linebreak' may require w_virtcol to be updated
|
||||
curwin->w_p_lbr = TRUE;
|
||||
curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
31
src/option.c
31
src/option.c
@ -672,18 +672,18 @@ set_string_default_esc(char *name, char_u *val, int escape)
|
||||
p = vim_strsave_escaped(val, (char_u *)" ");
|
||||
else
|
||||
p = vim_strsave(val);
|
||||
if (p != NULL) // we don't want a NULL
|
||||
{
|
||||
if (p == NULL) // we don't want a NULL
|
||||
return;
|
||||
|
||||
opt_idx = findoption((char_u *)name);
|
||||
if (opt_idx >= 0)
|
||||
{
|
||||
if (opt_idx < 0)
|
||||
return;
|
||||
|
||||
if (options[opt_idx].flags & P_DEF_ALLOCED)
|
||||
vim_free(options[opt_idx].def_val[VI_DEFAULT]);
|
||||
options[opt_idx].def_val[VI_DEFAULT] = p;
|
||||
options[opt_idx].flags |= P_DEF_ALLOCED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
set_string_default(char *name, char_u *val)
|
||||
@ -1112,8 +1112,9 @@ set_helplang_default(char_u *lang)
|
||||
if (lang == NULL || STRLEN(lang) < 2) // safety check
|
||||
return;
|
||||
idx = findoption((char_u *)"hlg");
|
||||
if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
|
||||
{
|
||||
if (idx < 0 || (options[idx].flags & P_WAS_SET))
|
||||
return;
|
||||
|
||||
if (options[idx].flags & P_ALLOCED)
|
||||
free_string_option(p_hlg);
|
||||
p_hlg = vim_strsave(lang);
|
||||
@ -1137,7 +1138,6 @@ set_helplang_default(char_u *lang)
|
||||
}
|
||||
options[idx].flags |= P_ALLOCED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -1171,8 +1171,11 @@ set_title_defaults(void)
|
||||
p_title = val;
|
||||
}
|
||||
idx1 = findoption((char_u *)"icon");
|
||||
if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
|
||||
if (idx1 < 0 || (options[idx1].flags & P_WAS_SET))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
if (gui.starting || gui.in_use)
|
||||
val = TRUE;
|
||||
@ -1182,7 +1185,6 @@ set_title_defaults(void)
|
||||
options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
|
||||
p_icon = val;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ex_set(exarg_T *eap)
|
||||
@ -7084,13 +7086,12 @@ reset_option_was_set(char_u *name)
|
||||
{
|
||||
int idx = findoption(name);
|
||||
|
||||
if (idx >= 0)
|
||||
{
|
||||
if (idx < 0)
|
||||
return FAIL;
|
||||
|
||||
options[idx].flags &= ~P_WAS_SET;
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* compatible_set() - Called when 'compatible' has been set or unset.
|
||||
|
@ -155,9 +155,10 @@ trigger_optionset_string(
|
||||
char_u *newval)
|
||||
{
|
||||
// Don't do this recursively.
|
||||
if (oldval != NULL && newval != NULL
|
||||
&& *get_vim_var_str(VV_OPTION_TYPE) == NUL)
|
||||
{
|
||||
if (oldval == NULL || newval == NULL
|
||||
|| *get_vim_var_str(VV_OPTION_TYPE) != NUL)
|
||||
return;
|
||||
|
||||
char_u buf_type[7];
|
||||
|
||||
sprintf((char *)buf_type, "%s",
|
||||
@ -191,7 +192,6 @@ trigger_optionset_string(
|
||||
NULL);
|
||||
reset_v_option_vars();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static char *
|
||||
@ -387,8 +387,9 @@ set_string_option_direct(
|
||||
return;
|
||||
|
||||
s = vim_strsave(val);
|
||||
if (s != NULL)
|
||||
{
|
||||
if (s == NULL)
|
||||
return;
|
||||
|
||||
varp = (char_u **)get_option_varp_scope(idx,
|
||||
both ? OPT_LOCAL : opt_flags);
|
||||
if ((opt_flags & OPT_FREE) && (get_option_flags(idx) & P_ALLOCED))
|
||||
@ -426,7 +427,6 @@ set_string_option_direct(
|
||||
}
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Like set_string_option_direct(), but for a window-local option in "wp".
|
||||
@ -507,8 +507,9 @@ set_string_option(
|
||||
return NULL;
|
||||
|
||||
s = vim_strsave(value == NULL ? (char_u *)"" : value);
|
||||
if (s != NULL)
|
||||
{
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
varp = (char_u **)get_option_varp_scope(opt_idx,
|
||||
(opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
||||
? (is_global_local_option(opt_idx)
|
||||
@ -554,7 +555,6 @@ set_string_option(
|
||||
vim_free(saved_oldval_g);
|
||||
vim_free(saved_newval);
|
||||
#endif
|
||||
}
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
|
@ -234,14 +234,14 @@ mch_delay(long msec, int flags)
|
||||
void Delay(long);
|
||||
#endif
|
||||
|
||||
if (msec > 0)
|
||||
{
|
||||
if (msec <= 0)
|
||||
return;
|
||||
|
||||
if (flags & MCH_DELAY_IGNOREINPUT)
|
||||
Delay(msec / 20L); // Delay works with 20 msec intervals
|
||||
else
|
||||
WaitForChar(raw_in, msec * 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We have no job control, fake it by starting a new shell.
|
||||
@ -577,8 +577,9 @@ fname_case(
|
||||
size_t flen;
|
||||
|
||||
fib = get_fib(name);
|
||||
if (fib != NULL)
|
||||
{
|
||||
if (fib == NULL)
|
||||
return;
|
||||
|
||||
flen = STRLEN(name);
|
||||
// TODO: Check if this fix applies to AmigaOS < 4 too.
|
||||
#ifdef __amigaos4__
|
||||
@ -589,7 +590,6 @@ fname_case(
|
||||
mch_memmove(name, fib->fib_FileName, flen);
|
||||
free_fib(fib);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the FileInfoBlock for file "fname"
|
||||
@ -609,8 +609,9 @@ get_fib(char_u *fname)
|
||||
#else
|
||||
fib = ALLOC_ONE(struct FileInfoBlock);
|
||||
#endif
|
||||
if (fib != NULL)
|
||||
{
|
||||
if (fib == NULL)
|
||||
return;
|
||||
|
||||
flock = Lock((UBYTE *)fname, (long)ACCESS_READ);
|
||||
if (flock == (BPTR)NULL || !Examine(flock, fib))
|
||||
{
|
||||
@ -619,7 +620,6 @@ get_fib(char_u *fname)
|
||||
}
|
||||
if (flock)
|
||||
UnLock(flock);
|
||||
}
|
||||
return fib;
|
||||
}
|
||||
|
||||
@ -815,11 +815,11 @@ mch_getperm(char_u *name)
|
||||
long retval = -1;
|
||||
|
||||
fib = get_fib(name);
|
||||
if (fib != NULL)
|
||||
{
|
||||
if (fib == NULL)
|
||||
return -1;
|
||||
|
||||
retval = fib->fib_Protection;
|
||||
free_fib(fib);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -856,15 +856,15 @@ mch_isdir(char_u *name)
|
||||
int retval = FALSE;
|
||||
|
||||
fib = get_fib(name);
|
||||
if (fib != NULL)
|
||||
{
|
||||
if (fib == NULL)
|
||||
return FALSE;
|
||||
|
||||
#ifdef __amigaos4__
|
||||
retval = (FIB_IS_DRAWER(fib)) ? TRUE : FALSE;
|
||||
#else
|
||||
retval = ((fib->fib_DirEntryType >= 0) ? TRUE : FALSE);
|
||||
#endif
|
||||
free_fib(fib);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -877,13 +877,12 @@ mch_mkdir(char_u *name)
|
||||
BPTR lock;
|
||||
|
||||
lock = CreateDir(name);
|
||||
if (lock != NULL)
|
||||
{
|
||||
if (lock == NULL)
|
||||
return -1;
|
||||
|
||||
UnLock(lock);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 1 if "name" can be executed, 0 if not.
|
||||
@ -1173,8 +1172,9 @@ out:
|
||||
void
|
||||
mch_set_shellsize(void)
|
||||
{
|
||||
if (term_console)
|
||||
{
|
||||
if (!term_console)
|
||||
return;
|
||||
|
||||
size_set = TRUE;
|
||||
out_char(CSI);
|
||||
out_num((long)Rows);
|
||||
@ -1184,7 +1184,6 @@ mch_set_shellsize(void)
|
||||
out_char('u');
|
||||
out_flush();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Rows and/or Columns has changed.
|
||||
|
@ -568,8 +568,9 @@ mac_utf8_to_utf16(
|
||||
void
|
||||
mac_lang_init(void)
|
||||
{
|
||||
if (mch_getenv((char_u *)"LANG") == NULL)
|
||||
{
|
||||
if (mch_getenv((char_u *)"LANG") != NULL)
|
||||
return;
|
||||
|
||||
char buf[50];
|
||||
|
||||
// $LANG is not set, either because it was unset or Vim was started
|
||||
@ -591,5 +592,4 @@ mac_lang_init(void)
|
||||
# endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // MACOS_CONVERT
|
||||
|
@ -835,8 +835,9 @@ check_str_len(char_u *str)
|
||||
GetSystemInfo(&si);
|
||||
|
||||
// get memory information
|
||||
if (VirtualQuery(str, &mbi, sizeof(mbi)))
|
||||
{
|
||||
if (!VirtualQuery(str, &mbi, sizeof(mbi)))
|
||||
return 0;
|
||||
|
||||
// pre cast these (typing savers)
|
||||
long_u dwStr = (long_u)str;
|
||||
long_u dwBaseAddress = (long_u)mbi.BaseAddress;
|
||||
@ -852,7 +853,6 @@ check_str_len(char_u *str)
|
||||
for (i = 0; i < pageLength; ++i, ++length)
|
||||
if (p[i] == NUL)
|
||||
return length + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1213,8 +1213,9 @@ PrintHookProc(
|
||||
RECT rc, rcDlg, rcOwner;
|
||||
PRINTDLGW *pPD;
|
||||
|
||||
if (uiMsg == WM_INITDIALOG)
|
||||
{
|
||||
if (uiMsg != WM_INITDIALOG)
|
||||
return FALSE;
|
||||
|
||||
// Get the owner window and dialog box rectangles.
|
||||
if ((hwndOwner = GetParent(hDlg)) == NULL)
|
||||
hwndOwner = GetDesktopWindow();
|
||||
@ -1249,7 +1250,6 @@ PrintHookProc(
|
||||
// Bring the window to top
|
||||
BringWindowToTop(GetParent(hDlg));
|
||||
SetForegroundWindow(hDlg);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -1571,7 +1571,6 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
|
||||
return TRUE;
|
||||
|
||||
init_fail_dlg:
|
||||
{
|
||||
DWORD err = CommDlgExtendedError();
|
||||
|
||||
if (err)
|
||||
@ -1594,7 +1593,6 @@ init_fail_dlg:
|
||||
mch_print_cleanup();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
@ -1999,12 +1997,12 @@ serverSendEnc(HWND target)
|
||||
static void
|
||||
CleanUpMessaging(void)
|
||||
{
|
||||
if (message_window != 0)
|
||||
{
|
||||
if (message_window == 0)
|
||||
return;
|
||||
|
||||
DestroyWindow(message_window);
|
||||
message_window = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int save_reply(HWND server, char_u *reply, int expr);
|
||||
|
||||
|
@ -67,8 +67,9 @@ clip_mch_request_selection(Clipboard_T *cbd)
|
||||
char_u *clip_text = NULL;
|
||||
|
||||
cbdata = PhClipboardPasteStart(PhInputGroup(NULL));
|
||||
if (cbdata != NULL)
|
||||
{
|
||||
if (cbdata == NULL)
|
||||
return;
|
||||
|
||||
// Look for the vim specific clip first
|
||||
clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM);
|
||||
if (clip_header != NULL && clip_header->data != NULL)
|
||||
@ -99,7 +100,6 @@ clip_mch_request_selection(Clipboard_T *cbd)
|
||||
|
||||
PhClipboardPasteFinish(cbdata);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
clip_mch_set_selection(Clipboard_T *cbd)
|
||||
|
@ -780,8 +780,9 @@ get_stack_limit(void)
|
||||
int
|
||||
mch_stackcheck(char *p)
|
||||
{
|
||||
if (stack_limit != NULL)
|
||||
{
|
||||
if (stack_limit == NULL)
|
||||
return OK;
|
||||
|
||||
if (stack_grows_downwards)
|
||||
{
|
||||
if (p < stack_limit)
|
||||
@ -789,7 +790,6 @@ mch_stackcheck(char *p)
|
||||
}
|
||||
else if (p > stack_limit)
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
@ -837,8 +837,9 @@ static char *signal_stack;
|
||||
static void
|
||||
init_signal_stack(void)
|
||||
{
|
||||
if (signal_stack != NULL)
|
||||
{
|
||||
if (signal_stack == NULL)
|
||||
return;
|
||||
|
||||
# ifdef HAVE_SIGALTSTACK
|
||||
# ifdef HAVE_SS_BASE
|
||||
sigstk.ss_base = signal_stack;
|
||||
@ -856,7 +857,6 @@ init_signal_stack(void)
|
||||
(void)sigstack(&sigstk, NULL);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -2020,8 +2020,9 @@ get_x11_thing(
|
||||
int retval = FALSE;
|
||||
Status status;
|
||||
|
||||
if (get_x11_windis() == OK)
|
||||
{
|
||||
if (get_x11_windis() != OK)
|
||||
return FALSE;
|
||||
|
||||
// Get window/icon name if any
|
||||
if (get_title)
|
||||
status = XGetWMName(x11_display, x11_window, &text_prop);
|
||||
@ -2037,7 +2038,6 @@ get_x11_thing(
|
||||
// Previously this was only done for xterm and alike. I don't see a
|
||||
// reason why it would fail for other terminal emulators.
|
||||
// if (term_is_xterm)
|
||||
{
|
||||
Window root;
|
||||
Window parent;
|
||||
Window win = x11_window;
|
||||
@ -2060,7 +2060,7 @@ get_x11_thing(
|
||||
else
|
||||
status = XGetWMIconName(x11_display, win, &text_prop);
|
||||
}
|
||||
}
|
||||
|
||||
if (status && text_prop.value != NULL)
|
||||
{
|
||||
retval = TRUE;
|
||||
@ -2105,7 +2105,6 @@ get_x11_thing(
|
||||
}
|
||||
XFree((void *)text_prop.value);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2772,8 +2771,9 @@ fname_case(
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
|
||||
if (mch_lstat((char *)name, &st) >= 0)
|
||||
{
|
||||
if (mch_lstat((char *)name, &st) < 0)
|
||||
return;
|
||||
|
||||
// Open the directory where the file is located.
|
||||
slash = vim_strrchr(name, '/');
|
||||
if (slash == NULL)
|
||||
@ -2789,8 +2789,9 @@ fname_case(
|
||||
tail = slash + 1;
|
||||
}
|
||||
|
||||
if (dirp != NULL)
|
||||
{
|
||||
if (dirp == NULL)
|
||||
return;
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL)
|
||||
{
|
||||
// Only accept names that differ in case and are the same byte
|
||||
@ -2817,8 +2818,6 @@ fname_case(
|
||||
|
||||
closedir(dirp);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -2902,8 +2901,9 @@ mch_copy_sec(char_u *from_file, char_u *to_file)
|
||||
if (selinux_enabled == -1)
|
||||
selinux_enabled = is_selinux_enabled();
|
||||
|
||||
if (selinux_enabled > 0)
|
||||
{
|
||||
if (selinux_enabled <= 0)
|
||||
return;
|
||||
|
||||
// Use "char *" instead of "security_context_t" to avoid a deprecation
|
||||
// warning.
|
||||
char *from_context = NULL;
|
||||
@ -2942,7 +2942,6 @@ mch_copy_sec(char_u *from_file, char_u *to_file)
|
||||
freecon(to_context);
|
||||
freecon(from_context);
|
||||
}
|
||||
}
|
||||
#endif // HAVE_SELINUX
|
||||
|
||||
#if defined(HAVE_SMACK) && !defined(PROTO)
|
||||
@ -3549,8 +3548,9 @@ mch_tcgetattr(int fd, void *term)
|
||||
int retval = -1;
|
||||
|
||||
tty_fd = get_tty_fd(fd);
|
||||
if (tty_fd >= 0)
|
||||
{
|
||||
if (tty_fd < 0)
|
||||
return -1;
|
||||
|
||||
#ifdef NEW_TTY_SYSTEM
|
||||
# ifdef HAVE_TERMIOS_H
|
||||
retval = tcgetattr(tty_fd, (struct termios *)term);
|
||||
@ -3563,7 +3563,6 @@ mch_tcgetattr(int fd, void *term)
|
||||
#endif
|
||||
if (tty_fd != fd)
|
||||
close(tty_fd);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -3682,8 +3681,9 @@ get_stty(void)
|
||||
char_u buf[2];
|
||||
char_u *p;
|
||||
|
||||
if (get_tty_info(read_cmd_fd, &info) == OK)
|
||||
{
|
||||
if (get_tty_info(read_cmd_fd, &info) != OK)
|
||||
return;
|
||||
|
||||
intr_char = info.interrupt;
|
||||
buf[0] = info.backspace;
|
||||
buf[1] = NUL;
|
||||
@ -3694,7 +3694,6 @@ get_stty(void)
|
||||
if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
|
||||
do_fixdel(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Obtain the characters that Backspace and Enter produce on "fd".
|
||||
@ -4160,8 +4159,9 @@ mch_report_winsize(int fd, int rows, int cols)
|
||||
int retval = -1;
|
||||
|
||||
tty_fd = get_tty_fd(fd);
|
||||
if (tty_fd >= 0)
|
||||
{
|
||||
if (tty_fd < 0)
|
||||
return FAIL;
|
||||
|
||||
# if defined(TIOCSWINSZ)
|
||||
struct winsize ws;
|
||||
|
||||
@ -4183,7 +4183,6 @@ mch_report_winsize(int fd, int rows, int cols)
|
||||
# endif
|
||||
if (tty_fd != fd)
|
||||
close(tty_fd);
|
||||
}
|
||||
return retval == 0 ? OK : FAIL;
|
||||
}
|
||||
#endif
|
||||
@ -4362,8 +4361,9 @@ open_pty(int *pty_master_fd, int *pty_slave_fd, char_u **name1, char_u **name2)
|
||||
*name2 = NULL;
|
||||
|
||||
*pty_master_fd = mch_openpty(&tty_name); // open pty
|
||||
if (*pty_master_fd >= 0)
|
||||
{
|
||||
if (*pty_master_fd < 0)
|
||||
return;
|
||||
|
||||
// Leaving out O_NOCTTY may lead to waitpid() always returning
|
||||
// 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
|
||||
// adding O_NOCTTY always works when defined.
|
||||
@ -4385,7 +4385,6 @@ open_pty(int *pty_master_fd, int *pty_slave_fd, char_u **name1, char_u **name2)
|
||||
*name2 = vim_strsave((char_u *)tty_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -7250,8 +7249,9 @@ gpm_open(void)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if (!gpm_flag)
|
||||
{
|
||||
if (gpm_flag)
|
||||
return 1; // already open
|
||||
|
||||
gpm_connect.eventMask = (GPM_UP | GPM_DRAG | GPM_DOWN);
|
||||
gpm_connect.defaultMask = ~GPM_HARD;
|
||||
// Default handling for mouse move
|
||||
@ -7272,8 +7272,6 @@ gpm_open(void)
|
||||
Gpm_Close(); // We don't want to talk to xterm via gpm
|
||||
return 0;
|
||||
}
|
||||
return 1; // already open
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if the GPM mouse is enabled.
|
||||
@ -7395,15 +7393,14 @@ sysmouse_open(void)
|
||||
mouse.operation = MOUSE_MODE;
|
||||
mouse.u.mode.mode = 0;
|
||||
mouse.u.mode.signal = SIGUSR2;
|
||||
if (ioctl(1, CONS_MOUSECTL, &mouse) != -1)
|
||||
{
|
||||
if (ioctl(1, CONS_MOUSECTL, &mouse) == -1)
|
||||
return FAIL;
|
||||
|
||||
signal(SIGUSR2, (void (*)())sig_sysmouse);
|
||||
mouse.operation = MOUSE_SHOW;
|
||||
ioctl(1, CONS_MOUSECTL, &mouse);
|
||||
return OK;
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop processing SIGUSR2 signals, and also make sure that
|
||||
@ -8243,15 +8240,15 @@ xsmp_init(void)
|
||||
void
|
||||
xsmp_close(void)
|
||||
{
|
||||
if (xsmp_icefd != -1)
|
||||
{
|
||||
if (xsmp_icefd == -1)
|
||||
return;
|
||||
|
||||
SmcCloseConnection(xsmp.smcconn, 0, NULL);
|
||||
if (xsmp.clientid != NULL)
|
||||
free(xsmp.clientid);
|
||||
xsmp.clientid = NULL;
|
||||
xsmp_icefd = -1;
|
||||
}
|
||||
}
|
||||
#endif // USE_XSMP
|
||||
|
||||
#if defined(FEAT_RELTIME) || defined(PROTO)
|
||||
@ -8348,12 +8345,12 @@ start_timeout(long msec)
|
||||
void
|
||||
delete_timer(void)
|
||||
{
|
||||
if (timer_created)
|
||||
{
|
||||
if (!timer_created)
|
||||
return;
|
||||
|
||||
timer_delete(timer_id);
|
||||
timer_created = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
# else // HAVE_TIMER_CREATE
|
||||
|
||||
|
111
src/os_win32.c
111
src/os_win32.c
@ -278,15 +278,15 @@ get_build_number(void)
|
||||
|
||||
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
||||
hNtdll = GetModuleHandle("ntdll.dll");
|
||||
if (hNtdll != NULL)
|
||||
{
|
||||
if (hNtdll == NULL)
|
||||
return ver;
|
||||
|
||||
pRtlGetVersion =
|
||||
(PfnRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion");
|
||||
pRtlGetVersion(&osver);
|
||||
ver = MAKE_VER(min(osver.dwMajorVersion, 255),
|
||||
min(osver.dwMinorVersion, 255),
|
||||
min(osver.dwBuildNumber, 32767));
|
||||
}
|
||||
return ver;
|
||||
}
|
||||
|
||||
@ -478,11 +478,13 @@ get_exe_name(void)
|
||||
exe_name = FullName_save((char_u *)temp, FALSE);
|
||||
}
|
||||
|
||||
if (exe_path == NULL && exe_name != NULL)
|
||||
{
|
||||
if (exe_path != NULL || exe_name == NULL)
|
||||
return;
|
||||
|
||||
exe_path = vim_strnsave(exe_name, gettail_sep(exe_name) - exe_name);
|
||||
if (exe_path != NULL)
|
||||
{
|
||||
if (exe_path == NULL)
|
||||
return;
|
||||
|
||||
// Append our starting directory to $PATH, so that when doing
|
||||
// "!xxd" it's found in our starting directory. Needed because
|
||||
// SearchPath() also looks there.
|
||||
@ -501,8 +503,6 @@ get_exe_name(void)
|
||||
vim_setenv((char_u *)"PATH", (char_u *)temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unescape characters in "p" that appear in "escaped".
|
||||
@ -533,18 +533,21 @@ vimLoadLib(const char *name)
|
||||
|
||||
// No need to load any library when registering OLE.
|
||||
if (found_register_arg)
|
||||
return dll;
|
||||
return NULL;
|
||||
|
||||
// NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
|
||||
// vimLoadLib() recursively, which causes a stack overflow.
|
||||
if (exe_path == NULL)
|
||||
get_exe_name();
|
||||
if (exe_path != NULL)
|
||||
{
|
||||
|
||||
if (exe_path == NULL)
|
||||
return NULL;
|
||||
|
||||
WCHAR old_dirw[MAXPATHL];
|
||||
|
||||
if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0)
|
||||
{
|
||||
if (GetCurrentDirectoryW(MAXPATHL, old_dirw) == 0)
|
||||
return NULL;
|
||||
|
||||
// Change directory to where the executable is, both to make
|
||||
// sure we find a .dll there and to avoid looking for a .dll
|
||||
// in the current directory.
|
||||
@ -553,9 +556,6 @@ vimLoadLib(const char *name)
|
||||
SetCurrentDirectoryW(old_dirw);
|
||||
return dll;
|
||||
}
|
||||
}
|
||||
return dll;
|
||||
}
|
||||
|
||||
#if defined(VIMDLL) || defined(PROTO)
|
||||
/*
|
||||
@ -907,8 +907,9 @@ PlatformId(void)
|
||||
{
|
||||
static int done = FALSE;
|
||||
|
||||
if (!done)
|
||||
{
|
||||
if (done)
|
||||
return;
|
||||
|
||||
OSVERSIONINFO ovi;
|
||||
|
||||
ovi.dwOSVersionInfoSize = sizeof(ovi);
|
||||
@ -932,7 +933,6 @@ PlatformId(void)
|
||||
#endif
|
||||
done = TRUE;
|
||||
}
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
@ -3051,8 +3051,9 @@ FitConsoleWindow(
|
||||
COORD dwWindowSize;
|
||||
BOOL NeedAdjust = FALSE;
|
||||
|
||||
if (GetConsoleScreenBufferInfo(g_hConOut, &csbi))
|
||||
{
|
||||
if (!GetConsoleScreenBufferInfo(g_hConOut, &csbi))
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* A buffer resize will fail if the current console window does
|
||||
* not lie completely within that buffer. To avoid this, we might
|
||||
@ -3084,9 +3085,6 @@ FitConsoleWindow(
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
typedef struct ConsoleBufferStruct
|
||||
{
|
||||
BOOL IsValid;
|
||||
@ -3674,17 +3672,15 @@ mch_get_host_name(
|
||||
WCHAR wszHostName[256 + 1];
|
||||
DWORD wcch = ARRAY_LENGTH(wszHostName);
|
||||
|
||||
if (GetComputerNameW(wszHostName, &wcch))
|
||||
{
|
||||
char_u *p = utf16_to_enc(wszHostName, NULL);
|
||||
if (!GetComputerNameW(wszHostName, &wcch))
|
||||
return;
|
||||
|
||||
char_u *p = utf16_to_enc(wszHostName, NULL);
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
vim_strncpy(s, p, len - 1);
|
||||
vim_free(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3732,8 +3728,9 @@ mch_dirname(
|
||||
* But the Win32s known bug list says that getcwd() doesn't work
|
||||
* so use the Win32 system call instead. <Negri>
|
||||
*/
|
||||
if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
|
||||
{
|
||||
if (GetCurrentDirectoryW(_MAX_PATH, wbuf) == 0)
|
||||
return FAIL;
|
||||
|
||||
WCHAR wcbuf[_MAX_PATH + 1];
|
||||
char_u *p = NULL;
|
||||
|
||||
@ -3750,15 +3747,13 @@ mch_dirname(
|
||||
if (p == NULL)
|
||||
p = utf16_to_enc(wbuf, NULL);
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
if (p == NULL)
|
||||
return FAIL;
|
||||
|
||||
vim_strncpy(buf, p, len - 1);
|
||||
vim_free(p);
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get file permissions for "name".
|
||||
@ -3974,14 +3969,14 @@ win32_fileinfo(char_u *fname, BY_HANDLE_FILE_INFORMATION *info)
|
||||
NULL); // handle to template file
|
||||
vim_free(wn);
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return FILEINFO_READ_FAIL;
|
||||
|
||||
if (GetFileInformationByHandle(hFile, info) != 0)
|
||||
res = FILEINFO_OK;
|
||||
else
|
||||
res = FILEINFO_INFO_FAIL;
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -6170,13 +6165,13 @@ mch_signal_job(job_T *job, char_u *how)
|
||||
void
|
||||
mch_clear_job(job_T *job)
|
||||
{
|
||||
if (job->jv_status != JOB_FAILED)
|
||||
{
|
||||
if (job->jv_status == JOB_FAILED)
|
||||
return;
|
||||
|
||||
if (job->jv_job_object != NULL)
|
||||
CloseHandle(job->jv_job_object);
|
||||
CloseHandle(job->jv_proc_info.hProcess);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -7988,8 +7983,9 @@ load_ntdll(void)
|
||||
{
|
||||
static int loaded = -1;
|
||||
|
||||
if (loaded == -1)
|
||||
{
|
||||
if (loaded != -1)
|
||||
return (BOOL) loaded;
|
||||
|
||||
HMODULE hNtdll = GetModuleHandle("ntdll.dll");
|
||||
if (hNtdll != NULL)
|
||||
{
|
||||
@ -8013,7 +8009,6 @@ load_ntdll(void)
|
||||
loaded = FALSE;
|
||||
else
|
||||
loaded = TRUE;
|
||||
}
|
||||
return (BOOL) loaded;
|
||||
}
|
||||
|
||||
@ -8190,12 +8185,12 @@ get_cmd_argsW(char ***argvp)
|
||||
void
|
||||
free_cmd_argsW(void)
|
||||
{
|
||||
if (ArglistW != NULL)
|
||||
{
|
||||
if (ArglistW == NULL)
|
||||
return;
|
||||
|
||||
GlobalFree(ArglistW);
|
||||
ArglistW = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remember "name" is an argument that was added to the argument list.
|
||||
@ -8899,8 +8894,9 @@ resize_console_buf(void)
|
||||
COORD coord;
|
||||
SMALL_RECT newsize;
|
||||
|
||||
if (GetConsoleScreenBufferInfo(g_hConOut, &csbi))
|
||||
{
|
||||
if (!GetConsoleScreenBufferInfo(g_hConOut, &csbi))
|
||||
return;
|
||||
|
||||
coord.X = SRWIDTH(csbi.srWindow);
|
||||
coord.Y = SRHEIGHT(csbi.srWindow);
|
||||
SetConsoleScreenBufferSize(g_hConOut, coord);
|
||||
@ -8913,7 +8909,6 @@ resize_console_buf(void)
|
||||
|
||||
SetConsoleScreenBufferSize(g_hConOut, coord);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
char *
|
||||
@ -8926,14 +8921,14 @@ GetWin32Error(void)
|
||||
NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL);
|
||||
if (oldmsg != NULL)
|
||||
LocalFree(oldmsg);
|
||||
if (msg != NULL)
|
||||
{
|
||||
if (msg == NULL)
|
||||
return NULL;
|
||||
|
||||
// remove trailing \r\n
|
||||
char *pcrlf = strstr(msg, "\r\n");
|
||||
if (pcrlf != NULL)
|
||||
*pcrlf = '\0';
|
||||
oldmsg = msg;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1208,
|
||||
/**/
|
||||
1207,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user