summaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-05 20:28:46 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-05 20:28:46 +0100
commit0f8737355d291679659579a48db1861b88970293 (patch)
tree6b8a8f4e9afe52e72c4039e404f3f4598e04d16a /src/os_unix.c
parent6e0ce171e19d0118ecd7c2b16e2a1bd50aa76013 (diff)
downloadvim-git-0f8737355d291679659579a48db1861b88970293.tar.gz
patch 8.1.2393: using old C style commentsv8.1.2393
Problem: Using old C style comments. Solution: Use // comments where appropriate.
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c1353
1 files changed, 675 insertions, 678 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index fd50eb316..90c5aed97 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -24,7 +24,7 @@
# include "if_mzsch.h"
#endif
-#include "os_unixx.h" /* unix includes for os_unix.c only */
+#include "os_unixx.h" // unix includes for os_unix.c only
#ifdef USE_XSMP
# include <X11/SM/SMlib.h>
@@ -51,8 +51,8 @@ static int selinux_enabled = -1;
#ifdef __CYGWIN__
# ifndef MSWIN
# include <cygwin/version.h>
-# include <sys/cygwin.h> /* for cygwin_conv_to_posix_path() and/or
- * for cygwin_conv_path() */
+# include <sys/cygwin.h> // for cygwin_conv_to_posix_path() and/or
+ // for cygwin_conv_path()
# ifdef FEAT_CYGWIN_WIN32_CLIPBOARD
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
@@ -63,11 +63,10 @@ static int selinux_enabled = -1;
#ifdef FEAT_MOUSE_GPM
# include <gpm.h>
-/* <linux/keyboard.h> contains defines conflicting with "keymap.h",
- * I just copied relevant defines here. A cleaner solution would be to put gpm
- * code into separate file and include there linux/keyboard.h
- */
-/* #include <linux/keyboard.h> */
+// <linux/keyboard.h> contains defines conflicting with "keymap.h",
+// I just copied relevant defines here. A cleaner solution would be to put gpm
+// code into separate file and include there linux/keyboard.h
+// #include <linux/keyboard.h>
# define KG_SHIFT 0
# define KG_CTRL 2
# define KG_ALT 3
@@ -96,7 +95,7 @@ static RETSIGTYPE sig_sysmouse SIGPROTOARG;
* end of autoconf section. To be extended...
*/
-/* Are the following #ifdefs still required? And why? Is that for X11? */
+// Are the following #ifdefs still required? And why? Is that for X11?
#if defined(ESIX) || defined(M_UNIX) && !defined(SCO)
# ifdef SIGWINCH
@@ -107,7 +106,7 @@ static RETSIGTYPE sig_sysmouse SIGPROTOARG;
# endif
#endif
-#if defined(SIGWINDOW) && !defined(SIGWINCH) /* hpux 9.01 has it */
+#if defined(SIGWINDOW) && !defined(SIGWINCH) // hpux 9.01 has it
# define SIGWINCH SIGWINDOW
#endif
@@ -157,7 +156,7 @@ static int RealWaitForChar(int, long, int *, int *interrupted);
#ifdef FEAT_XCLIPBOARD
static int do_xterm_trace(void);
-# define XT_TRACE_DELAY 50 /* delay for xterm tracing */
+# define XT_TRACE_DELAY 50 // delay for xterm tracing
#endif
static void handle_resize(void);
@@ -175,7 +174,7 @@ static RETSIGTYPE catch_sigpwr SIGPROTOARG;
&& defined(FEAT_TITLE) && !defined(FEAT_GUI_GTK)
# define SET_SIG_ALARM
static RETSIGTYPE sig_alarm SIGPROTOARG;
-/* volatile because it is used in signal handler sig_alarm(). */
+// volatile because it is used in signal handler sig_alarm().
static volatile sig_atomic_t sig_alarm_called;
#endif
static RETSIGTYPE deathtrap SIGPROTOARG;
@@ -201,29 +200,29 @@ static int save_patterns(int num_pat, char_u **pat, int *num_file, char_u ***fil
# define SIG_ERR ((RETSIGTYPE (*)())-1)
#endif
-/* volatile because it is used in signal handler sig_winch(). */
+// volatile because it is used in signal handler sig_winch().
static volatile sig_atomic_t do_resize = FALSE;
static char_u *extra_shell_arg = NULL;
static int show_shell_mess = TRUE;
-/* volatile because it is used in signal handler deathtrap(). */
-static volatile sig_atomic_t deadly_signal = 0; /* The signal we caught */
-/* volatile because it is used in signal handler deathtrap(). */
-static volatile sig_atomic_t in_mch_delay = FALSE; /* sleeping in mch_delay() */
+// volatile because it is used in signal handler deathtrap().
+static volatile sig_atomic_t deadly_signal = 0; // The signal we caught
+// volatile because it is used in signal handler deathtrap().
+static volatile sig_atomic_t in_mch_delay = FALSE; // sleeping in mch_delay()
#if defined(FEAT_JOB_CHANNEL) && !defined(USE_SYSTEM)
static int dont_check_job_ended = 0;
#endif
-static int curr_tmode = TMODE_COOK; /* contains current terminal mode */
+static int curr_tmode = TMODE_COOK; // contains current terminal mode
#ifdef USE_XSMP
typedef struct
{
- SmcConn smcconn; /* The SM connection ID */
- IceConn iceconn; /* The ICE connection ID */
- char *clientid; /* The client ID for the current smc session */
- Bool save_yourself; /* If we're in the middle of a save_yourself */
- Bool shutdown; /* If we're in shutdown mode */
+ SmcConn smcconn; // The SM connection ID
+ IceConn iceconn; // The ICE connection ID
+ char *clientid; // The client ID for the current smc session
+ Bool save_yourself; // If we're in the middle of a save_yourself
+ Bool shutdown; // If we're in shutdown mode
} xsmp_config_T;
static xsmp_config_T xsmp;
@@ -243,9 +242,9 @@ static xsmp_config_T xsmp;
static struct signalinfo
{
- int sig; /* Signal number, eg. SIGSEGV etc */
- char *name; /* Signal name (not char_u!). */
- char deadly; /* Catch as a deadly signal? */
+ int sig; // Signal number, eg. SIGSEGV etc
+ char *name; // Signal name (not char_u!).
+ char deadly; // Catch as a deadly signal?
} signal_info[] =
{
#ifdef SIGHUP
@@ -273,14 +272,14 @@ static struct signalinfo
{SIGBUS, "BUS", TRUE},
#endif
#if defined(SIGSEGV) && !defined(FEAT_MZSCHEME)
- /* MzScheme uses SEGV in its garbage collector */
+ // MzScheme uses SEGV in its garbage collector
{SIGSEGV, "SEGV", TRUE},
#endif
#ifdef SIGSYS
{SIGSYS, "SYS", TRUE},
#endif
#ifdef SIGALRM
- {SIGALRM, "ALRM", FALSE}, /* Perl's alarm() can trigger it */
+ {SIGALRM, "ALRM", FALSE}, // Perl's alarm() can trigger it
#endif
#ifdef SIGTERM
{SIGTERM, "TERM", TRUE},
@@ -289,8 +288,8 @@ static struct signalinfo
{SIGVTALRM, "VTALRM", TRUE},
#endif
#if defined(SIGPROF) && !defined(FEAT_MZSCHEME) && !defined(WE_ARE_PROFILING)
- /* MzScheme uses SIGPROF for its own needs; On Linux with profiling
- * this makes Vim exit. WE_ARE_PROFILING is defined in Makefile. */
+ // MzScheme uses SIGPROF for its own needs; On Linux with profiling
+ // this makes Vim exit. WE_ARE_PROFILING is defined in Makefile.
{SIGPROF, "PROF", TRUE},
#endif
#ifdef SIGXCPU
@@ -303,7 +302,7 @@ static struct signalinfo
{SIGUSR1, "USR1", TRUE},
#endif
#if defined(SIGUSR2) && !defined(FEAT_SYSMOUSE)
- /* Used for sysmouse handling */
+ // Used for sysmouse handling
{SIGUSR2, "USR2", TRUE},
#endif
#ifdef SIGINT
@@ -337,7 +336,7 @@ mch_chdir(char *path)
# endif
}
-/* Why is NeXT excluded here (and not in os_unixx.h)? */
+// Why is NeXT excluded here (and not in os_unixx.h)?
#if defined(ECHOE) && defined(ICANON) \
&& (defined(HAVE_TERMIO_H) || defined(HAVE_TERMIOS_H)) \
&& !defined(__NeXT__)
@@ -351,7 +350,7 @@ mch_chdir(char *path)
mch_write(char_u *s, int len)
{
vim_ignored = (int)write(1, (char *)s, len);
- if (p_wd) /* Unix is too fast, slow down a bit more */
+ if (p_wd) // Unix is too fast, slow down a bit more
RealWaitForChar(read_cmd_fd, p_wd, NULL, NULL);
}
@@ -382,7 +381,7 @@ resize_func(int check_only)
mch_inchar(
char_u *buf,
int maxlen,
- long wtime, /* don't use "time", MIPS cannot handle it */
+ long wtime, // don't use "time", MIPS cannot handle it
int tb_change_cnt)
{
return inchar_loop(buf, maxlen, wtime, tb_change_cnt,
@@ -439,11 +438,11 @@ mch_check_messages(void)
mch_total_mem(int special UNUSED)
{
long_u mem = 0;
- long_u shiftright = 10; /* how much to shift "mem" right for Kbyte */
+ long_u shiftright = 10; // how much to shift "mem" right for Kbyte
# ifdef MACOS_X
{
- /* Mac (Darwin) way of getting the amount of RAM available */
+ // Mac (Darwin) way of getting the amount of RAM available
mach_port_t host = mach_host_self();
kern_return_t kret;
# ifdef HOST_VM_INFO64
@@ -460,7 +459,7 @@ mch_total_mem(int special UNUSED)
(host_info_t)&vm_stat, &count);
# endif
if (kret == KERN_SUCCESS)
- /* get the amount of user memory by summing each usage */
+ // get the amount of user memory by summing each usage
mem = (long_u)(vm_stat.free_count + vm_stat.active_count
+ vm_stat.inactive_count
# ifdef MAC_OS_X_VERSION_10_9
@@ -474,13 +473,13 @@ mch_total_mem(int special UNUSED)
# ifdef HAVE_SYSCTL
if (mem == 0)
{
- /* BSD way of getting the amount of RAM available. */
+ // BSD way of getting the amount of RAM available.
int mib[2];
size_t len = sizeof(long_u);
# ifdef HW_USERMEM64
long_u physmem;
# else
- /* sysctl() may return 32 bit or 64 bit, accept both */
+ // sysctl() may return 32 bit or 64 bit, accept both
union {
int_u u32;
long_u u64;
@@ -512,11 +511,11 @@ mch_total_mem(int special UNUSED)
{
struct sysinfo sinfo;
- /* Linux way of getting amount of RAM available */
+ // Linux way of getting amount of RAM available
if (sysinfo(&sinfo) == 0)
{
# ifdef HAVE_SYSINFO_MEM_UNIT
- /* avoid overflow as much as possible */
+ // avoid overflow as much as possible
while (shiftright > 0 && (sinfo.mem_unit & 1) == 0)
{
sinfo.mem_unit = sinfo.mem_unit >> 1;
@@ -535,12 +534,12 @@ mch_total_mem(int special UNUSED)
{
long pagesize, pagecount;
- /* Solaris way of getting amount of RAM available */
+ // Solaris way of getting amount of RAM available
pagesize = sysconf(_SC_PAGESIZE);
pagecount = sysconf(_SC_PHYS_PAGES);
if (pagesize > 0 && pagecount > 0)
{
- /* avoid overflow as much as possible */
+ // avoid overflow as much as possible
while (shiftright > 0 && (pagesize & 1) == 0)
{
pagesize = (long_u)pagesize >> 1;
@@ -551,8 +550,8 @@ mch_total_mem(int special UNUSED)
}
# endif
- /* Return the minimum of the physical memory and the user limit, because
- * using more than the user limit may cause Vim to be terminated. */
+ // Return the minimum of the physical memory and the user limit, because
+ // using more than the user limit may cause Vim to be terminated.
# if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT)
{
struct rlimit rlp;
@@ -582,14 +581,14 @@ mch_delay(long msec, int ignoreinput)
{
int old_tmode;
#ifdef FEAT_MZSCHEME
- long total = msec; /* remember original value */
+ long total = msec; // remember original value
#endif
if (ignoreinput)
{
- /* Go to cooked mode without echo, to allow SIGINT interrupting us
- * here. But we don't want QUIT to kill us (CTRL-\ used in a
- * shell may produce SIGQUIT). */
+ // Go to cooked mode without echo, to allow SIGINT interrupting us
+ // here. But we don't want QUIT to kill us (CTRL-\ used in a
+ // shell may produce SIGQUIT).
in_mch_delay = TRUE;
old_tmode = curr_tmode;
if (curr_tmode == TMODE_RAW)
@@ -603,7 +602,7 @@ mch_delay(long msec, int ignoreinput)
#ifdef FEAT_MZSCHEME
do
{
- /* if total is large enough, wait by portions in p_mzq */
+ // if total is large enough, wait by portions in p_mzq
if (total > p_mzq)
msec = p_mzq;
else
@@ -641,9 +640,9 @@ mch_delay(long msec, int ignoreinput)
*/
select(0, NULL, NULL, NULL, &tv);
}
-# endif /* HAVE_SELECT */
-# endif /* HAVE_NANOSLEEP */
-#endif /* HAVE_USLEEP */
+# endif // HAVE_SELECT
+# endif // HAVE_NANOSLEEP
+#endif // HAVE_USLEEP
#ifdef FEAT_MZSCHEME
}
while (total > 0);
@@ -702,8 +701,8 @@ get_stack_limit(void)
int i;
long lim;
- /* Set the stack limit to 15/16 of the allowable size. Skip this when the
- * limit doesn't fit in a long (rlim_cur might be "long long"). */
+ // Set the stack limit to 15/16 of the allowable size. Skip this when the
+ // limit doesn't fit in a long (rlim_cur might be "long long").
if (getrlimit(RLIMIT_STACK, &rlp) == 0
&& rlp.rlim_cur < ((rlim_t)1 << (sizeof(long_u) * 8 - 1))
# ifdef RLIM_INFINITY
@@ -717,8 +716,8 @@ get_stack_limit(void)
pthread_attr_t attr;
size_t size;
- /* On FreeBSD the initial thread always has a fixed stack size, no
- * matter what the limits are set to. Normally it's 1 Mbyte. */
+ // On FreeBSD the initial thread always has a fixed stack size, no
+ // matter what the limits are set to. Normally it's 1 Mbyte.
pthread_attr_init(&attr);
if (pthread_attr_get_np(pthread_self(), &attr) == 0)
{
@@ -733,14 +732,14 @@ get_stack_limit(void)
{
stack_limit = (char *)((long)&i - (lim / 16L * 15L));
if (stack_limit >= (char *)&i)
- /* overflow, set to 1/16 of current stack position */
+ // overflow, set to 1/16 of current stack position
stack_limit = (char *)((long)&i / 16L);
}
else
{
stack_limit = (char *)((long)&i + (lim / 16L * 15L));
if (stack_limit <= (char *)&i)
- stack_limit = NULL; /* overflow */
+ stack_limit = NULL; // overflow
}
}
}
@@ -775,13 +774,13 @@ mch_stackcheck(char *p)
*/
#ifndef SIGSTKSZ
-# define SIGSTKSZ 8000 /* just a guess of how much stack is needed... */
+# define SIGSTKSZ 8000 // just a guess of how much stack is needed...
#endif
# ifdef HAVE_SIGALTSTACK
-static stack_t sigstk; /* for sigaltstack() */
+static stack_t sigstk; // for sigaltstack()
# else
-static struct sigstack sigstk; /* for sigstack() */
+static struct sigstack sigstk; // for sigstack()
# endif
static char *signal_stack;
@@ -820,7 +819,7 @@ init_signal_stack(void)
static RETSIGTYPE
sig_winch SIGDEFARG(sigarg)
{
- /* this is not required on all systems, but it doesn't hurt anybody */
+ // this is not required on all systems, but it doesn't hurt anybody
signal(SIGWINCH, (RETSIGTYPE (*)())sig_winch);
do_resize = TRUE;
SIGRETURN;
@@ -831,7 +830,7 @@ sig_winch SIGDEFARG(sigarg)
static RETSIGTYPE
catch_sigint SIGDEFARG(sigarg)
{
- /* this is not required on all systems, but it doesn't hurt anybody */
+ // this is not required on all systems, but it doesn't hurt anybody
signal(SIGINT, (RETSIGTYPE (*)())catch_sigint);
got_int = TRUE;
SIGRETURN;
@@ -842,7 +841,7 @@ catch_sigint SIGDEFARG(sigarg)
static RETSIGTYPE
catch_sigpwr SIGDEFARG(sigarg)
{
- /* this is not required on all systems, but it doesn't hurt anybody */
+ // this is not required on all systems, but it doesn't hurt anybody
signal(SIGPWR, (RETSIGTYPE (*)())catch_sigpwr);
/*
* I'm not sure we get the SIGPWR signal when the system is really going
@@ -861,7 +860,7 @@ catch_sigpwr SIGDEFARG(sigarg)
static RETSIGTYPE
sig_alarm SIGDEFARG(sigarg)
{
- /* doesn't do anything, just to break a system call */
+ // doesn't do anything, just to break a system call
sig_alarm_called = TRUE;
SIGRETURN;
}
@@ -944,9 +943,9 @@ mch_didjmp(void)
static RETSIGTYPE
deathtrap SIGDEFARG(sigarg)
{
- static int entered = 0; /* count the number of times we got here.
- Note: when memory has been corrupted
- this may get an arbitrary value! */
+ static int entered = 0; // count the number of times we got here.
+ // Note: when memory has been corrupted
+ // this may get an arbitrary value!
#ifdef SIGHASARG
int i;
#endif
@@ -962,24 +961,24 @@ deathtrap SIGDEFARG(sigarg)
# if defined(SIGHASARG)
lc_signal = sigarg;
# endif
- lc_active = FALSE; /* don't jump again */
+ lc_active = FALSE; // don't jump again
LONGJMP(lc_jump_env, 1);
- /* NOTREACHED */
+ // NOTREACHED
}
#endif
#ifdef SIGHASARG
# ifdef SIGQUIT
- /* While in mch_delay() we go to cooked mode to allow a CTRL-C to
- * interrupt us. But in cooked mode we may also get SIGQUIT, e.g., when
- * pressing CTRL-\, but we don't want Vim to exit then. */
+ // While in mch_delay() we go to cooked mode to allow a CTRL-C to
+ // interrupt us. But in cooked mode we may also get SIGQUIT, e.g., when
+ // pressing CTRL-\, but we don't want Vim to exit then.
if (in_mch_delay && sigarg == SIGQUIT)
SIGRETURN;
# endif
- /* When SIGHUP, SIGQUIT, etc. are blocked: postpone the effect and return
- * here. This avoids that a non-reentrant function is interrupted, e.g.,
- * free(). Calling free() again may then cause a crash. */
+ // When SIGHUP, SIGQUIT, etc. are blocked: postpone the effect and return
+ // here. This avoids that a non-reentrant function is interrupted, e.g.,
+ // free(). Calling free() again may then cause a crash.
if (entered == 0
&& (0
# ifdef SIGHUP
@@ -1005,29 +1004,29 @@ deathtrap SIGDEFARG(sigarg)
SIGRETURN;
#endif
- /* Remember how often we have been called. */
+ // Remember how often we have been called.
++entered;
- /* Executing autocommands is likely to use more stack space than we have
- * available in the signal stack. */
+ // Executing autocommands is likely to use more stack space than we have
+ // available in the signal stack.
block_autocmds();
#ifdef FEAT_EVAL
- /* Set the v:dying variable. */
+ // Set the v:dying variable.
set_vim_var_nr(VV_DYING, (long)entered);
#endif
v_dying = entered;
#ifdef HAVE_STACK_LIMIT
- /* Since we are now using the signal stack, need to reset the stack
- * limit. Otherwise using a regexp will fail. */
+ // Since we are now using the signal stack, need to reset the stack
+ // limit. Otherwise using a regexp will fail.
get_stack_limit();
#endif
#if 0
- /* This is for opening gdb the moment Vim crashes.
- * You need to manually adjust the file name and Vim executable name.
- * Suggested by SungHyun Nam. */
+ // This is for opening gdb the moment Vim crashes.
+ // You need to manually adjust the file name and Vim executable name.
+ // Suggested by SungHyun Nam.
{
# define VI_GDB_FILE "/tmp/vimgdb"
# define VIM_NAME "/usr/bin/vim"
@@ -1048,15 +1047,15 @@ deathtrap SIGDEFARG(sigarg)
#endif
#ifdef SIGHASARG
- /* try to find the name of this signal */
+ // try to find the name of this signal
for (i = 0; signal_info[i].sig != -1; i++)
if (sigarg == signal_info[i].sig)
break;
deadly_signal = sigarg;
#endif
- full_screen = FALSE; /* don't write message to the GUI, it might be
- * part of the problem... */
+ full_screen = FALSE; // don't write message to the GUI, it might be
+ // part of the problem...
/*
* If something goes wrong after entering here, we may get here again.
* When this happens, give a message and try to exit nicely (resetting the
@@ -1068,7 +1067,7 @@ deathtrap SIGDEFARG(sigarg)
*/
if (entered >= 3)
{
- reset_signals(); /* don't catch any signals anymore */
+ reset_signals(); // don't catch any signals anymore
may_core_dump();
if (entered >= 4)
_exit(8);
@@ -1076,13 +1075,13 @@ deathtrap SIGDEFARG(sigarg)
}
if (entered == 2)
{
- /* No translation, it may call malloc(). */
+ // No translation, it may call malloc().
OUT_STR("Vim: Double signal, exiting\n");
out_flush();
getout(1);
}
- /* No translation, it may call malloc(). */
+ // No translation, it may call malloc().
#ifdef SIGHASARG
sprintf((char *)IObuff, "Vim: Caught deadly signal %s\n",
signal_info[i].name);
@@ -1090,11 +1089,11 @@ deathtrap SIGDEFARG(sigarg)
sprintf((char *)IObuff, "Vim: Caught deadly signal\n");
#endif
- /* Preserve files and exit. This sets the really_exiting flag to prevent
- * calling free(). */
+ // Preserve files and exit. This sets the really_exiting flag to prevent
+ // calling free().
preserve_exit();
- /* NOTREACHED */
+ // NOTREACHED
#ifdef NBDEBUG
reset_signals();
@@ -1238,13 +1237,13 @@ restore_clipboard(void)
void
mch_suspend(void)
{
- /* BeOS does have SIGTSTP, but it doesn't work. */
+ // BeOS does have SIGTSTP, but it doesn't work.
#if defined(SIGTSTP) && !defined(__BEOS__)
in_mch_suspend = TRUE;
- out_flush(); /* needed to make cursor visible on some systems */
+ out_flush(); // needed to make cursor visible on some systems
settmode(TMODE_COOK);
- out_flush(); /* needed to disable mouse on some systems */
+ out_flush(); // needed to disable mouse on some systems
# if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
loose_clipboard();
@@ -1253,7 +1252,7 @@ mch_suspend(void)
sigcont_received = FALSE;
# endif
- kill(0, SIGTSTP); /* send ourselves a STOP signal */
+ kill(0, SIGTSTP); // send ourselves a STOP signal
# if defined(SIGCONT)
/*
@@ -1374,7 +1373,7 @@ reset_signals(void)
{
catch_signals(SIG_DFL, SIG_DFL);
#if defined(SIGCONT)
- /* SIGCONT isn't in the list, because its default action is ignore */
+ // SIGCONT isn't in the list, because its default action is ignore
signal(SIGCONT, SIG_DFL);
#endif
}
@@ -1392,15 +1391,15 @@ catch_signals(
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
struct sigaction sa;
- /* Setup to use the alternate stack for the signal function. */
+ // Setup to use the alternate stack for the signal function.
sa.sa_handler = func_deadly;
sigemptyset(&sa.sa_mask);
# if defined(__linux__) && defined(_REENTRANT)
- /* On Linux, with glibc compiled for kernel 2.2, there is a bug in
- * thread handling in combination with using the alternate stack:
- * pthread library functions try to use the stack pointer to
- * identify the current thread, causing a SEGV signal, which
- * recursively calls deathtrap() and hangs. */
+ // On Linux, with glibc compiled for kernel 2.2, there is a bug in
+ // thread handling in combination with using the alternate stack:
+ // pthread library functions try to use the stack pointer to
+ // identify the current thread, causing a SEGV signal, which
+ // recursively calls deathtrap() and hangs.
sa.sa_flags = 0;
# else
sa.sa_flags = SA_ONSTACK;
@@ -1410,7 +1409,7 @@ catch_signals(
# if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGVEC)
struct sigvec sv;
- /* Setup to use the alternate stack for the signal function. */
+ // Setup to use the alternate stack for the signal function.
sv.sv_handler = func_deadly;
sv.sv_mask = 0;
sv.sv_flags = SV_ONSTACK;
@@ -1437,7 +1436,7 @@ block_signals(sigset_t *set)
sigaddset(&newset, signal_info[i].sig);
# if defined(SIGCONT)
- /* SIGCONT isn't in the list, because its default action is ignore */
+ // SIGCONT isn't in the list, because its default action is ignore
sigaddset(&newset, SIGCONT);
# endif
@@ -1480,12 +1479,12 @@ vim_handle_signal(int sig)
break;
default: if (!blocked)
- return TRUE; /* exit! */
+ return TRUE; // exit!
got_signal = sig;
#ifdef SIGPWR
if (sig != SIGPWR)
#endif
- got_int = TRUE; /* break any loops */
+ got_int = TRUE; // break any loops
break;
}
return FALSE;
@@ -1545,12 +1544,12 @@ x_error_handler(Display *dpy, XErrorEvent *error_event)
XGetErrorText(dpy, error_event->error_code, (char *)IObuff, IOSIZE);
STRCAT(IObuff, _("\nVim: Got X error\n"));
- /* We cannot print a message and continue, because no X calls are allowed
- * here (causes my system to hang). Silently continuing might be an
- * alternative... */
- preserve_exit(); /* preserve files and exit */
+ // We cannot print a message and continue, because no X calls are allowed
+ // here (causes my system to hang). Silently continuing might be an
+ // alternative...
+ preserve_exit(); // preserve files and exit
- return 0; /* NOTREACHED */
+ return 0; // NOTREACHED
}
/*
@@ -1603,10 +1602,10 @@ x_connect_to_server(void)
static int
x_IOerror_check(Display *dpy UNUSED)
{
- /* This function should not return, it causes exit(). Longjump instead. */
+ // This function should not return, it causes exit(). Longjump instead.
LONGJMP(lc_jump_env, 1);
# if defined(VMS) || defined(__CYGWIN__)
- return 0; /* avoid the compiler complains about missing return value */
+ return 0; // avoid the compiler complains about missing return value
# endif
}
# endif
@@ -1625,10 +1624,10 @@ x_IOerror_handler(Display *dpy UNUSED)
x11_display = NULL;
xterm_Shell = (Widget)0;
- /* This function should not return, it causes exit(). Longjump instead. */
+ // This function should not return, it causes exit(). Longjump instead.
LONGJMP(x_jump_env, 1);
# if defined(VMS) || defined(__CYGWIN__)
- return 0; /* avoid the compiler complains about missing return value */
+ return 0; // avoid the compiler complains about missing return value
# endif
}
@@ -1646,12 +1645,12 @@ may_restore_clipboard(void)
--xterm_dpy_retry_count;
# ifndef LESSTIF_VERSION
- /* This has been reported to avoid Vim getting stuck. */
+ // This has been reported to avoid Vim getting stuck.
if (app_context != (XtAppContext)NULL)
{
XtDestroyApplicationContext(app_context);
app_context = (XtAppContext)NULL;
- x11_display = NULL; /* freed by XtDestroyApplicationContext() */
+ x11_display = NULL; // freed by XtDestroyApplicationContext()
}
# endif
@@ -1723,16 +1722,16 @@ get_x11_windis(void)
{
char *winid;
static int result = -1;
-#define XD_NONE 0 /* x11_display not set here */
-#define XD_HERE 1 /* x11_display opened here */
-#define XD_GUI 2 /* x11_display used from gui.dpy */
-#define XD_XTERM 3 /* x11_display used from xterm_dpy */
+#define XD_NONE 0 // x11_display not set here
+#define XD_HERE 1 // x11_display opened here
+#define XD_GUI 2 // x11_display used from gui.dpy
+#define XD_XTERM 3 // x11_display used from xterm_dpy
static int x11_display_from = XD_NONE;
static int did_set_error_handler = FALSE;
if (!did_set_error_handler)
{
- /* X just exits if it finds an error otherwise! */
+ // X just exits if it finds an error otherwise!
(void)XSetErrorHandler(x_error_handler);
did_set_error_handler = TRUE;
}
@@ -1759,14 +1758,14 @@ get_x11_windis(void)
}
else if (x11_display_from == XD_GUI)
{
- /* GUI must have stopped somehow, clear x11_display */
+ // GUI must have stopped somehow, clear x11_display
x11_window = 0;
x11_display = NULL;
x11_display_from = XD_NONE;
}
#endif
- /* When started with the "-X" argument, don't try connecting. */
+ // When started with the "-X" argument, don't try connecting.
if (!x_connect_to_server())
return FAIL;
@@ -1786,8 +1785,8 @@ get_x11_windis(void)
if (xterm_dpy != NULL && x11_window != 0)
{
- /* We may have checked it already, but Gnome terminal can move us to
- * another window, so we need to check every time. */
+ // We may have checked it already, but Gnome terminal can move us to
+ // another window, so we need to check every time.
if (x11_display_from != XD_XTERM)
{
/*
@@ -1801,7 +1800,7 @@ get_x11_windis(void)
}
if (test_x11_window(x11_display) == FAIL)
{
- /* probably bad $WINDOWID */
+ // probably bad $WINDOWID
x11_window = 0;
x11_display = NULL;
x11_display_from = XD_NONE;
@@ -1814,8 +1813,8 @@ get_x11_windis(void)
if (x11_window == 0 || x11_display == NULL)
result = -1;
- if (result != -1) /* Have already been here and set this */
- return result; /* Don't do all these X calls again */
+ if (result != -1) // Have already been here and set this
+ return result; // Don't do all these X calls again
if (x11_window != 0 && x11_display == NULL)
{
@@ -1859,7 +1858,7 @@ get_x11_windis(void)
# endif
if (test_x11_window(x11_display) == FAIL)
{
- /* Maybe window id is bad */
+ // Maybe window id is bad
x11_window = 0;
XCloseDisplay(x11_display);
x11_display = NULL;
@@ -1897,7 +1896,7 @@ get_x11_icon(int test_only)
retval = get_x11_thing(FALSE, test_only);
- /* could not get old icon, use terminal name */
+ // could not get old icon, use terminal name
if (oldicon == NULL && !test_only)
{
if (STRNCMP(T_NAME, "builtin_", 8) == 0)
@@ -1911,7 +1910,7 @@ get_x11_icon(int test_only)
static int
get_x11_thing(
- int get_title, /* get title string */
+ int get_title, // get title string
int test_only)
{
XTextProperty text_prop;
@@ -1920,7 +1919,7 @@ get_x11_thing(
if (get_x11_windis() == OK)
{
- /* Get window/icon name if any */
+ // Get window/icon name if any
if (get_title)
status = XGetWMName(x11_display, x11_window, &text_prop);
else
@@ -1932,9 +1931,9 @@ get_x11_thing(
* keep traversing up the tree until a window with a title/icon is
* found.
*/
- /* Previously this was only done for xterm and alikes. I don't see a
- * reason why it would fail for other terminal emulators.
- * if (term_is_xterm) */
+ // Previously this was only done for xterm and alikes. I don't see a
+ // reason why it would fail for other terminal emulators.
+ // if (term_is_xterm)
{
Window root;
Window parent;
@@ -2003,10 +2002,10 @@ get_x11_thing(
return retval;
}
-/* Xutf8 functions are not available on older systems. Note that on some
- * systems X_HAVE_UTF8_STRING may be defined in a header file but
- * Xutf8SetWMProperties() is not in the X11 library. Configure checks for
- * that and defines HAVE_XUTF8SETWMPROPERTIES. */
+// Xutf8 functions are not available on older systems. Note that on some
+// systems X_HAVE_UTF8_STRING may be defined in a header file but
+// Xutf8SetWMProperties() is not in the X11 library. Configure checks for
+// that and defines HAVE_XUTF8SETWMPROPERTIES.
#if defined(X_HAVE_UTF8_STRING)
# if X_HAVE_UTF8_STRING && HAVE_XUTF8SETWMPROPERTIES
# define USE_UTF8_STRING
@@ -2021,10 +2020,9 @@ get_x11_thing(
static void
set_x11_title(char_u *title)
{
- /* XmbSetWMProperties() and Xutf8SetWMProperties() should use a STRING
- * when possible, COMPOUND_TEXT otherwise. COMPOUND_TEXT isn't
- * supported everywhere and STRING doesn't work for multi-byte titles.
- */
+ // XmbSetWMProperties() and Xutf8SetWMProperties() should use a STRING
+ // when possible, COMPOUND_TEXT otherwise. COMPOUND_TEXT isn't
+ // supported everywhere and STRING doesn't work for multi-byte titles.
#ifdef USE_UTF8_STRING
if (enc_utf8)
Xutf8SetWMProperties(x11_display, x11_window, (const char *)title,
@@ -2040,7 +2038,7 @@ set_x11_title(char_u *title)
XTextProperty text_prop;
char *c_title = (char *)title;
- /* directly from example 3-18 "basicwin" of Xlib Programming Manual */
+ // directly from example 3-18 "basicwin" of Xlib Programming Manual
(void)XStringListToTextProperty(&c_title, 1, &text_prop);
XSetWMProperties(x11_display, x11_window, &text_prop,
NULL, NULL, 0, NULL, NULL, NULL);
@@ -2060,7 +2058,7 @@ set_x11_title(char_u *title)
static void
set_x11_icon(char_u *icon)
{
- /* See above for comments about using X*SetWMProperties(). */
+ // See above for comments about using X*SetWMProperties().
#ifdef USE_UTF8_STRING
if (enc_utf8)
Xutf8SetWMProperties(x11_display, x11_window, NULL, (const char *)icon,
@@ -2087,7 +2085,7 @@ set_x11_icon(char_u *icon)
XFlush(x11_display);
}
-#else /* FEAT_X11 */
+#else // FEAT_X11
static int
get_x11_title(int test_only UNUSED)
@@ -2108,7 +2106,7 @@ get_x11_icon(int test_only)
return FALSE;
}
-#endif /* FEAT_X11 */
+#endif // FEAT_X11
int
mch_can_restore_title(void)
@@ -2131,13 +2129,13 @@ mch_settitle(char_u *title, char_u *icon)
int type = 0;
static int recursive = 0;
- if (T_NAME == NULL) /* no terminal name (yet) */
+ if (T_NAME == NULL) // no terminal name (yet)
return;
- if (title == NULL && icon == NULL) /* nothing to do */
+ if (title == NULL && icon == NULL) // nothing to do
return;
- /* When one of the X11 functions causes a deadly signal, we get here again
- * recursively. Avoid hanging then (something is probably locked). */
+ // When one of the X11 functions causes a deadly signal, we get here again
+ // recursively. Avoid hanging then (something is probably locked).
if (recursive)
return;
++recursive;
@@ -2170,17 +2168,17 @@ mch_settitle(char_u *title, char_u *icon)
#ifdef FEAT_GUI
&& !gui.in_use
#endif
- ) /* first call but not in GUI, save title */
+ ) // first call but not in GUI, save title
(void)get_x11_title(FALSE);
- if (*T_TS != NUL) /* it's OK if t_fs is empty */
+ if (*T_TS != NUL) // it's OK if t_fs is empty
term_settitle(title);
#ifdef FEAT_X11
else
# ifdef FEAT_GUI_GTK
- if (!gui.in_use) /* don't do this if GTK+ is running */
+ if (!gui.in_use) // don't do this if GTK+ is running
# endif
- set_x11_title(title); /* x11 */
+ set_x11_title(title); // x11
#endif
#if defined(FEAT_GUI_GTK) \
|| defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)
@@ -2196,7 +2194,7 @@ mch_settitle(char_u *title, char_u *icon)
#ifdef FEAT_GUI
&& !gui.in_use
#endif
- ) /* first call, save icon */
+ ) // first call, save icon
get_x11_icon(FALSE);
if (*T_CIS != NUL)
@@ -2209,9 +2207,9 @@ mch_settitle(char_u *title, char_u *icon)
#ifdef FEAT_X11
else
# ifdef FEAT_GUI_GTK
- if (!gui.in_use) /* don't do this if GTK+ is running */
+ if (!gui.in_use) // don't do this if GTK+ is running
# endif
- set_x11_icon(icon); /* x11 */
+ set_x11_icon(icon); // x11
#endif
did_set_icon = TRUE;
}
@@ -2230,7 +2228,7 @@ mch_restore_title(int which)
{
int do_push_pop = unix_did_set_title || did_set_icon;
- /* only restore the title or icon when it has been set */
+ // only restore the title or icon when it has been set
mch_settitle(((which & SAVE_RESTORE_TITLE) && unix_did_set_title) ?
(oldtitle ? oldtitle : p_titleold) : NULL,
((which & SAVE_RESTORE_ICON) && did_set_icon) ? oldicon : NULL);
@@ -2243,7 +2241,7 @@ mch_restore_title(int which)
}
}
-#endif /* FEAT_TITLE */
+#endif // FEAT_TITLE
/*
* Return TRUE if "name" looks like some xterm name.
@@ -2316,8 +2314,8 @@ vim_is_iris(char_u *name)
vim_is_vt300(char_u *name)
{
if (name == NULL)
- return FALSE; /* actually all ANSI comp. terminals should be here */
- /* catch VT100 - VT5xx */
+ return FALSE; // actually all ANSI comp. terminals should be here
+ // catch VT100 - VT5xx
return ((STRNICMP(name, "vt", 2) == 0
&& vim_strchr((char_u *)"12345", name[2]) != NULL)
|| STRCMP(name, "builtin_vt320") == 0);
@@ -2373,8 +2371,8 @@ mch_get_uname(uid_t uid, char_u *s, int len)
return OK;
}
#endif
- sprintf((char *)s, "%d", (int)uid); /* assumes s is long enough */
- return FAIL; /* a number is not a name */
+ sprintf((char *)s, "%d", (int)uid); // assumes s is long enough
+ return FAIL; // a number is not a name
}
/*
@@ -2392,7 +2390,7 @@ mch_get_host_name(char_u *s, int len)
else
vim_strncpy(s, (char_u *)vutsname.nodename, len - 1);
}
-#else /* HAVE_SYS_UTSNAME_H */
+#else // HAVE_SYS_UTSNAME_H
# ifdef HAVE_SYS_SYSTEMINFO_H
# define gethostname(nam, len) sysinfo(SI_HOSTNAME, nam, len)
@@ -2406,9 +2404,9 @@ mch_get_host_name(char_u *s, int len)
# else
gethostname((char *)s, len);
# endif
- s[len - 1] = NUL; /* make sure it's terminated */
+ s[len - 1] = NUL; // make sure it's terminated
}
-#endif /* HAVE_SYS_UTSNAME_H */
+#endif // HAVE_SYS_UTSNAME_H
/*
* return process ID
@@ -2474,19 +2472,19 @@ mch_FullName(
char_u *fname,
char_u *buf,
int len,
- int force) /* also expand when already absolute path */
+ int force) // also expand when already absolute path
{
int l;
#ifdef HAVE_FCHDIR
int fd = -1;
- static int dont_fchdir = FALSE; /* TRUE when fchdir() doesn't work */
+ static int dont_fchdir = FALSE; // TRUE when fchdir() doesn't work
#endif
char_u olddir[MAXPATHL];
char_u *p;
int retval = OK;
#ifdef __CYGWIN__
- char_u posix_fname[MAXPATHL]; /* Cygwin docs mention MAX_PATH, but
- it's not always defined */
+ char_u posix_fname[MAXPATHL]; // Cygwin docs mention MAX_PATH, but
+ // it's not always defined
#endif
#ifdef VMS
@@ -2498,8 +2496,8 @@ mch_FullName(
* This helps for when "/etc/hosts" is a symlink to "c:/something/hosts".
*/
# if CYGWIN_VERSION_DLL_MAJOR >= 1007
- /* Use CCP_RELATIVE to avoid that it sometimes returns a path that ends in
- * a forward slash. */
+ // Use CCP_RELATIVE to avoid that it sometimes returns a path that ends in
+ // a forward slash.
cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE,
fname, posix_fname, MAXPATHL);
# else
@@ -2508,8 +2506,8 @@ mch_FullName(
fname = posix_fname;
#endif
- /* Expand it if forced or not an absolute path.
- * Do not do it for "/file", the result is always "/". */
+ // Expand it if forced or not an absolute path.
+ // Do not do it for "/file", the result is always "/".
if ((force || !mch_isFullName(fname))
&& ((p = vim_strrchr(fname, '/')) == NULL || p != fname))
{
@@ -2533,13 +2531,13 @@ mch_FullName(
{
close(fd);
fd = -1;
- dont_fchdir = TRUE; /* don't try again */
+ dont_fchdir = TRUE; // don't try again
}
}
#endif
- /* Only change directory when we are sure we can return to where
- * we are now. After doing "su" chdir(".") might not work. */
+ // Only change directory when we are sure we can return to where
+ // we are now. After doing "su" chdir(".") might not work.
if (
#ifdef HAVE_FCHDIR
fd < 0 &&
@@ -2547,14 +2545,14 @@ mch_FullName(
(mch_dirname(olddir, MAXPATHL) == FAIL
|| mch_chdir((char *)olddir) != 0))
{
- p = NULL; /* can't get current dir: don't chdir */
+ p = NULL; // can't get current dir: don't chdir
retval = FAIL;
}
else
{
- /* The directory is copied into buf[], to be able to remove
- * the file name without changing it (could be a string in
- * read-only memory) */
+ // The directory is copied into buf[], to be able to remove
+ // the file name without changing it (could be a string in
+ // read-only memory)
if (p - fname >= len)
retval = FAIL;
else
@@ -2596,7 +2594,7 @@ mch_FullName(
l = STRLEN(buf);
if (l >= len - 1)
- retval = FAIL; /* no space for trailing "/" */
+ retval = FAIL; // no space for trailing "/"
#ifndef VMS
else if (l > 0 && buf[l - 1] != '/' && *fname != NUL
&& STRCMP(fname, ".") != 0)
@@ -2604,11 +2602,11 @@ mch_FullName(
#endif
}
- /* Catch file names which are too long. */
+ // Catch file names which are too long.
if (retval == FAIL || (int)(STRLEN(buf) + STRLEN(fname)) >= len)
return FAIL;
- /* Do not append ".", "/dir/." is equal to "/dir". */
+ // Do not append ".", "/dir/." is equal to "/dir".
if (STRCMP(fname, ".") != 0)
STRCAT(buf, fname);
@@ -2640,7 +2638,7 @@ mch_isFullName(char_u *fname)
void
fname_case(
char_u *name,
- int len UNUSED) /* buffer size, only used when name gets longer */
+ int len UNUSED) // buffer size, only used when name gets longer
{
struct stat st;
char_u *slash, *tail;
@@ -2649,7 +2647,7 @@ fname_case(
if (mch_lstat((char *)name, &st) >= 0)
{
- /* Open the directory where the file is located. */
+ // Open the directory where the file is located.
slash = vim_strrchr(name, '/');
if (slash == NULL)
{
@@ -2668,15 +2666,15 @@ fname_case(
{
while ((dp = readdir(dirp)) != NULL)
{
- /* Only accept names that differ in case and are the same byte
- * length. TODO: accept different length name. */
+ // Only accept names that differ in case and are the same byte
+ // length. TODO: accept different length name.
if (STRICMP(tail, dp->d_name) == 0
&& STRLEN(tail) == STRLEN(dp->d_name))
{
char_u newname[MAXPATHL + 1];
struct stat st2;
- /* Verify the inode is equal. */
+ // Verify the inode is equal.
vim_strncpy(newname, name, MAXPATHL);
vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
MAXPATHL - (tail - name));
@@ -2705,7 +2703,7 @@ mch_getperm(char_u *name)
{
struct stat statb;
- /* Keep the #ifdef outside of stat(), it may be a macro. */
+ // Keep the #ifdef outside of stat(), it may be a macro.
#ifdef VMS
if (stat((char *)vms_fixfilename(name), &statb))
#else
@@ -2713,8 +2711,8 @@ mch_getperm(char_u *name)
#endif
return -1;
#ifdef __INTERIX
- /* The top bit makes the value negative, which means the file doesn't
- * exist. Remove the bit, we don't use it. */
+ // The top bit makes the value negative, which means the file doesn't
+ // exist. Remove the bit, we don't use it.
return statb.st_mode & ~S_ADDACE;
#else
return statb.st_mode;
@@ -2784,9 +2782,9 @@ mch_copy_sec(char_u *from_file, char_u *to_file)
if (getfilecon((char *)from_file, &from_context) < 0)
{
- /* If the filesystem doesn't support extended attributes,
- the original had no special security context and the
- target cannot have one either. */
+ // If the filesystem doesn't support extended attributes,
+ // the original had no special security context and the
+ // target cannot have one either.
if (errno == EOPNOTSUPP)
return;
@@ -2816,7 +2814,7 @@ mch_copy_sec(char_u *from_file, char_u *to_file)
freecon(from_context);
}
}
-#endif /* HAVE_SELINUX */
+#endif // HAVE_SELINUX
#if defined(HAVE_SMACK) && !defined(PROTO)
/*
@@ -2844,14 +2842,14 @@ mch_copy_sec(char_u *from_file, char_u *to_file)
for (index = 0 ; index < (int)(sizeof(smack_copied_attributes)
/ sizeof(smack_copied_attributes)[0]) ; index++)
{
- /* get the name of the attribute to copy */
+ // get the name of the attribute to copy
name = smack_copied_attributes[index];
- /* get the value of the attribute in buffer */
+ // get the value of the attribute in buffer
size = getxattr((char*)from_file, name, buffer, sizeof(buffer));
if (size >= 0)
{
- /* copy the attribute value of buffer */
+ // copy the attribute value of buffer
ret = setxattr((char*)to_file, name, buffer, (size_t)size, 0);
if (ret < 0)
{
@@ -2864,35 +2862,35 @@ mch_copy_sec(char_u *from_file, char_u *to_file)
}
else
{
- /* what reason of not having the attribute value? */
+ // what reason of not having the attribute value?
switch (errno)
{
case ENOTSUP:
- /* extended attributes aren't supported or enabled */
- /* should a message be echoed? not sure... */
- return; /* leave because it isn't useful to continue */
+ // extended attributes aren't supported or enabled
+ // should a message be echoed? not sure...
+ return; // leave because it isn't useful to continue
case ERANGE:
default:
- /* no enough size OR unexpected error */
+ // no enough size OR unexpected error
vim_snprintf((char *)IObuff, IOSIZE,
_("Could not get security context %s for %s. Removing it!"),
name, from_file);
msg_puts((char *)IObuff);
msg_putchar('\n');
- /* FALLTHROUGH to remove the attribute */
+ // FALLTHROUGH to remove the attribute
case ENODATA:
- /* no attribute of this name */
+ // no attribute of this name
ret = removexattr((char*)to_file, name);
- /* Silently ignore errors, apparently this happens when
- * smack is not actually being used. */
+ // Silently ignore errors, apparently this happens when
+ // smack is not actually being used.
break;
}
}
}
}
-#endif /* HAVE_SMACK */
+#endif // HAVE_SMACK
/*
* Return a pointer to the ACL of file "fname" in allocated memory.
@@ -2955,10 +2953,10 @@ mch_get_acl(char_u *fname UNUSED)
}
}
ret = (vim_acl_T)aclent;
-#endif /* HAVE_AIX_ACL */
-#endif /* HAVE_SOLARIS_ACL */
-#endif /* HAVE_SOLARIS_ZFS_ACL */
-#endif /* HAVE_POSIX_ACL */
+#endif // HAVE_AIX_ACL
+#endif // HAVE_SOLARIS_ACL
+#endif // HAVE_SOLARIS_ZFS_ACL
+#endif // HAVE_POSIX_ACL
return ret;
}
@@ -2982,10 +2980,10 @@ mch_set_acl(char_u *fname UNUSED, vim_acl_T aclent)
#else
#ifdef HAVE_AIX_ACL
chacl((char *)fname, aclent, ((struct acl *)aclent)->acl_len);
-#endif /* HAVE_AIX_ACL */
-#endif /* HAVE_SOLARIS_ACL */
-#endif /* HAVE_SOLARIS_ZFS_ACL */
-#endif /* HAVE_POSIX_ACL */
+#endif // HAVE_AIX_ACL
+#endif // HAVE_SOLARIS_ACL
+#endif // HAVE_SOLARIS_ZFS_ACL
+#endif // HAVE_POSIX_ACL
}
void
@@ -3005,10 +3003,10 @@ mch_free_acl(vim_acl_T aclent)
#else
#ifdef HAVE_AIX_ACL
free(aclent);
-#endif /* HAVE_AIX_ACL */
-#endif /* HAVE_SOLARIS_ACL */
-#endif /* HAVE_SOLARIS_ZFS_ACL */
-#endif /* HAVE_POSIX_ACL */
+#endif // HAVE_AIX_ACL
+#endif // HAVE_SOLARIS_ACL
+#endif // HAVE_SOLARIS_ZFS_ACL
+#endif // HAVE_POSIX_ACL
}
#endif
@@ -3018,7 +3016,7 @@ mch_free_acl(vim_acl_T aclent)
void
mch_hide(char_u *name UNUSED)
{
- /* can't hide a file */
+ // can't hide a file
}
/*
@@ -3031,7 +3029,7 @@ mch_isdir(char_u *name)
{
struct stat statb;
- if (*name == NUL) /* Some stat()s don't flag "" as an error. */
+ if (*name == NUL) // Some stat()s don't flag "" as an error.
return FALSE;
if (stat((char *)name, &statb))
return FALSE;
@@ -3048,7 +3046,7 @@ mch_isrealdir(char_u *name)
{
struct stat statb;
- if (*name == NUL) /* Some stat()s don't flag "" as an error. */
+ if (*name == NUL) // Some stat()s don't flag "" as an error.
return FALSE;
if (mch_lstat((char *)name, &statb))
return FALSE;
@@ -3066,14 +3064,13 @@ executable_file(char_u *name)
if (stat((char *)name, &st))
return 0;
#ifdef VMS
- /* Like on Unix system file can have executable rights but not necessarily
- * be an executable, but on Unix is not a default for an ordinary file to
- * have an executable flag - on VMS it is in most cases.
- * Therefore, this check does not have any sense - let keep us to the
- * conventions instead:
- * *.COM and *.EXE files are the executables - the rest are not. This is
- * not ideal but better then it was.
- */
+ // Like on Unix system file can have executable rights but not necessarily
+ // be an executable, but on Unix is not a default for an ordinary file to
+ // have an executable flag - on VMS it is in most cases.
+ // Therefore, this check does not have any sense - let keep us to the
+ // conventions instead:
+ // *.COM and *.EXE files are the executables - the rest are not. This is
+ // not ideal but better then it was.
int vms_executable = 0;
if (S_ISREG(st.st_mode) && mch_access((char *)name, X_OK) == 0)
{
@@ -3099,12 +3096,12 @@ mch_can_exe(char_u *name, char_u **path, int use_path)
char_u *p, *e;
int retval;
- /* When "use_path" is false and if it's an absolute or relative path don't
- * need to use $PATH. */
+ // When "use_path" is false and if it's an absolute or relative path don't
+ // need to use $PATH.
if (!use_path || gettail(name) != name)
{
- /* There must be a path separator, files in the current directory
- * can't be executed. */
+ // There must be a path separator, files in the current directory
+ // can't be executed.
if ((use_path || gettail(name) != name) && executable_file(name))
{
if (path != NULL)
@@ -3135,7 +3132,7 @@ mch_can_exe(char_u *name, char_u **path, int use_path)
e = (char_u *)strchr((char *)p, ':');
if (e == NULL)
e = p + STRLEN(p);
- if (e - p <= 1) /* empty entry means current dir */
+ if (e - p <= 1) // empty entry means current dir
STRCPY(buf, "./");
else
{
@@ -3180,9 +3177,9 @@ mch_nodetype(char_u *name)
return NODE_NORMAL;
if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))
return NODE_NORMAL;
- if (S_ISBLK(st.st_mode)) /* block device isn't writable */
+ if (S_ISBLK(st.st_mode)) // block device isn't writable
return NODE_OTHER;
- /* Everything else is writable? */
+ // Everything else is writable?
return NODE_WRITABLE;
}
@@ -3226,14 +3223,14 @@ mch_free_mem(void)
if (xterm_Shell != (Widget)0)
XtDestroyWidget(xterm_Shell);
# ifndef LESSTIF_VERSION
- /* Lesstif crashes here, lose some memory */
+ // Lesstif crashes here, lose some memory
if (xterm_dpy != NULL)
XtCloseDisplay(xterm_dpy);
if (app_context != (XtAppContext)NULL)
{
XtDestroyApplicationContext(app_context);
# ifdef FEAT_X11
- x11_display = NULL; /* freed by XtDestroyApplicationContext() */
+ x11_display = NULL; // freed by XtDestroyApplicationContext()
# endif
}
# endif
@@ -3279,9 +3276,9 @@ exit_scroll(void)
}
else
{
- restore_cterm_colors(); /* get original colors back */
- msg_clr_eos_force(); /* clear the rest of the display */
- windgoto((int)Rows - 1, 0); /* may have moved the cursor */
+ restore_cterm_colors(); // get original colors back
+ msg_clr_eos_force(); // clear the rest of the display
+ windgoto((int)Rows - 1, 0); // may have moved the cursor
}
}
@@ -3313,8 +3310,8 @@ mch_exit(int r)
if (swapping_screen() && !newline_on_exit)
exit_scroll();
- /* Stop termcap: May need to check for T_CRV response, which
- * requires RAW mode. */
+ // Stop termcap: May need to check for T_CRV response, which
+ // requires RAW mode.
stoptermcap();
/*
@@ -3324,13 +3321,13 @@ mch_exit(int r)
if (!swapping_screen() || newline_on_exit)
exit_scroll();
- /* Cursor may have been switched off without calling starttermcap()
- * when doing "vim -u vimrc" and vimrc contains ":q". */
+ // Cursor may have been switched off without calling starttermcap()
+ // when doing "vim -u vimrc" and vimrc contains ":q".
if (full_screen)
cursor_on();
}
out_flush();
- ml_close_all(TRUE); /* remove all memfiles */
+ ml_close_all(TRUE); // remove all memfiles
may_core_dump();
#ifdef FEAT_GUI
if (gui.in_use)
@@ -3342,8 +3339,8 @@ mch_exit(int r)
#endif
#ifdef __QNX__
- /* A core dump won't be created if the signal handler
- * doesn't return, so we can't call exit() */
+ // A core dump won't be created if the signal handler
+ // doesn't return, so we can't call exit()
if (deadly_signal != 0)
return;
#endif
@@ -3365,7 +3362,7 @@ may_core_dump(void)
if (deadly_signal != 0)
{
signal(deadly_signal, SIG_DFL);
- kill(getpid(), deadly_signal); /* Die using the signal we caught */
+ kill(getpid(), deadly_signal); // Die using the signal we caught
}
}
@@ -3452,8 +3449,8 @@ mch_settmode(int tmode)
tnew.c_iflag &= ~ICRNL;
tnew.c_lflag &= ~(ICANON | ECHO | ISIG | ECHOE
# if defined(IEXTEN) && !defined(__MINT__)
- | IEXTEN /* IEXTEN enables typing ^V on SOLARIS */
- /* but it breaks function keys on MINT */
+ | IEXTEN // IEXTEN enables typing ^V on SOLARIS
+ // but it breaks function keys on MINT
# endif
);
# ifdef ONLCR
@@ -3474,19 +3471,19 @@ mch_settmode(int tmode)
}
else if (tmode == TMODE_SLEEP)
{
- /* Also reset ICANON here, otherwise on Solaris select() won't see
- * typeahead characters. */
+ // Also reset ICANON here, otherwise on Solaris select() won't see
+ // typeahead characters.
tnew.c_lflag &= ~(ICANON | ECHO);
- tnew.c_cc[VMIN] = 1; /* return after 1 char */
- tnew.c_cc[VTIME] = 0; /* don't wait */
+ tnew.c_cc[VMIN] = 1; // return after 1 char
+ tnew.c_cc[VTIME] = 0; // don't wait
}
# if defined(HAVE_TERMIOS_H)
{
int n = 10;
- /* A signal may cause tcsetattr() to fail (e.g., SIGCONT). Retry a
- * few times. */
+ // A signal may cause tcsetattr() to fail (e.g., SIGCONT). Retry a
+ // few times.
while (tcsetattr(read_cmd_fd, TCSANOW, &tnew) == -1
&& errno == EINTR && n > 0)
--n;
@@ -3500,7 +3497,7 @@ mch_settmode(int tmode)
* for "old" tty systems
*/
# ifndef TIOCSETN
-# define TIOCSETN TIOCSETP /* for hpux 9.0 */
+# define TIOCSETN TIOCSETP // for hpux 9.0
# endif
static struct sgttyb ttybold;
struct sgttyb ttybnew;
@@ -3547,7 +3544,7 @@ get_stty(void)
buf[1] = NUL;
add_termcode((char_u *)"kb", buf, FALSE);
- /* If <BS> and <DEL> are now the same, redefine <DEL>. */
+ // If <BS> and <DEL> are now the same, redefine <DEL>.
p = find_termcode((char_u *)"kD");
if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
do_fixdel(NULL);
@@ -3583,7 +3580,7 @@ get_tty_info(int fd, ttyinfo_T *info)
return OK;
}
#else
- /* for "old" tty systems */
+ // for "old" tty systems
struct sgttyb keys;
if (mch_tcgetattr(fd, &keys) != -1)
@@ -3598,7 +3595,7 @@ get_tty_info(int fd, ttyinfo_T *info)
return FAIL;
}
-#endif /* VMS */
+#endif // VMS
static int mouse_ison = FALSE;
@@ -3625,7 +3622,7 @@ mch_setmouse(int on)
&& p_bevalterm == bevalterm_ison
#endif
)
- /* return quickly if nothing to do */
+ // return quickly if nothing to do
return;
xterm_mouse_vers = use_xterm_mouse();
@@ -3643,7 +3640,7 @@ mch_setmouse(int on)
if (ttym_flags == TTYM_SGR)
{
- /* SGR mode supports columns above 223 */
+ // SGR mode supports columns above 223
out_str_nf((char_u *)
(on
? IF_EB("\033[?1006h", ESC_STR "[?1006h")
@@ -3656,7 +3653,7 @@ mch_setmouse(int on)
{
bevalterm_ison = (p_bevalterm && on);
if (xterm_mouse_vers > 1 && !bevalterm_ison)
- /* disable mouse movement events, enabling is below */
+ // disable mouse movement events, enabling is below
out_str_nf((char_u *)
(IF_EB("\033[?1003l", ESC_STR "[?1003l")));
}
@@ -3664,7 +3661,7 @@ mch_setmouse(int on)
if (xterm_mouse_vers > 0)
{
- if (on) /* enable mouse events, use mouse tracking if available */
+ if (on) // enable mouse events, use mouse tracking if available
out_str_nf((char_u *)
(xterm_mouse_vers > 1
? (
@@ -3674,7 +3671,7 @@ mch_setmouse(int on)
#endif
IF_EB("\033[?1002h", ESC_STR "[?1002h"))
: IF_EB("\033[?1000h", ESC_STR "[?1000h")));
- else /* disable mouse events, could probably always send the same */
+ else // disable mouse events, could probably always send the same
out_str_nf((char_u *)
(xterm_mouse_vers > 1
? IF_EB("\033[?1002l", ESC_STR "[?1002l")
@@ -3685,9 +3682,9 @@ mch_setmouse(int on)
#ifdef FEAT_MOUSE_DEC
else if (ttym_flags == TTYM_DEC)
{
- if (on) /* enable mouse events */
+ if (on) // enable mouse events
out_str_nf((char_u *)"\033[1;2'z\033[1;3'{");
- else /* disable mouse events */
+ else // disable mouse events
out_str_nf((char_u *)"\033['z");
mouse_ison = on;
}
@@ -3730,23 +3727,22 @@ mch_setmouse(int on)
{
if (on)
{
- /* D - Enable Mouse up/down messages
- * L - Enable Left Button Reporting
- * M - Enable Middle Button Reporting
- * R - Enable Right Button Reporting
- * K - Enable SHIFT and CTRL key Reporting
- * + - Enable Advanced messaging of mouse moves and up/down messages
- * Q - Quiet No Ack
- * # - Numeric value of mouse pointer required
- * 0 = Multiview 2000 cursor, used as standard
- * 1 = Windows Arrow
- * 2 = Windows I Beam
- * 3 = Windows Hour Glass
- * 4 = Windows Cross Hair
- * 5 = Windows UP Arrow
- */
+ // D - Enable Mouse up/down messages
+ // L - Enable Left Button Reporting
+ // M - Enable Middle Button Reporting
+ // R - Enable Right Button Reporting
+ // K - Enable SHIFT and CTRL key Reporting
+ // + - Enable Advanced messaging of mouse moves and up/down messages
+ // Q - Quiet No Ack
+ // # - Numeric value of mouse pointer required
+ // 0 = Multiview 2000 cursor, used as standard
+ // 1 = Windows Arrow
+ // 2 = Windows I Beam
+ // 3 = Windows Hour Glass
+ // 4 = Windows Cross Hair
+ // 5 = Windows UP Arrow
# ifdef JSBTERM_MOUSE_NONADVANCED
- /* Disables full feedback of pointer movements */
+ // Disables full feedback of pointer movements
out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK1Q\033\\",
ESC_STR "[0~ZwLMRK1Q" ESC_STR "\\"));
# else
@@ -3766,7 +3762,7 @@ mch_setmouse(int on)
#ifdef FEAT_MOUSE_PTERM
else
{
- /* 1 = button press, 6 = release, 7 = drag, 1h...9l = right button */
+ // 1 = button press, 6 = release, 7 = drag, 1h...9l = right button
if (on)
out_str_nf("\033[>1h\033[>6h\033[>7h\033[>1h\033[>9l");
else
@@ -3808,8 +3804,8 @@ check_mouse_termcode(void)
: IF_EB("\033[M", ESC_STR "[M")));
if (*p_mouse != NUL)
{
- /* force mouse off and maybe on to send possibly new mouse
- * activation sequence to the xterm, with(out) drag tracing. */
+ // force mouse off and maybe on to send possibly new mouse
+ // activation sequence to the xterm, with(out) drag tracing.
mch_setmouse(FALSE);
setmouse();
}
@@ -3840,7 +3836,7 @@ check_mouse_termcode(void)
# endif
# ifdef FEAT_MOUSE_JSB
- /* Conflicts with xterm mouse: "\033[" and "\033[M" ??? */
+ // Conflicts with xterm mouse: "\033[" and "\033[M" ???
if (!use_xterm_mouse()
# ifdef FEAT_GUI
&& !gui.in_use
@@ -3853,8 +3849,8 @@ check_mouse_termcode(void)
# endif
# ifdef FEAT_MOUSE_NET
- /* There is no conflict, but one may type "ESC }" from Insert mode. Don't
- * define it in the GUI or when using an xterm. */
+ // There is no conflict, but one may type "ESC }" from Insert mode. Don't
+ // define it in the GUI or when using an xterm.
if (!use_xterm_mouse()
# ifdef FEAT_GUI
&& !gui.in_use
@@ -3867,7 +3863,7 @@ check_mouse_termcode(void)
# endif
# ifdef FEAT_MOUSE_DEC
- /* Conflicts with xterm mouse: "\033[" and "\033[M" */
+ // Conflicts with xterm mouse: "\033[" and "\033[M"
if (!use_xterm_mouse()
# ifdef FEAT_GUI
&& !gui.in_use
@@ -3879,7 +3875,7 @@ check_mouse_termcode(void)
del_mouse_termcode(KS_DEC_MOUSE);
# endif
# ifdef FEAT_MOUSE_PTERM
- /* same conflict as the dec mouse */
+ // same conflict as the dec mouse
if (!use_xterm_mouse()
# ifdef FEAT_GUI
&& !gui.in_use
@@ -3975,7 +3971,7 @@ mch_get_shellsize(void)
struct winsize ws;
int fd = 1;
- /* When stdout is not a tty, use stdin for the ioctl(). */
+ // When stdout is not a tty, use stdin for the ioctl().
if (!isatty(fd) && isatty(read_cmd_fd))
fd = read_cmd_fd;
if (ioctl(fd, TIOCGWINSZ, &ws) == 0)
@@ -3984,13 +3980,13 @@ mch_get_shellsize(void)
rows = ws.ws_row;
}
}
-# else /* TIOCGWINSZ */
+# else // TIOCGWINSZ
# ifdef TIOCGSIZE
{
struct ttysize ts;
int fd = 1;
- /* When stdout is not a tty, use stdin for the ioctl(). */
+ // When stdout is not a tty, use stdin for the ioctl().
if (!isatty(fd) && isatty(read_cmd_fd))
fd = read_cmd_fd;
if (ioctl(fd, TIOCGSIZE, &ts) == 0)
@@ -3999,8 +3995,8 @@ mch_get_shellsize(void)
rows = ts.ts_lines;
}
}
-# endif /* TIOCGSIZE */
-# endif /* TIOCGWINSZ */
+# endif // TIOCGSIZE
+# endif // TIOCGWINSZ
/*
* 2. get size from environment
@@ -4089,11 +4085,11 @@ mch_set_shellsize(void)
*/
term_set_winsize((int)Rows, (int)Columns);
out_flush();
- screen_start(); /* don't know where cursor is now */
+ screen_start(); // don't know where cursor is now
}
}
-#endif /* VMS */
+#endif // VMS
/*
* Rows and/or Columns has changed.
@@ -4101,7 +4097,7 @@ mch_set_shellsize(void)
void
mch_new_shellsize(void)
{
- /* Nothing to do. */
+ // Nothing to do.
}
/*
@@ -4116,10 +4112,10 @@ wait4pid(pid_t child, waitstatus *status)
while (wait_pid != child)
{
- /* When compiled with Python threads are probably used, in which case
- * wait() sometimes hangs for no obvious reason. Use waitpid()
- * instead and loop (like the GUI). Also needed for other interfaces,
- * they might call system(). */
+ // When compiled with Python threads are probably used, in which case
+ // wait() sometimes hangs for no obvious reason. Use waitpid()
+ // instead and loop (like the GUI). Also needed for other interfaces,
+ // they might call system().
# ifdef __NeXT__
wait_pid = wait4(child, status, WNOHANG, (struct rusage *)0);
# else
@@ -4127,7 +4123,7 @@ wait4pid(pid_t child, waitstatus *status)
# endif
if (wait_pid == 0)
{
- /* Wait for 1 to 10 msec before trying again. */
+ // Wait for 1 to 10 msec before trying again.
mch_delay(delay_msec, TRUE);
if (++delay_msec > 10)
delay_msec = 10;
@@ -4255,9 +4251,9 @@ open_pty(int *pty_master_fd, int *pty_slave_fd, char_u **name1, char_u **name2)
*pty_master_fd = mch_openpty(&tty_name); // open pty
if (*pty_master_fd >= 0)
{
- /* Leaving out O_NOCTTY may lead to waitpid() always returning
- * 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
- * adding O_NOCTTY always works when defined. */
+ // Leaving out O_NOCTTY may lead to waitpid() always returning
+ // 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
+ // adding O_NOCTTY always works when defined.
#ifdef O_NOCTTY
*pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
#else
@@ -4301,6 +4297,11 @@ may_send_sigint(int c UNUSED, pid_t pid UNUSED, pid_t wpid UNUSED)
#if !defined(USE_SYSTEM) || defined(FEAT_TERMINAL) || defined(PROTO)
+/*
+ * Parse "cmd" and return the result in "argvp" which is an allocated array of
+ * pointers, the last one is NULL.
+ * The "sh_tofree" and "shcf_tofree" must be later freed by the caller.
+ */
int
unix_build_argv(
char_u *cmd,
@@ -4312,7 +4313,7 @@ unix_build_argv(
int argc;
*sh_tofree = vim_strsave(p_sh);
- if (*sh_tofree == NULL) /* out of memory */
+ if (*sh_tofree == NULL) // out of memory
return FAIL;
if (mch_parse_cmd(*sh_tofree, TRUE, &argv, &argc) == FAIL)
@@ -4327,10 +4328,10 @@ unix_build_argv(
if (extra_shell_arg != NULL)
argv[argc++] = (char *)extra_shell_arg;
- /* Break 'shellcmdflag' into white separated parts. This doesn't
- * handle quoted strings, they are very unlikely to appear. */
+ // Break 'shellcmdflag' into white separated parts. This doesn't
+ // handle quoted strings, they are very unlikely to appear.
*shcf_tofree = alloc(STRLEN(p_shcf) + 1);
- if (*shcf_tofree == NULL) /* out of memory */
+ if (*shcf_tofree == NULL) // out of memory
return FAIL;
s = *shcf_tofree;
p = p_shcf;
@@ -4357,7 +4358,7 @@ unix_build_argv(
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 **argv = NULL;
@@ -4367,7 +4368,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 (unix_build_argv(cmd, &argv, &tofree1, &tofree2) == FAIL)
goto theend;
@@ -4381,7 +4382,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);
@@ -4389,8 +4390,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);
}
@@ -4402,7 +4403,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);
@@ -4423,20 +4424,20 @@ theend:
static int
mch_call_shell_system(
char_u *cmd,
- int options) /* SHELL_*, see vim.h */
+ int options) // SHELL_*, see vim.h
{
#ifdef VMS
char *ifn = NULL;
char *ofn = NULL;
#endif
int tmode = cur_tmode;
- char_u *newcmd; /* only needed for unix */
+ char_u *newcmd; // only needed for unix
int x;
out_flush();
if (options & SHELL_COOKED)
- settmode(TMODE_COOK); /* set to normal mode */
+ settmode(TMODE_COOK); // set to normal mode
# if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
save_clipboard();
@@ -4455,7 +4456,7 @@ mch_call_shell_system(
char *p;
*ifn++ = '\0';
- p = strchr(ifn,' '); /* chop off any trailing spaces */
+ p = strchr(ifn,' '); // chop off any trailing spaces
if (p)
*p = '\0';
}
@@ -4495,7 +4496,7 @@ mch_call_shell_system(
}
if (tmode == TMODE_RAW)
- settmode(TMODE_RAW); /* set to raw mode */
+ settmode(TMODE_RAW); // set to raw mode
# ifdef FEAT_TITLE
resettitle();
# endif
@@ -4505,11 +4506,11 @@ mch_call_shell_system(
return x;
}
-#else /* USE_SYSTEM */
+#else // USE_SYSTEM
-# define EXEC_FAILED 122 /* Exit code when shell didn't execute. Don't use
- 127, some shells use that already */
-# define OPEN_NULL_FAILED 123 /* Exit code if /dev/null can't be opened */
+# define EXEC_FAILED 122 // Exit code when shell didn't execute. Don't use
+ // 127, some shells use that already
+# define OPEN_NULL_FAILED 123 // Exit code if /dev/null can't be opened
/*
* Don't use system(), use fork()/exec().
@@ -4517,7 +4518,7 @@ mch_call_shell_system(
static int
mch_call_shell_fork(
char_u *cmd,
- int options) /* SHELL_*, see vim.h */
+ int options) // SHELL_*, see vim.h
{
int tmode = cur_tmode;
pid_t pid;
@@ -4533,18 +4534,18 @@ mch_call_shell_fork(
char_u *tofree1 = NULL;
char_u *tofree2 = NULL;
int i;
- int pty_master_fd = -1; /* for pty's */
+ int pty_master_fd = -1; // for pty's
# ifdef FEAT_GUI
int pty_slave_fd = -1;
# endif
- int fd_toshell[2]; /* for pipes */
+ int fd_toshell[2]; // for pipes
int fd_fromshell[2];
int pipe_error = FALSE;
- int did_settmode = FALSE; /* settmode(TMODE_RAW) called */
+ int did_settmode = FALSE; // settmode(TMODE_RAW) called
out_flush();
if (options & SHELL_COOKED)
- settmode(TMODE_COOK); /* set to normal mode */
+ settmode(TMODE_COOK); // set to normal mode
if (unix_build_argv(cmd, &argv, &tofree1, &tofree2) == FAIL)
goto error;
@@ -4575,10 +4576,10 @@ mch_call_shell_fork(
# endif
{
pipe_error = (pipe(fd_toshell) < 0);
- if (!pipe_error) /* pipe create OK */
+ if (!pipe_error) // pipe create OK
{
pipe_error = (pipe(fd_fromshell) < 0);
- if (pipe_error) /* pipe create failed */
+ if (pipe_error) // pipe create failed
{
close(fd_toshell[0]);
close(fd_toshell[1]);
@@ -4592,7 +4593,7 @@ mch_call_shell_fork(
}
}
- if (!pipe_error) /* pty or pipe opened or not used */
+ if (!pipe_error) // pty or pipe opened or not used
{
SIGSET_DECL(curset)
@@ -4601,7 +4602,7 @@ mch_call_shell_fork(
# endif
BLOCK_SIGNALS(&curset);
- pid = fork(); /* maybe we should use vfork() */
+ pid = fork(); // maybe we should use vfork()
if (pid == -1)
{
UNBLOCK_SIGNALS(&curset);
@@ -4614,12 +4615,12 @@ mch_call_shell_fork(
)
{
# ifdef FEAT_GUI
- if (pty_master_fd >= 0) /* close the pseudo tty */
+ if (pty_master_fd >= 0) // close the pseudo tty
{
close(pty_master_fd);
close(pty_slave_fd);
}
- else /* close the pipes */
+ else // close the pipes
# endif
{
close(fd_toshell[0]);
@@ -4629,14 +4630,14 @@ mch_call_shell_fork(
}
}
}
- else if (pid == 0) /* child */
+ else if (pid == 0) // child
{
- reset_signals(); /* handle signals normally */
+ reset_signals(); // handle signals normally
UNBLOCK_SIGNALS(&curset);
# ifdef FEAT_JOB_CHANNEL
if (ch_log_active())
- /* close the log file in the child */
+ // close the log file in the child
ch_logfile((char_u *)"", (char_u *)"");
# endif
@@ -4668,11 +4669,11 @@ mch_call_shell_fork(
*/
if (fd >= 0)
{
- vim_ignored = dup(fd); /* To replace stdin (fd 0) */
- vim_ignored = dup(fd); /* To replace stdout (fd 1) */
- vim_ignored = dup(fd); /* To replace stderr (fd 2) */
+ vim_ignored = dup(fd); // To replace stdin (fd 0)
+ vim_ignored = dup(fd); // To replace stdout (fd 1)
+ vim_ignored = dup(fd); // To replace stderr (fd 2)
- /* Don't need this now that we've duplicated it */
+ // Don't need this now that we've duplicated it
close(fd);
}
}
@@ -4684,18 +4685,17 @@ mch_call_shell_fork(
{
# ifdef HAVE_SETSID
- /* Create our own process group, so that the child and all its
- * children can be kill()ed. Don't do this when using pipes,
- * because stdin is not a tty, we would lose /dev/tty. */
+ // Create our own process group, so that the child and all its
+ // children can be kill()ed. Don't do this when using pipes,
+ // because stdin is not a tty, we would lose /dev/tty.
if (p_stmp)
{
(void)setsid();
# if defined(SIGHUP)
- /* When doing "!xterm&" and 'shell' is bash: the shell
- * will exit and send SIGHUP to all processes in its
- * group, killing the just started process. Ignore SIGHUP
- * to avoid that. (suggested by Simon Schubert)
- */
+ // When doing "!xterm&" and 'shell' is bash: the shell
+ // will exit and send SIGHUP to all processes in its
+ // group, killing the just started process. Ignore SIGHUP
+ // to avoid that. (suggested by Simon Schubert)
signal(SIGHUP, SIG_IGN);
# endif
}
@@ -4703,12 +4703,12 @@ mch_call_shell_fork(
# ifdef FEAT_GUI
if (pty_slave_fd >= 0)
{
- /* push stream discipline modules */
+ // push stream discipline modules
if (options & SHELL_COOKED)
setup_slavepty(pty_slave_fd);
# ifdef TIOCSCTTY
- /* Try to become controlling tty (probably doesn't work,
- * unless run by root) */
+ // Try to become controlling tty (probably doesn't work,
+ // unless run by root)
ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL);
# endif
}
@@ -4723,9 +4723,9 @@ mch_call_shell_fork(
# ifdef FEAT_GUI
if (pty_master_fd >= 0)
{
- close(pty_master_fd); /* close master side of pty */
+ close(pty_master_fd); // close master side of pty
- /* set up stdin/stdout/stderr for the child */
+ // set up stdin/stdout/stderr for the child
close(0);
vim_ignored = dup(pty_slave_fd);
close(1);
@@ -4736,18 +4736,18 @@ mch_call_shell_fork(
vim_ignored = dup(pty_slave_fd);
}
- close(pty_slave_fd); /* has been dupped, close it now */
+ close(pty_slave_fd); // has been dupped, close it now
}
else
# endif
{
- /* set up stdin for the child */
+ // set up stdin for the child
close(fd_toshell[1]);
close(0);
vim_ignored = dup(fd_toshell[0]);
close(fd_toshell[0]);
- /* set up stdout for the child */
+ // set up stdout for the child
close(fd_fromshell[0]);
close(1);
vim_ignored = dup(fd_fromshell[1]);
@@ -4756,7 +4756,7 @@ mch_call_shell_fork(
# ifdef FEAT_GUI
if (gui.in_use)
{
- /* set up stderr for the child */
+ // set up stderr for the child
close(2);
vim_ignored = dup(1);
}
@@ -4772,9 +4772,9 @@ mch_call_shell_fork(
* to the X server (esp. with GTK, which uses atexit()).
*/
execvp(argv[0], argv);
- _exit(EXEC_FAILED); /* exec failed, return failure code */
+ _exit(EXEC_FAILED); // exec failed, return failure code
}
- else /* parent */
+ else // parent
{
/*
* While child is running, ignore terminating signals.
@@ -4797,11 +4797,11 @@ mch_call_shell_fork(
# endif
)
{
-# define BUFLEN 100 /* length for buffer, pseudo tty limit is 128 */
+# define BUFLEN 100 // length for buffer, pseudo tty limit is 128
char_u buffer[BUFLEN + 1];
- int buffer_off = 0; /* valid bytes in buffer[] */
- char_u ta_buf[BUFLEN + 1]; /* TypeAHead */
- int ta_len = 0; /* valid bytes in ta_buf[] */
+ int buffer_off = 0; // valid bytes in buffer[]
+ char_u ta_buf[BUFLEN + 1]; // TypeAHead
+ int ta_len = 0; // valid bytes in ta_buf[]
int len;
int p_more_save;
int old_State;
@@ -4848,17 +4848,17 @@ mch_call_shell_fork(
p_more_save = p_more;
p_more = FALSE;
old_State = State;
- State = EXTERNCMD; /* don't redraw at window resize */
+ State = EXTERNCMD; // don't redraw at window resize
if ((options & SHELL_WRITE) && toshell_fd >= 0)
{
- /* Fork a process that will write the lines to the
- * external program. */
+ // Fork a process that will write the lines to the
+ // external program.
if ((wpid = fork()) == -1)
{
msg_puts(_("\nCannot fork\n"));
}
- else if (wpid == 0) /* child */
+ else if (wpid == 0) // child
{
linenr_T lnum = curbuf->b_op_start.lnum;
int written = 0;
@@ -4872,7 +4872,7 @@ mch_call_shell_fork(
if (l == 0)
len = 0;
else if (lp[written] == NL)
- /* NL -> NUL translation */
+ // NL -> NUL translation
len = write(toshell_fd, "", (size_t)1);
else
{
@@ -4884,8 +4884,8 @@ mch_call_shell_fork(
}
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)
@@ -4898,7 +4898,7 @@ mch_call_shell_fork(
++lnum;
if (lnum > curbuf->b_op_end.lnum)
{
- /* finished all the lines, close pipe */
+ // finished all the lines, close pipe
close(toshell_fd);
toshell_fd = -1;
break;
@@ -4911,7 +4911,7 @@ mch_call_shell_fork(
}
_exit(0);
}
- else /* parent */
+ else // parent
{
close(toshell_fd);
toshell_fd = -1;
@@ -4955,8 +4955,8 @@ mch_call_shell_fork(
{
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;
# ifdef ELAPSED_FUNC
ELAPSED_INIT(start_tv);
@@ -4986,7 +4986,7 @@ mch_call_shell_fork(
}
}
- /* 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)
@@ -5059,8 +5059,8 @@ mch_call_shell_fork(
if (got_int)
{
- /* CTRL-C sends a signal to the child, we ignore it
- * ourselves */
+ // CTRL-C sends a signal to the child, we ignore it
+ // ourselves
# ifdef HAVE_SETSID
kill(-pid, SIGINT);
# else
@@ -5086,14 +5086,14 @@ mch_call_shell_fork(
len = read_eintr(fromshell_fd, buffer
+ buffer_off, (size_t)(BUFLEN - buffer_off)
);
- if (len <= 0) /* end of file or error */
+ if (len <= 0) // end of file or error
goto finished;
noread_cnt = 0;
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)
@@ -5112,20 +5112,20 @@ mch_call_shell_fork(
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
@@ -5163,9 +5163,9 @@ mch_call_shell_fork(
{
long msec = ELAPSED_FUNC(start_tv);
- /* Avoid that we keep looping here without
- * checking for a CTRL-C for a long time. Don't
- * break out too often to avoid losing typeahead. */
+ // Avoid that we keep looping here without
+ // checking for a CTRL-C for a long time. Don't
+ // break out too often to avoid losing typeahead.
if (msec > 2000)
{
noread_cnt = 5;
@@ -5175,9 +5175,9 @@ mch_call_shell_fork(
# endif
}
- /* If we already detected the child has finished, continue
- * reading output for a short while. Some text may be
- * buffered. */
+ // If we already detected the child has finished, continue
+ // reading output for a short while. Some text may be
+ // buffered.
if (wait_pid == pid)
{
if (noread_cnt < 5)
@@ -5197,17 +5197,17 @@ mch_call_shell_fork(
if ((wait_pid == (pid_t)-1 && errno == ECHILD)
|| (wait_pid == pid && WIFEXITED(status)))
{
- /* Don't break the loop yet, try reading more
- * characters from "fromshell_fd" first. When using
- * pipes there might still be something to read and
- * then we'll break the loop at the "break" above. */
+ // Don't break the loop yet, try reading more
+ // characters from "fromshell_fd" first. When using
+ // pipes there might still be something to read and
+ // then we'll break the loop at the "break" above.
wait_pid = pid;
}
else
wait_pid = 0;
# if defined(FEAT_XCLIPBOARD) && defined(FEAT_X11)
- /* Handle any X events, e.g. serving the clipboard. */
+ // Handle any X events, e.g. serving the clipboard.
clip_update();
# endif
}
@@ -5218,7 +5218,7 @@ finished:
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
@@ -5249,8 +5249,8 @@ finished:
{
if (got_int)
{
- /* CTRL-C sends a signal to the child, we ignore it
- * ourselves */
+ // CTRL-C sends a signal to the child, we ignore it
+ // ourselves
# ifdef HAVE_SETSID
kill(-pid, SIGINT);
# else
@@ -5270,11 +5270,11 @@ finished:
break;
}
- /* Handle any X events, e.g. serving the clipboard. */
+ // Handle any X events, e.g. serving the clipboard.
clip_update();
- /* Wait for 1 to 10 msec. 1 is faster but gives the child
- * less time. */
+ // Wait for 1 to 10 msec. 1 is faster but gives the child
+ // less time.
mch_delay(delay_msec, TRUE);
if (++delay_msec > 10)
delay_msec = 10;
@@ -5293,15 +5293,15 @@ finished:
wait_pid = wait4pid(pid, &status);
# ifdef FEAT_GUI
- /* Close slave side of pty. Only do this after the child has
- * exited, otherwise the child may hang when it tries to write on
- * the pty. */
+ // Close slave side of pty. Only do this after the child has
+ // exited, otherwise the child may hang when it tries to write on
+ // the pty.
if (pty_master_fd >= 0)
close(pty_slave_fd);
# endif
- /* Make sure the child that writes to the external program is
- * dead. */
+ // Make sure the child that writes to the external program is
+ // dead.
if (wpid > 0)
{
kill(wpid, SIGKILL);
@@ -5323,7 +5323,7 @@ finished:
if (WIFEXITED(status))
{
- /* LINTED avoid "bitwise operation on signed value" */
+ // LINTED avoid "bitwise operation on signed value"
retval = WEXITSTATUS(status);
if (retval != 0 && !emsg_silent)
{
@@ -5349,7 +5349,7 @@ finished:
error:
if (!did_settmode)
if (tmode == TMODE_RAW)
- settmode(TMODE_RAW); /* set to raw mode */
+ settmode(TMODE_RAW); // set to raw mode
# ifdef FEAT_TITLE
resettitle();
# endif
@@ -5359,12 +5359,12 @@ error:
return retval;
}
-#endif /* USE_SYSTEM */
+#endif // USE_SYSTEM
int
mch_call_shell(
char_u *cmd,
- int options) /* SHELL_*, see vim.h */
+ int options) // SHELL_*, see vim.h
{
#if defined(FEAT_GUI) && defined(FEAT_TERMINAL)
if (gui.in_use && vim_strchr(p_go, GO_TERMINAL) != NULL)
@@ -5382,9 +5382,9 @@ mch_call_shell(
mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
{
pid_t pid;
- int fd_in[2] = {-1, -1}; /* for stdin */
- int fd_out[2] = {-1, -1}; /* for stdout */
- int fd_err[2] = {-1, -1}; /* for stderr */
+ int fd_in[2] = {-1, -1}; // for stdin
+ int fd_out[2] = {-1, -1}; // for stdout
+ int fd_err[2] = {-1, -1}; // for stderr
int pty_master_fd = -1;
int pty_slave_fd = -1;
channel_T *channel = NULL;
@@ -5401,7 +5401,7 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
if (use_out_for_err && use_null_for_out)
use_null_for_err = TRUE;
- /* default is to fail */
+ // default is to fail
job->jv_status = JOB_FAILED;
if (options->jo_pty
@@ -5411,8 +5411,8 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
open_pty(&pty_master_fd, &pty_slave_fd,
&job->jv_tty_out, &job->jv_tty_in);
- /* TODO: without the channel feature connect the child to /dev/null? */
- /* Open pipes for stdin, stdout, stderr. */
+ // TODO: without the channel feature connect the child to /dev/null?
+ // Open pipes for stdin, stdout, stderr.
if (use_file_for_in)
{
char_u *fname = options->jo_io_name[PART_IN];
@@ -5425,8 +5425,8 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
}
}
else
- /* When writing buffer lines to the input don't use the pty, so that
- * the pipe can be closed when all lines were written. */
+ // When writing buffer lines to the input don't use the pty, so that
+ // the pipe can be closed when all lines were written.
if (!use_null_for_in && (pty_master_fd < 0 || use_buffer_for_in)
&& pipe(fd_in) < 0)
goto failed;
@@ -5478,10 +5478,10 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
}
BLOCK_SIGNALS(&curset);
- pid = fork(); /* maybe we should use vfork() */
+ pid = fork(); // maybe we should use vfork()
if (pid == -1)
{
- /* failed to fork */
+ // failed to fork
UNBLOCK_SIGNALS(&curset);
goto failed;
}
@@ -5490,20 +5490,20 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
int null_fd = -1;
int stderr_works = TRUE;
- /* child */
- reset_signals(); /* handle signals normally */
+ // child
+ reset_signals(); // handle signals normally
UNBLOCK_SIGNALS(&curset);
# ifdef FEAT_JOB_CHANNEL
if (ch_log_active())
- /* close the log file in the child */
+ // close the log file in the child
ch_logfile((char_u *)"", (char_u *)"");
# endif
# ifdef HAVE_SETSID
- /* Create our own process group, so that the child and all its
- * children can be kill()ed. Don't do this when using pipes,
- * because stdin is not a tty, we would lose /dev/tty. */
+ // Create our own process group, so that the child and all its
+ // children can be kill()ed. Don't do this when using pipes,
+ // because stdin is not a tty, we would lose /dev/tty.
(void)setsid();
# endif
@@ -5514,11 +5514,11 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
#ifdef FEAT_GUI
if (term_is_gui(T_NAME))
- /* In the GUI 'term' is not what we want, use $TERM. */
+ // In the GUI 'term' is not what we want, use $TERM.
term = getenv("TERM");
#endif
- /* Use 'term' or $TERM if it starts with "xterm", otherwise fall
- * back to "xterm". */
+ // Use 'term' or $TERM if it starts with "xterm", otherwise fall
+ // back to "xterm".
if (term == NULL || *term == NUL || STRNCMP(term, "xterm", 5) != 0)
term = "xterm";
set_child_environment(
@@ -5559,16 +5559,16 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
if (pty_slave_fd >= 0)
{
- /* push stream discipline modules */
+ // push stream discipline modules
setup_slavepty(pty_slave_fd);
# ifdef TIOCSCTTY
- /* Try to become controlling tty (probably doesn't work,
- * unless run by root) */
+ // Try to become controlling tty (probably doesn't work,
+ // unless run by root)
ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL);
# endif
}
- /* set up stdin for the child */
+ // set up stdin for the child
close(0);
if (use_null_for_in && null_fd >= 0)
vim_ignored = dup(null_fd);
@@ -5577,7 +5577,7 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
else
vim_ignored = dup(fd_in[0]);
- /* set up stderr for the child */
+ // set up stderr for the child
close(2);
if (use_null_for_err && null_fd >= 0)
{
@@ -5591,7 +5591,7 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
else
vim_ignored = dup(fd_err[1]);
- /* set up stdout for the child */
+ // set up stdout for the child
close(1);
if (use_null_for_out && null_fd >= 0)
vim_ignored = dup(null_fd);
@@ -5614,8 +5614,8 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
close(fd_err[1]);
if (pty_master_fd >= 0)
{
- close(pty_master_fd); /* not used in the child */
- close(pty_slave_fd); /* was duped above */
+ close(pty_master_fd); // not used in the child
+ close(pty_slave_fd); // was duped above
}
if (null_fd >= 0)
@@ -5624,28 +5624,28 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
if (options->jo_cwd != NULL && mch_chdir((char *)options->jo_cwd) != 0)
_exit(EXEC_FAILED);
- /* See above for type of argv. */
+ // See above for type of argv.
execvp(argv[0], argv);
if (stderr_works)
perror("executing job failed");
# ifdef EXITFREE
- /* calling free_all_mem() here causes problems. Ignore valgrind
- * reporting possibly leaked memory. */
+ // calling free_all_mem() here causes problems. Ignore valgrind
+ // reporting possibly leaked memory.
# endif
- _exit(EXEC_FAILED); /* exec failed, return failure code */
+ _exit(EXEC_FAILED); // exec failed, return failure code
}
- /* parent */
+ // parent
UNBLOCK_SIGNALS(&curset);
job->jv_pid = pid;
job->jv_status = JOB_STARTED;
- job->jv_channel = channel; /* ch_refcount was set above */
+ job->jv_channel = channel; // ch_refcount was set above
if (pty_master_fd >= 0)
- close(pty_slave_fd); /* not used in the parent */
- /* close child stdin, stdout and stderr */
+ close(pty_slave_fd); // not used in the parent
+ // close child stdin, stdout and stderr
if (fd_in[0] >= 0)
close(fd_in[0]);
if (fd_out[1] >= 0)
@@ -5689,7 +5689,7 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
close(pty_master_fd);
}
- /* success! */
+ // success!
return;
failed:
@@ -5746,7 +5746,7 @@ mch_job_status(job_T *job)
# endif
if (wait_pid == -1)
{
- /* process must have exited */
+ // process must have exited
if (job->jv_status < JOB_ENDED)
ch_log(job->jv_channel, "Job no longer exists: %s",
strerror(errno));
@@ -5756,7 +5756,7 @@ mch_job_status(job_T *job)
return "run";
if (WIFEXITED(status))
{
- /* LINTED avoid "bitwise operation on signed value" */
+ // LINTED avoid "bitwise operation on signed value"
job->jv_exitval = WEXITSTATUS(status);
if (job->jv_status < JOB_ENDED)
ch_log(job->jv_channel, "Job exited with %d", job->jv_exitval);
@@ -5791,9 +5791,9 @@ mch_detect_ended_job(job_T *job_list)
job_T *job;
# ifndef USE_SYSTEM
- /* Do not do this when waiting for a shell command to finish, we would get
- * the exit value here (and discard it), the exit value obtained there
- * would then be wrong. */
+ // Do not do this when waiting for a shell command to finish, we would get
+ // the exit value here (and discard it), the exit value obtained there
+ // would then be wrong.
if (dont_check_job_ended > 0)
return NULL;
# endif
@@ -5804,14 +5804,14 @@ mch_detect_ended_job(job_T *job_list)
wait_pid = waitpid(-1, &status, WNOHANG);
# endif
if (wait_pid <= 0)
- /* no process ended */
+ // no process ended
return NULL;
for (job = job_list; job != NULL; job = job->jv_next)
{
if (job->jv_pid == wait_pid)
{
if (WIFEXITED(status))
- /* LINTED avoid "bitwise operation on signed value" */
+ // LINTED avoid "bitwise operation on signed value"
job->jv_exitval = WEXITSTATUS(status);
else if (WIFSIGNALED(status))
{
@@ -5874,7 +5874,7 @@ mch_signal_job(job_T *job, char_u *how)
void
mch_clear_job(job_T *job)
{
- /* call waitpid because child process may become zombie */
+ // call waitpid because child process may become zombie
# ifdef __NeXT__
(void)wait4(job->jv_pid, NULL, WNOHANG, (struct rusage *)0);
# else
@@ -5903,11 +5903,11 @@ mch_create_pty_channel(job_T *job, jobopt_T *options)
if (job->jv_tty_out != NULL)
ch_log(channel, "using pty %s on fd %d",
job->jv_tty_out, pty_master_fd);
- job->jv_channel = channel; /* ch_refcount was set by add_channel() */
+ job->jv_channel = channel; // ch_refcount was set by add_channel()
channel->ch_keep_open = TRUE;
- /* Only set the pty_master_fd for stdout, do not duplicate it for stderr,
- * it only needs to be read once. */
+ // Only set the pty_master_fd for stdout, do not duplicate it for stderr,
+ // it only needs to be read once.
channel_set_pipes(channel, pty_master_fd, pty_master_fd, INVALID_FD);
channel_set_job(channel, job, options);
return OK;
@@ -5969,11 +5969,11 @@ WaitForCharOrMouse(long msec, int *interrupted, int ignore_input)
#endif
int avail;
- if (!ignore_input && input_available()) /* something in inbuf[] */
+ if (!ignore_input && input_available()) // something in inbuf[]
return 1;
#if defined(FEAT_MOUSE_DEC)
- /* May need to query the mouse position. */
+ // May need to query the mouse position.
if (WantQueryMouse)
{
WantQueryMouse = FALSE;
@@ -6066,12 +6066,12 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
#if defined(FEAT_XCLIPBOARD) || defined(USE_XSMP) || defined(FEAT_MZSCHEME)
static int busy = FALSE;
- /* May retry getting characters after an event was handled. */
+ // May retry getting characters after an event was handled.
# define MAY_LOOP
# ifdef ELAPSED_FUNC
- /* Remember at what time we started, so that we know how much longer we
- * should wait after being interrupted. */
+ // Remember at what time we started, so that we know how much longer we
+ // should wait after being interrupted.
long start_msec = msec;
elapsed_T start_tv;
@@ -6079,8 +6079,8 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
ELAPSED_INIT(start_tv);
# endif
- /* Handle being called recursively. This may happen for the session
- * manager stuff, it may save the file, which does a breakcheck. */
+ // Handle being called recursively. This may happen for the session
+ // manager stuff, it may save the file, which does a breakcheck.
if (busy)
return 0;
#endif
@@ -6090,13 +6090,13 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
#endif
{
#ifdef MAY_LOOP
- int finished = TRUE; /* default is to 'loop' just once */
+ int finished = TRUE; // default is to 'loop' just once
# ifdef FEAT_MZSCHEME
int mzquantum_used = FALSE;
# endif
#endif
#ifndef HAVE_SELECT
- /* each channel may use in, out and err */
+ // each channel may use in, out and err
struct pollfd fds[6 + 3 * MAX_OPEN_CHANNELS];
int nfd;
# ifdef FEAT_XCLIPBOARD
@@ -6114,7 +6114,7 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
mzvim_check_threads();
if (mzthreads_allowed() && p_mzq > 0 && (msec < 0 || msec > p_mzq))
{
- towait = (int)p_mzq; /* don't wait longer than 'mzquantum' */
+ towait = (int)p_mzq; // don't wait longer than 'mzquantum'
mzquantum_used = TRUE;
}
# endif
@@ -6164,16 +6164,16 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
# ifdef FEAT_MZSCHEME
if (ret == 0 && mzquantum_used)
- /* MzThreads scheduling is required and timeout occurred */
+ // MzThreads scheduling is required and timeout occurred
finished = FALSE;
# endif
# ifdef FEAT_XCLIPBOARD
if (xterm_Shell != (Widget)0 && (fds[xterm_idx].revents & POLLIN))
{
- xterm_update(); /* Maybe we should hand out clipboard */
+ xterm_update(); // Maybe we should hand out clipboard
if (--ret == 0 && !input_available())
- /* Try again */
+ // Try again
finished = FALSE;
}
# endif
@@ -6197,7 +6197,7 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
xsmp_close();
}
if (--ret == 0)
- finished = FALSE; /* Try again */
+ finished = FALSE; // Try again
}
# endif
#ifdef FEAT_JOB_CHANNEL
@@ -6206,7 +6206,7 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
channel_poll_check(ret, &fds);
#endif
-#else /* HAVE_SELECT */
+#else // HAVE_SELECT
struct timeval tv;
struct timeval *tvp;
@@ -6220,7 +6220,7 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted)
mzvim_check_threads();
if (mzthreads_allowed() && p_mzq > 0 && (msec < 0 || msec > p_mzq))
{
- towait = p_mzq; /* don't wait longer than 'mzquantum' */
+ towait = p_mzq; // don't wait longer than 'mzquantum'
mzquantum_used = TRUE;
}
# endif
@@ -6243,7 +6243,7 @@ select_eintr:
FD_ZERO(&efds);
FD_SET(fd, &rfds);
# if !defined(__QNX__) && !defined(__CYGWIN32__)
- /* For QNX select() always returns 1 if this is set. Why? */
+ // For QNX select() always returns 1 if this is set. Why?
FD_SET(fd, &efds);
# endif
maxfd = fd;
@@ -6256,8 +6256,8 @@ select_eintr:
if (maxfd < ConnectionNumber(xterm_dpy))
maxfd = ConnectionNumber(xterm_dpy);
- /* An event may have already been read but not handled. In
- * particularly, XFlush may cause this. */
+ // An event may have already been read but not handled. In
+ // particularly, XFlush may cause this.
xterm_update();
}
# endif
@@ -6296,15 +6296,15 @@ select_eintr:
# ifdef EINTR
if (ret == -1 && errno == EINTR)
{
- /* Check whether window has been resized, EINTR may be caused by
- * SIGWINCH. */
+ // Check whether window has been resized, EINTR may be caused by
+ // SIGWINCH.
if (do_resize)
handle_resize();
- /* Interrupted by a signal, need to try again. We ignore msec
- * here, because we do want to check even after a timeout if
- * characters are available. Needed for reading output of an
- * external command after the process has finished. */
+ // Interrupted by a signal, need to try again. We ignore msec
+ // here, because we do want to check even after a timeout if
+ // characters are available. Needed for reading output of an
+ // external command after the process has finished.
goto select_eintr;
}
# endif
@@ -6318,7 +6318,7 @@ select_eintr:
# endif
# ifdef FEAT_MZSCHEME
if (ret == 0 && mzquantum_used)
- /* loop if MzThreads must be scheduled and timeout occurred */
+ // loop if MzThreads must be scheduled and timeout occurred
finished = FALSE;
# endif
@@ -6326,12 +6326,12 @@ select_eintr:
if (ret > 0 && xterm_Shell != (Widget)0
&& FD_ISSET(ConnectionNumber(xterm_dpy), &rfds))
{
- xterm_update(); /* Maybe we should hand out clipboard */
- /* continue looping when we only got the X event and the input
- * buffer is empty */
+ xterm_update(); // Maybe we should hand out clipboard
+ // continue looping when we only got the X event and the input
+ // buffer is empty
if (--ret == 0 && !input_available())
{
- /* Try again */
+ // Try again
finished = FALSE;
}
}
@@ -6354,7 +6354,7 @@ select_eintr:
verb_msg(_("XSMP lost ICE connection"));
xsmp_close();
if (--ret == 0)
- finished = FALSE; /* keep going if event was only one */
+ finished = FALSE; // keep going if event was only one
}
else if (FD_ISSET(xsmp_icefd, &rfds))
{
@@ -6362,17 +6362,17 @@ select_eintr:
xsmp_handle_requests();
busy = FALSE;
if (--ret == 0)
- finished = FALSE; /* keep going if event was only one */
+ finished = FALSE; // keep going if event was only one
}
}
# endif
#ifdef FEAT_JOB_CHANNEL
- /* also call when ret == 0, we may be polling a keep-open channel */
+ // also call when ret == 0, we may be polling a keep-open channel
if (ret >= 0)
ret = channel_select_check(ret, &rfds, &wfds);
#endif
-#endif /* HAVE_SELECT */
+#endif // HAVE_SELECT
#ifdef MAY_LOOP
if (finished || msec == 0)
@@ -6383,18 +6383,18 @@ select_eintr:
break;
# endif
- /* We're going to loop around again, find out for how long */
+ // We're going to loop around again, find out for how long
if (msec > 0)
{
# ifdef ELAPSED_FUNC
- /* Compute remaining wait time. */
+ // Compute remaining wait time.
msec = start_msec - ELAPSED_FUNC(start_tv);
# else
- /* Guess we got interrupted halfway. */
+ // Guess we got interrupted halfway.
msec = msec / 2;
# endif
if (msec <= 0)
- break; /* waited long enough */
+ break; // waited long enough
}
#endif
}
@@ -6412,7 +6412,7 @@ select_eintr:
mch_expandpath(
garray_T *gap,
char_u *path,
- int flags) /* EW_* flags */
+ int flags) // EW_* flags
{
return unix_expandpath(gap, path, 0, flags, FALSE);
}
@@ -6445,7 +6445,7 @@ mch_expand_wildcards(
char_u **pat,
int *num_file,
char_u ***file,
- int flags) /* EW_* flags */
+ int flags) // EW_* flags
{
int i;
size_t len;
@@ -6461,20 +6461,20 @@ mch_expand_wildcards(
char_u *command;
FILE *fd;
char_u *buffer;
-#define STYLE_ECHO 0 /* use "echo", the default */
-#define STYLE_GLOB 1 /* use "glob", for csh */
-#define STYLE_VIMGLOB 2 /* use "vimglob", for Posix sh */
-#define STYLE_PRINT 3 /* use "print -N", for zsh */
-#define STYLE_BT 4 /* `cmd` expansion, execute the pattern
- * directly */
+#define STYLE_ECHO 0 // use "echo", the default
+#define STYLE_GLOB 1 // use "glob", for csh
+#define STYLE_VIMGLOB 2 // use "vimglob", for Posix sh
+#define STYLE_PRINT 3 // use "print -N", for zsh
+#define STYLE_BT 4 // `cmd` expansion, execute the pattern
+ // directly
int shell_style = STYLE_ECHO;
int check_spaces;
static int did_find_nul = FALSE;
int ampersand = FALSE;
- /* vimglob() function to define for Posix shell */
+ // vimglob() function to define for Posix shell
static char *sh_vimglob_func = "vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >";
- *num_file = 0; /* default: no files found */
+ *num_file = 0; // default: no files found
*file = NULL;
/*
@@ -6485,7 +6485,7 @@ mch_expand_wildcards(
return save_patterns(num_pat, pat, num_file, file);
# ifdef HAVE_SANDBOX
- /* Don't allow any shell command in the sandbox. */
+ // Don't allow any shell command in the sandbox.
if (sandbox != 0 && check_secure())
return FAIL;
# endif
@@ -6537,25 +6537,25 @@ mch_expand_wildcards(
"sh") != NULL)
shell_style = STYLE_VIMGLOB;
- /* Compute the length of the command. We need 2 extra bytes: for the
- * optional '&' and for the NUL.
- * Worst case: "unset nonomatch; print -N >" plus two is 29 */
+ // Compute the length of the command. We need 2 extra bytes: for the
+ // optional '&' and for the NUL.
+ // Worst case: "unset nonomatch; print -N >" plus two is 29
len = STRLEN(tempname) + 29;
if (shell_style == STYLE_VIMGLOB)
len += STRLEN(sh_vimglob_func);
for (i = 0; i < num_pat; ++i)
{
- /* Count the length of the patterns in the same way as they are put in
- * "command" below. */
+ // Count the length of the patterns in the same way as they are put in
+ // "command" below.
#ifdef USE_SYSTEM
- len += STRLEN(pat[i]) + 3; /* add space and two quotes */
+ len += STRLEN(pat[i]) + 3; // add space and two quotes
#else
- ++len; /* add space */
+ ++len; // add space
for (j = 0; pat[i][j] != NUL; ++j)
{
if (vim_strchr(SHELL_SPECIAL, pat[i][j]) != NULL)
- ++len; /* may add a backslash */
+ ++len; // may add a backslash
++len;
}
#endif
@@ -6563,7 +6563,7 @@ mch_expand_wildcards(
command = alloc(len);
if (command == NULL)
{
- /* out of memory */
+ // out of memory
vim_free(tempname);
return FAIL;
}
@@ -6578,14 +6578,14 @@ mch_expand_wildcards(
*/
if (shell_style == STYLE_BT)
{
- /* change `command; command& ` to (command; command ) */
+ // change `command; command& ` to (command; command )
STRCPY(command, "(");
- STRCAT(command, pat[0] + 1); /* exclude first backtick */
+ STRCAT(command, pat[0] + 1); // exclude first backtick
p = command + STRLEN(command) - 1;
- *p-- = ')'; /* remove last backtick */
+ *p-- = ')'; // remove last backtick
while (p > command && VIM_ISWHITE(*p))
--p;
- if (*p == '&') /* remove trailing '&' */
+ if (*p == '&') // remove trailing '&'
{
ampersand = TRUE;
*p = ' ';
@@ -6613,9 +6613,9 @@ mch_expand_wildcards(
if (shell_style != STYLE_BT)
for (i = 0; i < num_pat; ++i)
{
- /* When using system() always add extra quotes, because the shell
- * is started twice. Otherwise put a backslash before special
- * characters, except inside ``. */
+ // When using system() always add extra quotes, because the shell
+ // is started twice. Otherwise put a backslash before special
+ // characters, except inside ``.
#ifdef USE_SYSTEM
STRCAT(command, " \"");
STRCAT(command, pat[i]);
@@ -6631,9 +6631,9 @@ mch_expand_wildcards(
intick = !intick;
else if (pat[i][j] == '\\' && pat[i][j + 1] != NUL)
{
- /* Remove a backslash, take char literally. But keep
- * backslash inside backticks, before a special character
- * and before a backtick. */
+ // Remove a backslash, take char literally. But keep
+ // backslash inside backticks, before a special character
+ // and before a backtick.
if (intick
|| vim_strchr(SHELL_SPECIAL, pat[i][j + 1]) != NULL
|| pat[i][j + 1] == '`')
@@ -6643,12 +6643,12 @@ mch_expand_wildcards(
else if (!intick
&& ((flags & EW_KEEPDOLLAR) == 0 || pat[i][j] != '$')
&& vim_strchr(SHELL_SPECIAL, pat[i][j]) != NULL)
- /* Put a backslash before a special character, but not
- * when inside ``. And not for $var when EW_KEEPDOLLAR is
- * set. */
+ // Put a backslash before a special character, but not
+ // when inside ``. And not for $var when EW_KEEPDOLLAR is
+ // set.
*p++ = '\\';
- /* Copy one character. */
+ // Copy one character.
*p++ = pat[i][j];
}
*p = NUL;
@@ -6657,7 +6657,7 @@ mch_expand_wildcards(
if (flags & EW_SILENT)
show_shell_mess = FALSE;
if (ampersand)
- STRCAT(command, "&"); /* put the '&' after the redirection */
+ STRCAT(command, "&"); // put the '&' after the redirection
/*
* Using zsh -G: If a pattern has no matches, it is just deleted from
@@ -6665,7 +6665,7 @@ mch_expand_wildcards(
* expand any other pattern.
*/
if (shell_style == STYLE_PRINT)
- extra_shell_arg = (char_u *)"-G"; /* Use zsh NULL_GLOB option */
+ extra_shell_arg = (char_u *)"-G"; // Use zsh NULL_GLOB option
/*
* If we use -f then shell variables set in .cshrc won't get expanded.
@@ -6673,23 +6673,23 @@ mch_expand_wildcards(
* in one of the patterns, otherwise we can still use the fast option.
*/
else if (shell_style == STYLE_GLOB && !have_dollars(num_pat, pat))
- extra_shell_arg = (char_u *)"-f"; /* Use csh fast option */
+ extra_shell_arg = (char_u *)"-f"; // Use csh fast option
/*
* execute the shell command
*/
i = call_shell(command, SHELL_EXPAND | SHELL_SILENT);
- /* When running in the background, give it some time to create the temp
- * file, but don't wait for it to finish. */
+ // When running in the background, give it some time to create the temp
+ // file, but don't wait for it to finish.
if (ampersand)
mch_delay(10L, TRUE);
- extra_shell_arg = NULL; /* cleanup */
+ extra_shell_arg = NULL; // cleanup
show_shell_mess = TRUE;
vim_free(command);
- if (i != 0) /* mch_call_shell() failed */
+ if (i != 0) // mch_call_shell() failed
{
mch_remove(tempname);
vim_free(tempname);
@@ -6702,19 +6702,19 @@ mch_expand_wildcards(
if (!(flags & EW_SILENT))
#endif
{
- redraw_later_clear(); /* probably messed up screen */
- msg_putchar('\n'); /* clear bottom line quickly */
- cmdline_row = Rows - 1; /* continue on last line */
+ redraw_later_clear(); // probably messed up screen
+ msg_putchar('\n'); // clear bottom line quickly
+ cmdline_row = Rows - 1; // continue on last line
#ifdef USE_SYSTEM
if (!(flags & EW_SILENT))
#endif
{
msg(_(e_wildexpand));
- msg_start(); /* don't overwrite this message */
+ msg_start(); // don't overwrite this message
}
}
- /* If a `cmd` expansion failed, don't list `cmd` as a match, even when
- * EW_NOTFOUND is given */
+ // If a `cmd` expansion failed, don't list `cmd` as a match, even when
+ // EW_NOTFOUND is given
if (shell_style == STYLE_BT)
return FAIL;
goto notfound;
@@ -6726,26 +6726,26 @@ mch_expand_wildcards(
fd = fopen((char *)tempname, READBIN);
if (fd == NULL)
{
- /* Something went wrong, perhaps a file name with a special char. */
+ // Something went wrong, perhaps a file name with a special char.
if (!(flags & EW_SILENT))
{
msg(_(e_wildexpand));
- msg_start(); /* don't overwrite this message */
+ msg_start(); // don't overwrite this message
}
vim_free(tempname);
goto notfound;
}
fseek(fd, 0L, SEEK_END);
- llen = ftell(fd); /* get size of temp file */
+ llen = ftell(fd); // get size of temp file
fseek(fd, 0L, SEEK_SET);
if (llen < 0)
- /* just in case ftell() would fail */
+ // just in case ftell() would fail
buffer = NULL;
else
buffer = alloc(llen + 1);
if (buffer == NULL)
{
- /* out of memory */
+ // out of memory
mch_remove(tempname);
vim_free(tempname);
fclose(fd);
@@ -6757,7 +6757,7 @@ mch_expand_wildcards(
mch_remove(tempname);
if (i != (int)len)
{
- /* unexpected read error */
+ // unexpected read error
semsg(_(e_notread), tempname);
vim_free(tempname);
vim_free(buffer);
@@ -6766,7 +6766,7 @@ mch_expand_wildcards(
vim_free(tempname);
# ifdef __CYGWIN__
- /* Translate <CR><NL> into <NL>. Caution, buffer may contain NUL. */
+ // Translate <CR><NL> into <NL>. Caution, buffer may contain NUL.
p = buffer;
for (i = 0; i < (int)len; ++i)
if (!(buffer[i] == CAR && buffer[i + 1] == NL))
@@ -6775,33 +6775,33 @@ mch_expand_wildcards(
# endif
- /* file names are separated with Space */
+ // file names are separated with Space
if (shell_style == STYLE_ECHO)
{
- buffer[len] = '\n'; /* make sure the buffer ends in NL */
+ buffer[len] = '\n'; // make sure the buffer ends in NL
p = buffer;
- for (i = 0; *p != '\n'; ++i) /* count number of entries */
+ for (i = 0; *p != '\n'; ++i) // count number of entries
{
while (*p != ' ' && *p != '\n')
++p;
- p = skipwhite(p); /* skip to next entry */
+ p = skipwhite(p); // skip to next entry
}
}
- /* file names are separated with NL */
+ // file names are separated with NL
else if (shell_style == STYLE_BT || shell_style == STYLE_VIMGLOB)
{
- buffer[len] = NUL; /* make sure the buffer ends in NUL */
+ buffer[len] = NUL; // make sure the buffer ends in NUL
p = buffer;
- for (i = 0; *p != NUL; ++i) /* count number of entries */
+ for (i = 0; *p != NUL; ++i) // count number of entries
{
while (*p != '\n' && *p != NUL)
++p;
if (*p != NUL)
++p;
- p = skipwhite(p); /* skip leading white space */
+ p = skipwhite(p); // skip leading white space
}
}
- /* file names are separated with NUL */
+ // file names are separated with NUL
else
{
/*
@@ -6815,7 +6815,7 @@ mch_expand_wildcards(
check_spaces = FALSE;
if (shell_style == STYLE_PRINT && !did_find_nul)
{
- /* If there is a NUL, set did_find_nul, else set check_spaces */
+ // If there is a NUL, set did_find_nul, else set check_spaces
buffer[len] = NUL;
if (len && (int)STRLEN(buffer) < (int)len)
did_find_nul = TRUE;
@@ -6833,13 +6833,13 @@ mch_expand_wildcards(
buffer[len] = NUL;
i = 0;
for (p = buffer; p < buffer + len; ++p)
- if (*p == NUL || (*p == ' ' && check_spaces)) /* count entry */
+ if (*p == NUL || (*p == ' ' && check_spaces)) // count entry
{
++i;
*p = NUL;
}
if (len)
- ++i; /* count last entry */
+ ++i; // count last entry
}
if (i == 0)
{
@@ -6855,7 +6855,7 @@ mch_expand_wildcards(
*file = ALLOC_MULT(char_u *, i);
if (*file == NULL)
{
- /* out of memory */
+ // out of memory
vim_free(buffer);
return FAIL;
}
@@ -6867,26 +6867,26 @@ mch_expand_wildcards(
for (i = 0; i < *num_file; ++i)
{
(*file)[i] = p;
- /* Space or NL separates */
+ // Space or NL separates
if (shell_style == STYLE_ECHO || shell_style == STYLE_BT
|| shell_style == STYLE_VIMGLOB)
{
while (!(shell_style == STYLE_ECHO && *p == ' ')
&& *p != '\n' && *p != NUL)
++p;
- if (p == buffer + len) /* last entry */
+ if (p == buffer + len) // last entry
*p = NUL;
else
{
*p++ = NUL;
- p = skipwhite(p); /* skip to next entry */
+ p = skipwhite(p); // skip to next entry
}
}
- else /* NUL separates */
+ else // NUL separates
{
- while (*p && p < buffer + len) /* skip entry */
+ while (*p && p < buffer + len) // skip entry
++p;
- ++p; /* skip NUL */
+ ++p; // skip NUL
}
}
@@ -6895,16 +6895,16 @@ mch_expand_wildcards(
*/
for (j = 0, i = 0; i < *num_file; ++i)
{
- /* Require the files to exist. Helps when using /bin/sh */
+ // Require the files to exist. Helps when using /bin/sh
if (!(flags & EW_NOTFOUND) && mch_getperm((*file)[i]) < 0)
continue;
- /* check if this entry should be included */
+ // check if this entry should be included
dir = (mch_isdir((*file)[i]));
if ((dir && !(flags & EW_DIR)) || (!dir && !(flags & EW_FILE)))
continue;
- /* Skip files that are not executable if we check for that. */
+ // Skip files that are not executable if we check for that.
if (!dir && (flags & EW_EXEC)
&& !mch_can_exe((*file)[i], NULL, !(flags & EW_SHELLCMD)))
continue;
@@ -6914,14 +6914,14 @@ mch_expand_wildcards(
{
STRCPY(p, (*file)[i]);
if (dir)
- add_pathsep(p); /* add '/' to a directory name */
+ add_pathsep(p); // add '/' to a directory name
(*file)[j++] = p;
}
}
vim_free(buffer);
*num_file = j;
- if (*num_file == 0) /* rejected all entries */
+ if (*num_file == 0) // rejected all entries
{
VIM_CLEAR(*file);
goto notfound;
@@ -6935,7 +6935,7 @@ notfound:
return FAIL;
}
-#endif /* VMS */
+#endif // VMS
static int
save_patterns(
@@ -6954,8 +6954,8 @@ save_patterns(
{
s = vim_strsave(pat[i]);
if (s != NULL)
- /* Be compatible with expand_filename(): halve the number of
- * backslashes. */
+ // Be compatible with expand_filename(): halve the number of
+ // backslashes.
backslash_halve(s);
(*file)[i] = s;
}
@@ -7045,15 +7045,15 @@ mch_rename(const char *src, const char *dest)
{
struct stat st;
- if (stat(dest, &st) >= 0) /* fail if destination exists */
+ if (stat(dest, &st) >= 0) // fail if destination exists
return -1;
- if (link(src, dest) != 0) /* link file to new name */
+ if (link(src, dest) != 0) // link file to new name
return -1;
- if (mch_remove(src) == 0) /* delete link to old name */
+ if (mch_remove(src) == 0) // delete link to old name
return 0;
return -1;
}
-#endif /* !HAVE_RENAME */
+#endif // !HAVE_RENAME
#if defined(FEAT_MOUSE_GPM) || defined(PROTO)
/*
@@ -7063,32 +7063,31 @@ mch_rename(const char *src, const char *dest)
static int
gpm_open(void)
{
- static Gpm_Connect gpm_connect; /* Must it be kept till closing ? */
+ static Gpm_Connect gpm_connect; // Must it be kept till closing ?
if (!gpm_flag)
{
gpm_connect.eventMask = (GPM_UP | GPM_DRAG | GPM_DOWN);
gpm_connect.defaultMask = ~GPM_HARD;
- /* Default handling for mouse move*/
- gpm_connect.minMod = 0; /* Handle any modifier keys */
+ // Default handling for mouse move
+ gpm_connect.minMod = 0; // Handle any modifier keys
gpm_connect.maxMod = 0xffff;
if (Gpm_Open(&gpm_connect, 0) > 0)
{
- /* gpm library tries to handling TSTP causes
- * problems. Anyways, we close connection to Gpm whenever
- * we are going to suspend or starting an external process
- * so we shouldn't have problem with this
- */
+ // gpm library tries to handling TSTP causes
+ // problems. Anyways, we close connection to Gpm whenever
+ // we are going to suspend or starting an external process
+ // so we shouldn't have problem with this
# ifdef SIGTSTP
signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
# endif
- return 1; /* succeed */
+ return 1; // succeed
}
if (gpm_fd == -2)
- Gpm_Close(); /* We don't want to talk to xterm via gpm */
+ Gpm_Close(); // We don't want to talk to xterm via gpm
return 0;
}
- return 1; /* already open */
+ return 1; // already open
}
/*
@@ -7130,7 +7129,7 @@ mch_gpm_process(void)
Gpm_GetEvent(&gpm_event);
#ifdef FEAT_GUI
- /* Don't put events in the input queue now. */
+ // Don't put events in the input queue now.
if (hold_gui_events)
return 0;
#endif
@@ -7138,7 +7137,7 @@ mch_gpm_process(void)
row = gpm_event.y - 1;
col = gpm_event.x - 1;
- string[0] = ESC; /* Our termcode */
+ string[0] = ESC; // Our termcode
string[1] = 'M';
string[2] = 'G';
switch (GPM_BARE_EVENTS(gpm_event.type))
@@ -7162,8 +7161,8 @@ mch_gpm_process(void)
break;
default:
return 0;
- /*Don't know what to do. Can more than one button be
- * reported in one event? */
+ // Don't know what to do. Can more than one button be
+ // reported in one event?
}
string[3] = (char_u)(button | 0x20);
SET_NUM_MOUSE_CLICKS(string[3], gpm_event.clicks + 1);
@@ -7175,13 +7174,12 @@ mch_gpm_process(void)
default:
return 0;
}
- /*This code is based on gui_x11_mouse_cb in gui_x11.c */
+ // This code is based on gui_x11_mouse_cb in gui_x11.c
gpm_modifiers = gpm_event.modifiers;
vim_modifiers = 0x0;
- /* I ignore capslock stats. Aren't we all just hate capslock mixing with
- * Vim commands ? Besides, gpm_event.modifiers is unsigned char, and
- * K_CAPSSHIFT is defined 8, so it probably isn't even reported
- */
+ // I ignore capslock stats. Aren't we all just hate capslock mixing with
+ // Vim commands ? Besides, gpm_event.modifiers is unsigned char, and
+ // K_CAPSSHIFT is defined 8, so it probably isn't even reported
if (gpm_modifiers & ((1 << KG_SHIFT) | (1 << KG_SHIFTR) | (1 << KG_SHIFTL)))
vim_modifiers |= MOUSE_SHIFT;
@@ -7195,7 +7193,7 @@ mch_gpm_process(void)
add_to_input_buf(string, 6);
return 6;
}
-#endif /* FEAT_MOUSE_GPM */
+#endif // FEAT_MOUSE_GPM
#ifdef FEAT_SYSMOUSE
/*
@@ -7253,7 +7251,7 @@ sig_sysmouse SIGDEFARG(sigarg)
static int oldbuttons = 0;
#ifdef FEAT_GUI
- /* Don't put events in the input queue now. */
+ // Don't put events in the input queue now.
if (hold_gui_events)
return;
#endif
@@ -7267,7 +7265,7 @@ sig_sysmouse SIGDEFARG(sigarg)
row = mouse.u.data.y / video.vi_cheight;
col = mouse.u.data.x / video.vi_cwidth;
buttons = mouse.u.data.buttons;
- string[0] = ESC; /* Our termcode */
+ string[0] = ESC; // Our termcode
string[1] = 'M';
string[2] = 'S';
if (oldbuttons == buttons && buttons != 0)
@@ -7302,7 +7300,7 @@ sig_sysmouse SIGDEFARG(sigarg)
}
return;
}
-#endif /* FEAT_SYSMOUSE */
+#endif // FEAT_SYSMOUSE
#if defined(FEAT_LIBCALL) || defined(PROTO)
typedef char_u * (*STRPROCSTR)(char_u *);
@@ -7318,9 +7316,9 @@ typedef int (*INTPROCINT)(int);
mch_libcall(
char_u *libname,
char_u *funcname,
- char_u *argstring, /* NULL when using a argint */
+ char_u *argstring, // NULL when using a argint
int argint,
- char_u **string_result,/* NULL when using number_result */
+ char_u **string_result, // NULL when using number_result
int *number_result)
{
# if defined(USE_DLOPEN)
@@ -7339,7 +7337,7 @@ mch_libcall(
* Get a handle to the DLL module.
*/
# if defined(USE_DLOPEN)
- /* First clear any error, it's not cleared by the dlopen() call. */
+ // First clear any error, it's not cleared by the dlopen() call.
(void)dlerror();
hinstLib = dlopen((char *)libname, RTLD_LAZY
@@ -7349,7 +7347,7 @@ mch_libcall(
);
if (hinstLib == NULL)
{
- /* "dlerr" must be used before dlclose() */
+ // "dlerr" must be used before dlclose()
dlerr = (char *)dlerror();
if (dlerr != NULL)
semsg(_("dlerror = \"%s\""), dlerr);
@@ -7358,7 +7356,7 @@ mch_libcall(
hinstLib = shl_load((const char*)libname, BIND_IMMEDIATE|BIND_VERBOSE, 0L);
# endif
- /* If the handle is valid, try to get the function address. */
+ // If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
# ifdef USING_SETJMP
@@ -7426,8 +7424,8 @@ mch_libcall(
}
}
- /* Save the string before we free the library. */
- /* Assume that a "1" or "-1" result is an illegal pointer. */
+ // Save the string before we free the library.
+ // Assume that a "1" or "-1" result is an illegal pointer.
if (string_result == NULL)
*number_result = retval_int;
else if (retval_str != NULL
@@ -7443,7 +7441,7 @@ mch_libcall(
{
int i;
- /* try to find the name of this signal */
+ // try to find the name of this signal
for (i = 0; signal_info[i].sig != -1; i++)
if (lc_signal == signal_info[i].sig)
break;
@@ -7453,11 +7451,11 @@ mch_libcall(
# endif
# if defined(USE_DLOPEN)
- /* "dlerr" must be used before dlclose() */
+ // "dlerr" must be used before dlclose()
if (dlerr != NULL)
semsg(_("dlerror = \"%s\""), dlerr);
- /* Free the DLL module. */
+ // Free the DLL module.
(void)dlclose(hinstLib);
# else
(void)shl_unload(hinstLib);
@@ -7475,7 +7473,7 @@ mch_libcall(
#endif
#if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)) || defined(PROTO)
-static int xterm_trace = -1; /* default: disabled */
+static int xterm_trace = -1; // default: disabled
static int xterm_button;
/*
@@ -7505,11 +7503,11 @@ setup_term_clip(void)
ELAPSED_INIT(start_tv);
# endif
- /* Ignore X errors while opening the display */
+ // Ignore X errors while opening the display
oldhandler = XSetErrorHandler(x_error_check);
# if defined(USING_SETJMP)
- /* Ignore X IO errors while opening the display */
+ // Ignore X IO errors while opening the display
oldIOhandler = XSetIOErrorHandler(x_IOerror_check);
mch_startjmp();
if (SETJMP(lc_jump_env) != 0)
@@ -7530,10 +7528,10 @@ setup_term_clip(void)
}
# if defined(USING_SETJMP)
- /* Now handle X IO errors normally. */
+ // Now handle X IO errors normally.
(void)XSetIOErrorHandler(oldIOhandler);
# endif
- /* Now handle X errors normally. */
+ // Now handle X errors normally.
(void)XSetErrorHandler(oldhandler);
if (xterm_dpy == NULL)
@@ -7543,7 +7541,7 @@ setup_term_clip(void)
return;
}
- /* Catch terminating error of the X server connection. */
+ // Catch terminating error of the X server connection.
(void)XSetIOErrorHandler(x_IOerror_handler);
# ifdef ELAPSED_FUNC
@@ -7555,7 +7553,7 @@ setup_term_clip(void)
}
# endif
- /* Create a Shell to make converters work. */
+ // Create a Shell to make converters work.
AppShell = XtVaAppCreateShell("vim_xterm", "Vim_xterm",
applicationShellWidgetClass, xterm_dpy,
NULL);
@@ -7584,7 +7582,7 @@ setup_term_clip(void)
clip_init(TRUE);
if (x11_window == 0 && (strp = getenv("WINDOWID")) != NULL)
x11_window = (Window)atol(strp);
- /* Check if $WINDOWID is valid. */
+ // Check if $WINDOWID is valid.
if (test_x11_window(xterm_dpy) == FAIL)
x11_window = 0;
if (x11_window != 0)
@@ -7636,25 +7634,25 @@ do_xterm_trace(void)
if (xterm_trace == 1)
{
- /* Get the hints just before tracking starts. The font size might
- * have changed recently. */
+ // Get the hints just before tracking starts. The font size might
+ // have changed recently.
if (!XGetWMNormalHints(xterm_dpy, x11_window, &xterm_hints, &got_hints)
|| !(got_hints & PResizeInc)
|| xterm_hints.width_inc <= 1
|| xterm_hints.height_inc <= 1)
{
- xterm_trace = -1; /* Not enough data -- disable tracing */
+ xterm_trace = -1; // Not enough data -- disable tracing
return FALSE;
}
- /* Rely on the same mouse code for the duration of this */
+ // Rely on the same mouse code for the duration of this
mouse_code = find_termcode(mouse_name);
prev_row = mouse_row;
prev_col = mouse_col;
xterm_trace = 2;
- /* Find the offset of the chars, there might be a scrollbar on the
- * left of the window and/or a menu on the top (eterm etc.) */
+ // Find the offset of the chars, there might be a scrollbar on the
+ // left of the window and/or a menu on the top (eterm etc.)
XQueryPointer(xterm_dpy, x11_window, &root, &child, &root_x, &root_y,
&win_x, &win_y, &mask_return);
xterm_hints.y = win_y - (xterm_hints.height_inc * mouse_row)
@@ -7709,7 +7707,7 @@ clear_xterm_clip(void)
if (xterm_dpy != NULL)
{
# if 0
- /* Lesstif and Solaris crash here, lose some memory */
+ // Lesstif and Solaris crash here, lose some memory
XtCloseDisplay(xterm_dpy);
# endif
if (x11_display == xterm_dpy)
@@ -7719,7 +7717,7 @@ clear_xterm_clip(void)
# if 0
if (app_context != (XtAppContext)NULL)
{
- /* Lesstif and Solaris crash here, lose some memory */
+ // Lesstif and Solaris crash here, lose some memory
XtDestroyApplicationContext(app_context);
app_context = (XtAppContext)NULL;
}
@@ -7762,7 +7760,7 @@ xterm_update(void)
if (mask & XtIMXEvent)
{
- /* There is an event to process. */
+ // There is an event to process.
XtAppNextEvent(app_context, &event);
#ifdef FEAT_CLIENTSERVER
{
@@ -7777,7 +7775,7 @@ xterm_update(void)
}
else
{
- /* There is something else than an event to process. */
+ // There is something else than an event to process.
XtAppProcessEvent(app_context, mask);
}
}
@@ -7832,20 +7830,19 @@ xsmp_handle_interaction(SmcConn smc_conn, SmPointer client_data UNUSED)
save_cmdmod = cmdmod;
cmdmod.confirm = TRUE;
if (check_changed_any(FALSE, FALSE))
- /* Mustn't logout */
+ // Mustn't logout
cancel_shutdown = True;
cmdmod = save_cmdmod;
- setcursor(); /* position cursor */
+ setcursor(); // position cursor
out_flush();
- /* Done interaction */
+ // Done interaction
SmcInteractDone(smc_conn, cancel_shutdown);
- /* Finish off
- * Only end save-yourself here if we're not cancelling shutdown;
- * we'll get a cancelled callback later in which we'll end it.
- * Hopefully get around glitchy SMs (like GNOME-1)
- */
+ // Finish off
+ // Only end save-yourself here if we're not cancelling shutdown;
+ // we'll get a cancelled callback later in which we'll end it.
+ // Hopefully get around glitchy SMs (like GNOME-1)
if (!cancel_shutdown)
{
xsmp.save_yourself = False;
@@ -7866,29 +7863,29 @@ xsmp_handle_save_yourself(
int interact_style UNUSED,
Bool fast UNUSED)
{
- /* Handle already being in saveyourself */
+ // Handle already being in saveyourself
if (xsmp.save_yourself)
SmcSaveYourselfDone(smc_conn, True);
xsmp.save_yourself = True;
xsmp.shutdown = shutdown;
- /* First up, preserve all files */
+ // First up, preserve all files
out_flush();
- ml_sync_all(FALSE, FALSE); /* preserve all swap files */
+ ml_sync_all(FALSE, FALSE); // preserve all swap files
if (p_verbose > 0)
verb_msg(_("XSMP handling save-yourself request"));
# if defined(FEAT_GUI) && defined(USE_XSMP_INTERACT)
- /* Now see if we can ask about unsaved files */
+ // Now see if we can ask about unsaved files
if (shutdown && !fast && gui.in_use)
- /* Need to interact with user, but need SM's permission */
+ // Need to interact with user, but need SM's permission
SmcInteractRequest(smc_conn, SmDialogError,
xsmp_handle_interaction, client_data);
else
# endif
{
- /* Can stop the cycle here */
+ // Can stop the cycle here
SmcSaveYourselfDone(smc_conn, True);
xsmp.save_yourself = False;
}
@@ -7903,7 +7900,7 @@ xsmp_die(SmcConn smc_conn UNUSED, SmPointer client_data UNUSED)
{
xsmp_close();
- /* quit quickly leaving swapfiles for modified buffers behind */
+ // quit quickly leaving swapfiles for modified buffers behind
getout_preserve_modified(0);
}
@@ -7946,7 +7943,7 @@ xsmp_ice_connection(
Bool opening,
IcePointer *watchData UNUSED)
{
- /* Intercept creation of ICE connection fd */
+ // Intercept creation of ICE connection fd
if (opening)
{
xsmp_icefd = IceConnectionNumber(iceConn);
@@ -7955,7 +7952,7 @@ xsmp_ice_connection(
}
-/* Handle any ICE processing that's required; return FAIL if SM lost */
+// Handle any ICE processing that's required; return FAIL if SM lost
int
xsmp_handle_requests(void)
{
@@ -7964,7 +7961,7 @@ xsmp_handle_requests(void)
if (IceProcessMessages(xsmp.iceconn, NULL, &rep)
== IceProcessMessagesIOError)
{
- /* Lost ICE */
+ // Lost ICE
if (p_verbose > 0)
verb_msg(_("XSMP lost ICE connection"));
xsmp_close();
@@ -7976,7 +7973,7 @@ xsmp_handle_requests(void)
static int dummy;
-/* Set up X Session Management Protocol */
+// Set up X Session Management Protocol
void
xsmp_init(void)
{
@@ -7993,7 +7990,7 @@ xsmp_init(void)
xsmp.save_yourself = xsmp.shutdown = False;
- /* Set up SM callbacks - must have all, even if they're not used */
+ // Set up SM callbacks - must have all, even if they're not used
smcallbacks.save_yourself.callback = xsmp_handle_save_yourself;
smcallbacks.save_yourself.client_data = NULL;
smcallbacks.die.callback = xsmp_die;
@@ -8003,8 +8000,8 @@ xsmp_init(void)
smcallbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled;
smcallbacks.shutdown_cancelled.client_data = NULL;
- /* Set up a watch on ICE connection creations. The "dummy" argument is
- * apparently required for FreeBSD (we get a BUS error when using NULL). */
+ // Set up a watch on ICE connection creations. The "dummy" argument is
+ // apparently required for FreeBSD (we get a BUS error when using NULL).
if (IceAddConnectionWatch(xsmp_ice_connection, &dummy) == 0)
{
if (p_verbose > 0)
@@ -8012,7 +8009,7 @@ xsmp_init(void)
return;
}
- /* Create an SM connection */
+ // Create an SM connection
xsmp.smcconn = SmcOpenConnection(
NULL,
NULL,
@@ -8040,7 +8037,7 @@ xsmp_init(void)
xsmp.iceconn = SmcGetIceConnection(xsmp.smcconn);
#if 0
- /* ID ourselves */
+ // ID ourselves
smname.value = "vim";
smname.length = 3;
smnameprop.name = "SmProgram";
@@ -8054,7 +8051,7 @@ xsmp_init(void)
}
-/* Shut down XSMP comms. */
+// Shut down XSMP comms.
void
xsmp_close(void)
{
@@ -8067,11 +8064,11 @@ xsmp_close(void)
xsmp_icefd = -1;
}
}
-#endif /* USE_XSMP */
+#endif // USE_XSMP
#ifdef EBCDIC
-/* Translate character to its CTRL- value */
+// Translate character to its CTRL- value
char CtrlTable[] =
{
/* 00 - 5E */
@@ -8160,7 +8157,7 @@ char CtrlTable[] =
};
char MetaCharTable[]=
-{/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
+{// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0, 0, 0, 0,'\\', 0,'F', 0,'W','M','N', 0, 0, 0, 0, 0,
0, 0, 0, 0,']', 0, 0,'G', 0, 0,'R','O', 0, 0, 0, 0,
'@','A','B','C','D','E', 0, 0,'H','I','J','K','L', 0, 0, 0,
@@ -8168,9 +8165,9 @@ char MetaCharTable[]=
};
-/* TODO: Use characters NOT numbers!!! */
+// TODO: Use characters NOT numbers!!!
char CtrlCharTable[]=
-{/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
+{// 0 1 2 3 4 5 6 7 8 9 A B C D E F
124,193,194,195, 0,201, 0, 0, 0, 0, 0,210,211,212,213,214,
215,216,217,226, 0,209,200, 0,231,232, 0, 0,224,189, 95,109,
0, 0, 0, 0, 0, 0,230,173, 0, 0, 0, 0, 0,197,198,199,