Merge upstream

This commit is contained in:
Bjorn Winckler
2008-11-21 20:20:00 +01:00
40 changed files with 400 additions and 183 deletions
+17 -9
View File
@@ -16819,21 +16819,29 @@ if test "x$MACARCH" = "xboth"; then
LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
fi
{ $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5
$as_echo_n "checking for GCC 3 or later... " >&6; }
DEPEND_CFLAGS_FILTER=
if test "$GCC" = yes; then
{ $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5
$as_echo_n "checking for GCC 3 or later... " >&6; }
gccmajor=`echo "$gccversion" | sed -e 's/^\([1-9]\)\..*$/\1/g'`
if test "$gccmajor" -gt "2"; then
DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
fi
fi
if test "$DEPEND_CFLAGS_FILTER" = ""; then
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: yes" >&5
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:$LINENO: checking whether we need -D_FORTIFY_SOURCE=1" >&5
$as_echo_n "checking whether we need -D_FORTIFY_SOURCE=1... " >&6; }
if test "$gccmajor" -gt "3"; then
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=1"
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
fi
+72 -17
View File
@@ -33,7 +33,7 @@ static char_u *buflist_match __ARGS((regprog_T *prog, buf_T *buf));
static char_u *fname_match __ARGS((regprog_T *prog, char_u *name));
#endif
static void buflist_setfpos __ARGS((buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options));
static wininfo_T *find_wininfo __ARGS((buf_T *buf));
static wininfo_T *find_wininfo __ARGS((buf_T *buf, int skip_diff_buffer));
#ifdef UNIX
static buf_T *buflist_findname_stat __ARGS((char_u *ffname, struct stat *st));
static int otherfile_buf __ARGS((buf_T *buf, char_u *ffname, struct stat *stp));
@@ -651,6 +651,9 @@ free_buffer_stuff(buf, free_options)
vim_free(buf->b_start_fenc);
buf->b_start_fenc = NULL;
#endif
#ifdef FEAT_SPELL
ga_clear(&buf->b_langp);
#endif
}
/*
@@ -1094,7 +1097,7 @@ do_buffer(action, start, dir, count, forceit)
#endif
setpcmark();
retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE,
forceit ? ECMD_FORCEIT : 0);
forceit ? ECMD_FORCEIT : 0, curwin);
/*
* do_ecmd() may create a new buffer, then we have to delete
@@ -1241,7 +1244,7 @@ do_buffer(action, start, dir, count, forceit)
* "buf" if one exists */
if ((swb_flags & SWB_USEOPEN) && buf_jump_open_win(buf))
return OK;
/* If 'switchbuf' contians "usetab": jump to first window in any tab
/* If 'switchbuf' contains "usetab": jump to first window in any tab
* page containing "buf" if one exists */
if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf))
return OK;
@@ -1317,7 +1320,7 @@ set_curbuf(buf, action)
setpcmark();
if (!cmdmod.keepalt)
curwin->w_alt_fnum = curbuf->b_fnum; /* remember alternate file */
buflist_altfpos(); /* remember curpos */
buflist_altfpos(curwin); /* remember curpos */
#ifdef FEAT_VISUAL
/* Don't restart Select mode after switching to another buffer. */
@@ -1402,6 +1405,9 @@ enter_buffer(buf)
curwin->w_cursor.coladd = 0;
#endif
curwin->w_set_curswant = TRUE;
#ifdef FEAT_AUTOCMD
curwin->w_topline_was_set = FALSE;
#endif
/* Make sure the buffer is loaded. */
if (curbuf->b_ml.ml_mfp == NULL) /* need to load the file */
@@ -1441,7 +1447,8 @@ enter_buffer(buf)
maketitle();
#endif
#ifdef FEAT_AUTOCMD
if (curwin->w_topline == 1) /* when autocmds didn't change it */
/* when autocmds didn't change it */
if (curwin->w_topline == 1 && !curwin->w_topline_was_set)
#endif
scroll_cursor_halfway(FALSE); /* redisplay at correct position */
@@ -2405,22 +2412,70 @@ buflist_setfpos(buf, win, lnum, col, copy_options)
return;
}
#ifdef FEAT_DIFF
static int wininfo_other_tab_diff __ARGS((wininfo_T *wip));
/*
* Return TRUE when "wip" has 'diff' set and the diff is only for another tab
* page. That's because a diff is local to a tab page.
*/
static int
wininfo_other_tab_diff(wip)
wininfo_T *wip;
{
win_T *wp;
if (wip->wi_opt.wo_diff)
{
for (wp = firstwin; wp != NULL; wp = wp->w_next)
/* return FALSE when it's a window in the current tab page, thus
* the buffer was in diff mode here */
if (wip->wi_win == wp)
return FALSE;
return TRUE;
}
return FALSE;
}
#endif
/*
* Find info for the current window in buffer "buf".
* If not found, return the info for the most recently used window.
* When "skip_diff_buffer" is TRUE avoid windows with 'diff' set that is in
* another tab page.
* Returns NULL when there isn't any info.
*/
/*ARGSUSED*/
static wininfo_T *
find_wininfo(buf)
find_wininfo(buf, skip_diff_buffer)
buf_T *buf;
int skip_diff_buffer;
{
wininfo_T *wip;
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
if (wip->wi_win == curwin)
if (wip->wi_win == curwin
#ifdef FEAT_DIFF
&& (!skip_diff_buffer || !wininfo_other_tab_diff(wip))
#endif
)
break;
if (wip == NULL) /* if no fpos for curwin, use the first in the list */
wip = buf->b_wininfo;
/* If no wininfo for curwin, use the first in the list (that doesn't have
* 'diff' set and is in another tab page). */
if (wip == NULL)
{
#ifdef FEAT_DIFF
if (skip_diff_buffer)
{
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
if (!wininfo_other_tab_diff(wip))
break;
}
else
#endif
wip = buf->b_wininfo;
}
return wip;
}
@@ -2441,7 +2496,7 @@ get_winopts(buf)
clearFolding(curwin);
#endif
wip = find_wininfo(buf);
wip = find_wininfo(buf, TRUE);
if (wip != NULL && wip->wi_optset)
{
copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt);
@@ -2473,7 +2528,7 @@ buflist_findfpos(buf)
wininfo_T *wip;
static pos_T no_position = {1, 0};
wip = find_wininfo(buf);
wip = find_wininfo(buf, FALSE);
if (wip != NULL)
return &(wip->wi_fpos);
else
@@ -2794,14 +2849,14 @@ buflist_slash_adjust()
#endif
/*
* Set alternate cursor position for current window.
* Set alternate cursor position for the current buffer and window "win".
* Also save the local window option values.
*/
void
buflist_altfpos()
buflist_altfpos(win)
win_T *win;
{
buflist_setfpos(curbuf, curwin, curwin->w_cursor.lnum,
curwin->w_cursor.col, TRUE);
buflist_setfpos(curbuf, win, win->w_cursor.lnum, win->w_cursor.col, TRUE);
}
/*
@@ -3974,7 +4029,7 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hltab, t
width = vim_strsize(out);
if (maxwidth > 0 && width > maxwidth)
{
/* Result is too long, must trunctate somewhere. */
/* Result is too long, must truncate somewhere. */
l = 0;
if (itemcnt == 0)
s = out;
@@ -4499,7 +4554,7 @@ do_arg_all(count, forceit, keep_tabs)
ECMD_ONE,
((P_HID(curwin->w_buffer)
|| bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)
+ ECMD_OLDBUF);
+ ECMD_OLDBUF, curwin);
#ifdef FEAT_AUTOCMD
if (use_firstwin)
++autocmd_no_leave;
+13 -6
View File
@@ -3188,18 +3188,25 @@ dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
dnl But only when making dependencies, cproto and lint don't take "-isystem".
dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
dnl the number before the version number.
AC_MSG_CHECKING(for GCC 3 or later)
DEPEND_CFLAGS_FILTER=
if test "$GCC" = yes; then
AC_MSG_CHECKING(for GCC 3 or later)
gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
if test "$gccmajor" -gt "2"; then
DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
if test "$gccmajor" -gt "3"; then
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=1"
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
if test "$DEPEND_CFLAGS_FILTER" = ""; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
fi
AC_SUBST(DEPEND_CFLAGS_FILTER)
+11 -4
View File
@@ -856,6 +856,7 @@ eval_clear()
}
}
hash_clear(&vimvarht);
hash_init(&vimvarht); /* garbage_collect() will access it */
hash_clear(&compat_hashtab);
/* script-local variables */
@@ -18165,14 +18166,17 @@ get_vim_var_list(idx)
}
/*
* Set v:count, v:count1 and v:prevcount.
* Set v:count to "count" and v:count1 to "count1".
* When "set_prevcount" is TRUE first set v:prevcount from v:count.
*/
void
set_vcount(count, count1)
set_vcount(count, count1, set_prevcount)
long count;
long count1;
int set_prevcount;
{
vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr;
if (set_prevcount)
vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr;
vimvars[VV_COUNT].vv_nr = count;
vimvars[VV_COUNT1].vv_nr = count1;
}
@@ -21169,8 +21173,11 @@ call_user_func(fp, argcount, argvars, rettv, firstline, lastline, selfdict)
init_var_dict(&fc.l_avars, &fc.l_avars_var);
add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "0",
(varnumber_T)(argcount - fp->uf_args.ga_len));
/* Use "name" to avoid a warning from some compiler that checks the
* destination size. */
v = &fc.fixvar[fixvar_idx++].var;
STRCPY(v->di_key, "000");
name = v->di_key;
STRCPY(name, "000");
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
hash_add(&fc.l_avars.dv_hashtab, DI2HIKEY(v));
v->di_tv.v_type = VAR_LIST;
+17 -5
View File
@@ -3052,7 +3052,8 @@ getfile(fnum, ffname, sfname, setpm, lnum, forceit)
retval = 0; /* it's in the same file */
}
else if (do_ecmd(fnum, ffname, sfname, NULL, lnum,
(P_HID(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0)) == OK)
(P_HID(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0),
curwin) == OK)
retval = -1; /* opened another file */
else
retval = 1; /* error encountered */
@@ -3085,17 +3086,21 @@ theend:
* ECMD_OLDBUF: use existing buffer if it exists
* ECMD_FORCEIT: ! used for Ex command
* ECMD_ADDBUF: don't edit, just add to buffer list
* oldwin: Should be "curwin" when editing a new buffer in the current
* window, NULL when splitting the window first. When not NULL info
* of the previous buffer for "oldwin" is stored.
*
* return FAIL for failure, OK otherwise
*/
int
do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
int fnum;
char_u *ffname;
char_u *sfname;
exarg_T *eap; /* can be NULL! */
linenr_T newlnum;
int flags;
win_T *oldwin;
{
int other_file; /* TRUE if editing another file */
int oldbuf; /* TRUE if using existing buffer */
@@ -3267,7 +3272,8 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
{
if (!cmdmod.keepalt)
curwin->w_alt_fnum = curbuf->b_fnum;
buflist_altfpos();
if (oldwin != NULL)
buflist_altfpos(oldwin);
}
if (fnum)
@@ -3371,7 +3377,7 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
/* close the link to the current buffer */
u_sync(FALSE);
close_buffer(curwin, curbuf,
close_buffer(oldwin, curbuf,
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD);
#ifdef FEAT_AUTOCMD
@@ -5609,7 +5615,13 @@ ex_help(eap)
*/
alt_fnum = curbuf->b_fnum;
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
ECMD_HIDE + ECMD_SET_HELP);
ECMD_HIDE + ECMD_SET_HELP,
#ifdef FEAT_WINDOWS
NULL /* buffer is still open, don't store info */
#else
curwin
#endif
);
if (!cmdmod.keepalt)
curwin->w_alt_fnum = alt_fnum;
empty_fnum = curbuf->b_fnum;
+2 -2
View File
@@ -2205,8 +2205,8 @@ do_argfile(eap, argn)
* argument index. */
if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
eap, ECMD_LAST,
(P_HID(curwin->w_buffer) ? ECMD_HIDE : 0) +
(eap->forceit ? ECMD_FORCEIT : 0)) == FAIL)
(P_HID(curwin->w_buffer) ? ECMD_HIDE : 0)
+ (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
curwin->w_arg_idx = old_arg_idx;
/* like Vi: set the mark where the cursor is in the file. */
else if (eap->cmdidx != CMD_argdo)
+3 -2
View File
@@ -7507,7 +7507,8 @@ do_exedit(eap, old_curwin)
/* ":new" or ":tabnew" without argument: edit an new empty buffer */
setpcmark();
(void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE,
ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0));
ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),
old_curwin == NULL ? curwin : NULL);
}
else if ((eap->cmdidx != CMD_split
#ifdef FEAT_VERTSPLIT
@@ -7544,7 +7545,7 @@ do_exedit(eap, old_curwin)
#ifdef FEAT_LISTCMDS
+ (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 )
#endif
) == FAIL)
, old_curwin == NULL ? curwin : NULL) == FAIL)
{
/* Editing the file failed. If the window was split, close it. */
#ifdef FEAT_WINDOWS
+1 -1
View File
@@ -6054,7 +6054,7 @@ ex_window()
cmdwin_type = '-';
/* Create the command-line buffer empty. */
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE);
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
(void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE);
set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
+6 -7
View File
@@ -932,7 +932,10 @@ retry:
else
{
if (eap != NULL && eap->force_ff != 0)
{
fileformat = get_fileformat_force(curbuf, eap);
try_unix = try_dos = try_mac = FALSE;
}
else if (curbuf->b_p_bin)
fileformat = EOL_UNIX; /* binary: use Unix format */
else if (*p_ffs == NUL)
@@ -2341,11 +2344,6 @@ failed:
STRCAT(IObuff, _("[CR missing]"));
c = TRUE;
}
if (ff_error == EOL_MAC)
{
STRCAT(IObuff, _("[NL found]"));
c = TRUE;
}
if (split)
{
STRCAT(IObuff, _("[long lines split]"));
@@ -5554,9 +5552,10 @@ check_for_bom(p, size, lenp, flags)
name = "ucs-4le"; /* FF FE 00 00 */
len = 4;
}
else if (flags == FIO_ALL || flags == (FIO_UCS2 | FIO_ENDIAN_L))
else if (flags == (FIO_UCS2 | FIO_ENDIAN_L))
name = "ucs-2le"; /* FF FE */
else if (flags == (FIO_UTF16 | FIO_ENDIAN_L))
else if (flags == FIO_ALL || flags == (FIO_UTF16 | FIO_ENDIAN_L))
/* utf-16le is preferred, it also works for ucs-2le text */
name = "utf-16le"; /* FF FE */
}
else if (p[0] == 0xfe && p[1] == 0xff
+2 -2
View File
@@ -695,7 +695,7 @@ gui_mch_set_winpos(int x, int y)
gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction)
int width; /* In OS units */
int height;
int min_width; /* Smallest permissable window size (ignored) */
int min_width; /* Smallest permissible window size (ignored) */
int min_height;
int base_width; /* Space for scroll bars, etc */
int base_height;
@@ -863,7 +863,7 @@ zap_load_file(name, style)
if (strncmp(file, "ZapFont\015", 8) == 0)
return file; /* Loaded OK! */
free(file);
vim_free(file);
return NULL; /* Not a valid font file */
}
+5 -5
View File
@@ -992,7 +992,7 @@ _WndProc(
SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
0, 500);
tt_text = enc_to_ucs2(str, NULL);
tt_text = enc_to_utf16(str, NULL);
lpdi->lpszText = tt_text;
/* can't show tooltip if failed */
}
@@ -1935,7 +1935,7 @@ GetResultStr(HWND hwnd, int GCS, int *lenp)
if (buf == NULL)
return NULL;
convbuf = ucs2_to_enc(buf, lenp);
convbuf = utf16_to_enc(buf, lenp);
pImmReleaseContext(hwnd, hIMC);
vim_free(buf);
return convbuf;
@@ -2566,7 +2566,7 @@ gui_mch_add_menu(
{
/* 'encoding' differs from active codepage: convert menu name
* and use wide function */
wn = enc_to_ucs2(menu->name, NULL);
wn = enc_to_utf16(menu->name, NULL);
if (wn != NULL)
{
MENUITEMINFOW infow;
@@ -2728,7 +2728,7 @@ gui_mch_add_menu_item(
{
/* 'encoding' differs from active codepage: convert menu item name
* and use wide function */
wn = enc_to_ucs2(menu->name, NULL);
wn = enc_to_utf16(menu->name, NULL);
if (wn != NULL)
{
n = InsertMenuW(parent->submenu_id, (UINT)idx,
@@ -3570,7 +3570,7 @@ nCopyAnsiToWideChar(
if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
{
/* Not a codepage, use our own conversion function. */
wn = enc_to_ucs2(lpAnsiIn, NULL);
wn = enc_to_utf16(lpAnsiIn, NULL);
if (wn != NULL)
{
wcscpy(lpWCStr, wn);
+20 -17
View File
@@ -547,7 +547,7 @@ char_to_string(int ch, char_u *string, int slen, int had_alt)
else
{
len = 1;
ws = ucs2_to_enc(wstring, &len);
ws = utf16_to_enc(wstring, &len);
if (ws == NULL)
len = 0;
else
@@ -2128,7 +2128,7 @@ GetTextWidthEnc(HDC hdc, char_u *str, int len)
{
/* 'encoding' differs from active codepage: convert text and use wide
* function */
wstr = enc_to_ucs2(str, &wlen);
wstr = enc_to_utf16(str, &wlen);
if (wstr != NULL)
{
n = GetTextExtentPointW(hdc, wstr, wlen, &size);
@@ -2252,7 +2252,7 @@ add_tabline_popup_menu_entry(HMENU pmenu, UINT item_id, char_u *item_text)
{
/* 'encoding' differs from active codepage: convert menu name
* and use wide function */
wn = enc_to_ucs2(item_text, NULL);
wn = enc_to_utf16(item_text, NULL);
if (wn != NULL)
{
MENUITEMINFOW infow;
@@ -2422,7 +2422,7 @@ gui_mch_update_tabline(void)
if (use_unicode)
{
/* Need to go through Unicode. */
wstr = enc_to_ucs2(NameBuff, NULL);
wstr = enc_to_utf16(NameBuff, NULL);
if (wstr != NULL)
{
TCITEMW tiw;
@@ -2521,8 +2521,8 @@ set_window_title(HWND hwnd, char *title)
WCHAR *wbuf;
int n;
/* Convert the title from 'encoding' to ucs2. */
wbuf = (WCHAR *)enc_to_ucs2((char_u *)title, NULL);
/* Convert the title from 'encoding' to UTF-16. */
wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL);
if (wbuf != NULL)
{
n = SetWindowTextW(hwnd, wbuf);
@@ -3222,7 +3222,7 @@ gui_mch_browseW(
char_u *initdir,
char_u *filter)
{
/* We always use the wide function. This means enc_to_ucs2() must work,
/* We always use the wide function. This means enc_to_utf16() must work,
* otherwise it fails miserably! */
OPENFILENAMEW fileStruct;
WCHAR fileBuf[MAXPATHL];
@@ -3238,7 +3238,7 @@ gui_mch_browseW(
fileBuf[0] = NUL;
else
{
wp = enc_to_ucs2(dflt, NULL);
wp = enc_to_utf16(dflt, NULL);
if (wp == NULL)
fileBuf[0] = NUL;
else
@@ -3263,11 +3263,11 @@ gui_mch_browseW(
#endif
if (title != NULL)
titlep = enc_to_ucs2(title, NULL);
titlep = enc_to_utf16(title, NULL);
fileStruct.lpstrTitle = titlep;
if (ext != NULL)
extp = enc_to_ucs2(ext, NULL);
extp = enc_to_utf16(ext, NULL);
fileStruct.lpstrDefExt = extp;
fileStruct.lpstrFile = fileBuf;
@@ -3278,7 +3278,7 @@ gui_mch_browseW(
if (initdir != NULL && *initdir != NUL)
{
/* Must have backslashes here, no matter what 'shellslash' says */
initdirp = enc_to_ucs2(initdir, NULL);
initdirp = enc_to_utf16(initdir, NULL);
if (initdirp != NULL)
{
for (wp = initdirp; *wp != NUL; ++wp)
@@ -3318,7 +3318,7 @@ gui_mch_browseW(
vim_free(extp);
/* Convert from UCS2 to 'encoding'. */
p = ucs2_to_enc(fileBuf, NULL);
p = utf16_to_enc(fileBuf, NULL);
if (p != NULL)
/* when out of memory we get garbage for non-ASCII chars */
STRCPY(fileBuf, p);
@@ -3335,7 +3335,7 @@ gui_mch_browseW(
/*
* Convert the string s to the proper format for a filter string by replacing
* the \t and \n delimeters with \0.
* the \t and \n delimiters with \0.
* Returns the converted string in allocated memory.
*
* Keep in sync with convert_filterW() above!
@@ -3518,7 +3518,7 @@ _OnDropFiles(
{
#ifdef FEAT_MBYTE
if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
fnames[i] = ucs2_to_enc(wszFile, NULL);
fnames[i] = utf16_to_enc(wszFile, NULL);
else
#endif
{
@@ -3674,7 +3674,8 @@ _OnScroll(
* Use "prog" as the name of the program and "cmdline" as the arguments.
* Copy the arguments to allocated memory.
* Return the number of arguments (including program name).
* Return pointers to the arguments in "argvp".
* Return pointers to the arguments in "argvp". Memory is allocated with
* malloc(), use free() instead of vim_free().
* Return pointer to buffer in "tofree".
* Returns zero when out of memory.
*/
@@ -3692,6 +3693,8 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
char **argv = NULL;
int round;
*tofree = NULL;
#ifdef FEAT_MBYTE
/* Try using the Unicode version first, it takes care of conversion when
* 'encoding' is changed. */
@@ -3802,15 +3805,15 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
argv = (char **)malloc((argc + 1) * sizeof(char *));
if (argv == NULL )
{
vim_free(newcmdline);
free(newcmdline);
return 0; /* malloc error */
}
pnew = newcmdline;
*tofree = newcmdline;
}
}
done:
argv[argc] = NULL; /* NULL-terminated list */
*argvp = argv;
return argc;
+1 -1
View File
@@ -2450,7 +2450,7 @@ find_closest_color(colormap, colorPtr)
*colorPtr = colortable[closest];
}
free(colortable);
vim_free(colortable);
return OK;
}
+8 -1
View File
@@ -531,6 +531,12 @@ Python_Init(void)
if (PythonMod_Init())
goto fail;
/* Remove the element from sys.path that was added because of our
* argv[0] value in PythonMod_Init(). Previously we used an empty
* string, but dependinding on the OS we then get an empty entry or
* the current directory in sys.path. */
PyRun_SimpleString("import sys; sys.path = filter(lambda x: x != '/must>not&exist', sys.path)");
/* the first python thread is vim's, release the lock */
Python_SaveThread();
@@ -2345,7 +2351,8 @@ PythonMod_Init(void)
{
PyObject *mod;
PyObject *dict;
static char *(argv[2]) = {"", NULL};
/* The special value is removed from sys.path in Python_Init(). */
static char *(argv[2]) = {"/must>not&exist/foo", NULL};
/* Fixups... */
BufferType.ob_type = &PyType_Type;
+2 -1
View File
@@ -1114,7 +1114,8 @@ vi_open_file(fname)
char *fname;
{
++no_wait_return;
do_ecmd(0, (char_u *)fname, NULL, NULL, ECMD_ONE, ECMD_HIDE+ECMD_OLDBUF);
do_ecmd(0, (char_u *)fname, NULL, NULL, ECMD_ONE, ECMD_HIDE+ECMD_OLDBUF,
curwin);
curbuf->b_sniff = TRUE;
--no_wait_return; /* [ex_docmd.c] */
}
+3 -3
View File
@@ -737,7 +737,7 @@ ServerReplyFind(w, op)
+ serverReply.ga_len;
e.id = w;
ga_init2(&e.strings, 1, 100);
memcpy(p, &e, sizeof(e));
mch_memmove(p, &e, sizeof(e));
serverReply.ga_len++;
}
}
@@ -1019,7 +1019,7 @@ LookupName(dpy, name, delete, loose)
p++;
count = numItems - (p - regProp);
if (count > 0)
memcpy(entry, p, count);
mch_memmove(entry, p, count);
XChangeProperty(dpy, RootWindow(dpy, 0), registryProperty, XA_STRING,
8, PropModeReplace, regProp,
(int)(numItems - (p - entry)));
@@ -1073,7 +1073,7 @@ DeleteAnyLingerer(dpy, win)
p++;
lastHalf = numItems - (p - regProp);
if (lastHalf > 0)
memcpy(entry, p, lastHalf);
mch_memmove(entry, p, lastHalf);
numItems = (entry - regProp) + lastHalf;
p = entry;
continue;
+11 -2
View File
@@ -1592,7 +1592,8 @@ parse_command_name(parmp)
early_arg_scan(parmp)
mparm_T *parmp;
{
#if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER)
#if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER) \
|| !defined(FEAT_NETBEANS_INTG)
int argc = parmp->argc;
char **argv = parmp->argv;
int i;
@@ -1664,6 +1665,14 @@ early_arg_scan(parmp)
else if (STRICMP(argv[i], "--echo-wid") == 0)
echo_wid_arg = TRUE;
# endif
# ifndef FEAT_NETBEANS_INTG
else if (strncmp(argv[i], "-nb", (size_t)3) == 0)
{
mch_errmsg(_("'-nb' cannot be used: not enabled at compile time\n"));
mch_exit(2);
}
# endif
}
#endif
}
@@ -2670,7 +2679,7 @@ edit_buffers(parmp)
# endif
(void)do_ecmd(0, arg_idx < GARGCOUNT
? alist_name(&GARGLIST[arg_idx]) : NULL,
NULL, NULL, ECMD_LASTL, ECMD_HIDE);
NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin);
# ifdef HAS_SWAP_EXISTS_ACTION
if (swap_exists_did_quit)
{
+6 -6
View File
@@ -3131,7 +3131,7 @@ enc_locale()
else
s = p + 1;
}
for (i = 0; s[i] != NUL && s + i < buf + sizeof(buf) - 1; ++i)
for (i = 0; s[i] != NUL && i < sizeof(buf) - 1; ++i)
{
if (s[i] == '_' || s[i] == '-')
buf[i] = '-';
@@ -5384,7 +5384,7 @@ preedit_draw_cbproc(XIC xic, XPointer client_data, XPointer call_data)
draw_feedback = (char *)alloc(draw_data->chg_first
+ text->length);
else
draw_feedback = realloc(draw_feedback,
draw_feedback = vim_realloc(draw_feedback,
draw_data->chg_first + text->length);
if (draw_feedback != NULL)
{
@@ -6101,7 +6101,7 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp)
/* 1. codepage/UTF-8 -> ucs-2. */
if (vcp->vc_cpfrom == 0)
tmp_len = utf8_to_ucs2(ptr, len, NULL, NULL);
tmp_len = utf8_to_utf16(ptr, len, NULL, NULL);
else
tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0,
ptr, len, 0, 0);
@@ -6109,13 +6109,13 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp)
if (tmp == NULL)
break;
if (vcp->vc_cpfrom == 0)
utf8_to_ucs2(ptr, len, tmp, unconvlenp);
utf8_to_utf16(ptr, len, tmp, unconvlenp);
else
MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len);
/* 2. ucs-2 -> codepage/UTF-8. */
if (vcp->vc_cpto == 0)
retlen = ucs2_to_utf8(tmp, tmp_len, NULL);
retlen = utf16_to_utf8(tmp, tmp_len, NULL);
else
retlen = WideCharToMultiByte(vcp->vc_cpto, 0,
tmp, tmp_len, 0, 0, 0, 0);
@@ -6123,7 +6123,7 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp)
if (retval != NULL)
{
if (vcp->vc_cpto == 0)
ucs2_to_utf8(tmp, tmp_len, retval);
utf16_to_utf8(tmp, tmp_len, retval);
else
WideCharToMultiByte(vcp->vc_cpto, 0,
tmp, tmp_len, retval, retlen, 0, 0);
+3 -3
View File
@@ -8728,7 +8728,7 @@ dos_expandpath(
/* The active codepage differs from 'encoding'. Attempt using the
* wide function. If it fails because it is not implemented fall back
* to the non-wide version (for Windows 98) */
wn = enc_to_ucs2(buf, NULL);
wn = enc_to_utf16(buf, NULL);
if (wn != NULL)
{
hFind = FindFirstFileW(wn, &wfb);
@@ -8756,7 +8756,7 @@ dos_expandpath(
#ifdef WIN3264
# ifdef FEAT_MBYTE
if (wn != NULL)
p = ucs2_to_enc(wfb.cFileName, NULL); /* p is allocated here */
p = utf16_to_enc(wfb.cFileName, NULL); /* p is allocated here */
else
# endif
p = (char_u *)fb.cFileName;
@@ -8830,7 +8830,7 @@ dos_expandpath(
if (wn != NULL)
{
vim_free(wn);
wn = enc_to_ucs2(buf, NULL);
wn = enc_to_utf16(buf, NULL);
if (wn != NULL)
hFind = FindFirstFileW(wn, &wfb);
}
+1 -1
View File
@@ -873,7 +873,7 @@ lalloc(size, message)
/* 3. check for available memory: call mch_avail_mem() */
if (mch_avail_mem(TRUE) < KEEP_ROOM && !releasing)
{
vim_free((char *)p); /* System is low... no go! */
free((char *)p); /* System is low... no go! */
p = NULL;
}
else
+14 -5
View File
@@ -280,18 +280,20 @@ update_topline()
if (curwin->w_botline <= curbuf->b_ml.ml_line_count)
{
if (curwin->w_cursor.lnum < curwin->w_botline
&& ((long)curwin->w_cursor.lnum
if (curwin->w_cursor.lnum < curwin->w_botline)
{
if (((long)curwin->w_cursor.lnum
>= (long)curwin->w_botline - p_so
#ifdef FEAT_FOLDING
|| hasAnyFolding(curwin)
#endif
))
{
{
lineoff_T loff;
/* Cursor is above botline, check if there are 'scrolloff'
* window lines below the cursor. If not, need to scroll. */
/* Cursor is (a few lines) above botline, check if there are
* 'scrolloff' window lines below the cursor. If not, need to
* scroll. */
n = curwin->w_empty_rows;
loff.lnum = curwin->w_cursor.lnum;
#ifdef FEAT_FOLDING
@@ -317,6 +319,10 @@ update_topline()
if (n >= p_so)
/* sufficient context, no need to scroll */
check_botline = FALSE;
}
else
/* sufficient context, no need to scroll */
check_botline = FALSE;
}
if (check_botline)
{
@@ -509,6 +515,9 @@ set_topline(wp, lnum)
/* Approximate the value of w_botline */
wp->w_botline += lnum - wp->w_topline;
wp->w_topline = lnum;
#ifdef FEAT_AUTOCMD
wp->w_topline_was_set = TRUE;
#endif
#ifdef FEAT_DIFF
wp->w_topfill = 0;
#endif
+3 -3
View File
@@ -1795,7 +1795,7 @@ nb_do_cmd(
buf->displayname = NULL;
netbeansReadFile = 0; /* don't try to open disk file */
do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF);
do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF, curwin);
netbeansReadFile = 1;
buf->bufp = curbuf;
maketitle();
@@ -1960,7 +1960,7 @@ nb_do_cmd(
netbeansReadFile = 0; /* don't try to open disk file */
do_ecmd(0, (char_u *)buf->displayname, 0, 0, ECMD_ONE,
ECMD_HIDE + ECMD_OLDBUF);
ECMD_HIDE + ECMD_OLDBUF, curwin);
netbeansReadFile = 1;
buf->bufp = curbuf;
maketitle();
@@ -1979,7 +1979,7 @@ nb_do_cmd(
vim_free(buf->displayname);
buf->displayname = nb_unquote(args, NULL);
do_ecmd(0, (char_u *)buf->displayname, NULL, NULL, ECMD_ONE,
ECMD_HIDE + ECMD_OLDBUF);
ECMD_HIDE + ECMD_OLDBUF, curwin);
buf->bufp = curbuf;
buf->initDone = TRUE;
doupdate = 1;
+19 -3
View File
@@ -580,6 +580,9 @@ normal_cmd(oap, toplevel)
static int old_mapped_len = 0;
#endif
int idx;
#ifdef FEAT_EVAL
int set_prevcount = FALSE;
#endif
vim_memset(&ca, 0, sizeof(ca)); /* also resets ca.retval */
ca.oap = oap;
@@ -615,7 +618,12 @@ normal_cmd(oap, toplevel)
/* When not finishing an operator and no register name typed, reset the
* count. */
if (!finish_op && !oap->regname)
{
ca.opcount = 0;
#ifdef FEAT_EVAL
set_prevcount = TRUE;
#endif
}
#ifdef FEAT_AUTOCMD
/* Restore counts from before receiving K_CURSORHOLD. This means after
@@ -719,7 +727,15 @@ getcount:
* command, so that v:count can be used in an expression mapping
* right after the count. */
if (toplevel && stuff_empty())
set_vcount(ca.count0, ca.count0 == 0 ? 1 : ca.count0);
{
long count = ca.count0;
/* multiply with ca.opcount the same way as below */
if (ca.opcount != 0)
count = ca.opcount * (count == 0 ? 1 : count);
set_vcount(count, count == 0 ? 1 : count, set_prevcount);
set_prevcount = FALSE; /* only set v:prevcount once */
}
#endif
if (ctrl_w)
{
@@ -806,7 +822,7 @@ getcount:
* Only set v:count when called from main() and not a stuffed command.
*/
if (toplevel && stuff_empty())
set_vcount(ca.count0, ca.count1);
set_vcount(ca.count0, ca.count1, set_prevcount);
#endif
/*
@@ -6069,7 +6085,7 @@ nv_gotofile(cap)
autowrite(curbuf, FALSE);
setpcmark();
(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
P_HID(curbuf) ? ECMD_HIDE : 0);
P_HID(curbuf) ? ECMD_HIDE : 0, curwin);
if (cap->nchar == 'F' && lnum >= 0)
{
curwin->w_cursor.lnum = lnum;
+57 -32
View File
@@ -309,7 +309,7 @@ mch_settitle(
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
/* Convert the title from 'encoding' to the active codepage. */
WCHAR *wp = enc_to_ucs2(title, NULL);
WCHAR *wp = enc_to_utf16(title, NULL);
int n;
if (wp != NULL)
@@ -406,10 +406,10 @@ mch_FullName(
* - invoke _wfullpath()
* - convert the result from UCS2 to 'encoding'.
*/
wname = enc_to_ucs2(fname, NULL);
wname = enc_to_utf16(fname, NULL);
if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL)
{
cname = ucs2_to_enc((short_u *)wbuf, NULL);
cname = utf16_to_enc((short_u *)wbuf, NULL);
if (cname != NULL)
{
vim_strncpy(buf, cname, len - 1);
@@ -507,7 +507,7 @@ vim_stat(const char *name, struct stat *stp)
# endif
)
{
WCHAR *wp = enc_to_ucs2(buf, NULL);
WCHAR *wp = enc_to_utf16(buf, NULL);
int n;
if (wp != NULL)
@@ -668,7 +668,7 @@ mch_chdir(char *path)
#ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
WCHAR *p = enc_to_ucs2(path, NULL);
WCHAR *p = enc_to_utf16(path, NULL);
int n;
if (p != NULL)
@@ -891,19 +891,20 @@ mch_libcall(
#if defined(FEAT_MBYTE) || defined(PROTO)
/*
* Convert an UTF-8 string to UCS-2.
* Convert an UTF-8 string to UTF-16.
* "instr[inlen]" is the input. "inlen" is in bytes.
* When "outstr" is NULL only return the number of UCS-2 words produced.
* When "outstr" is NULL only return the number of UTF-16 words produced.
* Otherwise "outstr" must be a buffer of sufficient size.
* Returns the number of UCS-2 words produced.
* Returns the number of UTF-16 words produced.
*/
int
utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
utf8_to_utf16(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
{
int outlen = 0;
char_u *p = instr;
int todo = inlen;
int l;
int ch;
while (todo > 0)
{
@@ -917,8 +918,19 @@ utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
break;
}
if (outstr != NULL)
*outstr++ = utf_ptr2char(p);
ch = utf_ptr2char(p);
if (ch >= 0x10000)
{
/* non-BMP character, encoding with surrogate pairs */
++outlen;
if (outstr != NULL)
{
*outstr++ = (0xD800 - (0x10000 >> 10)) + (ch >> 10);
*outstr++ = 0xDC00 | (ch & 0x3FF);
}
}
else if (outstr != NULL)
*outstr++ = ch;
++outlen;
p += l;
todo -= l;
@@ -928,29 +940,42 @@ utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
}
/*
* Convert an UCS-2 string to UTF-8.
* The input is "instr[inlen]" with "inlen" in number of ucs-2 words.
* Convert an UTF-16 string to UTF-8.
* The input is "instr[inlen]" with "inlen" in number of UTF-16 words.
* When "outstr" is NULL only return the required number of bytes.
* Otherwise "outstr" must be a buffer of sufficient size.
* Return the number of bytes produced.
*/
int
ucs2_to_utf8(short_u *instr, int inlen, char_u *outstr)
utf16_to_utf8(short_u *instr, int inlen, char_u *outstr)
{
int outlen = 0;
int todo = inlen;
short_u *p = instr;
int l;
int ch, ch2;
while (todo > 0)
{
ch = *p;
if (ch >= 0xD800 && ch <= 0xDBFF && todo > 1)
{
/* surrogate pairs handling */
ch2 = p[1];
if (ch2 >= 0xDC00 && ch2 <= 0xDFFF)
{
ch = ((ch - 0xD800) << 10) + (ch2 & 0x3FF) + 0x10000;
++p;
--todo;
}
}
if (outstr != NULL)
{
l = utf_char2bytes(*p, outstr);
l = utf_char2bytes(ch, outstr);
outstr += l;
}
else
l = utf_char2len(*p);
l = utf_char2len(ch);
++p;
outlen += l;
--todo;
@@ -1079,14 +1104,14 @@ crnl_to_nl(const char_u *str, int *size)
*/
/*
* Convert "str" from 'encoding' to UCS-2.
* Convert "str" from 'encoding' to UTF-16.
* Input in "str" with length "*lenp". When "lenp" is NULL, use strlen().
* Output is returned as an allocated string. "*lenp" is set to the length of
* the result. A trailing NUL is always added.
* Returns NULL when out of memory.
*/
short_u *
enc_to_ucs2(char_u *str, int *lenp)
enc_to_utf16(char_u *str, int *lenp)
{
vimconv_T conv;
WCHAR *ret;
@@ -1102,7 +1127,7 @@ enc_to_ucs2(char_u *str, int *lenp)
if (enc_codepage > 0)
{
/* We can do any CP### -> UCS-2 in one pass, and we can do it
/* We can do any CP### -> UTF-16 in one pass, and we can do it
* without iconv() (convert_* may need iconv). */
MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
}
@@ -1123,11 +1148,11 @@ enc_to_ucs2(char_u *str, int *lenp)
}
convert_setup(&conv, NULL, NULL);
length = utf8_to_ucs2(str, *lenp, NULL, NULL);
length = utf8_to_utf16(str, *lenp, NULL, NULL);
ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
if (ret != NULL)
{
utf8_to_ucs2(str, *lenp, (short_u *)ret, NULL);
utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
ret[length] = 0;
}
@@ -1139,7 +1164,7 @@ enc_to_ucs2(char_u *str, int *lenp)
}
/*
* Convert an UCS-2 string to 'encoding'.
* Convert an UTF-16 string to 'encoding'.
* Input in "str" with length (counted in wide characters) "*lenp". When
* "lenp" is NULL, use wcslen().
* Output is returned as an allocated string. If "*lenp" is not NULL it is
@@ -1147,7 +1172,7 @@ enc_to_ucs2(char_u *str, int *lenp)
* Returns NULL when out of memory.
*/
char_u *
ucs2_to_enc(short_u *str, int *lenp)
utf16_to_enc(short_u *str, int *lenp)
{
vimconv_T conv;
char_u *utf8_str = NULL, *enc_str = NULL;
@@ -1161,7 +1186,7 @@ ucs2_to_enc(short_u *str, int *lenp)
if (enc_codepage > 0)
{
/* We can do any UCS-2 -> CP### in one pass. */
/* We can do any UTF-16 -> CP### in one pass. */
int length;
WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
@@ -1171,10 +1196,10 @@ ucs2_to_enc(short_u *str, int *lenp)
}
/* Avoid allocating zero bytes, it generates an error message. */
utf8_str = alloc(ucs2_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
if (utf8_str != NULL)
{
*lenp = ucs2_to_utf8(str, *lenp, utf8_str);
*lenp = utf16_to_utf8(str, *lenp, utf8_str);
/* We might be called before we have p_enc set up. */
conv.vc_type = CONV_NONE;
@@ -1308,7 +1333,7 @@ clip_mch_request_selection(VimClipboard *cbd)
if (hMemWstr[str_size] == NUL)
break;
}
to_free = str = ucs2_to_enc((short_u *)hMemWstr, &str_size);
to_free = str = utf16_to_enc((short_u *)hMemWstr, &str_size);
GlobalUnlock(hMemW);
}
}
@@ -1340,7 +1365,7 @@ clip_mch_request_selection(VimClipboard *cbd)
# if defined(FEAT_MBYTE) && defined(WIN3264)
/* The text is in the active codepage. Convert to 'encoding',
* going through UCS-2. */
* going through UTF-16. */
acp_to_enc(str, str_size, &to_free, &maxlen);
if (to_free != NULL)
{
@@ -1404,7 +1429,7 @@ acp_to_enc(str, str_size, out, outlen)
if (widestr != NULL)
{
++*outlen; /* Include the 0 after the string */
*out = ucs2_to_enc((short_u *)widestr, outlen);
*out = utf16_to_enc((short_u *)widestr, outlen);
vim_free(widestr);
}
}
@@ -1466,9 +1491,9 @@ clip_mch_set_selection(VimClipboard *cbd)
WCHAR *out;
int len = metadata.txtlen;
/* Convert the text to UCS-2. This is put on the clipboard as
/* Convert the text to UTF-16. This is put on the clipboard as
* CF_UNICODETEXT. */
out = (WCHAR *)enc_to_ucs2(str, &len);
out = (WCHAR *)enc_to_utf16(str, &len);
if (out != NULL)
{
WCHAR *lpszMemW;
@@ -1488,7 +1513,7 @@ clip_mch_set_selection(VimClipboard *cbd)
WideCharToMultiByte(GetACP(), 0, out, len,
str, metadata.txtlen, 0, 0);
/* Allocate memory for the UCS-2 text, add one NUL word to
/* Allocate memory for the UTF-16 text, add one NUL word to
* terminate the string. */
hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
(len + 1) * sizeof(WCHAR));
+5 -3
View File
@@ -2907,7 +2907,7 @@ mch_early_init()
* Ignore any errors.
*/
#if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
signal_stack = malloc(SIGSTKSZ);
signal_stack = (char *)alloc(SIGSTKSZ);
init_signal_stack();
#endif
}
@@ -2938,7 +2938,8 @@ mch_free_mem()
}
# endif
# endif
# ifdef FEAT_X11
/* Don't close the display for GTK 1, it is done in exit(). */
# if defined(FEAT_X11) && (!defined(FEAT_GUI_GTK) || defined(HAVE_GTK2))
if (x11_display != NULL
# ifdef FEAT_XCLIPBOARD
&& x11_display != xterm_dpy
@@ -6816,7 +6817,8 @@ xsmp_close()
if (xsmp_icefd != -1)
{
SmcCloseConnection(xsmp.smcconn, 0, NULL);
vim_free(xsmp.clientid);
if (xsmp.clientid != NULL)
free(xsmp.clientid);
xsmp.clientid = NULL;
xsmp_icefd = -1;
}
+6 -6
View File
@@ -228,7 +228,7 @@ mch_getenv(char_u *lognam)
else if ((sbuf = getenv((char *)lognam)))
{
lengte = strlen(sbuf) + 1;
cp = (char_u *)malloc((size_t)lengte);
cp = (char_u *)alloc((size_t)lengte);
if (cp)
strcpy((char *)cp, sbuf);
return cp;
@@ -381,7 +381,7 @@ vms_wproc(char *name, int val)
if (--vms_match_free == 0) {
/* add more space to store matches */
vms_match_alloced += EXPL_ALLOC_INC;
vms_fmatch = (char_u **)realloc(vms_fmatch,
vms_fmatch = (char_u **)vim_realloc(vms_fmatch,
sizeof(char **) * vms_match_alloced);
if (!vms_fmatch)
return 0;
@@ -460,7 +460,7 @@ mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, i
if (--files_free < 1)
{
files_alloced += EXPL_ALLOC_INC;
*file = (char_u **)realloc(*file,
*file = (char_u **)vim_realloc(*file,
sizeof(char_u **) * files_alloced);
if (*file == NULL)
{
@@ -614,14 +614,14 @@ vms_fixfilename(void *instring)
{
buflen = len + 128;
if (buf)
buf = (char *)realloc(buf, buflen);
buf = (char *)vim_realloc(buf, buflen);
else
buf = (char *)calloc(buflen, sizeof(char));
buf = (char *)alloc(buflen * sizeof(char));
}
#ifdef DEBUG
char *tmpbuf = NULL;
tmpbuf = (char *)calloc(buflen, sizeof(char));
tmpbuf = (char *)alloc(buflen * sizeof(char));
strcpy(tmpbuf, instring);
#endif
+2 -1
View File
@@ -129,7 +129,8 @@ WinMain(
errout:
#endif
free(argv);
free(tofree);
if (tofree != NULL)
free(tofree);
#ifdef FEAT_MBYTE
free_cmd_argsW();
#endif
+2 -1
View File
@@ -121,7 +121,8 @@ WinMain(
pmain(argc, argv);
free(argv);
free(tofree);
if (tofree != NULL)
free(tofree);
return 0;
}
+18 -18
View File
@@ -1587,7 +1587,7 @@ executable_exists(char *name)
#ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
WCHAR *p = enc_to_ucs2(name, NULL);
WCHAR *p = enc_to_utf16(name, NULL);
WCHAR fnamew[_MAX_PATH];
WCHAR *dumw;
long n;
@@ -2440,7 +2440,7 @@ mch_dirname(
if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
{
char_u *p = ucs2_to_enc(wbuf, NULL);
char_u *p = utf16_to_enc(wbuf, NULL);
if (p != NULL)
{
@@ -2466,7 +2466,7 @@ mch_getperm(char_u *name)
#ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
WCHAR *p = enc_to_ucs2(name, NULL);
WCHAR *p = enc_to_utf16(name, NULL);
long n;
if (p != NULL)
@@ -2495,7 +2495,7 @@ mch_setperm(
#ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
WCHAR *p = enc_to_ucs2(name, NULL);
WCHAR *p = enc_to_utf16(name, NULL);
long n;
if (p != NULL)
@@ -2522,7 +2522,7 @@ mch_hide(char_u *name)
WCHAR *p = NULL;
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
p = enc_to_ucs2(name, NULL);
p = enc_to_utf16(name, NULL);
#endif
#ifdef FEAT_MBYTE
@@ -2590,7 +2590,7 @@ mch_is_linked(char_u *fname)
WCHAR *wn = NULL;
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
wn = enc_to_ucs2(fname, NULL);
wn = enc_to_utf16(fname, NULL);
if (wn != NULL)
{
hFile = CreateFileW(wn, /* file name */
@@ -4239,7 +4239,7 @@ mch_remove(char_u *name)
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
wn = enc_to_ucs2(name, NULL);
wn = enc_to_utf16(name, NULL);
if (wn != NULL)
{
SetFileAttributesW(wn, FILE_ATTRIBUTE_NORMAL);
@@ -4382,8 +4382,8 @@ mch_rename(
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
wold = enc_to_ucs2((char_u *)pszOldFile, NULL);
wnew = enc_to_ucs2((char_u *)pszNewFile, NULL);
wold = enc_to_utf16((char_u *)pszOldFile, NULL);
wnew = enc_to_utf16((char_u *)pszNewFile, NULL);
if (wold != NULL && wnew != NULL)
retval = mch_wrename(wold, wnew);
vim_free(wold);
@@ -4492,7 +4492,7 @@ mch_access(char *n, int p)
WCHAR *wn = NULL;
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
wn = enc_to_ucs2(n, NULL);
wn = enc_to_utf16(n, NULL);
#endif
if (mch_isdir(n))
@@ -4618,7 +4618,7 @@ getout:
#if defined(FEAT_MBYTE) || defined(PROTO)
/*
* Version of open() that may use ucs2 file name.
* Version of open() that may use UTF-16 file name.
*/
int
mch_open(char *name, int flags, int mode)
@@ -4630,7 +4630,7 @@ mch_open(char *name, int flags, int mode)
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
wn = enc_to_ucs2(name, NULL);
wn = enc_to_utf16(name, NULL);
if (wn != NULL)
{
f = _wopen(wn, flags, mode);
@@ -4648,7 +4648,7 @@ mch_open(char *name, int flags, int mode)
}
/*
* Version of fopen() that may use ucs2 file name.
* Version of fopen() that may use UTF-16 file name.
*/
FILE *
mch_fopen(char *name, char *mode)
@@ -4675,8 +4675,8 @@ mch_fopen(char *name, char *mode)
else if (newMode == 'b')
_set_fmode(_O_BINARY);
# endif
wn = enc_to_ucs2(name, NULL);
wm = enc_to_ucs2(mode, NULL);
wn = enc_to_utf16(name, NULL);
wm = enc_to_utf16(mode, NULL);
if (wn != NULL && wm != NULL)
f = _wfopen(wn, wm);
vim_free(wn);
@@ -4776,8 +4776,8 @@ copy_infostreams(char_u *from, char_u *to)
int len;
/* Convert the file names to wide characters. */
fromw = enc_to_ucs2(from, NULL);
tow = enc_to_ucs2(to, NULL);
fromw = enc_to_utf16(from, NULL);
tow = enc_to_utf16(to, NULL);
if (fromw != NULL && tow != NULL)
{
/* Open the file for reading. */
@@ -5122,7 +5122,7 @@ fix_arg_enc(void)
for (i = 0; i < used_file_count; ++i)
{
idx = used_file_indexes[i];
str = ucs2_to_enc(ArglistW[idx], NULL);
str = utf16_to_enc(ArglistW[idx], NULL);
if (str != NULL)
{
#ifdef FEAT_DIFF
+1 -1
View File
@@ -573,7 +573,7 @@ pum_set_selected(n, repeat)
{
/* Don't want to sync undo in the current buffer. */
++no_u_sync;
res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0);
res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0, NULL);
--no_u_sync;
if (res == OK)
{
+1 -1
View File
@@ -33,7 +33,7 @@ buf_T *setaltfname __ARGS((char_u *ffname, char_u *sfname, linenr_T lnum));
char_u *getaltfname __ARGS((int errmsg));
int buflist_add __ARGS((char_u *fname, int flags));
void buflist_slash_adjust __ARGS((void));
void buflist_altfpos __ARGS((void));
void buflist_altfpos __ARGS((win_T *win));
int otherfile __ARGS((char_u *ffname));
void buf_setino __ARGS((buf_T *buf));
void fileinfo __ARGS((int fullname, int shorthelp, int dont_truncate));
+1 -1
View File
@@ -61,7 +61,7 @@ void set_vim_var_nr __ARGS((int idx, long val));
long get_vim_var_nr __ARGS((int idx));
char_u *get_vim_var_str __ARGS((int idx));
list_T *get_vim_var_list __ARGS((int idx));
void set_vcount __ARGS((long count, long count1));
void set_vcount __ARGS((long count, long count1, int set_prevcount));
void set_vim_var_string __ARGS((int idx, char_u *val, int len));
void set_vim_var_list __ARGS((int idx, list_T *val));
void set_reg_var __ARGS((int c));
+1 -1
View File
@@ -27,7 +27,7 @@ void ex_wnext __ARGS((exarg_T *eap));
void do_wqall __ARGS((exarg_T *eap));
int not_writing __ARGS((void));
int getfile __ARGS((int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, int forceit));
int do_ecmd __ARGS((int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags));
int do_ecmd __ARGS((int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags, win_T *oldwin));
void ex_append __ARGS((exarg_T *eap));
void ex_change __ARGS((exarg_T *eap));
void ex_z __ARGS((exarg_T *eap));
+4 -4
View File
@@ -22,14 +22,14 @@ int mch_chdir __ARGS((char *path));
int can_end_termcap_mode __ARGS((int give_msg));
int mch_screenmode __ARGS((char_u *arg));
int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result));
int utf8_to_ucs2 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
int ucs2_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
int utf8_to_utf16 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
int utf16_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
void MultiByteToWideChar_alloc __ARGS((UINT cp, DWORD flags, LPCSTR in, int inlen, LPWSTR *out, int *outlen));
void WideCharToMultiByte_alloc __ARGS((UINT cp, DWORD flags, LPCWSTR in, int inlen, LPSTR *out, int *outlen, LPCSTR def, LPBOOL useddef));
int clip_mch_own_selection __ARGS((VimClipboard *cbd));
void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
short_u *enc_to_ucs2 __ARGS((char_u *str, int *lenp));
char_u *ucs2_to_enc __ARGS((short_u *str, int *lenp));
short_u *enc_to_utf16 __ARGS((char_u *str, int *lenp));
char_u *utf16_to_enc __ARGS((short_u *str, int *lenp));
void clip_mch_request_selection __ARGS((VimClipboard *cbd));
void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
void clip_mch_set_selection __ARGS((VimClipboard *cbd));
+8 -3
View File
@@ -1420,6 +1420,7 @@ qf_jump(qi, dir, errornr, forceit)
win_T *win;
win_T *altwin;
#endif
win_T *oldwin = curwin;
int print_message = TRUE;
int len;
#ifdef FEAT_FOLDING
@@ -1744,7 +1745,8 @@ qf_jump(qi, dir, errornr, forceit)
}
else
ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
ECMD_HIDE + ECMD_SET_HELP);
ECMD_HIDE + ECMD_SET_HELP,
oldwin == curwin ? curwin : NULL);
}
else
ok = buflist_getfile(qf_ptr->qf_fnum,
@@ -2267,6 +2269,7 @@ ex_copen(eap)
win_T *win;
tabpage_T *prevtab = curtab;
buf_T *qf_buf;
win_T *oldwin = curwin;
if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
{
@@ -2326,14 +2329,16 @@ ex_copen(eap)
win->w_llist->qf_refcount++;
}
if (oldwin != curwin)
oldwin = NULL; /* don't store info when in another window */
if (qf_buf != NULL)
/* Use the existing quickfix buffer */
(void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
ECMD_HIDE + ECMD_OLDBUF);
ECMD_HIDE + ECMD_OLDBUF, oldwin);
else
{
/* Create a new quickfix buffer */
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE);
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
/* switch off 'swapfile' */
set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
+6 -1
View File
@@ -1792,10 +1792,15 @@ struct window_S
#endif
/*
* The next three specify the offsets for displaying the buffer:
* "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for
* displaying the buffer.
*/
linenr_T w_topline; /* buffer line number of the line at the
top of the window */
#ifdef FEAT_AUTOCMD
char w_topline_was_set; /* flag set to TRUE when topline is set,
e.g. by winrestview() */
#endif
#ifdef FEAT_DIFF
int w_topfill; /* number of filler lines above w_topline */
int w_old_topfill; /* w_topfill at last redraw */
Binary file not shown.
+34
View File
@@ -691,6 +691,40 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
49,
/**/
48,
/**/
47,
/**/
46,
/**/
45,
/**/
44,
/**/
43,
/**/
42,
/**/
41,
/**/
40,
/**/
39,
/**/
38,
/**/
37,
/**/
36,
/**/
35,
/**/
34,
/**/
33,
/**/
32,
/**/
+12 -3
View File
@@ -342,8 +342,14 @@
#ifdef BACKSLASH_IN_FILENAME
# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`%#'\"|!<")
#else
# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
# define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
# ifdef VMS
/* VMS allows a lot of characters in the file name */
# define PATH_ESC_CHARS ((char_u *)" \t\n*?{`\\%#'\"|!")
# define SHELL_ESC_CHARS ((char_u *)" \t\n*?{`\\%#'|!()&")
# else
# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
# define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
# endif
#endif
#define NUMBUFLEN 30 /* length of a buffer to store a number in ASCII */
@@ -371,7 +377,7 @@ typedef __int64 long_i;
* Define __w64 as an empty token for everything but MSVC 7.x or later.
*/
# if !defined(_MSC_VER) || (_MSC_VER < 1300)
# define __w64
# define __w64
# endif
typedef unsigned long __w64 long_u;
typedef long __w64 long_i;
@@ -1983,6 +1989,9 @@ typedef int VimClipboard; /* This is required for the prototypes. */
# endif
#endif
#ifndef FEAT_NETBEANS_INTG
# undef NBDEBUG
#endif
#ifdef NBDEBUG /* Netbeans debugging. */
# include "nbdebug.h"
#else
+2 -1
View File
@@ -531,7 +531,8 @@ wingotofile:
# ifdef FEAT_SCROLLBIND
curwin->w_p_scb = FALSE;
# endif
(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE);
(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL,
ECMD_HIDE, NULL);
if (nchar == 'F' && lnum >= 0)
{
curwin->w_cursor.lnum = lnum;