summaryrefslogtreecommitdiff
path: root/src/os_win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os_win32.c')
-rw-r--r--src/os_win32.c761
1 files changed, 380 insertions, 381 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index ff37f54b2..b56033cac 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -30,7 +30,7 @@
#include <signal.h>
#include <limits.h>
-/* cproto fails on missing include files */
+// cproto fails on missing include files
#ifndef PROTO
# include <process.h>
#endif
@@ -82,8 +82,8 @@
# endif
#endif
-/* Record all output and all keyboard & mouse input */
-/* #define MCH_WRITE_DUMP */
+// Record all output and all keyboard & mouse input
+// #define MCH_WRITE_DUMP
#ifdef MCH_WRITE_DUMP
FILE* fdDump = NULL;
@@ -143,25 +143,25 @@ typedef int PSNSECINFOW;
typedef int STARTUPINFO;
typedef int PROCESS_INFORMATION;
typedef int LPSECURITY_ATTRIBUTES;
-# define __stdcall /* empty */
+# define __stdcall // empty
#endif
#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)
-/* Win32 Console handles for input and output */
+// Win32 Console handles for input and output
static HANDLE g_hConIn = INVALID_HANDLE_VALUE;
static HANDLE g_hConOut = INVALID_HANDLE_VALUE;
-/* Win32 Screen buffer,coordinate,console I/O information */
+// Win32 Screen buffer,coordinate,console I/O information
static SMALL_RECT g_srScrollRegion;
-static COORD g_coord; /* 0-based, but external coords are 1-based */
+static COORD g_coord; // 0-based, but external coords are 1-based
-/* The attribute of the screen when the editor was started */
-static WORD g_attrDefault = 7; /* lightgray text on black background */
+// The attribute of the screen when the editor was started
+static WORD g_attrDefault = 7; // lightgray text on black background
static WORD g_attrCurrent;
-static int g_fCBrkPressed = FALSE; /* set by ctrl-break interrupt */
-static int g_fCtrlCPressed = FALSE; /* set when ctrl-C or ctrl-break detected */
-static int g_fForceExit = FALSE; /* set when forcefully exiting */
+static int g_fCBrkPressed = FALSE; // set by ctrl-break interrupt
+static int g_fCtrlCPressed = FALSE; // set when ctrl-C or ctrl-break detected
+static int g_fForceExit = FALSE; // set when forcefully exiting
static void scroll(unsigned cLines);
static void set_scroll_region(unsigned left, unsigned top,
@@ -219,13 +219,13 @@ static void set_console_color_rgb(void);
static void reset_console_color_rgb(void);
#endif
-/* This flag is newly created from Windows 10 */
+// This flag is newly created from Windows 10
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)
-static int suppress_winsize = 1; /* don't fiddle with console */
+static int suppress_winsize = 1; // don't fiddle with console
#endif
static char_u *exe_path = NULL;
@@ -233,7 +233,7 @@ static char_u *exe_path = NULL;
static BOOL win8_or_later = FALSE;
#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)
-/* Dynamic loading for portability */
+// Dynamic loading for portability
typedef struct _DYN_CONSOLE_SCREEN_BUFFER_INFOEX
{
ULONG cbSize;
@@ -339,7 +339,7 @@ read_console_input(
&& s_irCache[head + 1].EventType
== WINDOW_BUFFER_SIZE_EVENT)
{
- /* Remove duplicate event to avoid flicker. */
+ // Remove duplicate event to avoid flicker.
for (i = head; i < tail; ++i)
s_irCache[i] = s_irCache[i + 1];
--tail;
@@ -403,15 +403,15 @@ wait_for_single_object(
static void
get_exe_name(void)
{
- /* Maximum length of $PATH is more than MAXPATHL. 8191 is often mentioned
- * as the maximum length that works (plus a NUL byte). */
+ // Maximum length of $PATH is more than MAXPATHL. 8191 is often mentioned
+ // as the maximum length that works (plus a NUL byte).
#define MAX_ENV_PATH_LEN 8192
char temp[MAX_ENV_PATH_LEN];
char_u *p;
if (exe_name == NULL)
{
- /* store the name of the executable, may be used for $VIM */
+ // store the name of the executable, may be used for $VIM
GetModuleFileName(NULL, temp, MAX_ENV_PATH_LEN - 1);
if (*temp != NUL)
exe_name = FullName_save((char_u *)temp, FALSE);
@@ -423,9 +423,9 @@ get_exe_name(void)
(int)(gettail_sep(exe_name) - exe_name));
if (exe_path != NULL)
{
- /* Append our starting directory to $PATH, so that when doing
- * "!xxd" it's found in our starting directory. Needed because
- * SearchPath() also looks there. */
+ // Append our starting directory to $PATH, so that when doing
+ // "!xxd" it's found in our starting directory. Needed because
+ // SearchPath() also looks there.
p = mch_getenv("PATH");
if (p == NULL
|| STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN)
@@ -471,8 +471,8 @@ vimLoadLib(char *name)
{
HINSTANCE dll = NULL;
- /* NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
- * vimLoadLib() recursively, which causes a stack overflow. */
+ // NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
+ // vimLoadLib() recursively, which causes a stack overflow.
if (exe_path == NULL)
get_exe_name();
if (exe_path != NULL)
@@ -481,9 +481,9 @@ vimLoadLib(char *name)
if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0)
{
- /* Change directory to where the executable is, both to make
- * sure we find a .dll there and to avoid looking for a .dll
- * in the current directory. */
+ // Change directory to where the executable is, both to make
+ // sure we find a .dll there and to avoid looking for a .dll
+ // in the current directory.
SetCurrentDirectory((LPCSTR)exe_path);
dll = LoadLibrary(name);
SetCurrentDirectoryW(old_dirw);
@@ -528,8 +528,8 @@ get_imported_func_info(HINSTANCE hInst, const char *funcname, int info)
PIMAGE_DOS_HEADER pDOS = (PIMAGE_DOS_HEADER)hInst;
PIMAGE_NT_HEADERS pPE;
PIMAGE_IMPORT_DESCRIPTOR pImpDesc;
- PIMAGE_THUNK_DATA pIAT; /* Import Address Table */
- PIMAGE_THUNK_DATA pINT; /* Import Name Table */
+ PIMAGE_THUNK_DATA pIAT; // Import Address Table
+ PIMAGE_THUNK_DATA pINT; // Import Name Table
PIMAGE_IMPORT_BY_NAME pImpName;
if (pDOS->e_magic != IMAGE_DOS_SIGNATURE)
@@ -599,7 +599,7 @@ get_dll_import_func(HINSTANCE hInst, const char *funcname)
# define GETTEXT_DLL_ALT1 "libintl-8.dll"
# define GETTEXT_DLL_ALT2 "intl.dll"
# endif
-/* Dummy functions */
+// Dummy functions
static char *null_libintl_gettext(const char *);
static char *null_libintl_ngettext(const char *, const char *, unsigned long n);
static char *null_libintl_textdomain(const char *);
@@ -676,14 +676,14 @@ dyn_libintl_init(void)
}
}
- /* The bind_textdomain_codeset() function is optional. */
+ // The bind_textdomain_codeset() function is optional.
dyn_libintl_bind_textdomain_codeset = (void *)GetProcAddress(hLibintlDLL,
"bind_textdomain_codeset");
if (dyn_libintl_bind_textdomain_codeset == NULL)
dyn_libintl_bind_textdomain_codeset =
null_libintl_bind_textdomain_codeset;
- /* _wputenv() function for the libintl.dll is optional. */
+ // _wputenv() function for the libintl.dll is optional.
hmsvcrt = find_imported_module_by_funcname(hLibintlDLL, "getenv");
if (hmsvcrt != NULL)
dyn_libintl_wputenv = (void *)GetProcAddress(hmsvcrt, "_wputenv");
@@ -750,9 +750,9 @@ null_libintl_wputenv(const wchar_t *envstring UNUSED)
return 0;
}
-#endif /* DYNAMIC_GETTEXT */
+#endif // DYNAMIC_GETTEXT
-/* This symbol is not defined in older versions of the SDK or Visual C++ */
+// This symbol is not defined in older versions of the SDK or Visual C++
#ifndef VER_PLATFORM_WIN32_WINDOWS
# define VER_PLATFORM_WIN32_WINDOWS 1
@@ -828,7 +828,7 @@ PlatformId(void)
win8_or_later = TRUE;
#ifdef HAVE_ACL
- /* Enable privilege for getting or setting SACLs. */
+ // Enable privilege for getting or setting SACLs.
win32_enable_privilege(SE_SECURITY_NAME, TRUE);
#endif
done = TRUE;
@@ -843,13 +843,12 @@ PlatformId(void)
# define ALT_GR (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)
-/* When uChar.AsciiChar is 0, then we need to look at wVirtualKeyCode.
- * We map function keys to their ANSI terminal equivalents, as produced
- * by ANSI.SYS, for compatibility with the MS-DOS version of Vim. Any
- * ANSI key with a value >= '\300' is nonstandard, but provided anyway
- * so that the user can have access to all SHIFT-, CTRL-, and ALT-
- * combinations of function/arrow/etc keys.
- */
+// When uChar.AsciiChar is 0, then we need to look at wVirtualKeyCode.
+// We map function keys to their ANSI terminal equivalents, as produced
+// by ANSI.SYS, for compatibility with the MS-DOS version of Vim. Any
+// ANSI key with a value >= '\300' is nonstandard, but provided anyway
+// so that the user can have access to all SHIFT-, CTRL-, and ALT-
+// combinations of function/arrow/etc keys.
static const struct
{
@@ -927,7 +926,9 @@ static const struct
# define UChar uChar.UnicodeChar
# endif
-/* The return code indicates key code size. */
+/*
+ * The return code indicates key code size.
+ */
static int
win32_kbd_patch_key(
KEY_EVENT_RECORD *pker)
@@ -950,7 +951,7 @@ win32_kbd_patch_key(
vim_memset(abKeystate, 0, sizeof (abKeystate));
- /* Clear any pending dead keys */
+ // Clear any pending dead keys
ToUnicode(VK_SPACE, MapVirtualKey(VK_SPACE, 0), abKeystate, awAnsiCode, 2, 0);
if (uMods & SHIFT_PRESSED)
@@ -992,39 +993,39 @@ decode_key_event(
*pch = *pch2 = NUL;
g_fJustGotFocus = FALSE;
- /* ignore key up events */
+ // ignore key up events
if (!pker->bKeyDown)
return FALSE;
- /* ignore some keystrokes */
+ // ignore some keystrokes
switch (pker->wVirtualKeyCode)
{
- /* modifiers */
+ // modifiers
case VK_SHIFT:
case VK_CONTROL:
- case VK_MENU: /* Alt key */
+ case VK_MENU: // Alt key
return FALSE;
default:
break;
}
- /* special cases */
+ // special cases
if ((nModifs & CTRL) != 0 && (nModifs & ~CTRL) == 0 && pker->UChar == NUL)
{
- /* Ctrl-6 is Ctrl-^ */
+ // Ctrl-6 is Ctrl-^
if (pker->wVirtualKeyCode == '6')
{
*pch = Ctrl_HAT;
return TRUE;
}
- /* Ctrl-2 is Ctrl-@ */
+ // Ctrl-2 is Ctrl-@
else if (pker->wVirtualKeyCode == '2')
{
*pch = NUL;
return TRUE;
}
- /* Ctrl-- is Ctrl-_ */
+ // Ctrl-- is Ctrl-_
else if (pker->wVirtualKeyCode == 0xBD)
{
*pch = Ctrl__;
@@ -1032,7 +1033,7 @@ decode_key_event(
}
}
- /* Shift-TAB */
+ // Shift-TAB
if (pker->wVirtualKeyCode == VK_TAB && (nModifs & SHIFT_PRESSED))
{
*pch = K_NUL;
@@ -1076,19 +1077,19 @@ decode_key_event(
if (pmodifiers != NULL)
{
- /* Pass on the ALT key as a modifier, but only when not combined
- * with CTRL (which is ALTGR). */
+ // Pass on the ALT key as a modifier, but only when not combined
+ // with CTRL (which is ALTGR).
if ((nModifs & ALT) != 0 && (nModifs & CTRL) == 0)
*pmodifiers |= MOD_MASK_ALT;
- /* Pass on SHIFT only for special keys, because we don't know when
- * it's already included with the character. */
+ // Pass on SHIFT only for special keys, because we don't know when
+ // it's already included with the character.
if ((nModifs & SHIFT) != 0 && *pch <= 0x20)
*pmodifiers |= MOD_MASK_SHIFT;
- /* Pass on CTRL only for non-special keys, because we don't know
- * when it's already included with the character. And not when
- * combined with ALT (which is ALTGR). */
+ // Pass on CTRL only for non-special keys, because we don't know
+ // when it's already included with the character. And not when
+ // combined with ALT (which is ALTGR).
if ((nModifs & CTRL) != 0 && (nModifs & ALT) == 0
&& *pch >= 0x20 && *pch < 0x80)
*pmodifiers |= MOD_MASK_CTRL;
@@ -1098,7 +1099,7 @@ decode_key_event(
return (*pch != NUL);
}
-#endif /* FEAT_GUI_MSWIN */
+#endif // FEAT_GUI_MSWIN
/*
@@ -1110,11 +1111,11 @@ mch_setmouse(int on UNUSED)
{
}
#else
-static int g_fMouseAvail = FALSE; /* mouse present */
-static int g_fMouseActive = FALSE; /* mouse enabled */
-static int g_nMouseClick = -1; /* mouse status */
-static int g_xMouse; /* mouse x coordinate */
-static int g_yMouse; /* mouse y coordinate */
+static int g_fMouseAvail = FALSE; // mouse present
+static int g_fMouseActive = FALSE; // mouse enabled
+static int g_nMouseClick = -1; // mouse status
+static int g_xMouse; // mouse x coordinate
+static int g_yMouse; // mouse y coordinate
/*
* Enable or disable mouse input
@@ -1198,7 +1199,7 @@ decode_mouse_event(
static DWORD s_dwLastClickTime = 0;
static BOOL s_fNextIsMiddle = FALSE;
- static DWORD cButtons = 0; /* number of buttons supported */
+ static DWORD cButtons = 0; // number of buttons supported
const DWORD LEFT = FROM_LEFT_1ST_BUTTON_PRESSED;
const DWORD MIDDLE = FROM_LEFT_2ND_BUTTON_PRESSED;
@@ -1216,14 +1217,14 @@ decode_mouse_event(
return FALSE;
}
- /* get a spurious MOUSE_EVENT immediately after receiving focus; ignore */
+ // get a spurious MOUSE_EVENT immediately after receiving focus; ignore
if (g_fJustGotFocus)
{
g_fJustGotFocus = FALSE;
return FALSE;
}
- /* unprocessed mouse click? */
+ // unprocessed mouse click?
if (g_nMouseClick != -1)
return TRUE;
@@ -1233,22 +1234,22 @@ decode_mouse_event(
if (pmer->dwEventFlags == MOUSE_MOVED)
{
- /* Ignore MOUSE_MOVED events if (x, y) hasn't changed. (We get these
- * events even when the mouse moves only within a char cell.) */
+ // Ignore MOUSE_MOVED events if (x, y) hasn't changed. (We get these
+ // events even when the mouse moves only within a char cell.)
if (s_xOldMouse == g_xMouse && s_yOldMouse == g_yMouse)
return FALSE;
}
- /* If no buttons are pressed... */
+ // If no buttons are pressed...
if ((pmer->dwButtonState & ((1 << cButtons) - 1)) == 0)
{
nButton = MOUSE_RELEASE;
- /* If the last thing returned was MOUSE_RELEASE, ignore this */
+ // If the last thing returned was MOUSE_RELEASE, ignore this
if (s_fReleased)
{
# ifdef FEAT_BEVAL_TERM
- /* do return mouse move events when we want them */
+ // do return mouse move events when we want them
if (p_bevalterm)
nButton = MOUSE_DRAG;
else
@@ -1258,22 +1259,22 @@ decode_mouse_event(
s_fReleased = TRUE;
}
- else /* one or more buttons pressed */
+ else // one or more buttons pressed
{
- /* on a 2-button mouse, hold down left and right buttons
- * simultaneously to get MIDDLE. */
+ // on a 2-button mouse, hold down left and right buttons
+ // simultaneously to get MIDDLE.
if (cButtons == 2 && s_nOldButton != MOUSE_DRAG)
{
DWORD dwLR = (pmer->dwButtonState & LEFT_RIGHT);
- /* if either left or right button only is pressed, see if the
- * next mouse event has both of them pressed */
+ // if either left or right button only is pressed, see if the
+ // next mouse event has both of them pressed
if (dwLR == LEFT || dwLR == RIGHT)
{
for (;;)
{
- /* wait a short time for next input event */
+ // wait a short time for next input event
if (WaitForSingleObject(g_hConIn, p_mouset / 3)
!= WAIT_OBJECT_0)
break;
@@ -1299,10 +1300,10 @@ decode_mouse_event(
else if (s_xOldMouse == pmer2->dwMousePosition.X &&
s_yOldMouse == pmer2->dwMousePosition.Y)
{
- /* throw away spurious mouse move */
+ // throw away spurious mouse move
read_console_input(g_hConIn, &ir, 1, &cRecords);
- /* are there any more mouse events in queue? */
+ // are there any more mouse events in queue?
peek_console_input(g_hConIn, &ir, 1, &cRecords);
if (cRecords==0 || ir.EventType != MOUSE_EVENT)
@@ -1349,7 +1350,7 @@ decode_mouse_event(
if (pmer->dwEventFlags == 0 || pmer->dwEventFlags == DOUBLE_CLICK)
{
- /* button pressed or released, without mouse moving */
+ // button pressed or released, without mouse moving
if (nButton != -1 && nButton != MOUSE_RELEASE)
{
DWORD dwCurrentTime = GetTickCount();
@@ -1399,7 +1400,7 @@ decode_mouse_event(
if (nButton != MOUSE_DRAG && nButton != MOUSE_RELEASE)
SET_NUM_MOUSE_CLICKS(g_nMouseClick, s_cClicks);
- /* only pass on interesting (i.e., different) mouse events */
+ // only pass on interesting (i.e., different) mouse events
if (s_xOldMouse == g_xMouse
&& s_yOldMouse == g_yMouse
&& s_nOldMouseClick == g_nMouseClick)
@@ -1456,7 +1457,7 @@ mch_update_cursor(void)
idx = get_shape_idx(FALSE);
if (shape_table[idx].shape == SHAPE_BLOCK)
- thickness = 99; /* 100 doesn't work on W95 */
+ thickness = 99; // 100 doesn't work on W95
else
thickness = shape_table[idx].percentage;
mch_set_cursor_shape(thickness);
@@ -1494,10 +1495,10 @@ WaitForChar(long msec, int ignore_input)
# endif
if (msec > 0)
- /* Wait until the specified time has elapsed. */
+ // Wait until the specified time has elapsed.
dwEndTime = GetTickCount() + msec;
else if (msec < 0)
- /* Wait forever. */
+ // Wait forever.
dwEndTime = INFINITE;
// We need to loop until the end of the time period, because
@@ -1527,8 +1528,8 @@ WaitForChar(long msec, int ignore_input)
if (msec > 0)
{
- /* If the specified wait time has passed, return. Beware that
- * GetTickCount() may wrap around (overflow). */
+ // If the specified wait time has passed, return. Beware that
+ // GetTickCount() may wrap around (overflow).
dwNow = GetTickCount();
if ((int)(dwNow - dwEndTime) >= 0)
break;
@@ -1538,26 +1539,26 @@ WaitForChar(long msec, int ignore_input)
DWORD dwWaitTime = dwEndTime - dwNow;
# ifdef FEAT_JOB_CHANNEL
- /* Check channel while waiting for input. */
+ // Check channel while waiting for input.
if (dwWaitTime > 100)
{
dwWaitTime = 100;
- /* If there is readahead then parse_queued_messages() timed out
- * and we should call it again soon. */
+ // If there is readahead then parse_queued_messages() timed out
+ // and we should call it again soon.
if (channel_any_readahead())
dwWaitTime = 10;
}
# endif
# ifdef FEAT_BEVAL_GUI
if (p_beval && dwWaitTime > 100)
- /* The 'balloonexpr' may indirectly invoke a callback while
- * waiting for a character, need to check often. */
+ // The 'balloonexpr' may indirectly invoke a callback while
+ // waiting for a character, need to check often.
dwWaitTime = 100;
# endif
# ifdef FEAT_MZSCHEME
if (mzthreads_allowed() && p_mzq > 0
&& (msec < 0 || (long)dwWaitTime > p_mzq))
- dwWaitTime = p_mzq; /* don't wait longer than 'mzquantum' */
+ dwWaitTime = p_mzq; // don't wait longer than 'mzquantum'
# endif
# ifdef FEAT_TIMERS
// When waiting very briefly don't trigger timers.
@@ -1603,8 +1604,8 @@ WaitForChar(long msec, int ignore_input)
{
if (csbi.dwCursorPosition.Y != msg_row)
{
- /* The screen is now messed up, must redraw the
- * command line and later all the windows. */
+ // The screen is now messed up, must redraw the
+ // command line and later all the windows.
redraw_all_later(CLEAR);
cmdline_row -= (msg_row - csbi.dwCursorPosition.Y);
redrawcmd();
@@ -1618,8 +1619,8 @@ WaitForChar(long msec, int ignore_input)
if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown)
{
# ifdef FEAT_MBYTE_IME
- /* Windows IME sends two '\n's with only one 'ENTER'. First:
- * wVirtualKeyCode == 13. second: wVirtualKeyCode == 0 */
+ // Windows IME sends two '\n's with only one 'ENTER'. First:
+ // wVirtualKeyCode == 13. second: wVirtualKeyCode == 0
if (ir.Event.KeyEvent.UChar == 0
&& ir.Event.KeyEvent.wVirtualKeyCode == 13)
{
@@ -1660,7 +1661,7 @@ WaitForChar(long msec, int ignore_input)
}
# ifdef FEAT_CLIENTSERVER
- /* Something might have been received while we were waiting. */
+ // Something might have been received while we were waiting.
if (input_available())
return TRUE;
# endif
@@ -1754,7 +1755,7 @@ tgetch(int *pmodifiers, WCHAR *pch2)
}
}
}
-#endif /* !FEAT_GUI_MSWIN */
+#endif // !FEAT_GUI_MSWIN
/*
@@ -1777,7 +1778,7 @@ mch_inchar(
int len;
int c;
# define TYPEAHEADLEN 20
- static char_u typeahead[TYPEAHEADLEN]; /* previously typed bytes. */
+ static char_u typeahead[TYPEAHEADLEN]; // previously typed bytes.
static int typeaheadlen = 0;
# ifdef VIMDLL
@@ -1785,18 +1786,18 @@ mch_inchar(
return 0;
# endif
- /* First use any typeahead that was kept because "buf" was too small. */
+ // First use any typeahead that was kept because "buf" was too small.
if (typeaheadlen > 0)
goto theend;
if (time >= 0)
{
- if (!WaitForChar(time, FALSE)) /* no character available */
+ if (!WaitForChar(time, FALSE)) // no character available
return 0;
}
- else /* time == -1, wait forever */
+ else // time == -1, wait forever
{
- mch_set_winsize_now(); /* Allow winsize changes from now on */
+ mch_set_winsize_now(); // Allow winsize changes from now on
/*
* If there is no character available within 2 seconds (default)
@@ -1820,7 +1821,7 @@ mch_inchar(
* Try to read as many characters as there are, until the buffer is full.
*/
- /* we will get at least one key. Get more if they are available. */
+ // we will get at least one key. Get more if they are available.
g_fCBrkPressed = FALSE;
# ifdef MCH_WRITE_DUMP
@@ -1828,16 +1829,16 @@ mch_inchar(
fputc('[', fdDump);
# endif
- /* Keep looping until there is something in the typeahead buffer and more
- * to get and still room in the buffer (up to two bytes for a char and
- * three bytes for a modifier). */
+ // Keep looping until there is something in the typeahead buffer and more
+ // to get and still room in the buffer (up to two bytes for a char and
+ // three bytes for a modifier).
while ((typeaheadlen == 0 || WaitForChar(0L, FALSE))
&& typeaheadlen + 5 <= TYPEAHEADLEN)
{
if (typebuf_changed(tb_change_cnt))
{
- /* "buf" may be invalid now if a client put something in the
- * typeahead buffer and "buf" is in the typeahead buffer. */
+ // "buf" may be invalid now if a client put something in the
+ // typeahead buffer and "buf" is in the typeahead buffer.
typeaheadlen = 0;
break;
}
@@ -1864,8 +1865,8 @@ mch_inchar(
if (typebuf_changed(tb_change_cnt))
{
- /* "buf" may be invalid now if a client put something in the
- * typeahead buffer and "buf" is in the typeahead buffer. */
+ // "buf" may be invalid now if a client put something in the
+ // typeahead buffer and "buf" is in the typeahead buffer.
typeaheadlen = 0;
break;
}
@@ -1889,7 +1890,7 @@ mch_inchar(
WCHAR ch[2];
ch[0] = c;
- if (c >= 0xD800 && c <= 0xDBFF) /* High surrogate */
+ if (c >= 0xD800 && c <= 0xDBFF) // High surrogate
{
ch[1] = tgetch(&modifiers, &ch2);
n++;
@@ -1933,10 +1934,10 @@ mch_inchar(
}
}
- /* Use the ALT key to set the 8th bit of the character
- * when it's one byte, the 8th bit isn't set yet and not
- * using a double-byte encoding (would become a lead
- * byte). */
+ // Use the ALT key to set the 8th bit of the character
+ // when it's one byte, the 8th bit isn't set yet and not
+ // using a double-byte encoding (would become a lead
+ // byte).
if ((modifiers & MOD_MASK_ALT)
&& n == 1
&& (typeahead[typeaheadlen] & 0x80) == 0
@@ -1950,7 +1951,7 @@ mch_inchar(
if (modifiers != 0)
{
- /* Prepend modifiers to the character. */
+ // Prepend modifiers to the character.
mch_memmove(typeahead + typeaheadlen + 3,
typeahead + typeaheadlen, n);
typeahead[typeaheadlen++] = K_SPECIAL;
@@ -1977,7 +1978,7 @@ mch_inchar(
# endif
theend:
- /* Move typeahead to "buf", as much as fits. */
+ // Move typeahead to "buf", as much as fits.
len = 0;
while (len < maxlen && typeaheadlen > 0)
{
@@ -1986,14 +1987,14 @@ theend:
}
return len;
-#else /* FEAT_GUI_MSWIN */
+#else // FEAT_GUI_MSWIN
return 0;
-#endif /* FEAT_GUI_MSWIN */
+#endif // FEAT_GUI_MSWIN
}
#ifndef PROTO
# ifndef __MINGW32__
-# include <shellapi.h> /* required for FindExecutable() */
+# include <shellapi.h> // required for FindExecutable()
# endif
#endif
@@ -2092,31 +2093,31 @@ mch_init_g(void)
extern int _fmode;
# endif
- /* Silently handle invalid parameters to CRT functions */
+ // Silently handle invalid parameters to CRT functions
SET_INVALID_PARAM_HANDLER;
- /* Let critical errors result in a failure, not in a dialog box. Required
- * for the timestamp test to work on removed floppies. */
+ // Let critical errors result in a failure, not in a dialog box. Required
+ // for the timestamp test to work on removed floppies.
SetErrorMode(SEM_FAILCRITICALERRORS);
- _fmode = O_BINARY; /* we do our own CR-LF translation */
+ _fmode = O_BINARY; // we do our own CR-LF translation
- /* Specify window size. Is there a place to get the default from? */
+ // Specify window size. Is there a place to get the default from?
Rows = 25;
Columns = 80;
- /* Look for 'vimrun' */
+ // Look for 'vimrun'
{
char_u vimrun_location[_MAX_PATH + 4];
- /* First try in same directory as gvim.exe */
+ // First try in same directory as gvim.exe
STRCPY(vimrun_location, exe_name);
STRCPY(gettail(vimrun_location), "vimrun.exe");
if (mch_getperm(vimrun_location) >= 0)
{
if (*skiptowhite(vimrun_location) != NUL)
{
- /* Enclose path with white space in double quotes. */
+ // Enclose path with white space in double quotes.
mch_memmove(vimrun_location + 1, vimrun_location,
STRLEN(vimrun_location) + 1);
*vimrun_location = '"';
@@ -2131,9 +2132,9 @@ mch_init_g(void)
else if (executable_exists("vimrun.exe", NULL, TRUE))
s_dont_use_vimrun = FALSE;
- /* Don't give the warning for a missing vimrun.exe right now, but only
- * when vimrun was supposed to be used. Don't bother people that do
- * not need vimrun.exe. */
+ // Don't give the warning for a missing vimrun.exe right now, but only
+ // when vimrun was supposed to be used. Don't bother people that do
+ // not need vimrun.exe.
if (s_dont_use_vimrun)
need_vimrun_warning = TRUE;
}
@@ -2153,7 +2154,7 @@ mch_init_g(void)
}
-#endif /* FEAT_GUI_MSWIN */
+#endif // FEAT_GUI_MSWIN
#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)
@@ -2343,11 +2344,11 @@ SaveConsoleBuffer(
*/
ReadRegion.Top = Y;
ReadRegion.Bottom = Y + Y_incr - 1;
- if (!ReadConsoleOutputW(g_hConOut, /* output handle */
- cb->Buffer, /* our buffer */
- cb->BufferSize, /* dimensions of our buffer */
- BufferCoord, /* offset in our buffer */
- &ReadRegion)) /* region to save */
+ if (!ReadConsoleOutputW(g_hConOut, // output handle
+ cb->Buffer, // our buffer
+ cb->BufferSize, // dimensions of our buffer
+ BufferCoord, // offset in our buffer
+ &ReadRegion)) // region to save
{
VIM_CLEAR(cb->Buffer);
VIM_CLEAR(cb->Regions);
@@ -2417,11 +2418,11 @@ RestoreConsoleBuffer(
BufferCoord.X = cb->Regions[i].Left;
BufferCoord.Y = cb->Regions[i].Top;
WriteRegion = cb->Regions[i];
- if (!WriteConsoleOutputW(g_hConOut, /* output handle */
- cb->Buffer, /* our buffer */
- cb->BufferSize, /* dimensions of our buffer */
- BufferCoord, /* offset in our buffer */
- &WriteRegion)) /* region to restore */
+ if (!WriteConsoleOutputW(g_hConOut, // output handle
+ cb->Buffer, // our buffer
+ cb->BufferSize, // dimensions of our buffer
+ BufferCoord, // offset in our buffer
+ &WriteRegion)) // region to restore
return FALSE;
}
}
@@ -2438,13 +2439,13 @@ static ConsoleBuffer g_cbTermcap = { 0 };
# ifdef FEAT_TITLE
char g_szOrigTitle[256] = { 0 };
-HWND g_hWnd = NULL; /* also used in os_mswin.c */
+HWND g_hWnd = NULL; // also used in os_mswin.c
static HICON g_hOrigIconSmall = NULL;
static HICON g_hOrigIcon = NULL;
static HICON g_hVimIcon = NULL;
static BOOL g_fCanChangeIcon = FALSE;
-/* ICON* are not defined in VC++ 4.0 */
+// ICON* are not defined in VC++ 4.0
# ifndef ICON_SMALL
# define ICON_SMALL 0
# endif
@@ -2516,7 +2517,7 @@ SetConsoleIcon(
static void
SaveConsoleTitleAndIcon(void)
{
- /* Save the original title. */
+ // Save the original title.
if (!GetConsoleTitle(g_szOrigTitle, sizeof(g_szOrigTitle)))
return;
@@ -2531,12 +2532,12 @@ SaveConsoleTitleAndIcon(void)
if (g_hWnd == NULL)
return;
- /* Save the original console window icon. */
+ // Save the original console window icon.
GetConsoleIcon(g_hWnd, &g_hOrigIconSmall, &g_hOrigIcon);
if (g_hOrigIconSmall == NULL || g_hOrigIcon == NULL)
return;
- /* Extract the first icon contained in the Vim executable. */
+ // Extract the first icon contained in the Vim executable.
if (mch_icon_load((HANDLE *)&g_hVimIcon) == FAIL || g_hVimIcon == NULL)
g_hVimIcon = ExtractIcon(NULL, (LPCSTR)exe_name, 0);
if (g_hVimIcon != NULL)
@@ -2563,17 +2564,17 @@ mch_init_c(void)
extern int _fmode;
# endif
- /* Silently handle invalid parameters to CRT functions */
+ // Silently handle invalid parameters to CRT functions
SET_INVALID_PARAM_HANDLER;
- /* Let critical errors result in a failure, not in a dialog box. Required
- * for the timestamp test to work on removed floppies. */
+ // Let critical errors result in a failure, not in a dialog box. Required
+ // for the timestamp test to work on removed floppies.
SetErrorMode(SEM_FAILCRITICALERRORS);
- _fmode = O_BINARY; /* we do our own CR-LF translation */
+ _fmode = O_BINARY; // we do our own CR-LF translation
out_flush();
- /* Obtain handles for the standard Console I/O devices */
+ // Obtain handles for the standard Console I/O devices
if (read_cmd_fd == 0)
g_hConIn = GetStdHandle(STD_INPUT_HANDLE);
else
@@ -2581,11 +2582,11 @@ mch_init_c(void)
g_hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
# ifdef FEAT_RESTORE_ORIG_SCREEN
- /* Save the initial console buffer for later restoration */
+ // Save the initial console buffer for later restoration
SaveConsoleBuffer(&g_cbOrig);
g_attrCurrent = g_attrDefault = g_cbOrig.Info.wAttributes;
# else
- /* Get current text attributes */
+ // Get current text attributes
GetConsoleScreenBufferInfo(g_hConOut, &csbi);
g_attrCurrent = g_attrDefault = csbi.wAttributes;
# endif
@@ -2598,7 +2599,7 @@ mch_init_c(void)
g_color_index_fg = g_attrDefault & 0xf;
g_color_index_bg = (g_attrDefault >> 4) & 0xf;
- /* set termcap codes to current text attributes */
+ // set termcap codes to current text attributes
update_tcap(g_attrCurrent);
GetConsoleCursorInfo(g_hConOut, &g_cci);
@@ -2659,7 +2660,7 @@ mch_exit_c(int r)
if (g_fWindInitCalled)
settmode(TMODE_COOK);
- ml_close_all(TRUE); /* remove all memfiles */
+ ml_close_all(TRUE); // remove all memfiles
if (g_fWindInitCalled)
{
@@ -2697,7 +2698,7 @@ mch_exit_c(int r)
exit(r);
}
-#endif /* !FEAT_GUI_MSWIN */
+#endif // !FEAT_GUI_MSWIN
void
mch_init(void)
@@ -2740,7 +2741,7 @@ mch_check_win(
get_exe_name();
#if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)
- return OK; /* GUI always has a tty */
+ return OK; // GUI always has a tty
#else
# ifdef VIMDLL
if (gui.in_use)
@@ -2798,7 +2799,7 @@ mch_get_user_name(
char_u *s,
int len)
{
- WCHAR wszUserName[256 + 1]; /* UNLEN is 256 */
+ WCHAR wszUserName[256 + 1]; // UNLEN is 256
DWORD wcch = sizeof(wszUserName) / sizeof(WCHAR);
if (GetUserNameW(wszUserName, &wcch))
@@ -2977,7 +2978,7 @@ mch_ishidden(char_u *name)
int f = win32_getattrs(name);
if (f == -1)
- return FALSE; /* file does not exist at all */
+ return FALSE; // file does not exist at all
return (f & FILE_ATTRIBUTE_HIDDEN) != 0;
}
@@ -2992,7 +2993,7 @@ mch_isdir(char_u *name)
int f = win32_getattrs(name);
if (f == -1)
- return FALSE; /* file does not exist at all */
+ return FALSE; // file does not exist at all
return (f & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
@@ -3270,7 +3271,7 @@ mch_can_exe(char_u *name, char_u **path, int use_path)
{
if (p[0] == '.' && (p[1] == NUL || p[1] == ';'))
{
- /* A single "." means no extension is added. */
+ // A single "." means no extension is added.
buf[len] = NUL;
++p;
if (*p)
@@ -3297,9 +3298,9 @@ mch_nodetype(char_u *name)
int type;
WCHAR *wn;
- /* We can't open a file with a name "\\.\con" or "\\.\prn" and trying to
- * read from it later will cause Vim to hang. Thus return NODE_WRITABLE
- * here. */
+ // We can't open a file with a name "\\.\con" or "\\.\prn" and trying to
+ // read from it later will cause Vim to hang. Thus return NODE_WRITABLE
+ // here.
if (STRNCMP(name, "\\\\.\\", 4) == 0)
return NODE_WRITABLE;
@@ -3507,7 +3508,7 @@ handler_routine(
case CTRL_BREAK_EVENT:
g_fCBrkPressed = TRUE;
ctrl_break_was_pressed = TRUE;
- /* ReadConsoleInput is blocking, send a key event to continue. */
+ // ReadConsoleInput is blocking, send a key event to continue.
ir.EventType = KEY_EVENT;
ir.Event.KeyEvent.bKeyDown = TRUE;
ir.Event.KeyEvent.wRepeatCount = 1;
@@ -3518,7 +3519,7 @@ handler_routine(
WriteConsoleInput(g_hConIn, &ir, 1, &out);
return TRUE;
- /* fatal events: shut down gracefully */
+ // fatal events: shut down gracefully
case CTRL_CLOSE_EVENT:
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
@@ -3535,9 +3536,9 @@ handler_routine(
OutputDebugString(IObuff);
# endif
- preserve_exit(); /* output IObuff, preserve files and exit */
+ preserve_exit(); // output IObuff, preserve files and exit
- return TRUE; /* not reached */
+ return TRUE; // not reached
default:
return FALSE;
@@ -3569,8 +3570,8 @@ mch_settmode(int tmode)
cmodein |= ENABLE_MOUSE_INPUT;
cmodeout &= ~(
# ifdef FEAT_TERMGUICOLORS
- /* Do not turn off the ENABLE_PROCESSED_OUTPUT flag when using
- * VTP. */
+ // Do not turn off the ENABLE_PROCESSED_OUTPUT flag when using
+ // VTP.
((vtp_working) ? 0 : ENABLE_PROCESSED_OUTPUT) |
# else
ENABLE_PROCESSED_OUTPUT |
@@ -3578,7 +3579,7 @@ mch_settmode(int tmode)
ENABLE_WRAP_AT_EOL_OUTPUT);
bEnableHandler = TRUE;
}
- else /* cooked */
+ else // cooked
{
cmodein |= (ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT |
ENABLE_ECHO_INPUT);
@@ -3690,8 +3691,8 @@ ResizeConBufAndWindow(
int xSize,
int ySize)
{
- CONSOLE_SCREEN_BUFFER_INFO csbi; /* hold current console buffer info */
- SMALL_RECT srWindowRect; /* hold the new console size */
+ CONSOLE_SCREEN_BUFFER_INFO csbi; // hold current console buffer info
+ SMALL_RECT srWindowRect; // hold the new console size
COORD coordScreen;
COORD cursor;
static int resized = FALSE;
@@ -3704,10 +3705,10 @@ ResizeConBufAndWindow(
}
# endif
- /* get the largest size we can size the console window to */
+ // get the largest size we can size the console window to
coordScreen = GetLargestConsoleWindowSize(hConsole);
- /* define the new console window size and scroll position */
+ // define the new console window size and scroll position
srWindowRect.Left = srWindowRect.Top = (SHORT) 0;
srWindowRect.Right = (SHORT) (min(xSize, coordScreen.X) - 1);
srWindowRect.Bottom = (SHORT) (min(ySize, coordScreen.Y) - 1);
@@ -3772,7 +3773,7 @@ mch_set_shellsize(void)
if (gui.in_use)
return;
# endif
- /* Don't change window size while still starting up */
+ // Don't change window size while still starting up
if (suppress_winsize != 0)
{
suppress_winsize = 2;
@@ -3783,7 +3784,7 @@ mch_set_shellsize(void)
{
coordScreen = GetLargestConsoleWindowSize(g_hConOut);
- /* Clamp Rows and Columns to reasonable values */
+ // Clamp Rows and Columns to reasonable values
if (Rows > coordScreen.Y)
Rows = coordScreen.Y;
if (Columns > coordScreen.X)
@@ -3821,7 +3822,7 @@ mch_set_winsize_now(void)
}
suppress_winsize = 0;
}
-#endif /* FEAT_GUI_MSWIN */
+#endif // FEAT_GUI_MSWIN
static BOOL
vim_create_process(
@@ -3916,17 +3917,17 @@ mch_system_classic(char *cmd, int options)
si.cbReserved2 = 0;
si.lpReserved2 = NULL;
- /* Now, run the command */
+ // Now, run the command
vim_create_process(cmd, FALSE,
CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE,
&si, &pi, NULL, NULL);
- /* Wait for the command to terminate before continuing */
+ // Wait for the command to terminate before continuing
{
# ifdef FEAT_GUI
int delay = 1;
- /* Keep updating the window while waiting for the shell to finish. */
+ // Keep updating the window while waiting for the shell to finish.
for (;;)
{
MSG msg;
@@ -3941,9 +3942,9 @@ mch_system_classic(char *cmd, int options)
if (WaitForSingleObject(pi.hProcess, delay) != WAIT_TIMEOUT)
break;
- /* We start waiting for a very short time and then increase it, so
- * that we respond quickly when the process is quick, and don't
- * consume too much overhead when it's slow. */
+ // We start waiting for a very short time and then increase it, so
+ // that we respond quickly when the process is quick, and don't
+ // consume too much overhead when it's slow.
if (delay < 50)
delay += 10;
}
@@ -3951,15 +3952,15 @@ mch_system_classic(char *cmd, int options)
WaitForSingleObject(pi.hProcess, INFINITE);
# endif
- /* Get the command exit code */
+ // Get the command exit code
GetExitCodeProcess(pi.hProcess, &ret);
}
- /* Close the handles to the subprocess, so that it goes away */
+ // Close the handles to the subprocess, so that it goes away
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
- /* Try to get input focus back. Doesn't always work though. */
+ // Try to get input focus back. Doesn't always work though.
PostMessage(hwnd, WM_SETFOCUS, 0, 0);
return ret;
@@ -3988,7 +3989,7 @@ sub_process_writer(LPVOID param)
len = 0;
else if (lp[written] == NL)
{
- /* NL -> NUL translation */
+ // NL -> NUL translation
WriteFile(g_hChildStd_IN_Wr, "", 1, &len, NULL);
}
else
@@ -4000,8 +4001,8 @@ sub_process_writer(LPVOID param)
}
if (len == (int)l)
{
- /* Finished a line, add a NL, unless this line should not have
- * one. */
+ // Finished a line, add a NL, unless this line should not have
+ // one.
if (lnum != curbuf->b_op_end.lnum
|| (!curbuf->b_p_bin
&& curbuf->b_p_fixeol)
@@ -4024,13 +4025,13 @@ sub_process_writer(LPVOID param)
written += len;
}
- /* finished all the lines, close pipe */
+ // finished all the lines, close pipe
CloseHandle(g_hChildStd_IN_Wr);
return 0;
}
-# define BUFLEN 100 /* length for buffer, stolen from unix version */
+# define BUFLEN 100 // length for buffer, stolen from unix version
/*
* This function read from the children's stdout and write the
@@ -4050,17 +4051,17 @@ dump_pipe(int options,
DWORD toRead;
int repeatCount;
- /* we query the pipe to see if there is any data to read
- * to avoid to perform a blocking read */
- ret = PeekNamedPipe(g_hChildStd_OUT_Rd, /* pipe to query */
- NULL, /* optional buffer */
- 0, /* buffer size */
- NULL, /* number of read bytes */
- &availableBytes, /* available bytes total */
- NULL); /* byteLeft */
+ // we query the pipe to see if there is any data to read
+ // to avoid to perform a blocking read
+ ret = PeekNamedPipe(g_hChildStd_OUT_Rd, // pipe to query
+ NULL, // optional buffer
+ 0, // buffer size
+ NULL, // number of read bytes
+ &availableBytes, // available bytes total
+ NULL); // byteLeft
repeatCount = 0;
- /* We got real data in the pipe, read it */
+ // We got real data in the pipe, read it
while (ret != 0 && availableBytes > 0)
{
repeatCount++;
@@ -4068,7 +4069,7 @@ dump_pipe(int options,
toRead = availableBytes < toRead ? availableBytes : toRead;
ReadFile(g_hChildStd_OUT_Rd, buffer + *buffer_off, toRead , &len, NULL);
- /* If we haven't read anything, there is a problem */
+ // If we haven't read anything, there is a problem
if (len == 0)
break;
@@ -4076,8 +4077,8 @@ dump_pipe(int options,
if (options & SHELL_READ)
{
- /* Do NUL -> NL translation, append NL separated
- * lines to the current buffer. */
+ // Do NUL -> NL translation, append NL separated
+ // lines to the current buffer.
for (i = 0; i < len; ++i)
{
if (buffer[i] == NL)
@@ -4097,20 +4098,20 @@ dump_pipe(int options,
len += *buffer_off;
buffer[len] = NUL;
- /* Check if the last character in buffer[] is
- * incomplete, keep these bytes for the next
- * round. */
+ // Check if the last character in buffer[] is
+ // incomplete, keep these bytes for the next
+ // round.
for (p = buffer; p < buffer + len; p += l)
{
l = MB_CPTR2LEN(p);
if (l == 0)
- l = 1; /* NUL byte? */
+ l = 1; // NUL byte?
else if (MB_BYTE2LEN(*p) != l)
break;
}
- if (p == buffer) /* no complete character */
+ if (p == buffer) // no complete character
{
- /* avoid getting stuck at an illegal byte */
+ // avoid getting stuck at an illegal byte
if (len >= 12)
++p;
else
@@ -4159,34 +4160,34 @@ mch_system_piped(char *cmd, int options)
HANDLE g_hChildStd_OUT_Rd = NULL;
HANDLE g_hChildStd_OUT_Wr = NULL;
- char_u buffer[BUFLEN + 1]; /* reading buffer + size */
+ char_u buffer[BUFLEN + 1]; // reading buffer + size
DWORD len;
- /* buffer used to receive keys */
- char_u ta_buf[BUFLEN + 1]; /* TypeAHead */
- int ta_len = 0; /* valid bytes in ta_buf[] */
+ // buffer used to receive keys
+ char_u ta_buf[BUFLEN + 1]; // TypeAHead
+ int ta_len = 0; // valid bytes in ta_buf[]
DWORD i;
int c;
int noread_cnt = 0;
garray_T ga;
int delay = 1;
- DWORD buffer_off = 0; /* valid bytes in buffer[] */
+ DWORD buffer_off = 0; // valid bytes in buffer[]
char *p = NULL;
SECURITY_ATTRIBUTES saAttr;
- /* Set the bInheritHandle flag so pipe handles are inherited. */
+ // Set the bInheritHandle flag so pipe handles are inherited.
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
if ( ! CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &saAttr, 0)
- /* Ensure the read handle to the pipe for STDOUT is not inherited. */
+ // Ensure the read handle to the pipe for STDOUT is not inherited.
|| ! SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0)
- /* Create a pipe for the child process's STDIN. */
+ // Create a pipe for the child process's STDIN.
|| ! CreatePipe(&g_hChildStd_IN_Rd, &g_hChildStd_IN_Wr, &saAttr, 0)
- /* Ensure the write handle to the pipe for STDIN is not inherited. */
+ // Ensure the write handle to the pipe for STDIN is not inherited.
|| ! SetHandleInformation(g_hChildStd_IN_Wr, HANDLE_FLAG_INHERIT, 0) )
{
CloseHandle(g_hChildStd_IN_Rd);
@@ -4202,7 +4203,7 @@ mch_system_piped(char *cmd, int options)
si.lpTitle = NULL;
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
- /* set-up our file redirection */
+ // set-up our file redirection
si.hStdError = g_hChildStd_OUT_Wr;
si.hStdOutput = g_hChildStd_OUT_Wr;
si.hStdInput = g_hChildStd_IN_Rd;
@@ -4222,34 +4223,34 @@ mch_system_piped(char *cmd, int options)
p = cmd;
}
- /* Now, run the command.
- * About "Inherit handles" being TRUE: this command can be litigious,
- * handle inheritance was deactivated for pending temp file, but, if we
- * deactivate it, the pipes don't work for some reason. */
+ // Now, run the command.
+ // About "Inherit handles" being TRUE: this command can be litigious,
+ // handle inheritance was deactivated for pending temp file, but, if we
+ // deactivate it, the pipes don't work for some reason.
vim_create_process(p, TRUE, CREATE_DEFAULT_ERROR_MODE,
&si, &pi, NULL, NULL);
if (p != cmd)
vim_free(p);
- /* Close our unused side of the pipes */
+ // Close our unused side of the pipes
CloseHandle(g_hChildStd_IN_Rd);
CloseHandle(g_hChildStd_OUT_Wr);
if (options & SHELL_WRITE)
{
HANDLE thread = (HANDLE)
- _beginthreadex(NULL, /* security attributes */
- 0, /* default stack size */
- sub_process_writer, /* function to be executed */
- g_hChildStd_IN_Wr, /* parameter */
- 0, /* creation flag, start immediately */
- NULL); /* we don't care about thread id */
+ _beginthreadex(NULL, // security attributes
+ 0, // default stack size
+ sub_process_writer, // function to be executed
+ g_hChildStd_IN_Wr, // parameter
+ 0, // creation flag, start immediately
+ NULL); // we don't care about thread id
CloseHandle(thread);
g_hChildStd_IN_Wr = NULL;
}
- /* Keep updating the window while waiting for the shell to finish. */
+ // Keep updating the window while waiting for the shell to finish.
for (;;)
{
MSG msg;
@@ -4260,7 +4261,7 @@ mch_system_piped(char *cmd, int options)
pDispatchMessage(&msg);
}
- /* write pipe information in the window */
+ // write pipe information in the window
if ((options & (SHELL_READ|SHELL_WRITE))
# ifdef FEAT_GUI
|| gui.in_use
@@ -4280,8 +4281,8 @@ mch_system_piped(char *cmd, int options)
{
if (ta_len == 0)
{
- /* Get extra characters when we don't have any. Reset the
- * counter and timer. */
+ // Get extra characters when we don't have any. Reset the
+ // counter and timer.
noread_cnt = 0;
len = ui_inchar(ta_buf, BUFLEN, 10L, 0);
}
@@ -4295,8 +4296,8 @@ mch_system_piped(char *cmd, int options)
{
if (ta_buf[ta_len] == Ctrl_C)
{
- /* Learn what exit code is expected, for
- * now put 9 as SIGKILL */
+ // Learn what exit code is expected, for
+ // now put 9 as SIGKILL
TerminateProcess(pi.hProcess, 9);
}
if (ta_buf[ta_len] == Ctrl_D)
@@ -4306,7 +4307,7 @@ mch_system_piped(char *cmd, int options)
}
}
- /* replace K_BS by <BS> and K_DEL by <DEL> */
+ // replace K_BS by <BS> and K_DEL by <DEL>
for (i = ta_len; i < ta_len + len; ++i)
{
if (ta_buf[i] == CSI && len - i > 2)
@@ -4390,21 +4391,21 @@ mch_system_piped(char *cmd, int options)
++noread_cnt;
dump_pipe(options, g_hChildStd_OUT_Rd, &ga, buffer, &buffer_off);
- /* We start waiting for a very short time and then increase it, so
- * that we respond quickly when the process is quick, and don't
- * consume too much overhead when it's slow. */
+ // We start waiting for a very short time and then increase it, so
+ // that we respond quickly when the process is quick, and don't
+ // consume too much overhead when it's slow.
if (delay < 50)
delay += 10;
}
- /* Close the pipe */
+ // Close the pipe
CloseHandle(g_hChildStd_OUT_Rd);
if (g_hChildStd_IN_Wr != NULL)
CloseHandle(g_hChildStd_IN_Wr);
WaitForSingleObject(pi.hProcess, INFINITE);
- /* Get the command exit code */
+ // Get the command exit code
GetExitCodeProcess(pi.hProcess, &ret);
if (options & SHELL_READ)
@@ -4412,7 +4413,7 @@ mch_system_piped(char *cmd, int options)
if (ga.ga_len > 0)
{
append_ga_line(&ga);
- /* remember that the NL was missing */
+ // remember that the NL was missing
curbuf->b_no_eol_lnum = curwin->w_cursor.lnum;
}
else
@@ -4420,7 +4421,7 @@ mch_system_piped(char *cmd, int options)
ga_clear(&ga);
}
- /* Close the handles to the subprocess, so that it goes away */
+ // Close the handles to the subprocess, so that it goes away
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
@@ -4430,7 +4431,7 @@ mch_system_piped(char *cmd, int options)
static int
mch_system_g(char *cmd, int options)
{
- /* if we can pipe and the shelltemp option is off */
+ // if we can pipe and the shelltemp option is off
if (!p_stmp)
return mch_system_piped(cmd, options);
else
@@ -4495,7 +4496,7 @@ mch_system(char *cmd, int options)
static int
mch_call_shell_terminal(
char_u *cmd,
- int options UNUSED) /* SHELL_*, see vim.h */
+ int options UNUSED) // SHELL_*, see vim.h
{
jobopt_T opt;
char_u *newcmd = NULL;
@@ -4505,7 +4506,7 @@ mch_call_shell_terminal(
buf_T *buf;
job_T *job;
aco_save_T aco;
- oparg_T oa; /* operator arguments */
+ oparg_T oa; // operator arguments
if (cmd == NULL)
cmdlen = STRLEN(p_sh) + 1;
@@ -4540,7 +4541,7 @@ mch_call_shell_terminal(
job = term_getjob(buf->b_term);
++job->jv_refcount;
- /* Find a window to make "buf" curbuf. */
+ // Find a window to make "buf" curbuf.
aucmd_prepbuf(&aco, buf);
clear_oparg(&oa);
@@ -4548,8 +4549,8 @@ mch_call_shell_terminal(
{
if (oa.op_type == OP_NOP && oa.regname == NUL && !VIsual_active)
{
- /* If terminal_loop() returns OK we got a key that is handled
- * in Normal model. We don't do redrawing anyway. */
+ // If terminal_loop() returns OK we got a key that is handled
+ // in Normal model. We don't do redrawing anyway.
if (terminal_loop(TRUE) == OK)
normal_cmd(&oa, TRUE);
}
@@ -4561,7 +4562,7 @@ mch_call_shell_terminal(
job_unref(job);
- /* restore curwin/curbuf and a few other things */
+ // restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
wait_return(TRUE);
@@ -4578,14 +4579,14 @@ mch_call_shell_terminal(
int
mch_call_shell(
char_u *cmd,
- int options) /* SHELL_*, see vim.h */
+ int options) // SHELL_*, see vim.h
{
int x = 0;
int tmode = cur_tmode;
#ifdef FEAT_TITLE
WCHAR szShellTitle[512];
- /* Change the title to reflect that we are in a subshell. */
+ // Change the title to reflect that we are in a subshell.
if (GetConsoleTitleW(szShellTitle,
sizeof(szShellTitle)/sizeof(WCHAR) - 4) > 0)
{
@@ -4664,7 +4665,7 @@ mch_call_shell(
signal(SIGABRT, SIG_IGN);
if (options & SHELL_COOKED)
- settmode(TMODE_COOK); /* set to normal mode */
+ settmode(TMODE_COOK); // set to normal mode
if (cmd == NULL)
{
@@ -4672,12 +4673,12 @@ mch_call_shell(
}
else
{
- /* we use "command" or "cmd" to start the shell; slow but easy */
+ // we use "command" or "cmd" to start the shell; slow but easy
char_u *newcmd = NULL;
char_u *cmdbase = cmd;
long_u cmdlen;
- /* Skip a leading ", ( and "(. */
+ // Skip a leading ", ( and "(.
if (*cmdbase == '"' )
++cmdbase;
if (*cmdbase == '(')
@@ -4726,8 +4727,8 @@ mch_call_shell(
si.hStdError = si.hStdInput;
}
- /* Remove a trailing ", ) and )" if they have a match
- * at the start of the command. */
+ // Remove a trailing ", ) and )" if they have a match
+ // at the start of the command.
if (cmdbase > cmd)
{
p = cmdbase + STRLEN(cmdbase);
@@ -4760,7 +4761,7 @@ mch_call_shell(
(char_u *)"|", '^', FALSE);
if (subcmd != NULL)
{
- /* make "cmd.exe /c arguments" */
+ // make "cmd.exe /c arguments"
cmdlen = STRLEN(cmd_shell) + STRLEN(subcmd) + 5;
newcmd = alloc(cmdlen);
if (newcmd != NULL)
@@ -4799,10 +4800,10 @@ mch_call_shell(
if (si.dwFlags == STARTF_USESTDHANDLES && si.hStdInput != NULL)
{
- /* Close the handle to \\.\NUL created above. */
+ // Close the handle to \\.\NUL created above.
CloseHandle(si.hStdInput);
}
- /* Close the handles to the subprocess, so that it goes away */
+ // Close the handles to the subprocess, so that it goes away
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
@@ -4871,9 +4872,9 @@ mch_call_shell(
}
if (tmode == TMODE_RAW)
- settmode(TMODE_RAW); /* set to raw mode */
+ settmode(TMODE_RAW); // set to raw mode
- /* Print the return value, unless "vimrun" was used. */
+ // Print the return value, unless "vimrun" was used.
if (x != 0 && !(options & SHELL_SILENT) && !emsg_silent
#if defined(FEAT_GUI_MSWIN)
&& ((gui.in_use || gui.starting) ?
@@ -4938,7 +4939,7 @@ win32_build_env(dict_T *env, garray_T *gap, int is_terminal)
long_u todo = env != NULL ? env->dv_hashtab.ht_used : 0;
LPVOID base = GetEnvironmentStringsW();
- /* for last \0 */
+ // for last \0
if (ga_grow(gap, 1) == FAIL)
return;
@@ -4946,7 +4947,7 @@ win32_build_env(dict_T *env, garray_T *gap, int is_terminal)
{
WCHAR *p = (WCHAR*) base;
- /* for last \0 */
+ // for last \0
if (ga_grow(gap, 1) == FAIL)
return;
@@ -5228,8 +5229,8 @@ mch_job_start(char *cmd, job_T *job, jobopt_T *options)
if (!AssignProcessToJobObject(jo, pi.hProcess))
{
- /* if failing, switch the way to terminate
- * process with TerminateProcess. */
+ // if failing, switch the way to terminate
+ // process with TerminateProcess.
CloseHandle(jo);
jo = NULL;
}
@@ -5373,7 +5374,7 @@ mch_signal_job(job_T *job, char_u *how)
if (STRCMP(how, "term") == 0 || STRCMP(how, "kill") == 0 || *how == NUL)
{
- /* deadly signal */
+ // deadly signal
if (job->jv_job_object != NULL)
{
if (job->jv_channel != NULL && job->jv_channel->ch_anonymous_pipe)
@@ -5523,7 +5524,7 @@ termcap_mode_end(void)
g_fTermcapMode = FALSE;
}
-#endif /* FEAT_GUI_MSWIN */
+#endif // FEAT_GUI_MSWIN
#if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)
@@ -5532,7 +5533,7 @@ mch_write(
char_u *s UNUSED,
int len UNUSED)
{
- /* never used */
+ // never used
}
#else
@@ -5960,7 +5961,7 @@ visual_bell(void)
FillConsoleOutputAttribute(g_hConOut, attrFlash, Rows * Columns,
coordOrigin, &dwDummy);
- Sleep(15); /* wait for 15 msec */
+ Sleep(15); // wait for 15 msec
if (!USE_VTP)
WriteConsoleOutputAttribute(g_hConOut, oldattrs, Rows * Columns,
coordOrigin, &dwDummy);
@@ -6077,11 +6078,11 @@ mch_write(
return;
}
- /* translate ESC | sequences into faked bios calls */
+ // translate ESC | sequences into faked bios calls
while (len--)
{
- /* optimization: use one single write_chars for runs of text,
- * rather than once per character It ain't curses, but it helps. */
+ // optimization: use one single write_chars for runs of text,
+ // rather than once per character It ain't curses, but it helps.
DWORD prefix = (DWORD)strcspn((char *)s, "\n\r\b\a\033");
if (p_wd)
@@ -6109,7 +6110,7 @@ mch_write(
}
else if (s[0] == '\n')
{
- /* \n, newline: go to the beginning of the next line or scroll */
+ // \n, newline: go to the beginning of the next line or scroll
if (g_coord.Y == g_srScrollRegion.Bottom)
{
scroll(1);
@@ -6127,7 +6128,7 @@ mch_write(
}
else if (s[0] == '\r')
{
- /* \r, carriage return: go to beginning of line */
+ // \r, carriage return: go to beginning of line
gotoxy(g_srScrollRegion.Left+1, g_coord.Y + 1);
# ifdef MCH_WRITE_DUMP
if (fdDump)
@@ -6137,7 +6138,7 @@ mch_write(
}
else if (s[0] == '\b')
{
- /* \b, backspace: move cursor one position left */
+ // \b, backspace: move cursor one position left
if (g_coord.X > g_srScrollRegion.Left)
g_coord.X--;
else if (g_coord.Y > g_srScrollRegion.Top)
@@ -6154,7 +6155,7 @@ mch_write(
}
else if (s[0] == '\a')
{
- /* \a, bell */
+ // \a, bell
MessageBeep(0xFFFFFFFF);
# ifdef MCH_WRITE_DUMP
if (fdDump)
@@ -6332,7 +6333,7 @@ mch_write(
}
else
{
- /* Write a single character */
+ // Write a single character
DWORD nWritten;
nWritten = write_chars(s, 1);
@@ -6356,7 +6357,7 @@ mch_write(
# endif
}
-#endif /* FEAT_GUI_MSWIN */
+#endif // FEAT_GUI_MSWIN
/*
@@ -6368,12 +6369,12 @@ mch_delay(
int ignoreinput UNUSED)
{
#if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)
- Sleep((int)msec); /* never wait for input */
-#else /* Console */
+ Sleep((int)msec); // never wait for input
+#else // Console
# ifdef VIMDLL
if (gui.in_use)
{
- Sleep((int)msec); /* never wait for input */
+ Sleep((int)msec); // never wait for input
return;
}
# endif
@@ -6383,7 +6384,7 @@ mch_delay(
{
int towait = p_mzq;
- /* if msec is large enough, wait by portions in p_mzq */
+ // if msec is large enough, wait by portions in p_mzq
while (msec > 0)
{
mzvim_check_threads();
@@ -6451,7 +6452,7 @@ mch_breakcheck(int force UNUSED)
#endif
}
-/* physical RAM to leave for the OS */
+// physical RAM to leave for the OS
#define WINNT_RESERVE_BYTES (256*1024*1024)
/*
@@ -6462,21 +6463,21 @@ mch_total_mem(int special UNUSED)
{
MEMORYSTATUSEX ms;
- /* Need to use GlobalMemoryStatusEx() when there is more memory than
- * what fits in 32 bits. */
+ // Need to use GlobalMemoryStatusEx() when there is more memory than
+ // what fits in 32 bits.
ms.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&ms);
if (ms.ullAvailVirtual < ms.ullTotalPhys)
{
- /* Process address space fits in physical RAM, use all of it. */
+ // Process address space fits in physical RAM, use all of it.
return (long_u)(ms.ullAvailVirtual / 1024);
}
if (ms.ullTotalPhys <= WINNT_RESERVE_BYTES)
{
- /* Catch old NT box or perverse hardware setup. */
+ // Catch old NT box or perverse hardware setup.
return (long_u)((ms.ullTotalPhys / 2) / 1024);
}
- /* Use physical RAM less reserve for OS + data. */
+ // Use physical RAM less reserve for OS + data.
return (long_u)((ms.ullTotalPhys - WINNT_RESERVE_BYTES) / 1024);
}
@@ -6610,7 +6611,7 @@ default_shell(void)
mch_access(char *n, int p)
{
HANDLE hFile;
- int retval = -1; /* default: fail */
+ int retval = -1; // default: fail
WCHAR *wn;
wn = enc_to_utf16((char_u *)n, NULL);
@@ -6623,8 +6624,8 @@ mch_access(char *n, int p)
if (p & R_OK)
{
- /* Read check is performed by seeing if we can do a find file on
- * the directory for any file. */
+ // Read check is performed by seeing if we can do a find file on
+ // the directory for any file.
int i;
WIN32_FIND_DATAW d;
@@ -6644,10 +6645,10 @@ mch_access(char *n, int p)
if (p & W_OK)
{
- /* Trying to create a temporary file in the directory should catch
- * directories on read-only network shares. However, in
- * directories whose ACL allows writes but denies deletes will end
- * up keeping the temporary file :-(. */
+ // Trying to create a temporary file in the directory should catch
+ // directories on read-only network shares. However, in
+ // directories whose ACL allows writes but denies deletes will end
+ // up keeping the temporary file :-(.
if (!GetTempFileNameW(wn, L"VIM", 0, TempNameW))
goto getout;
else
@@ -6659,8 +6660,8 @@ mch_access(char *n, int p)
// Don't consider a file read-only if another process has opened it.
DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE;
- /* Trying to open the file for the required access does ACL, read-only
- * network share, and file attribute checks. */
+ // Trying to open the file for the required access does ACL, read-only
+ // network share, and file attribute checks.
DWORD access_mode = ((p & W_OK) ? GENERIC_WRITE : 0)
| ((p & R_OK) ? GENERIC_READ : 0);
@@ -6671,7 +6672,7 @@ mch_access(char *n, int p)
CloseHandle(hFile);
}
- retval = 0; /* success */
+ retval = 0; // success
getout:
vim_free(wn);
return retval;
@@ -6705,8 +6706,8 @@ mch_fopen(const char *name, const char *mode)
FILE *f = NULL;
#if defined(DEBUG) && _MSC_VER >= 1400
- /* Work around an annoying assertion in the Microsoft debug CRT
- * when mode's text/binary setting doesn't match _get_fmode(). */
+ // Work around an annoying assertion in the Microsoft debug CRT
+ // when mode's text/binary setting doesn't match _get_fmode().
char newMode = mode[strlen(mode) - 1];
int oldMode = 0;
@@ -6770,10 +6771,10 @@ copy_substream(HANDLE sh, void *context, WCHAR *to, WCHAR *substream, long len)
DWORD readcnt, written;
char buf[4096];
- /* Copy block of bytes at a time. Abort when something goes wrong. */
+ // Copy block of bytes at a time. Abort when something goes wrong.
for (done = 0; done < len; done += written)
{
- /* (size_t) cast for Borland C 5.5 */
+ // (size_t) cast for Borland C 5.5
todo = (DWORD)((size_t)(len - done) > sizeof(buf) ? sizeof(buf)
: (size_t)(len - done));
if (!BackupRead(sh, (LPBYTE)buf, todo, &readcnt,
@@ -6806,22 +6807,22 @@ copy_infostreams(char_u *from, char_u *to)
DWORD lo, hi;
int len;
- /* Convert the file names to wide characters. */
+ // Convert the file names to wide characters.
fromw = enc_to_utf16(from, NULL);
tow = enc_to_utf16(to, NULL);
if (fromw != NULL && tow != NULL)
{
- /* Open the file for reading. */
+ // Open the file for reading.
sh = CreateFileW(fromw, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (sh != INVALID_HANDLE_VALUE)
{
- /* Use BackupRead() to find the info streams. Repeat until we
- * have done them all.*/
+ // Use BackupRead() to find the info streams. Repeat until we
+ // have done them all.
for (;;)
{
- /* Get the header to find the length of the stream name. If
- * the "readcount" is zero we have done all info streams. */
+ // Get the header to find the length of the stream name. If
+ // the "readcount" is zero we have done all info streams.
ZeroMemory(&sid, sizeof(WIN32_STREAM_ID));
headersize = (int)((char *)&sid.cStreamName - (char *)&sid.dwStreamId);
if (!BackupRead(sh, (LPBYTE)&sid, headersize,
@@ -6829,22 +6830,22 @@ copy_infostreams(char_u *from, char_u *to)
|| readcount == 0)
break;
- /* We only deal with streams that have a name. The normal
- * file data appears to be without a name, even though docs
- * suggest it is called "::$DATA". */
+ // We only deal with streams that have a name. The normal
+ // file data appears to be without a name, even though docs
+ // suggest it is called "::$DATA".
if (sid.dwStreamNameSize > 0)
{
- /* Read the stream name. */
+ // Read the stream name.
if (!BackupRead(sh, (LPBYTE)streamname,
sid.dwStreamNameSize,
&readcount, FALSE, FALSE, &context))
break;
- /* Copy an info stream with a name ":anything:$DATA".
- * Skip "::$DATA", it has no stream name (examples suggest
- * it might be used for the normal file contents).
- * Note that BackupRead() counts bytes, but the name is in
- * wide characters. */
+ // Copy an info stream with a name ":anything:$DATA".
+ // Skip "::$DATA", it has no stream name (examples suggest
+ // it might be used for the normal file contents).
+ // Note that BackupRead() counts bytes, but the name is in
+ // wide characters.
len = readcount / sizeof(WCHAR);
streamname[len] = 0;
if (len > 7 && wcsicmp(streamname + len - 6,
@@ -6856,14 +6857,14 @@ copy_infostreams(char_u *from, char_u *to)
}
}
- /* Advance to the next stream. We might try seeking too far,
- * but BackupSeek() doesn't skip over stream borders, thus
- * that's OK. */
+ // Advance to the next stream. We might try seeking too far,
+ // but BackupSeek() doesn't skip over stream borders, thus
+ // that's OK.
(void)BackupSeek(sh, sid.Size.u.LowPart, sid.Size.u.HighPart,
&lo, &hi, &context);
}
- /* Clear the context. */
+ // Clear the context.
(void)BackupRead(sh, NULL, 0, &readcount, TRUE, FALSE, &context);
CloseHandle(sh);
@@ -6881,7 +6882,7 @@ copy_infostreams(char_u *from, char_u *to)
int
mch_copy_file_attribute(char_u *from, char_u *to)
{
- /* File streams only work on Windows NT and later. */
+ // File streams only work on Windows NT and later.
copy_infostreams(from, to);
return 0;
}
@@ -6892,7 +6893,7 @@ mch_copy_file_attribute(char_u *from, char_u *to)
* Written by Benjamin Peterson.
*/
-/* These magic numbers are from the MS header files */
+// These magic numbers are from the MS header files
# define MIN_STACK_WINNT 2
/*
@@ -6912,26 +6913,25 @@ myresetstkoflw(void)
DWORD nPageSize;
DWORD dummy;
- /* We need to know the system page size. */
+ // We need to know the system page size.
GetSystemInfo(&si);
nPageSize = si.dwPageSize;
- /* ...and the current stack pointer */
+ // ...and the current stack pointer
pStackPtr = (BYTE*)_alloca(1);
- /* ...and the base of the stack. */
+ // ...and the base of the stack.
if (VirtualQuery(pStackPtr, &mbi, sizeof mbi) == 0)
return 0;
pStackBase = (BYTE*)mbi.AllocationBase;
- /* ...and the page thats min_stack_req pages away from stack base; this is
- * the lowest page we could use. */
+ // ...and the page thats min_stack_req pages away from stack base; this is
+ // the lowest page we could use.
pLowestPossiblePage = pStackBase + MIN_STACK_WINNT * nPageSize;
{
- /* We want the first committed page in the stack Start at the stack
- * base and move forward through memory until we find a committed block.
- */
+ // We want the first committed page in the stack Start at the stack
+ // base and move forward through memory until we find a committed block.
BYTE *pBlock = pStackBase;
for (;;)
@@ -6945,21 +6945,21 @@ myresetstkoflw(void)
break;
}
- /* mbi now describes the first committed block in the stack. */
+ // mbi now describes the first committed block in the stack.
if (mbi.Protect & PAGE_GUARD)
return 1;
- /* decide where the guard page should start */
+ // decide where the guard page should start
if ((long_u)(mbi.BaseAddress) < (long_u)pLowestPossiblePage)
pGuardPage = pLowestPossiblePage;
else
pGuardPage = (BYTE*)mbi.BaseAddress;
- /* allocate the guard page */
+ // allocate the guard page
if (!VirtualAlloc(pGuardPage, nPageSize, MEM_COMMIT, PAGE_READWRITE))
return 0;
- /* apply the guard attribute to the page */
+ // apply the guard attribute to the page
if (!VirtualProtect(pGuardPage, nPageSize, PAGE_READWRITE | PAGE_GUARD,
&dummy))
return 0;
@@ -6978,15 +6978,15 @@ static LPWSTR *ArglistW = NULL;
static int global_argc = 0;
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_file_diff_mode = FALSE; /* file name was with diff mode */
+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_file_diff_mode = FALSE; // file name was with diff mode
static int used_alist_count = 0;
@@ -7014,13 +7014,13 @@ get_cmd_argsW(char ***argvp)
{
int len;
- /* Convert each Unicode argument to the current codepage. */
+ // Convert each Unicode argument to the current codepage.
WideCharToMultiByte_alloc(GetACP(), 0,
ArglistW[i], (int)wcslen(ArglistW[i]) + 1,
(LPSTR *)&argv[i], &len, 0, 0);
if (argv[i] == NULL)
{
- /* Out of memory, clear everything. */
+ // Out of memory, clear everything.
while (i > 0)
free(argv[--i]);
free(argv);
@@ -7102,12 +7102,11 @@ fix_arg_enc(void)
char_u *str;
int *fnum_list;
- /* 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.
- */
+ // 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 != nArgsW
|| ArglistW == NULL
|| used_file_indexes == NULL
@@ -7115,17 +7114,17 @@ fix_arg_enc(void)
|| used_alist_count != GARGCOUNT)
return;
- /* Remember the buffer numbers for the arguments. */
+ // Remember the buffer numbers for the arguments.
fnum_list = ALLOC_MULT(int, GARGCOUNT);
if (fnum_list == NULL)
- return; /* out of memory */
+ return; // out of memory
for (i = 0; i < GARGCOUNT; ++i)
fnum_list[i] = GARGLIST[i].ae_fnum;
- /* Clear the argument list. Make room for the new arguments. */
+ // 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 */
+ return; // out of memory
for (i = 0; i < used_file_count; ++i)
{
@@ -7136,8 +7135,8 @@ fix_arg_enc(void)
int literal = used_file_literal;
#ifdef FEAT_DIFF
- /* When using diff mode may need to concatenate file name to
- * directory name. Just like it's done in main(). */
+ // When using diff mode may need to concatenate file name to
+ // directory name. Just like it's done in main().
if (used_file_diff_mode && mch_isdir(str) && GARGCOUNT > 0
&& !mch_isdir(alist_name(&GARGLIST[0])))
{
@@ -7151,13 +7150,13 @@ fix_arg_enc(void)
}
}
#endif
- /* Re-use the old buffer by renaming it. When not using literal
- * names it's done by alist_expand() below. */
+ // Re-use the old buffer by renaming it. When not using literal
+ // names it's done by alist_expand() below.
if (used_file_literal)
buf_set_name(fnum_list[i], str);
- /* Check backtick literal. backtick literal is already expanded in
- * main.c, so this part add str as literal. */
+ // Check backtick literal. backtick literal is already expanded in
+ // main.c, so this part add str as literal.
if (literal == FALSE)
{
size_t len = STRLEN(str);
@@ -7171,13 +7170,13 @@ fix_arg_enc(void)
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).
- * Also, unset wildignore to not be influenced by this option.
- * The arguments specified in command-line should be kept even if
- * encoding options were changed. */
+ // 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).
+ // Also, unset wildignore to not be influenced by this option.
+ // The arguments specified in command-line should be kept even if
+ // encoding options were changed.
do_cmdline_cmd((char_u *)":let SaVe_ISF = &isf|set isf+=(,)");
do_cmdline_cmd((char_u *)":let SaVe_WIG = &wig|set wig=");
alist_expand(fnum_list, used_alist_count);
@@ -7185,8 +7184,8 @@ fix_arg_enc(void)
do_cmdline_cmd((char_u *)":let &wig = SaVe_WIG|unlet SaVe_WIG");
}
- /* 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 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");
@@ -7306,7 +7305,7 @@ vtp_init(void)
COLORREF fg, bg;
# endif
- /* Use functions supported from Vista */
+ // Use functions supported from Vista
hKerneldll = GetModuleHandle("kernel32.dll");
if (hKerneldll != NULL)
{
@@ -7377,7 +7376,7 @@ vtp_sgr_bulks(
int *args
)
{
- /* 2('\033[') + 4('255.') * 16 + NUL */
+ // 2('\033[') + 4('255.') * 16 + NUL
char_u buf[2 + (4 * 16) + 1];
char_u *p;
int i;