# HG changeset patch # User Bram Moolenaar # Date 1575574204 -3600 # Node ID 44b855153d8e5a2f1ed8d970e3cf07747260b8e9 # Parent 8c6177fec9cbe45f04d64696c427b20630be7bb9 patch 8.1.2393: using old C style comments Commit: https://github.com/vim/vim/commit/0f8737355d291679659579a48db1861b88970293 Author: Bram Moolenaar Date: Thu Dec 5 20:28:46 2019 +0100 patch 8.1.2393: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate. diff --git a/src/os_amiga.c b/src/os_amiga.c --- a/src/os_amiga.c +++ b/src/os_amiga.c @@ -17,13 +17,13 @@ #include "version.h" #ifdef Window -# undef Window /* Amiga has its own Window definition */ +# undef Window // Amiga has its own Window definition #endif -#undef TRUE /* will be redefined by exec/types.h */ +#undef TRUE // will be redefined by exec/types.h #undef FALSE -/* cproto fails on missing include files, skip them */ +// cproto fails on missing include files, skip them #ifndef PROTO #ifndef LATTICE @@ -33,21 +33,19 @@ # include #endif -/* XXX These are included from os_amiga.h -#include -#include -#include -*/ +// XXX These are included from os_amiga.h +// #include +// #include +// #include #include #include -#include /* for 2.0 functions */ +#include // for 2.0 functions #include -/* From version 4 of AmigaOS, several system structures must be allocated - * and freed using system functions. "struct AnchorPath" is one. - */ +// From version 4 of AmigaOS, several system structures must be allocated +// and freed using system functions. "struct AnchorPath" is one. #ifdef __amigaos4__ # include # define free_fib(x) FreeDosObject(DOS_FIB, x) @@ -59,7 +57,7 @@ # include #endif -#endif /* PROTO */ +#endif // PROTO /* * Set stack size to 1 MiB on NG systems. This should be enough even for @@ -92,9 +90,9 @@ static int sortcmp(const void *a, const static BPTR raw_in = (BPTR)NULL; static BPTR raw_out = (BPTR)NULL; -static int close_win = FALSE; /* set if Vim opened the window */ +static int close_win = FALSE; // set if Vim opened the window -#ifndef __amigaos4__ /* Use autoopen for AmigaOS4 */ +#ifndef __amigaos4__ // Use autoopen for AmigaOS4 struct IntuitionBase *IntuitionBase = NULL; #endif #ifdef FEAT_ARP @@ -105,9 +103,9 @@ static struct Window *wb_window; static char_u *oldwindowtitle = NULL; #ifdef FEAT_ARP -int dos2 = FALSE; /* Amiga DOS 2.0x or higher */ +int dos2 = FALSE; // Amiga DOS 2.0x or higher #endif -int size_set = FALSE; /* set to TRUE if window size was set */ +int size_set = FALSE; // set to TRUE if window size was set #ifdef __GNUC__ static char version[] __attribute__((used)) = @@ -151,7 +149,7 @@ mch_write(char_u *p, int len) mch_inchar( char_u *buf, int maxlen, - long time, /* milli seconds */ + long time, // milli seconds int tb_change_cnt) { int len; @@ -160,13 +158,13 @@ mch_inchar( if (time >= 0) { if (time == 0) - utime = 100L; /* time = 0 causes problems in DOS 1.2 */ + utime = 100L; // time = 0 causes problems in DOS 1.2 else - utime = time * 1000L; /* convert from milli to micro secs */ - if (WaitForChar(raw_in, utime) == 0) /* no character available */ + utime = time * 1000L; // convert from milli to micro secs + if (WaitForChar(raw_in, utime) == 0) // no character available return 0; } - else /* time == -1 */ + else // time == -1 { /* * If there is no character available within 2 seconds (default) @@ -186,12 +184,12 @@ mch_inchar( } } - for (;;) /* repeat until we got a character */ + for (;;) // repeat until we got a character { len = Read(raw_in, (char *)buf, (long)maxlen / input_conv.vc_factor); if (len > 0) { - /* Convert from 'termencoding' to 'encoding'. */ + // Convert from 'termencoding' to 'encoding'. if (input_conv.vc_type != CONV_NONE) len = convert_input(buf, len, maxlen); return len; @@ -228,14 +226,14 @@ mch_avail_mem(int special) void mch_delay(long msec, int ignoreinput) { -#ifndef LATTICE /* SAS declares void Delay(ULONG) */ +#ifndef LATTICE // SAS declares void Delay(ULONG) void Delay(long); #endif if (msec > 0) { if (ignoreinput) - Delay(msec / 20L); /* Delay works with 20 msec intervals */ + Delay(msec / 20L); // Delay works with 20 msec intervals else WaitForChar(raw_in, msec * 1000L); } @@ -260,7 +258,7 @@ mch_init(void) static char intlibname[] = "intuition.library"; #ifdef AZTEC_C - Enable_Abort = 0; /* disallow vim to be aborted */ + Enable_Abort = 0; // disallow vim to be aborted #endif Columns = 80; Rows = 24; @@ -313,7 +311,7 @@ mch_init(void) * For the -f option (foreground mode) we open our own window and disable :sh. * Otherwise the calling program would never know when editing is finished. */ -#define BUF2SIZE 320 /* length of buffer for argument with complete path */ +#define BUF2SIZE 320 // length of buffer for argument with complete path int mch_check_win(int argc, char **argv) @@ -342,20 +340,20 @@ mch_check_win(int argc, char **argv) #ifndef __amigaos4__ DosBase = OpenLibrary(DOS_LIBRARY, 37L); if (DosBase != NULL) - /* if (((struct Library *)DOSBase)->lib_Version >= 37) */ + // if (((struct Library *)DOSBase)->lib_Version >= 37) { CloseLibrary(DosBase); # ifdef FEAT_ARP dos2 = TRUE; # endif } - else /* without arp functions we NEED 2.0 */ + else // without arp functions we NEED 2.0 { # ifndef FEAT_ARP mch_errmsg(_("Need Amigados version 2.04 or later\n")); exit(3); # else - /* need arp functions for dos 1.x */ + // need arp functions for dos 1.x if (!(ArpBase = (struct ArpBase *) OpenLibrary((UBYTE *)ArpName, ArpVersion))) { fprintf(stderr, _("Need %s version %ld\n"), ArpName, ArpVersion); @@ -363,7 +361,7 @@ mch_check_win(int argc, char **argv) } # endif } -#endif /* __amigaos4__ */ +#endif // __amigaos4__ /* * scan argv[] for the "-f" and "-d" arguments @@ -380,7 +378,7 @@ mch_check_win(int argc, char **argv) case 'd': if (i < argc - 1 #ifdef FEAT_DIFF - /* require using "-dev", "-d" means diff mode */ + // require using "-dev", "-d" means diff mode && argv[i][2] == 'e' && argv[i][3] == 'v' #endif ) @@ -419,7 +417,7 @@ mch_check_win(int argc, char **argv) (long)MODE_NEWFILE)) != (BPTR)NULL) break; } - if (raw_in == (BPTR)NULL) /* all three failed */ + if (raw_in == (BPTR)NULL) // all three failed { mch_errmsg(_(winerr)); goto exit; @@ -458,7 +456,7 @@ mch_check_win(int argc, char **argv) * Write the command into the file, put quotes around the arguments that * have a space in them. */ - if (argc == 0) /* run from workbench */ + if (argc == 0) // run from workbench ac = ((struct WBStartup *)argv)->sm_NumArgs; else ac = argc; @@ -471,11 +469,11 @@ mch_check_win(int argc, char **argv) if (argp->wa_Lock) (void)lock2name(argp->wa_Lock, buf2, (long)(BUF2SIZE - 1)); #ifdef FEAT_ARP - if (dos2) /* use 2.0 function */ + if (dos2) // use 2.0 function #endif AddPart((UBYTE *)buf2, (UBYTE *)argp->wa_Name, (long)(BUF2SIZE - 1)); #ifdef FEAT_ARP - else /* use arp function */ + else // use arp function TackOn((char *)buf2, argp->wa_Name); #endif av = (char *)buf2; @@ -483,7 +481,7 @@ mch_check_win(int argc, char **argv) else av = argv[i]; - /* skip '-d' or "-dev" option */ + // skip '-d' or "-dev" option if (av[0] == '-' && av[1] == 'd' #ifdef FEAT_DIFF && av[2] == 'e' && av[3] == 'v' @@ -530,13 +528,13 @@ mch_check_win(int argc, char **argv) } #endif } - if (i == 3) /* all three failed */ + if (i == 3) // all three failed { DeleteFile((UBYTE *)buf1); mch_errmsg(_(winerr)); goto exit; } - exitval = 0; /* The Execute succeeded: exit this program */ + exitval = 0; // The Execute succeeded: exit this program exit: #ifdef FEAT_ARP @@ -544,7 +542,7 @@ exit: CloseLibrary((struct Library *) ArpBase); #endif exit(exitval); - /* NOTREACHED */ + // NOTREACHED return FAIL; } @@ -563,11 +561,11 @@ mch_input_isatty(void) * This will cause the file name to remain exactly the same * if the file system ignores, but preserves case. */ -/*ARGSUSED*/ +//ARGSUSED void fname_case( char_u *name, - int len) /* buffer size, ignored here */ + int len) // buffer size, ignored here { struct FileInfoBlock *fib; size_t flen; @@ -576,12 +574,12 @@ fname_case( if (fib != NULL) { flen = STRLEN(name); - /* TODO: Check if this fix applies to AmigaOS < 4 too.*/ + // TODO: Check if this fix applies to AmigaOS < 4 too. #ifdef __amigaos4__ if (fib->fib_DirEntryType == ST_ROOT) strcat(fib->fib_FileName, ":"); #endif - if (flen == strlen(fib->fib_FileName)) /* safety check */ + if (flen == strlen(fib->fib_FileName)) // safety check mch_memmove(name, fib->fib_FileName, flen); free_fib(fib); } @@ -598,7 +596,7 @@ get_fib(char_u *fname) BPTR flock; struct FileInfoBlock *fib; - if (fname == NULL) /* safety check */ + if (fname == NULL) // safety check return NULL; #ifdef __amigaos4__ fib = AllocDosObject(DOS_FIB,0); @@ -610,7 +608,7 @@ get_fib(char_u *fname) flock = Lock((UBYTE *)fname, (long)ACCESS_READ); if (flock == (BPTR)NULL || !Examine(flock, fib)) { - free_fib(fib); /* in case of an error the memory is freed here */ + free_fib(fib); // in case of an error the memory is freed here fib = NULL; } if (flock) @@ -703,9 +701,8 @@ mch_get_host_name(char_u *s, int len) mch_get_pid(void) { #ifdef __amigaos4__ - /* This is as close to a pid as we can come. We could use CLI numbers also, - * but then we would have two different types of process identifiers. - */ + // This is as close to a pid as we can come. We could use CLI numbers also, + // but then we would have two different types of process identifiers. return((long)FindTask(0)); #else return (long)0; @@ -738,13 +735,13 @@ mch_FullName( int retval = FAIL; int i; - /* Lock the file. If it exists, we can get the exact name. */ + // Lock the file. If it exists, we can get the exact name. if ((l = Lock((UBYTE *)fname, (long)ACCESS_READ)) != (BPTR)0) { retval = lock2name(l, buf, (long)len - 1); UnLock(l); } - else if (force || !mch_isFullName(fname)) /* not a full path yet */ + else if (force || !mch_isFullName(fname)) // not a full path yet { /* * If the file cannot be locked (doesn't exist), try to lock the @@ -757,8 +754,8 @@ mch_FullName( if (retval == OK) { i = STRLEN(buf); - /* Concatenate the fname to the directory. Don't add a slash - * if fname is empty, but do change "" to "/". */ + // Concatenate the fname to the directory. Don't add a slash + // if fname is empty, but do change "" to "/". if (i == 0 || *fname != NUL) { if (i < len - 1 && (i == 0 || buf[i - 1] != ':')) @@ -769,7 +766,7 @@ mch_FullName( } } if (*buf == 0 || *buf == ':') - retval = FAIL; /* something failed; use the file name */ + retval = FAIL; // something failed; use the file name return retval; } @@ -792,11 +789,11 @@ mch_isFullName(char_u *fname) lock2name(BPTR lock, char_u *buf, long len) { #ifdef FEAT_ARP - if (dos2) /* use 2.0 function */ + if (dos2) // use 2.0 function #endif return ((int)NameFromLock(lock, (UBYTE *)buf, len) ? OK : FAIL); #ifdef FEAT_ARP - else /* use arp function */ + else // use arp function return ((int)PathName(lock, (char *)buf, (long)(len/32)) ? OK : FAIL); #endif } @@ -828,7 +825,7 @@ mch_getperm(char_u *name) int mch_setperm(char_u *name, long perm) { - perm &= ~FIBF_ARCHIVE; /* reset archived bit */ + perm &= ~FIBF_ARCHIVE; // reset archived bit return (SetProtection((UBYTE *)name, (long)perm) ? OK : FAIL); } @@ -838,7 +835,7 @@ mch_setperm(char_u *name, long perm) void mch_hide(char_u *name) { - /* can't hide a file */ + // can't hide a file } /* @@ -890,7 +887,7 @@ mch_mkdir(char_u *name) int mch_can_exe(char_u *name, char_u **path, int use_path) { - /* TODO */ + // TODO return -1; } @@ -903,7 +900,7 @@ mch_can_exe(char_u *name, char_u **path, int mch_nodetype(char_u *name) { - /* TODO */ + // TODO return NODE_NORMAL; } @@ -920,7 +917,7 @@ mch_exit(int r) { exiting = TRUE; - if (raw_in) /* put terminal in 'normal' mode */ + if (raw_in) // put terminal in 'normal' mode { settmode(TMODE_COOK); stoptermcap(); @@ -930,18 +927,18 @@ mch_exit(int r) { if (term_console) { - win_resize_off(); /* window resize events de-activated */ + win_resize_off(); // window resize events de-activated if (size_set) - OUT_STR("\233t\233u"); /* reset window size (CSI t CSI u) */ + OUT_STR("\233t\233u"); // reset window size (CSI t CSI u) } out_flush(); } #ifdef FEAT_TITLE - mch_restore_title(SAVE_RESTORE_BOTH); /* restore window title */ + mch_restore_title(SAVE_RESTORE_BOTH); // restore window title #endif - ml_close_all(TRUE); /* remove all memfiles */ + ml_close_all(TRUE); // remove all memfiles #ifdef FEAT_ARP if (ArpBase) @@ -950,7 +947,7 @@ mch_exit(int r) if (close_win) Close(raw_in); if (r) - printf(_("Vim exiting with %d\n"), r); /* somehow this makes :cq work!? */ + printf(_("Vim exiting with %d\n"), r); // somehow this makes :cq work!? exit(r); } @@ -1027,10 +1024,10 @@ mch_get_shellsize(void) #endif struct InfoData *id=0; - if (!term_console) /* not an amiga window */ + if (!term_console) // not an amiga window goto out; - /* insure longword alignment */ + // insure longword alignment #ifdef __amigaos4__ if (!(id = AllocDosObject(DOS_INFODATA, 0))) goto out; @@ -1044,7 +1041,7 @@ mch_get_shellsize(void) * is rarely needed, so we skip it now, unless we changed the size. */ if (size_set) - OUT_STR("\233t\233u"); /* CSI t CSI u */ + OUT_STR("\233t\233u"); // CSI t CSI u out_flush(); #ifdef __AROS__ @@ -1055,8 +1052,8 @@ mch_get_shellsize(void) || (wb_window = (struct Window *)id->id_VolumeNode) == NULL) #endif { - /* it's not an amiga window, maybe aux device */ - /* terminal type should be set */ + // it's not an amiga window, maybe aux device + // terminal type should be set term_console = FALSE; goto out; } @@ -1069,10 +1066,10 @@ mch_get_shellsize(void) } conUnit = (struct ConUnit *) ((struct IOStdReq *) id->id_InUse)->io_Unit; - /* get window size */ + // get window size Rows = conUnit->cu_YMax + 1; Columns = conUnit->cu_XMax + 1; - if (Rows < 0 || Rows > 200) /* cannot be an amiga window */ + if (Rows < 0 || Rows > 200) // cannot be an amiga window { Columns = 80; Rows = 24; @@ -1083,7 +1080,7 @@ mch_get_shellsize(void) return OK; out: #ifdef __amigaos4__ - FreeDosObject(DOS_INFODATA, id); /* Safe to pass NULL */ + FreeDosObject(DOS_INFODATA, id); // Safe to pass NULL #endif return FAIL; @@ -1114,7 +1111,7 @@ mch_set_shellsize(void) void mch_new_shellsize(void) { - /* Nothing to do. */ + // Nothing to do. } /* @@ -1139,8 +1136,8 @@ out_num(long n) */ #ifndef PROTO -/* #include */ -/* #include */ +// #include +// #include # include #endif @@ -1152,9 +1149,9 @@ out_num(long n) static long dos_packet( - struct MsgPort *pid, /* process identifier ... (handlers message port) */ - long action, /* packet type ... (what you want handler to do) */ - long arg) /* single argument */ + struct MsgPort *pid, // process identifier ... (handlers message port) + long action, // packet type ... (what you want handler to do) + long arg) // single argument { # ifdef FEAT_ARP struct MsgPort *replyport; @@ -1163,14 +1160,14 @@ dos_packet( if (dos2) # endif - return DoPkt(pid, action, arg, 0L, 0L, 0L, 0L); /* use 2.0 function */ + return DoPkt(pid, action, arg, 0L, 0L, 0L, 0L); // use 2.0 function # ifdef FEAT_ARP - replyport = (struct MsgPort *) CreatePort(NULL, 0); /* use arp function */ + replyport = (struct MsgPort *) CreatePort(NULL, 0); // use arp function if (!replyport) return (0); - /* Allocate space for a packet, make it public and clear it */ + // Allocate space for a packet, make it public and clear it packet = (struct StandardPacket *) AllocMem((long) sizeof(struct StandardPacket), MEMF_PUBLIC | MEMF_CLEAR); if (!packet) { @@ -1183,7 +1180,7 @@ dos_packet( packet->sp_Pkt.dp_Type = action; packet->sp_Pkt.dp_Arg1 = arg; - PutMsg(pid, (struct Message *)packet); /* send packet */ + PutMsg(pid, (struct Message *)packet); // send packet WaitPort(replyport); GetMsg(replyport); @@ -1196,7 +1193,7 @@ dos_packet( return (res1); # endif } -#endif /* !defined(AZTEC_C) && !defined(__AROS__) */ +#endif // !defined(AZTEC_C) && !defined(__AROS__) /* * Call shell. @@ -1205,7 +1202,7 @@ dos_packet( int mch_call_shell( char_u *cmd, - int options) /* SHELL_*, see vim.h */ + int options) // SHELL_*, see vim.h { BPTR mydir; int x; @@ -1219,20 +1216,20 @@ mch_call_shell( if (close_win) { - /* if Vim opened a window: Executing a shell may cause crashes */ + // if Vim opened a window: Executing a shell may cause crashes emsg(_("E360: Cannot execute shell with -f option")); return -1; } if (term_console) - win_resize_off(); /* window resize events de-activated */ + win_resize_off(); // window resize events de-activated out_flush(); if (options & SHELL_COOKED) - settmode(TMODE_COOK); /* set to normal mode */ - mydir = Lock((UBYTE *)"", (long)ACCESS_READ); /* remember current dir */ + settmode(TMODE_COOK); // set to normal mode + mydir = Lock((UBYTE *)"", (long)ACCESS_READ); // remember current dir -#if !defined(AZTEC_C) /* not tested very much */ +#if !defined(AZTEC_C) // not tested very much if (cmd == NULL) { # ifdef FEAT_ARP @@ -1289,7 +1286,7 @@ mch_call_shell( retval = x; } } -#else /* else part is for AZTEC_C */ +#else // else part is for AZTEC_C if (p_st >= 4 || (p_st >= 2 && !(options & SHELL_FILTER))) use_execute = 1; else @@ -1300,11 +1297,11 @@ mch_call_shell( * separate shell name from argument */ shellcmd = vim_strsave(p_sh); - if (shellcmd == NULL) /* out of memory, use Execute */ + if (shellcmd == NULL) // out of memory, use Execute use_execute = 1; else { - shellarg = skiptowhite(shellcmd); /* find start of arguments */ + shellarg = skiptowhite(shellcmd); // find start of arguments if (*shellarg != NUL) { *shellarg++ = NUL; @@ -1392,17 +1389,17 @@ mch_call_shell( } } vim_free(shellcmd); -#endif /* AZTEC_C */ +#endif // AZTEC_C - if ((mydir = CurrentDir(mydir)) != 0) /* make sure we stay in the same directory */ + if ((mydir = CurrentDir(mydir)) != 0) // make sure we stay in the same directory UnLock(mydir); if (tmode == TMODE_RAW) - settmode(TMODE_RAW); /* set to raw mode */ + settmode(TMODE_RAW); // set to raw mode #ifdef FEAT_TITLE resettitle(); #endif if (term_console) - win_resize_on(); /* window resize events activated */ + win_resize_on(); // window resize events activated return retval; } @@ -1418,9 +1415,9 @@ mch_breakcheck(int force) got_int = TRUE; } -/* this routine causes manx to use this Chk_Abort() rather than its own */ -/* otherwise it resets our ^C when doing any I/O (even when Enable_Abort */ -/* is zero). Since we want to check for our own ^C's */ +// this routine causes manx to use this Chk_Abort() rather than its own +// otherwise it resets our ^C when doing any I/O (even when Enable_Abort +// is zero). Since we want to check for our own ^C's #ifdef _DCC #define Chk_Abort chkabort @@ -1464,7 +1461,7 @@ Chk_Abort(void) mch_expandpath( garray_T *gap, char_u *pat, - int flags) /* EW_* flags */ + int flags) // EW_* flags { struct AnchorPath *Anchor; LONG Result; @@ -1481,7 +1478,7 @@ mch_expandpath( start_len = gap->ga_len; - /* Get our AnchorBase */ + // Get our AnchorBase #ifdef __amigaos4__ Anchor = AllocDosObject(DOS_ANCHORPATH, AnchorTags); #else @@ -1491,11 +1488,11 @@ mch_expandpath( return 0; #ifndef __amigaos4__ - Anchor->ap_Strlen = ANCHOR_BUF_SIZE; /* ap_Length not supported anymore */ + Anchor->ap_Strlen = ANCHOR_BUF_SIZE; // ap_Length not supported anymore # ifdef APF_DODOT - Anchor->ap_Flags = APF_DODOT | APF_DOWILD; /* allow '.' for current dir */ + Anchor->ap_Flags = APF_DODOT | APF_DOWILD; // allow '.' for current dir # else - Anchor->ap_Flags = APF_DoDot | APF_DoWild; /* allow '.' for current dir */ + Anchor->ap_Flags = APF_DoDot | APF_DoWild; // allow '.' for current dir # endif #endif @@ -1503,7 +1500,7 @@ mch_expandpath( if (dos2) { #endif - /* hack to replace '*' by '#?' */ + // hack to replace '*' by '#?' starbuf = alloc(2 * STRLEN(pat) + 1); if (starbuf == NULL) goto Return; @@ -1561,7 +1558,7 @@ mch_expandpath( qsort((void *)(((char_u **)gap->ga_data) + start_len), (size_t)matches, sizeof(char_u *), sortcmp); - /* Free the wildcard stuff */ + // Free the wildcard stuff #ifdef FEAT_ARP if (dos2) #endif @@ -1638,9 +1635,9 @@ mch_has_wildcard(char_u *p) mch_getenv(char_u *var) { int len; - UBYTE *buf; /* buffer to expand in */ - char_u *retval; /* return value */ - static char_u *alloced = NULL; /* allocated memory */ + UBYTE *buf; // buffer to expand in + char_u *retval; // return value + static char_u *alloced = NULL; // allocated memory #ifdef FEAT_ARP if (!dos2) @@ -1665,7 +1662,7 @@ mch_getenv(char_u *var) vim_free(buf); } - /* if $VIM is not defined, use "vim:" instead */ + // if $VIM is not defined, use "vim:" instead if (retval == NULL && STRCMP(var, "VIM") == 0) retval = (char_u *)"vim:"; @@ -1675,7 +1672,7 @@ mch_getenv(char_u *var) /* * Amiga version of setenv() with AmigaDOS 2.0 support. */ -/* ARGSUSED */ +// ARGSUSED int mch_setenv(char *var, char *value, int x) { @@ -1685,6 +1682,6 @@ mch_setenv(char *var, char *value, int x #endif if (SetVar((UBYTE *)var, (UBYTE *)value, (LONG)-1, (ULONG)GVF_LOCAL_ONLY)) - return 0; /* success */ - return -1; /* failure */ + return 0; // success + return -1; // failure } diff --git a/src/os_beos.c b/src/os_beos.c --- a/src/os_beos.c +++ b/src/os_beos.c @@ -21,7 +21,7 @@ #if USE_THREAD_FOR_INPUT_WITH_TIMEOUT -#ifdef PROTO /* making prototypes on Unix */ +#ifdef PROTO // making prototypes on Unix #define sem_id int #define thread_id int #endif @@ -32,7 +32,7 @@ sem_id character_present; sem_id character_wanted; thread_id read_thread_id; -#define TRY_ABORT 0 /* This code does not work so turn it off. */ +#define TRY_ABORT 0 // This code does not work so turn it off. #if TRY_ABORT static void @@ -89,7 +89,7 @@ beos_select(int nbits, bigtime_t tmo; if (nbits == 0) { - /* select is purely being used for delay */ + // select is purely being used for delay snooze(timeout->tv_sec * 1e6 + timeout->tv_usec); return 0; } @@ -140,10 +140,10 @@ beos_select(int nbits, resume_thread(read_thread_id); } - /* timeout == NULL means "indefinitely" */ + // timeout == NULL means "indefinitely" if (timeout) { tmo = timeout->tv_sec * 1e6 + timeout->tv_usec; - /* 0 means "don't wait, which is impossible to do exactly. */ + // 0 means "don't wait, which is impossible to do exactly. if (tmo == 0) tmo = 1.0; } diff --git a/src/os_mac_conv.c b/src/os_mac_conv.c --- a/src/os_mac_conv.c +++ b/src/os_mac_conv.c @@ -25,7 +25,7 @@ #if defined(MACOS_CONVERT) || defined(PROTO) # ifdef PROTO -/* A few dummy types to be able to generate function prototypes. */ +// A few dummy types to be able to generate function prototypes. typedef int UniChar; typedef int *TECObjectRef; typedef int CFStringRef; @@ -34,9 +34,9 @@ typedef int CFStringRef; static char_u *mac_utf16_to_utf8(UniChar *from, size_t fromLen, size_t *actualLen); static UniChar *mac_utf8_to_utf16(char_u *from, size_t fromLen, size_t *actualLen); -/* Converter for composing decomposed HFS+ file paths */ +// Converter for composing decomposed HFS+ file paths static TECObjectRef gPathConverter; -/* Converter used by mac_utf16_to_utf8 */ +// Converter used by mac_utf16_to_utf8 static TECObjectRef gUTF16ToUTF8Converter; /* @@ -79,9 +79,9 @@ mac_string_convert( if (cfstr == NULL) fprintf(stderr, "Encoding failed\n"); - /* When conversion failed, try excluding bytes from the end, helps when - * there is an incomplete byte sequence. Only do up to 6 bytes to avoid - * looping a long time when there really is something unconvertible. */ + // When conversion failed, try excluding bytes from the end, helps when + // there is an incomplete byte sequence. Only do up to 6 bytes to avoid + // looping a long time when there really is something unconvertible. while (cfstr == NULL && unconvlenp != NULL && len > 1 && *unconvlenp < 6) { --len; @@ -104,7 +104,7 @@ mac_string_convert( #if 0 CFRange convertRange = CFRangeMake(0, CFStringGetLength(cfstr)); - /* Determine output buffer size */ + // Determine output buffer size CFStringGetBytes(cfstr, convertRange, to, NULL, FALSE, NULL, 0, (CFIndex *)&buflen); retval = (buflen > 0) ? alloc(buflen) : NULL; if (retval == NULL) { @@ -127,8 +127,8 @@ mac_string_convert( } fprintf(stderr, "Trying char-by-char conversion...\n"); - /* conversion failed for the whole string, but maybe it will work - * for each character */ + // conversion failed for the whole string, but maybe it will work + // for each character for (d = retval, in = 0, out = 0; in < len && out < buflen - 1;) { if (from == kCFStringEncodingUTF8) @@ -188,8 +188,8 @@ macroman2enc( CFRange r; CFIndex len = *sizep; - /* MacRoman is an 8-bit encoding, no need to move bytes to - * conv_rest[]. */ + // MacRoman is an 8-bit encoding, no need to move bytes to + // conv_rest[]. cfstr = CFStringCreateWithBytes(NULL, ptr, len, kCFStringEncodingMacRoman, 0); /* @@ -203,8 +203,8 @@ macroman2enc( r.length = CFStringGetLength(cfstr); if (r.length != CFStringGetBytes(cfstr, r, (enc_utf8) ? kCFStringEncodingUTF8 : kCFStringEncodingISOLatin1, - 0, /* no lossy conversion */ - 0, /* not external representation */ + 0, // no lossy conversion + 0, // not external representation ptr + *sizep, real_size - *sizep, &len)) { CFRelease(cfstr); @@ -256,9 +256,9 @@ enc2macroman( r.length = CFStringGetLength(cfstr); if (r.length != CFStringGetBytes(cfstr, r, kCFStringEncodingMacRoman, - 0, /* no lossy conversion */ - 0, /* not external representation (since vim - * handles this internally */ + 0, // no lossy conversion + 0, // not external representation (since vim + // handles this internally to, maxtolen, &l)) { CFRelease(cfstr); @@ -296,8 +296,8 @@ mac_conv_init(void) if (TECCreateConverter(&gUTF16ToUTF8Converter, utf16_encoding, utf8_canon_encoding) != noErr) { - /* On pre-10.3, Unicode normalization is not available so - * fall back to non-normalizing converter */ + // On pre-10.3, Unicode normalization is not available so + // fall back to non-normalizing converter if (TECCreateConverter(&gUTF16ToUTF8Converter, utf16_encoding, utf8_encoding) != noErr) gUTF16ToUTF8Converter = NULL; @@ -334,30 +334,30 @@ mac_utf16_to_enc( size_t fromLen, size_t *actualLen) { - /* Following code borrows somewhat from os_mswin.c */ + // Following code borrows somewhat from os_mswin.c vimconv_T conv; size_t utf8_len; char_u *utf8_str; char_u *result = NULL; - /* Convert to utf-8 first, works better with iconv */ + // Convert to utf-8 first, works better with iconv utf8_len = 0; utf8_str = mac_utf16_to_utf8(from, fromLen, &utf8_len); if (utf8_str) { - /* We might be called before we have p_enc set up. */ + // We might be called before we have p_enc set up. conv.vc_type = CONV_NONE; - /* If encoding (p_enc) is any unicode, it is actually in utf-8 (vim - * internal unicode is always utf-8) so don't convert in such cases */ + // If encoding (p_enc) is any unicode, it is actually in utf-8 (vim + // internal unicode is always utf-8) so don't convert in such cases if ((enc_canon_props(p_enc) & ENC_UNICODE) == 0) convert_setup(&conv, (char_u *)"utf-8", p_enc? p_enc: (char_u *)"macroman"); if (conv.vc_type == CONV_NONE) { - /* p_enc is utf-8, so we're done. */ + // p_enc is utf-8, so we're done. result = utf8_str; } else @@ -388,7 +388,7 @@ mac_enc_to_utf16( size_t fromLen, size_t *actualLen) { - /* Following code borrows somewhat from os_mswin.c */ + // Following code borrows somewhat from os_mswin.c vimconv_T conv; size_t utf8_len; char_u *utf8_str; @@ -397,9 +397,9 @@ mac_enc_to_utf16( do { - /* Use MacRoman by default, we might be called before we have p_enc - * set up. Convert to utf-8 first, works better with iconv(). Does - * nothing if 'encoding' is "utf-8". */ + // Use MacRoman by default, we might be called before we have p_enc + // set up. Convert to utf-8 first, works better with iconv(). Does + // nothing if 'encoding' is "utf-8". conv.vc_type = CONV_NONE; if ((enc_canon_props(p_enc) & ENC_UNICODE) == 0 && convert_setup(&conv, p_enc ? p_enc : (char_u *)"macroman", @@ -583,4 +583,4 @@ mac_lang_init(void) } } } -#endif /* MACOS_CONVERT */ +#endif // MACOS_CONVERT diff --git a/src/os_mswin.c b/src/os_mswin.c --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -42,7 +42,7 @@ # include # endif -#endif /* PROTO */ +#endif // PROTO #ifdef __MINGW32__ # ifndef FROM_LEFT_1ST_BUTTON_PRESSED @@ -122,8 +122,8 @@ typedef int WPARAM; typedef void VOID; #endif -/* Record all output and all keyboard & mouse input */ -/* #define MCH_WRITE_DUMP */ +// Record all output and all keyboard & mouse input +// #define MCH_WRITE_DUMP #ifdef MCH_WRITE_DUMP FILE* fdDump = NULL; @@ -136,15 +136,15 @@ extern char g_szOrigTitle[]; #ifdef FEAT_GUI extern HWND s_hwnd; #else -static HWND s_hwnd = 0; /* console window handle, set by GetConsoleHwnd() */ +static HWND s_hwnd = 0; // console window handle, set by GetConsoleHwnd() #endif #ifdef FEAT_JOB_CHANNEL -int WSInitialized = FALSE; /* WinSock is initialized */ +int WSInitialized = FALSE; // WinSock is initialized #endif -/* Don't generate prototypes here, because some systems do have these - * functions. */ +// Don't generate prototypes here, because some systems do have these +// functions. #if defined(__GNUC__) && !defined(PROTO) # ifndef __MINGW32__ int _stricoll(char *a, char *b) @@ -199,7 +199,7 @@ mch_exit_g(int r) display_errors(); - ml_close_all(TRUE); /* remove all memfiles */ + ml_close_all(TRUE); // remove all memfiles # ifdef FEAT_OLE UninitOLE(); @@ -225,7 +225,7 @@ mch_exit_g(int r) exit(r); } -#endif /* FEAT_GUI_MSWIN */ +#endif // FEAT_GUI_MSWIN /* @@ -238,7 +238,7 @@ mch_early_init(void) PlatformId(); - /* Init the tables for toupper() and tolower() */ + // Init the tables for toupper() and tolower() for (i = 0; i < 256; ++i) toupper_tab[i] = tolower_tab[i] = i; CharUpperBuff((LPSTR)toupper_tab, 256); @@ -256,7 +256,7 @@ mch_input_isatty(void) # ifdef VIMDLL if (gui.in_use) # endif - return TRUE; /* GUI always has a tty */ + return TRUE; // GUI always has a tty #endif #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) if (isatty(read_cmd_fd)) @@ -336,7 +336,7 @@ mch_can_restore_icon(void) { return FALSE; } -#endif /* FEAT_TITLE */ +#endif // FEAT_TITLE /* @@ -387,17 +387,17 @@ mch_FullName( int mch_isFullName(char_u *fname) { - /* WinNT and later can use _MAX_PATH wide characters for a pathname, which - * means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is - * UTF-8. */ + // WinNT and later can use _MAX_PATH wide characters for a pathname, which + // means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is + // UTF-8. char szName[_MAX_PATH * 3 + 1]; - /* A name like "d:/foo" and "//server/share" is absolute */ + // A name like "d:/foo" and "//server/share" is absolute if ((fname[0] && fname[1] == ':' && (fname[2] == '/' || fname[2] == '\\')) || (fname[0] == fname[1] && (fname[0] == '/' || fname[0] == '\\'))) return TRUE; - /* A name that can't be made absolute probably isn't absolute. */ + // A name that can't be made absolute probably isn't absolute. if (mch_FullName(fname, (char_u *)szName, sizeof(szName) - 1, FALSE) == FAIL) return FALSE; @@ -424,7 +424,7 @@ slash_adjust(char_u *p) { size_t len = STRLEN(p); - /* don't replace backslash in backtick quoted strings */ + // don't replace backslash in backtick quoted strings if (len > 2 && *(p + len - 1) == '`') return; } @@ -437,7 +437,7 @@ slash_adjust(char_u *p) } } -/* Use 64-bit stat functions if available. */ +// Use 64-bit stat functions if available. #ifdef HAVE_STAT64 # undef stat # undef _stat @@ -459,15 +459,15 @@ slash_adjust(char_u *p) wstat_symlink_aware(const WCHAR *name, stat_T *stp) { #if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__MINGW32__) - /* Work around for VC12 or earlier (and MinGW). _wstat() can't handle - * symlinks properly. - * VC9 or earlier: _wstat() doesn't support a symlink at all. It retrieves - * status of a symlink itself. - * VC10: _wstat() supports a symlink to a normal file, but it doesn't - * support a symlink to a directory (always returns an error). - * VC11 and VC12: _wstat() doesn't return an error for a symlink to a - * directory, but it doesn't set S_IFDIR flag. - * MinGW: Same as VC9. */ + // Work around for VC12 or earlier (and MinGW). _wstat() can't handle + // symlinks properly. + // VC9 or earlier: _wstat() doesn't support a symlink at all. It retrieves + // status of a symlink itself. + // VC10: _wstat() supports a symlink to a normal file, but it doesn't + // support a symlink to a directory (always returns an error). + // VC11 and VC12: _wstat() doesn't return an error for a symlink to a + // directory, but it doesn't set S_IFDIR flag. + // MinGW: Same as VC9. int n; BOOL is_symlink = FALSE; HANDLE hFind, h; @@ -513,9 +513,9 @@ wstat_symlink_aware(const WCHAR *name, s int vim_stat(const char *name, stat_T *stp) { - /* WinNT and later can use _MAX_PATH wide characters for a pathname, which - * means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is - * UTF-8. */ + // WinNT and later can use _MAX_PATH wide characters for a pathname, which + // means that the maximum pathname is _MAX_PATH * 3 bytes when 'enc' is + // UTF-8. char_u buf[_MAX_PATH * 3 + 1]; char_u *p; WCHAR *wp; @@ -526,13 +526,13 @@ vim_stat(const char *name, stat_T *stp) if (p > buf) MB_PTR_BACK(buf, p); - /* Remove trailing '\\' except root path. */ + // Remove trailing '\\' except root path. if (p > buf && (*p == '\\' || *p == '/') && p[-1] != ':') *p = NUL; if ((buf[0] == '\\' && buf[1] == '\\') || (buf[0] == '/' && buf[1] == '/')) { - /* UNC root path must be followed by '\\'. */ + // UNC root path must be followed by '\\'. p = vim_strpbrk(buf + 2, (char_u *)"\\/"); if (p != NULL) { @@ -555,20 +555,20 @@ vim_stat(const char *name, stat_T *stp) void mch_settmode(int tmode UNUSED) { - /* nothing to do */ + // nothing to do } int mch_get_shellsize(void) { - /* never used */ + // never used return OK; } void mch_set_shellsize(void) { - /* never used */ + // never used } /* @@ -577,7 +577,7 @@ mch_set_shellsize(void) void mch_new_shellsize(void) { - /* never used */ + // never used } #endif @@ -612,7 +612,7 @@ display_errors(void) { if (error_ga.ga_data != NULL) { - /* avoid putting up a message box with blanks only */ + // avoid putting up a message box with blanks only for (p = (char *)error_ga.ga_data; *p; ++p) if (!isspace(*p)) { @@ -686,7 +686,7 @@ mch_chdir(char *path) WCHAR *p; int n; - if (path[0] == NUL) /* just checking... */ + if (path[0] == NUL) // just checking... return -1; if (p_verbose >= 5) @@ -695,16 +695,16 @@ mch_chdir(char *path) smsg("chdir(%s)", path); verbose_leave(); } - if (isalpha(path[0]) && path[1] == ':') /* has a drive name */ + if (isalpha(path[0]) && path[1] == ':') // has a drive name { - /* If we can change to the drive, skip that part of the path. If we - * can't then the current directory may be invalid, try using chdir() - * with the whole path. */ + // If we can change to the drive, skip that part of the path. If we + // can't then the current directory may be invalid, try using chdir() + // with the whole path. if (_chdrive(TOLOWER_ASC(path[0]) - 'a' + 1) == 0) path += 2; } - if (*path == NUL) /* drive name only */ + if (*path == NUL) // drive name only return 0; p = enc_to_utf16((char_u *)path, NULL); @@ -724,7 +724,7 @@ mch_chdir(char *path) int mch_char_avail(void) { - /* never used */ + // never used return TRUE; } @@ -735,7 +735,7 @@ mch_char_avail(void) int mch_check_messages(void) { - /* TODO: check for messages */ + // TODO: check for messages return TRUE; } # endif @@ -778,20 +778,20 @@ check_str_len(char_u *str) size_t i; const char_u *p; - /* get page size */ + // get page size GetSystemInfo(&si); - /* get memory information */ + // get memory information if (VirtualQuery(str, &mbi, sizeof(mbi))) { - /* pre cast these (typing savers) */ + // pre cast these (typing savers) long_u dwStr = (long_u)str; long_u dwBaseAddress = (long_u)mbi.BaseAddress; - /* get start address of page that str is on */ + // get start address of page that str is on long_u strPage = dwStr - (dwStr - dwBaseAddress) % si.dwPageSize; - /* get length from str to end of page */ + // get length from str to end of page long_u pageLength = si.dwPageSize - (dwStr - strPage); for (p = str; !IsBadReadPtr(p, (UINT)pageLength); @@ -834,9 +834,9 @@ mch_icon_load(HANDLE *iconp) 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) { HINSTANCE hinstLib; @@ -860,7 +860,7 @@ mch_libcall( # endif if (argstring != NULL) { - /* Call with string argument */ + // Call with string argument ProcAdd = (MYSTRPROCSTR)GetProcAddress(hinstLib, (LPCSTR)funcname); if ((fRunTimeLinkSuccess = (ProcAdd != NULL)) != 0) { @@ -872,7 +872,7 @@ mch_libcall( } else { - /* Call with number argument */ + // Call with number argument ProcAddI = (MYINTPROCSTR) GetProcAddress(hinstLib, (LPCSTR)funcname); if ((fRunTimeLinkSuccess = (ProcAddI != NULL)) != 0) { @@ -957,7 +957,7 @@ Trace( #if !defined(FEAT_GUI) || defined(VIMDLL) || defined(PROTO) # ifdef FEAT_TITLE -extern HWND g_hWnd; /* This is in os_win32.c. */ +extern HWND g_hWnd; // This is in os_win32.c. # endif /* @@ -968,12 +968,12 @@ extern HWND g_hWnd; /* This is in os_win static void GetConsoleHwnd(void) { - /* Skip if it's already set. */ + // Skip if it's already set. if (s_hwnd != 0) return; # ifdef FEAT_TITLE - /* Window handle may have been found by init code (Windows NT only) */ + // Window handle may have been found by init code (Windows NT only) if (g_hWnd != 0) { s_hwnd = g_hWnd; @@ -1013,9 +1013,8 @@ mch_set_winpos(int x, int y) #if (defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT)) || defined(PROTO) -/*================================================================= - * Win32 printer stuff - */ +//================================================================= +// Win32 printer stuff static HFONT prt_font_handles[2][2][2]; static PRINTDLGW prt_dlg; @@ -1031,7 +1030,7 @@ static HWND hDlgPrint; static int *bUserAbort = NULL; static char_u *prt_name = NULL; -/* Defines which are also in vim.rc. */ +// Defines which are also in vim.rc. # define IDC_BOX1 400 # define IDC_PRINTTEXT1 401 # define IDC_PRINTTEXT2 402 @@ -1067,7 +1066,7 @@ swap_me(COLORREF colorref) return colorref; } -/* Attempt to make this work for old and new compilers */ +// Attempt to make this work for old and new compilers # if !defined(_WIN64) && (!defined(_MSC_VER) || _MSC_VER < 1300) # define PDP_RETVAL BOOL # else @@ -1100,7 +1099,7 @@ PrintDlgProc( char buff[MAX_PATH]; int i; - /* Translate the dialog texts */ + // Translate the dialog texts hfont = CreateFontIndirect(&nm.lfMessageFont); for (i = IDC_PRINTTEXT1; i <= IDC_PROGRESS; i++) { @@ -1201,11 +1200,11 @@ PrintHookProc( 0, 0, // ignores size arguments SWP_NOSIZE); - /* tackle the printdlg copiesctrl problem */ + // tackle the printdlg copiesctrl problem pPD = (PRINTDLGW *)lParam; pPD->nCopies = (WORD)pPD->lCustData; SetDlgItemInt( hDlg, edt3, pPD->nCopies, FALSE ); - /* Bring the window to top */ + // Bring the window to top BringWindowToTop(GetParent(hDlg)); SetForegroundWindow(hDlg); } @@ -1323,7 +1322,7 @@ prt_get_lpp(void) prt_top_margin = to_device_units(OPT_PRINT_TOP, dpi, phyw, dvoff, 5); - /* adjust top margin if there is a header */ + // adjust top margin if there is a header prt_top_margin += prt_line_height * prt_header_height(); bottom_margin = vr - to_device_units(OPT_PRINT_BOT, dpi, phyw, @@ -1356,7 +1355,7 @@ mch_print_init(prt_settings_T *psettings # ifdef VIMDLL if (!gui.in_use) # endif - GetConsoleHwnd(); /* get value of s_hwnd */ + GetConsoleHwnd(); // get value of s_hwnd # endif prt_dlg.hwndOwner = s_hwnd; prt_dlg.Flags = PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC; @@ -1428,15 +1427,15 @@ mch_print_init(prt_settings_T *psettings return FALSE; } - /* Not all printer drivers report the support of color (or grey) in the - * same way. Let's set has_color if there appears to be some way to print - * more than B&W. */ + // Not all printer drivers report the support of color (or grey) in the + // same way. Let's set has_color if there appears to be some way to print + // more than B&W. i = GetDeviceCaps(prt_dlg.hDC, NUMCOLORS); psettings->has_color = (GetDeviceCaps(prt_dlg.hDC, BITSPIXEL) > 1 || GetDeviceCaps(prt_dlg.hDC, PLANES) > 1 || i > 2 || i == -1); - /* Ensure all font styles are baseline aligned */ + // Ensure all font styles are baseline aligned SetTextAlign(prt_dlg.hDC, TA_BASELINE|TA_LEFT); /* @@ -1537,8 +1536,8 @@ init_fail_dlg: { char_u *buf; - /* I suspect FormatMessage() doesn't work for values returned by - * CommDlgExtendedError(). What does? */ + // I suspect FormatMessage() doesn't work for values returned by + // CommDlgExtendedError(). What does? FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, @@ -1548,7 +1547,7 @@ init_fail_dlg: LocalFree((LPVOID)(buf)); } else - msg_clr_eos(); /* Maybe canceled */ + msg_clr_eos(); // Maybe canceled mch_print_cleanup(); return FALSE; @@ -1582,7 +1581,7 @@ mch_print_begin(prt_settings_T *psetting } # ifdef FEAT_GUI - /* Give focus back to main window (when using MDI). */ + // Give focus back to main window (when using MDI). # ifdef VIMDLL if (gui.in_use) # endif @@ -1651,7 +1650,7 @@ mch_print_text_out(char_u *p, int len) GetTextExtentPoint32W(prt_dlg.hDC, wp, wlen, &sz); vim_free(wp); prt_pos_x += (sz.cx - prt_tm.tmOverhang); - /* This is wrong when printing spaces for a TAB. */ + // This is wrong when printing spaces for a TAB. if (p[len] != NUL) { wlen = mb_ptr2len(p + len); @@ -1694,7 +1693,7 @@ mch_print_set_fg(long_u fgcol) swap_me((COLORREF)fgcol))); } -#endif /*FEAT_PRINTER && !FEAT_POSTSCRIPT*/ +#endif // FEAT_PRINTER && !FEAT_POSTSCRIPT @@ -1830,8 +1829,8 @@ resolve_shortcut(char_u *fname) IShellLinkW *pslw = NULL; WIN32_FIND_DATAW ffdw; // we get those free of charge - /* Check if the file name ends in ".lnk". Avoid calling - * CoCreateInstance(), it's quite slow. */ + // Check if the file name ends in ".lnk". Avoid calling + // CoCreateInstance(), it's quite slow. if (fname == NULL) return rfname; len = (int)STRLEN(fname); @@ -1907,7 +1906,7 @@ mch_resolve_path(char_u *fname, int repa void win32_set_foreground(void) { - GetConsoleHwnd(); /* get value of s_hwnd */ + GetConsoleHwnd(); // get value of s_hwnd if (s_hwnd != 0) SetForegroundWindow(s_hwnd); } @@ -1920,20 +1919,19 @@ win32_set_foreground(void) * Originally written by Paul Moore */ -/* In order to handle inter-process messages, we need to have a window. But - * the functions in this module can be called before the main GUI window is - * created (and may also be called in the console version, where there is no - * GUI window at all). - * - * So we create a hidden window, and arrange to destroy it on exit. - */ -HWND message_window = 0; /* window that's handling messages */ +// In order to handle inter-process messages, we need to have a window. But +// the functions in this module can be called before the main GUI window is +// created (and may also be called in the console version, where there is no +// GUI window at all). +// +// So we create a hidden window, and arrange to destroy it on exit. +HWND message_window = 0; // window that's handling messages # define VIM_CLASSNAME "VIM_MESSAGES" # define VIM_CLASSNAME_LEN (sizeof(VIM_CLASSNAME) - 1) -/* Communication is via WM_COPYDATA messages. The message type is send in - * the dwData parameter. Types are defined here. */ +// Communication is via WM_COPYDATA messages. The message type is send in +// the dwData parameter. Types are defined here. # define COPYDATA_KEYS 0 # define COPYDATA_REPLY 1 # define COPYDATA_EXPR 10 @@ -1941,14 +1939,14 @@ HWND message_window = 0; /* window t # define COPYDATA_ERROR_RESULT 12 # define COPYDATA_ENCODING 20 -/* This is a structure containing a server HWND and its name. */ +// This is a structure containing a server HWND and its name. struct server_id { HWND hwnd; char_u *name; }; -/* Last received 'encoding' that the client uses. */ +// Last received 'encoding' that the client uses. static char_u *client_enc = NULL; /* @@ -1997,27 +1995,26 @@ Messaging_WndProc(HWND hwnd, UINT msg, W { if (msg == WM_COPYDATA) { - /* This is a message from another Vim. The dwData member of the - * COPYDATASTRUCT determines the type of message: - * COPYDATA_ENCODING: - * The encoding that the client uses. Following messages will - * use this encoding, convert if needed. - * COPYDATA_KEYS: - * A key sequence. We are a server, and a client wants these keys - * adding to the input queue. - * COPYDATA_REPLY: - * A reply. We are a client, and a server has sent this message - * in response to a request. (server2client()) - * COPYDATA_EXPR: - * An expression. We are a server, and a client wants us to - * evaluate this expression. - * COPYDATA_RESULT: - * A reply. We are a client, and a server has sent this message - * in response to a COPYDATA_EXPR. - * COPYDATA_ERROR_RESULT: - * A reply. We are a client, and a server has sent this message - * in response to a COPYDATA_EXPR that failed to evaluate. - */ + // This is a message from another Vim. The dwData member of the + // COPYDATASTRUCT determines the type of message: + // COPYDATA_ENCODING: + // The encoding that the client uses. Following messages will + // use this encoding, convert if needed. + // COPYDATA_KEYS: + // A key sequence. We are a server, and a client wants these keys + // adding to the input queue. + // COPYDATA_REPLY: + // A reply. We are a client, and a server has sent this message + // in response to a request. (server2client()) + // COPYDATA_EXPR: + // An expression. We are a server, and a client wants us to + // evaluate this expression. + // COPYDATA_RESULT: + // A reply. We are a client, and a server has sent this message + // in response to a COPYDATA_EXPR. + // COPYDATA_ERROR_RESULT: + // A reply. We are a client, and a server has sent this message + // in response to a COPYDATA_EXPR that failed to evaluate. COPYDATASTRUCT *data = (COPYDATASTRUCT*)lParam; HWND sender = (HWND)wParam; COPYDATASTRUCT reply; @@ -2029,23 +2026,23 @@ Messaging_WndProc(HWND hwnd, UINT msg, W switch (data->dwData) { case COPYDATA_ENCODING: - /* Remember the encoding that the client uses. */ + // Remember the encoding that the client uses. vim_free(client_enc); client_enc = enc_canonize((char_u *)data->lpData); return 1; case COPYDATA_KEYS: - /* Remember who sent this, for */ + // Remember who sent this, for clientWindow = sender; - /* Add the received keys to the input buffer. The loop waiting - * for the user to do something should check the input buffer. */ + // Add the received keys to the input buffer. The loop waiting + // for the user to do something should check the input buffer. str = serverConvert(client_enc, (char_u *)data->lpData, &tofree); server_to_input_buf(str); vim_free(tofree); # ifdef FEAT_GUI - /* Wake up the main GUI loop. */ + // Wake up the main GUI loop. # ifdef VIMDLL if (gui.in_use) # endif @@ -2055,7 +2052,7 @@ Messaging_WndProc(HWND hwnd, UINT msg, W return 1; case COPYDATA_EXPR: - /* Remember who sent this, for */ + // Remember who sent this, for clientWindow = sender; str = serverConvert(client_enc, (char_u *)data->lpData, &tofree); @@ -2114,13 +2111,13 @@ Messaging_WndProc(HWND hwnd, UINT msg, W else if (msg == WM_ACTIVATE && wParam == WA_ACTIVE) { - /* When the message window is activated (brought to the foreground), - * this actually applies to the text window. */ + // When the message window is activated (brought to the foreground), + // this actually applies to the text window. # if !defined(FEAT_GUI) || defined(VIMDLL) # ifdef VIMDLL if (!gui.in_use) # endif - GetConsoleHwnd(); /* get value of s_hwnd */ + GetConsoleHwnd(); // get value of s_hwnd # endif if (s_hwnd != 0) { @@ -2141,12 +2138,11 @@ serverInitMessaging(void) { WNDCLASS wndclass; - /* Clean up on exit */ + // Clean up on exit atexit(CleanUpMessaging); - /* Register a window class - we only really care - * about the window procedure - */ + // Register a window class - we only really care + // about the window procedure wndclass.style = 0; wndclass.lpfnWndProc = Messaging_WndProc; wndclass.cbClsExtra = 0; @@ -2159,9 +2155,9 @@ serverInitMessaging(void) wndclass.lpszClassName = VIM_CLASSNAME; RegisterClass(&wndclass); - /* Create the message window. It will be hidden, so the details don't - * matter. Don't use WS_OVERLAPPEDWINDOW, it will make a shortcut remove - * focus from gvim. */ + // Create the message window. It will be hidden, so the details don't + // matter. Don't use WS_OVERLAPPEDWINDOW, it will make a shortcut remove + // focus from gvim. message_window = CreateWindow(VIM_CLASSNAME, "", WS_POPUPWINDOW | WS_CAPTION, CW_USEDEFAULT, CW_USEDEFAULT, @@ -2169,7 +2165,7 @@ serverInitMessaging(void) g_hinst, NULL); } -/* Used by serverSendToVim() to find an alternate server name. */ +// Used by serverSendToVim() to find an alternate server name. static char_u *altname_buf_ptr = NULL; /* @@ -2183,12 +2179,12 @@ getVimServerName(HWND hwnd, char *name, int len; char buffer[VIM_CLASSNAME_LEN + 1]; - /* Ignore windows which aren't Vim message windows */ + // Ignore windows which aren't Vim message windows len = GetClassName(hwnd, buffer, sizeof(buffer)); if (len != VIM_CLASSNAME_LEN || STRCMP(buffer, VIM_CLASSNAME) != 0) return 0; - /* Get the title of the window */ + // Get the title of the window return GetWindowText(hwnd, name, namelen); } @@ -2198,27 +2194,27 @@ enumWindowsGetServer(HWND hwnd, LPARAM l struct server_id *id = (struct server_id *)lparam; char server[MAX_PATH]; - /* Get the title of the window */ + // Get the title of the window if (getVimServerName(hwnd, server, sizeof(server)) == 0) return TRUE; - /* If this is the server we're looking for, return its HWND */ + // If this is the server we're looking for, return its HWND if (STRICMP(server, id->name) == 0) { id->hwnd = hwnd; return FALSE; } - /* If we are looking for an alternate server, remember this name. */ + // If we are looking for an alternate server, remember this name. if (altname_buf_ptr != NULL && STRNICMP(server, id->name, STRLEN(id->name)) == 0 && vim_isdigit(server[STRLEN(id->name)])) { STRCPY(altname_buf_ptr, server); - altname_buf_ptr = NULL; /* don't use another name */ + altname_buf_ptr = NULL; // don't use another name } - /* Otherwise, keep looking */ + // Otherwise, keep looking return TRUE; } @@ -2228,11 +2224,11 @@ enumWindowsGetNames(HWND hwnd, LPARAM lp garray_T *ga = (garray_T *)lparam; char server[MAX_PATH]; - /* Get the title of the window */ + // Get the title of the window if (getVimServerName(hwnd, server, sizeof(server)) == 0) return TRUE; - /* Add the name to the list */ + // Add the name to the list ga_concat(ga, (char_u *)server); ga_concat(ga, (char_u *)"\n"); return TRUE; @@ -2262,7 +2258,9 @@ enum_windows_toplevel(HWND hwnd, LPARAM return EnumChildWindows(hwnd, enum_windows_child, lParam); } -/* Enumerate all windows including children. */ +/* + * Enumerate all windows including children. + */ static BOOL enum_windows(WNDENUMPROC lpEnumFunc, LPARAM lParam) { @@ -2294,7 +2292,7 @@ serverSetName(char_u *name) int i = 0; char_u *p; - /* Leave enough space for a 9-digit suffix to ensure uniqueness! */ + // Leave enough space for a 9-digit suffix to ensure uniqueness! ok_name = alloc(STRLEN(name) + 10); STRCPY(ok_name, name); @@ -2302,10 +2300,9 @@ serverSetName(char_u *name) for (;;) { - /* This is inefficient - we're doing an EnumWindows loop for each - * possible name. It would be better to grab all names in one go, - * and scan the list each time... - */ + // This is inefficient - we're doing an EnumWindows loop for each + // possible name. It would be better to grab all names in one go, + // and scan the list each time... hwnd = findServer(ok_name); if (hwnd == 0) break; @@ -2321,17 +2318,17 @@ serverSetName(char_u *name) vim_free(ok_name); else { - /* Remember the name */ + // Remember the name serverName = ok_name; # ifdef FEAT_TITLE - need_maketitle = TRUE; /* update Vim window title later */ + need_maketitle = TRUE; // update Vim window title later # endif - /* Update the message window title */ + // Update the message window title SetWindowText(message_window, (LPCSTR)ok_name); # ifdef FEAT_EVAL - /* Set the servername variable */ + // Set the servername variable set_vim_var_string(VV_SEND_SERVER, serverName, -1); # endif } @@ -2352,17 +2349,16 @@ serverGetVimNames(void) int serverSendReply( - char_u *name, /* Where to send. */ - char_u *reply) /* What to send. */ + char_u *name, // Where to send. + char_u *reply) // What to send. { HWND target; COPYDATASTRUCT data; long_u n = 0; - /* The "name" argument is a magic cookie obtained from expand(""). - * It should be of the form 0xXXXXX - i.e. a C hex literal, which is the - * value of the client's message window HWND. - */ + // The "name" argument is a magic cookie obtained from expand(""). + // It should be of the form 0xXXXXX - i.e. a C hex literal, which is the + // value of the client's message window HWND. sscanf((char *)name, SCANF_HEX_LONG_U, &n); if (n == 0) return -1; @@ -2385,13 +2381,13 @@ serverSendReply( int serverSendToVim( - char_u *name, /* Where to send. */ - char_u *cmd, /* What to send. */ - char_u **result, /* Result of eval'ed expression */ - void *ptarget, /* HWND of server */ - int asExpr, /* Expression or keys? */ - int timeout, /* timeout in seconds or zero */ - int silent) /* don't complain about no server */ + char_u *name, // Where to send. + char_u *cmd, // What to send. + char_u **result, // Result of eval'ed expression + void *ptarget, // HWND of server + int asExpr, // Expression or keys? + int timeout, // timeout in seconds or zero + int silent) // don't complain about no server { HWND target; COPYDATASTRUCT data; @@ -2399,19 +2395,19 @@ serverSendToVim( int retcode = 0; char_u altname_buf[MAX_PATH]; - /* Execute locally if no display or target is ourselves */ + // Execute locally if no display or target is ourselves if (serverName != NULL && STRICMP(name, serverName) == 0) return sendToLocalVim(cmd, asExpr, result); - /* If the server name does not end in a digit then we look for an - * alternate name. e.g. when "name" is GVIM the we may find GVIM2. */ + // If the server name does not end in a digit then we look for an + // alternate name. e.g. when "name" is GVIM the we may find GVIM2. if (STRLEN(name) > 1 && !vim_isdigit(name[STRLEN(name) - 1])) altname_buf_ptr = altname_buf; altname_buf[0] = NUL; target = findServer(name); altname_buf_ptr = NULL; if (target == 0 && altname_buf[0] != NUL) - /* Use another server name we found. */ + // Use another server name we found. target = findServer(altname_buf); if (target == 0) @@ -2439,7 +2435,7 @@ serverSendToVim( if (result == NULL) vim_free(retval); else - *result = retval; /* Caller assumes responsibility for freeing */ + *result = retval; // Caller assumes responsibility for freeing return retcode; } @@ -2456,19 +2452,18 @@ serverForeground(char_u *name) SetForegroundWindow(target); } -/* Replies from server need to be stored until the client picks them up via - * remote_read(). So we maintain a list of server-id/reply pairs. - * Note that there could be multiple replies from one server pending if the - * client is slow picking them up. - * We just store the replies in a simple list. When we remove an entry, we - * move list entries down to fill the gap. - * The server ID is simply the HWND. - */ +// Replies from server need to be stored until the client picks them up via +// remote_read(). So we maintain a list of server-id/reply pairs. +// Note that there could be multiple replies from one server pending if the +// client is slow picking them up. +// We just store the replies in a simple list. When we remove an entry, we +// move list entries down to fill the gap. +// The server ID is simply the HWND. typedef struct { - HWND server; /* server window */ - char_u *reply; /* reply string */ - int expr_result; /* 0 for REPLY, 1 for RESULT 2 for error */ + HWND server; // server window + char_u *reply; // reply string + int expr_result; // 0 for REPLY, 1 for RESULT 2 for error } reply_T; static garray_T reply_list = {0, 0, sizeof(reply_T), 5, 0}; @@ -2476,7 +2471,7 @@ static garray_T reply_list = {0, 0, size # define REPLY_ITEM(i) ((reply_T *)(reply_list.ga_data) + (i)) # define REPLY_COUNT (reply_list.ga_len) -/* Flag which is used to wait for a reply */ +// Flag which is used to wait for a reply static int reply_received = 0; /* @@ -2520,12 +2515,12 @@ serverGetReply(HWND server, int *expr_re time_t start; time_t now; - /* When waiting, loop until the message waiting for is received. */ + // When waiting, loop until the message waiting for is received. time(&start); for (;;) { - /* Reset this here, in case a message arrives while we are going - * through the already received messages. */ + // Reset this here, in case a message arrives while we are going + // through the already received messages. reply_received = 0; for (i = 0; i < REPLY_COUNT; ++i) @@ -2534,31 +2529,31 @@ serverGetReply(HWND server, int *expr_re if (rep->server == server && ((rep->expr_result != 0) == (expr_res != NULL))) { - /* Save the values we've found for later */ + // Save the values we've found for later reply = rep->reply; if (expr_res != NULL) *expr_res = rep->expr_result == 1 ? 0 : -1; if (remove) { - /* Move the rest of the list down to fill the gap */ + // Move the rest of the list down to fill the gap mch_memmove(rep, rep + 1, (REPLY_COUNT - i - 1) * sizeof(reply_T)); --REPLY_COUNT; } - /* Return the reply to the caller, who takes on responsibility - * for freeing it if "remove" is TRUE. */ + // Return the reply to the caller, who takes on responsibility + // for freeing it if "remove" is TRUE. return reply; } } - /* If we got here, we didn't find a reply. Return immediately if the - * "wait" parameter isn't set. */ + // If we got here, we didn't find a reply. Return immediately if the + // "wait" parameter isn't set. if (!wait) { - /* Process pending messages once. Without this, looping on - * remote_peek() would never get the reply. */ + // Process pending messages once. Without this, looping on + // remote_peek() would never get the reply. if (!did_process) { did_process = TRUE; @@ -2568,26 +2563,26 @@ serverGetReply(HWND server, int *expr_re break; } - /* We need to wait for a reply. Enter a message loop until the - * "reply_received" flag gets set. */ - - /* Loop until we receive a reply */ + // We need to wait for a reply. Enter a message loop until the + // "reply_received" flag gets set. + + // Loop until we receive a reply while (reply_received == 0) { # ifdef FEAT_TIMERS - /* TODO: use the return value to decide how long to wait. */ + // TODO: use the return value to decide how long to wait. check_due_timer(); # endif time(&now); if (timeout > 0 && (now - start) >= timeout) break; - /* Wait for a SendMessage() call to us. This could be the reply - * we are waiting for. Use a timeout of a second, to catch the - * situation that the server died unexpectedly. */ + // Wait for a SendMessage() call to us. This could be the reply + // we are waiting for. Use a timeout of a second, to catch the + // situation that the server died unexpectedly. MsgWaitForMultipleObjects(0, NULL, TRUE, 1000, QS_ALLINPUT); - /* If the server has died, give up */ + // If the server has died, give up if (!IsWindow(server)) return NULL; @@ -2613,7 +2608,7 @@ serverProcessPendingMessages(void) } } -#endif /* FEAT_CLIENTSERVER */ +#endif // FEAT_CLIENTSERVER #if defined(FEAT_GUI) || (defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT)) \ || defined(PROTO) @@ -2713,7 +2708,7 @@ static const LOGFONTW s_lfDefault = -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FIXED_PITCH | FF_DONTCARE, - L"Fixedsys" /* see _ReadVimIni */ + L"Fixedsys" // see _ReadVimIni }; // Initialise the "current height" to -12 (same as s_lfDefault) just @@ -2722,7 +2717,8 @@ static const LOGFONTW s_lfDefault = // (-12 equates to roughly 9pt). int current_font_height = -12; // also used in gui_w32.c -/* Convert a string representing a point size into pixels. The string should +/* + * Convert a string representing a point size into pixels. The string should * be a positive decimal number, with an optional decimal point (eg, "12", or * "10.5"). The pixel value is returned, and a pointer to the next unconverted * character is stored in *end. The flag "vertical" says whether this @@ -2742,7 +2738,7 @@ points_to_pixels(WCHAR *str, WCHAR **end { if (*str == L'.' && divisor == 0) { - /* Start keeping a divisor, for later */ + // Start keeping a divisor, for later divisor = 1; } else @@ -2786,35 +2782,34 @@ font_enumproc( DWORD type UNUSED, LPARAM lparam) { - /* Return value: - * 0 = terminate now (monospace & ANSI) - * 1 = continue, still no luck... - * 2 = continue, but we have an acceptable LOGFONTW - * (monospace, not ANSI) - * We use these values, as EnumFontFamilies returns 1 if the - * callback function is never called. So, we check the return as - * 0 = perfect, 2 = OK, 1 = no good... - * It's not pretty, but it works! - */ + // Return value: + // 0 = terminate now (monospace & ANSI) + // 1 = continue, still no luck... + // 2 = continue, but we have an acceptable LOGFONTW + // (monospace, not ANSI) + // We use these values, as EnumFontFamilies returns 1 if the + // callback function is never called. So, we check the return as + // 0 = perfect, 2 = OK, 1 = no good... + // It's not pretty, but it works! LOGFONTW *lf = (LOGFONTW *)(lparam); # ifndef FEAT_PROPORTIONAL_FONTS - /* Ignore non-monospace fonts without further ado */ + // Ignore non-monospace fonts without further ado if ((ntm->tmPitchAndFamily & 1) != 0) return 1; # endif - /* Remember this LOGFONTW as a "possible" */ + // Remember this LOGFONTW as a "possible" *lf = elf->elfLogFont; - /* Terminate the scan as soon as we find an ANSI font */ + // Terminate the scan as soon as we find an ANSI font if (lf->lfCharSet == ANSI_CHARSET || lf->lfCharSet == OEM_CHARSET || lf->lfCharSet == DEFAULT_CHARSET) return 0; - /* Continue the scan - we have a non-ANSI font */ + // Continue the scan - we have a non-ANSI font return 2; } @@ -2832,14 +2827,13 @@ init_logfont(LOGFONTW *lf) ReleaseDC(hwnd, hdc); - /* If we couldn't find a usable font, return failure */ + // If we couldn't find a usable font, return failure if (n == 1) return FAIL; - /* Tidy up the rest of the LOGFONTW structure. We set to a basic - * font - get_logfont() sets bold, italic, etc based on the user's - * input. - */ + // Tidy up the rest of the LOGFONTW structure. We set to a basic + // font - get_logfont() sets bold, italic, etc based on the user's + // input. lf->lfHeight = current_font_height; lf->lfWidth = 0; lf->lfItalic = FALSE; @@ -2847,7 +2841,7 @@ init_logfont(LOGFONTW *lf) lf->lfStrikeOut = FALSE; lf->lfWeight = FW_NORMAL; - /* Return success */ + // Return success return OK; } @@ -2897,7 +2891,7 @@ get_logfont( { # if defined(FEAT_GUI_MSWIN) CHOOSEFONTW cf; - /* if name is "*", bring up std font dialog: */ + // if name is "*", bring up std font dialog: vim_memset(&cf, 0, sizeof(cf)); cf.lStructSize = sizeof(cf); cf.hwndOwner = s_hwnd; @@ -2918,13 +2912,13 @@ get_logfont( for (p = wname; *p && *p != L':'; p++) { if (p - wname + 1 >= LF_FACESIZE) - goto theend; /* Name too long */ + goto theend; // Name too long lf->lfFaceName[p - wname] = *p; } if (p != wname) lf->lfFaceName[p - wname] = NUL; - /* First set defaults */ + // First set defaults lf->lfHeight = -12; lf->lfWidth = 0; lf->lfWeight = FW_NORMAL; @@ -2952,7 +2946,7 @@ get_logfont( while (*p == L':') p++; - /* Set the values found after ':' */ + // Set the values found after ':' while (*p) { switch (*p++) @@ -3029,7 +3023,7 @@ get_logfont( ret = OK; theend: - /* ron: init lastlf */ + // ron: init lastlf if (ret == OK && printer_dc == NULL) { vim_free(lastlf); @@ -3042,7 +3036,7 @@ theend: return ret; } -#endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */ +#endif // defined(FEAT_GUI) || defined(FEAT_PRINTER) #if defined(FEAT_JOB_CHANNEL) || defined(PROTO) /* diff --git a/src/os_qnx.c b/src/os_qnx.c --- a/src/os_qnx.c +++ b/src/os_qnx.c @@ -36,17 +36,17 @@ void qnx_init(void) #define CLIP_TYPE_VIM "VIMTYPE" #define CLIP_TYPE_TEXT "TEXT" -/* Turn on the clipboard for a console vim when photon is running */ +// Turn on the clipboard for a console vim when photon is running void qnx_clip_init(void) { if (is_photon_available == TRUE && !gui.in_use) clip_init(TRUE); } -/*****************************************************************************/ -/* Clipboard */ +///////////////////////////////////////////////////////////////////////////// +// Clipboard -/* No support for owning the clipboard */ +// No support for owning the clipboard int clip_mch_own_selection(Clipboard_T *cbd) { @@ -69,13 +69,13 @@ clip_mch_request_selection(Clipboard_T * cbdata = PhClipboardPasteStart(PhInputGroup(NULL)); if (cbdata != NULL) { - /* Look for the vim specific clip first */ + // Look for the vim specific clip first clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_VIM); if (clip_header != NULL && clip_header->data != NULL) { switch(*(char *) clip_header->data) { - default: /* fallthrough to line type */ + default: // fallthrough to line type case 'L': type = MLINE; break; case 'C': type = MCHAR; break; case 'B': type = MBLOCK; break; @@ -83,7 +83,7 @@ clip_mch_request_selection(Clipboard_T * is_type_set = TRUE; } - /* Try for just normal text */ + // Try for just normal text clip_header = PhClipboardPasteType(cbdata, CLIP_TYPE_TEXT); if (clip_header != NULL) { @@ -109,7 +109,7 @@ clip_mch_set_selection(Clipboard_T *cbd) char_u *text_clip, vim_clip[2], *str = NULL; PhClipHeader clip_header[2]; - /* Prevent recursion from clip_get_selection() */ + // Prevent recursion from clip_get_selection() if (cbd->owned == TRUE) return; @@ -136,7 +136,7 @@ clip_mch_set_selection(Clipboard_T *cbd) switch(type) { - default: /* fallthrough to MLINE */ + default: // fallthrough to MLINE case MLINE: *vim_clip = 'L'; break; case MCHAR: *vim_clip = 'C'; break; case MBLOCK: *vim_clip = 'B'; break; diff --git a/src/os_unix.c b/src/os_unix.c --- 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 @@ -51,8 +51,8 @@ static int selinux_enabled = -1; #ifdef __CYGWIN__ # ifndef MSWIN # include -# include /* for cygwin_conv_to_posix_path() and/or - * for cygwin_conv_path() */ +# include // for cygwin_conv_to_posix_path() and/or + // for cygwin_conv_path() # ifdef FEAT_CYGWIN_WIN32_CLIPBOARD # define WIN32_LEAN_AND_MEAN # include @@ -63,11 +63,10 @@ static int selinux_enabled = -1; #ifdef FEAT_MOUSE_GPM # include -/* 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 */ +// 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 # define KG_SHIFT 0 # define KG_CTRL 2 # define KG_ALT 3 @@ -96,7 +95,7 @@ static RETSIGTYPE sig_sysmouse SIGPROTOA * 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 SIGPROTOA # 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, i #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 SIGPROTOA && 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, ch # 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, XErrorEven 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 */ - - return 0; /* NOTREACHED */ + // 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 } /* @@ -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 */ -# endif - set_x11_title(title); /* x11 */ + if (!gui.in_use) // don't do this if GTK+ is running +# endif + 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 */ -# endif - set_x11_icon(icon); /* x11 */ + if (!gui.in_use) // don't do this if GTK+ is running +# endif + 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 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 */ -} -#endif /* HAVE_SYS_UTSNAME_H */ + s[len - 1] = NUL; // make sure it's terminated +} +#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 * 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 * 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 * 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 * } 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_ac #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, 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, 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 and are now the same, redefine . */ + // If and are now the same, redefine . 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 */ - } -} - -#endif /* VMS */ + screen_start(); // don't know where cursor is now + } +} + +#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_sl *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 #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 */ - -# 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 */ +#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 /* * 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) */ - - /* Don't need this now that we've duplicated it */ + 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 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 */ - - /* set up stdin/stdout/stderr for the child */ + close(pty_master_fd); // close master side of pty + + // 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 and K_DEL by */ + // replace K_BS by and K_DEL by 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, j 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, j 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, j } } 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, j } 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, j 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, j #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, j 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, j 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, j 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, j 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, j 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. */ -# endif - _exit(EXEC_FAILED); /* exec failed, return failure code */ - } - - /* parent */ + // calling free_all_mem() here causes problems. Ignore valgrind + // reporting possibly leaked memory. +# endif + _exit(EXEC_FAILED); // exec failed, return failure code + } + + // 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, j 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, jobop 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 *inter #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 * #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 * 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 * #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 * 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 * # 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 * 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 * 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 * 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 into . Caution, buffer may contain NUL. */ + // Translate into . 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 * { 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 * 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 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, SmPoin { 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, diff --git a/src/os_vms.c b/src/os_vms.c --- a/src/os_vms.c +++ b/src/os_vms.c @@ -11,19 +11,19 @@ #include "vim.h" -/* define _generic_64 for use in time functions */ +// define _generic_64 for use in time functions #if !defined(VAX) && !defined(PROTO) # include #else -/* based on Alpha's gen64def.h; the file is absent on VAX */ +// based on Alpha's gen64def.h; the file is absent on VAX typedef struct _generic_64 { # pragma __nomember_alignment - __union { /* You can treat me as... */ - /* long long is not available on VAXen */ - /* unsigned __int64 gen64$q_quadword; ...a single 64-bit value, or */ + __union { // You can treat me as... + // long long is not available on VAXen + // unsigned __int64 gen64$q_quadword; ...a single 64-bit value, or - unsigned int gen64$l_longword [2]; /* ...two 32-bit values, or */ - unsigned short int gen64$w_word [4]; /* ...four 16-bit values */ + unsigned int gen64$l_longword [2]; // ...two 32-bit values, or + unsigned short int gen64$w_word [4]; // ...four 16-bit values } gen64$r_quad_overlay; } GENERIC_64; #endif @@ -67,13 +67,13 @@ typedef struct } ITMLST2; static TT_MODE orgmode; -static short iochan; /* TTY I/O channel */ -static short iosb[4]; /* IO status block */ +static short iochan; // TTY I/O channel +static short iosb[4]; // IO status block static int vms_match_num = 0; static int vms_match_free = 0; static char_u **vms_fmatch = NULL; -static char *Fspec_Rms; /* rms file spec, passed implicitly between routines */ +static char *Fspec_Rms; // rms file spec, passed implicitly between routines @@ -139,7 +139,7 @@ mch_settmode(int tmode) set_tty(int row, int col) { int status; - TT_MODE newmode; /* New TTY mode bits */ + TT_MODE newmode; // New TTY mode bits static short first_time = TRUE; if (first_time) @@ -165,7 +165,7 @@ set_tty(int row, int col) get_tty(void) { - static $DESCRIPTOR(odsc,"SYS$OUTPUT"); /* output descriptor */ + static $DESCRIPTOR(odsc,"SYS$OUTPUT"); // output descriptor int status; TT_MODE tt_mode; @@ -195,7 +195,7 @@ mch_get_shellsize(void) { TT_MODE tmode; - tmode = get_tty(); /* get size from VMS */ + tmode = get_tty(); // get size from VMS Columns = tmode.width; Rows = tmode.x.y.length; return OK; @@ -262,7 +262,7 @@ mch_setenv(char *var, char *value, int x { int res, dum; long attrib = 0L; - char acmode = PSL$C_SUPER; /* needs SYSNAM privilege */ + char acmode = PSL$C_SUPER; // needs SYSNAM privilege DESC tabnam, lognam; ITMLST1 itmlst; @@ -288,9 +288,9 @@ vms_sys(char *cmd, char *out, char *inp) if (inp) vul_desc(&idsc, inp); - lib$spawn(cmd ? &cdsc : NULL, /* command string */ - inp ? &idsc : NULL, /* input file */ - out ? &odsc : NULL, /* output file */ + lib$spawn(cmd ? &cdsc : NULL, // command string + inp ? &idsc : NULL, // input file + out ? &odsc : NULL, // output file 0, 0, 0, &status, 0, 0, 0, 0, 0, 0); return status; } @@ -314,7 +314,7 @@ vms_tolower( char *name ) vms_sys_status(int status) { if (status != SS$_NORMAL && (status & STS$M_SUCCESS) == 0) - return status; /* Command failed. */ + return status; // Command failed. return 0; } @@ -329,35 +329,35 @@ vms_read(char *inbuf, size_t nbytes) { int status, function, len; TT_MODE tt_mode; - ITEM itmlst[2]; /* terminates on everything */ + ITEM itmlst[2]; // terminates on everything static long trm_mask[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; - /* whatever happened earlier we need an iochan here */ + // whatever happened earlier we need an iochan here if (!iochan) tt_mode = get_tty(); - /* important: clean the inbuf */ + // important: clean the inbuf memset(inbuf, 0, nbytes); - /* set up the itemlist for the first read */ + // set up the itemlist for the first read vul_item(&itmlst[0], 0, TRM$_MODIFIERS, (char *)( TRM$M_TM_NOECHO | TRM$M_TM_NOEDIT | TRM$M_TM_NOFILTR | TRM$M_TM_TRMNOECHO | TRM$M_TM_NORECALL) , 0); vul_item(&itmlst[1], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask, 0); - /* wait forever for a char */ + // wait forever for a char function = (IO$_READLBLK | IO$M_EXTEND); status = sys$qiow(0, iochan, function, &iosb, 0, 0, inbuf, nbytes-1, 0, 0, &itmlst, sizeof(itmlst)); - len = strlen(inbuf); /* how many chars we got? */ + len = strlen(inbuf); // how many chars we got? - /* read immediately the rest in the IO queue */ + // read immediately the rest in the IO queue function = (IO$_READLBLK | IO$M_TIMED | IO$M_ESCAPE | IO$M_NOECHO | IO$M_NOFILTR); status = sys$qiow(0, iochan, function, &iosb, 0, 0, inbuf+len, nbytes-1-len, 0, 0, 0, 0); - len = strlen(inbuf); /* return the total length */ + len = strlen(inbuf); // return the total length return len; } @@ -375,12 +375,12 @@ vms_wproc(char *name, int val) int i; static int vms_match_alloced = 0; - if (val == DECC$K_FOREIGN ) /* foreign non VMS files are not counting */ + if (val == DECC$K_FOREIGN ) // foreign non VMS files are not counting return 1; - /* accept all DECC$K_FILE and DECC$K_DIRECTORY */ + // accept all DECC$K_FILE and DECC$K_DIRECTORY if (vms_match_num == 0) { - /* first time through, setup some things */ + // first time through, setup some things if (NULL == vms_fmatch) { vms_fmatch = ALLOC_MULT(char_u *, EXPL_ALLOC_INC); if (!vms_fmatch) @@ -389,16 +389,16 @@ vms_wproc(char *name, int val) vms_match_free = EXPL_ALLOC_INC; } else { - /* re-use existing space */ + // re-use existing space vms_match_free = vms_match_alloced; } } - /* make matches look uniform */ + // make matches look uniform vms_remove_version(name); name=vms_tolower(name); - /* if name already exists, don't add it */ + // if name already exists, don't add it for (i = 0; i= 0) /* add existing file */ + if (mch_getperm(vms_fmatch[i]) >= 0) // add existing file addfile(gap, vms_fmatch[i], flags); } return cnt; @@ -551,10 +551,9 @@ vms_unix_mixed_filespec(char *in, char * int len; char *out_str=out; - /* copy vms filename portion up to last colon - * (node and/or disk) - */ - lastcolon = strrchr(in, ':'); /* find last colon */ + // copy vms filename portion up to last colon + // (node and/or disk) + lastcolon = strrchr(in, ':'); // find last colon if (lastcolon != NULL) { len = lastcolon - in + 1; strncpy(out, in, len); @@ -562,49 +561,49 @@ vms_unix_mixed_filespec(char *in, char * in += len; } - end_of_dir = NULL; /* default: no directory */ + end_of_dir = NULL; // default: no directory - /* start of directory portion */ + // start of directory portion ch = *in; - if ((ch == '[') || (ch == '/') || (ch == '<')) { /* start of directory(s) ? */ + if ((ch == '[') || (ch == '/') || (ch == '<')) { // start of directory(s) ? ch = '['; SKIP_FOLLOWING_SLASHES(in); - } else if (EQN(in, "../", 3)) { /* Unix parent directory? */ + } else if (EQN(in, "../", 3)) { // Unix parent directory? *out++ = '['; *out++ = '-'; end_of_dir = out; ch = '.'; in += 2; SKIP_FOLLOWING_SLASHES(in); - } else { /* not a special character */ - while (EQN(in, "./", 2)) { /* Ignore Unix "current dir" */ + } else { // not a special character + while (EQN(in, "./", 2)) { // Ignore Unix "current dir" in += 2; SKIP_FOLLOWING_SLASHES(in); } - if (strchr(in, '/') == NULL) { /* any more Unix directories ? */ - strcpy(out, in); /* No - get rest of the spec */ + if (strchr(in, '/') == NULL) { // any more Unix directories ? + strcpy(out, in); // No - get rest of the spec return; } else { - *out++ = '['; /* Yes, denote a Vms subdirectory */ + *out++ = '['; // Yes, denote a Vms subdirectory ch = '.'; --in; } } - /* if we get here, there is a directory part of the filename */ + // if we get here, there is a directory part of the filename - /* initialize output file spec */ + // initialize output file spec *out++ = ch; ++in; while (*in != '\0') { ch = *in; - if ((ch == ']') || (ch == '/') || (ch == '>') ) { /* end of (sub)directory ? */ + if ((ch == ']') || (ch == '/') || (ch == '>') ) { // end of (sub)directory ? end_of_dir = out; ch = '.'; SKIP_FOLLOWING_SLASHES(in); } - else if (EQN(in, "../", 3)) { /* Unix parent directory? */ + else if (EQN(in, "../", 3)) { // Unix parent directory? *out++ = '-'; end_of_dir = out; ch = '.'; @@ -612,7 +611,7 @@ vms_unix_mixed_filespec(char *in, char * SKIP_FOLLOWING_SLASHES(in); } else { - while (EQN(in, "./", 2)) { /* Ignore Unix "current dir" */ + while (EQN(in, "./", 2)) { // Ignore Unix "current dir" end_of_dir = out; in += 2; SKIP_FOLLOWING_SLASHES(in); @@ -620,14 +619,14 @@ vms_unix_mixed_filespec(char *in, char * } } - /* Place next character into output file spec */ + // Place next character into output file spec *out++ = ch; ++in; } - *out = '\0'; /* Terminate output file spec */ + *out = '\0'; // Terminate output file spec - if (end_of_dir != NULL) /* Terminate directory portion */ + if (end_of_dir != NULL) // Terminate directory portion *end_of_dir = ']'; } @@ -651,7 +650,7 @@ vms_fixfilename(void *instring) static size_t buflen = 0; size_t len; - /* get a big-enough buffer */ + // get a big-enough buffer len = strlen(instring) + 1; if (len > buflen) { @@ -665,22 +664,22 @@ vms_fixfilename(void *instring) strcpy(tmpbuf, instring); #endif - Fspec_Rms = buf; /* for decc$to_vms */ + Fspec_Rms = buf; // for decc$to_vms if (strchr(instring,'/') == NULL) - /* It is already a VMS file spec */ + // It is already a VMS file spec strcpy(buf, instring); - else if (strchr(instring,'"') == NULL) /* password in the path? */ + else if (strchr(instring,'"') == NULL) // password in the path? { - /* Seems it is a regular file, let guess that it is pure Unix fspec */ + // Seems it is a regular file, let guess that it is pure Unix fspec if (decc$to_vms(instring, vms_fspec_proc, 0, 0) <= 0) - /* No... it must be mixed */ + // No... it must be mixed vms_unix_mixed_filespec(instring, buf); } else - /* we have a password in the path */ - /* decc$ functions can not handle */ - /* this is our only hope to resolv */ + // we have a password in the path + // decc$ functions can not handle + // this is our only hope to resolv vms_unix_mixed_filespec(instring, buf); return buf; @@ -697,7 +696,7 @@ vms_remove_version(void * fname) char_u *cp; char_u *fp; - if ((cp = vim_strchr( fname, ';')) != NULL) /* remove version */ + if ((cp = vim_strchr( fname, ';')) != NULL) // remove version *cp = '\0'; else if ((cp = vim_strrchr( fname, '.')) != NULL ) { @@ -726,7 +725,7 @@ struct typeahead_st { */ int RealWaitForChar( - int fd UNUSED, /* always read from iochan */ + int fd UNUSED, // always read from iochan long msec, int *check_for_gpm UNUSED, int *interrupted) @@ -738,71 +737,71 @@ RealWaitForChar( unsigned int convert_operation = LIB$K_DELTA_SECONDS_F; float sec =(float) msec/1000; - /* make sure the iochan is set */ + // make sure the iochan is set if (!iochan) get_tty(); if (sec > 0) { - /* time-out specified; convert it to absolute time */ - /* sec>0 requirement of lib$cvtf_to_internal_time()*/ + // time-out specified; convert it to absolute time + // sec>0 requirement of lib$cvtf_to_internal_time() - /* get current time (number of 100ns ticks since the VMS Epoch) */ + // get current time (number of 100ns ticks since the VMS Epoch) status = sys$gettim(&time_curr); if (status != SS$_NORMAL) - return 0; /* error */ - /* construct the delta time */ + return 0; // error + // construct the delta time #if __G_FLOAT==0 # ifndef VAX - /* IEEE is default on IA64, but can be used on Alpha too - but not on VAX */ + // IEEE is default on IA64, but can be used on Alpha too - but not on VAX status = lib$cvts_to_internal_time( &convert_operation, &sec, &time_diff); # endif -#else /* default on Alpha and VAX */ +#else // default on Alpha and VAX status = lib$cvtf_to_internal_time( &convert_operation, &sec, &time_diff); #endif if (status != LIB$_NORMAL) - return 0; /* error */ - /* add them up */ + return 0; // error + // add them up status = lib$add_times( &time_curr, &time_diff, &time_out); if (status != LIB$_NORMAL) - return 0; /* error */ + return 0; // error } while (TRUE) { - /* select() */ + // select() status = sys$qiow(0, iochan, IO$_SENSEMODE | IO$M_TYPEAHDCNT, iosb, 0, 0, &typeahead, 8, 0, 0, 0, 0); if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) - return 0; /* error */ + return 0; // error if (typeahead.numchars) - return 1; /* ready to read */ + return 1; // ready to read - /* there's nothing to read; what now? */ + // there's nothing to read; what now? if (msec == 0) { - /* immediate time-out; return impatiently */ + // immediate time-out; return impatiently return 0; } else if (msec < 0) { - /* no time-out; wait on indefinitely */ - return 1; /* fakeout to force a wait in vms_read() */ + // no time-out; wait on indefinitely + return 1; // fakeout to force a wait in vms_read() } else { - /* time-out needs to be checked */ + // time-out needs to be checked status = sys$gettim(&time_curr); if (status != SS$_NORMAL) - return 0; /* error */ + return 0; // error status = lib$sub_times( &time_out, &time_curr, &time_diff); if (status != LIB$_NORMAL) - return 0; /* error, incl. time_diff < 0 (i.e. time-out) */ + return 0; // error, incl. time_diff < 0 (i.e. time-out) - /* otherwise wait some more */ + // otherwise wait some more } } } diff --git a/src/os_win32.c b/src/os_win32.c --- a/src/os_win32.c +++ b/src/os_win32.c @@ -30,7 +30,7 @@ #include #include -/* cproto fails on missing include files */ +// cproto fails on missing include files #ifndef PROTO # include #endif @@ -82,8 +82,8 @@ # endif #endif -/* Record all output and all keyboard & mouse input */ -/* #define MCH_WRITE_DUMP */ +// Record all output and all keyboard & mouse input +// #define MCH_WRITE_DUMP #ifdef MCH_WRITE_DUMP FILE* fdDump = NULL; @@ -143,25 +143,25 @@ typedef int PSNSECINFOW; typedef int STARTUPINFO; typedef int PROCESS_INFORMATION; typedef int LPSECURITY_ATTRIBUTES; -# define __stdcall /* empty */ +# define __stdcall // empty #endif #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) -/* Win32 Console handles for input and output */ +// Win32 Console handles for input and output static HANDLE g_hConIn = INVALID_HANDLE_VALUE; static HANDLE g_hConOut = INVALID_HANDLE_VALUE; -/* Win32 Screen buffer,coordinate,console I/O information */ +// Win32 Screen buffer,coordinate,console I/O information static SMALL_RECT g_srScrollRegion; -static COORD g_coord; /* 0-based, but external coords are 1-based */ - -/* The attribute of the screen when the editor was started */ -static WORD g_attrDefault = 7; /* lightgray text on black background */ +static COORD g_coord; // 0-based, but external coords are 1-based + +// The attribute of the screen when the editor was started +static WORD g_attrDefault = 7; // lightgray text on black background static WORD g_attrCurrent; -static int g_fCBrkPressed = FALSE; /* set by ctrl-break interrupt */ -static int g_fCtrlCPressed = FALSE; /* set when ctrl-C or ctrl-break detected */ -static int g_fForceExit = FALSE; /* set when forcefully exiting */ +static int g_fCBrkPressed = FALSE; // set by ctrl-break interrupt +static int g_fCtrlCPressed = FALSE; // set when ctrl-C or ctrl-break detected +static int g_fForceExit = FALSE; // set when forcefully exiting static void scroll(unsigned cLines); static void set_scroll_region(unsigned left, unsigned top, @@ -219,13 +219,13 @@ static void set_console_color_rgb(void); static void reset_console_color_rgb(void); #endif -/* This flag is newly created from Windows 10 */ +// This flag is newly created from Windows 10 #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING # define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 #endif #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) -static int suppress_winsize = 1; /* don't fiddle with console */ +static int suppress_winsize = 1; // don't fiddle with console #endif static char_u *exe_path = NULL; @@ -233,7 +233,7 @@ static char_u *exe_path = NULL; static BOOL win8_or_later = FALSE; #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) -/* Dynamic loading for portability */ +// Dynamic loading for portability typedef struct _DYN_CONSOLE_SCREEN_BUFFER_INFOEX { ULONG cbSize; @@ -339,7 +339,7 @@ read_console_input( && s_irCache[head + 1].EventType == WINDOW_BUFFER_SIZE_EVENT) { - /* Remove duplicate event to avoid flicker. */ + // Remove duplicate event to avoid flicker. for (i = head; i < tail; ++i) s_irCache[i] = s_irCache[i + 1]; --tail; @@ -403,15 +403,15 @@ wait_for_single_object( static void get_exe_name(void) { - /* Maximum length of $PATH is more than MAXPATHL. 8191 is often mentioned - * as the maximum length that works (plus a NUL byte). */ + // Maximum length of $PATH is more than MAXPATHL. 8191 is often mentioned + // as the maximum length that works (plus a NUL byte). #define MAX_ENV_PATH_LEN 8192 char temp[MAX_ENV_PATH_LEN]; char_u *p; if (exe_name == NULL) { - /* store the name of the executable, may be used for $VIM */ + // store the name of the executable, may be used for $VIM GetModuleFileName(NULL, temp, MAX_ENV_PATH_LEN - 1); if (*temp != NUL) exe_name = FullName_save((char_u *)temp, FALSE); @@ -423,9 +423,9 @@ get_exe_name(void) (int)(gettail_sep(exe_name) - exe_name)); if (exe_path != NULL) { - /* Append our starting directory to $PATH, so that when doing - * "!xxd" it's found in our starting directory. Needed because - * SearchPath() also looks there. */ + // Append our starting directory to $PATH, so that when doing + // "!xxd" it's found in our starting directory. Needed because + // SearchPath() also looks there. p = mch_getenv("PATH"); if (p == NULL || STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN) @@ -471,8 +471,8 @@ vimLoadLib(char *name) { HINSTANCE dll = NULL; - /* NOTE: Do not use mch_dirname() and mch_chdir() here, they may call - * vimLoadLib() recursively, which causes a stack overflow. */ + // NOTE: Do not use mch_dirname() and mch_chdir() here, they may call + // vimLoadLib() recursively, which causes a stack overflow. if (exe_path == NULL) get_exe_name(); if (exe_path != NULL) @@ -481,9 +481,9 @@ vimLoadLib(char *name) if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0) { - /* Change directory to where the executable is, both to make - * sure we find a .dll there and to avoid looking for a .dll - * in the current directory. */ + // Change directory to where the executable is, both to make + // sure we find a .dll there and to avoid looking for a .dll + // in the current directory. SetCurrentDirectory((LPCSTR)exe_path); dll = LoadLibrary(name); SetCurrentDirectoryW(old_dirw); @@ -528,8 +528,8 @@ get_imported_func_info(HINSTANCE hInst, PIMAGE_DOS_HEADER pDOS = (PIMAGE_DOS_HEADER)hInst; PIMAGE_NT_HEADERS pPE; PIMAGE_IMPORT_DESCRIPTOR pImpDesc; - PIMAGE_THUNK_DATA pIAT; /* Import Address Table */ - PIMAGE_THUNK_DATA pINT; /* Import Name Table */ + PIMAGE_THUNK_DATA pIAT; // Import Address Table + PIMAGE_THUNK_DATA pINT; // Import Name Table PIMAGE_IMPORT_BY_NAME pImpName; if (pDOS->e_magic != IMAGE_DOS_SIGNATURE) @@ -599,7 +599,7 @@ get_dll_import_func(HINSTANCE hInst, con # define GETTEXT_DLL_ALT1 "libintl-8.dll" # define GETTEXT_DLL_ALT2 "intl.dll" # endif -/* Dummy functions */ +// Dummy functions static char *null_libintl_gettext(const char *); static char *null_libintl_ngettext(const char *, const char *, unsigned long n); static char *null_libintl_textdomain(const char *); @@ -676,14 +676,14 @@ dyn_libintl_init(void) } } - /* The bind_textdomain_codeset() function is optional. */ + // The bind_textdomain_codeset() function is optional. dyn_libintl_bind_textdomain_codeset = (void *)GetProcAddress(hLibintlDLL, "bind_textdomain_codeset"); if (dyn_libintl_bind_textdomain_codeset == NULL) dyn_libintl_bind_textdomain_codeset = null_libintl_bind_textdomain_codeset; - /* _wputenv() function for the libintl.dll is optional. */ + // _wputenv() function for the libintl.dll is optional. hmsvcrt = find_imported_module_by_funcname(hLibintlDLL, "getenv"); if (hmsvcrt != NULL) dyn_libintl_wputenv = (void *)GetProcAddress(hmsvcrt, "_wputenv"); @@ -750,9 +750,9 @@ null_libintl_wputenv(const wchar_t *envs return 0; } -#endif /* DYNAMIC_GETTEXT */ - -/* This symbol is not defined in older versions of the SDK or Visual C++ */ +#endif // DYNAMIC_GETTEXT + +// This symbol is not defined in older versions of the SDK or Visual C++ #ifndef VER_PLATFORM_WIN32_WINDOWS # define VER_PLATFORM_WIN32_WINDOWS 1 @@ -828,7 +828,7 @@ PlatformId(void) win8_or_later = TRUE; #ifdef HAVE_ACL - /* Enable privilege for getting or setting SACLs. */ + // Enable privilege for getting or setting SACLs. win32_enable_privilege(SE_SECURITY_NAME, TRUE); #endif done = TRUE; @@ -843,13 +843,12 @@ PlatformId(void) # define ALT_GR (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED) -/* When uChar.AsciiChar is 0, then we need to look at wVirtualKeyCode. - * We map function keys to their ANSI terminal equivalents, as produced - * by ANSI.SYS, for compatibility with the MS-DOS version of Vim. Any - * ANSI key with a value >= '\300' is nonstandard, but provided anyway - * so that the user can have access to all SHIFT-, CTRL-, and ALT- - * combinations of function/arrow/etc keys. - */ +// When uChar.AsciiChar is 0, then we need to look at wVirtualKeyCode. +// We map function keys to their ANSI terminal equivalents, as produced +// by ANSI.SYS, for compatibility with the MS-DOS version of Vim. Any +// ANSI key with a value >= '\300' is nonstandard, but provided anyway +// so that the user can have access to all SHIFT-, CTRL-, and ALT- +// combinations of function/arrow/etc keys. static const struct { @@ -927,7 +926,9 @@ static const struct # define UChar uChar.UnicodeChar # endif -/* The return code indicates key code size. */ +/* + * The return code indicates key code size. + */ static int win32_kbd_patch_key( KEY_EVENT_RECORD *pker) @@ -950,7 +951,7 @@ win32_kbd_patch_key( vim_memset(abKeystate, 0, sizeof (abKeystate)); - /* Clear any pending dead keys */ + // Clear any pending dead keys ToUnicode(VK_SPACE, MapVirtualKey(VK_SPACE, 0), abKeystate, awAnsiCode, 2, 0); if (uMods & SHIFT_PRESSED) @@ -992,39 +993,39 @@ decode_key_event( *pch = *pch2 = NUL; g_fJustGotFocus = FALSE; - /* ignore key up events */ + // ignore key up events if (!pker->bKeyDown) return FALSE; - /* ignore some keystrokes */ + // ignore some keystrokes switch (pker->wVirtualKeyCode) { - /* modifiers */ + // modifiers case VK_SHIFT: case VK_CONTROL: - case VK_MENU: /* Alt key */ + case VK_MENU: // Alt key return FALSE; default: break; } - /* special cases */ + // special cases if ((nModifs & CTRL) != 0 && (nModifs & ~CTRL) == 0 && pker->UChar == NUL) { - /* Ctrl-6 is Ctrl-^ */ + // Ctrl-6 is Ctrl-^ if (pker->wVirtualKeyCode == '6') { *pch = Ctrl_HAT; return TRUE; } - /* Ctrl-2 is Ctrl-@ */ + // Ctrl-2 is Ctrl-@ else if (pker->wVirtualKeyCode == '2') { *pch = NUL; return TRUE; } - /* Ctrl-- is Ctrl-_ */ + // Ctrl-- is Ctrl-_ else if (pker->wVirtualKeyCode == 0xBD) { *pch = Ctrl__; @@ -1032,7 +1033,7 @@ decode_key_event( } } - /* Shift-TAB */ + // Shift-TAB if (pker->wVirtualKeyCode == VK_TAB && (nModifs & SHIFT_PRESSED)) { *pch = K_NUL; @@ -1076,19 +1077,19 @@ decode_key_event( if (pmodifiers != NULL) { - /* Pass on the ALT key as a modifier, but only when not combined - * with CTRL (which is ALTGR). */ + // Pass on the ALT key as a modifier, but only when not combined + // with CTRL (which is ALTGR). if ((nModifs & ALT) != 0 && (nModifs & CTRL) == 0) *pmodifiers |= MOD_MASK_ALT; - /* Pass on SHIFT only for special keys, because we don't know when - * it's already included with the character. */ + // Pass on SHIFT only for special keys, because we don't know when + // it's already included with the character. if ((nModifs & SHIFT) != 0 && *pch <= 0x20) *pmodifiers |= MOD_MASK_SHIFT; - /* Pass on CTRL only for non-special keys, because we don't know - * when it's already included with the character. And not when - * combined with ALT (which is ALTGR). */ + // Pass on CTRL only for non-special keys, because we don't know + // when it's already included with the character. And not when + // combined with ALT (which is ALTGR). if ((nModifs & CTRL) != 0 && (nModifs & ALT) == 0 && *pch >= 0x20 && *pch < 0x80) *pmodifiers |= MOD_MASK_CTRL; @@ -1098,7 +1099,7 @@ decode_key_event( return (*pch != NUL); } -#endif /* FEAT_GUI_MSWIN */ +#endif // FEAT_GUI_MSWIN /* @@ -1110,11 +1111,11 @@ mch_setmouse(int on UNUSED) { } #else -static int g_fMouseAvail = FALSE; /* mouse present */ -static int g_fMouseActive = FALSE; /* mouse enabled */ -static int g_nMouseClick = -1; /* mouse status */ -static int g_xMouse; /* mouse x coordinate */ -static int g_yMouse; /* mouse y coordinate */ +static int g_fMouseAvail = FALSE; // mouse present +static int g_fMouseActive = FALSE; // mouse enabled +static int g_nMouseClick = -1; // mouse status +static int g_xMouse; // mouse x coordinate +static int g_yMouse; // mouse y coordinate /* * Enable or disable mouse input @@ -1198,7 +1199,7 @@ decode_mouse_event( static DWORD s_dwLastClickTime = 0; static BOOL s_fNextIsMiddle = FALSE; - static DWORD cButtons = 0; /* number of buttons supported */ + static DWORD cButtons = 0; // number of buttons supported const DWORD LEFT = FROM_LEFT_1ST_BUTTON_PRESSED; const DWORD MIDDLE = FROM_LEFT_2ND_BUTTON_PRESSED; @@ -1216,14 +1217,14 @@ decode_mouse_event( return FALSE; } - /* get a spurious MOUSE_EVENT immediately after receiving focus; ignore */ + // get a spurious MOUSE_EVENT immediately after receiving focus; ignore if (g_fJustGotFocus) { g_fJustGotFocus = FALSE; return FALSE; } - /* unprocessed mouse click? */ + // unprocessed mouse click? if (g_nMouseClick != -1) return TRUE; @@ -1233,22 +1234,22 @@ decode_mouse_event( if (pmer->dwEventFlags == MOUSE_MOVED) { - /* Ignore MOUSE_MOVED events if (x, y) hasn't changed. (We get these - * events even when the mouse moves only within a char cell.) */ + // Ignore MOUSE_MOVED events if (x, y) hasn't changed. (We get these + // events even when the mouse moves only within a char cell.) if (s_xOldMouse == g_xMouse && s_yOldMouse == g_yMouse) return FALSE; } - /* If no buttons are pressed... */ + // If no buttons are pressed... if ((pmer->dwButtonState & ((1 << cButtons) - 1)) == 0) { nButton = MOUSE_RELEASE; - /* If the last thing returned was MOUSE_RELEASE, ignore this */ + // If the last thing returned was MOUSE_RELEASE, ignore this if (s_fReleased) { # ifdef FEAT_BEVAL_TERM - /* do return mouse move events when we want them */ + // do return mouse move events when we want them if (p_bevalterm) nButton = MOUSE_DRAG; else @@ -1258,22 +1259,22 @@ decode_mouse_event( s_fReleased = TRUE; } - else /* one or more buttons pressed */ - { - /* on a 2-button mouse, hold down left and right buttons - * simultaneously to get MIDDLE. */ + else // one or more buttons pressed + { + // on a 2-button mouse, hold down left and right buttons + // simultaneously to get MIDDLE. if (cButtons == 2 && s_nOldButton != MOUSE_DRAG) { DWORD dwLR = (pmer->dwButtonState & LEFT_RIGHT); - /* if either left or right button only is pressed, see if the - * next mouse event has both of them pressed */ + // if either left or right button only is pressed, see if the + // next mouse event has both of them pressed if (dwLR == LEFT || dwLR == RIGHT) { for (;;) { - /* wait a short time for next input event */ + // wait a short time for next input event if (WaitForSingleObject(g_hConIn, p_mouset / 3) != WAIT_OBJECT_0) break; @@ -1299,10 +1300,10 @@ decode_mouse_event( else if (s_xOldMouse == pmer2->dwMousePosition.X && s_yOldMouse == pmer2->dwMousePosition.Y) { - /* throw away spurious mouse move */ + // throw away spurious mouse move read_console_input(g_hConIn, &ir, 1, &cRecords); - /* are there any more mouse events in queue? */ + // are there any more mouse events in queue? peek_console_input(g_hConIn, &ir, 1, &cRecords); if (cRecords==0 || ir.EventType != MOUSE_EVENT) @@ -1349,7 +1350,7 @@ decode_mouse_event( if (pmer->dwEventFlags == 0 || pmer->dwEventFlags == DOUBLE_CLICK) { - /* button pressed or released, without mouse moving */ + // button pressed or released, without mouse moving if (nButton != -1 && nButton != MOUSE_RELEASE) { DWORD dwCurrentTime = GetTickCount(); @@ -1399,7 +1400,7 @@ decode_mouse_event( if (nButton != MOUSE_DRAG && nButton != MOUSE_RELEASE) SET_NUM_MOUSE_CLICKS(g_nMouseClick, s_cClicks); - /* only pass on interesting (i.e., different) mouse events */ + // only pass on interesting (i.e., different) mouse events if (s_xOldMouse == g_xMouse && s_yOldMouse == g_yMouse && s_nOldMouseClick == g_nMouseClick) @@ -1456,7 +1457,7 @@ mch_update_cursor(void) idx = get_shape_idx(FALSE); if (shape_table[idx].shape == SHAPE_BLOCK) - thickness = 99; /* 100 doesn't work on W95 */ + thickness = 99; // 100 doesn't work on W95 else thickness = shape_table[idx].percentage; mch_set_cursor_shape(thickness); @@ -1494,10 +1495,10 @@ WaitForChar(long msec, int ignore_input) # endif if (msec > 0) - /* Wait until the specified time has elapsed. */ + // Wait until the specified time has elapsed. dwEndTime = GetTickCount() + msec; else if (msec < 0) - /* Wait forever. */ + // Wait forever. dwEndTime = INFINITE; // We need to loop until the end of the time period, because @@ -1527,8 +1528,8 @@ WaitForChar(long msec, int ignore_input) if (msec > 0) { - /* If the specified wait time has passed, return. Beware that - * GetTickCount() may wrap around (overflow). */ + // If the specified wait time has passed, return. Beware that + // GetTickCount() may wrap around (overflow). dwNow = GetTickCount(); if ((int)(dwNow - dwEndTime) >= 0) break; @@ -1538,26 +1539,26 @@ WaitForChar(long msec, int ignore_input) DWORD dwWaitTime = dwEndTime - dwNow; # ifdef FEAT_JOB_CHANNEL - /* Check channel while waiting for input. */ + // Check channel while waiting for input. if (dwWaitTime > 100) { dwWaitTime = 100; - /* If there is readahead then parse_queued_messages() timed out - * and we should call it again soon. */ + // If there is readahead then parse_queued_messages() timed out + // and we should call it again soon. if (channel_any_readahead()) dwWaitTime = 10; } # endif # ifdef FEAT_BEVAL_GUI if (p_beval && dwWaitTime > 100) - /* The 'balloonexpr' may indirectly invoke a callback while - * waiting for a character, need to check often. */ + // The 'balloonexpr' may indirectly invoke a callback while + // waiting for a character, need to check often. dwWaitTime = 100; # endif # ifdef FEAT_MZSCHEME if (mzthreads_allowed() && p_mzq > 0 && (msec < 0 || (long)dwWaitTime > p_mzq)) - dwWaitTime = p_mzq; /* don't wait longer than 'mzquantum' */ + dwWaitTime = p_mzq; // don't wait longer than 'mzquantum' # endif # ifdef FEAT_TIMERS // When waiting very briefly don't trigger timers. @@ -1603,8 +1604,8 @@ WaitForChar(long msec, int ignore_input) { if (csbi.dwCursorPosition.Y != msg_row) { - /* The screen is now messed up, must redraw the - * command line and later all the windows. */ + // The screen is now messed up, must redraw the + // command line and later all the windows. redraw_all_later(CLEAR); cmdline_row -= (msg_row - csbi.dwCursorPosition.Y); redrawcmd(); @@ -1618,8 +1619,8 @@ WaitForChar(long msec, int ignore_input) if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown) { # ifdef FEAT_MBYTE_IME - /* Windows IME sends two '\n's with only one 'ENTER'. First: - * wVirtualKeyCode == 13. second: wVirtualKeyCode == 0 */ + // Windows IME sends two '\n's with only one 'ENTER'. First: + // wVirtualKeyCode == 13. second: wVirtualKeyCode == 0 if (ir.Event.KeyEvent.UChar == 0 && ir.Event.KeyEvent.wVirtualKeyCode == 13) { @@ -1660,7 +1661,7 @@ WaitForChar(long msec, int ignore_input) } # ifdef FEAT_CLIENTSERVER - /* Something might have been received while we were waiting. */ + // Something might have been received while we were waiting. if (input_available()) return TRUE; # endif @@ -1754,7 +1755,7 @@ tgetch(int *pmodifiers, WCHAR *pch2) } } } -#endif /* !FEAT_GUI_MSWIN */ +#endif // !FEAT_GUI_MSWIN /* @@ -1777,7 +1778,7 @@ mch_inchar( int len; int c; # define TYPEAHEADLEN 20 - static char_u typeahead[TYPEAHEADLEN]; /* previously typed bytes. */ + static char_u typeahead[TYPEAHEADLEN]; // previously typed bytes. static int typeaheadlen = 0; # ifdef VIMDLL @@ -1785,18 +1786,18 @@ mch_inchar( return 0; # endif - /* First use any typeahead that was kept because "buf" was too small. */ + // First use any typeahead that was kept because "buf" was too small. if (typeaheadlen > 0) goto theend; if (time >= 0) { - if (!WaitForChar(time, FALSE)) /* no character available */ + if (!WaitForChar(time, FALSE)) // no character available return 0; } - else /* time == -1, wait forever */ - { - mch_set_winsize_now(); /* Allow winsize changes from now on */ + else // time == -1, wait forever + { + mch_set_winsize_now(); // Allow winsize changes from now on /* * If there is no character available within 2 seconds (default) @@ -1820,7 +1821,7 @@ mch_inchar( * Try to read as many characters as there are, until the buffer is full. */ - /* we will get at least one key. Get more if they are available. */ + // we will get at least one key. Get more if they are available. g_fCBrkPressed = FALSE; # ifdef MCH_WRITE_DUMP @@ -1828,16 +1829,16 @@ mch_inchar( fputc('[', fdDump); # endif - /* Keep looping until there is something in the typeahead buffer and more - * to get and still room in the buffer (up to two bytes for a char and - * three bytes for a modifier). */ + // Keep looping until there is something in the typeahead buffer and more + // to get and still room in the buffer (up to two bytes for a char and + // three bytes for a modifier). while ((typeaheadlen == 0 || WaitForChar(0L, FALSE)) && typeaheadlen + 5 <= TYPEAHEADLEN) { if (typebuf_changed(tb_change_cnt)) { - /* "buf" may be invalid now if a client put something in the - * typeahead buffer and "buf" is in the typeahead buffer. */ + // "buf" may be invalid now if a client put something in the + // typeahead buffer and "buf" is in the typeahead buffer. typeaheadlen = 0; break; } @@ -1864,8 +1865,8 @@ mch_inchar( if (typebuf_changed(tb_change_cnt)) { - /* "buf" may be invalid now if a client put something in the - * typeahead buffer and "buf" is in the typeahead buffer. */ + // "buf" may be invalid now if a client put something in the + // typeahead buffer and "buf" is in the typeahead buffer. typeaheadlen = 0; break; } @@ -1889,7 +1890,7 @@ mch_inchar( WCHAR ch[2]; ch[0] = c; - if (c >= 0xD800 && c <= 0xDBFF) /* High surrogate */ + if (c >= 0xD800 && c <= 0xDBFF) // High surrogate { ch[1] = tgetch(&modifiers, &ch2); n++; @@ -1933,10 +1934,10 @@ mch_inchar( } } - /* Use the ALT key to set the 8th bit of the character - * when it's one byte, the 8th bit isn't set yet and not - * using a double-byte encoding (would become a lead - * byte). */ + // Use the ALT key to set the 8th bit of the character + // when it's one byte, the 8th bit isn't set yet and not + // using a double-byte encoding (would become a lead + // byte). if ((modifiers & MOD_MASK_ALT) && n == 1 && (typeahead[typeaheadlen] & 0x80) == 0 @@ -1950,7 +1951,7 @@ mch_inchar( if (modifiers != 0) { - /* Prepend modifiers to the character. */ + // Prepend modifiers to the character. mch_memmove(typeahead + typeaheadlen + 3, typeahead + typeaheadlen, n); typeahead[typeaheadlen++] = K_SPECIAL; @@ -1977,7 +1978,7 @@ mch_inchar( # endif theend: - /* Move typeahead to "buf", as much as fits. */ + // Move typeahead to "buf", as much as fits. len = 0; while (len < maxlen && typeaheadlen > 0) { @@ -1986,14 +1987,14 @@ theend: } return len; -#else /* FEAT_GUI_MSWIN */ +#else // FEAT_GUI_MSWIN return 0; -#endif /* FEAT_GUI_MSWIN */ +#endif // FEAT_GUI_MSWIN } #ifndef PROTO # ifndef __MINGW32__ -# include /* required for FindExecutable() */ +# include // required for FindExecutable() # endif #endif @@ -2092,31 +2093,31 @@ mch_init_g(void) extern int _fmode; # endif - /* Silently handle invalid parameters to CRT functions */ + // Silently handle invalid parameters to CRT functions SET_INVALID_PARAM_HANDLER; - /* Let critical errors result in a failure, not in a dialog box. Required - * for the timestamp test to work on removed floppies. */ + // Let critical errors result in a failure, not in a dialog box. Required + // for the timestamp test to work on removed floppies. SetErrorMode(SEM_FAILCRITICALERRORS); - _fmode = O_BINARY; /* we do our own CR-LF translation */ - - /* Specify window size. Is there a place to get the default from? */ + _fmode = O_BINARY; // we do our own CR-LF translation + + // Specify window size. Is there a place to get the default from? Rows = 25; Columns = 80; - /* Look for 'vimrun' */ + // Look for 'vimrun' { char_u vimrun_location[_MAX_PATH + 4]; - /* First try in same directory as gvim.exe */ + // First try in same directory as gvim.exe STRCPY(vimrun_location, exe_name); STRCPY(gettail(vimrun_location), "vimrun.exe"); if (mch_getperm(vimrun_location) >= 0) { if (*skiptowhite(vimrun_location) != NUL) { - /* Enclose path with white space in double quotes. */ + // Enclose path with white space in double quotes. mch_memmove(vimrun_location + 1, vimrun_location, STRLEN(vimrun_location) + 1); *vimrun_location = '"'; @@ -2131,9 +2132,9 @@ mch_init_g(void) else if (executable_exists("vimrun.exe", NULL, TRUE)) s_dont_use_vimrun = FALSE; - /* Don't give the warning for a missing vimrun.exe right now, but only - * when vimrun was supposed to be used. Don't bother people that do - * not need vimrun.exe. */ + // Don't give the warning for a missing vimrun.exe right now, but only + // when vimrun was supposed to be used. Don't bother people that do + // not need vimrun.exe. if (s_dont_use_vimrun) need_vimrun_warning = TRUE; } @@ -2153,7 +2154,7 @@ mch_init_g(void) } -#endif /* FEAT_GUI_MSWIN */ +#endif // FEAT_GUI_MSWIN #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) @@ -2343,11 +2344,11 @@ SaveConsoleBuffer( */ ReadRegion.Top = Y; ReadRegion.Bottom = Y + Y_incr - 1; - if (!ReadConsoleOutputW(g_hConOut, /* output handle */ - cb->Buffer, /* our buffer */ - cb->BufferSize, /* dimensions of our buffer */ - BufferCoord, /* offset in our buffer */ - &ReadRegion)) /* region to save */ + if (!ReadConsoleOutputW(g_hConOut, // output handle + cb->Buffer, // our buffer + cb->BufferSize, // dimensions of our buffer + BufferCoord, // offset in our buffer + &ReadRegion)) // region to save { VIM_CLEAR(cb->Buffer); VIM_CLEAR(cb->Regions); @@ -2417,11 +2418,11 @@ RestoreConsoleBuffer( BufferCoord.X = cb->Regions[i].Left; BufferCoord.Y = cb->Regions[i].Top; WriteRegion = cb->Regions[i]; - if (!WriteConsoleOutputW(g_hConOut, /* output handle */ - cb->Buffer, /* our buffer */ - cb->BufferSize, /* dimensions of our buffer */ - BufferCoord, /* offset in our buffer */ - &WriteRegion)) /* region to restore */ + if (!WriteConsoleOutputW(g_hConOut, // output handle + cb->Buffer, // our buffer + cb->BufferSize, // dimensions of our buffer + BufferCoord, // offset in our buffer + &WriteRegion)) // region to restore return FALSE; } } @@ -2438,13 +2439,13 @@ static ConsoleBuffer g_cbTermcap = { 0 } # ifdef FEAT_TITLE char g_szOrigTitle[256] = { 0 }; -HWND g_hWnd = NULL; /* also used in os_mswin.c */ +HWND g_hWnd = NULL; // also used in os_mswin.c static HICON g_hOrigIconSmall = NULL; static HICON g_hOrigIcon = NULL; static HICON g_hVimIcon = NULL; static BOOL g_fCanChangeIcon = FALSE; -/* ICON* are not defined in VC++ 4.0 */ +// ICON* are not defined in VC++ 4.0 # ifndef ICON_SMALL # define ICON_SMALL 0 # endif @@ -2516,7 +2517,7 @@ SetConsoleIcon( static void SaveConsoleTitleAndIcon(void) { - /* Save the original title. */ + // Save the original title. if (!GetConsoleTitle(g_szOrigTitle, sizeof(g_szOrigTitle))) return; @@ -2531,12 +2532,12 @@ SaveConsoleTitleAndIcon(void) if (g_hWnd == NULL) return; - /* Save the original console window icon. */ + // Save the original console window icon. GetConsoleIcon(g_hWnd, &g_hOrigIconSmall, &g_hOrigIcon); if (g_hOrigIconSmall == NULL || g_hOrigIcon == NULL) return; - /* Extract the first icon contained in the Vim executable. */ + // Extract the first icon contained in the Vim executable. if (mch_icon_load((HANDLE *)&g_hVimIcon) == FAIL || g_hVimIcon == NULL) g_hVimIcon = ExtractIcon(NULL, (LPCSTR)exe_name, 0); if (g_hVimIcon != NULL) @@ -2563,17 +2564,17 @@ mch_init_c(void) extern int _fmode; # endif - /* Silently handle invalid parameters to CRT functions */ + // Silently handle invalid parameters to CRT functions SET_INVALID_PARAM_HANDLER; - /* Let critical errors result in a failure, not in a dialog box. Required - * for the timestamp test to work on removed floppies. */ + // Let critical errors result in a failure, not in a dialog box. Required + // for the timestamp test to work on removed floppies. SetErrorMode(SEM_FAILCRITICALERRORS); - _fmode = O_BINARY; /* we do our own CR-LF translation */ + _fmode = O_BINARY; // we do our own CR-LF translation out_flush(); - /* Obtain handles for the standard Console I/O devices */ + // Obtain handles for the standard Console I/O devices if (read_cmd_fd == 0) g_hConIn = GetStdHandle(STD_INPUT_HANDLE); else @@ -2581,11 +2582,11 @@ mch_init_c(void) g_hConOut = GetStdHandle(STD_OUTPUT_HANDLE); # ifdef FEAT_RESTORE_ORIG_SCREEN - /* Save the initial console buffer for later restoration */ + // Save the initial console buffer for later restoration SaveConsoleBuffer(&g_cbOrig); g_attrCurrent = g_attrDefault = g_cbOrig.Info.wAttributes; # else - /* Get current text attributes */ + // Get current text attributes GetConsoleScreenBufferInfo(g_hConOut, &csbi); g_attrCurrent = g_attrDefault = csbi.wAttributes; # endif @@ -2598,7 +2599,7 @@ mch_init_c(void) g_color_index_fg = g_attrDefault & 0xf; g_color_index_bg = (g_attrDefault >> 4) & 0xf; - /* set termcap codes to current text attributes */ + // set termcap codes to current text attributes update_tcap(g_attrCurrent); GetConsoleCursorInfo(g_hConOut, &g_cci); @@ -2659,7 +2660,7 @@ mch_exit_c(int r) if (g_fWindInitCalled) settmode(TMODE_COOK); - ml_close_all(TRUE); /* remove all memfiles */ + ml_close_all(TRUE); // remove all memfiles if (g_fWindInitCalled) { @@ -2697,7 +2698,7 @@ mch_exit_c(int r) exit(r); } -#endif /* !FEAT_GUI_MSWIN */ +#endif // !FEAT_GUI_MSWIN void mch_init(void) @@ -2740,7 +2741,7 @@ mch_check_win( get_exe_name(); #if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL) - return OK; /* GUI always has a tty */ + return OK; // GUI always has a tty #else # ifdef VIMDLL if (gui.in_use) @@ -2798,7 +2799,7 @@ mch_get_user_name( char_u *s, int len) { - WCHAR wszUserName[256 + 1]; /* UNLEN is 256 */ + WCHAR wszUserName[256 + 1]; // UNLEN is 256 DWORD wcch = sizeof(wszUserName) / sizeof(WCHAR); if (GetUserNameW(wszUserName, &wcch)) @@ -2977,7 +2978,7 @@ mch_ishidden(char_u *name) int f = win32_getattrs(name); if (f == -1) - return FALSE; /* file does not exist at all */ + return FALSE; // file does not exist at all return (f & FILE_ATTRIBUTE_HIDDEN) != 0; } @@ -2992,7 +2993,7 @@ mch_isdir(char_u *name) int f = win32_getattrs(name); if (f == -1) - return FALSE; /* file does not exist at all */ + return FALSE; // file does not exist at all return (f & FILE_ATTRIBUTE_DIRECTORY) != 0; } @@ -3270,7 +3271,7 @@ mch_can_exe(char_u *name, char_u **path, { if (p[0] == '.' && (p[1] == NUL || p[1] == ';')) { - /* A single "." means no extension is added. */ + // A single "." means no extension is added. buf[len] = NUL; ++p; if (*p) @@ -3297,9 +3298,9 @@ mch_nodetype(char_u *name) int type; WCHAR *wn; - /* We can't open a file with a name "\\.\con" or "\\.\prn" and trying to - * read from it later will cause Vim to hang. Thus return NODE_WRITABLE - * here. */ + // We can't open a file with a name "\\.\con" or "\\.\prn" and trying to + // read from it later will cause Vim to hang. Thus return NODE_WRITABLE + // here. if (STRNCMP(name, "\\\\.\\", 4) == 0) return NODE_WRITABLE; @@ -3507,7 +3508,7 @@ handler_routine( case CTRL_BREAK_EVENT: g_fCBrkPressed = TRUE; ctrl_break_was_pressed = TRUE; - /* ReadConsoleInput is blocking, send a key event to continue. */ + // ReadConsoleInput is blocking, send a key event to continue. ir.EventType = KEY_EVENT; ir.Event.KeyEvent.bKeyDown = TRUE; ir.Event.KeyEvent.wRepeatCount = 1; @@ -3518,7 +3519,7 @@ handler_routine( WriteConsoleInput(g_hConIn, &ir, 1, &out); return TRUE; - /* fatal events: shut down gracefully */ + // fatal events: shut down gracefully case CTRL_CLOSE_EVENT: case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: @@ -3535,9 +3536,9 @@ handler_routine( OutputDebugString(IObuff); # endif - preserve_exit(); /* output IObuff, preserve files and exit */ - - return TRUE; /* not reached */ + preserve_exit(); // output IObuff, preserve files and exit + + return TRUE; // not reached default: return FALSE; @@ -3569,8 +3570,8 @@ mch_settmode(int tmode) cmodein |= ENABLE_MOUSE_INPUT; cmodeout &= ~( # ifdef FEAT_TERMGUICOLORS - /* Do not turn off the ENABLE_PROCESSED_OUTPUT flag when using - * VTP. */ + // Do not turn off the ENABLE_PROCESSED_OUTPUT flag when using + // VTP. ((vtp_working) ? 0 : ENABLE_PROCESSED_OUTPUT) | # else ENABLE_PROCESSED_OUTPUT | @@ -3578,7 +3579,7 @@ mch_settmode(int tmode) ENABLE_WRAP_AT_EOL_OUTPUT); bEnableHandler = TRUE; } - else /* cooked */ + else // cooked { cmodein |= (ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT); @@ -3690,8 +3691,8 @@ ResizeConBufAndWindow( int xSize, int ySize) { - CONSOLE_SCREEN_BUFFER_INFO csbi; /* hold current console buffer info */ - SMALL_RECT srWindowRect; /* hold the new console size */ + CONSOLE_SCREEN_BUFFER_INFO csbi; // hold current console buffer info + SMALL_RECT srWindowRect; // hold the new console size COORD coordScreen; COORD cursor; static int resized = FALSE; @@ -3704,10 +3705,10 @@ ResizeConBufAndWindow( } # endif - /* get the largest size we can size the console window to */ + // get the largest size we can size the console window to coordScreen = GetLargestConsoleWindowSize(hConsole); - /* define the new console window size and scroll position */ + // define the new console window size and scroll position srWindowRect.Left = srWindowRect.Top = (SHORT) 0; srWindowRect.Right = (SHORT) (min(xSize, coordScreen.X) - 1); srWindowRect.Bottom = (SHORT) (min(ySize, coordScreen.Y) - 1); @@ -3772,7 +3773,7 @@ mch_set_shellsize(void) if (gui.in_use) return; # endif - /* Don't change window size while still starting up */ + // Don't change window size while still starting up if (suppress_winsize != 0) { suppress_winsize = 2; @@ -3783,7 +3784,7 @@ mch_set_shellsize(void) { coordScreen = GetLargestConsoleWindowSize(g_hConOut); - /* Clamp Rows and Columns to reasonable values */ + // Clamp Rows and Columns to reasonable values if (Rows > coordScreen.Y) Rows = coordScreen.Y; if (Columns > coordScreen.X) @@ -3821,7 +3822,7 @@ mch_set_winsize_now(void) } suppress_winsize = 0; } -#endif /* FEAT_GUI_MSWIN */ +#endif // FEAT_GUI_MSWIN static BOOL vim_create_process( @@ -3916,17 +3917,17 @@ mch_system_classic(char *cmd, int option si.cbReserved2 = 0; si.lpReserved2 = NULL; - /* Now, run the command */ + // Now, run the command vim_create_process(cmd, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE, &si, &pi, NULL, NULL); - /* Wait for the command to terminate before continuing */ + // Wait for the command to terminate before continuing { # ifdef FEAT_GUI int delay = 1; - /* Keep updating the window while waiting for the shell to finish. */ + // Keep updating the window while waiting for the shell to finish. for (;;) { MSG msg; @@ -3941,9 +3942,9 @@ mch_system_classic(char *cmd, int option if (WaitForSingleObject(pi.hProcess, delay) != WAIT_TIMEOUT) break; - /* We start waiting for a very short time and then increase it, so - * that we respond quickly when the process is quick, and don't - * consume too much overhead when it's slow. */ + // We start waiting for a very short time and then increase it, so + // that we respond quickly when the process is quick, and don't + // consume too much overhead when it's slow. if (delay < 50) delay += 10; } @@ -3951,15 +3952,15 @@ mch_system_classic(char *cmd, int option WaitForSingleObject(pi.hProcess, INFINITE); # endif - /* Get the command exit code */ + // Get the command exit code GetExitCodeProcess(pi.hProcess, &ret); } - /* Close the handles to the subprocess, so that it goes away */ + // Close the handles to the subprocess, so that it goes away CloseHandle(pi.hThread); CloseHandle(pi.hProcess); - /* Try to get input focus back. Doesn't always work though. */ + // Try to get input focus back. Doesn't always work though. PostMessage(hwnd, WM_SETFOCUS, 0, 0); return ret; @@ -3988,7 +3989,7 @@ sub_process_writer(LPVOID param) len = 0; else if (lp[written] == NL) { - /* NL -> NUL translation */ + // NL -> NUL translation WriteFile(g_hChildStd_IN_Wr, "", 1, &len, NULL); } else @@ -4000,8 +4001,8 @@ sub_process_writer(LPVOID param) } if (len == (int)l) { - /* Finished a line, add a NL, unless this line should not have - * one. */ + // Finished a line, add a NL, unless this line should not have + // one. if (lnum != curbuf->b_op_end.lnum || (!curbuf->b_p_bin && curbuf->b_p_fixeol) @@ -4024,13 +4025,13 @@ sub_process_writer(LPVOID param) written += len; } - /* finished all the lines, close pipe */ + // finished all the lines, close pipe CloseHandle(g_hChildStd_IN_Wr); return 0; } -# define BUFLEN 100 /* length for buffer, stolen from unix version */ +# define BUFLEN 100 // length for buffer, stolen from unix version /* * This function read from the children's stdout and write the @@ -4050,17 +4051,17 @@ dump_pipe(int options, DWORD toRead; int repeatCount; - /* we query the pipe to see if there is any data to read - * to avoid to perform a blocking read */ - ret = PeekNamedPipe(g_hChildStd_OUT_Rd, /* pipe to query */ - NULL, /* optional buffer */ - 0, /* buffer size */ - NULL, /* number of read bytes */ - &availableBytes, /* available bytes total */ - NULL); /* byteLeft */ + // we query the pipe to see if there is any data to read + // to avoid to perform a blocking read + ret = PeekNamedPipe(g_hChildStd_OUT_Rd, // pipe to query + NULL, // optional buffer + 0, // buffer size + NULL, // number of read bytes + &availableBytes, // available bytes total + NULL); // byteLeft repeatCount = 0; - /* We got real data in the pipe, read it */ + // We got real data in the pipe, read it while (ret != 0 && availableBytes > 0) { repeatCount++; @@ -4068,7 +4069,7 @@ dump_pipe(int options, toRead = availableBytes < toRead ? availableBytes : toRead; ReadFile(g_hChildStd_OUT_Rd, buffer + *buffer_off, toRead , &len, NULL); - /* If we haven't read anything, there is a problem */ + // If we haven't read anything, there is a problem if (len == 0) break; @@ -4076,8 +4077,8 @@ dump_pipe(int options, if (options & SHELL_READ) { - /* Do NUL -> NL translation, append NL separated - * lines to the current buffer. */ + // Do NUL -> NL translation, append NL separated + // lines to the current buffer. for (i = 0; i < len; ++i) { if (buffer[i] == NL) @@ -4097,20 +4098,20 @@ dump_pipe(int options, len += *buffer_off; buffer[len] = NUL; - /* Check if the last character in buffer[] is - * incomplete, keep these bytes for the next - * round. */ + // Check if the last character in buffer[] is + // incomplete, keep these bytes for the next + // round. for (p = buffer; p < buffer + len; p += l) { l = MB_CPTR2LEN(p); if (l == 0) - l = 1; /* NUL byte? */ + l = 1; // NUL byte? else if (MB_BYTE2LEN(*p) != l) break; } - if (p == buffer) /* no complete character */ + if (p == buffer) // no complete character { - /* avoid getting stuck at an illegal byte */ + // avoid getting stuck at an illegal byte if (len >= 12) ++p; else @@ -4159,34 +4160,34 @@ mch_system_piped(char *cmd, int options) HANDLE g_hChildStd_OUT_Rd = NULL; HANDLE g_hChildStd_OUT_Wr = NULL; - char_u buffer[BUFLEN + 1]; /* reading buffer + size */ + char_u buffer[BUFLEN + 1]; // reading buffer + size DWORD len; - /* buffer used to receive keys */ - char_u ta_buf[BUFLEN + 1]; /* TypeAHead */ - int ta_len = 0; /* valid bytes in ta_buf[] */ + // buffer used to receive keys + char_u ta_buf[BUFLEN + 1]; // TypeAHead + int ta_len = 0; // valid bytes in ta_buf[] DWORD i; int c; int noread_cnt = 0; garray_T ga; int delay = 1; - DWORD buffer_off = 0; /* valid bytes in buffer[] */ + DWORD buffer_off = 0; // valid bytes in buffer[] char *p = NULL; SECURITY_ATTRIBUTES saAttr; - /* Set the bInheritHandle flag so pipe handles are inherited. */ + // Set the bInheritHandle flag so pipe handles are inherited. saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; if ( ! CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &saAttr, 0) - /* Ensure the read handle to the pipe for STDOUT is not inherited. */ + // Ensure the read handle to the pipe for STDOUT is not inherited. || ! SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0) - /* Create a pipe for the child process's STDIN. */ + // Create a pipe for the child process's STDIN. || ! CreatePipe(&g_hChildStd_IN_Rd, &g_hChildStd_IN_Wr, &saAttr, 0) - /* Ensure the write handle to the pipe for STDIN is not inherited. */ + // Ensure the write handle to the pipe for STDIN is not inherited. || ! SetHandleInformation(g_hChildStd_IN_Wr, HANDLE_FLAG_INHERIT, 0) ) { CloseHandle(g_hChildStd_IN_Rd); @@ -4202,7 +4203,7 @@ mch_system_piped(char *cmd, int options) si.lpTitle = NULL; si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; - /* set-up our file redirection */ + // set-up our file redirection si.hStdError = g_hChildStd_OUT_Wr; si.hStdOutput = g_hChildStd_OUT_Wr; si.hStdInput = g_hChildStd_IN_Rd; @@ -4222,34 +4223,34 @@ mch_system_piped(char *cmd, int options) p = cmd; } - /* Now, run the command. - * About "Inherit handles" being TRUE: this command can be litigious, - * handle inheritance was deactivated for pending temp file, but, if we - * deactivate it, the pipes don't work for some reason. */ + // Now, run the command. + // About "Inherit handles" being TRUE: this command can be litigious, + // handle inheritance was deactivated for pending temp file, but, if we + // deactivate it, the pipes don't work for some reason. vim_create_process(p, TRUE, CREATE_DEFAULT_ERROR_MODE, &si, &pi, NULL, NULL); if (p != cmd) vim_free(p); - /* Close our unused side of the pipes */ + // Close our unused side of the pipes CloseHandle(g_hChildStd_IN_Rd); CloseHandle(g_hChildStd_OUT_Wr); if (options & SHELL_WRITE) { HANDLE thread = (HANDLE) - _beginthreadex(NULL, /* security attributes */ - 0, /* default stack size */ - sub_process_writer, /* function to be executed */ - g_hChildStd_IN_Wr, /* parameter */ - 0, /* creation flag, start immediately */ - NULL); /* we don't care about thread id */ + _beginthreadex(NULL, // security attributes + 0, // default stack size + sub_process_writer, // function to be executed + g_hChildStd_IN_Wr, // parameter + 0, // creation flag, start immediately + NULL); // we don't care about thread id CloseHandle(thread); g_hChildStd_IN_Wr = NULL; } - /* Keep updating the window while waiting for the shell to finish. */ + // Keep updating the window while waiting for the shell to finish. for (;;) { MSG msg; @@ -4260,7 +4261,7 @@ mch_system_piped(char *cmd, int options) pDispatchMessage(&msg); } - /* write pipe information in the window */ + // write pipe information in the window if ((options & (SHELL_READ|SHELL_WRITE)) # ifdef FEAT_GUI || gui.in_use @@ -4280,8 +4281,8 @@ mch_system_piped(char *cmd, int options) { if (ta_len == 0) { - /* Get extra characters when we don't have any. Reset the - * counter and timer. */ + // Get extra characters when we don't have any. Reset the + // counter and timer. noread_cnt = 0; len = ui_inchar(ta_buf, BUFLEN, 10L, 0); } @@ -4295,8 +4296,8 @@ mch_system_piped(char *cmd, int options) { if (ta_buf[ta_len] == Ctrl_C) { - /* Learn what exit code is expected, for - * now put 9 as SIGKILL */ + // Learn what exit code is expected, for + // now put 9 as SIGKILL TerminateProcess(pi.hProcess, 9); } if (ta_buf[ta_len] == Ctrl_D) @@ -4306,7 +4307,7 @@ mch_system_piped(char *cmd, int options) } } - /* replace K_BS by and K_DEL by */ + // replace K_BS by and K_DEL by for (i = ta_len; i < ta_len + len; ++i) { if (ta_buf[i] == CSI && len - i > 2) @@ -4390,21 +4391,21 @@ mch_system_piped(char *cmd, int options) ++noread_cnt; dump_pipe(options, g_hChildStd_OUT_Rd, &ga, buffer, &buffer_off); - /* We start waiting for a very short time and then increase it, so - * that we respond quickly when the process is quick, and don't - * consume too much overhead when it's slow. */ + // We start waiting for a very short time and then increase it, so + // that we respond quickly when the process is quick, and don't + // consume too much overhead when it's slow. if (delay < 50) delay += 10; } - /* Close the pipe */ + // Close the pipe CloseHandle(g_hChildStd_OUT_Rd); if (g_hChildStd_IN_Wr != NULL) CloseHandle(g_hChildStd_IN_Wr); WaitForSingleObject(pi.hProcess, INFINITE); - /* Get the command exit code */ + // Get the command exit code GetExitCodeProcess(pi.hProcess, &ret); if (options & SHELL_READ) @@ -4412,7 +4413,7 @@ mch_system_piped(char *cmd, int options) if (ga.ga_len > 0) { append_ga_line(&ga); - /* remember that the NL was missing */ + // remember that the NL was missing curbuf->b_no_eol_lnum = curwin->w_cursor.lnum; } else @@ -4420,7 +4421,7 @@ mch_system_piped(char *cmd, int options) ga_clear(&ga); } - /* Close the handles to the subprocess, so that it goes away */ + // Close the handles to the subprocess, so that it goes away CloseHandle(pi.hThread); CloseHandle(pi.hProcess); @@ -4430,7 +4431,7 @@ mch_system_piped(char *cmd, int options) static int mch_system_g(char *cmd, int options) { - /* if we can pipe and the shelltemp option is off */ + // if we can pipe and the shelltemp option is off if (!p_stmp) return mch_system_piped(cmd, options); else @@ -4495,7 +4496,7 @@ mch_system(char *cmd, int options) static int mch_call_shell_terminal( char_u *cmd, - int options UNUSED) /* SHELL_*, see vim.h */ + int options UNUSED) // SHELL_*, see vim.h { jobopt_T opt; char_u *newcmd = NULL; @@ -4505,7 +4506,7 @@ mch_call_shell_terminal( buf_T *buf; job_T *job; aco_save_T aco; - oparg_T oa; /* operator arguments */ + oparg_T oa; // operator arguments if (cmd == NULL) cmdlen = STRLEN(p_sh) + 1; @@ -4540,7 +4541,7 @@ mch_call_shell_terminal( job = term_getjob(buf->b_term); ++job->jv_refcount; - /* Find a window to make "buf" curbuf. */ + // Find a window to make "buf" curbuf. aucmd_prepbuf(&aco, buf); clear_oparg(&oa); @@ -4548,8 +4549,8 @@ mch_call_shell_terminal( { if (oa.op_type == OP_NOP && oa.regname == NUL && !VIsual_active) { - /* If terminal_loop() returns OK we got a key that is handled - * in Normal model. We don't do redrawing anyway. */ + // If terminal_loop() returns OK we got a key that is handled + // in Normal model. We don't do redrawing anyway. if (terminal_loop(TRUE) == OK) normal_cmd(&oa, TRUE); } @@ -4561,7 +4562,7 @@ mch_call_shell_terminal( job_unref(job); - /* restore curwin/curbuf and a few other things */ + // restore curwin/curbuf and a few other things aucmd_restbuf(&aco); wait_return(TRUE); @@ -4578,14 +4579,14 @@ mch_call_shell_terminal( int mch_call_shell( char_u *cmd, - int options) /* SHELL_*, see vim.h */ + int options) // SHELL_*, see vim.h { int x = 0; int tmode = cur_tmode; #ifdef FEAT_TITLE WCHAR szShellTitle[512]; - /* Change the title to reflect that we are in a subshell. */ + // Change the title to reflect that we are in a subshell. if (GetConsoleTitleW(szShellTitle, sizeof(szShellTitle)/sizeof(WCHAR) - 4) > 0) { @@ -4664,7 +4665,7 @@ mch_call_shell( signal(SIGABRT, SIG_IGN); if (options & SHELL_COOKED) - settmode(TMODE_COOK); /* set to normal mode */ + settmode(TMODE_COOK); // set to normal mode if (cmd == NULL) { @@ -4672,12 +4673,12 @@ mch_call_shell( } else { - /* we use "command" or "cmd" to start the shell; slow but easy */ + // we use "command" or "cmd" to start the shell; slow but easy char_u *newcmd = NULL; char_u *cmdbase = cmd; long_u cmdlen; - /* Skip a leading ", ( and "(. */ + // Skip a leading ", ( and "(. if (*cmdbase == '"' ) ++cmdbase; if (*cmdbase == '(') @@ -4726,8 +4727,8 @@ mch_call_shell( si.hStdError = si.hStdInput; } - /* Remove a trailing ", ) and )" if they have a match - * at the start of the command. */ + // Remove a trailing ", ) and )" if they have a match + // at the start of the command. if (cmdbase > cmd) { p = cmdbase + STRLEN(cmdbase); @@ -4760,7 +4761,7 @@ mch_call_shell( (char_u *)"|", '^', FALSE); if (subcmd != NULL) { - /* make "cmd.exe /c arguments" */ + // make "cmd.exe /c arguments" cmdlen = STRLEN(cmd_shell) + STRLEN(subcmd) + 5; newcmd = alloc(cmdlen); if (newcmd != NULL) @@ -4799,10 +4800,10 @@ mch_call_shell( if (si.dwFlags == STARTF_USESTDHANDLES && si.hStdInput != NULL) { - /* Close the handle to \\.\NUL created above. */ + // Close the handle to \\.\NUL created above. CloseHandle(si.hStdInput); } - /* Close the handles to the subprocess, so that it goes away */ + // Close the handles to the subprocess, so that it goes away CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } @@ -4871,9 +4872,9 @@ mch_call_shell( } if (tmode == TMODE_RAW) - settmode(TMODE_RAW); /* set to raw mode */ - - /* Print the return value, unless "vimrun" was used. */ + settmode(TMODE_RAW); // set to raw mode + + // Print the return value, unless "vimrun" was used. if (x != 0 && !(options & SHELL_SILENT) && !emsg_silent #if defined(FEAT_GUI_MSWIN) && ((gui.in_use || gui.starting) ? @@ -4938,7 +4939,7 @@ win32_build_env(dict_T *env, garray_T *g long_u todo = env != NULL ? env->dv_hashtab.ht_used : 0; LPVOID base = GetEnvironmentStringsW(); - /* for last \0 */ + // for last \0 if (ga_grow(gap, 1) == FAIL) return; @@ -4946,7 +4947,7 @@ win32_build_env(dict_T *env, garray_T *g { WCHAR *p = (WCHAR*) base; - /* for last \0 */ + // for last \0 if (ga_grow(gap, 1) == FAIL) return; @@ -5228,8 +5229,8 @@ mch_job_start(char *cmd, job_T *job, job if (!AssignProcessToJobObject(jo, pi.hProcess)) { - /* if failing, switch the way to terminate - * process with TerminateProcess. */ + // if failing, switch the way to terminate + // process with TerminateProcess. CloseHandle(jo); jo = NULL; } @@ -5373,7 +5374,7 @@ mch_signal_job(job_T *job, char_u *how) if (STRCMP(how, "term") == 0 || STRCMP(how, "kill") == 0 || *how == NUL) { - /* deadly signal */ + // deadly signal if (job->jv_job_object != NULL) { if (job->jv_channel != NULL && job->jv_channel->ch_anonymous_pipe) @@ -5523,7 +5524,7 @@ termcap_mode_end(void) g_fTermcapMode = FALSE; } -#endif /* FEAT_GUI_MSWIN */ +#endif // FEAT_GUI_MSWIN #if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL) @@ -5532,7 +5533,7 @@ mch_write( char_u *s UNUSED, int len UNUSED) { - /* never used */ + // never used } #else @@ -5960,7 +5961,7 @@ visual_bell(void) FillConsoleOutputAttribute(g_hConOut, attrFlash, Rows * Columns, coordOrigin, &dwDummy); - Sleep(15); /* wait for 15 msec */ + Sleep(15); // wait for 15 msec if (!USE_VTP) WriteConsoleOutputAttribute(g_hConOut, oldattrs, Rows * Columns, coordOrigin, &dwDummy); @@ -6077,11 +6078,11 @@ mch_write( return; } - /* translate ESC | sequences into faked bios calls */ + // translate ESC | sequences into faked bios calls while (len--) { - /* optimization: use one single write_chars for runs of text, - * rather than once per character It ain't curses, but it helps. */ + // optimization: use one single write_chars for runs of text, + // rather than once per character It ain't curses, but it helps. DWORD prefix = (DWORD)strcspn((char *)s, "\n\r\b\a\033"); if (p_wd) @@ -6109,7 +6110,7 @@ mch_write( } else if (s[0] == '\n') { - /* \n, newline: go to the beginning of the next line or scroll */ + // \n, newline: go to the beginning of the next line or scroll if (g_coord.Y == g_srScrollRegion.Bottom) { scroll(1); @@ -6127,7 +6128,7 @@ mch_write( } else if (s[0] == '\r') { - /* \r, carriage return: go to beginning of line */ + // \r, carriage return: go to beginning of line gotoxy(g_srScrollRegion.Left+1, g_coord.Y + 1); # ifdef MCH_WRITE_DUMP if (fdDump) @@ -6137,7 +6138,7 @@ mch_write( } else if (s[0] == '\b') { - /* \b, backspace: move cursor one position left */ + // \b, backspace: move cursor one position left if (g_coord.X > g_srScrollRegion.Left) g_coord.X--; else if (g_coord.Y > g_srScrollRegion.Top) @@ -6154,7 +6155,7 @@ mch_write( } else if (s[0] == '\a') { - /* \a, bell */ + // \a, bell MessageBeep(0xFFFFFFFF); # ifdef MCH_WRITE_DUMP if (fdDump) @@ -6332,7 +6333,7 @@ mch_write( } else { - /* Write a single character */ + // Write a single character DWORD nWritten; nWritten = write_chars(s, 1); @@ -6356,7 +6357,7 @@ mch_write( # endif } -#endif /* FEAT_GUI_MSWIN */ +#endif // FEAT_GUI_MSWIN /* @@ -6368,12 +6369,12 @@ mch_delay( int ignoreinput UNUSED) { #if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL) - Sleep((int)msec); /* never wait for input */ -#else /* Console */ + Sleep((int)msec); // never wait for input +#else // Console # ifdef VIMDLL if (gui.in_use) { - Sleep((int)msec); /* never wait for input */ + Sleep((int)msec); // never wait for input return; } # endif @@ -6383,7 +6384,7 @@ mch_delay( { int towait = p_mzq; - /* if msec is large enough, wait by portions in p_mzq */ + // if msec is large enough, wait by portions in p_mzq while (msec > 0) { mzvim_check_threads(); @@ -6451,7 +6452,7 @@ mch_breakcheck(int force UNUSED) #endif } -/* physical RAM to leave for the OS */ +// physical RAM to leave for the OS #define WINNT_RESERVE_BYTES (256*1024*1024) /* @@ -6462,21 +6463,21 @@ mch_total_mem(int special UNUSED) { MEMORYSTATUSEX ms; - /* Need to use GlobalMemoryStatusEx() when there is more memory than - * what fits in 32 bits. */ + // Need to use GlobalMemoryStatusEx() when there is more memory than + // what fits in 32 bits. ms.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&ms); if (ms.ullAvailVirtual < ms.ullTotalPhys) { - /* Process address space fits in physical RAM, use all of it. */ + // Process address space fits in physical RAM, use all of it. return (long_u)(ms.ullAvailVirtual / 1024); } if (ms.ullTotalPhys <= WINNT_RESERVE_BYTES) { - /* Catch old NT box or perverse hardware setup. */ + // Catch old NT box or perverse hardware setup. return (long_u)((ms.ullTotalPhys / 2) / 1024); } - /* Use physical RAM less reserve for OS + data. */ + // Use physical RAM less reserve for OS + data. return (long_u)((ms.ullTotalPhys - WINNT_RESERVE_BYTES) / 1024); } @@ -6610,7 +6611,7 @@ default_shell(void) mch_access(char *n, int p) { HANDLE hFile; - int retval = -1; /* default: fail */ + int retval = -1; // default: fail WCHAR *wn; wn = enc_to_utf16((char_u *)n, NULL); @@ -6623,8 +6624,8 @@ mch_access(char *n, int p) if (p & R_OK) { - /* Read check is performed by seeing if we can do a find file on - * the directory for any file. */ + // Read check is performed by seeing if we can do a find file on + // the directory for any file. int i; WIN32_FIND_DATAW d; @@ -6644,10 +6645,10 @@ mch_access(char *n, int p) if (p & W_OK) { - /* Trying to create a temporary file in the directory should catch - * directories on read-only network shares. However, in - * directories whose ACL allows writes but denies deletes will end - * up keeping the temporary file :-(. */ + // Trying to create a temporary file in the directory should catch + // directories on read-only network shares. However, in + // directories whose ACL allows writes but denies deletes will end + // up keeping the temporary file :-(. if (!GetTempFileNameW(wn, L"VIM", 0, TempNameW)) goto getout; else @@ -6659,8 +6660,8 @@ mch_access(char *n, int p) // Don't consider a file read-only if another process has opened it. DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE; - /* Trying to open the file for the required access does ACL, read-only - * network share, and file attribute checks. */ + // Trying to open the file for the required access does ACL, read-only + // network share, and file attribute checks. DWORD access_mode = ((p & W_OK) ? GENERIC_WRITE : 0) | ((p & R_OK) ? GENERIC_READ : 0); @@ -6671,7 +6672,7 @@ mch_access(char *n, int p) CloseHandle(hFile); } - retval = 0; /* success */ + retval = 0; // success getout: vim_free(wn); return retval; @@ -6705,8 +6706,8 @@ mch_fopen(const char *name, const char * FILE *f = NULL; #if defined(DEBUG) && _MSC_VER >= 1400 - /* Work around an annoying assertion in the Microsoft debug CRT - * when mode's text/binary setting doesn't match _get_fmode(). */ + // Work around an annoying assertion in the Microsoft debug CRT + // when mode's text/binary setting doesn't match _get_fmode(). char newMode = mode[strlen(mode) - 1]; int oldMode = 0; @@ -6770,10 +6771,10 @@ copy_substream(HANDLE sh, void *context, DWORD readcnt, written; char buf[4096]; - /* Copy block of bytes at a time. Abort when something goes wrong. */ + // Copy block of bytes at a time. Abort when something goes wrong. for (done = 0; done < len; done += written) { - /* (size_t) cast for Borland C 5.5 */ + // (size_t) cast for Borland C 5.5 todo = (DWORD)((size_t)(len - done) > sizeof(buf) ? sizeof(buf) : (size_t)(len - done)); if (!BackupRead(sh, (LPBYTE)buf, todo, &readcnt, @@ -6806,22 +6807,22 @@ copy_infostreams(char_u *from, char_u *t DWORD lo, hi; int len; - /* Convert the file names to wide characters. */ + // Convert the file names to wide characters. fromw = enc_to_utf16(from, NULL); tow = enc_to_utf16(to, NULL); if (fromw != NULL && tow != NULL) { - /* Open the file for reading. */ + // Open the file for reading. sh = CreateFileW(fromw, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if (sh != INVALID_HANDLE_VALUE) { - /* Use BackupRead() to find the info streams. Repeat until we - * have done them all.*/ + // Use BackupRead() to find the info streams. Repeat until we + // have done them all. for (;;) { - /* Get the header to find the length of the stream name. If - * the "readcount" is zero we have done all info streams. */ + // Get the header to find the length of the stream name. If + // the "readcount" is zero we have done all info streams. ZeroMemory(&sid, sizeof(WIN32_STREAM_ID)); headersize = (int)((char *)&sid.cStreamName - (char *)&sid.dwStreamId); if (!BackupRead(sh, (LPBYTE)&sid, headersize, @@ -6829,22 +6830,22 @@ copy_infostreams(char_u *from, char_u *t || readcount == 0) break; - /* We only deal with streams that have a name. The normal - * file data appears to be without a name, even though docs - * suggest it is called "::$DATA". */ + // We only deal with streams that have a name. The normal + // file data appears to be without a name, even though docs + // suggest it is called "::$DATA". if (sid.dwStreamNameSize > 0) { - /* Read the stream name. */ + // Read the stream name. if (!BackupRead(sh, (LPBYTE)streamname, sid.dwStreamNameSize, &readcount, FALSE, FALSE, &context)) break; - /* Copy an info stream with a name ":anything:$DATA". - * Skip "::$DATA", it has no stream name (examples suggest - * it might be used for the normal file contents). - * Note that BackupRead() counts bytes, but the name is in - * wide characters. */ + // Copy an info stream with a name ":anything:$DATA". + // Skip "::$DATA", it has no stream name (examples suggest + // it might be used for the normal file contents). + // Note that BackupRead() counts bytes, but the name is in + // wide characters. len = readcount / sizeof(WCHAR); streamname[len] = 0; if (len > 7 && wcsicmp(streamname + len - 6, @@ -6856,14 +6857,14 @@ copy_infostreams(char_u *from, char_u *t } } - /* Advance to the next stream. We might try seeking too far, - * but BackupSeek() doesn't skip over stream borders, thus - * that's OK. */ + // Advance to the next stream. We might try seeking too far, + // but BackupSeek() doesn't skip over stream borders, thus + // that's OK. (void)BackupSeek(sh, sid.Size.u.LowPart, sid.Size.u.HighPart, &lo, &hi, &context); } - /* Clear the context. */ + // Clear the context. (void)BackupRead(sh, NULL, 0, &readcount, TRUE, FALSE, &context); CloseHandle(sh); @@ -6881,7 +6882,7 @@ copy_infostreams(char_u *from, char_u *t int mch_copy_file_attribute(char_u *from, char_u *to) { - /* File streams only work on Windows NT and later. */ + // File streams only work on Windows NT and later. copy_infostreams(from, to); return 0; } @@ -6892,7 +6893,7 @@ mch_copy_file_attribute(char_u *from, ch * Written by Benjamin Peterson. */ -/* These magic numbers are from the MS header files */ +// These magic numbers are from the MS header files # define MIN_STACK_WINNT 2 /* @@ -6912,26 +6913,25 @@ myresetstkoflw(void) DWORD nPageSize; DWORD dummy; - /* We need to know the system page size. */ + // We need to know the system page size. GetSystemInfo(&si); nPageSize = si.dwPageSize; - /* ...and the current stack pointer */ + // ...and the current stack pointer pStackPtr = (BYTE*)_alloca(1); - /* ...and the base of the stack. */ + // ...and the base of the stack. if (VirtualQuery(pStackPtr, &mbi, sizeof mbi) == 0) return 0; pStackBase = (BYTE*)mbi.AllocationBase; - /* ...and the page thats min_stack_req pages away from stack base; this is - * the lowest page we could use. */ + // ...and the page thats min_stack_req pages away from stack base; this is + // the lowest page we could use. pLowestPossiblePage = pStackBase + MIN_STACK_WINNT * nPageSize; { - /* We want the first committed page in the stack Start at the stack - * base and move forward through memory until we find a committed block. - */ + // We want the first committed page in the stack Start at the stack + // base and move forward through memory until we find a committed block. BYTE *pBlock = pStackBase; for (;;) @@ -6945,21 +6945,21 @@ myresetstkoflw(void) break; } - /* mbi now describes the first committed block in the stack. */ + // mbi now describes the first committed block in the stack. if (mbi.Protect & PAGE_GUARD) return 1; - /* decide where the guard page should start */ + // decide where the guard page should start if ((long_u)(mbi.BaseAddress) < (long_u)pLowestPossiblePage) pGuardPage = pLowestPossiblePage; else pGuardPage = (BYTE*)mbi.BaseAddress; - /* allocate the guard page */ + // allocate the guard page if (!VirtualAlloc(pGuardPage, nPageSize, MEM_COMMIT, PAGE_READWRITE)) return 0; - /* apply the guard attribute to the page */ + // apply the guard attribute to the page if (!VirtualProtect(pGuardPage, nPageSize, PAGE_READWRITE | PAGE_GUARD, &dummy)) return 0; @@ -6978,15 +6978,15 @@ static LPWSTR *ArglistW = NULL; static int global_argc = 0; static char **global_argv; -static int used_file_argc = 0; /* last argument in global_argv[] used - for the argument list. */ -static int *used_file_indexes = NULL; /* indexes in global_argv[] for - command line arguments added to - the argument list */ -static int used_file_count = 0; /* nr of entries in used_file_indexes */ -static int used_file_literal = FALSE; /* take file names literally */ -static int used_file_full_path = FALSE; /* file name was full path */ -static int used_file_diff_mode = FALSE; /* file name was with diff mode */ +static int used_file_argc = 0; // last argument in global_argv[] used + // for the argument list. +static int *used_file_indexes = NULL; // indexes in global_argv[] for + // command line arguments added to + // the argument list +static int used_file_count = 0; // nr of entries in used_file_indexes +static int used_file_literal = FALSE; // take file names literally +static int used_file_full_path = FALSE; // file name was full path +static int used_file_diff_mode = FALSE; // file name was with diff mode static int used_alist_count = 0; @@ -7014,13 +7014,13 @@ get_cmd_argsW(char ***argvp) { int len; - /* Convert each Unicode argument to the current codepage. */ + // Convert each Unicode argument to the current codepage. WideCharToMultiByte_alloc(GetACP(), 0, ArglistW[i], (int)wcslen(ArglistW[i]) + 1, (LPSTR *)&argv[i], &len, 0, 0); if (argv[i] == NULL) { - /* Out of memory, clear everything. */ + // Out of memory, clear everything. while (i > 0) free(argv[--i]); free(argv); @@ -7102,12 +7102,11 @@ fix_arg_enc(void) char_u *str; int *fnum_list; - /* Safety checks: - * - if argument count differs between the wide and non-wide argument - * list, something must be wrong. - * - the file name arguments must have been located. - * - the length of the argument list wasn't changed by the user. - */ + // Safety checks: + // - if argument count differs between the wide and non-wide argument + // list, something must be wrong. + // - the file name arguments must have been located. + // - the length of the argument list wasn't changed by the user. if (global_argc != nArgsW || ArglistW == NULL || used_file_indexes == NULL @@ -7115,17 +7114,17 @@ fix_arg_enc(void) || used_alist_count != GARGCOUNT) return; - /* Remember the buffer numbers for the arguments. */ + // Remember the buffer numbers for the arguments. fnum_list = ALLOC_MULT(int, GARGCOUNT); if (fnum_list == NULL) - return; /* out of memory */ + return; // out of memory for (i = 0; i < GARGCOUNT; ++i) fnum_list[i] = GARGLIST[i].ae_fnum; - /* Clear the argument list. Make room for the new arguments. */ + // Clear the argument list. Make room for the new arguments. alist_clear(&global_alist); if (ga_grow(&global_alist.al_ga, used_file_count) == FAIL) - return; /* out of memory */ + return; // out of memory for (i = 0; i < used_file_count; ++i) { @@ -7136,8 +7135,8 @@ fix_arg_enc(void) int literal = used_file_literal; #ifdef FEAT_DIFF - /* When using diff mode may need to concatenate file name to - * directory name. Just like it's done in main(). */ + // When using diff mode may need to concatenate file name to + // directory name. Just like it's done in main(). if (used_file_diff_mode && mch_isdir(str) && GARGCOUNT > 0 && !mch_isdir(alist_name(&GARGLIST[0]))) { @@ -7151,13 +7150,13 @@ fix_arg_enc(void) } } #endif - /* Re-use the old buffer by renaming it. When not using literal - * names it's done by alist_expand() below. */ + // Re-use the old buffer by renaming it. When not using literal + // names it's done by alist_expand() below. if (used_file_literal) buf_set_name(fnum_list[i], str); - /* Check backtick literal. backtick literal is already expanded in - * main.c, so this part add str as literal. */ + // Check backtick literal. backtick literal is already expanded in + // main.c, so this part add str as literal. if (literal == FALSE) { size_t len = STRLEN(str); @@ -7171,13 +7170,13 @@ fix_arg_enc(void) if (!used_file_literal) { - /* Now expand wildcards in the arguments. */ - /* Temporarily add '(' and ')' to 'isfname'. These are valid - * filename characters but are excluded from 'isfname' to make - * "gf" work on a file name in parenthesis (e.g.: see vim.h). - * Also, unset wildignore to not be influenced by this option. - * The arguments specified in command-line should be kept even if - * encoding options were changed. */ + // Now expand wildcards in the arguments. + // Temporarily add '(' and ')' to 'isfname'. These are valid + // filename characters but are excluded from 'isfname' to make + // "gf" work on a file name in parenthesis (e.g.: see vim.h). + // Also, unset wildignore to not be influenced by this option. + // The arguments specified in command-line should be kept even if + // encoding options were changed. do_cmdline_cmd((char_u *)":let SaVe_ISF = &isf|set isf+=(,)"); do_cmdline_cmd((char_u *)":let SaVe_WIG = &wig|set wig="); alist_expand(fnum_list, used_alist_count); @@ -7185,8 +7184,8 @@ fix_arg_enc(void) do_cmdline_cmd((char_u *)":let &wig = SaVe_WIG|unlet SaVe_WIG"); } - /* If wildcard expansion failed, we are editing the first file of the - * arglist and there is no file name: Edit the first argument now. */ + // If wildcard expansion failed, we are editing the first file of the + // arglist and there is no file name: Edit the first argument now. if (curwin->w_arg_idx == 0 && curbuf->b_fname == NULL) { do_cmdline_cmd((char_u *)":rewind"); @@ -7306,7 +7305,7 @@ vtp_init(void) COLORREF fg, bg; # endif - /* Use functions supported from Vista */ + // Use functions supported from Vista hKerneldll = GetModuleHandle("kernel32.dll"); if (hKerneldll != NULL) { @@ -7377,7 +7376,7 @@ vtp_sgr_bulks( int *args ) { - /* 2('\033[') + 4('255.') * 16 + NUL */ + // 2('\033[') + 4('255.') * 16 + NUL char_u buf[2 + (4 * 16) + 1]; char_u *p; int i; diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2393, +/**/ 2392, /**/ 2391,