summaryrefslogtreecommitdiff
path: root/src/if_cscope.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-04 21:24:53 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-04 21:24:53 +0100
commit2ab2e8608f9b2c85432715bb9a7f226fdbf8cd35 (patch)
tree0a361d816527e615a7b64298e7c51c16d65fb015 /src/if_cscope.c
parent9834b96820bec95d6858229d6fb256310365efff (diff)
downloadvim-git-2ab2e8608f9b2c85432715bb9a7f226fdbf8cd35.tar.gz
patch 8.1.2387: using old C style commentsv8.1.2387
Problem: Using old C style comments. Solution: Use // comments where appropriate.
Diffstat (limited to 'src/if_cscope.c')
-rw-r--r--src/if_cscope.c378
1 files changed, 187 insertions, 191 deletions
diff --git a/src/if_cscope.c b/src/if_cscope.c
index aac613364..89c851b2a 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -51,11 +51,11 @@ static int cs_show(exarg_T *eap);
static csinfo_T * csinfo = NULL;
-static int csinfo_size = 0; /* number of items allocated in
- csinfo[] */
+static int csinfo_size = 0; // number of items allocated in
+ // csinfo[]
-static int eap_arg_len; /* length of eap->arg, set in
- cs_lookup_cmd() */
+static int eap_arg_len; // length of eap->arg, set in
+ // cs_lookup_cmd()
static cscmd_T cs_cmds[] =
{
{ "add", cs_add,
@@ -81,10 +81,10 @@ cs_usage_msg(csid_e x)
static enum
{
- EXP_CSCOPE_SUBCMD, /* expand ":cscope" sub-commands */
- EXP_SCSCOPE_SUBCMD, /* expand ":scscope" sub-commands */
- EXP_CSCOPE_FIND, /* expand ":cscope find" arguments */
- EXP_CSCOPE_KILL /* expand ":cscope kill" arguments */
+ EXP_CSCOPE_SUBCMD, // expand ":cscope" sub-commands
+ EXP_SCSCOPE_SUBCMD, // expand ":scscope" sub-commands
+ EXP_CSCOPE_FIND, // expand ":cscope find" arguments
+ EXP_CSCOPE_KILL // expand ":cscope kill" arguments
} expand_what;
/*
@@ -100,12 +100,12 @@ get_cscope_name(expand_T *xp UNUSED, int idx)
switch (expand_what)
{
case EXP_CSCOPE_SUBCMD:
- /* Complete with sub-commands of ":cscope":
- * add, find, help, kill, reset, show */
+ // Complete with sub-commands of ":cscope":
+ // add, find, help, kill, reset, show
return (char_u *)cs_cmds[idx].name;
case EXP_SCSCOPE_SUBCMD:
- /* Complete with sub-commands of ":scscope": same sub-commands as
- * ":cscope" but skip commands which don't support split windows */
+ // Complete with sub-commands of ":scscope": same sub-commands as
+ // ":cscope" but skip commands which don't support split windows
for (i = 0, current_idx = 0; cs_cmds[i].name != NULL; i++)
if (cs_cmds[i].cansplit)
if (current_idx++ == idx)
@@ -118,20 +118,20 @@ get_cscope_name(expand_T *xp UNUSED, int idx)
"a", "c", "d", "e", "f", "g", "i", "s", "t", NULL
};
- /* Complete with query type of ":cscope find {query_type}".
- * {query_type} can be letters (c, d, ... a) or numbers (0, 1,
- * ..., 9) but only complete with letters, since numbers are
- * redundant. */
+ // Complete with query type of ":cscope find {query_type}".
+ // {query_type} can be letters (c, d, ... a) or numbers (0, 1,
+ // ..., 9) but only complete with letters, since numbers are
+ // redundant.
return (char_u *)query_type[idx];
}
case EXP_CSCOPE_KILL:
{
static char connection[5];
- /* ":cscope kill" accepts connection numbers or partial names of
- * the pathname of the cscope database as argument. Only complete
- * with connection numbers. -1 can also be used to kill all
- * connections. */
+ // ":cscope kill" accepts connection numbers or partial names of
+ // the pathname of the cscope database as argument. Only complete
+ // with connection numbers. -1 can also be used to kill all
+ // connections.
for (i = 0, current_idx = 0; i < csinfo_size; i++)
{
if (csinfo[i].fname == NULL)
@@ -160,17 +160,17 @@ set_context_in_cscope_cmd(
{
char_u *p;
- /* Default: expand subcommands */
+ // Default: expand subcommands
xp->xp_context = EXPAND_CSCOPE;
xp->xp_pattern = arg;
expand_what = (cmdidx == CMD_scscope)
? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD;
- /* (part of) subcommand already typed */
+ // (part of) subcommand already typed
if (*arg != NUL)
{
p = skiptowhite(arg);
- if (*p != NUL) /* past first word */
+ if (*p != NUL) // past first word
{
xp->xp_pattern = skipwhite(p);
if (*skiptowhite(xp->xp_pattern) != NUL)
@@ -194,7 +194,7 @@ set_context_in_cscope_cmd(
static void
do_cscope_general(
exarg_T *eap,
- int make_split UNUSED) /* whether to split window */
+ int make_split UNUSED) // whether to split window
{
cscmd_T *cmdp;
@@ -333,7 +333,7 @@ cs_fgets(char_u *buf, int size)
vim_strncpy(buf, (char_u *)p, size - 1);
return FALSE;
-} /* cs_fgets */
+}
/*
@@ -483,8 +483,8 @@ cs_stat_emsg(char *fname)
*/
static int
cs_add_common(
- char *arg1, /* filename - may contain environment variables */
- char *arg2, /* prepend path - may contain environment variables */
+ char *arg1, // filename - may contain environment variables
+ char *arg2, // prepend path - may contain environment variables
char *flags)
{
stat_T statbuf;
@@ -497,7 +497,7 @@ cs_add_common(
int usedlen = 0;
char_u *fbuf = NULL;
- /* get the filename (arg1), expand it, and try to stat it */
+ // get the filename (arg1), expand it, and try to stat it
if ((fname = alloc(MAXPATHL + 1)) == NULL)
goto add_err;
@@ -520,7 +520,7 @@ staterr:
goto add_err;
}
- /* get the prepend path (arg2), expand it, and try to stat it */
+ // get the prepend path (arg2), expand it, and try to stat it
if (arg2 != NULL)
{
stat_T statbuf2;
@@ -534,7 +534,7 @@ staterr:
goto staterr;
}
- /* if filename is a directory, append the cscope database name to it */
+ // if filename is a directory, append the cscope database name to it
if (S_ISDIR(statbuf.st_mode))
{
fname2 = alloc(strlen(CSCOPE_DBFILE) + strlen(fname) + 2);
@@ -607,21 +607,21 @@ add_err:
vim_free(fname);
vim_free(ppath);
return CSCOPE_FAILURE;
-} /* cs_add_common */
+}
static int
cs_check_for_connections(void)
{
return (cs_cnt_connections() > 0);
-} /* cs_check_for_connections */
+}
static int
cs_check_for_tags(void)
{
return (p_tags[0] != NUL && curbuf->b_p_tags != NULL);
-} /* cs_check_for_tags */
+}
/*
@@ -639,11 +639,11 @@ cs_cnt_connections(void)
cnt++;
}
return cnt;
-} /* cs_cnt_connections */
+}
static void
cs_reading_emsg(
- int idx) /* connection index */
+ int idx) // connection index
{
semsg(_("E262: error reading cscope connection %d"), idx);
}
@@ -708,7 +708,7 @@ cs_cnt_matches(int idx)
vim_free(buf);
return nlines;
-} /* cs_cnt_matches */
+}
/*
@@ -756,8 +756,8 @@ cs_create_cmd(char *csoption, char *pattern)
return NULL;
}
- /* Skip white space before the patter, except for text and pattern search,
- * they may want to use the leading white space. */
+ // Skip white space before the patter, except for text and pattern search,
+ // they may want to use the leading white space.
pat = pattern;
if (search != 4 && search != 6)
while VIM_ISWHITE(*pat)
@@ -769,7 +769,7 @@ cs_create_cmd(char *csoption, char *pattern)
(void)sprintf(cmd, "%d%s", search, pat);
return cmd;
-} /* cs_create_cmd */
+}
/*
@@ -826,7 +826,7 @@ err_closing:
case -1:
(void)emsg(_("E622: Could not fork for cscope"));
goto err_closing;
- case 0: /* child: run cscope. */
+ case 0: // child: run cscope.
if (dup2(to_cs[0], STDIN_FILENO) == -1)
PERROR("cs_create_connection 1");
if (dup2(from_cs[1], STDOUT_FILENO) == -1)
@@ -834,12 +834,12 @@ err_closing:
if (dup2(from_cs[1], STDERR_FILENO) == -1)
PERROR("cs_create_connection 3");
- /* close unused */
+ // close unused
(void)close(to_cs[1]);
(void)close(from_cs[0]);
#else
- /* MSWIN */
- /* Create pipes to communicate with cscope */
+ // MSWIN
+ // Create pipes to communicate with cscope
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
@@ -862,30 +862,30 @@ err_closing:
return CSCOPE_FAILURE;
}
#endif
- /* expand the cscope exec for env var's */
+ // expand the cscope exec for env var's
if ((prog = alloc(MAXPATHL + 1)) == NULL)
{
#ifdef UNIX
return CSCOPE_FAILURE;
#else
- /* MSWIN */
+ // MSWIN
goto err_closing;
#endif
}
expand_env((char_u *)p_csprg, (char_u *)prog, MAXPATHL);
- /* alloc space to hold the cscope command */
+ // alloc space to hold the cscope command
len = (int)(strlen(prog) + strlen(csinfo[i].fname) + 32);
if (csinfo[i].ppath)
{
- /* expand the prepend path for env var's */
+ // expand the prepend path for env var's
if ((ppath = alloc(MAXPATHL + 1)) == NULL)
{
vim_free(prog);
#ifdef UNIX
return CSCOPE_FAILURE;
#else
- /* MSWIN */
+ // MSWIN
goto err_closing;
#endif
}
@@ -904,16 +904,16 @@ err_closing:
#ifdef UNIX
return CSCOPE_FAILURE;
#else
- /* MSWIN */
+ // MSWIN
goto err_closing;
#endif
}
- /* run the cscope command; is there execl for non-unix systems? */
+ // run the cscope command; is there execl for non-unix systems?
#if defined(UNIX)
(void)sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname);
#else
- /* MSWIN */
+ // MSWIN
(void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname);
#endif
if (csinfo[i].ppath != NULL)
@@ -927,14 +927,14 @@ err_closing:
(void)strcat(cmd, csinfo[i].flags);
}
# ifdef UNIX
- /* on Win32 we still need prog */
+ // on Win32 we still need prog
vim_free(prog);
# endif
vim_free(ppath);
#if defined(UNIX)
# if defined(HAVE_SETSID) || defined(HAVE_SETPGID)
- /* Change our process group to avoid cscope receiving SIGWINCH. */
+ // Change our process group to avoid cscope receiving SIGWINCH.
# if defined(HAVE_SETSID)
(void)setsid();
# else
@@ -946,8 +946,8 @@ err_closing:
PERROR(_("cs_create_connection exec failed"));
exit(127);
- /* NOTREACHED */
- default: /* parent. */
+ // NOTREACHED
+ default: // parent.
/*
* Save the file descriptors for later duplication, and
* reopen as streams.
@@ -957,7 +957,7 @@ err_closing:
if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL)
PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
- /* close unused */
+ // close unused
(void)close(to_cs[0]);
(void)close(from_cs[1]);
@@ -965,11 +965,11 @@ err_closing:
}
#else
- /* MSWIN */
- /* Create a new process to run cscope and use pipes to talk with it */
+ // MSWIN
+ // Create a new process to run cscope and use pipes to talk with it
GetStartupInfo(&si);
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
- si.wShowWindow = SW_HIDE; /* Hide child application window */
+ si.wShowWindow = SW_HIDE; // Hide child application window
si.hStdOutput = stdout_wr;
si.hStdError = stdout_wr;
si.hStdInput = stdin_rd;
@@ -984,12 +984,12 @@ err_closing:
(void)emsg(_("E623: Could not spawn cscope process"));
goto err_closing;
}
- /* else */
+ // else
csinfo[i].pid = pi.dwProcessId;
csinfo[i].hProc = pi.hProcess;
CloseHandle(pi.hThread);
- /* TODO - tidy up after failure to create files on pipe handles. */
+ // TODO - tidy up after failure to create files on pipe handles.
if (((fd = _open_osfhandle((OPEN_OH_ARGTYPE)stdin_wr,
_O_TEXT|_O_APPEND)) < 0)
|| ((csinfo[i].to_fp = _fdopen(fd, "w")) == NULL))
@@ -999,14 +999,14 @@ err_closing:
|| ((csinfo[i].fr_fp = _fdopen(fd, "r")) == NULL))
PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
- /* Close handles for file descriptors inherited by the cscope process */
+ // Close handles for file descriptors inherited by the cscope process
CloseHandle(stdin_rd);
CloseHandle(stdout_wr);
-#endif /* !UNIX */
+#endif // !UNIX
return CSCOPE_SUCCESS;
-} /* cs_create_connection */
+}
/*
@@ -1050,7 +1050,7 @@ cs_find(exarg_T *eap)
return cs_find_common(opt, pat, eap->forceit, TRUE,
eap->cmdidx == CMD_lcscope, *eap->cmdlinep);
-} /* cs_find */
+}
/*
@@ -1073,7 +1073,7 @@ cs_find_common(
char cmdletter;
char *qfpos;
- /* get cmd letter */
+ // get cmd letter
switch (opt[0])
{
case '0' :
@@ -1111,13 +1111,13 @@ cs_find_common(
if (qfpos != NULL)
{
qfpos++;
- /* next symbol must be + or - */
+ // next symbol must be + or -
if (strchr(CSQF_FLAGS, *qfpos) == NULL)
{
char *nf = _("E469: invalid cscopequickfix flag %c for %c");
char *buf = alloc(strlen(nf));
- /* strlen will be enough because we use chars */
+ // strlen will be enough because we use chars
if (buf != NULL)
{
sprintf(buf, nf, *qfpos, *(qfpos-1));
@@ -1139,7 +1139,7 @@ cs_find_common(
}
#endif
- /* create the actual command to send to cscope */
+ // create the actual command to send to cscope
cmd = cs_create_cmd(opt, pat);
if (cmd == NULL)
return FALSE;
@@ -1151,8 +1151,8 @@ cs_find_common(
return FALSE;
}
- /* Send query to all open connections, then count the total number
- * of matches so we can alloc all in one swell foop. */
+ // Send query to all open connections, then count the total number
+ // of matches so we can alloc all in one swell foop.
for (i = 0; i < csinfo_size; i++)
nummatches[i] = 0;
totmatches = 0;
@@ -1161,7 +1161,7 @@ cs_find_common(
if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL)
continue;
- /* send cmd to cscope */
+ // send cmd to cscope
(void)fprintf(csinfo[i].to_fp, "%s\n", cmd);
(void)fflush(csinfo[i].to_fp);
@@ -1202,7 +1202,7 @@ cs_find_common(
#ifdef FEAT_QUICKFIX
if (qfpos != NULL && *qfpos != '0' && totmatches > 0)
{
- /* fill error list */
+ // fill error list
FILE *f;
char_u *tmp = vim_tempname('c', TRUE);
qf_info_T *qi = NULL;
@@ -1215,9 +1215,9 @@ cs_find_common(
{
cs_file_results(f, nummatches);
fclose(f);
- if (use_ll) /* Use location list */
+ if (use_ll) // Use location list
wp = curwin;
- /* '-' starts a new error list */
+ // '-' starts a new error list
if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m",
*qfpos == '-', cmdline, NULL) > 0)
{
@@ -1247,12 +1247,12 @@ cs_find_common(
return TRUE;
}
else
-#endif /* FEAT_QUICKFIX */
+#endif // FEAT_QUICKFIX
{
char **matches = NULL, **contexts = NULL;
int matched = 0;
- /* read output */
+ // read output
cs_fill_results((char *)pat, totmatches, nummatches, &matches,
&contexts, &matched);
vim_free(nummatches);
@@ -1264,7 +1264,7 @@ cs_find_common(
return do_tag((char_u *)pat, DT_CSCOPE, 0, forceit, verbose);
}
-} /* cs_find_common */
+}
/*
* Print help.
@@ -1280,7 +1280,7 @@ cs_help(exarg_T *eap UNUSED)
char *help = _(cmdp->help);
int space_cnt = 30 - vim_strsize((char_u *)help);
- /* Use %*s rather than %30s to ensure proper alignment in utf-8 */
+ // Use %*s rather than %30s to ensure proper alignment in utf-8
if (space_cnt < 0)
space_cnt = 0;
(void)smsg(_("%-5s: %s%*s (Usage: %s)"),
@@ -1304,7 +1304,7 @@ cs_help(exarg_T *eap UNUSED)
wait_return(TRUE);
return 0;
-} /* cs_help */
+}
static void
@@ -1338,7 +1338,7 @@ GetWin32Error(void)
NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL);
if (msg != NULL)
{
- /* remove trailing \r\n */
+ // remove trailing \r\n
char *pcrlf = strstr(msg, "\r\n");
if (pcrlf != NULL)
*pcrlf = '\0';
@@ -1363,8 +1363,8 @@ cs_insert_filelist(
switch (win32_fileinfo((char_u *)fname, &bhfi))
{
- case FILEINFO_ENC_FAIL: /* enc_to_utf16() failed */
- case FILEINFO_READ_FAIL: /* CreateFile() failed */
+ case FILEINFO_ENC_FAIL: // enc_to_utf16() failed
+ case FILEINFO_READ_FAIL: // CreateFile() failed
if (p_csverbose)
{
char *cant_msg = _("E625: cannot open cscope database: %s");
@@ -1376,19 +1376,19 @@ cs_insert_filelist(
LocalFree(winmsg);
}
else
- /* subst filename if can't get error text */
+ // subst filename if can't get error text
(void)semsg(cant_msg, fname);
}
return -1;
- case FILEINFO_INFO_FAIL: /* GetFileInformationByHandle() failed */
+ case FILEINFO_INFO_FAIL: // GetFileInformationByHandle() failed
if (p_csverbose)
(void)emsg(_("E626: cannot get cscope database information"));
return -1;
}
#endif
- i = -1; /* can be set to the index of an empty item in csinfo */
+ i = -1; // can be set to the index of an empty item in csinfo
for (j = 0; j < csinfo_size; j++)
{
if (csinfo[j].fname != NULL
@@ -1411,7 +1411,7 @@ cs_insert_filelist(
}
if (csinfo[j].fname == NULL && i == -1)
- i = j; /* remember first empty entry */
+ i = j; // remember first empty entry
}
if (i == -1)
@@ -1419,9 +1419,9 @@ cs_insert_filelist(
i = csinfo_size;
if (csinfo_size == 0)
{
- /* First time allocation: allocate only 1 connection. It should
- * be enough for most users. If more is needed, csinfo will be
- * reallocated. */
+ // First time allocation: allocate only 1 connection. It should
+ // be enough for most users. If more is needed, csinfo will be
+ // reallocated.
csinfo_size = 1;
csinfo = ALLOC_CLEAR_ONE(csinfo_T);
}
@@ -1429,7 +1429,7 @@ cs_insert_filelist(
{
csinfo_T *t_csinfo = csinfo;
- /* Reallocate space for more connections. */
+ // Reallocate space for more connections.
csinfo_size *= 2;
csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size);
if (csinfo == NULL)
@@ -1482,7 +1482,7 @@ cs_insert_filelist(
csinfo[i].nIndexHigh = bhfi.nFileIndexHigh;
#endif
return i;
-} /* cs_insert_filelist */
+}
/*
@@ -1498,7 +1498,7 @@ cs_lookup_cmd(exarg_T *eap)
if (eap->arg == NULL)
return NULL;
- /* Store length of eap->arg before it gets modified by strtok(). */
+ // Store length of eap->arg before it gets modified by strtok().
eap_arg_len = (int)STRLEN(eap->arg);
if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL)
@@ -1511,7 +1511,7 @@ cs_lookup_cmd(exarg_T *eap)
return (cmdp);
}
return NULL;
-} /* cs_lookup_cmd */
+}
/*
@@ -1529,16 +1529,15 @@ cs_kill(exarg_T *eap UNUSED)
return CSCOPE_FAILURE;
}
- /* only single digit positive and negative integers are allowed */
+ // only single digit positive and negative integers are allowed
if ((strlen(stok) < 2 && VIM_ISDIGIT((int)(stok[0])))
|| (strlen(stok) < 3 && stok[0] == '-'
&& VIM_ISDIGIT((int)(stok[1]))))
i = atoi(stok);
else
{
- /* It must be part of a name. We will try to find a match
- * within all the names in the csinfo data structure
- */
+ // It must be part of a name. We will try to find a match
+ // within all the names in the csinfo data structure
for (i = 0; i < csinfo_size; i++)
{
if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok))
@@ -1566,7 +1565,7 @@ cs_kill(exarg_T *eap UNUSED)
}
return 0;
-} /* cs_kill */
+}
/*
@@ -1574,8 +1573,8 @@ cs_kill(exarg_T *eap UNUSED)
*/
static void
cs_kill_execute(
- int i, /* cscope table index */
- char *cname) /* cscope database name */
+ int i, // cscope table index
+ char *cname) // cscope database name
{
if (p_csverbose)
{
@@ -1612,17 +1611,16 @@ cs_make_vim_style_matches(
char *search,
char *tagstr)
{
- /* vim style is ctags:
- *
- * <tagstr>\t<filename>\t<linenum_or_search>"\t<extra>
- *
- * but as mentioned above, we'll always use the line number and
- * put the search pattern (if one exists) as "extra"
- *
- * buf is used as part of vim's method of handling tags, and
- * (i think) vim frees it when you pop your tags and get replaced
- * by new ones on the tag stack.
- */
+ // vim style is ctags:
+ //
+ // <tagstr>\t<filename>\t<linenum_or_search>"\t<extra>
+ //
+ // but as mentioned above, we'll always use the line number and
+ // put the search pattern (if one exists) as "extra"
+ //
+ // buf is used as part of vim's method of handling tags, and
+ // (i think) vim frees it when you pop your tags and get replaced
+ // by new ones on the tag stack.
char *buf;
int amt;
@@ -1644,7 +1642,7 @@ cs_make_vim_style_matches(
}
return buf;
-} /* cs_make_vim_style_matches */
+}
/*
@@ -1716,13 +1714,13 @@ cs_manage_matches(
case Print:
cs_print_tags_priv(mp, cp, cnt);
break;
- default: /* should not reach here */
+ default: // should not reach here
iemsg(_("E570: fatal error in cs_manage_matches"));
return NULL;
}
return p;
-} /* cs_manage_matches */
+}
/*
@@ -1751,7 +1749,7 @@ cs_parse_results(
return NULL;
}
- /* If the line's too long for the buffer, discard it. */
+ // If the line's too long for the buffer, discard it.
if ((p = strchr(buf, '\n')) == NULL)
{
while ((ch = getc(csinfo[cnumber].fr_fp)) != EOF && ch != '\n')
@@ -1771,13 +1769,12 @@ cs_parse_results(
return NULL;
if ((*linenumber = strtok(NULL, (const char *)" ")) == NULL)
return NULL;
- *search = *linenumber + strlen(*linenumber) + 1; /* +1 to skip \0 */
+ *search = *linenumber + strlen(*linenumber) + 1; // +1 to skip \0
- /* --- nvi ---
- * If the file is older than the cscope database, that is,
- * the database was built since the file was last modified,
- * or there wasn't a search string, use the line number.
- */
+ // --- nvi ---
+ // If the file is older than the cscope database, that is,
+ // the database was built since the file was last modified,
+ // or there wasn't a search string, use the line number.
if (strcmp(*search, "<unknown>") == 0)
*search = NULL;
@@ -1830,11 +1827,11 @@ cs_file_results(FILE *f, int *nummatches_a)
vim_free(context);
vim_free(fullname);
- } /* for all matches */
+ } // for all matches
(void)cs_read_prompt(i);
- } /* for all cscope connections */
+ } // for all cscope connections
vim_free(buf);
}
#endif
@@ -1892,24 +1889,23 @@ cs_fill_results(
if (strcmp(cntx, "<global>") == 0)
cntxts[totsofar] = NULL;
else
- /* note: if vim_strsave returns NULL, then the context
- * will be "<global>", which is misleading.
- */
+ // note: if vim_strsave returns NULL, then the context
+ // will be "<global>", which is misleading.
cntxts[totsofar] = (char *)vim_strsave((char_u *)cntx);
if (matches[totsofar] != NULL)
totsofar++;
- } /* for all matches */
+ } // for all matches
(void)cs_read_prompt(i);
- } /* for all cscope connections */
+ } // for all cscope connections
parse_out:
if (totsofar == 0)
{
- /* No matches, free the arrays and return NULL in "*matches_p". */
+ // No matches, free the arrays and return NULL in "*matches_p".
VIM_CLEAR(matches);
VIM_CLEAR(cntxts);
}
@@ -1918,10 +1914,12 @@ parse_out:
*cntxts_p = cntxts;
vim_free(buf);
-} /* cs_fill_results */
+}
-/* get the requested path components */
+/*
+ * get the requested path components
+ */
static char *
cs_pathcomponents(char *path)
{
@@ -1956,7 +1954,7 @@ cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
{
char *buf = NULL;
char *t_buf;
- int bufsize = 0; /* Track available bufsize */
+ int bufsize = 0; // Track available bufsize
int newsize = 0;
char *ptag;
char *fname, *lno, *extra, *tbuf;
@@ -1991,7 +1989,7 @@ cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
vim_free(tbuf);
- msg_puts_attr(_("\n # line"), HL_ATTR(HLF_T)); /* strlen is 7 */
+ msg_puts_attr(_("\n # line"), HL_ATTR(HLF_T)); // strlen is 7
msg_advance(msg_col + 2);
msg_puts_attr(_("filename / context / line\n"), HL_ATTR(HLF_T));
@@ -2000,10 +1998,9 @@ cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
{
idx = i;
- /* if we really wanted to, we could avoid this malloc and strcpy
- * by parsing matches[i] on the fly and placing stuff into buf
- * directly, but that's too much of a hassle
- */
+ // if we really wanted to, we could avoid this malloc and strcpy
+ // by parsing matches[i] on the fly and placing stuff into buf
+ // directly, but that's too much of a hassle
if ((tbuf = alloc(strlen(matches[idx]) + 1)) == NULL)
continue;
(void)strcpy(tbuf, matches[idx]);
@@ -2017,9 +2014,9 @@ cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
}
extra = strtok(NULL, (const char *)"\t");
- lno[strlen(lno)-2] = '\0'; /* ignore ;" at the end */
+ lno[strlen(lno)-2] = '\0'; // ignore ;" at the end
- /* hopefully 'num' (num of matches) will be less than 10^16 */
+ // hopefully 'num' (num of matches) will be less than 10^16
newsize = (int)(strlen(csfmt_str) + 16 + strlen(lno));
if (bufsize < newsize)
{
@@ -2035,14 +2032,14 @@ cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
}
if (buf != NULL)
{
- /* csfmt_str = "%4d %6s "; */
+ // csfmt_str = "%4d %6s ";
(void)sprintf(buf, csfmt_str, num, lno);
msg_puts_attr(buf, HL_ATTR(HLF_CM));
}
msg_outtrans_long_attr((char_u *)cs_pathcomponents(fname),
HL_ATTR(HLF_CM));
- /* compute the required space for the context */
+ // compute the required space for the context
if (cntxts[idx] != NULL)
context = cntxts[idx];
else
@@ -2065,7 +2062,7 @@ cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
{
(void)sprintf(buf, cntxformat, context);
- /* print the context only if it fits on the same line */
+ // print the context only if it fits on the same line
if (msg_col + (int)strlen(buf) >= (int)Columns)
msg_putchar('\n');
msg_advance(12);
@@ -2078,7 +2075,7 @@ cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
msg_outtrans_long_attr((char_u *)extra, 0);
}
- vim_free(tbuf); /* only after printing extra due to strtok use */
+ vim_free(tbuf); // only after printing extra due to strtok use
if (msg_col)
msg_putchar('\n');
@@ -2086,15 +2083,15 @@ cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
ui_breakcheck();
if (got_int)
{
- got_int = FALSE; /* don't print any more matches */
+ got_int = FALSE; // don't print any more matches
break;
}
num++;
- } /* for all matches */
+ } // for all matches
vim_free(buf);
-} /* cs_print_tags_priv */
+}
/*
@@ -2104,7 +2101,7 @@ cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
cs_read_prompt(int i)
{
int ch;
- char *buf = NULL; /* buffer for possible error message from cscope */
+ char *buf = NULL; // buffer for possible error message from cscope
int bufpos = 0;
char *cs_emsg;
int maxlen;
@@ -2113,36 +2110,36 @@ cs_read_prompt(int i)
int n;
cs_emsg = _("E609: Cscope error: %s");
- /* compute maximum allowed len for Cscope error message */
+ // compute maximum allowed len for Cscope error message
maxlen = (int)(IOSIZE - strlen(cs_emsg));
for (;;)
{
while ((ch = getc(csinfo[i].fr_fp)) != EOF && ch != CSCOPE_PROMPT[0])
- /* if there is room and char is printable */
+ // if there is room and char is printable
if (bufpos < maxlen - 1 && vim_isprintc(ch))
{
- if (buf == NULL) /* lazy buffer allocation */
+ if (buf == NULL) // lazy buffer allocation
buf = alloc(maxlen);
if (buf != NULL)
{
- /* append character to the message */
+ // append character to the message
buf[bufpos++] = ch;
buf[bufpos] = NUL;
if (bufpos >= epromptlen
&& strcmp(&buf[bufpos - epromptlen], eprompt) == 0)
{
- /* remove eprompt from buf */
+ // remove eprompt from buf
buf[bufpos - epromptlen] = NUL;
- /* print message to user */
+ // print message to user
(void)semsg(cs_emsg, buf);
- /* send RETURN to cscope */
+ // send RETURN to cscope
(void)putc('\n', csinfo[i].to_fp);
(void)fflush(csinfo[i].to_fp);
- /* clear buf */
+ // clear buf
bufpos = 0;
buf[bufpos] = NUL;
}
@@ -2159,7 +2156,7 @@ cs_read_prompt(int i)
if (buf != NULL && buf[0] != NUL)
(void)semsg(cs_emsg, buf);
else if (p_csverbose)
- cs_reading_emsg(i); /* don't have additional information */
+ cs_reading_emsg(i); // don't have additional information
cs_release_csp(i, TRUE);
vim_free(buf);
return CSCOPE_FAILURE;
@@ -2173,8 +2170,8 @@ cs_read_prompt(int i)
}
if (ch == EOF)
- continue; /* didn't find the prompt */
- break; /* did find the prompt */
+ continue; // didn't find the prompt
+ break; // did find the prompt
}
vim_free(buf);
@@ -2188,7 +2185,7 @@ cs_read_prompt(int i)
static RETSIGTYPE
sig_handler SIGDEFARG(sigarg)
{
- /* do nothing */
+ // do nothing
SIGRETURN;
}
#endif
@@ -2217,7 +2214,7 @@ cs_release_csp(int i, int freefnpp)
# if defined(HAVE_SIGACTION)
struct sigaction sa, old;
- /* Use sigaction() to limit the waiting time to two seconds. */
+ // Use sigaction() to limit the waiting time to two seconds.
sigemptyset(&sa.sa_mask);
sa.sa_handler = sig_handler;
# ifdef SA_NODEFER
@@ -2226,28 +2223,28 @@ cs_release_csp(int i, int freefnpp)
sa.sa_flags = 0;
# endif
sigaction(SIGALRM, &sa, &old);
- alarm(2); /* 2 sec timeout */
+ alarm(2); // 2 sec timeout
- /* Block until cscope exits or until timer expires */
+ // Block until cscope exits or until timer expires
pid = waitpid(csinfo[i].pid, &pstat, 0);
waitpid_errno = errno;
- /* cancel pending alarm if still there and restore signal */
+ // cancel pending alarm if still there and restore signal
alarm(0);
sigaction(SIGALRM, &old, NULL);
# else
int waited;
- /* Can't use sigaction(), loop for two seconds. First yield the CPU
- * to give cscope a chance to exit quickly. */
+ // Can't use sigaction(), loop for two seconds. First yield the CPU
+ // to give cscope a chance to exit quickly.
sleep(0);
for (waited = 0; waited < 40; ++waited)
{
pid = waitpid(csinfo[i].pid, &pstat, WNOHANG);
waitpid_errno = errno;
if (pid != 0)
- break; /* break unless the process is still running */
- mch_delay(50L, FALSE); /* sleep 50 ms */
+ break; // break unless the process is still running
+ mch_delay(50L, FALSE); // sleep 50 ms
}
# endif
/*
@@ -2276,13 +2273,13 @@ cs_release_csp(int i, int freefnpp)
sleep(0);
for (waited = 0; waited < 40; ++waited)
{
- /* Check whether cscope process is still alive */
+ // Check whether cscope process is still alive
if (kill(csinfo[i].pid, 0) != 0)
{
- alive = FALSE; /* cscope process no longer exists */
+ alive = FALSE; // cscope process no longer exists
break;
}
- mch_delay(50L, FALSE); /* sleep 50ms */
+ mch_delay(50L, FALSE); // sleep 50ms
}
}
if (alive)
@@ -2293,10 +2290,10 @@ cs_release_csp(int i, int freefnpp)
}
}
}
-#else /* !UNIX */
+#else // !UNIX
if (csinfo[i].hProc != NULL)
{
- /* Give cscope a chance to exit normally */
+ // Give cscope a chance to exit normally
if (WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
TerminateProcess(csinfo[i].hProc, 0);
CloseHandle(csinfo[i].hProc);
@@ -2316,7 +2313,7 @@ cs_release_csp(int i, int freefnpp)
}
clear_csinfo(i);
-} /* cs_release_csp */
+}
/*
@@ -2327,12 +2324,12 @@ cs_reset(exarg_T *eap UNUSED)
{
char **dblist = NULL, **pplist = NULL, **fllist = NULL;
int i;
- char buf[20]; /* for sprintf " (#%d)" */
+ char buf[20]; // for sprintf " (#%d)"
if (csinfo_size == 0)
return CSCOPE_SUCCESS;
- /* malloc our db and ppath list */
+ // malloc our db and ppath list
dblist = ALLOC_MULT(char *, csinfo_size);
pplist = ALLOC_MULT(char *, csinfo_size);
fllist = ALLOC_MULT(char *, csinfo_size);
@@ -2353,7 +2350,7 @@ cs_reset(exarg_T *eap UNUSED)
cs_release_csp(i, FALSE);
}
- /* rebuild the cscope connection list */
+ // rebuild the cscope connection list
for (i = 0; i < csinfo_size; i++)
{
if (dblist[i] != NULL)
@@ -2361,10 +2358,9 @@ cs_reset(exarg_T *eap UNUSED)
cs_add_common(dblist[i], pplist[i], fllist[i]);
if (p_csverbose)
{
- /* don't use smsg_attr() because we want to display the
- * connection number in the same line as
- * "Added cscope database..."
- */
+ // don't use smsg_attr() because we want to display the
+ // connection number in the same line as
+ // "Added cscope database..."
sprintf(buf, " (#%d)", i);
msg_puts_attr(buf, HL_ATTR(HLF_R));
}
@@ -2380,7 +2376,7 @@ cs_reset(exarg_T *eap UNUSED)
if (p_csverbose)
msg_attr(_("All cscope databases reset"), HL_ATTR(HLF_R) | MSG_HIST);
return CSCOPE_SUCCESS;
-} /* cs_reset */
+}
/*
@@ -2409,8 +2405,8 @@ cs_resolve_file(int i, char *name)
len += (int)strlen(csinfo[i].ppath);
else if (p_csre && csinfo[i].fname != NULL)
{
- /* If 'cscoperelative' is set and ppath is not set, use cscope.out
- * path in path resolution. */
+ // If 'cscoperelative' is set and ppath is not set, use cscope.out
+ // path in path resolution.
csdir = alloc(MAXPATHL);
if (csdir != NULL)
{
@@ -2421,9 +2417,9 @@ cs_resolve_file(int i, char *name)
}
}
- /* Note/example: this won't work if the cscope output already starts
- * "../.." and the prefix path is also "../..". if something like this
- * happens, you are screwed up and need to fix how you're using cscope. */
+ // Note/example: this won't work if the cscope output already starts
+ // "../.." and the prefix path is also "../..". if something like this
+ // happens, you are screwed up and need to fix how you're using cscope.
if (csinfo[i].ppath != NULL
&& (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0)
&& (name[0] != '/')
@@ -2437,8 +2433,8 @@ cs_resolve_file(int i, char *name)
}
else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL)
{
- /* Check for csdir to be non empty to avoid empty path concatenated to
- * cscope output. */
+ // Check for csdir to be non empty to avoid empty path concatenated to
+ // cscope output.
fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE);
}
else
@@ -2481,7 +2477,7 @@ cs_show(exarg_T *eap UNUSED)
wait_return(TRUE);
return CSCOPE_SUCCESS;
-} /* cs_show */
+}
/*
@@ -2498,7 +2494,7 @@ cs_end(void)
csinfo_size = 0;
}
-#endif /* FEAT_CSCOPE */
+#endif // FEAT_CSCOPE
#if defined(FEAT_EVAL) || defined(PROTO)