summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GvimExt/gvimext.cpp2
-rw-r--r--src/buffer.c31
-rw-r--r--src/ex_cmds.c5
-rw-r--r--src/ex_docmd.c20
-rw-r--r--src/fileio.c24
-rw-r--r--src/gui_kde.cc69
-rw-r--r--src/gui_kde_x11.cc38
-rw-r--r--src/gui_w48.c10
-rw-r--r--src/main.c23
-rw-r--r--src/mbyte.c14
-rw-r--r--src/option.c17
-rw-r--r--src/os_mswin.c21
-rw-r--r--src/os_w32exe.c173
-rw-r--r--src/os_win32.c1
-rw-r--r--src/po/Makefile8
-rw-r--r--src/po/uk.cp1251.po6225
-rw-r--r--src/proto/buffer.pro2
-rw-r--r--src/proto/ex_docmd.pro1
-rw-r--r--src/vim.h1
19 files changed, 6599 insertions, 86 deletions
diff --git a/src/GvimExt/gvimext.cpp b/src/GvimExt/gvimext.cpp
index 57fbf81199..1cb0b83659 100644
--- a/src/GvimExt/gvimext.cpp
+++ b/src/GvimExt/gvimext.cpp
@@ -595,7 +595,7 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
indexMenu++,
MF_STRING|MF_BYPOSITION,
idCmd++,
- _("&Diff with Vim"));
+ _("Diff with Vim"));
m_edit_existing_off = 3;
}
else
diff --git a/src/buffer.c b/src/buffer.c
index 007afd6356..9f29b27510 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -252,7 +252,7 @@ open_buffer(read_stdin, eap)
/* Go to the buffer that was opened. */
aucmd_prepbuf(&aco, old_curbuf);
#endif
- do_modelines();
+ do_modelines(FALSE);
curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED);
#ifdef FEAT_AUTOCMD
@@ -724,7 +724,7 @@ handle_swap_exists(old_curbuf)
ml_recover();
MSG_PUTS("\n"); /* don't overwrite the last message */
cmdline_row = msg_row;
- do_modelines();
+ do_modelines(FALSE);
}
swap_exists_action = SEA_NONE;
got_int |= old_got_int;
@@ -4338,14 +4338,15 @@ ex_buffer_all(eap)
*
* Returns immediately if the "ml" option isn't set.
*/
-static int chk_modeline __ARGS((linenr_T));
+static int chk_modeline __ARGS((linenr_T, int));
void
-do_modelines()
+do_modelines(win_only)
+ int win_only; /* Only do window-local options. */
{
- linenr_T lnum;
- int nmlines;
- static int entered = 0;
+ linenr_T lnum;
+ int nmlines;
+ static int entered = 0;
if (!curbuf->b_p_ml || (nmlines = (int)p_mls) == 0)
return;
@@ -4358,12 +4359,12 @@ do_modelines()
++entered;
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count && lnum <= nmlines;
++lnum)
- if (chk_modeline(lnum) == FAIL)
+ if (chk_modeline(lnum, win_only) == FAIL)
nmlines = 0;
for (lnum = curbuf->b_ml.ml_line_count; lnum > 0 && lnum > nmlines
&& lnum > curbuf->b_ml.ml_line_count - nmlines; --lnum)
- if (chk_modeline(lnum) == FAIL)
+ if (chk_modeline(lnum, win_only) == FAIL)
nmlines = 0;
--entered;
}
@@ -4375,8 +4376,9 @@ do_modelines()
* Return FAIL if an error encountered.
*/
static int
-chk_modeline(lnum)
+chk_modeline(lnum, win_only)
linenr_T lnum;
+ int win_only; /* Only do window-local options. */
{
char_u *s;
char_u *e;
@@ -4473,7 +4475,8 @@ chk_modeline(lnum)
save_SID = current_SID;
current_SID = SID_MODELINE;
#endif
- retval = do_set(s, OPT_MODELINE | OPT_LOCAL);
+ retval = do_set(s, OPT_MODELINE | OPT_LOCAL
+ | (win_only ? OPT_WINONLY : 0));
#ifdef FEAT_EVAL
current_SID = save_SID;
#endif
@@ -4558,10 +4561,14 @@ write_viminfo_bufferlist(fp)
win_T *win;
#endif
char_u *line;
+ int max_buffers;
if (find_viminfo_parameter('%') == NULL)
return;
+ /* Without a number -1 is returned: do all buffers. */
+ max_buffers = get_viminfo_parameter('%');
+
/* Allocate room for the file name, lnum and col. */
line = alloc(MAXPATHL + 30);
if (line == NULL)
@@ -4585,6 +4592,8 @@ write_viminfo_bufferlist(fp)
|| removable(buf->b_ffname))
continue;
+ if (max_buffers-- == 0)
+ break;
putc('%', fp);
home_replace(NULL, buf->b_ffname, line, MAXPATHL, TRUE);
sprintf((char *)line + STRLEN(line), "\t%ld\t%d",
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 2568b194ba..ee9f1bca77 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3059,6 +3059,11 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
#ifdef FEAT_AUTOCMD
else
{
+ /* Read the modelines, but only to set window-local options. Any
+ * buffer-local options have already been set and may have been
+ * changed by the user. */
+ do_modelines(TRUE);
+
apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf,
&retval);
apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf,
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 3627f32ccc..a0c07201d2 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -4460,7 +4460,7 @@ ex_doautocmd(eap)
exarg_T *eap;
{
(void)do_doautocmd(eap->arg, TRUE);
- do_modelines();
+ do_modelines(FALSE);
}
#endif
@@ -6173,11 +6173,10 @@ handle_drop(filec, filev, split)
}
#endif
-static void alist_clear __ARGS((alist_T *al));
/*
* Clear an argument list: free all file names and reset it to zero entries.
*/
- static void
+ void
alist_clear(al)
alist_T *al;
{
@@ -6264,8 +6263,8 @@ alist_expand()
&& new_arg_file_count > 0)
{
alist_set(&global_alist, new_arg_file_count, new_arg_files, TRUE);
+ vim_free(old_arg_files);
}
- vim_free(old_arg_files);
}
p_su = save_p_su;
}
@@ -6288,7 +6287,18 @@ alist_set(al, count, files, use_curbuf)
if (ga_grow(&al->al_ga, count) == OK)
{
for (i = 0; i < count; ++i)
+ {
+ if (got_int)
+ {
+ /* When adding many buffers this can take a long time. Allow
+ * interrupting here. */
+ while (i < count)
+ vim_free(files[i++]);
+ break;
+ }
alist_add(al, files[i], use_curbuf ? 2 : 1);
+ ui_breakcheck();
+ }
vim_free(files);
}
else
@@ -9582,7 +9592,7 @@ ex_filetype(eap)
if (*arg == 'd')
{
(void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE);
- do_modelines();
+ do_modelines(FALSE);
}
}
else if (STRCMP(arg, "off") == 0)
diff --git a/src/fileio.c b/src/fileio.c
index 026bc8f384..b82cd4a6e7 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -370,15 +370,21 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
* file may destroy it! Reported on MS-DOS and Win 95.
* If the name is too long we might crash further on, quit here.
*/
- if (fname != NULL
- && *fname != NUL
- && (vim_ispathsep(*(fname + STRLEN(fname) - 1))
- || STRLEN(fname) >= MAXPATHL))
+ if (fname != NULL && *fname != NUL)
{
- filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0);
- msg_end();
- msg_scroll = msg_save;
- return FAIL;
+ p = fname + STRLEN(fname) - 1;
+ if ((vim_ispathsep(*p)
+#ifdef FEAT_MBYTE
+ /* Do not use a multi-byte char as path separator. */
+ && (!has_mbyte || (*mb_head_off)(fname, p) == 0)
+#endif
+ ) || STRLEN(fname) >= MAXPATHL)
+ {
+ filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0);
+ msg_end();
+ msg_scroll = msg_save;
+ return FAIL;
+ }
}
#ifdef UNIX
@@ -7526,7 +7532,7 @@ ex_doautoall(eap)
/* execute the autocommands for this buffer */
retval = do_doautocmd(eap->arg, FALSE);
- do_modelines();
+ do_modelines(FALSE);
/* restore the current window */
aucmd_restbuf(&aco);
diff --git a/src/gui_kde.cc b/src/gui_kde.cc
index 2be18b9b7a..499db7754b 100644
--- a/src/gui_kde.cc
+++ b/src/gui_kde.cc
@@ -1,4 +1,4 @@
-/* vi:set ts=8 sts=0 sw=8:
+/* vi:set ts=8 sts=4 sw=4:
*
* VIM - Vi IMproved by Bram Moolenaar
*
@@ -371,12 +371,10 @@ gui_mch_destroy_menu(vimmenu_T * menu)//{{{
return;
}
#endif
- if(menu->parent){
- menu->parent->widget->removeItem((int)menu );
- }
- if (menu->widget){
+ if (menu->parent)
+ menu->parent->widget->removeItem((int)menu);
+ if (menu->widget)
delete menu->widget;
- }
menu->widget = 0;
}//}}}
#endif /* FEAT_MENU */
@@ -475,21 +473,24 @@ gui_mch_browse(int saving,//{{{
char_u * filter)
{
char * filt_glob;
- if (filter != (char_u *) 0x0 ) {
+
+ if (filter != (char_u *) 0x0 )
+ {
filter = vim_strsave(filter);
strtok((char *) filter, "(");
filt_glob = strtok(0L, ")");
- } else
+ }
+ else
filt_glob = (char *) filter;
-
+
gui_mch_mousehide(FALSE);
QString s;
- if (! saving)
+ if (!saving)
s = KFileDialog::getOpenFileName( (char *) initdir, (char *) filt_glob, vmw, (char *) title );
else
s = KFileDialog::getSaveFileName( );
-
+
if (filter)
vim_free(filter);
@@ -508,7 +509,7 @@ gui_mch_browse(int saving,//{{{
#ifdef FEAT_GUI_DIALOG
/* ARGSUSED */
-int
+ int
gui_mch_dialog(int type, /* type of dialog *///{{{
char_u * title, /* title of dialog */
char_u * message, /* message text */
@@ -516,29 +517,29 @@ gui_mch_dialog(int type, /* type of dialog *///{{{
int def_but, /* default button */
char_u *textfield)
{
- gui_mch_mousehide(FALSE);
- VimDialog vd(type, title, message, buttons, def_but,textfield);
- int ret = vd.exec();
- return ret;
+ gui_mch_mousehide(FALSE);
+ VimDialog vd(type, title, message, buttons, def_but,textfield);
+ int ret = vd.exec();
+ return ret;
}//}}}
#endif /* FEAT_GUI_DIALOG */
#if defined(FEAT_MENU) || defined(PROTO)
- void
+ void
gui_mch_show_popupmenu(vimmenu_T * menu)//{{{
{
- menu->widget->popup(QCursor::pos());
+ menu->widget->popup(QCursor::pos());
}//}}}
void
-gui_make_popup (char_u *pathname) {//{{{
- vimmenu_T *menu = gui_find_menu(pathname);
+gui_make_popup (char_u *pathname)//{{{
+{
+ vimmenu_T *menu = gui_find_menu(pathname);
- if (menu != NULL) {
- menu->widget->popup(QCursor::pos());
- }
+ if (menu != NULL)
+ menu->widget->popup(QCursor::pos());
}//}}}
#endif
@@ -548,19 +549,19 @@ gui_make_popup (char_u *pathname) {//{{{
void
gui_mch_find_dialog(exarg_T * eap)//{{{
{
- // char_u* entry_text;
- //int exact_word=FALSE;
- // entry_text = get_find_dialog_text(eap->arg,&exact_word);
+ // char_u* entry_text;
+ //int exact_word=FALSE;
+ // entry_text = get_find_dialog_text(eap->arg,&exact_word);
- vmw->finddlg->setCaseSensitive(true);
+ vmw->finddlg->setCaseSensitive(true);
- /* if(entry_text!=NULL) {
- vmw->finddlg->setText(QString((char*)entry_text));
- // exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
- }*/ // Don't use it, KDE keeps old search in memory and vim give \\Csearch, which is difficult to handle
- // vim_free(entry_text);
+ /* if (entry_text!=NULL) {
+ vmw->finddlg->setText(QString((char*)entry_text));
+ // exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
+ }*/ // Don't use it, KDE keeps old search in memory and vim give \\Csearch, which is difficult to handle
+ // vim_free(entry_text);
- vmw->finddlg->show();
+ vmw->finddlg->show();
}//}}}
void
@@ -571,7 +572,7 @@ gui_mch_replace_dialog(exarg_T * eap)//{{{
// entry_text = get_find_dialog_text(eap->arg,&exact_word);
- /* if(entry_text!=NULL) {
+ /* if (entry_text!=NULL) {
vmw->repldlg->setText(QString((char*)entry_text));
// exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
}*/
diff --git a/src/gui_kde_x11.cc b/src/gui_kde_x11.cc
index 6517cd2f89..4fe2eee139 100644
--- a/src/gui_kde_x11.cc
+++ b/src/gui_kde_x11.cc
@@ -112,7 +112,7 @@ gui_mch_prepare(int *argc, char **argv)// {{{
i--;
continue;
}
-
+
if (strcmp(argv[i],"--servername")==0) {
argServerName = new QString(argv[i+1]); // to get the serverName now
}
@@ -182,7 +182,7 @@ gui_mch_prepare(int *argc, char **argv)// {{{
) {
gui_argv[gui_argc++] = argv[i];
}
-
+
//KDE/Qt options with one arg
if ( strcmp(argv[i],"--session")==0
@@ -211,7 +211,7 @@ gui_mch_prepare(int *argc, char **argv)// {{{
gui_argv[gui_argc++] = argv[i+1];
found=2;
}
-
+
//remove from the list of argv
if (found >= 1 && --*argc>i) {
mch_memmove(&argv[i], &argv[i + 1],
@@ -385,7 +385,7 @@ gui_mch_open()//{{{
#endif
if (startfont!=NULL)
gui_mch_init_font((char_u*)startfont->latin1(),0);
-
+
if (startsize!=NULL)
vmw->resize(startsize->width(), startsize->height());
@@ -394,7 +394,7 @@ gui_mch_open()//{{{
if (kapp->isRestored())
if (KMainWindow::canBeRestored(1))
vmw->restore(1);
-
+
vmw->show();
#if QT_VERSION>=300
if (tip==2) KTipDialog::showTip (vmw,QString::null,true);
@@ -559,8 +559,9 @@ gui_mch_init_font(char_u * font_name, int fontset)//{{{
{
QString fontname;
GuiFont font=NULL;
-
- if (font_name==NULL) {
+
+ if (font_name==NULL)
+ {
#if 0
#if QT_VERSION>=300
KConfig *base = KGlobal::config();
@@ -568,7 +569,7 @@ gui_mch_init_font(char_u * font_name, int fontset)//{{{
KConfigBase *base = KGlobal::config();
#endif
base->setGroup("General");
- if(!base->hasKey("fixed")) {
+ if (!base->hasKey("fixed")) {
KMessageBox::error(KApplication::kApplication()->mainWidget(),"Cannot load default fixed font\n\nConfigure fonts in KDE Control Center.\n(Just click 'Choose...', 'OK' and then 'Apply')");
return FAIL;
}
@@ -614,11 +615,20 @@ gui_mch_init_font(char_u * font_name, int fontset)//{{{
if (fontname.contains('*') && fontname.contains('-'))
return FAIL;
+ /* Compute the width of the character cell. Some fonts include
+ * double-width characters. Use the width of ASCII characters to find
+ * out if this is so. */
QFontMetrics f(*font);
- gui.char_width = f.maxWidth();
+ int width_max = 0;
+ for (char c = 32; c < 127; c++)
+ if (width_max < f.width((QChar)c))
+ width_max = f.width((QChar)c);
+ if (width_max <= f.maxWidth() / 2)
+ width_max = f.maxWidth() / 2;
+ gui.char_width = width_max;
gui.char_height = f.height()+p_linespace;
- gui.char_ascent = f.ascent()+p_linespace/2;
-
+ gui.char_ascent = f.ascent()+p_linespace;
+
//check values, just to make sure and avoid a crash
if (gui.char_width<=0) gui.char_width=8;
if (gui.char_height<=0) gui.char_height=1;
@@ -778,7 +788,7 @@ gui_mch_mousehide(int hide)//{{{
{
if (hide == gui.pointer_hidden) return;
//#ifdef FEAT_MOUSESHAPE
- // if( !hide) mch_set_mouse_shape(last_shape);
+ // if (!hide) mch_set_mouse_shape(last_shape);
//#else
# if (QT_VERSION<300)
gui.w->setCursor((hide)?BlankCursor:ArrowCursor);
@@ -1092,7 +1102,7 @@ clip_mch_set_selection(VimClipboard *cbd){//{{{
long_u length;
clip_get_selection(cbd);
- if(clip_convert_selection(&data,&length,cbd)<0) return;
+ if (clip_convert_selection(&data,&length,cbd)<0) return;
QString selection((const char *) data);
//We must turncate the string because it is not
@@ -1156,7 +1166,7 @@ gui_mch_enable_scrollbar(scrollbar_T * sb, int flag)//{{{
if (gui.which_scrollbars[SBAR_LEFT]) width += gui.scrollbar_width;
if (gui.which_scrollbars[SBAR_RIGHT]) width += gui.scrollbar_width;
if (gui.which_scrollbars[SBAR_BOTTOM]) height += gui.scrollbar_height;
-
+
if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
#if QT_VERSION>=300
&& !vmw->menuBar()->isTopLevelMenu()
diff --git a/src/gui_w48.c b/src/gui_w48.c
index 761c1af167..7b8d8de30d 100644
--- a/src/gui_w48.c
+++ b/src/gui_w48.c
@@ -3376,6 +3376,16 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
{
if (pnew != NULL)
*pnew++ = *p;
+#ifdef FEAT_MBYTE
+ /* Can't use mb_* functions, because 'encoding' is not
+ * initialized yet here. */
+ if (IsDBCSLeadByte(*p))
+ {
+ ++p;
+ if (pnew != NULL)
+ *pnew++ = *p;
+ }
+#endif
++p;
}
}
diff --git a/src/main.c b/src/main.c
index 0c8701ad93..0f63d7848f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1065,6 +1065,16 @@ scripterror:
2 /* add buffer number now and use curbuf */
#endif
);
+
+#if defined(FEAT_MBYTE) && defined(WIN32)
+ {
+ extern void used_file_arg(char *, int, int);
+
+ /* Remember this argument has been added to the argument list.
+ * Needed when 'encoding' is changed. */
+ used_file_arg(argv[0], literal, full_path);
+ }
+#endif
}
/*
@@ -1133,6 +1143,17 @@ scripterror:
#endif
fname = alist_name(&GARGLIST[0]);
}
+
+#if defined(WIN32) && defined(FEAT_MBYTE)
+ {
+ extern void set_alist_count(void);
+
+ /* Remember the number of entries in the argument list. If it changes
+ * we don't react on setting 'encoding'. */
+ set_alist_count();
+ }
+#endif
+
if (GARGCOUNT > 1)
printf(_("%d files to edit\n"), GARGCOUNT);
#ifdef MSWIN
@@ -1756,7 +1777,7 @@ scripterror:
ml_recover();
if (curbuf->b_ml.ml_mfp == NULL) /* failed */
getout(1);
- do_modelines(); /* do modelines */
+ do_modelines(FALSE); /* do modelines */
}
else
{
diff --git a/src/mbyte.c b/src/mbyte.c
index 407f6674b6..a71fb51746 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -426,6 +426,9 @@ mb_init()
vimconv_T vimconv;
char_u *p;
#endif
+#ifdef WIN32
+ int prev_enc_utf8 = enc_utf8;
+#endif
if (p_enc == NULL)
{
@@ -684,6 +687,17 @@ codepage_invalid:
enc_utf8 ? "utf-8" : (char *)p_enc);
#endif
+#ifdef WIN32
+ /* When changing 'encoding' while starting up, then convert the command
+ * line arguments from the active codepage to 'encoding'. */
+ if (starting != 0)
+ {
+ extern void fix_arg_enc(void);
+
+ fix_arg_enc();
+ }
+#endif
+
#ifdef FEAT_AUTOCMD
/* Fire an autocommand to let people do custom font setup. This must be
* after Vim has been setup for the new encoding. */
diff --git a/src/option.c b/src/option.c
index d049cd47a7..0b36dfef12 100644
--- a/src/option.c
+++ b/src/option.c
@@ -3529,6 +3529,12 @@ do_set(arg, opt_flags)
goto skip;
}
+ /* Skip all options that are not window-local (used when showing
+ * an already loaded buffer in a window). */
+ if ((opt_flags & OPT_WINONLY)
+ && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
+ goto skip;
+
#ifdef HAVE_SANDBOX
/* Disallow changing some options in the sandbox */
if (sandbox > 0 && (flags & P_SECURE))
@@ -4280,7 +4286,8 @@ set_options_bin(oldval, newval, opt_flags)
* Find the parameter represented by the given character (eg ', :, ", or /),
* and return its associated value in the 'viminfo' string.
* Only works for number parameters, not for 'r' or 'n'.
- * If the parameter is not specified in the string, return -1.
+ * If the parameter is not specified in the string or there is no following
+ * number, return -1.
*/
int
get_viminfo_parameter(type)
@@ -5149,7 +5156,13 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
while (*++s && *s != ',')
;
}
- else if (*s == '%' || *s == '!' || *s == 'h' || *s == 'c')
+ else if (*s == '%')
+ {
+ /* optional number */
+ while (vim_isdigit(*++s))
+ ;
+ }
+ else if (*s == '!' || *s == 'h' || *s == 'c')
++s; /* no extra chars */
else /* must have a number */
{
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 3ce61bc1d2..7b5da8a4c0 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -443,6 +443,10 @@ vim_stat(const char *name, struct stat *stp)
p = buf + strlen(buf);
if (p > buf)
--p;
+#ifdef FEAT_MBYTE
+ if (p > buf && has_mbyte)
+ p -= (*mb_head_off)(buf, p);
+#endif
if (p > buf && (*p == '\\' || *p == '/') && p[-1] != ':')
*p = NUL;
#ifdef FEAT_MBYTE
@@ -624,6 +628,23 @@ mch_chdir(char *path)
if (*path == NUL) /* drive name only */
return 0;
+#ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+ WCHAR *p = enc_to_ucs2(path, NULL);
+ int n;
+
+ if (p != NULL)
+ {
+ n = _wchdir(p);
+ vim_free(p);
+ if (n == 0)
+ return 0;
+ /* Retry with non-wide function (for Windows 98). */
+ }
+ }
+#endif
+
return chdir(path); /* let the normal chdir() do the rest */
}
diff --git a/src/os_w32exe.c b/src/os_w32exe.c
index e37873b760..7bdceadcbc 100644
--- a/src/os_w32exe.c
+++ b/src/os_w32exe.c
@@ -30,6 +30,24 @@ VimMain
__ARGS((int argc, char **argv));
int (_cdecl *pmain)(int, char **);
+#ifdef FEAT_MBYTE
+/* The commandline arguments in UCS2. */
+static DWORD nArgsW = 0;
+static LPWSTR *ArglistW = NULL;
+static int global_argc;
+static char **global_argv;
+
+static int used_file_argc = 0; /* last argument in global_argv[] used
+ for the argument list. */
+static int *used_file_indexes = NULL; /* indexes in global_argv[] for
+ command line arguments added to
+ the argument list */
+static int used_file_count = 0; /* nr of entries in used_file_indexes */
+static int used_file_literal = FALSE; /* take file names literally */
+static int used_file_full_path = FALSE; /* file name was full path */
+static int used_alist_count = 0;
+#endif
+
#ifndef PROTO
#ifdef FEAT_GUI
#ifndef VIMDLL
@@ -45,7 +63,7 @@ WinMain(
LPSTR lpszCmdLine,
int nCmdShow)
{
- int argc;
+ int argc = 0;
char **argv;
char *tofree;
char prog[256];
@@ -58,15 +76,56 @@ WinMain(
* startup path (so the .vimrc file can be found w/o a VIM env. var.) */
GetModuleFileName(NULL, prog, 255);
- /* Separate the command line into arguments. */
- argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree);
+ /* Separate the command line into arguments. Use the Unicode functions
+ * when possible. When 'encoding' is later changed these are used to
+ * recode the arguments. */
+#ifdef FEAT_MBYTE
+ ArglistW = CommandLineToArgvW(GetCommandLineW(), &nArgsW);
+ if (ArglistW != NULL)
+ {
+ argv = malloc((nArgsW + 1) * sizeof(char *));
+ if (argv != NULL)
+ {
+ int i;
+
+ argv[argc] = NULL;
+ argc = nArgsW;
+ for (i = 0; i < argc; ++i)
+ {
+ int len;
+
+ WideCharToMultiByte_alloc(GetACP(), 0,
+ ArglistW[i], wcslen(ArglistW[i]) + 1,
+ (LPSTR *)&argv[i], &len, 0, 0);
+ if (argv[i] == NULL)
+ {
+ while (i > 0)
+ free(argv[--i]);
+ free(argv);
+ argc = 0;
+ }
+ }
+ }
+ }
+
if (argc == 0)
+#endif
{
- MessageBox(0, _("Could not allocate memory for command line."),
- _("VIM Error"), 0);
- return 0;
+ argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree);
+ if (argc == 0)
+ {
+ MessageBox(0, "Could not allocate memory for command line.",
+ "VIM Error", 0);
+ return 0;
+ }
}
+#ifdef FEAT_MBYTE
+ global_argc = argc;
+ global_argv = argv;
+ used_file_indexes = malloc(argc * sizeof(int));
+#endif
+
#ifdef DYNAMIC_GETTEXT
/* Initialize gettext library */
dyn_libintl_init(NULL);
@@ -130,7 +189,109 @@ errout:
#endif
free(argv);
free(tofree);
+#ifdef FEAT_MBYTE
+ if (ArglistW != NULL)
+ GlobalFree(ArglistW);
+#endif
return 0;
}
#endif
+
+#ifdef FEAT_MBYTE
+/*
+ * Remember "name" is an argument that was added to the argument list.
+ * This avoids that we have to re-parse the argument list when fix_arg_enc()
+ * is called.
+ */
+ void
+used_file_arg(name, literal, full_path)
+ char *name;
+ int literal;
+ int full_path;
+{
+ int i;
+
+ if (used_file_indexes == NULL)
+ return;
+ for (i = used_file_argc + 1; i < global_argc; ++i)
+ if (STRCMP(global_argv[i], name) == 0)
+ {
+ used_file_argc = i;
+ used_file_indexes[used_file_count++] = i;
+ break;
+ }
+ used_file_literal = literal;
+ used_file_full_path = full_path;
+}
+
+/*
+ * Remember the length of the argument list as it was. If it changes then we
+ * leave it alone when 'encoding' is set.
+ */
+ void
+set_alist_count(void)
+{
+ used_alist_count = GARGCOUNT;
+}
+
+/*
+ * Fix the encoding of the command line arguments. Invoked when 'encoding'
+ * has been changed while starting up. Use the UCS-2 command line arguments
+ * and convert them to 'encoding'.
+ */
+ void
+fix_arg_enc()
+{
+ int i;
+ int idx;
+ char_u *str;
+
+ /* Safety checks:
+ * - if argument count differs between the wide and non-wide argument
+ * list, something must be wrong.
+ * - the file name arguments must have been located.
+ * - the length of the argument list wasn't changed by the user.
+ */
+ if (global_argc != (int)nArgsW
+ || ArglistW == NULL
+ || used_file_indexes == NULL
+ || used_file_count == 0
+ || used_alist_count != GARGCOUNT)
+ return;
+
+ /* Clear the argument list. Make room for the new arguments. */
+ alist_clear(&global_alist);
+ if (ga_grow(&global_alist.al_ga, used_file_count) == FAIL)
+ return; /* out of memory */
+
+ for (i = 0; i < used_file_count; ++i)
+ {
+ idx = used_file_indexes[i];
+ str = ucs2_to_enc(ArglistW[idx], NULL);
+ if (str != NULL)
+ alist_add(&global_alist, str, used_file_literal ? 2 : 0);
+ }
+
+ if (!used_file_literal)
+ {
+ /* Now expand wildcards in the arguments. */
+ /* Temporarily add '(' and ')' to 'isfname'. These are valid
+ * filename characters but are excluded from 'isfname' to make
+ * "gf" work on a file name in parenthesis (e.g.: see vim.h). */
+ do_cmdline_cmd((char_u *)":let SaVe_ISF = &isf|set isf+=(,)");
+ alist_expand();
+ do_cmdline_cmd((char_u *)":let &isf = SaVe_ISF|unlet SaVe_ISF");
+ }
+
+ /* If wildcard expansion failed, we are editing the first file of the
+ * arglist and there is no file name: Edit the first argument now. */
+ if (curwin->w_arg_idx == 0 && curbuf->b_fname == NULL)
+ {
+ do_cmdline_cmd((char_u *)":rewind");
+ if (GARGCOUNT == 1 && used_file_full_path)
+ (void)vim_chdirfile(alist_name(&GARGLIST[0]));
+ }
+}
+#endif
+
diff --git a/src/os_win32.c b/src/os_win32.c
index 1c68689851..a39e00508c 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -2207,7 +2207,6 @@ mch_exit(int r)
}
#endif /* !FEAT_GUI_W32 */
-
/*
* Do we have an interactive window?
*/
diff --git a/src/po/Makefile b/src/po/Makefile
index 364210c6e5..c71df8dad0 100644
--- a/src/po/Makefile
+++ b/src/po/Makefile
@@ -56,7 +56,7 @@ uninstall:
done
converted: ja.sjis.mo cs.cp1250.mo pl.cp1250.mo sk.cp1250.mo zh_CN.cp936.mo \
- ru.cp1251.mo
+ ru.cp1251.mo uk.cp1251.mo
# Convert ja.po to create ja.sjis.po. Requires doubling backslashes in the
# second byte. Don't depend on sjiscorr, it should only be compiled when
@@ -100,6 +100,12 @@ ru.cp1251.po: ru.po
iconv -f utf-8 -t cp1251 ru.po | \
sed -e 's/charset=utf-8/charset=cp1251/' -e 's/# Original translations/# Generated from ru.po, DO NOT EDIT/' > ru.cp1251.po
+# Convert uk.po to create uk.cp1251.po.
+uk.cp1251.po: uk.po
+ rm -f uk.cp1251.po
+ iconv -f koi8-u -t cp1251 uk.po | \
+ sed -e 's/charset=koi8-u/charset=cp1251/' -e 's/# Original translations/# Generated from uk.po, DO NOT EDIT/' > uk.cp1251.po
+
check:
@if test "x" = "x$(prefix)"; then \
echo "******************************************"; \
diff --git a/src/po/uk.cp1251.po b/src/po/uk.cp1251.po
new file mode 100644
index 0000000000..5df9b18d5c
--- /dev/null
+++ b/src/po/uk.cp1251.po
@@ -0,0 +1,6225 @@
+#
+# Ukrainian Vim translation [uk]
+#
+# Copyright (C) 2001 Bohdan Vlasyuk <bohdan@vstu.edu.ua>
+#
+# Thanks to:
+# Dmytro Kovalov <dmytro.kovalov@nssmb.com> for useful suggestions
+# Dmytro O. Redchuk <dor@kiev-online.net> for viminfo bug
+#
+# Please, see readme at htpp://www.vstu.edu.ua/~bohdan/vim before any
+# complains, and even if you won't complain, read it anyway.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: vim 6.0\n"
+"POT-Creation-Date: 2002-01-10 09:03+0200\n"
+"PO-Revision-Date: 2001-10-16 13:34+0300\n"
+"Last-Translator: Bohdan Vlasyuk <bohdan@vstu.edu.ua>\n"
+"Language-Team: Bohdan Vlasyuk <bohdan@vstu.edu.ua>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=cp1251\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: buffer.c:97
+msgid "E82: Cannot allocate any buffer, exiting..."
+msgstr "E82: Немає можливості розмістити хоч один буфер, завершення роботи..."
+
+#: buffer.c:100
+msgid "E83: Cannot allocate buffer, using other one..."
+msgstr "E83: Немає можливості розмістити буфер, буде використано інший..."
+
+#: buffer.c:698
+msgid "No buffers were unloaded"
+msgstr "Жоден з буферів не був вивантажений"
+
+#: buffer.c:700
+msgid "No buffers were deleted"
+msgstr "Жоден з буферів не був видалений"
+
+#: buffer.c:702
+msgid "No buffers were wiped out"
+msgstr "Жоден з буферів не був витертий"
+
+#: buffer.c:710
+msgid "1 buffer unloaded"
+msgstr "Вивантажено один буфер"
+
+#: buffer.c:712
+#, c-format
+msgid "%d buffers unloaded"
+msgstr "Вивантажено буферів -- %d"
+
+#: buffer.c:717
+msgid "1 buffer deleted"
+msgstr "Видалено один буфер"
+
+#: buffer.c:719
+#, c-format
+msgid "%d buffers deleted"
+msgstr "Видалено буферів -- %d"
+
+#: buffer.c:724
+msgid "1 buffer wiped out"
+msgstr "Витерто один буфер"
+
+#: buffer.c:726
+#, c-format
+msgid "%d buffers wiped out"
+msgstr "Витерто буферів -- %d"
+
+#: buffer.c:783
+msgid "E84: No modified buffer found"
+msgstr "E84: Жоден буфер не змінено"
+
+#. back where we started, didn't find anything.
+#: buffer.c:822
+msgid "E85: There is no listed buffer"
+msgstr "E85: У списку немає буферів"
+
+#: buffer.c:834
+#, c-format
+msgid "E86: Cannot go to buffer %ld"
+msgstr "E86: Не можу перейти в буфер %ld"
+
+#: buffer.c:837
+msgid "E87: Cannot go beyond