.
This commit is contained in:
parent
00e707993c
commit
3c2fd1c829
13
README.md
13
README.md
@ -1,5 +1,5 @@
|
|||||||
# Csope
|
# Csope
|
||||||
Fork of Cscope, with various improvements, because cscope is good and shall not be forgotten.
|
Fork of Cscope version 15.9, with various improvements, because cscope is good and shall not be forgotten.
|
||||||
While the original's mainentence seems abandoned and as far as I can tell you need a PhD in autoconf to compile the latest version,
|
While the original's mainentence seems abandoned and as far as I can tell you need a PhD in autoconf to compile the latest version,
|
||||||
Csope is alive and well.
|
Csope is alive and well.
|
||||||
|
|
||||||
@ -77,26 +77,16 @@ fixing it would have been a lost cause, if not for Cscope itself. Well, Csope no
|
|||||||
| help.c | all functions dealing with help messages |
|
| help.c | all functions dealing with help messages |
|
||||||
|
|
||||||
# TODO /*move soon*/
|
# TODO /*move soon*/
|
||||||
+ recursive macro function to assign KEY_\* default values; look for a new and shiny preprocessor?
|
|
||||||
+ sort out constants.h
|
+ sort out constants.h
|
||||||
+ scrollbar() uses magic int literals?
|
+ scrollbar() uses magic int literals?
|
||||||
+ Ordering function declarations in global.h by alpha order is not smart
|
+ Ordering function declarations in global.h by alpha order is not smart
|
||||||
+ lineflagafterfile is stupid
|
+ lineflagafterfile is stupid
|
||||||
+ library.h...; "private library", in a program using 90 globals; ffs
|
+ library.h...; "private library", in a program using 90 globals; ffs
|
||||||
+ sort out the global hell
|
+ sort out the global hell
|
||||||
+ changestring() forks sh to execute an ed script...
|
|
||||||
+ was there really ever a scrollbar?
|
+ was there really ever a scrollbar?
|
||||||
## Original
|
## Original
|
||||||
+ Display the current case mode (^C) onscreen
|
|
||||||
+ emacs like key bindings
|
|
||||||
^S for searching (^Y)
|
|
||||||
Up/dwn Arrow support Next/Prev field. ??
|
|
||||||
Inline editing on Input fields ( ??^B/^F )
|
|
||||||
^X^C to quit ( ^Q ??)
|
|
||||||
Pagdwn/PageUp/+/-
|
|
||||||
+ Same capabilities as interactive in non interactive (one shot) mode
|
+ Same capabilities as interactive in non interactive (one shot) mode
|
||||||
+ Provide some how-do-I-use-this-thing doc.
|
+ Provide some how-do-I-use-this-thing doc.
|
||||||
+ Replace invlib.[ch] by real database. Failing that, at least sanitize it.
|
|
||||||
|
|
||||||
|
|
||||||
# BUGS
|
# BUGS
|
||||||
@ -104,6 +94,7 @@ fixing it would have been a lost cause, if not for Cscope itself. Well, Csope no
|
|||||||
free(): double free detected in tcache 2
|
free(): double free detected in tcache 2
|
||||||
Aborted
|
Aborted
|
||||||
+ Changing text can crash without replacing text and leaving the console ncursed
|
+ Changing text can crash without replacing text and leaving the console ncursed
|
||||||
|
+ The wrong number of lines are bing printed
|
||||||
|
|
||||||
# Future features / contributor wishlist
|
# Future features / contributor wishlist
|
||||||
+ providing support for other languages by integrating new lexers (e.g. ctag's)
|
+ providing support for other languages by integrating new lexers (e.g. ctag's)
|
||||||
|
41
src/build.c
41
src/build.c
@ -97,12 +97,10 @@ static bool samelist(FILE *oldrefs, char **names, int count);
|
|||||||
static void
|
static void
|
||||||
cannotindex(void)
|
cannotindex(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\
|
fprintf(stderr, PROGRAM_NAME ": cannot create inverted index; ignoring -q option\n");
|
||||||
cscope: cannot create inverted index; ignoring -q option\n");
|
|
||||||
invertedindex = false;
|
invertedindex = false;
|
||||||
errorsfound = true;
|
errorsfound = true;
|
||||||
fprintf(stderr, "\
|
fprintf(stderr, PROGRAM_NAME ": removed files %s and %s\n",
|
||||||
cscope: removed files %s and %s\n",
|
|
||||||
newinvname, newinvpost);
|
newinvname, newinvpost);
|
||||||
unlink(newinvname);
|
unlink(newinvname);
|
||||||
unlink(newinvpost);
|
unlink(newinvpost);
|
||||||
@ -232,7 +230,7 @@ build(void)
|
|||||||
/* or this is an unconditional build */
|
/* or this is an unconditional build */
|
||||||
if ((oldrefs = vpfopen(reffile, "rb")) != NULL
|
if ((oldrefs = vpfopen(reffile, "rb")) != NULL
|
||||||
&& unconditional == false
|
&& unconditional == false
|
||||||
&& fscanf(oldrefs, "cscope %d %" PATHLEN_STR "s", &fileversion, olddir) == 2
|
&& fscanf(oldrefs, PROGRAM_NAME " %d %" PATHLEN_STR "s", &fileversion, olddir) == 2
|
||||||
&& (strcmp(olddir, currentdir) == 0 /* remain compatible */
|
&& (strcmp(olddir, currentdir) == 0 /* remain compatible */
|
||||||
|| strcmp(olddir, newdir) == 0)) {
|
|| strcmp(olddir, newdir) == 0)) {
|
||||||
/* get the cross-reference file's modification time */
|
/* get the cross-reference file's modification time */
|
||||||
@ -267,15 +265,13 @@ build(void)
|
|||||||
}
|
}
|
||||||
/* check the old and new option settings */
|
/* check the old and new option settings */
|
||||||
if (oldcompress != compress || oldtruncate != trun_syms) {
|
if (oldcompress != compress || oldtruncate != trun_syms) {
|
||||||
posterr("\
|
posterr(PROGRAM_NAME ": -c or -T option mismatch between command line and old symbol database\n");
|
||||||
cscope: -c or -T option mismatch between command line and old symbol database\n");
|
|
||||||
goto force;
|
goto force;
|
||||||
}
|
}
|
||||||
if (oldinvertedindex != invertedindex) {
|
if (oldinvertedindex != invertedindex) {
|
||||||
posterr("\
|
posterr(PROGRAM_NAME ": -q option mismatch between command line and old symbol database\n");
|
||||||
cscope: -q option mismatch between command line and old symbol database\n");
|
|
||||||
if (invertedindex == false) {
|
if (invertedindex == false) {
|
||||||
posterr("cscope: removed files %s and %s\n",
|
posterr(PROGRAM_NAME ": removed files %s and %s\n",
|
||||||
invname, invpost);
|
invname, invpost);
|
||||||
unlink(invname);
|
unlink(invname);
|
||||||
unlink(invpost);
|
unlink(invpost);
|
||||||
@ -285,7 +281,7 @@ cscope: -q option mismatch between command line and old symbol database\n");
|
|||||||
/* seek to the trailer */
|
/* seek to the trailer */
|
||||||
if (fscanf(oldrefs, "%ld", &traileroffset) != 1 ||
|
if (fscanf(oldrefs, "%ld", &traileroffset) != 1 ||
|
||||||
fseek(oldrefs, traileroffset, SEEK_SET) == -1) {
|
fseek(oldrefs, traileroffset, SEEK_SET) == -1) {
|
||||||
posterr("cscope: incorrect symbol database file format\n");
|
posterr(PROGRAM_NAME ": incorrect symbol database file format\n");
|
||||||
goto force;
|
goto force;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,14 +320,13 @@ cscope: -q option mismatch between command line and old symbol database\n");
|
|||||||
outofdate:
|
outofdate:
|
||||||
/* if the database format has changed, rebuild it all */
|
/* if the database format has changed, rebuild it all */
|
||||||
if (fileversion != FILEVERSION) {
|
if (fileversion != FILEVERSION) {
|
||||||
fprintf(stderr, "\
|
fprintf(stderr, PROGRAM_NAME ": converting to new symbol database file format\n");
|
||||||
cscope: converting to new symbol database file format\n");
|
|
||||||
goto force;
|
goto force;
|
||||||
}
|
}
|
||||||
/* reopen the old cross-reference file for fast scanning */
|
/* reopen the old cross-reference file for fast scanning */
|
||||||
if ((symrefs = vpopen(reffile, O_BINARY | O_RDONLY)) == -1) {
|
if ((symrefs = vpopen(reffile, O_BINARY | O_RDONLY)) == -1) {
|
||||||
postfatal("cscope: cannot open file %s\n", reffile);
|
postfatal(PROGRAM_NAME ": cannot open file %s\n", reffile);
|
||||||
/* falseTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
/* get the first file name in the old cross-reference */
|
/* get the first file name in the old cross-reference */
|
||||||
blocknumber = -1;
|
blocknumber = -1;
|
||||||
@ -345,8 +340,8 @@ cscope: converting to new symbol database file format\n");
|
|||||||
}
|
}
|
||||||
/* open the new cross-reference file */
|
/* open the new cross-reference file */
|
||||||
if ((newrefs = myfopen(newreffile, "wb")) == NULL) {
|
if ((newrefs = myfopen(newreffile, "wb")) == NULL) {
|
||||||
postfatal("cscope: cannot open file %s\n", reffile);
|
postfatal(PROGRAM_NAME ": cannot open file %s\n", reffile);
|
||||||
/* falseTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
if (invertedindex == true && (postings = myfopen(temp1, "wb")) == NULL) {
|
if (invertedindex == true && (postings = myfopen(temp1, "wb")) == NULL) {
|
||||||
cannotwrite(temp1);
|
cannotwrite(temp1);
|
||||||
@ -456,7 +451,7 @@ cscope: converting to new symbol database file format\n");
|
|||||||
fclose(postings);
|
fclose(postings);
|
||||||
snprintf(sortcommand, sizeof(sortcommand), "env LC_ALL=C sort -T %s %s", tmpdir, temp1);
|
snprintf(sortcommand, sizeof(sortcommand), "env LC_ALL=C sort -T %s %s", tmpdir, temp1);
|
||||||
if ((postings = mypopen(sortcommand, "r")) == NULL) {
|
if ((postings = mypopen(sortcommand, "r")) == NULL) {
|
||||||
fprintf(stderr, "cscope: cannot open pipe to sort command\n");
|
fprintf(stderr, PROGRAM_NAME ": cannot open pipe to sort command\n");
|
||||||
cannotindex();
|
cannotindex();
|
||||||
} else {
|
} else {
|
||||||
if ((totalterms = invmake(newinvname, newinvpost, postings)) > 0) {
|
if ((totalterms = invmake(newinvname, newinvpost, postings)) > 0) {
|
||||||
@ -503,11 +498,11 @@ void
|
|||||||
seek_to_trailer(FILE *f)
|
seek_to_trailer(FILE *f)
|
||||||
{
|
{
|
||||||
if (fscanf(f, "%ld", &traileroffset) != 1) {
|
if (fscanf(f, "%ld", &traileroffset) != 1) {
|
||||||
postfatal("cscope: cannot read trailer offset from file %s\n", reffile);
|
postfatal(PROGRAM_NAME ": cannot read trailer offset from file %s\n", reffile);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
if (fseek(f, traileroffset, SEEK_SET) == -1) {
|
if (fseek(f, traileroffset, SEEK_SET) == -1) {
|
||||||
postfatal("cscope: cannot seek to trailer in file %s\n", reffile);
|
postfatal(PROGRAM_NAME ": cannot seek to trailer in file %s\n", reffile);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -549,7 +544,7 @@ void free_newbuildfiles(void)
|
|||||||
static void
|
static void
|
||||||
putheader(char *dir)
|
putheader(char *dir)
|
||||||
{
|
{
|
||||||
dboffset = fprintf(newrefs, "cscope %d %s", FILEVERSION, dir);
|
dboffset = fprintf(newrefs, PROGRAM_NAME " %d %s", FILEVERSION, dir);
|
||||||
if (compress == false) {
|
if (compress == false) {
|
||||||
dboffset += fprintf(newrefs, " -c");
|
dboffset += fprintf(newrefs, " -c");
|
||||||
}
|
}
|
||||||
@ -718,8 +713,8 @@ movefile(char *new, char *old)
|
|||||||
{
|
{
|
||||||
unlink(old);
|
unlink(old);
|
||||||
if (rename(new, old) == -1) {
|
if (rename(new, old) == -1) {
|
||||||
myperror("cscope");
|
myperror(PROGRAM_NAME);
|
||||||
postfatal("cscope: cannot rename file %s to file %s\n",
|
postfatal(PROGRAM_NAME ": cannot rename file %s to file %s\n",
|
||||||
new, old);
|
new, old);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ void
|
|||||||
warning(char *text)
|
warning(char *text)
|
||||||
{
|
{
|
||||||
|
|
||||||
(void) fprintf(stderr, "cscope: \"%s\", line %d: warning: %s\n", filename,
|
(void) fprintf(stderr, PROGRAM_NAME ": \"%s\", line %d: warning: %s\n", filename,
|
||||||
myylineno, text);
|
myylineno, text);
|
||||||
errorsfound = true;
|
errorsfound = true;
|
||||||
}
|
}
|
||||||
|
16
src/dir.c
16
src/dir.c
@ -93,7 +93,7 @@ makevpsrcdirs(void)
|
|||||||
}
|
}
|
||||||
/* get the current directory name */
|
/* get the current directory name */
|
||||||
if (getcwd(currentdir, PATHLEN) == NULL) {
|
if (getcwd(currentdir, PATHLEN) == NULL) {
|
||||||
fprintf(stderr, "cscope: warning: cannot get current directory name\n");
|
fprintf(stderr, PROGRAM_NAME ": warning: cannot get current directory name\n");
|
||||||
strcpy(currentdir, "<unknown>");
|
strcpy(currentdir, "<unknown>");
|
||||||
}
|
}
|
||||||
/* see if there is a view path and this directory is in it */
|
/* see if there is a view path and this directory is in it */
|
||||||
@ -283,7 +283,7 @@ makefilelist(void)
|
|||||||
if ((s = inviewpath(file)) != NULL) {
|
if ((s = inviewpath(file)) != NULL) {
|
||||||
addsrcfile(s);
|
addsrcfile(s);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "cscope: cannot find file %s\n",
|
fprintf(stderr, PROGRAM_NAME ": cannot find file %s\n",
|
||||||
file);
|
file);
|
||||||
errorsfound = true;
|
errorsfound = true;
|
||||||
}
|
}
|
||||||
@ -337,8 +337,7 @@ makefilelist(void)
|
|||||||
if (unfinished_option) {
|
if (unfinished_option) {
|
||||||
/* Can't have another option directly after an
|
/* Can't have another option directly after an
|
||||||
* -I or -p option with no name after it! */
|
* -I or -p option with no name after it! */
|
||||||
fprintf(stderr, "\
|
fprintf(stderr, PROGRAM_NAME ": Syntax error in namelist file %s: unfinished -I or -p option\n",
|
||||||
cscope: Syntax error in namelist file %s: unfinished -I or -p option\n",
|
|
||||||
namefile);
|
namefile);
|
||||||
unfinished_option = 0;
|
unfinished_option = 0;
|
||||||
}
|
}
|
||||||
@ -382,8 +381,7 @@ cscope: Syntax error in namelist file %s: unfinished -I or -p option\n",
|
|||||||
break; \
|
break; \
|
||||||
case 'p': /* file path components to display */ \
|
case 'p': /* file path components to display */ \
|
||||||
if (*(s) < '0' || *(s) > '9') { \
|
if (*(s) < '0' || *(s) > '9') { \
|
||||||
fprintf(stderr, \
|
fprintf(stderr, "csope: -p option in file %s: missing or invalid numeric value\n", \
|
||||||
"cscope: -p option in file %s: missing or invalid numeric value\n", \
|
|
||||||
namefile); \
|
namefile); \
|
||||||
} \
|
} \
|
||||||
dispcomponents = atoi(s); \
|
dispcomponents = atoi(s); \
|
||||||
@ -398,7 +396,7 @@ cscope: Syntax error in namelist file %s: unfinished -I or -p option\n",
|
|||||||
HANDLE_OPTION_ARGUMENT(i, s)
|
HANDLE_OPTION_ARGUMENT(i, s)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "cscope: only -I, -c, -k, -p, and -T options can be in file %s\n",
|
fprintf(stderr, PROGRAM_NAME ": only -I, -c, -k, -p, and -T options can be in file %s\n",
|
||||||
namefile);
|
namefile);
|
||||||
} /* switch(i) */
|
} /* switch(i) */
|
||||||
} /* if('-') */
|
} /* if('-') */
|
||||||
@ -437,7 +435,7 @@ cscope: Syntax error in namelist file %s: unfinished -I or -p option\n",
|
|||||||
if ((s = inviewpath(newpath)) != NULL) {
|
if ((s = inviewpath(newpath)) != NULL) {
|
||||||
addsrcfile(s);
|
addsrcfile(s);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "cscope: cannot find file %s\n",
|
fprintf(stderr, PROGRAM_NAME, ": cannot find file %s\n",
|
||||||
newpath);
|
newpath);
|
||||||
errorsfound = true;
|
errorsfound = true;
|
||||||
}
|
}
|
||||||
@ -454,7 +452,7 @@ cscope: Syntax error in namelist file %s: unfinished -I or -p option\n",
|
|||||||
if ((s = inviewpath(path)) != NULL) {
|
if ((s = inviewpath(path)) != NULL) {
|
||||||
addsrcfile(s);
|
addsrcfile(s);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "cscope: cannot find file %s\n",
|
fprintf(stderr, PROGRAM_NAME ": cannot find file %s\n",
|
||||||
path);
|
path);
|
||||||
errorsfound = true;
|
errorsfound = true;
|
||||||
}
|
}
|
||||||
|
@ -170,10 +170,10 @@ dispinit(void)
|
|||||||
mode_window_height = LINES - input_window_height - 2 - 1;
|
mode_window_height = LINES - input_window_height - 2 - 1;
|
||||||
first_col_width = 48; // (((COLS - 2)%2 == 0) ? ((COLS-2)/2) : (((COLS-2)/2)+1));
|
first_col_width = 48; // (((COLS - 2)%2 == 0) ? ((COLS-2)/2) : (((COLS-2)/2)+1));
|
||||||
second_col_width = COLS - 2 - 1 - first_col_width; //((COLS - 2) / 2) - 1;
|
second_col_width = COLS - 2 - 1 - first_col_width; //((COLS - 2) / 2) - 1;
|
||||||
mdisprefs = result_window_height - WRESULT_TABLE_BODY_START - 1 - 1 - 1;
|
mdisprefs = result_window_height - (WRESULT_TABLE_BODY_START + 1);
|
||||||
|
|
||||||
if (mdisprefs <= 0) {
|
if (mdisprefs <= 0) {
|
||||||
postfatal("%s: screen too small\n", argv0);
|
postfatal(PROGRAM_NAME ": screen too small\n");
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
if(mdisprefs > sizeof(dispchars)){
|
if(mdisprefs > sizeof(dispchars)){
|
||||||
@ -255,12 +255,18 @@ static inline void display_frame(const bool border_only){
|
|||||||
const int LEFT_PADDING = 5;
|
const int LEFT_PADDING = 5;
|
||||||
wmove(stdscr, 0, LEFT_PADDING);
|
wmove(stdscr, 0, LEFT_PADDING);
|
||||||
#if CCS
|
#if CCS
|
||||||
wprintw(stdscr, "cscope %s", ESG_REL);
|
wprintw(stdscr, PROGRAM_NAME " %s", ESG_REL);
|
||||||
#else
|
#else
|
||||||
wprintw(stdscr, "Cscope version %d%s", FILEVERSION, FIXVERSION);
|
wprintw(stdscr, PROGRAM_NAME " version %d%s", FILEVERSION, FIXVERSION);
|
||||||
#endif
|
#endif
|
||||||
wmove(stdscr, 0, COLS - (int)sizeof(helpstring) - 3);
|
wmove(stdscr, 0, COLS - (int)sizeof(helpstring) - 3);
|
||||||
waddstr(stdscr, helpstring);
|
waddstr(stdscr, helpstring);
|
||||||
|
wmove(stdscr, LINES-1, 4);
|
||||||
|
if(caseless){
|
||||||
|
waddstr(stdscr, "Case: ON");
|
||||||
|
}else{
|
||||||
|
waddstr(stdscr, "Case: OFF");
|
||||||
|
}
|
||||||
/* --- */
|
/* --- */
|
||||||
if(!border_only){
|
if(!border_only){
|
||||||
/* Vertical line */
|
/* Vertical line */
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
|
|
||||||
#define UNUSED(x) (void)(x)
|
#define UNUSED(x) (void)(x)
|
||||||
|
|
||||||
//#include "config.h"
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -116,11 +115,12 @@ extern char dicode2[]; /* digraph second character code */
|
|||||||
((0200 - 2) + dicode1[(unsigned char)(inchar1)] \
|
((0200 - 2) + dicode1[(unsigned char)(inchar1)] \
|
||||||
+ dicode2[(unsigned char)(inchar2)])
|
+ dicode2[(unsigned char)(inchar2)])
|
||||||
|
|
||||||
|
#define PROGRAM_NAME "Csope"
|
||||||
|
|
||||||
/* main.c global data */
|
/* main.c global data */
|
||||||
extern char *editor, *home, *shell, *lineflag; /* environment variables */
|
extern char *editor, *home, *shell, *lineflag; /* environment variables */
|
||||||
extern char *home; /* Home directory */
|
extern char *home; /* Home directory */
|
||||||
extern bool lineflagafterfile;
|
extern bool lineflagafterfile;
|
||||||
extern char *argv0; /* command name */
|
|
||||||
extern bool compress; /* compress the characters in the crossref */
|
extern bool compress; /* compress the characters in the crossref */
|
||||||
extern bool dbtruncated; /* database symbols truncated to 8 chars */
|
extern bool dbtruncated; /* database symbols truncated to 8 chars */
|
||||||
extern int dispcomponents; /* file path components to display */
|
extern int dispcomponents; /* file path components to display */
|
||||||
|
@ -74,10 +74,10 @@ static char help_msg[] =
|
|||||||
"^F\t\tRecall next input field and search pattern.\n"
|
"^F\t\tRecall next input field and search pattern.\n"
|
||||||
"^C\t\tToggle ignore/use letter case when searching.\n"
|
"^C\t\tToggle ignore/use letter case when searching.\n"
|
||||||
"^R\t\tRebuild the cross-reference.\n"
|
"^R\t\tRebuild the cross-reference.\n"
|
||||||
"!\t\tStart an interactive shell (type ^D to return to cscope).\n"
|
"!\t\tStart an interactive shell (type ^D to return).\n"
|
||||||
"^L\t\tRedraw the screen.\n"
|
"^L\t\tRedraw the screen.\n"
|
||||||
"?\t\tDisplay this list of commands.\n"
|
"?\t\tDisplay this list of commands.\n"
|
||||||
"^D\t\tExit cscope.\n"
|
"^D\t\tExit the program.\n"
|
||||||
"\nNote: If the first character of the pattern you want to search for matches\n"
|
"\nNote: If the first character of the pattern you want to search for matches\n"
|
||||||
"a command, type a \\ character first.\n"
|
"a command, type a \\ character first.\n"
|
||||||
"Note: Some ctrl keys may be occupied by your terminal configuration.\n"
|
"Note: Some ctrl keys may be occupied by your terminal configuration.\n"
|
||||||
@ -93,7 +93,7 @@ static char changeing_help_msg[] =
|
|||||||
"^A\t\tMark or unmark all lines to be changed.\n"
|
"^A\t\tMark or unmark all lines to be changed.\n"
|
||||||
"^D\t\tChange the marked lines and exit.\n"
|
"^D\t\tChange the marked lines and exit.\n"
|
||||||
"ESC\t\tExit without changing the marked lines.\n"
|
"ESC\t\tExit without changing the marked lines.\n"
|
||||||
"!\t\tStart an interactive shell (type ^D to return to cscope).\n"
|
"!\t\tStart an interactive shell (type ^D to return).\n"
|
||||||
"^L\t\tRedraw the screen.\n"
|
"^L\t\tRedraw the screen.\n"
|
||||||
"?\t\tDisplay this list of commands.\n"
|
"?\t\tDisplay this list of commands.\n"
|
||||||
;
|
;
|
||||||
@ -122,7 +122,7 @@ void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fputs(
|
fputs(
|
||||||
"Usage: cscope [-bcCdehklLqRTuUvV] [-f file] [-F file] [-i file] [-I dir] [-s dir]\n"
|
"Usage: " PROGRAM_NAME " [-bcCdehklLqRTuUvV] [-f file] [-F file] [-i file] [-I dir] [-s dir]\n"
|
||||||
" [-p number] [-P path] [-[0-8] pattern] [source files]\n",
|
" [-p number] [-P path] [-[0-8] pattern] [source files]\n",
|
||||||
stderr
|
stderr
|
||||||
);
|
);
|
||||||
|
16
src/invlib.c
16
src/invlib.c
@ -581,19 +581,19 @@ invopen(INVCONTROL *invcntl, char *invname, char *invpost, int stat)
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if (fread(&invcntl->param, sizeof(invcntl->param), 1, invcntl->invfile) == 0) {
|
if (fread(&invcntl->param, sizeof(invcntl->param), 1, invcntl->invfile) == 0) {
|
||||||
fprintf(stderr, "%s: empty inverted file\n", argv0);
|
fprintf(stderr, PROGRAM_NAME ": empty inverted file\n");
|
||||||
fclose(invcntl->invfile);
|
fclose(invcntl->invfile);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if (invcntl->param.version != FMTVERSION) {
|
if (invcntl->param.version != FMTVERSION) {
|
||||||
fprintf(stderr, "%s: cannot read old index format; use -U option to force database to rebuild\n", argv0);
|
fprintf(stderr, PROGRAM_NAME ": cannot read old index format; use -U option to force database to rebuild\n");
|
||||||
fclose(invcntl->invfile);
|
fclose(invcntl->invfile);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
assert(invcntl->param.sizeblk == sizeof(t_logicalblk));
|
assert(invcntl->param.sizeblk == sizeof(t_logicalblk));
|
||||||
|
|
||||||
if (stat == 0 && invcntl->param.filestat == INVALONE) {
|
if (stat == 0 && invcntl->param.filestat == INVALONE) {
|
||||||
fprintf(stderr, "%s: inverted file is locked\n", argv0);
|
fprintf(stderr, PROGRAM_NAME ": inverted file is locked\n");
|
||||||
fclose(invcntl->invfile);
|
fclose(invcntl->invfile);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -636,7 +636,7 @@ invopen(INVCONTROL *invcntl, char *invname, char *invpost, int stat)
|
|||||||
if (shm_id != -1) {
|
if (shm_id != -1) {
|
||||||
invcntl->iindex = shmat(shm_id, 0, ((read_index) ? 0 : SHM_RDONLY));
|
invcntl->iindex = shmat(shm_id, 0, ((read_index) ? 0 : SHM_RDONLY));
|
||||||
if (invcntl->iindex == (char *)ERR) {
|
if (invcntl->iindex == (char *)ERR) {
|
||||||
fprintf(stderr, "%s: shared memory link failed\n", argv0);
|
fprintf(stderr, PROGRAM_NAME ": shared memory link failed\n");
|
||||||
invcntl->iindex = NULL;
|
invcntl->iindex = NULL;
|
||||||
read_index = 1;
|
read_index = 1;
|
||||||
}
|
}
|
||||||
@ -1187,18 +1187,18 @@ boolsave(int clear) /* flag about whether to clear core */
|
|||||||
static void
|
static void
|
||||||
invcannotalloc(unsigned n)
|
invcannotalloc(unsigned n)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: cannot allocate %u bytes\n", argv0, n);
|
fprintf(stderr, PROGRAM_NAME ": cannot allocate %u bytes\n", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
invcannotopen(char *file)
|
invcannotopen(char *file)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: cannot open file %s\n", argv0, file);
|
fprintf(stderr, PROGRAM_NAME "%s: cannot open file %s\n", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
invcannotwrite(char *file)
|
invcannotwrite(char *file)
|
||||||
{
|
{
|
||||||
perror(argv0); /* must be first to preserve errno */
|
perror(PROGRAM_NAME); /* must be first to preserve errno */
|
||||||
fprintf(stderr, "%s: write to file %s failed\n", argv0, file);
|
fprintf(stderr, PROGRAM_NAME ": write to file %s failed\n", file);
|
||||||
}
|
}
|
||||||
|
48
src/main.c
48
src/main.c
@ -191,12 +191,12 @@ skiplist(FILE *oldrefs)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (fscanf(oldrefs, "%d", &i) != 1) {
|
if (fscanf(oldrefs, "%d", &i) != 1) {
|
||||||
postfatal("cscope: cannot read list size from file %s\n", reffile);
|
postfatal(PROGRAM_NAME ": cannot read list size from file %s\n", reffile);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
if (fscanf(oldrefs, "%*s") != 0) {
|
if (fscanf(oldrefs, "%*s") != 0) {
|
||||||
postfatal("cscope: cannot read list name from file %s\n", reffile);
|
postfatal(PROGRAM_NAME ": cannot read list name from file %s\n", reffile);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,7 +260,7 @@ static inline void linemode_event_loop(void){
|
|||||||
/* print the total number of lines in
|
/* print the total number of lines in
|
||||||
* verbose mode */
|
* verbose mode */
|
||||||
if (verbosemode == true)
|
if (verbosemode == true)
|
||||||
printf("cscope: %d lines\n",
|
printf(PROGRAM_NAME ": %d lines\n",
|
||||||
totallines);
|
totallines);
|
||||||
|
|
||||||
while ((c = getc(refsfound)) != EOF)
|
while ((c = getc(refsfound)) != EOF)
|
||||||
@ -349,7 +349,7 @@ static inline void linemode_event_loop(void){
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "cscope: unknown command '%s'\n", buf);
|
fprintf(stderr, PROGRAM_NAME ": unknown command '%s'\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,35 +387,34 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* XXX remove if/when clearerr() in dir.c does the right thing. */
|
/* XXX remove if/when clearerr() in dir.c does the right thing. */
|
||||||
if (namefile && strcmp(namefile, "-") == 0 && !buildonly) {
|
if (namefile && strcmp(namefile, "-") == 0 && !buildonly) {
|
||||||
postfatal("cscope: Must use -b if file list comes from stdin\n");
|
postfatal(PROGRAM_NAME ": Must use -b if file list comes from stdin\n");
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure that tmpdir exists */
|
/* make sure that tmpdir exists */
|
||||||
if (lstat (tmpdir, &stat_buf)) {
|
if (lstat (tmpdir, &stat_buf)) {
|
||||||
fprintf (stderr,
|
fprintf (stderr, PROGRAM_NAME ": Temporary directory %s does not exist or cannot be accessed\n",
|
||||||
"cscope: Temporary directory %s does not exist or cannot be accessed\n",
|
|
||||||
tmpdir);
|
tmpdir);
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"cscope: Please create the directory or set the environment variable\n"
|
PROGRAM_NAME ": Please create the directory or set the environment variable\n"
|
||||||
"cscope: TMPDIR to a valid directory\n");
|
PROGRAM_NAME ": TMPDIR to a valid directory\n");
|
||||||
myexit(1);
|
myexit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create the temporary file names */
|
/* create the temporary file names */
|
||||||
orig_umask = umask(S_IRWXG|S_IRWXO);
|
orig_umask = umask(S_IRWXG|S_IRWXO);
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
snprintf(tempdirpv, sizeof(tempdirpv), "%s/cscope.%d", tmpdir, pid);
|
snprintf(tempdirpv, sizeof(tempdirpv), "%s/"PROGRAM_NAME".%d", tmpdir, pid);
|
||||||
if(mkdir(tempdirpv,S_IRWXU)) {
|
if(mkdir(tempdirpv,S_IRWXU)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"cscope: Could not create private temp dir %s\n",
|
PROGRAM_NAME ": Could not create private temp dir %s\n",
|
||||||
tempdirpv);
|
tempdirpv);
|
||||||
myexit(1);
|
myexit(1);
|
||||||
}
|
}
|
||||||
umask(orig_umask);
|
umask(orig_umask);
|
||||||
|
|
||||||
snprintf(temp1, sizeof(temp1), "%s/cscope.1", tempdirpv);
|
snprintf(temp1, sizeof(temp1), "%s/"PROGRAM_NAME".1", tempdirpv);
|
||||||
snprintf(temp2, sizeof(temp2), "%s/cscope.2", tempdirpv);
|
snprintf(temp2, sizeof(temp2), "%s/"PROGRAM_NAME".2", tempdirpv);
|
||||||
|
|
||||||
/* if the database path is relative and it can't be created */
|
/* if the database path is relative and it can't be created */
|
||||||
if (reffile[0] != '/' && access(".", WRITE) != 0) {
|
if (reffile[0] != '/' && access(".", WRITE) != 0) {
|
||||||
@ -448,12 +447,12 @@ main(int argc, char **argv)
|
|||||||
/* if the cross-reference is to be considered up-to-date */
|
/* if the cross-reference is to be considered up-to-date */
|
||||||
if (isuptodate == true) {
|
if (isuptodate == true) {
|
||||||
if ((oldrefs = vpfopen(reffile, "rb")) == NULL) {
|
if ((oldrefs = vpfopen(reffile, "rb")) == NULL) {
|
||||||
postfatal("cscope: cannot open file %s\n", reffile);
|
postfatal(PROGRAM_NAME ": cannot open file %s\n", reffile);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
/* get the crossref file version but skip the current directory */
|
/* get the crossref file version but skip the current directory */
|
||||||
if (fscanf(oldrefs, "cscope %d %*s", &fileversion) != 1) {
|
if (fscanf(oldrefs, PROGRAM_NAME " %d %*s", &fileversion) != 1) {
|
||||||
postfatal("cscope: cannot read file version from file %s\n",
|
postfatal(PROGRAM_NAME ": cannot read file version from file %s\n",
|
||||||
reffile);
|
reffile);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
@ -494,7 +493,7 @@ main(int argc, char **argv)
|
|||||||
/* get the number of source files */
|
/* get the number of source files */
|
||||||
if (fscanf(oldrefs, "%lu", &nsrcfiles) != 1) {
|
if (fscanf(oldrefs, "%lu", &nsrcfiles) != 1) {
|
||||||
postfatal(
|
postfatal(
|
||||||
"cscope: cannot read source file size from file %s\n",
|
PROGRAM_NAME ": cannot read source file size from file %s\n",
|
||||||
reffile);
|
reffile);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
@ -505,7 +504,7 @@ main(int argc, char **argv)
|
|||||||
/* allocate the string space */
|
/* allocate the string space */
|
||||||
if (fscanf(oldrefs, "%d", &oldnum) != 1) {
|
if (fscanf(oldrefs, "%d", &oldnum) != 1) {
|
||||||
postfatal(
|
postfatal(
|
||||||
"cscope: cannot read string space size from file %s\n",
|
PROGRAM_NAME ": cannot read string space size from file %s\n",
|
||||||
reffile);
|
reffile);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
@ -515,7 +514,7 @@ main(int argc, char **argv)
|
|||||||
/* read the strings */
|
/* read the strings */
|
||||||
if (fread(s, oldnum, 1, oldrefs) != 1) {
|
if (fread(s, oldnum, 1, oldrefs) != 1) {
|
||||||
postfatal(
|
postfatal(
|
||||||
"cscope: cannot read source file names from file %s\n",
|
PROGRAM_NAME ": cannot read source file names from file %s\n",
|
||||||
reffile);
|
reffile);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
@ -543,7 +542,7 @@ main(int argc, char **argv)
|
|||||||
switch (i) {
|
switch (i) {
|
||||||
case 'p': /* file path components to display */
|
case 'p': /* file path components to display */
|
||||||
if (*s < '0' || *s > '9') {
|
if (*s < '0' || *s > '9') {
|
||||||
posterr("cscope: -p option in file %s: missing or invalid numeric value\n", namefile);
|
posterr(PROGRAM_NAME ": -p option in file %s: missing or invalid numeric value\n", namefile);
|
||||||
|
|
||||||
}
|
}
|
||||||
dispcomponents = atoi(s);
|
dispcomponents = atoi(s);
|
||||||
@ -555,8 +554,9 @@ main(int argc, char **argv)
|
|||||||
for (i = 0; i < nsrcfiles; ++i) {
|
for (i = 0; i < nsrcfiles; ++i) {
|
||||||
if (!fgets(path, sizeof(path), oldrefs) ) {
|
if (!fgets(path, sizeof(path), oldrefs) ) {
|
||||||
postfatal(
|
postfatal(
|
||||||
"cscope: cannot read source file name from file %s\n",
|
PROGRAM_NAME ": cannot read source file name from file %s\n",
|
||||||
reffile);
|
reffile
|
||||||
|
);
|
||||||
/* falseTREACHED */
|
/* falseTREACHED */
|
||||||
}
|
}
|
||||||
srcfiles[i] = strdup(path);
|
srcfiles[i] = strdup(path);
|
||||||
@ -576,8 +576,8 @@ main(int argc, char **argv)
|
|||||||
srcfiles = malloc(msrcfiles * sizeof(*srcfiles));
|
srcfiles = malloc(msrcfiles * sizeof(*srcfiles));
|
||||||
makefilelist();
|
makefilelist();
|
||||||
if (nsrcfiles == 0) {
|
if (nsrcfiles == 0) {
|
||||||
postfatal("cscope: no source files found\n");
|
postfatal(PROGRAM_NAME ": no source files found\n");
|
||||||
/* falseTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
/* get include directories from the environment */
|
/* get include directories from the environment */
|
||||||
if ((s = getenv("INCLUDEDIRS")) != NULL) {
|
if ((s = getenv("INCLUDEDIRS")) != NULL) {
|
||||||
|
@ -90,7 +90,7 @@ char ** parse_options(int *argc, char **argv)
|
|||||||
verbosemode = true;
|
verbosemode = true;
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
fprintf(stderr, "%s: version %d%s\n", argv0,
|
fprintf(stderr, PROGRAM_NAME ": version %d%s\n",
|
||||||
FILEVERSION, FIXVERSION);
|
FILEVERSION, FIXVERSION);
|
||||||
myexit(0);
|
myexit(0);
|
||||||
break;
|
break;
|
||||||
|
@ -81,7 +81,7 @@ vpinit(char *current_dir)
|
|||||||
}
|
}
|
||||||
/* if not given, get the current directory name */
|
/* if not given, get the current directory name */
|
||||||
if (current_dir == NULL && (current_dir = getcwd(buf, MAXPATH)) == NULL) {
|
if (current_dir == NULL && (current_dir = getcwd(buf, MAXPATH)) == NULL) {
|
||||||
(void) fprintf(stderr, "%s: cannot get current directory name\n", argv0);
|
(void) fprintf(stderr, PROGRAM_NAME ": cannot get current directory name\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* see if this directory is in the first view path node */
|
/* see if this directory is in the first view path node */
|
||||||
|
Loading…
Reference in New Issue
Block a user