summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2004-10-07 21:02:47 +0000
committerBram Moolenaar <Bram@vim.org>2004-10-07 21:02:47 +0000
commit3fdfa4a9a52ab3d1a790262ee872a49853ad4626 (patch)
tree76f57a06a5f3b9e0abc15446b38722658fde7e1e /src
parente5f258eb4c4b87ea1d6f61c1a0a9deecbb5d9726 (diff)
updated for version 7.0017v7.0017
Diffstat (limited to 'src')
-rw-r--r--src/GvimExt/gvimext.cpp2
-rw-r--r--src/Makefile2
-rw-r--r--src/digraph.c1
-rw-r--r--src/eval.c66
-rw-r--r--src/fileio.c2
-rw-r--r--src/globals.h1
-rw-r--r--src/gui_gtk.c6
-rw-r--r--src/gui_gtk_x11.c9
-rw-r--r--src/gui_mac.c8
-rw-r--r--src/gui_w32.c38
-rw-r--r--src/gui_w48.c12
-rw-r--r--src/mbyte.c100
-rw-r--r--src/menu.c2
-rw-r--r--src/os_mswin.c22
-rw-r--r--src/os_w32exe.c169
-rw-r--r--src/os_win32.c327
-rw-r--r--src/proto/gui_kde.pro4
-rw-r--r--src/proto/gui_kde_x11.pro4
-rw-r--r--src/proto/mbyte.pro1
-rw-r--r--src/proto/os_win32.pro5
-rw-r--r--src/proto/syntax.pro2
-rw-r--r--src/quickfix.c3
-rw-r--r--src/screen.c11
-rw-r--r--src/structs.h16
-rw-r--r--src/syntax.c8
-rw-r--r--src/testdir/test.ok92
-rw-r--r--src/version.c3
-rw-r--r--src/version.h4
-rw-r--r--src/vim.h3
29 files changed, 509 insertions, 414 deletions
diff --git a/src/GvimExt/gvimext.cpp b/src/GvimExt/gvimext.cpp
index 1cb0b83659..5a175d36d4 100644
--- a/src/GvimExt/gvimext.cpp
+++ b/src/GvimExt/gvimext.cpp
@@ -630,7 +630,7 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
*pos = 0;
}
// Now concatenate
- strncpy(temp, _("Edit with existing Vim - &"), MAX_PATH - 1);
+ strncpy(temp, _("Edit with existing Vim - "), MAX_PATH - 1);
strncat(temp, title, MAX_PATH - 1);
InsertMenu(hMenu,
indexMenu++,
diff --git a/src/Makefile b/src/Makefile
index fade47f352..72f0cb8b09 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1202,7 +1202,7 @@ CARBONGUI_TESTARG = VIMPROG=../$(CARBONGUI_BUNDLE)/Contents/MacOS/$(VIMTARGET)
# All GUI files
ALL_GUI_SRC = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_athena.c gui_gtk_x11.c gui_x11.c gui_at_sb.c gui_at_fs.c pty.c gui_kde.cc gui_kde_wid.cc gui_kde_x11.cc gui_kde_wid_moc.cc
-ALL_GUI_PRO = gui.pro gui_gtk.pro gui_motif.pro gui_athena.pro gui_gtk_x11.pro gui_x11.pro gui_w16.pro gui_w32.pro gui_amiga.pro gui_photon.pro gui_kde.pro gui_kde_x11.pro
+ALL_GUI_PRO = gui.pro gui_gtk.pro gui_motif.pro gui_athena.pro gui_gtk_x11.pro gui_x11.pro gui_w16.pro gui_w32.pro gui_amiga.pro gui_photon.pro
# }}}
diff --git a/src/digraph.c b/src/digraph.c
index de61ce2c7b..4c15d498c8 100644
--- a/src/digraph.c
+++ b/src/digraph.c
@@ -1428,6 +1428,7 @@ digr_T digraphdefault[] =
{'L', 'i', 0x20a4},
{'P', 't', 0x20a7},
{'W', '=', 0x20a9},
+ {'=', 'e', 0x20ac}, /* euro */
{'o', 'C', 0x2103},
{'c', 'o', 0x2105},
{'o', 'F', 0x2109},
diff --git a/src/eval.c b/src/eval.c
index df83da5a8a..492feba59e 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -8526,46 +8526,46 @@ set_cmdarg(eap, oldarg)
unsigned len;
oldval = vimvars[VV_CMDARG].val;
- if (eap != NULL)
+ if (eap == NULL)
{
- if (eap->force_bin == FORCE_BIN)
- len = 6;
- else if (eap->force_bin == FORCE_NOBIN)
- len = 8;
- else
- len = 0;
- if (eap->force_ff != 0)
- len += (unsigned)STRLEN(eap->cmd + eap->force_ff) + 6;
+ vim_free(oldval);
+ vimvars[VV_CMDARG].val = oldarg;
+ return NULL;
+ }
+
+ if (eap->force_bin == FORCE_BIN)
+ len = 6;
+ else if (eap->force_bin == FORCE_NOBIN)
+ len = 8;
+ else
+ len = 0;
+ if (eap->force_ff != 0)
+ len += (unsigned)STRLEN(eap->cmd + eap->force_ff) + 6;
# ifdef FEAT_MBYTE
- if (eap->force_enc != 0)
- len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
+ if (eap->force_enc != 0)
+ len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
# endif
- newval = alloc(len + 1);
- if (newval == NULL)
- return NULL;
+ newval = alloc(len + 1);
+ if (newval == NULL)
+ return NULL;
- if (eap->force_bin == FORCE_BIN)
- sprintf((char *)newval, " ++bin");
- else if (eap->force_bin == FORCE_NOBIN)
- sprintf((char *)newval, " ++nobin");
- else
- *newval = NUL;
- if (eap->force_ff != 0)
- sprintf((char *)newval + STRLEN(newval), " ++ff=%s",
- eap->cmd + eap->force_ff);
+ if (eap->force_bin == FORCE_BIN)
+ sprintf((char *)newval, " ++bin");
+ else if (eap->force_bin == FORCE_NOBIN)
+ sprintf((char *)newval, " ++nobin");
+ else
+ *newval = NUL;
+ if (eap->force_ff != 0)
+ sprintf((char *)newval + STRLEN(newval), " ++ff=%s",
+ eap->cmd + eap->force_ff);
# ifdef FEAT_MBYTE
- if (eap->force_enc != 0)
- sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
- eap->cmd + eap->force_enc);
+ if (eap->force_enc != 0)
+ sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
+ eap->cmd + eap->force_enc);
# endif
- vimvars[VV_CMDARG].val = newval;
- return oldval;
- }
-
- vim_free(oldval);
- vimvars[VV_CMDARG].val = oldarg;
- return NULL;
+ vimvars[VV_CMDARG].val = newval;
+ return oldval;
}
#endif
diff --git a/src/fileio.c b/src/fileio.c
index c925775a9b..bf29748d04 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4066,7 +4066,7 @@ restore_backup:
{
#ifdef FEAT_MBYTE
if (write_info.bw_conv_error)
- errmsg = (char_u *)_("E513: write error, conversion failed");
+ errmsg = (char_u *)_("E513: write error, conversion failed (make 'fenc' empty to override)");
else
#endif
if (got_int)
diff --git a/src/globals.h b/src/globals.h
index 83e6c4b961..93371347f4 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -677,6 +677,7 @@ EXTERN int enc_utf8 INIT(= FALSE); /* UTF-8 encoded Unicode */
/* Codepage nr of 'encoding'. Negative means it's not been set yet, zero
* means 'encoding' is not a valid codepage. */
EXTERN int enc_codepage INIT(= -1);
+EXTERN int enc_latin9 INIT(= FALSE); /* 'encoding' is latin9 */
# endif
EXTERN int has_mbyte INIT(= 0); /* any multi-byte encoding */
diff --git a/src/gui_gtk.c b/src/gui_gtk.c
index 0d552c05f5..ed4e5bc771 100644
--- a/src/gui_gtk.c
+++ b/src/gui_gtk.c
@@ -749,6 +749,10 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx)
text = CONVERT_TO_UTF8(menu->dname);
tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]);
+ if (tooltip != NULL && !utf_valid_string(tooltip, NULL))
+ /* Invalid text, can happen when 'encoding' is changed. Avoid
+ * a nasty GTK error message, skip the tooltip. */
+ CONVERT_TO_UTF8_FREE(tooltip);
menu->id = gtk_toolbar_insert_item(
toolbar,
@@ -993,6 +997,8 @@ gui_mch_menu_set_tip(vimmenu_T *menu)
# ifdef HAVE_GTK2
tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]);
+ if (tooltip == NULL || utf_valid_string(tooltip, NULL))
+ /* Only set the tooltip when it's valid utf-8. */
# else
tooltip = menu->strings[MENU_INDEX_TIP];
# endif
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index aed649b277..bc727733f3 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -5239,6 +5239,14 @@ not_ascii:
int last_glyph_rbearing;
int cells = 0; /* cells occupied by current cluster */
+ /* Safety check: pango crashes when invoked with invalid utf-8
+ * characters. */
+ if (!utf_valid_string(s, s + len))
+ {
+ column_offset = len;
+ goto skipitall;
+ }
+
/* original width of the current cluster */
cluster_width = PANGO_SCALE * gui.char_width;
@@ -5372,6 +5380,7 @@ not_ascii:
pango_attr_list_unref(attr_list);
}
+skipitall:
if (flags & DRAW_UNDERL)
gdk_draw_line(gui.drawarea->window,
gui.text_gc,
diff --git a/src/gui_mac.c b/src/gui_mac.c
index 645e0b5b87..f60567e570 100644
--- a/src/gui_mac.c
+++ b/src/gui_mac.c
@@ -2200,6 +2200,7 @@ gui_mac_doKeyEvent(EventRecord *theEvent)
KeySym key_sym;
int key_char;
int modifiers;
+ int simplify = FALSE;
/* Mask the mouse (as per user setting) */
if (p_mh)
@@ -2253,7 +2254,7 @@ gui_mac_doKeyEvent(EventRecord *theEvent)
/* Handle special keys. */
#if 0
- /* Why have this been removed? */
+ /* Why has this been removed? */
if (!(theEvent->modifiers & (cmdKey | controlKey | rightControlKey)))
#endif
{
@@ -2270,11 +2271,14 @@ gui_mac_doKeyEvent(EventRecord *theEvent)
# endif
key_char = TO_SPECIAL(special_keys[i].vim_code0,
special_keys[i].vim_code1);
- key_char = simplify_key(key_char,&modifiers);
+ simplify = TRUE;
break;
}
}
+ /* For some keys the modifier is included in the char itself. */
+ if (simplify || key_char == TAB || key_char == ' ')
+ key_char = simplify_key(key_char, &modifiers);
/* Add the modifier to the input bu if needed */
/* Do not want SHIFT-A or CTRL-A with modifier */
diff --git a/src/gui_w32.c b/src/gui_w32.c
index a3a7ffa248..ef20a28c66 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -1709,6 +1709,33 @@ im_get_status()
}
#endif
+#ifdef FEAT_MBYTE
+/*
+ * Convert latin9 text to ucs-2.
+ */
+ static void
+latin9_to_ucs(char_u *text, int len, WCHAR *unicodebuf)
+{
+ int c;
+
+ while (len-- >= 0)
+ {
+ c = *text++;
+ switch (c)
+ {
+ case 0xa4: c = 0x20ac; break; /* euro */
+ case 0xa6: c = 0x0160; break; /* S hat */
+ case 0xa8: c = 0x0161; break; /* S -hat */
+ case 0xb4: c = 0x017d; break; /* Z hat */
+ case 0xb8: c = 0x017e; break; /* Z -hat */
+ case 0xbc: c = 0x0152; break; /* OE */
+ case 0xbd: c = 0x0153; break; /* oe */
+ case 0xbe: c = 0x0178; break; /* Y */
+ }
+ *unicodebuf++ = c;
+ }
+}
+#endif
#ifdef FEAT_RIGHTLEFT
/*
@@ -1907,7 +1934,9 @@ gui_mch_draw_string(
/* Check if the Unicode buffer exists and is big enough. Create it
* with the same lengt as the multi-byte string, the number of wide
* characters is always equal or smaller. */
- if ((enc_utf8 || (enc_codepage > 0 && (int)GetACP() != enc_codepage))
+ if ((enc_utf8
+ || (enc_codepage > 0 && (int)GetACP() != enc_codepage)
+ || enc_latin9)
&& (unicodebuf == NULL || len > unibuflen))
{
vim_free(unicodebuf);
@@ -1950,13 +1979,16 @@ gui_mch_draw_string(
foptions, pcliprect, unicodebuf, clen, unicodepdy);
len = cells; /* used for underlining */
}
- else if (enc_codepage > 0 && (int)GetACP() != enc_codepage)
+ else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9)
{
/* If we want to display codepage data, and the current CP is not the
* ANSI one, we need to go via Unicode. */
if (unicodebuf != NULL)
{
- len = MultiByteToWideChar(enc_codepage,
+ if (enc_latin9)
+ latin9_to_ucs(text, len, unicodebuf);
+ else
+ len = MultiByteToWideChar(enc_codepage,
MB_PRECOMPOSED,
(char *)text, len,
(LPWSTR)unicodebuf, unibuflen);
diff --git a/src/gui_w48.c b/src/gui_w48.c
index 7b8d8de30d..eeaf651c77 100644
--- a/src/gui_w48.c
+++ b/src/gui_w48.c
@@ -3277,6 +3277,7 @@ _OnScroll(
return 0;
}
+
/*
* Get command line arguments.
* Use "prog" as the name of the program and "cmdline" as the arguments.
@@ -3299,6 +3300,14 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
char **argv = NULL;
int round;
+#ifdef FEAT_MBYTE
+ /* Try using the Unicode version first, it takes care of conversion when
+ * 'encoding' is changed. */
+ argc = get_cmd_argsW(&argv);
+ if (argc != 0)
+ goto done;
+#endif
+
/* Handle the program name. Remove the ".exe" extension, and find the 1st
* non-space. */
p = strrchr(prog, '.');
@@ -3405,8 +3414,9 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
}
}
- argv[argc] = NULL; /* NULL-terminated list */
+done:
+ argv[argc] = NULL; /* NULL-terminated list */
*argvp = argv;
return argc;
}
diff --git a/src/mbyte.c b/src/mbyte.c
index a71fb51746..0710966532 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -216,7 +216,7 @@ enc_canon_table[] =
#define IDX_ISO_14 13
{"iso-8859-14", ENC_8BIT, 0},
#define IDX_ISO_15 14
- {"iso-8859-15", ENC_8BIT, 0},
+ {"iso-8859-15", ENC_8BIT + ENC_LATIN9, 0},
#define IDX_KOI8_R 15
{"koi8-r", ENC_8BIT, 0},
#define IDX_KOI8_U 16
@@ -534,6 +534,7 @@ codepage_invalid:
#ifdef WIN3264
enc_codepage = encname2codepage(p_enc);
+ enc_latin9 = (STRCMP(p_enc, "iso-8859-15") == 0);
#endif
/*
@@ -2486,6 +2487,36 @@ mb_tail_off(base, p)
return 1 - dbcs_head_off(base, p);
}
+#if defined(HAVE_GTK2) || defined(PROTO)
+/*
+ * Return TRUE if string "s" is a valid utf-8 string.
+ * When "end" is NULL stop at the first NUL.
+ * When "end" is positive stop there.
+ */
+ int
+utf_valid_string(s, end)
+ char_u *s;
+ char_u *end;
+{
+ int l;
+ char_u *p = s;
+
+ while (end == NULL ? *p != NUL : p < end)
+ {
+ if ((*p & 0xc0) == 0x80)
+ return FALSE; /* invalid lead byte */
+ l = utf8len_tab[*p];
+ if (end != NULL && p + l > end)
+ return FALSE; /* incomplete byte sequence */
+ ++p;
+ while (--l > 0)
+ if ((*p++ & 0xc0) != 0x80)
+ return FALSE; /* invalid trail byte */
+ }
+ return TRUE;
+}
+#endif
+
#if defined(FEAT_GUI) || defined(PROTO)
/*
* Special version of mb_tail_off() for use in ScreenLines[].
@@ -5453,11 +5484,22 @@ convert_setup(vcp, from, to)
vcp->vc_type = CONV_TO_UTF8;
vcp->vc_factor = 2; /* up to twice as long */
}
+ else if ((from_prop & ENC_LATIN9) && (to_prop & ENC_UNICODE))
+ {
+ /* Internal latin9 -> utf-8 conversion. */
+ vcp->vc_type = CONV_9_TO_UTF8;
+ vcp->vc_factor = 3; /* up to three as long (euro sign) */
+ }
else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_LATIN1))
{
/* Internal utf-8 -> latin1 conversion. */
vcp->vc_type = CONV_TO_LATIN1;
}
+ else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_LATIN9))
+ {
+ /* Internal utf-8 -> latin9 conversion. */
+ vcp->vc_type = CONV_TO_LATIN9;
+ }
#ifdef WIN3264
/* Win32-specific codepage <-> codepage conversion without iconv. */
else if (((from_prop & ENC_UNICODE) || encname2codepage(from) > 0)
@@ -5622,13 +5664,40 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp)
d = retval;
for (i = 0; i < len; ++i)
{
- if (ptr[i] < 0x80)
- *d++ = ptr[i];
+ c = ptr[i];
+ if (c < 0x80)
+ *d++ = c;
else
{
- *d++ = 0xc0 + ((unsigned)ptr[i] >> 6);
- *d++ = 0x80 + (ptr[i] & 0x3f);
+ *d++ = 0xc0 + ((unsigned)c >> 6);
+ *d++ = 0x80 + (c & 0x3f);
+ }
+ }
+ *d = NUL;
+ if (lenp != NULL)
+ *lenp = (int)(d - retval);
+ break;
+
+ case CONV_9_TO_UTF8: /* latin9 to utf-8 conversion */
+ retval = alloc(len * 3 + 1);
+ if (retval == NULL)
+ break;
+ d = retval;
+ for (i = 0; i < len; ++i)
+ {
+ c = ptr[i];
+ switch (c)
+ {
+ case 0xa4: c = 0x20ac; break; /* euro */
+ case 0xa6: c = 0x0160; break; /* S hat */
+ case 0xa8: c = 0x0161; break; /* S -hat */
+ case 0xb4: c = 0x017d; break; /* Z hat */
+ case 0xb8: c = 0x017e; break; /* Z -hat */
+ case 0xbc: c = 0x0152; break; /* OE */
+ case 0xbd: c = 0x0153; break; /* oe */
+ case 0xbe: c = 0x0178; break; /* Y */
}
+ d += utf_char2bytes(c, d);
}
*d = NUL;
if (lenp != NULL)
@@ -5636,6 +5705,7 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp)
break;
case CONV_TO_LATIN1: /* utf-8 to latin1 conversion */
+ case CONV_TO_LATIN9: /* utf-8 to latin9 conversion */
retval = alloc(len + 1);
if (retval == NULL)
break;
@@ -5658,6 +5728,26 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp)
else
{
c = utf_ptr2char(ptr + i);
+ if (vcp->vc_type == CONV_TO_LATIN9)
+ switch (c)
+ {
+ case 0x20ac: c = 0xa4; break; /* euro */
+ case 0x0160: c = 0xa6; break; /* S hat */
+ case 0x0161: c = 0xa8; break; /* S -hat */
+ case 0x017d: c = 0xb4; break; /* Z hat */
+ case 0x017e: c = 0xb8; break; /* Z -hat */
+ case 0x0152: c = 0xbc; break; /* OE */
+ case 0x0153: c = 0xbd; break; /* oe */
+ case 0x0178: c = 0xbe; break; /* Y */
+ case 0xa4:
+ case 0xa6:
+ case 0xa8:
+ case 0xb4:
+ case 0xb8:
+ case 0xbc:
+ case 0xbd:
+ case 0xbe: c = 0x100; break; /* not in latin9 */
+ }
if (!utf_iscomposing(c)) /* skip composing chars */
{
if (c < 0x100)
diff --git a/src/menu.c b/src/menu.c
index fc8411fbfc..258b84da9b 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -392,6 +392,8 @@ ex_menu(eap)
map_to = (char_u *)"";
map_buf = NULL;
}
+ else if (modes & MENU_TIP_MODE)
+ map_buf = NULL; /* Menu tips are plain text. */
else
map_to = replace_termcodes(map_to, &map_buf, FALSE, TRUE);
menuarg.modes = modes;
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 7b5da8a4c0..7f2288ee5e 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -267,6 +267,10 @@ mch_early_init(void)
AnsiUpperBuff(toupper_tab, 256);
AnsiLowerBuff(tolower_tab, 256);
#endif
+
+#if defined(FEAT_MBYTE) && !defined(FEAT_GUI)
+ (void)get_cmd_argsW(NULL);
+#endif
}
@@ -298,7 +302,25 @@ mch_settitle(
gui_mch_settitle(title, icon);
# else
if (title != NULL)
+ {
+# ifdef FEAT_MBYTE
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+ /* Convert the title from 'encoding' to the active codepage. */
+ WCHAR *wp = enc_to_ucs2(title, NULL);
+ int n;
+
+ if (wp != NULL)
+ {
+ n = SetConsoleTitleW(wp);
+ vim_free(wp);
+ if (n != 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ return;
+ }
+ }
+# endif
SetConsoleTitle(title);
+ }
# endif
}
diff --git a/src/os_w32exe.c b/src/os_w32exe.c
index 7bdceadcbc..ac9bf3c4ac 100644
--- a/src/os_w32exe.c
+++ b/src/os_w32exe.c
@@ -30,24 +30,6 @@ 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
@@ -76,56 +58,14 @@ 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. 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;
- }
- }
- }
- }
-
+ argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree);
if (argc == 0)
-#endif
{
- 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;
- }
+ 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);
@@ -190,108 +130,9 @@ errout:
free(argv);
free(tofree);
#ifdef FEAT_MBYTE
- if (ArglistW != NULL)
- GlobalFree(ArglistW);
+ free_cmd_argsW();
#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 bc6c7d4fd7..fce48f9fcd 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -92,6 +92,7 @@ FILE* fdDump = NULL;
#define WINAPI
#define WINBASEAPI
typedef char * LPCSTR;
+typedef char * LPWSTR;
typedef int ACCESS_MASK;
typedef int BOOL;
typedef int COLORREF;
@@ -301,19 +302,19 @@ dyn_libintl_end()
}
static char *
-null_libintl_gettext(const char* msgid)
+null_libintl_gettext(const char *msgid)
{
return (char*)msgid;
}
static char *
-null_libintl_bindtextdomain(const char* domainname, const char* dirname)
+null_libintl_bindtextdomain(const char *domainname, const char *dirname)
{
return NULL;
}
static char *
-null_libintl_textdomain(const char* domainname)
+null_libintl_textdomain(const char *domainname)
{
return NULL;
}
@@ -530,7 +531,7 @@ const static struct
__stdcall
#endif
win32_kbd_patch_key(
- KEY_EVENT_RECORD* pker)
+ KEY_EVENT_RECORD *pker)
{
UINT uMods = pker->dwControlKeyState;
static int s_iIsDead = 0;
@@ -734,8 +735,7 @@ decode_key_event(
*/
# ifdef FEAT_GUI_W32
void
-mch_setmouse(
- int on)
+mch_setmouse(int on)
{
}
# else
@@ -749,8 +749,7 @@ static int g_yMouse; /* mouse y coordinate */
* Enable or disable mouse input
*/
void
-mch_setmouse(
- int on)
+mch_setmouse(int on)
{
DWORD cmodein;
@@ -798,7 +797,7 @@ mch_setmouse(
*/
static BOOL
decode_mouse_event(
- MOUSE_EVENT_RECORD* pmer)
+ MOUSE_EVENT_RECORD *pmer)
{
static int s_nOldButton = -1;
static int s_nOldMouseClick = -1;
@@ -1214,7 +1213,7 @@ WaitForChar(long msec)
* return non-zero if a character is available
*/
int
-mch_char_avail()
+mch_char_avail(void)
{
return WaitForChar(0L);
}
@@ -1579,7 +1578,7 @@ executable_exists(char *name)
* GUI version of mch_init().
*/
void
-mch_init()
+mch_init(void)
{
#ifndef __MINGW32__
extern int _fmode;
@@ -1746,10 +1745,10 @@ FitConsoleWindow(
typedef struct ConsoleBufferStruct
{
- BOOL IsValid;
- CONSOLE_SCREEN_BUFFER_INFO Info;
- PCHAR_INFO Buffer;
- COORD BufferSize;
+ BOOL IsValid;
+ CONSOLE_SCREEN_BUFFER_INFO Info;
+ PCHAR_INFO Buffer;
+ COORD BufferSize;
} ConsoleBuffer;
/*
@@ -1853,8 +1852,8 @@ SaveConsoleBuffer(
*/
static BOOL
RestoreConsoleBuffer(
- ConsoleBuffer *cb,
- BOOL RestoreScreen)
+ ConsoleBuffer *cb,
+ BOOL RestoreScreen)
{
COORD BufferCoord;
SMALL_RECT WriteRegion;
@@ -1949,23 +1948,19 @@ static BOOL g_fCanChangeIcon = FALSE;
*/
static BOOL
GetConsoleIcon(
- HWND hWnd,
- HICON *phIconSmall,
- HICON *phIcon)
+ HWND hWnd,
+ HICON *phIconSmall,
+ HICON *phIcon)
{
if (hWnd == NULL)
return FALSE;
if (phIconSmall != NULL)
- {
- *phIconSmall = (HICON) SendMessage(hWnd, WM_GETICON,
- (WPARAM) ICON_SMALL, (LPARAM) 0);
- }
+ *phIconSmall = (HICON)SendMessage(hWnd, WM_GETICON,
+ (WPARAM)ICON_SMALL, (LPARAM)0);
if (phIcon != NULL)
- {
- *phIcon = (HICON) SendMessage(hWnd, WM_GETICON,
- (WPARAM) ICON_BIG, (LPARAM) 0);
- }
+ *phIcon = (HICON)SendMessage(hWnd, WM_GETICON,
+ (WPARAM)ICON_BIG, (LPARAM)0);
return TRUE;
}
@@ -1979,26 +1974,22 @@ GetConsole