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
175
src/netbeans.c
175
src/netbeans.c
@ -938,13 +938,13 @@ nb_partialremove(linenr_T lnum, colnr_T first, colnr_T last)
|
|||||||
if (lastbyte >= oldlen)
|
if (lastbyte >= oldlen)
|
||||||
lastbyte = oldlen - 1;
|
lastbyte = oldlen - 1;
|
||||||
newtext = alloc(oldlen - (int)(lastbyte - first));
|
newtext = alloc(oldlen - (int)(lastbyte - first));
|
||||||
if (newtext != NULL)
|
if (newtext == NULL)
|
||||||
{
|
return;
|
||||||
mch_memmove(newtext, oldtext, first);
|
|
||||||
STRMOVE(newtext + first, oldtext + lastbyte + 1);
|
mch_memmove(newtext, oldtext, first);
|
||||||
nbdebug((" NEW LINE %ld: %s\n", lnum, newtext));
|
STRMOVE(newtext + first, oldtext + lastbyte + 1);
|
||||||
ml_replace(lnum, newtext, FALSE);
|
nbdebug((" NEW LINE %ld: %s\n", lnum, newtext));
|
||||||
}
|
ml_replace(lnum, newtext, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -960,12 +960,12 @@ nb_joinlines(linenr_T first, linenr_T other)
|
|||||||
len_first = (int)STRLEN(ml_get(first));
|
len_first = (int)STRLEN(ml_get(first));
|
||||||
len_other = (int)STRLEN(ml_get(other));
|
len_other = (int)STRLEN(ml_get(other));
|
||||||
p = alloc(len_first + len_other + 1);
|
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);
|
mch_memmove(p, ml_get(first), len_first);
|
||||||
ml_replace(first, p, FALSE);
|
mch_memmove(p + len_first, ml_get(other), len_other + 1);
|
||||||
}
|
ml_replace(first, p, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SKIP_STOP 2
|
#define SKIP_STOP 2
|
||||||
@ -2247,13 +2247,14 @@ nb_do_cmd(
|
|||||||
static void
|
static void
|
||||||
nb_set_curbuf(buf_T *buf)
|
nb_set_curbuf(buf_T *buf)
|
||||||
{
|
{
|
||||||
if (curbuf != buf) {
|
if (curbuf == buf)
|
||||||
if (buf_jump_open_win(buf) != NULL)
|
return;
|
||||||
return;
|
|
||||||
if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL)
|
if (buf_jump_open_win(buf) != NULL)
|
||||||
return;
|
return;
|
||||||
set_curbuf(buf, DOBUF_GOTO);
|
if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL)
|
||||||
}
|
return;
|
||||||
|
set_curbuf(buf, DOBUF_GOTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2364,14 +2365,14 @@ nb_init_graphics(void)
|
|||||||
{
|
{
|
||||||
static int did_init = FALSE;
|
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;
|
coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black"
|
||||||
}
|
" ctermbg=LightCyan ctermfg=Black");
|
||||||
|
coloncmd(":sign define %d linehl=NBGuarded", GUARDED);
|
||||||
|
|
||||||
|
did_init = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2468,29 +2469,29 @@ netbeans_beval_cb(
|
|||||||
if (!can_use_beval() || !NETBEANS_OPEN)
|
if (!can_use_beval() || !NETBEANS_OPEN)
|
||||||
return;
|
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)
|
||||||
{
|
{
|
||||||
// Send debugger request. Only when the text is of reasonable
|
buf = alloc(MAXPATHL * 2 + 25);
|
||||||
// length.
|
if (buf != NULL)
|
||||||
if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL)
|
|
||||||
{
|
{
|
||||||
buf = alloc(MAXPATHL * 2 + 25);
|
p = nb_quote(text);
|
||||||
if (buf != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
p = nb_quote(text);
|
vim_snprintf(buf, MAXPATHL * 2 + 25,
|
||||||
if (p != NULL)
|
"0:balloonText=%d \"%s\"\n", r_cmdno, p);
|
||||||
{
|
vim_free(p);
|
||||||
vim_snprintf(buf, MAXPATHL * 2 + 25,
|
|
||||||
"0:balloonText=%d \"%s\"\n", r_cmdno, p);
|
|
||||||
vim_free(p);
|
|
||||||
}
|
|
||||||
nbdebug(("EVT: %s", buf));
|
|
||||||
nb_send(buf, "netbeans_beval_cb");
|
|
||||||
vim_free(buf);
|
|
||||||
}
|
}
|
||||||
|
nbdebug(("EVT: %s", buf));
|
||||||
|
nb_send(buf, "netbeans_beval_cb");
|
||||||
|
vim_free(buf);
|
||||||
}
|
}
|
||||||
vim_free(text);
|
|
||||||
}
|
}
|
||||||
|
vim_free(text);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2555,12 +2556,12 @@ set_ref_in_nb_channel(int copyID)
|
|||||||
int abort = FALSE;
|
int abort = FALSE;
|
||||||
typval_T tv;
|
typval_T tv;
|
||||||
|
|
||||||
if (nb_channel != NULL)
|
if (nb_channel == NULL)
|
||||||
{
|
return FALSE;
|
||||||
tv.v_type = VAR_CHANNEL;
|
|
||||||
tv.vval.v_channel = nb_channel;
|
tv.v_type = VAR_CHANNEL;
|
||||||
abort = set_ref_in_item(&tv, copyID, NULL, NULL);
|
tv.vval.v_channel = nb_channel;
|
||||||
}
|
abort = set_ref_in_item(&tv, copyID, NULL, NULL);
|
||||||
return abort;
|
return abort;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2827,22 +2828,22 @@ netbeans_button_release(int button)
|
|||||||
|
|
||||||
bufno = nb_getbufno(curbuf);
|
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);
|
|
||||||
|
|
||||||
// sync the cursor position
|
int col = mouse_col - curwin->w_wincol
|
||||||
sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
|
- ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1);
|
||||||
nbdebug(("EVT: %s", buf));
|
long off = pos2off(curbuf, &curwin->w_cursor);
|
||||||
nb_send(buf, "netbeans_button_release[newDotAndMark]");
|
|
||||||
|
|
||||||
sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno,
|
// sync the cursor position
|
||||||
button, (long)curwin->w_cursor.lnum, col);
|
sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
|
||||||
nbdebug(("EVT: %s", buf));
|
nbdebug(("EVT: %s", buf));
|
||||||
nb_send(buf, "netbeans_button_release");
|
nb_send(buf, "netbeans_button_release[newDotAndMark]");
|
||||||
}
|
|
||||||
|
sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno,
|
||||||
|
button, (long)curwin->w_cursor.lnum, col);
|
||||||
|
nbdebug(("EVT: %s", buf));
|
||||||
|
nb_send(buf, "netbeans_button_release");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3308,29 +3309,27 @@ get_buf_size(buf_T *bufp)
|
|||||||
|
|
||||||
if (bufp->b_ml.ml_flags & ML_EMPTY)
|
if (bufp->b_ml.ml_flags & ML_EMPTY)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (get_fileformat(bufp) == EOL_DOS)
|
||||||
|
eol_size = 2;
|
||||||
else
|
else
|
||||||
|
eol_size = 1;
|
||||||
|
for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
|
||||||
{
|
{
|
||||||
if (get_fileformat(bufp) == EOL_DOS)
|
char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE))
|
||||||
eol_size = 2;
|
+ eol_size;
|
||||||
else
|
// Check for a CTRL-C every 100000 characters
|
||||||
eol_size = 1;
|
if (char_count > last_check)
|
||||||
for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
|
|
||||||
{
|
{
|
||||||
char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE))
|
ui_breakcheck();
|
||||||
+ eol_size;
|
if (got_int)
|
||||||
// Check for a CTRL-C every 100000 characters
|
return char_count;
|
||||||
if (char_count > last_check)
|
last_check = char_count + 100000L;
|
||||||
{
|
|
||||||
ui_breakcheck();
|
|
||||||
if (got_int)
|
|
||||||
return char_count;
|
|
||||||
last_check = char_count + 100000L;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
// 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;
|
return char_count;
|
||||||
}
|
}
|
||||||
@ -3393,12 +3392,12 @@ pos2off(buf_T *buf, pos_T *pos)
|
|||||||
{
|
{
|
||||||
long offset = 0;
|
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;
|
if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0)
|
||||||
offset += pos->col;
|
return 0;
|
||||||
}
|
offset += pos->col;
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
858
src/normal.c
858
src/normal.c
File diff suppressed because it is too large
Load Diff
51
src/ops.c
51
src/ops.c
@ -989,11 +989,11 @@ mb_adjust_opend(oparg_T *oap)
|
|||||||
{
|
{
|
||||||
char_u *p;
|
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);
|
p = ml_get(oap->end.lnum);
|
||||||
}
|
oap->end.col += mb_tail_off(p, p + oap->end.col);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1869,22 +1869,23 @@ adjust_cursor_eol(void)
|
|||||||
{
|
{
|
||||||
unsigned int cur_ve_flags = get_ve_flags();
|
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
|
&& gchar_cursor() == NUL
|
||||||
&& (cur_ve_flags & VE_ONEMORE) == 0
|
&& (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();
|
||||||
|
|
||||||
|
if (cur_ve_flags == VE_ALL)
|
||||||
{
|
{
|
||||||
// Put the cursor on the last character in the line.
|
colnr_T scol, ecol;
|
||||||
dec_cursor();
|
|
||||||
|
|
||||||
if (cur_ve_flags == VE_ALL)
|
// Coladd is set to the width of the last character.
|
||||||
{
|
getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
|
||||||
colnr_T scol, ecol;
|
curwin->w_cursor.coladd = ecol - scol + 1;
|
||||||
|
|
||||||
// Coladd is set to the width of the last character.
|
|
||||||
getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
|
|
||||||
curwin->w_cursor.coladd = ecol - scol + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2235,12 +2236,12 @@ reset_lbr(void)
|
|||||||
static void
|
static void
|
||||||
restore_lbr(int lbr_saved)
|
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;
|
// changing 'linebreak' may require w_virtcol to be updated
|
||||||
curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
|
curwin->w_p_lbr = TRUE;
|
||||||
}
|
curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
95
src/option.c
95
src/option.c
@ -672,17 +672,17 @@ set_string_default_esc(char *name, char_u *val, int escape)
|
|||||||
p = vim_strsave_escaped(val, (char_u *)" ");
|
p = vim_strsave_escaped(val, (char_u *)" ");
|
||||||
else
|
else
|
||||||
p = vim_strsave(val);
|
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)
|
opt_idx = findoption((char_u *)name);
|
||||||
{
|
if (opt_idx < 0)
|
||||||
if (options[opt_idx].flags & P_DEF_ALLOCED)
|
return;
|
||||||
vim_free(options[opt_idx].def_val[VI_DEFAULT]);
|
|
||||||
options[opt_idx].def_val[VI_DEFAULT] = p;
|
if (options[opt_idx].flags & P_DEF_ALLOCED)
|
||||||
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
|
void
|
||||||
@ -1112,31 +1112,31 @@ set_helplang_default(char_u *lang)
|
|||||||
if (lang == NULL || STRLEN(lang) < 2) // safety check
|
if (lang == NULL || STRLEN(lang) < 2) // safety check
|
||||||
return;
|
return;
|
||||||
idx = findoption((char_u *)"hlg");
|
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);
|
||||||
|
if (p_hlg == NULL)
|
||||||
|
p_hlg = empty_option;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (options[idx].flags & P_ALLOCED)
|
// zh_CN becomes "cn", zh_TW becomes "tw"
|
||||||
free_string_option(p_hlg);
|
if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
|
||||||
p_hlg = vim_strsave(lang);
|
|
||||||
if (p_hlg == NULL)
|
|
||||||
p_hlg = empty_option;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// zh_CN becomes "cn", zh_TW becomes "tw"
|
p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
|
||||||
if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
|
p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
|
||||||
{
|
|
||||||
p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
|
|
||||||
p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
|
|
||||||
}
|
|
||||||
// any C like setting, such as C.UTF-8, becomes "en"
|
|
||||||
else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C')
|
|
||||||
{
|
|
||||||
p_hlg[0] = 'e';
|
|
||||||
p_hlg[1] = 'n';
|
|
||||||
}
|
|
||||||
p_hlg[2] = NUL;
|
|
||||||
}
|
}
|
||||||
options[idx].flags |= P_ALLOCED;
|
// any C like setting, such as C.UTF-8, becomes "en"
|
||||||
|
else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C')
|
||||||
|
{
|
||||||
|
p_hlg[0] = 'e';
|
||||||
|
p_hlg[1] = 'n';
|
||||||
|
}
|
||||||
|
p_hlg[2] = NUL;
|
||||||
}
|
}
|
||||||
|
options[idx].flags |= P_ALLOCED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1171,17 +1171,19 @@ set_title_defaults(void)
|
|||||||
p_title = val;
|
p_title = val;
|
||||||
}
|
}
|
||||||
idx1 = findoption((char_u *)"icon");
|
idx1 = findoption((char_u *)"icon");
|
||||||
if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
|
if (idx1 < 0 || (options[idx1].flags & P_WAS_SET))
|
||||||
{
|
{
|
||||||
#ifdef FEAT_GUI
|
return;
|
||||||
if (gui.starting || gui.in_use)
|
|
||||||
val = TRUE;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
val = mch_can_restore_icon();
|
|
||||||
options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
|
|
||||||
p_icon = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FEAT_GUI
|
||||||
|
if (gui.starting || gui.in_use)
|
||||||
|
val = TRUE;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
val = mch_can_restore_icon();
|
||||||
|
options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
|
||||||
|
p_icon = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -7084,12 +7086,11 @@ reset_option_was_set(char_u *name)
|
|||||||
{
|
{
|
||||||
int idx = findoption(name);
|
int idx = findoption(name);
|
||||||
|
|
||||||
if (idx >= 0)
|
if (idx < 0)
|
||||||
{
|
return FAIL;
|
||||||
options[idx].flags &= ~P_WAS_SET;
|
|
||||||
return OK;
|
options[idx].flags &= ~P_WAS_SET;
|
||||||
}
|
return OK;
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
232
src/optionstr.c
232
src/optionstr.c
@ -155,42 +155,42 @@ trigger_optionset_string(
|
|||||||
char_u *newval)
|
char_u *newval)
|
||||||
{
|
{
|
||||||
// Don't do this recursively.
|
// Don't do this recursively.
|
||||||
if (oldval != NULL && newval != NULL
|
if (oldval == NULL || newval == NULL
|
||||||
&& *get_vim_var_str(VV_OPTION_TYPE) == NUL)
|
|| *get_vim_var_str(VV_OPTION_TYPE) != NUL)
|
||||||
{
|
return;
|
||||||
char_u buf_type[7];
|
|
||||||
|
|
||||||
sprintf((char *)buf_type, "%s",
|
char_u buf_type[7];
|
||||||
|
|
||||||
|
sprintf((char *)buf_type, "%s",
|
||||||
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||||
set_vim_var_string(VV_OPTION_OLD, oldval, -1);
|
set_vim_var_string(VV_OPTION_OLD, oldval, -1);
|
||||||
set_vim_var_string(VV_OPTION_NEW, newval, -1);
|
set_vim_var_string(VV_OPTION_NEW, newval, -1);
|
||||||
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
|
||||||
if (opt_flags & OPT_LOCAL)
|
if (opt_flags & OPT_LOCAL)
|
||||||
{
|
{
|
||||||
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1);
|
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1);
|
||||||
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
|
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
|
||||||
}
|
|
||||||
if (opt_flags & OPT_GLOBAL)
|
|
||||||
{
|
|
||||||
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1);
|
|
||||||
set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval, -1);
|
|
||||||
}
|
|
||||||
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
|
||||||
{
|
|
||||||
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1);
|
|
||||||
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval_l, -1);
|
|
||||||
set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval_g, -1);
|
|
||||||
}
|
|
||||||
if (opt_flags & OPT_MODELINE)
|
|
||||||
{
|
|
||||||
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1);
|
|
||||||
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
|
|
||||||
}
|
|
||||||
apply_autocmds(EVENT_OPTIONSET,
|
|
||||||
get_option_fullname(opt_idx), NULL, FALSE,
|
|
||||||
NULL);
|
|
||||||
reset_v_option_vars();
|
|
||||||
}
|
}
|
||||||
|
if (opt_flags & OPT_GLOBAL)
|
||||||
|
{
|
||||||
|
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1);
|
||||||
|
set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval, -1);
|
||||||
|
}
|
||||||
|
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
||||||
|
{
|
||||||
|
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1);
|
||||||
|
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval_l, -1);
|
||||||
|
set_vim_var_string(VV_OPTION_OLDGLOBAL, oldval_g, -1);
|
||||||
|
}
|
||||||
|
if (opt_flags & OPT_MODELINE)
|
||||||
|
{
|
||||||
|
set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1);
|
||||||
|
set_vim_var_string(VV_OPTION_OLDLOCAL, oldval, -1);
|
||||||
|
}
|
||||||
|
apply_autocmds(EVENT_OPTIONSET,
|
||||||
|
get_option_fullname(opt_idx), NULL, FALSE,
|
||||||
|
NULL);
|
||||||
|
reset_v_option_vars();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -387,45 +387,45 @@ set_string_option_direct(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
s = vim_strsave(val);
|
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))
|
||||||
|
free_string_option(*varp);
|
||||||
|
*varp = s;
|
||||||
|
|
||||||
|
// For buffer/window local option may also set the global value.
|
||||||
|
if (both)
|
||||||
|
set_string_option_global(idx, varp);
|
||||||
|
|
||||||
|
set_option_flag(idx, P_ALLOCED);
|
||||||
|
|
||||||
|
// When setting both values of a global option with a local value,
|
||||||
|
// make the local value empty, so that the global value is used.
|
||||||
|
if (is_global_local_option(idx) && both)
|
||||||
{
|
{
|
||||||
varp = (char_u **)get_option_varp_scope(idx,
|
free_string_option(*varp);
|
||||||
both ? OPT_LOCAL : opt_flags);
|
*varp = empty_option;
|
||||||
if ((opt_flags & OPT_FREE) && (get_option_flags(idx) & P_ALLOCED))
|
|
||||||
free_string_option(*varp);
|
|
||||||
*varp = s;
|
|
||||||
|
|
||||||
// For buffer/window local option may also set the global value.
|
|
||||||
if (both)
|
|
||||||
set_string_option_global(idx, varp);
|
|
||||||
|
|
||||||
set_option_flag(idx, P_ALLOCED);
|
|
||||||
|
|
||||||
// When setting both values of a global option with a local value,
|
|
||||||
// make the local value empty, so that the global value is used.
|
|
||||||
if (is_global_local_option(idx) && both)
|
|
||||||
{
|
|
||||||
free_string_option(*varp);
|
|
||||||
*varp = empty_option;
|
|
||||||
}
|
|
||||||
# ifdef FEAT_EVAL
|
|
||||||
if (set_sid != SID_NONE)
|
|
||||||
{
|
|
||||||
sctx_T script_ctx;
|
|
||||||
|
|
||||||
if (set_sid == 0)
|
|
||||||
script_ctx = current_sctx;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
script_ctx.sc_sid = set_sid;
|
|
||||||
script_ctx.sc_seq = 0;
|
|
||||||
script_ctx.sc_lnum = 0;
|
|
||||||
script_ctx.sc_version = 1;
|
|
||||||
}
|
|
||||||
set_option_sctx_idx(idx, opt_flags, script_ctx);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
# ifdef FEAT_EVAL
|
||||||
|
if (set_sid != SID_NONE)
|
||||||
|
{
|
||||||
|
sctx_T script_ctx;
|
||||||
|
|
||||||
|
if (set_sid == 0)
|
||||||
|
script_ctx = current_sctx;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
script_ctx.sc_sid = set_sid;
|
||||||
|
script_ctx.sc_seq = 0;
|
||||||
|
script_ctx.sc_lnum = 0;
|
||||||
|
script_ctx.sc_version = 1;
|
||||||
|
}
|
||||||
|
set_option_sctx_idx(idx, opt_flags, script_ctx);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -507,54 +507,54 @@ set_string_option(
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
s = vim_strsave(value == NULL ? (char_u *)"" : value);
|
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)
|
||||||
|
? OPT_GLOBAL : OPT_LOCAL)
|
||||||
|
: opt_flags);
|
||||||
|
oldval = *varp;
|
||||||
|
#if defined(FEAT_EVAL)
|
||||||
|
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
||||||
{
|
{
|
||||||
varp = (char_u **)get_option_varp_scope(opt_idx,
|
oldval_l = *(char_u **)get_option_varp_scope(opt_idx, OPT_LOCAL);
|
||||||
(opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
oldval_g = *(char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL);
|
||||||
? (is_global_local_option(opt_idx)
|
|
||||||
? OPT_GLOBAL : OPT_LOCAL)
|
|
||||||
: opt_flags);
|
|
||||||
oldval = *varp;
|
|
||||||
#if defined(FEAT_EVAL)
|
|
||||||
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
|
|
||||||
{
|
|
||||||
oldval_l = *(char_u **)get_option_varp_scope(opt_idx, OPT_LOCAL);
|
|
||||||
oldval_g = *(char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*varp = s;
|
|
||||||
|
|
||||||
#if defined(FEAT_EVAL)
|
|
||||||
if (!starting
|
|
||||||
# ifdef FEAT_CRYPT
|
|
||||||
&& !is_crypt_key_option(opt_idx)
|
|
||||||
# endif
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (oldval_l != NULL)
|
|
||||||
saved_oldval_l = vim_strsave(oldval_l);
|
|
||||||
if (oldval_g != NULL)
|
|
||||||
saved_oldval_g = vim_strsave(oldval_g);
|
|
||||||
saved_oldval = vim_strsave(oldval);
|
|
||||||
saved_newval = vim_strsave(s);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if ((errmsg = did_set_string_option(opt_idx, varp, oldval, NULL,
|
|
||||||
opt_flags, &value_checked)) == NULL)
|
|
||||||
did_set_option(opt_idx, opt_flags, TRUE, value_checked);
|
|
||||||
|
|
||||||
#if defined(FEAT_EVAL)
|
|
||||||
// call autocommand after handling side effects
|
|
||||||
if (errmsg == NULL)
|
|
||||||
trigger_optionset_string(opt_idx, opt_flags,
|
|
||||||
saved_oldval, saved_oldval_l,
|
|
||||||
saved_oldval_g, saved_newval);
|
|
||||||
vim_free(saved_oldval);
|
|
||||||
vim_free(saved_oldval_l);
|
|
||||||
vim_free(saved_oldval_g);
|
|
||||||
vim_free(saved_newval);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
*varp = s;
|
||||||
|
|
||||||
|
#if defined(FEAT_EVAL)
|
||||||
|
if (!starting
|
||||||
|
# ifdef FEAT_CRYPT
|
||||||
|
&& !is_crypt_key_option(opt_idx)
|
||||||
|
# endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (oldval_l != NULL)
|
||||||
|
saved_oldval_l = vim_strsave(oldval_l);
|
||||||
|
if (oldval_g != NULL)
|
||||||
|
saved_oldval_g = vim_strsave(oldval_g);
|
||||||
|
saved_oldval = vim_strsave(oldval);
|
||||||
|
saved_newval = vim_strsave(s);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if ((errmsg = did_set_string_option(opt_idx, varp, oldval, NULL,
|
||||||
|
opt_flags, &value_checked)) == NULL)
|
||||||
|
did_set_option(opt_idx, opt_flags, TRUE, value_checked);
|
||||||
|
|
||||||
|
#if defined(FEAT_EVAL)
|
||||||
|
// call autocommand after handling side effects
|
||||||
|
if (errmsg == NULL)
|
||||||
|
trigger_optionset_string(opt_idx, opt_flags,
|
||||||
|
saved_oldval, saved_oldval_l,
|
||||||
|
saved_oldval_g, saved_newval);
|
||||||
|
vim_free(saved_oldval);
|
||||||
|
vim_free(saved_oldval_l);
|
||||||
|
vim_free(saved_oldval_g);
|
||||||
|
vim_free(saved_newval);
|
||||||
|
#endif
|
||||||
return errmsg;
|
return errmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
107
src/os_amiga.c
107
src/os_amiga.c
@ -234,13 +234,13 @@ mch_delay(long msec, int flags)
|
|||||||
void Delay(long);
|
void Delay(long);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (msec > 0)
|
if (msec <= 0)
|
||||||
{
|
return;
|
||||||
if (flags & MCH_DELAY_IGNOREINPUT)
|
|
||||||
Delay(msec / 20L); // Delay works with 20 msec intervals
|
if (flags & MCH_DELAY_IGNOREINPUT)
|
||||||
else
|
Delay(msec / 20L); // Delay works with 20 msec intervals
|
||||||
WaitForChar(raw_in, msec * 1000L);
|
else
|
||||||
}
|
WaitForChar(raw_in, msec * 1000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -577,18 +577,18 @@ fname_case(
|
|||||||
size_t flen;
|
size_t flen;
|
||||||
|
|
||||||
fib = get_fib(name);
|
fib = get_fib(name);
|
||||||
if (fib != NULL)
|
if (fib == NULL)
|
||||||
{
|
return;
|
||||||
flen = STRLEN(name);
|
|
||||||
// TODO: Check if this fix applies to AmigaOS < 4 too.
|
flen = STRLEN(name);
|
||||||
|
// TODO: Check if this fix applies to AmigaOS < 4 too.
|
||||||
#ifdef __amigaos4__
|
#ifdef __amigaos4__
|
||||||
if (fib->fib_DirEntryType == ST_ROOT)
|
if (fib->fib_DirEntryType == ST_ROOT)
|
||||||
strcat(fib->fib_FileName, ":");
|
strcat(fib->fib_FileName, ":");
|
||||||
#endif
|
#endif
|
||||||
if (flen == strlen(fib->fib_FileName)) // safety check
|
if (flen == strlen(fib->fib_FileName)) // safety check
|
||||||
mch_memmove(name, fib->fib_FileName, flen);
|
mch_memmove(name, fib->fib_FileName, flen);
|
||||||
free_fib(fib);
|
free_fib(fib);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -609,17 +609,17 @@ get_fib(char_u *fname)
|
|||||||
#else
|
#else
|
||||||
fib = ALLOC_ONE(struct FileInfoBlock);
|
fib = ALLOC_ONE(struct FileInfoBlock);
|
||||||
#endif
|
#endif
|
||||||
if (fib != NULL)
|
if (fib == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
flock = Lock((UBYTE *)fname, (long)ACCESS_READ);
|
||||||
|
if (flock == (BPTR)NULL || !Examine(flock, fib))
|
||||||
{
|
{
|
||||||
flock = Lock((UBYTE *)fname, (long)ACCESS_READ);
|
free_fib(fib); // in case of an error the memory is freed here
|
||||||
if (flock == (BPTR)NULL || !Examine(flock, fib))
|
fib = NULL;
|
||||||
{
|
|
||||||
free_fib(fib); // in case of an error the memory is freed here
|
|
||||||
fib = NULL;
|
|
||||||
}
|
|
||||||
if (flock)
|
|
||||||
UnLock(flock);
|
|
||||||
}
|
}
|
||||||
|
if (flock)
|
||||||
|
UnLock(flock);
|
||||||
return fib;
|
return fib;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,11 +815,11 @@ mch_getperm(char_u *name)
|
|||||||
long retval = -1;
|
long retval = -1;
|
||||||
|
|
||||||
fib = get_fib(name);
|
fib = get_fib(name);
|
||||||
if (fib != NULL)
|
if (fib == NULL)
|
||||||
{
|
return -1;
|
||||||
retval = fib->fib_Protection;
|
|
||||||
free_fib(fib);
|
retval = fib->fib_Protection;
|
||||||
}
|
free_fib(fib);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,15 +856,15 @@ mch_isdir(char_u *name)
|
|||||||
int retval = FALSE;
|
int retval = FALSE;
|
||||||
|
|
||||||
fib = get_fib(name);
|
fib = get_fib(name);
|
||||||
if (fib != NULL)
|
if (fib == NULL)
|
||||||
{
|
return FALSE;
|
||||||
|
|
||||||
#ifdef __amigaos4__
|
#ifdef __amigaos4__
|
||||||
retval = (FIB_IS_DRAWER(fib)) ? TRUE : FALSE;
|
retval = (FIB_IS_DRAWER(fib)) ? TRUE : FALSE;
|
||||||
#else
|
#else
|
||||||
retval = ((fib->fib_DirEntryType >= 0) ? TRUE : FALSE);
|
retval = ((fib->fib_DirEntryType >= 0) ? TRUE : FALSE);
|
||||||
#endif
|
#endif
|
||||||
free_fib(fib);
|
free_fib(fib);
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,12 +877,11 @@ mch_mkdir(char_u *name)
|
|||||||
BPTR lock;
|
BPTR lock;
|
||||||
|
|
||||||
lock = CreateDir(name);
|
lock = CreateDir(name);
|
||||||
if (lock != NULL)
|
if (lock == NULL)
|
||||||
{
|
return -1;
|
||||||
UnLock(lock);
|
|
||||||
return 0;
|
UnLock(lock);
|
||||||
}
|
return 0;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1173,17 +1172,17 @@ out:
|
|||||||
void
|
void
|
||||||
mch_set_shellsize(void)
|
mch_set_shellsize(void)
|
||||||
{
|
{
|
||||||
if (term_console)
|
if (!term_console)
|
||||||
{
|
return;
|
||||||
size_set = TRUE;
|
|
||||||
out_char(CSI);
|
size_set = TRUE;
|
||||||
out_num((long)Rows);
|
out_char(CSI);
|
||||||
out_char('t');
|
out_num((long)Rows);
|
||||||
out_char(CSI);
|
out_char('t');
|
||||||
out_num((long)Columns);
|
out_char(CSI);
|
||||||
out_char('u');
|
out_num((long)Columns);
|
||||||
out_flush();
|
out_char('u');
|
||||||
}
|
out_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -568,28 +568,28 @@ mac_utf8_to_utf16(
|
|||||||
void
|
void
|
||||||
mac_lang_init(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
|
char buf[50];
|
||||||
// from the Dock. Query the system locale.
|
|
||||||
if (LocaleRefGetPartString(NULL,
|
// $LANG is not set, either because it was unset or Vim was started
|
||||||
kLocaleLanguageMask | kLocaleLanguageVariantMask |
|
// from the Dock. Query the system locale.
|
||||||
kLocaleRegionMask | kLocaleRegionVariantMask,
|
if (LocaleRefGetPartString(NULL,
|
||||||
sizeof(buf) - 10, buf) == noErr && *buf)
|
kLocaleLanguageMask | kLocaleLanguageVariantMask |
|
||||||
{
|
kLocaleRegionMask | kLocaleRegionVariantMask,
|
||||||
if (strcasestr(buf, "utf-8") == NULL)
|
sizeof(buf) - 10, buf) == noErr && *buf)
|
||||||
strcat(buf, ".UTF-8");
|
{
|
||||||
vim_setenv((char_u *)"LANG", (char_u *)buf);
|
if (strcasestr(buf, "utf-8") == NULL)
|
||||||
|
strcat(buf, ".UTF-8");
|
||||||
|
vim_setenv((char_u *)"LANG", (char_u *)buf);
|
||||||
# ifdef HAVE_LOCALE_H
|
# ifdef HAVE_LOCALE_H
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
# endif
|
# endif
|
||||||
# if defined(LC_NUMERIC)
|
# if defined(LC_NUMERIC)
|
||||||
// Make sure strtod() uses a decimal point, not a comma.
|
// Make sure strtod() uses a decimal point, not a comma.
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
# endif
|
# endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // MACOS_CONVERT
|
#endif // MACOS_CONVERT
|
||||||
|
140
src/os_mswin.c
140
src/os_mswin.c
@ -835,24 +835,24 @@ check_str_len(char_u *str)
|
|||||||
GetSystemInfo(&si);
|
GetSystemInfo(&si);
|
||||||
|
|
||||||
// get memory information
|
// 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;
|
|
||||||
|
|
||||||
// get start address of page that str is on
|
// pre cast these (typing savers)
|
||||||
long_u strPage = dwStr - (dwStr - dwBaseAddress) % si.dwPageSize;
|
long_u dwStr = (long_u)str;
|
||||||
|
long_u dwBaseAddress = (long_u)mbi.BaseAddress;
|
||||||
|
|
||||||
// get length from str to end of page
|
// get start address of page that str is on
|
||||||
long_u pageLength = si.dwPageSize - (dwStr - strPage);
|
long_u strPage = dwStr - (dwStr - dwBaseAddress) % si.dwPageSize;
|
||||||
|
|
||||||
for (p = str; !IsBadReadPtr(p, (UINT)pageLength);
|
// get length from str to end of page
|
||||||
p += pageLength, pageLength = si.dwPageSize)
|
long_u pageLength = si.dwPageSize - (dwStr - strPage);
|
||||||
for (i = 0; i < pageLength; ++i, ++length)
|
|
||||||
if (p[i] == NUL)
|
for (p = str; !IsBadReadPtr(p, (UINT)pageLength);
|
||||||
return length + 1;
|
p += pageLength, pageLength = si.dwPageSize)
|
||||||
}
|
for (i = 0; i < pageLength; ++i, ++length)
|
||||||
|
if (p[i] == NUL)
|
||||||
|
return length + 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1213,43 +1213,43 @@ PrintHookProc(
|
|||||||
RECT rc, rcDlg, rcOwner;
|
RECT rc, rcDlg, rcOwner;
|
||||||
PRINTDLGW *pPD;
|
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();
|
|
||||||
|
|
||||||
GetWindowRect(hwndOwner, &rcOwner);
|
// Get the owner window and dialog box rectangles.
|
||||||
GetWindowRect(hDlg, &rcDlg);
|
if ((hwndOwner = GetParent(hDlg)) == NULL)
|
||||||
CopyRect(&rc, &rcOwner);
|
hwndOwner = GetDesktopWindow();
|
||||||
|
|
||||||
// Offset the owner and dialog box rectangles so that
|
GetWindowRect(hwndOwner, &rcOwner);
|
||||||
// right and bottom values represent the width and
|
GetWindowRect(hDlg, &rcDlg);
|
||||||
// height, and then offset the owner again to discard
|
CopyRect(&rc, &rcOwner);
|
||||||
// space taken up by the dialog box.
|
|
||||||
|
|
||||||
OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
|
// Offset the owner and dialog box rectangles so that
|
||||||
OffsetRect(&rc, -rc.left, -rc.top);
|
// right and bottom values represent the width and
|
||||||
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
|
// height, and then offset the owner again to discard
|
||||||
|
// space taken up by the dialog box.
|
||||||
|
|
||||||
// The new position is the sum of half the remaining
|
OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
|
||||||
// space and the owner's original position.
|
OffsetRect(&rc, -rc.left, -rc.top);
|
||||||
|
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
|
||||||
|
|
||||||
SetWindowPos(hDlg,
|
// The new position is the sum of half the remaining
|
||||||
HWND_TOP,
|
// space and the owner's original position.
|
||||||
rcOwner.left + (rc.right / 2),
|
|
||||||
rcOwner.top + (rc.bottom / 2),
|
|
||||||
0, 0, // ignores size arguments
|
|
||||||
SWP_NOSIZE);
|
|
||||||
|
|
||||||
// tackle the printdlg copiesctrl problem
|
SetWindowPos(hDlg,
|
||||||
pPD = (PRINTDLGW *)lParam;
|
HWND_TOP,
|
||||||
pPD->nCopies = (WORD)pPD->lCustData;
|
rcOwner.left + (rc.right / 2),
|
||||||
SetDlgItemInt( hDlg, edt3, pPD->nCopies, FALSE );
|
rcOwner.top + (rc.bottom / 2),
|
||||||
// Bring the window to top
|
0, 0, // ignores size arguments
|
||||||
BringWindowToTop(GetParent(hDlg));
|
SWP_NOSIZE);
|
||||||
SetForegroundWindow(hDlg);
|
|
||||||
}
|
// tackle the printdlg copiesctrl problem
|
||||||
|
pPD = (PRINTDLGW *)lParam;
|
||||||
|
pPD->nCopies = (WORD)pPD->lCustData;
|
||||||
|
SetDlgItemInt( hDlg, edt3, pPD->nCopies, FALSE );
|
||||||
|
// Bring the window to top
|
||||||
|
BringWindowToTop(GetParent(hDlg));
|
||||||
|
SetForegroundWindow(hDlg);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1571,29 +1571,27 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
init_fail_dlg:
|
init_fail_dlg:
|
||||||
|
DWORD err = CommDlgExtendedError();
|
||||||
|
|
||||||
|
if (err)
|
||||||
{
|
{
|
||||||
DWORD err = CommDlgExtendedError();
|
char_u *buf;
|
||||||
|
|
||||||
if (err)
|
// I suspect FormatMessage() doesn't work for values returned by
|
||||||
{
|
// CommDlgExtendedError(). What does?
|
||||||
char_u *buf;
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
// I suspect FormatMessage() doesn't work for values returned by
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
// CommDlgExtendedError(). What does?
|
NULL, err, 0, (LPTSTR)(&buf), 0, NULL);
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
semsg(_(e_print_error_str),
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
buf == NULL ? (char_u *)_("Unknown") : buf);
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
LocalFree((LPVOID)(buf));
|
||||||
NULL, err, 0, (LPTSTR)(&buf), 0, NULL);
|
|
||||||
semsg(_(e_print_error_str),
|
|
||||||
buf == NULL ? (char_u *)_("Unknown") : buf);
|
|
||||||
LocalFree((LPVOID)(buf));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
msg_clr_eos(); // Maybe canceled
|
|
||||||
|
|
||||||
mch_print_cleanup();
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
msg_clr_eos(); // Maybe canceled
|
||||||
|
|
||||||
|
mch_print_cleanup();
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1999,11 +1997,11 @@ serverSendEnc(HWND target)
|
|||||||
static void
|
static void
|
||||||
CleanUpMessaging(void)
|
CleanUpMessaging(void)
|
||||||
{
|
{
|
||||||
if (message_window != 0)
|
if (message_window == 0)
|
||||||
{
|
return;
|
||||||
DestroyWindow(message_window);
|
|
||||||
message_window = 0;
|
DestroyWindow(message_window);
|
||||||
}
|
message_window = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int save_reply(HWND server, char_u *reply, int expr);
|
static int save_reply(HWND server, char_u *reply, int expr);
|
||||||
|
56
src/os_qnx.c
56
src/os_qnx.c
@ -67,38 +67,38 @@ clip_mch_request_selection(Clipboard_T *cbd)
|
|||||||
char_u *clip_text = NULL;
|
char_u *clip_text = NULL;
|
||||||
|
|
||||||
cbdata = PhClipboardPasteStart(PhInputGroup(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)
|
||||||
{
|
{
|
||||||
// Look for the vim specific clip first
|
switch(*(char *) clip_header->data)
|
||||||
clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM);
|
|
||||||
if (clip_header != NULL && clip_header->data != NULL)
|
|
||||||
{
|
{
|
||||||
switch(*(char *) clip_header->data)
|
default: // fallthrough to line type
|
||||||
{
|
case 'L': type = MLINE; break;
|
||||||
default: // fallthrough to line type
|
case 'C': type = MCHAR; break;
|
||||||
case 'L': type = MLINE; break;
|
case 'B': type = MBLOCK; break;
|
||||||
case 'C': type = MCHAR; break;
|
|
||||||
case 'B': type = MBLOCK; break;
|
|
||||||
}
|
|
||||||
is_type_set = TRUE;
|
|
||||||
}
|
}
|
||||||
|
is_type_set = TRUE;
|
||||||
// Try for just normal text
|
|
||||||
clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT);
|
|
||||||
if (clip_header != NULL)
|
|
||||||
{
|
|
||||||
clip_text = clip_header->data;
|
|
||||||
clip_length = clip_header->length - 1;
|
|
||||||
|
|
||||||
if (clip_text != NULL && is_type_set == FALSE)
|
|
||||||
type = MAUTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((clip_text != NULL) && (clip_length > 0))
|
|
||||||
clip_yank_selection(type, clip_text, clip_length, cbd);
|
|
||||||
|
|
||||||
PhClipboardPasteFinish(cbdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try for just normal text
|
||||||
|
clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT);
|
||||||
|
if (clip_header != NULL)
|
||||||
|
{
|
||||||
|
clip_text = clip_header->data;
|
||||||
|
clip_length = clip_header->length - 1;
|
||||||
|
|
||||||
|
if (clip_text != NULL && is_type_set == FALSE)
|
||||||
|
type = MAUTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((clip_text != NULL) && (clip_length > 0))
|
||||||
|
clip_yank_selection(type, clip_text, clip_length, cbd);
|
||||||
|
|
||||||
|
PhClipboardPasteFinish(cbdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
509
src/os_unix.c
509
src/os_unix.c
@ -780,16 +780,16 @@ get_stack_limit(void)
|
|||||||
int
|
int
|
||||||
mch_stackcheck(char *p)
|
mch_stackcheck(char *p)
|
||||||
{
|
{
|
||||||
if (stack_limit != NULL)
|
if (stack_limit == NULL)
|
||||||
|
return OK;
|
||||||
|
|
||||||
|
if (stack_grows_downwards)
|
||||||
{
|
{
|
||||||
if (stack_grows_downwards)
|
if (p < stack_limit)
|
||||||
{
|
|
||||||
if (p < stack_limit)
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
else if (p > stack_limit)
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
else if (p > stack_limit)
|
||||||
|
return FAIL;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -837,25 +837,25 @@ static char *signal_stack;
|
|||||||
static void
|
static void
|
||||||
init_signal_stack(void)
|
init_signal_stack(void)
|
||||||
{
|
{
|
||||||
if (signal_stack != NULL)
|
if (signal_stack == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
# ifdef HAVE_SIGALTSTACK
|
# ifdef HAVE_SIGALTSTACK
|
||||||
# ifdef HAVE_SS_BASE
|
# ifdef HAVE_SS_BASE
|
||||||
sigstk.ss_base = signal_stack;
|
sigstk.ss_base = signal_stack;
|
||||||
# else
|
# else
|
||||||
sigstk.ss_sp = signal_stack;
|
sigstk.ss_sp = signal_stack;
|
||||||
# endif
|
# endif
|
||||||
sigstk.ss_size = get_signal_stack_size();
|
sigstk.ss_size = get_signal_stack_size();
|
||||||
sigstk.ss_flags = 0;
|
sigstk.ss_flags = 0;
|
||||||
(void)sigaltstack(&sigstk, NULL);
|
(void)sigaltstack(&sigstk, NULL);
|
||||||
# else
|
# else
|
||||||
sigstk.ss_sp = signal_stack;
|
sigstk.ss_sp = signal_stack;
|
||||||
if (stack_grows_downwards)
|
if (stack_grows_downwards)
|
||||||
sigstk.ss_sp += get_signal_stack_size() - 1;
|
sigstk.ss_sp += get_signal_stack_size() - 1;
|
||||||
sigstk.ss_onstack = 0;
|
sigstk.ss_onstack = 0;
|
||||||
(void)sigstack(&sigstk, NULL);
|
(void)sigstack(&sigstk, NULL);
|
||||||
# endif
|
# endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2020,91 +2020,90 @@ get_x11_thing(
|
|||||||
int retval = FALSE;
|
int retval = FALSE;
|
||||||
Status status;
|
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);
|
||||||
|
else
|
||||||
|
status = XGetWMIconName(x11_display, x11_window, &text_prop);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If terminal is xterm, then x11_window may be a child window of the
|
||||||
|
* outer xterm window that actually contains the window/icon name, so
|
||||||
|
* keep traversing up the tree until a window with a title/icon is
|
||||||
|
* found.
|
||||||
|
*/
|
||||||
|
// 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;
|
||||||
|
Window *children;
|
||||||
|
unsigned int num_children;
|
||||||
|
|
||||||
|
while (!status || text_prop.value == NULL)
|
||||||
{
|
{
|
||||||
// Get window/icon name if any
|
if (!XQueryTree(x11_display, win, &root, &parent, &children,
|
||||||
|
&num_children))
|
||||||
|
break;
|
||||||
|
if (children)
|
||||||
|
XFree((void *)children);
|
||||||
|
if (parent == root || parent == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
win = parent;
|
||||||
if (get_title)
|
if (get_title)
|
||||||
status = XGetWMName(x11_display, x11_window, &text_prop);
|
status = XGetWMName(x11_display, win, &text_prop);
|
||||||
else
|
else
|
||||||
status = XGetWMIconName(x11_display, x11_window, &text_prop);
|
status = XGetWMIconName(x11_display, win, &text_prop);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
if (status && text_prop.value != NULL)
|
||||||
* If terminal is xterm, then x11_window may be a child window of the
|
{
|
||||||
* outer xterm window that actually contains the window/icon name, so
|
retval = TRUE;
|
||||||
* keep traversing up the tree until a window with a title/icon is
|
if (!test_only)
|
||||||
* found.
|
|
||||||
*/
|
|
||||||
// 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;
|
if (get_title)
|
||||||
Window parent;
|
vim_free(oldtitle);
|
||||||
Window win = x11_window;
|
else
|
||||||
Window *children;
|
vim_free(oldicon);
|
||||||
unsigned int num_children;
|
if (text_prop.encoding == XA_STRING && !has_mbyte)
|
||||||
|
|
||||||
while (!status || text_prop.value == NULL)
|
|
||||||
{
|
{
|
||||||
if (!XQueryTree(x11_display, win, &root, &parent, &children,
|
|
||||||
&num_children))
|
|
||||||
break;
|
|
||||||
if (children)
|
|
||||||
XFree((void *)children);
|
|
||||||
if (parent == root || parent == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
win = parent;
|
|
||||||
if (get_title)
|
if (get_title)
|
||||||
status = XGetWMName(x11_display, win, &text_prop);
|
oldtitle = vim_strsave((char_u *)text_prop.value);
|
||||||
else
|
else
|
||||||
status = XGetWMIconName(x11_display, win, &text_prop);
|
oldicon = vim_strsave((char_u *)text_prop.value);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
if (status && text_prop.value != NULL)
|
|
||||||
{
|
|
||||||
retval = TRUE;
|
|
||||||
if (!test_only)
|
|
||||||
{
|
{
|
||||||
if (get_title)
|
char **cl;
|
||||||
vim_free(oldtitle);
|
Status transform_status;
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
transform_status = XmbTextPropertyToTextList(x11_display,
|
||||||
|
&text_prop,
|
||||||
|
&cl, &n);
|
||||||
|
if (transform_status >= Success && n > 0 && cl[0])
|
||||||
|
{
|
||||||
|
if (get_title)
|
||||||
|
oldtitle = vim_strsave((char_u *) cl[0]);
|
||||||
|
else
|
||||||
|
oldicon = vim_strsave((char_u *) cl[0]);
|
||||||
|
XFreeStringList(cl);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
vim_free(oldicon);
|
|
||||||
if (text_prop.encoding == XA_STRING && !has_mbyte)
|
|
||||||
{
|
{
|
||||||
if (get_title)
|
if (get_title)
|
||||||
oldtitle = vim_strsave((char_u *)text_prop.value);
|
oldtitle = vim_strsave((char_u *)text_prop.value);
|
||||||
else
|
else
|
||||||
oldicon = vim_strsave((char_u *)text_prop.value);
|
oldicon = vim_strsave((char_u *)text_prop.value);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
char **cl;
|
|
||||||
Status transform_status;
|
|
||||||
int n = 0;
|
|
||||||
|
|
||||||
transform_status = XmbTextPropertyToTextList(x11_display,
|
|
||||||
&text_prop,
|
|
||||||
&cl, &n);
|
|
||||||
if (transform_status >= Success && n > 0 && cl[0])
|
|
||||||
{
|
|
||||||
if (get_title)
|
|
||||||
oldtitle = vim_strsave((char_u *) cl[0]);
|
|
||||||
else
|
|
||||||
oldicon = vim_strsave((char_u *) cl[0]);
|
|
||||||
XFreeStringList(cl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (get_title)
|
|
||||||
oldtitle = vim_strsave((char_u *)text_prop.value);
|
|
||||||
else
|
|
||||||
oldicon = vim_strsave((char_u *)text_prop.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
XFree((void *)text_prop.value);
|
|
||||||
}
|
}
|
||||||
|
XFree((void *)text_prop.value);
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -2772,52 +2771,52 @@ fname_case(
|
|||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct dirent *dp;
|
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)
|
||||||
{
|
{
|
||||||
// Open the directory where the file is located.
|
dirp = opendir(".");
|
||||||
slash = vim_strrchr(name, '/');
|
tail = name;
|
||||||
if (slash == NULL)
|
}
|
||||||
{
|
else
|
||||||
dirp = opendir(".");
|
{
|
||||||
tail = name;
|
*slash = NUL;
|
||||||
}
|
dirp = opendir((char *)name);
|
||||||
else
|
*slash = '/';
|
||||||
{
|
tail = slash + 1;
|
||||||
*slash = NUL;
|
}
|
||||||
dirp = opendir((char *)name);
|
|
||||||
*slash = '/';
|
|
||||||
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
|
||||||
|
// length. TODO: accept different length name.
|
||||||
|
if (STRICMP(tail, dp->d_name) == 0
|
||||||
|
&& STRLEN(tail) == STRLEN(dp->d_name))
|
||||||
{
|
{
|
||||||
while ((dp = readdir(dirp)) != NULL)
|
char_u newname[MAXPATHL + 1];
|
||||||
|
struct stat st2;
|
||||||
|
|
||||||
|
// Verify the inode is equal.
|
||||||
|
vim_strncpy(newname, name, MAXPATHL);
|
||||||
|
vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
|
||||||
|
MAXPATHL - (tail - name));
|
||||||
|
if (mch_lstat((char *)newname, &st2) >= 0
|
||||||
|
&& st.st_ino == st2.st_ino
|
||||||
|
&& st.st_dev == st2.st_dev)
|
||||||
{
|
{
|
||||||
// Only accept names that differ in case and are the same byte
|
STRCPY(tail, dp->d_name);
|
||||||
// length. TODO: accept different length name.
|
break;
|
||||||
if (STRICMP(tail, dp->d_name) == 0
|
|
||||||
&& STRLEN(tail) == STRLEN(dp->d_name))
|
|
||||||
{
|
|
||||||
char_u newname[MAXPATHL + 1];
|
|
||||||
struct stat st2;
|
|
||||||
|
|
||||||
// Verify the inode is equal.
|
|
||||||
vim_strncpy(newname, name, MAXPATHL);
|
|
||||||
vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
|
|
||||||
MAXPATHL - (tail - name));
|
|
||||||
if (mch_lstat((char *)newname, &st2) >= 0
|
|
||||||
&& st.st_ino == st2.st_ino
|
|
||||||
&& st.st_dev == st2.st_dev)
|
|
||||||
{
|
|
||||||
STRCPY(tail, dp->d_name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dirp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closedir(dirp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2902,46 +2901,46 @@ mch_copy_sec(char_u *from_file, char_u *to_file)
|
|||||||
if (selinux_enabled == -1)
|
if (selinux_enabled == -1)
|
||||||
selinux_enabled = is_selinux_enabled();
|
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;
|
||||||
|
char *to_context = NULL;
|
||||||
|
|
||||||
|
if (getfilecon((char *)from_file, &from_context) < 0)
|
||||||
{
|
{
|
||||||
// Use "char *" instead of "security_context_t" to avoid a deprecation
|
// If the filesystem doesn't support extended attributes,
|
||||||
// warning.
|
// the original had no special security context and the
|
||||||
char *from_context = NULL;
|
// target cannot have one either.
|
||||||
char *to_context = NULL;
|
if (errno == EOPNOTSUPP)
|
||||||
|
|
||||||
if (getfilecon((char *)from_file, &from_context) < 0)
|
|
||||||
{
|
|
||||||
// If the filesystem doesn't support extended attributes,
|
|
||||||
// the original had no special security context and the
|
|
||||||
// target cannot have one either.
|
|
||||||
if (errno == EOPNOTSUPP)
|
|
||||||
return;
|
|
||||||
|
|
||||||
msg_puts(_("\nCould not get security context for "));
|
|
||||||
msg_outtrans(from_file);
|
|
||||||
msg_putchar('\n');
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (getfilecon((char *)to_file, &to_context) < 0)
|
msg_puts(_("\nCould not get security context for "));
|
||||||
|
msg_outtrans(from_file);
|
||||||
|
msg_putchar('\n');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (getfilecon((char *)to_file, &to_context) < 0)
|
||||||
|
{
|
||||||
|
msg_puts(_("\nCould not get security context for "));
|
||||||
|
msg_outtrans(to_file);
|
||||||
|
msg_putchar('\n');
|
||||||
|
freecon (from_context);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (strcmp(from_context, to_context) != 0)
|
||||||
|
{
|
||||||
|
if (setfilecon((char *)to_file, from_context) < 0)
|
||||||
{
|
{
|
||||||
msg_puts(_("\nCould not get security context for "));
|
msg_puts(_("\nCould not set security context for "));
|
||||||
msg_outtrans(to_file);
|
msg_outtrans(to_file);
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
freecon (from_context);
|
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
if (strcmp(from_context, to_context) != 0)
|
|
||||||
{
|
|
||||||
if (setfilecon((char *)to_file, from_context) < 0)
|
|
||||||
{
|
|
||||||
msg_puts(_("\nCould not set security context for "));
|
|
||||||
msg_outtrans(to_file);
|
|
||||||
msg_putchar('\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
freecon(to_context);
|
|
||||||
freecon(from_context);
|
|
||||||
}
|
}
|
||||||
|
freecon(to_context);
|
||||||
|
freecon(from_context);
|
||||||
}
|
}
|
||||||
#endif // HAVE_SELINUX
|
#endif // HAVE_SELINUX
|
||||||
|
|
||||||
@ -3549,21 +3548,21 @@ mch_tcgetattr(int fd, void *term)
|
|||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
tty_fd = get_tty_fd(fd);
|
tty_fd = get_tty_fd(fd);
|
||||||
if (tty_fd >= 0)
|
if (tty_fd < 0)
|
||||||
{
|
return -1;
|
||||||
|
|
||||||
#ifdef NEW_TTY_SYSTEM
|
#ifdef NEW_TTY_SYSTEM
|
||||||
# ifdef HAVE_TERMIOS_H
|
# ifdef HAVE_TERMIOS_H
|
||||||
retval = tcgetattr(tty_fd, (struct termios *)term);
|
retval = tcgetattr(tty_fd, (struct termios *)term);
|
||||||
# else
|
# else
|
||||||
retval = ioctl(tty_fd, TCGETA, (struct termio *)term);
|
retval = ioctl(tty_fd, TCGETA, (struct termio *)term);
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
// for "old" tty systems
|
// for "old" tty systems
|
||||||
retval = ioctl(tty_fd, TIOCGETP, (struct sgttyb *)term);
|
retval = ioctl(tty_fd, TIOCGETP, (struct sgttyb *)term);
|
||||||
#endif
|
#endif
|
||||||
if (tty_fd != fd)
|
if (tty_fd != fd)
|
||||||
close(tty_fd);
|
close(tty_fd);
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3682,18 +3681,18 @@ get_stty(void)
|
|||||||
char_u buf[2];
|
char_u buf[2];
|
||||||
char_u *p;
|
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;
|
|
||||||
add_termcode((char_u *)"kb", buf, FALSE);
|
|
||||||
|
|
||||||
// If <BS> and <DEL> are now the same, redefine <DEL>.
|
intr_char = info.interrupt;
|
||||||
p = find_termcode((char_u *)"kD");
|
buf[0] = info.backspace;
|
||||||
if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
|
buf[1] = NUL;
|
||||||
do_fixdel(NULL);
|
add_termcode((char_u *)"kb", buf, FALSE);
|
||||||
}
|
|
||||||
|
// If <BS> and <DEL> are now the same, redefine <DEL>.
|
||||||
|
p = find_termcode((char_u *)"kD");
|
||||||
|
if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
|
||||||
|
do_fixdel(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4160,30 +4159,30 @@ mch_report_winsize(int fd, int rows, int cols)
|
|||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
tty_fd = get_tty_fd(fd);
|
tty_fd = get_tty_fd(fd);
|
||||||
if (tty_fd >= 0)
|
if (tty_fd < 0)
|
||||||
{
|
return FAIL;
|
||||||
|
|
||||||
# if defined(TIOCSWINSZ)
|
# if defined(TIOCSWINSZ)
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
|
|
||||||
ws.ws_col = cols;
|
ws.ws_col = cols;
|
||||||
ws.ws_row = rows;
|
ws.ws_row = rows;
|
||||||
ws.ws_xpixel = cols * 5;
|
ws.ws_xpixel = cols * 5;
|
||||||
ws.ws_ypixel = rows * 10;
|
ws.ws_ypixel = rows * 10;
|
||||||
retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
|
retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
|
||||||
ch_log(NULL, "ioctl(TIOCSWINSZ) %s",
|
ch_log(NULL, "ioctl(TIOCSWINSZ) %s",
|
||||||
retval == 0 ? "success" : "failed");
|
retval == 0 ? "success" : "failed");
|
||||||
# elif defined(TIOCSSIZE)
|
# elif defined(TIOCSSIZE)
|
||||||
struct ttysize ts;
|
struct ttysize ts;
|
||||||
|
|
||||||
ts.ts_cols = cols;
|
ts.ts_cols = cols;
|
||||||
ts.ts_lines = rows;
|
ts.ts_lines = rows;
|
||||||
retval = ioctl(tty_fd, TIOCSSIZE, &ts);
|
retval = ioctl(tty_fd, TIOCSSIZE, &ts);
|
||||||
ch_log(NULL, "ioctl(TIOCSSIZE) %s",
|
ch_log(NULL, "ioctl(TIOCSSIZE) %s",
|
||||||
retval == 0 ? "success" : "failed");
|
retval == 0 ? "success" : "failed");
|
||||||
# endif
|
# endif
|
||||||
if (tty_fd != fd)
|
if (tty_fd != fd)
|
||||||
close(tty_fd);
|
close(tty_fd);
|
||||||
}
|
|
||||||
return retval == 0 ? OK : FAIL;
|
return retval == 0 ? OK : FAIL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -4362,28 +4361,28 @@ open_pty(int *pty_master_fd, int *pty_slave_fd, char_u **name1, char_u **name2)
|
|||||||
*name2 = NULL;
|
*name2 = NULL;
|
||||||
|
|
||||||
*pty_master_fd = mch_openpty(&tty_name); // open pty
|
*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
|
// Leaving out O_NOCTTY may lead to waitpid() always returning
|
||||||
// adding O_NOCTTY always works when defined.
|
// 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
|
||||||
|
// adding O_NOCTTY always works when defined.
|
||||||
#ifdef O_NOCTTY
|
#ifdef O_NOCTTY
|
||||||
*pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
|
*pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
|
||||||
#else
|
#else
|
||||||
*pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0);
|
*pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0);
|
||||||
#endif
|
#endif
|
||||||
if (*pty_slave_fd < 0)
|
if (*pty_slave_fd < 0)
|
||||||
{
|
{
|
||||||
close(*pty_master_fd);
|
close(*pty_master_fd);
|
||||||
*pty_master_fd = -1;
|
*pty_master_fd = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (name1 != NULL)
|
if (name1 != NULL)
|
||||||
*name1 = vim_strsave((char_u *)tty_name);
|
*name1 = vim_strsave((char_u *)tty_name);
|
||||||
if (name2 != NULL)
|
if (name2 != NULL)
|
||||||
*name2 = vim_strsave((char_u *)tty_name);
|
*name2 = vim_strsave((char_u *)tty_name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -7250,29 +7249,28 @@ gpm_open(void)
|
|||||||
return 0;
|
return 0;
|
||||||
#endif
|
#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
|
||||||
|
gpm_connect.minMod = 0; // Handle any modifier keys
|
||||||
|
gpm_connect.maxMod = 0xffff;
|
||||||
|
if (Gpm_Open(&gpm_connect, 0) > 0)
|
||||||
{
|
{
|
||||||
gpm_connect.eventMask = (GPM_UP | GPM_DRAG | GPM_DOWN);
|
// gpm library tries to handling TSTP causes
|
||||||
gpm_connect.defaultMask = ~GPM_HARD;
|
// problems. Anyways, we close connection to Gpm whenever
|
||||||
// Default handling for mouse move
|
// we are going to suspend or starting an external process
|
||||||
gpm_connect.minMod = 0; // Handle any modifier keys
|
// so we shouldn't have problem with this
|
||||||
gpm_connect.maxMod = 0xffff;
|
|
||||||
if (Gpm_Open(&gpm_connect, 0) > 0)
|
|
||||||
{
|
|
||||||
// gpm library tries to handling TSTP causes
|
|
||||||
// problems. Anyways, we close connection to Gpm whenever
|
|
||||||
// we are going to suspend or starting an external process
|
|
||||||
// so we shouldn't have problem with this
|
|
||||||
# ifdef SIGTSTP
|
# ifdef SIGTSTP
|
||||||
signal(SIGTSTP, restricted ? SIG_IGN : (void (*)())sig_tstp);
|
signal(SIGTSTP, restricted ? SIG_IGN : (void (*)())sig_tstp);
|
||||||
# endif
|
# endif
|
||||||
return 1; // succeed
|
return 1; // succeed
|
||||||
}
|
|
||||||
if (gpm_fd == -2)
|
|
||||||
Gpm_Close(); // We don't want to talk to xterm via gpm
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return 1; // already open
|
if (gpm_fd == -2)
|
||||||
|
Gpm_Close(); // We don't want to talk to xterm via gpm
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -7395,14 +7393,13 @@ sysmouse_open(void)
|
|||||||
mouse.operation = MOUSE_MODE;
|
mouse.operation = MOUSE_MODE;
|
||||||
mouse.u.mode.mode = 0;
|
mouse.u.mode.mode = 0;
|
||||||
mouse.u.mode.signal = SIGUSR2;
|
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;
|
signal(SIGUSR2, (void (*)())sig_sysmouse);
|
||||||
ioctl(1, CONS_MOUSECTL, &mouse);
|
mouse.operation = MOUSE_SHOW;
|
||||||
return OK;
|
ioctl(1, CONS_MOUSECTL, &mouse);
|
||||||
}
|
return OK;
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -8243,14 +8240,14 @@ xsmp_init(void)
|
|||||||
void
|
void
|
||||||
xsmp_close(void)
|
xsmp_close(void)
|
||||||
{
|
{
|
||||||
if (xsmp_icefd != -1)
|
if (xsmp_icefd == -1)
|
||||||
{
|
return;
|
||||||
SmcCloseConnection(xsmp.smcconn, 0, NULL);
|
|
||||||
if (xsmp.clientid != NULL)
|
SmcCloseConnection(xsmp.smcconn, 0, NULL);
|
||||||
free(xsmp.clientid);
|
if (xsmp.clientid != NULL)
|
||||||
xsmp.clientid = NULL;
|
free(xsmp.clientid);
|
||||||
xsmp_icefd = -1;
|
xsmp.clientid = NULL;
|
||||||
}
|
xsmp_icefd = -1;
|
||||||
}
|
}
|
||||||
#endif // USE_XSMP
|
#endif // USE_XSMP
|
||||||
|
|
||||||
@ -8348,11 +8345,11 @@ start_timeout(long msec)
|
|||||||
void
|
void
|
||||||
delete_timer(void)
|
delete_timer(void)
|
||||||
{
|
{
|
||||||
if (timer_created)
|
if (!timer_created)
|
||||||
{
|
return;
|
||||||
timer_delete(timer_id);
|
|
||||||
timer_created = FALSE;
|
timer_delete(timer_id);
|
||||||
}
|
timer_created = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
# else // HAVE_TIMER_CREATE
|
# else // HAVE_TIMER_CREATE
|
||||||
|
371
src/os_win32.c
371
src/os_win32.c
@ -278,15 +278,15 @@ get_build_number(void)
|
|||||||
|
|
||||||
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
||||||
hNtdll = GetModuleHandle("ntdll.dll");
|
hNtdll = GetModuleHandle("ntdll.dll");
|
||||||
if (hNtdll != NULL)
|
if (hNtdll == NULL)
|
||||||
{
|
return ver;
|
||||||
pRtlGetVersion =
|
|
||||||
(PfnRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion");
|
pRtlGetVersion =
|
||||||
pRtlGetVersion(&osver);
|
(PfnRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion");
|
||||||
ver = MAKE_VER(min(osver.dwMajorVersion, 255),
|
pRtlGetVersion(&osver);
|
||||||
min(osver.dwMinorVersion, 255),
|
ver = MAKE_VER(min(osver.dwMajorVersion, 255),
|
||||||
min(osver.dwBuildNumber, 32767));
|
min(osver.dwMinorVersion, 255),
|
||||||
}
|
min(osver.dwBuildNumber, 32767));
|
||||||
return ver;
|
return ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,29 +478,29 @@ get_exe_name(void)
|
|||||||
exe_name = FullName_save((char_u *)temp, FALSE);
|
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)
|
||||||
|
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.
|
||||||
|
p = mch_getenv("PATH");
|
||||||
|
if (p == NULL
|
||||||
|
|| STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN)
|
||||||
{
|
{
|
||||||
exe_path = vim_strnsave(exe_name, gettail_sep(exe_name) - exe_name);
|
if (p == NULL || *p == NUL)
|
||||||
if (exe_path != NULL)
|
temp[0] = NUL;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Append our starting directory to $PATH, so that when doing
|
STRCPY(temp, p);
|
||||||
// "!xxd" it's found in our starting directory. Needed because
|
STRCAT(temp, ";");
|
||||||
// SearchPath() also looks there.
|
|
||||||
p = mch_getenv("PATH");
|
|
||||||
if (p == NULL
|
|
||||||
|| STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN)
|
|
||||||
{
|
|
||||||
if (p == NULL || *p == NUL)
|
|
||||||
temp[0] = NUL;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
STRCPY(temp, p);
|
|
||||||
STRCAT(temp, ";");
|
|
||||||
}
|
|
||||||
STRCAT(temp, exe_path);
|
|
||||||
vim_setenv((char_u *)"PATH", (char_u *)temp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
STRCAT(temp, exe_path);
|
||||||
|
vim_setenv((char_u *)"PATH", (char_u *)temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,27 +533,27 @@ vimLoadLib(const char *name)
|
|||||||
|
|
||||||
// No need to load any library when registering OLE.
|
// No need to load any library when registering OLE.
|
||||||
if (found_register_arg)
|
if (found_register_arg)
|
||||||
return dll;
|
return NULL;
|
||||||
|
|
||||||
// NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
|
// NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
|
||||||
// vimLoadLib() recursively, which causes a stack overflow.
|
// vimLoadLib() recursively, which causes a stack overflow.
|
||||||
if (exe_path == NULL)
|
if (exe_path == NULL)
|
||||||
get_exe_name();
|
get_exe_name();
|
||||||
if (exe_path != NULL)
|
|
||||||
{
|
|
||||||
WCHAR old_dirw[MAXPATHL];
|
|
||||||
|
|
||||||
if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0)
|
if (exe_path == NULL)
|
||||||
{
|
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
|
WCHAR old_dirw[MAXPATHL];
|
||||||
// in the current directory.
|
|
||||||
SetCurrentDirectory((LPCSTR)exe_path);
|
if (GetCurrentDirectoryW(MAXPATHL, old_dirw) == 0)
|
||||||
dll = LoadLibrary(name);
|
return NULL;
|
||||||
SetCurrentDirectoryW(old_dirw);
|
|
||||||
return dll;
|
// 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.
|
||||||
|
SetCurrentDirectory((LPCSTR)exe_path);
|
||||||
|
dll = LoadLibrary(name);
|
||||||
|
SetCurrentDirectoryW(old_dirw);
|
||||||
return dll;
|
return dll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -907,31 +907,31 @@ PlatformId(void)
|
|||||||
{
|
{
|
||||||
static int done = FALSE;
|
static int done = FALSE;
|
||||||
|
|
||||||
if (!done)
|
if (done)
|
||||||
{
|
return;
|
||||||
OSVERSIONINFO ovi;
|
|
||||||
|
|
||||||
ovi.dwOSVersionInfoSize = sizeof(ovi);
|
OSVERSIONINFO ovi;
|
||||||
GetVersionEx(&ovi);
|
|
||||||
|
ovi.dwOSVersionInfoSize = sizeof(ovi);
|
||||||
|
GetVersionEx(&ovi);
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d",
|
vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d",
|
||||||
(int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion);
|
(int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion);
|
||||||
#endif
|
#endif
|
||||||
if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2)
|
if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2)
|
||||||
|| ovi.dwMajorVersion > 6)
|
|| ovi.dwMajorVersion > 6)
|
||||||
win8_or_later = TRUE;
|
win8_or_later = TRUE;
|
||||||
|
|
||||||
if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 19045)
|
if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 19045)
|
||||||
|| ovi.dwMajorVersion > 10)
|
|| ovi.dwMajorVersion > 10)
|
||||||
win10_22H2_or_later = TRUE;
|
win10_22H2_or_later = TRUE;
|
||||||
|
|
||||||
#ifdef HAVE_ACL
|
#ifdef HAVE_ACL
|
||||||
// Enable privilege for getting or setting SACLs.
|
// Enable privilege for getting or setting SACLs.
|
||||||
win32_enable_privilege(SE_SECURITY_NAME, TRUE);
|
win32_enable_privilege(SE_SECURITY_NAME, TRUE);
|
||||||
#endif
|
#endif
|
||||||
done = TRUE;
|
done = TRUE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
@ -3051,40 +3051,38 @@ FitConsoleWindow(
|
|||||||
COORD dwWindowSize;
|
COORD dwWindowSize;
|
||||||
BOOL NeedAdjust = FALSE;
|
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
|
|
||||||
* have to move and possibly shrink the window.
|
|
||||||
*/
|
|
||||||
if (csbi.srWindow.Right >= dwBufferSize.X)
|
|
||||||
{
|
|
||||||
dwWindowSize.X = SRWIDTH(csbi.srWindow);
|
|
||||||
if (dwWindowSize.X > dwBufferSize.X)
|
|
||||||
dwWindowSize.X = dwBufferSize.X;
|
|
||||||
csbi.srWindow.Right = dwBufferSize.X - 1;
|
|
||||||
csbi.srWindow.Left = dwBufferSize.X - dwWindowSize.X;
|
|
||||||
NeedAdjust = TRUE;
|
|
||||||
}
|
|
||||||
if (csbi.srWindow.Bottom >= dwBufferSize.Y)
|
|
||||||
{
|
|
||||||
dwWindowSize.Y = SRHEIGHT(csbi.srWindow);
|
|
||||||
if (dwWindowSize.Y > dwBufferSize.Y)
|
|
||||||
dwWindowSize.Y = dwBufferSize.Y;
|
|
||||||
csbi.srWindow.Bottom = dwBufferSize.Y - 1;
|
|
||||||
csbi.srWindow.Top = dwBufferSize.Y - dwWindowSize.Y;
|
|
||||||
NeedAdjust = TRUE;
|
|
||||||
}
|
|
||||||
if (NeedAdjust && WantAdjust)
|
|
||||||
{
|
|
||||||
if (!SetConsoleWindowInfo(g_hConOut, TRUE, &csbi.srWindow))
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
/*
|
||||||
|
* A buffer resize will fail if the current console window does
|
||||||
|
* not lie completely within that buffer. To avoid this, we might
|
||||||
|
* have to move and possibly shrink the window.
|
||||||
|
*/
|
||||||
|
if (csbi.srWindow.Right >= dwBufferSize.X)
|
||||||
|
{
|
||||||
|
dwWindowSize.X = SRWIDTH(csbi.srWindow);
|
||||||
|
if (dwWindowSize.X > dwBufferSize.X)
|
||||||
|
dwWindowSize.X = dwBufferSize.X;
|
||||||
|
csbi.srWindow.Right = dwBufferSize.X - 1;
|
||||||
|
csbi.srWindow.Left = dwBufferSize.X - dwWindowSize.X;
|
||||||
|
NeedAdjust = TRUE;
|
||||||
|
}
|
||||||
|
if (csbi.srWindow.Bottom >= dwBufferSize.Y)
|
||||||
|
{
|
||||||
|
dwWindowSize.Y = SRHEIGHT(csbi.srWindow);
|
||||||
|
if (dwWindowSize.Y > dwBufferSize.Y)
|
||||||
|
dwWindowSize.Y = dwBufferSize.Y;
|
||||||
|
csbi.srWindow.Bottom = dwBufferSize.Y - 1;
|
||||||
|
csbi.srWindow.Top = dwBufferSize.Y - dwWindowSize.Y;
|
||||||
|
NeedAdjust = TRUE;
|
||||||
|
}
|
||||||
|
if (NeedAdjust && WantAdjust)
|
||||||
|
{
|
||||||
|
if (!SetConsoleWindowInfo(g_hConOut, TRUE, &csbi.srWindow))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct ConsoleBufferStruct
|
typedef struct ConsoleBufferStruct
|
||||||
@ -3674,17 +3672,15 @@ mch_get_host_name(
|
|||||||
WCHAR wszHostName[256 + 1];
|
WCHAR wszHostName[256 + 1];
|
||||||
DWORD wcch = ARRAY_LENGTH(wszHostName);
|
DWORD wcch = ARRAY_LENGTH(wszHostName);
|
||||||
|
|
||||||
if (GetComputerNameW(wszHostName, &wcch))
|
if (!GetComputerNameW(wszHostName, &wcch))
|
||||||
{
|
return;
|
||||||
char_u *p = utf16_to_enc(wszHostName, NULL);
|
|
||||||
|
|
||||||
if (p != NULL)
|
char_u *p = utf16_to_enc(wszHostName, NULL);
|
||||||
{
|
if (p == NULL)
|
||||||
vim_strncpy(s, p, len - 1);
|
return;
|
||||||
vim_free(p);
|
|
||||||
return;
|
vim_strncpy(s, p, len - 1);
|
||||||
}
|
vim_free(p);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3732,32 +3728,31 @@ mch_dirname(
|
|||||||
* But the Win32s known bug list says that getcwd() doesn't work
|
* But the Win32s known bug list says that getcwd() doesn't work
|
||||||
* so use the Win32 system call instead. <Negri>
|
* 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;
|
||||||
|
|
||||||
|
if (GetLongPathNameW(wbuf, wcbuf, _MAX_PATH) != 0)
|
||||||
{
|
{
|
||||||
WCHAR wcbuf[_MAX_PATH + 1];
|
p = utf16_to_enc(wcbuf, NULL);
|
||||||
char_u *p = NULL;
|
if (STRLEN(p) >= (size_t)len)
|
||||||
|
|
||||||
if (GetLongPathNameW(wbuf, wcbuf, _MAX_PATH) != 0)
|
|
||||||
{
|
{
|
||||||
p = utf16_to_enc(wcbuf, NULL);
|
// long path name is too long, fall back to short one
|
||||||
if (STRLEN(p) >= (size_t)len)
|
|
||||||
{
|
|
||||||
// long path name is too long, fall back to short one
|
|
||||||
vim_free(p);
|
|
||||||
p = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (p == NULL)
|
|
||||||
p = utf16_to_enc(wbuf, NULL);
|
|
||||||
|
|
||||||
if (p != NULL)
|
|
||||||
{
|
|
||||||
vim_strncpy(buf, p, len - 1);
|
|
||||||
vim_free(p);
|
vim_free(p);
|
||||||
return OK;
|
p = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FAIL;
|
if (p == NULL)
|
||||||
|
p = utf16_to_enc(wbuf, NULL);
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
|
vim_strncpy(buf, p, len - 1);
|
||||||
|
vim_free(p);
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3974,14 +3969,14 @@ win32_fileinfo(char_u *fname, BY_HANDLE_FILE_INFORMATION *info)
|
|||||||
NULL); // handle to template file
|
NULL); // handle to template file
|
||||||
vim_free(wn);
|
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;
|
if (GetFileInformationByHandle(hFile, info) != 0)
|
||||||
else
|
res = FILEINFO_OK;
|
||||||
res = FILEINFO_INFO_FAIL;
|
else
|
||||||
CloseHandle(hFile);
|
res = FILEINFO_INFO_FAIL;
|
||||||
}
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -6170,12 +6165,12 @@ mch_signal_job(job_T *job, char_u *how)
|
|||||||
void
|
void
|
||||||
mch_clear_job(job_T *job)
|
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);
|
if (job->jv_job_object != NULL)
|
||||||
CloseHandle(job->jv_proc_info.hProcess);
|
CloseHandle(job->jv_job_object);
|
||||||
}
|
CloseHandle(job->jv_proc_info.hProcess);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -7988,32 +7983,32 @@ load_ntdll(void)
|
|||||||
{
|
{
|
||||||
static int loaded = -1;
|
static int loaded = -1;
|
||||||
|
|
||||||
if (loaded == -1)
|
if (loaded != -1)
|
||||||
|
return (BOOL) loaded;
|
||||||
|
|
||||||
|
HMODULE hNtdll = GetModuleHandle("ntdll.dll");
|
||||||
|
if (hNtdll != NULL)
|
||||||
{
|
{
|
||||||
HMODULE hNtdll = GetModuleHandle("ntdll.dll");
|
pNtOpenFile = (PfnNtOpenFile) GetProcAddress(hNtdll, "NtOpenFile");
|
||||||
if (hNtdll != NULL)
|
pNtClose = (PfnNtClose) GetProcAddress(hNtdll, "NtClose");
|
||||||
{
|
pNtSetEaFile = (PfnNtSetEaFile)
|
||||||
pNtOpenFile = (PfnNtOpenFile) GetProcAddress(hNtdll, "NtOpenFile");
|
GetProcAddress(hNtdll, "NtSetEaFile");
|
||||||
pNtClose = (PfnNtClose) GetProcAddress(hNtdll, "NtClose");
|
pNtQueryEaFile = (PfnNtQueryEaFile)
|
||||||
pNtSetEaFile = (PfnNtSetEaFile)
|
GetProcAddress(hNtdll, "NtQueryEaFile");
|
||||||
GetProcAddress(hNtdll, "NtSetEaFile");
|
pNtQueryInformationFile = (PfnNtQueryInformationFile)
|
||||||
pNtQueryEaFile = (PfnNtQueryEaFile)
|
GetProcAddress(hNtdll, "NtQueryInformationFile");
|
||||||
GetProcAddress(hNtdll, "NtQueryEaFile");
|
pRtlInitUnicodeString = (PfnRtlInitUnicodeString)
|
||||||
pNtQueryInformationFile = (PfnNtQueryInformationFile)
|
GetProcAddress(hNtdll, "RtlInitUnicodeString");
|
||||||
GetProcAddress(hNtdll, "NtQueryInformationFile");
|
|
||||||
pRtlInitUnicodeString = (PfnRtlInitUnicodeString)
|
|
||||||
GetProcAddress(hNtdll, "RtlInitUnicodeString");
|
|
||||||
}
|
|
||||||
if (pNtOpenFile == NULL
|
|
||||||
|| pNtClose == NULL
|
|
||||||
|| pNtSetEaFile == NULL
|
|
||||||
|| pNtQueryEaFile == NULL
|
|
||||||
|| pNtQueryInformationFile == NULL
|
|
||||||
|| pRtlInitUnicodeString == NULL)
|
|
||||||
loaded = FALSE;
|
|
||||||
else
|
|
||||||
loaded = TRUE;
|
|
||||||
}
|
}
|
||||||
|
if (pNtOpenFile == NULL
|
||||||
|
|| pNtClose == NULL
|
||||||
|
|| pNtSetEaFile == NULL
|
||||||
|
|| pNtQueryEaFile == NULL
|
||||||
|
|| pNtQueryInformationFile == NULL
|
||||||
|
|| pRtlInitUnicodeString == NULL)
|
||||||
|
loaded = FALSE;
|
||||||
|
else
|
||||||
|
loaded = TRUE;
|
||||||
return (BOOL) loaded;
|
return (BOOL) loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8190,11 +8185,11 @@ get_cmd_argsW(char ***argvp)
|
|||||||
void
|
void
|
||||||
free_cmd_argsW(void)
|
free_cmd_argsW(void)
|
||||||
{
|
{
|
||||||
if (ArglistW != NULL)
|
if (ArglistW == NULL)
|
||||||
{
|
return;
|
||||||
GlobalFree(ArglistW);
|
|
||||||
ArglistW = NULL;
|
GlobalFree(ArglistW);
|
||||||
}
|
ArglistW = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -8899,20 +8894,20 @@ resize_console_buf(void)
|
|||||||
COORD coord;
|
COORD coord;
|
||||||
SMALL_RECT newsize;
|
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);
|
|
||||||
|
|
||||||
newsize.Left = 0;
|
coord.X = SRWIDTH(csbi.srWindow);
|
||||||
newsize.Top = 0;
|
coord.Y = SRHEIGHT(csbi.srWindow);
|
||||||
newsize.Right = coord.X - 1;
|
SetConsoleScreenBufferSize(g_hConOut, coord);
|
||||||
newsize.Bottom = coord.Y - 1;
|
|
||||||
SetConsoleWindowInfo(g_hConOut, TRUE, &newsize);
|
|
||||||
|
|
||||||
SetConsoleScreenBufferSize(g_hConOut, coord);
|
newsize.Left = 0;
|
||||||
}
|
newsize.Top = 0;
|
||||||
|
newsize.Right = coord.X - 1;
|
||||||
|
newsize.Bottom = coord.Y - 1;
|
||||||
|
SetConsoleWindowInfo(g_hConOut, TRUE, &newsize);
|
||||||
|
|
||||||
|
SetConsoleScreenBufferSize(g_hConOut, coord);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -8926,14 +8921,14 @@ GetWin32Error(void)
|
|||||||
NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL);
|
NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL);
|
||||||
if (oldmsg != NULL)
|
if (oldmsg != NULL)
|
||||||
LocalFree(oldmsg);
|
LocalFree(oldmsg);
|
||||||
if (msg != NULL)
|
if (msg == NULL)
|
||||||
{
|
return NULL;
|
||||||
// remove trailing \r\n
|
|
||||||
char *pcrlf = strstr(msg, "\r\n");
|
// remove trailing \r\n
|
||||||
if (pcrlf != NULL)
|
char *pcrlf = strstr(msg, "\r\n");
|
||||||
*pcrlf = '\0';
|
if (pcrlf != NULL)
|
||||||
oldmsg = msg;
|
*pcrlf = '\0';
|
||||||
}
|
oldmsg = msg;
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1208,
|
||||||
/**/
|
/**/
|
||||||
1207,
|
1207,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user