replacing werks
This commit is contained in:
parent
a83c6632c3
commit
4a92182125
@ -54,30 +54,18 @@
|
||||
* In the original version this was handled by
|
||||
* "int selecting // whether the (upper) symbol list is being browsed".
|
||||
*/
|
||||
extern const void const* winput;
|
||||
extern const void const* wmode;
|
||||
extern const void const* wresult;
|
||||
extern const void const* const* current_window;
|
||||
extern const void *const winput;
|
||||
extern const void *const wmode;
|
||||
extern const void *const wresult;
|
||||
extern const void *const *const current_window;
|
||||
|
||||
bool caseless; /* ignore letter case when searching */
|
||||
bool *change; /* change this line */
|
||||
bool changing; /* changing text */
|
||||
char newpat[PATLEN + 1]; /* new pattern */
|
||||
|
||||
/* Internal prototypes: */
|
||||
static void clearprompt(void);
|
||||
static void mark(unsigned int i);
|
||||
static void scrollbar(MOUSE *p);
|
||||
|
||||
/* clear the prompt line */
|
||||
|
||||
static void
|
||||
clearprompt(void)
|
||||
{
|
||||
wmove(winput, 0, 0);
|
||||
clrtoeol();
|
||||
}
|
||||
|
||||
/* read references from a file */
|
||||
|
||||
bool
|
||||
@ -114,27 +102,6 @@ readrefs(char *filename)
|
||||
return(true);
|
||||
}
|
||||
|
||||
/* mark/unmark this displayed line to be changed */
|
||||
static void
|
||||
mark(unsigned int i)
|
||||
{
|
||||
unsigned int j;
|
||||
|
||||
//j = i + topline - 1;
|
||||
if (j < totallines) {
|
||||
move(displine[i], 1);
|
||||
|
||||
if (change[j] == false) {
|
||||
change[j] = true;
|
||||
addch('>');
|
||||
} else {
|
||||
change[j] = false;
|
||||
addch(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* scrollbar actions */
|
||||
static void
|
||||
scrollbar(MOUSE *p)
|
||||
|
@ -94,7 +94,7 @@ enum {
|
||||
#define FIELDS 10
|
||||
|
||||
// XXX
|
||||
#define bazdmeg 1
|
||||
#define bazdki 1
|
||||
|
||||
/* file open modes */
|
||||
#ifndef R_OK
|
||||
|
123
src/display.c
123
src/display.c
@ -76,6 +76,7 @@ const char* prompts[] = {
|
||||
[INPUT_APPEND] = "Append to file: ",
|
||||
[INPUT_PIPE] = "Pipe to shell command: ",
|
||||
[INPUT_READ] = "Read from file: ",
|
||||
[INPUT_CHANGE_TO] = "To: ",
|
||||
[INPUT_CHANGE] = "To: "
|
||||
};
|
||||
|
||||
@ -190,7 +191,7 @@ entercurses(void)
|
||||
curs_set(0);
|
||||
clear(); /* clear the screen */
|
||||
mouseinit(); /* initialize any mouse interface */
|
||||
drawscrollbar(topline, nextline);
|
||||
//drawscrollbar(topline, nextline);
|
||||
keypad(stdscr, TRUE); /* enable the keypad */
|
||||
//fixkeypad(); /* fix for getch() intermittently returning garbage */
|
||||
standend(); /* turn off reverse video */
|
||||
@ -295,7 +296,7 @@ static inline void display_results(){
|
||||
waddstr(wresult, lastmsg);
|
||||
return;
|
||||
}
|
||||
if (changing == true) { // Its a pattern
|
||||
if (input_mode == INPUT_CHANGE) { // Its a pattern
|
||||
snprintf(lastmsg, MSGLEN, "Change \"%s\" to \"%s\"", input_line, newpat);
|
||||
} else {
|
||||
snprintf(lastmsg, MSGLEN, "%c%s: %s", toupper((unsigned char)fields[field].text2[0]),
|
||||
@ -339,14 +340,15 @@ static inline void display_results(){
|
||||
|
||||
/* decide where to list from */
|
||||
/* XXX: this error handling migth be redundant*/
|
||||
int seekerr;
|
||||
do{
|
||||
seekerr = seekpage(current_page);
|
||||
}while(seekerr == -1 && current_page--);
|
||||
{
|
||||
int seekerr;
|
||||
do{
|
||||
seekerr = seekpage(current_page);
|
||||
}while(seekerr == -1 && current_page--);
|
||||
}
|
||||
|
||||
/* until the max references have been displayed or
|
||||
there is no more room */
|
||||
topline = nextline;
|
||||
for (disprefs = 0, screenline = WRESULT_TABLE_BODY_START;
|
||||
disprefs < mdisprefs && screenline <= result_window_height;
|
||||
++disprefs, ++screenline)
|
||||
@ -368,7 +370,7 @@ static inline void display_results(){
|
||||
wprintw(wresult, "%c", dispchars[disprefs]);
|
||||
|
||||
/* display any change mark */
|
||||
if (changing == true && change[topline + disprefs - 1] == true) {
|
||||
if (input_mode == INPUT_CHANGE && change[topref + disprefs]) {
|
||||
waddch(wresult, '>');
|
||||
} else {
|
||||
waddch(wresult, ' ');
|
||||
@ -376,19 +378,19 @@ static inline void display_results(){
|
||||
|
||||
/* display the file name */
|
||||
if (field == FILENAME) {
|
||||
wprintw(wresult, "%-*s ", filelen, file);
|
||||
wprintw(wresult, "%-*s ", filelen, file);
|
||||
} else {
|
||||
/* if OGS, display the subsystem and book names */
|
||||
if (ogs == true) {
|
||||
ogsnames(file, &subsystem, &book);
|
||||
wprintw(wresult, "%-*.*s ", subsystemlen, subsystemlen, subsystem);
|
||||
wprintw(wresult, "%-*.*s ", booklen, booklen, book);
|
||||
}
|
||||
/* display the requested path components */
|
||||
if (dispcomponents > 0) {
|
||||
wprintw(wresult, "%-*.*s ", filelen, filelen,
|
||||
pathcomponents(file, dispcomponents));
|
||||
}
|
||||
/* if OGS, display the subsystem and book names */
|
||||
if (ogs == true) {
|
||||
ogsnames(file, &subsystem, &book);
|
||||
wprintw(wresult, "%-*.*s ", subsystemlen, subsystemlen, subsystem);
|
||||
wprintw(wresult, "%-*.*s ", booklen, booklen, book);
|
||||
}
|
||||
/* display the requested path components */
|
||||
if (dispcomponents > 0) {
|
||||
wprintw(wresult, "%-*.*s ", filelen, filelen,
|
||||
pathcomponents(file, dispcomponents));
|
||||
}
|
||||
} /* else(field == FILENAME) */
|
||||
|
||||
/* display the function name */
|
||||
@ -443,7 +445,7 @@ static inline void display_results(){
|
||||
|
||||
/* if this is the first displayed line,
|
||||
display what will fit on the screen */
|
||||
if (topline == nextline-1) {
|
||||
if (topref == nextline-1) {
|
||||
disprefs++;
|
||||
/* break out of two loops */
|
||||
goto endrefs;
|
||||
@ -479,10 +481,10 @@ endrefs:
|
||||
i = totallines - nextline + 1;
|
||||
bottomline = nextline;
|
||||
if (i > 0) {
|
||||
wprintw(wresult, "* Lines %d-%d of %d, %d more - press the space bar to display more *", topline, bottomline, totallines, i);
|
||||
wprintw(wresult, "* Lines %d-%d of %d, %d more - press the space bar to display more *", topref, bottomline, totallines, i);
|
||||
}
|
||||
/* if this is the last page of references */
|
||||
else if (topline > 1 && nextline > totallines) {
|
||||
else if (current_page > 0 && nextline > totallines) {
|
||||
waddstr(wresult, "* Press the space bar to display the first lines again *");
|
||||
}
|
||||
}
|
||||
@ -507,44 +509,6 @@ void display_cursor(void){
|
||||
i |= A_REVERSE;
|
||||
waddch(*current_window, i);
|
||||
}
|
||||
|
||||
void
|
||||
display(void)
|
||||
{
|
||||
//drawscrollbar(topline, nextline); /* display the scrollbar */
|
||||
|
||||
if(window_change){
|
||||
if(window_change == CH_HELP){
|
||||
display_help();
|
||||
/* Do not display over the help msg and */
|
||||
/* rely on display_help() setting CH_ALL */
|
||||
return;
|
||||
}
|
||||
/**/
|
||||
if(window_change == CH_ALL){
|
||||
display_frame();
|
||||
}
|
||||
if(window_change & CH_INPUT){
|
||||
display_command_field();
|
||||
}
|
||||
if(window_change & CH_RESULT){
|
||||
display_results();
|
||||
}
|
||||
if(window_change & CH_MODE){
|
||||
display_mode();
|
||||
}
|
||||
|
||||
display_cursor();
|
||||
|
||||
refresh();
|
||||
wrefresh(winput);
|
||||
wrefresh(wmode);
|
||||
wrefresh(wresult);
|
||||
}
|
||||
|
||||
window_change = CH_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
horswp_field(void){
|
||||
if(current_window != &wresult){
|
||||
@ -738,3 +702,40 @@ ogsnames(char *file, char **subsystem, char **book)
|
||||
s = slash + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
display(void)
|
||||
{
|
||||
//drawscrollbar(topline, nextline); /* display the scrollbar */
|
||||
|
||||
if(window_change){
|
||||
if(window_change == CH_HELP){
|
||||
display_help();
|
||||
/* Do not display over the help msg and */
|
||||
/* rely on display_help() setting CH_ALL */
|
||||
return;
|
||||
}
|
||||
/**/
|
||||
if(window_change == CH_ALL){
|
||||
display_frame();
|
||||
}
|
||||
if(window_change & CH_INPUT){
|
||||
display_command_field();
|
||||
}
|
||||
if(window_change & CH_RESULT){
|
||||
display_results();
|
||||
}
|
||||
if(window_change & CH_MODE){
|
||||
display_mode();
|
||||
}
|
||||
|
||||
display_cursor();
|
||||
|
||||
refresh();
|
||||
wrefresh(winput);
|
||||
wrefresh(wmode);
|
||||
wrefresh(wresult);
|
||||
}
|
||||
|
||||
window_change = CH_NONE;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ edit(char *file, char *linenum)
|
||||
/* if requested, prepend a path to a relative file name */
|
||||
|
||||
char *
|
||||
filepath(char *file)
|
||||
filepath(const char *file)
|
||||
{
|
||||
static char path[PATHLEN + 1];
|
||||
|
||||
|
@ -1909,7 +1909,7 @@ follow(unsigned int v)
|
||||
}
|
||||
|
||||
char *
|
||||
egrepinit(char *egreppat)
|
||||
egrepinit(const char *egreppat)
|
||||
{
|
||||
/* initialize the global data */
|
||||
memset(gotofn, 0, sizeof(gotofn));
|
||||
|
@ -519,7 +519,7 @@ follow(unsigned int v)
|
||||
}
|
||||
|
||||
char *
|
||||
egrepinit(char *egreppat)
|
||||
egrepinit(const char *egreppat)
|
||||
{
|
||||
/* initialize the global data */
|
||||
memset(gotofn, 0, sizeof(gotofn));
|
||||
|
110
src/find.c
110
src/find.c
@ -70,20 +70,26 @@ static bool isregexp_valid = false; /* regular expression status */
|
||||
static bool match(void);
|
||||
static bool matchrest(void);
|
||||
static POSTING *getposting(void);
|
||||
static char *lcasify(char *s);
|
||||
static void findcalledbysub(char *file, bool macro);
|
||||
static void findterm(char *pattern);
|
||||
static char *lcasify(const char *s);
|
||||
static void findcalledbysub(const char *file, bool macro);
|
||||
static void findterm(const char *pattern);
|
||||
static void putline(FILE *output);
|
||||
static char *find_symbol_or_assignment(char *pattern, bool assign_flag);
|
||||
static char *find_symbol_or_assignment(const char *pattern, bool assign_flag);
|
||||
static bool check_for_assignment(void);
|
||||
static void putpostingref(POSTING *p, char *pat);
|
||||
static void putref(int seemore, char *file, char *func);
|
||||
static void putpostingref(POSTING *p, const char *pat);
|
||||
static void putref(int seemore, const char *file, const char *func);
|
||||
static void putsource(int seemore, FILE *output);
|
||||
static FILE *nonglobalrefs; /* non-global references file */
|
||||
|
||||
static sigjmp_buf env; /* setjmp/longjmp buffer */
|
||||
|
||||
typedef char * (*FP)(char *); /* pointer to function returning a character pointer */
|
||||
typedef enum { /* findinit return code */
|
||||
NOERROR,
|
||||
NOTSYMBOL,
|
||||
REGCMPERROR
|
||||
} FINDINIT;
|
||||
|
||||
typedef char * (*FP)(const char *); /* pointer to function returning a character pointer */
|
||||
/* Paralel array to "fields", indexed by "field" */
|
||||
FP field_searchers[FIELDS + 1] = {
|
||||
findsymbol,
|
||||
@ -118,14 +124,14 @@ jumpback(int sig)
|
||||
|
||||
/* find the symbol in the cross-reference */
|
||||
char *
|
||||
findsymbol(char *pattern)
|
||||
findsymbol(const char *pattern)
|
||||
{
|
||||
return find_symbol_or_assignment(pattern, false);
|
||||
}
|
||||
|
||||
/* find the symbol in the cross-reference, and look for assignments */
|
||||
char *
|
||||
findassign(char *pattern)
|
||||
findassign(const char *pattern)
|
||||
{
|
||||
return find_symbol_or_assignment(pattern, true);
|
||||
}
|
||||
@ -188,10 +194,10 @@ check_for_assignment(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The actual routine that does the work for findsymbol() and
|
||||
/* The actual routine that does the work for findsymbol() and
|
||||
* findassign() */
|
||||
static char *
|
||||
find_symbol_or_assignment(char *pattern, bool assign_flag)
|
||||
find_symbol_or_assignment(const char *pattern, bool assign_flag)
|
||||
{
|
||||
char file[PATHLEN + 1]; /* source file name */
|
||||
char function[PATLEN + 1]; /* function name */
|
||||
@ -386,10 +392,10 @@ find_symbol_or_assignment(char *pattern, bool assign_flag)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/* find the function definition or #define */
|
||||
/* find the function definition or #define */
|
||||
|
||||
char *
|
||||
finddef(char *pattern)
|
||||
finddef(const char *pattern)
|
||||
{
|
||||
char file[PATHLEN + 1]; /* source file name */
|
||||
|
||||
@ -449,10 +455,10 @@ finddef(char *pattern)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/* find all function definitions (used by samuel only) */
|
||||
/* find all function definitions (used by samuel only) */
|
||||
|
||||
char *
|
||||
findallfcns(char *dummy)
|
||||
findallfcns(const char *dummy)
|
||||
{
|
||||
char file[PATHLEN + 1]; /* source file name */
|
||||
char function[PATLEN + 1]; /* function name */
|
||||
@ -492,7 +498,7 @@ findallfcns(char *dummy)
|
||||
/* find the functions calling this function */
|
||||
|
||||
char *
|
||||
findcalling(char *pattern)
|
||||
findcalling(const char *pattern)
|
||||
{
|
||||
char file[PATHLEN + 1]; /* source file name */
|
||||
char function[PATLEN + 1]; /* function name */
|
||||
@ -584,13 +590,13 @@ findcalling(char *pattern)
|
||||
/* find the text in the source files */
|
||||
|
||||
char *
|
||||
findstring(char *pattern)
|
||||
findstring(const char *pattern)
|
||||
{
|
||||
char egreppat[2 * PATLEN];
|
||||
char *cp, *pp;
|
||||
char *cp = egreppat;
|
||||
const char* pp;
|
||||
|
||||
/* translate special characters in the regular expression */
|
||||
cp = egreppat;
|
||||
for (pp = pattern; *pp != '\0'; ++pp) {
|
||||
if (strchr(".*[\\^$+?|()", *pp) != NULL) {
|
||||
*cp++ = '\\';
|
||||
@ -606,7 +612,7 @@ findstring(char *pattern)
|
||||
/* find this regular expression in the source files */
|
||||
|
||||
char *
|
||||
findregexp(char *egreppat)
|
||||
findregexp(const char *egreppat)
|
||||
{
|
||||
unsigned int i;
|
||||
char *egreperror;
|
||||
@ -630,7 +636,7 @@ findregexp(char *egreppat)
|
||||
/* find matching file names */
|
||||
|
||||
char *
|
||||
findfile(char *dummy)
|
||||
findfile(const char *dummy)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@ -656,7 +662,7 @@ findfile(char *dummy)
|
||||
/* find files #including this file */
|
||||
|
||||
char *
|
||||
findinclude(char *pattern)
|
||||
findinclude(const char *pattern)
|
||||
{
|
||||
char file[PATHLEN + 1]; /* source file name */
|
||||
|
||||
@ -701,9 +707,11 @@ findinclude(char *pattern)
|
||||
|
||||
/* initialize */
|
||||
|
||||
FINDINIT
|
||||
findinit(char *pattern)
|
||||
int
|
||||
findinit(const char *pattern_)
|
||||
{
|
||||
char* pattern = strdup(pattern_);
|
||||
int r = NOERROR;
|
||||
char buf[PATLEN + 3];
|
||||
bool isregexp = false;
|
||||
int i;
|
||||
@ -733,11 +741,11 @@ findinit(char *pattern)
|
||||
/* allow a partial match for a file name */
|
||||
if (field == FILENAME || field == INCLUDES) {
|
||||
if (regcomp (®exp, pattern, REG_EXTENDED | REG_NOSUB) != 0) {
|
||||
return(REGCMPERROR);
|
||||
r = REGCMPERROR;
|
||||
} else {
|
||||
isregexp_valid = true;
|
||||
}
|
||||
return(falseERROR);
|
||||
goto end;
|
||||
}
|
||||
/* see if the pattern is a regular expression */
|
||||
if (strpbrk(pattern, "^.[{*+$|(") != NULL) {
|
||||
@ -746,11 +754,13 @@ findinit(char *pattern)
|
||||
/* check for a valid C symbol */
|
||||
s = pattern;
|
||||
if (!isalpha((unsigned char)*s) && *s != '_') {
|
||||
return(falseTSYMBOL);
|
||||
r = NOTSYMBOL;
|
||||
goto end;
|
||||
}
|
||||
while (*++s != '\0') {
|
||||
if (!isalnum((unsigned char)*s) && *s != '_') {
|
||||
return(falseTSYMBOL);
|
||||
r = NOTSYMBOL;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
/* look for use of the -T option (truncate symbol to 8
|
||||
@ -788,7 +798,8 @@ findinit(char *pattern)
|
||||
unless it is given as a single arg */
|
||||
(void) snprintf(buf, sizeof(buf), "^%s$", s);
|
||||
if (regcomp (®exp, buf, REG_EXTENDED | REG_NOSUB) != 0) {
|
||||
return(REGCMPERROR);
|
||||
r = REGCMPERROR;
|
||||
goto end;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -811,7 +822,10 @@ findinit(char *pattern)
|
||||
}
|
||||
*s = '\0';
|
||||
}
|
||||
return(falseERROR);
|
||||
|
||||
end:
|
||||
free(pattern);
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
@ -868,7 +882,7 @@ matchrest(void)
|
||||
/* put the reference into the file */
|
||||
|
||||
static void
|
||||
putref(int seemore, char *file, char *func)
|
||||
putref(int seemore, const char *file, const char *func)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
@ -1051,7 +1065,7 @@ read_block(void)
|
||||
}
|
||||
|
||||
static char *
|
||||
lcasify(char *s)
|
||||
lcasify(const char *s)
|
||||
{
|
||||
static char ls[PATLEN+1]; /* largest possible match string */
|
||||
char *lptr = ls;
|
||||
@ -1062,7 +1076,7 @@ lcasify(char *s)
|
||||
s++;
|
||||
}
|
||||
*lptr = '\0';
|
||||
return(ls);
|
||||
return ls;
|
||||
}
|
||||
|
||||
/* find the functions called by this function */
|
||||
@ -1073,7 +1087,7 @@ lcasify(char *s)
|
||||
* 'n', for the boolean result values true and false */
|
||||
|
||||
char *
|
||||
findcalledby(char *pattern)
|
||||
findcalledby(const char *pattern)
|
||||
{
|
||||
char file[PATHLEN + 1]; /* source file name */
|
||||
static char found_caller = 'n'; /* seen calling function? */
|
||||
@ -1132,7 +1146,7 @@ findcalledby(char *pattern)
|
||||
/* find this term, which can be a regular expression */
|
||||
|
||||
static void
|
||||
findterm(char *pattern)
|
||||
findterm(const char *pattern)
|
||||
{
|
||||
char *s;
|
||||
int len;
|
||||
@ -1229,7 +1243,7 @@ getposting(void)
|
||||
/* put the posting reference into the file */
|
||||
|
||||
static void
|
||||
putpostingref(POSTING *p, char *pat)
|
||||
putpostingref(POSTING *p, const char *pat)
|
||||
{
|
||||
// initialize function to "unknown" so that the first line of temp1
|
||||
// is properly formed if symbol matches a header file entry first time
|
||||
@ -1282,7 +1296,7 @@ dbseek(long offset)
|
||||
}
|
||||
|
||||
static void
|
||||
findcalledbysub(char *file, bool macro)
|
||||
findcalledbysub(const char *file, bool macro)
|
||||
{
|
||||
/* find the next function call or the end of this function */
|
||||
while (scanpast('\t') != NULL) {
|
||||
@ -1353,12 +1367,12 @@ writerefsfound(void)
|
||||
|
||||
/* Perform token search based on "field" */
|
||||
bool
|
||||
search(void)
|
||||
search(const char* query)
|
||||
{
|
||||
char msg[MSGLEN+1];
|
||||
char *findresult = NULL; /* find function output */
|
||||
bool funcexist = true; /* find "function" error */
|
||||
FINDINIT rc = falseERROR; /* findinit return code */
|
||||
FINDINIT rc = NOERROR; /* findinit return code */
|
||||
sighandler_t savesig; /* old value of signal */
|
||||
FP f; /* searching function */
|
||||
int c;
|
||||
@ -1376,15 +1390,15 @@ search(void)
|
||||
if (sigsetjmp(env, 1) == 0) {
|
||||
f = field_searchers[field];
|
||||
if (f == findregexp || f == findstring) {
|
||||
findresult = (*f)(input_line);
|
||||
findresult = (*f)(query);
|
||||
} else {
|
||||
if ((nonglobalrefs = myfopen(temp2, "wb")) == NULL) {
|
||||
cannotopen(temp2);
|
||||
return(false);
|
||||
}
|
||||
if ((rc = findinit(input_line)) == falseERROR) {
|
||||
if ((rc = findinit(query)) == NOERROR) {
|
||||
(void) dbseek(0L); /* read the first block */
|
||||
findresult = (*f)(input_line);
|
||||
findresult = (*f)(query);
|
||||
if (f == findcalledby)
|
||||
funcexist = (*findresult == 'y');
|
||||
findcleanup();
|
||||
@ -1422,20 +1436,20 @@ search(void)
|
||||
if ((c = getc(refsfound)) == EOF) {
|
||||
if (findresult != NULL) {
|
||||
(void) snprintf(msg, sizeof(msg), "Egrep %s in this pattern: %s",
|
||||
findresult, input_line);
|
||||
} else if (rc == falseTSYMBOL) {
|
||||
findresult, query);
|
||||
} else if (rc == NOTSYMBOL) {
|
||||
(void) snprintf(msg, sizeof(msg), "This is not a C symbol: %s",
|
||||
input_line);
|
||||
query);
|
||||
} else if (rc == REGCMPERROR) {
|
||||
(void) snprintf(msg, sizeof(msg), "Error in this regcomp(3) regular expression: %s",
|
||||
input_line);
|
||||
query);
|
||||
|
||||
} else if (funcexist == false) {
|
||||
(void) snprintf(msg, sizeof(msg), "Function definition does not exist: %s",
|
||||
input_line);
|
||||
query);
|
||||
} else {
|
||||
(void) snprintf(msg, sizeof(msg), "Could not find the %s: %s",
|
||||
fields[field].text2, input_line);
|
||||
fields[field].text2, query);
|
||||
}
|
||||
postmsg(msg);
|
||||
return(false);
|
||||
|
37
src/global.h
37
src/global.h
@ -64,12 +64,6 @@ typedef void (*sighandler_t)(int);
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum { /* findinit return code */
|
||||
falseERROR,
|
||||
falseTSYMBOL,
|
||||
REGCMPERROR
|
||||
} FINDINIT;
|
||||
|
||||
typedef struct { /* mouse action */
|
||||
int button;
|
||||
int percent;
|
||||
@ -98,6 +92,7 @@ enum {
|
||||
INPUT_APPEND,
|
||||
INPUT_PIPE,
|
||||
INPUT_READ,
|
||||
INPUT_CHANGE_TO,
|
||||
INPUT_CHANGE
|
||||
};
|
||||
|
||||
@ -157,7 +152,6 @@ extern char *tmpdir; /* temporary directory */
|
||||
/* command.c global data */
|
||||
extern bool caseless; /* ignore letter case when searching */
|
||||
extern bool *change; /* change this line */
|
||||
extern bool changing; /* changing text */
|
||||
extern unsigned int curdispline;
|
||||
extern char newpat[]; /* new pattern */
|
||||
|
||||
@ -221,17 +215,17 @@ extern bool unixpcmouse; /* UNIX PC mouse interface */
|
||||
|
||||
/* cscope functions called from more than one function or between files */
|
||||
|
||||
char *filepath(char *file);
|
||||
char *findcalledby(char *pattern);
|
||||
char *findcalling(char *pattern);
|
||||
char *findallfcns(char *dummy);
|
||||
char *finddef(char *pattern);
|
||||
char *findfile(char *dummy);
|
||||
char *findinclude(char *pattern);
|
||||
char *findsymbol(char *pattern);
|
||||
char *findassign(char *pattern);
|
||||
char *findregexp(char *egreppat);
|
||||
char *findstring(char *pattern);
|
||||
char *filepath(const char *file);
|
||||
char *findsymbol(const char *pattern);
|
||||
char *finddef(const char *pattern);
|
||||
char *findcalledby(const char *pattern);
|
||||
char *findcalling(const char *pattern);
|
||||
char *findstring(const char *pattern);
|
||||
char *findregexp(const char *egreppat);
|
||||
char *findfile(const char *dummy);
|
||||
char *findinclude(const char *pattern);
|
||||
char *findassign(const char *pattern);
|
||||
char *findallfcns(const char *dummy);
|
||||
char *inviewpath(char *file);
|
||||
char *lookup(char *ident);
|
||||
char *pathcomponents(char *path, int components);
|
||||
@ -247,6 +241,7 @@ extern bool onesearch; /* one search only in line mode */
|
||||
extern char *reflines; /* symbol reference lines file */
|
||||
extern bool do_press_any_key; /* wait for any key to continue */
|
||||
extern int current_page;
|
||||
#define topref current_page*mdisprefs
|
||||
void verswp_field(void);
|
||||
void horswp_field(void);
|
||||
bool interpret(int c); // XXX: probably rename
|
||||
@ -254,7 +249,7 @@ int handle_input(const int c);
|
||||
int dispchar2int(const char c);
|
||||
int process_mouse();
|
||||
extern int input_mode;
|
||||
int changestring(const char* from, const char* to, bool *change);
|
||||
int changestring(const char* from, const char* to, const bool *const change, const int change_len);
|
||||
|
||||
long seekpage(size_t i);
|
||||
long seekrelline(unsigned i);
|
||||
@ -314,10 +309,10 @@ void writestring(char *s);
|
||||
|
||||
bool infilelist(char *file);
|
||||
bool readrefs(char *filename);
|
||||
bool search(void);
|
||||
bool search(const char* query);
|
||||
bool writerefsfound(void);
|
||||
|
||||
FINDINIT findinit(char *pattern);
|
||||
int findinit(const char *pattern_);
|
||||
MOUSE *getmouseaction(char leading_char);
|
||||
struct cmd *currentcmd(void);
|
||||
struct cmd *prevcmd(void);
|
||||
|
@ -101,7 +101,7 @@ static char changeing_help_msg[] =
|
||||
const char*
|
||||
help(void)
|
||||
{
|
||||
if (changing == false) {
|
||||
if (input_mode == INPUT_CHANGE) {
|
||||
return help_msg;
|
||||
} else {
|
||||
return changeing_help_msg;
|
||||
|
53
src/input.c
53
src/input.c
@ -529,23 +529,23 @@ extern const void *const winput;
|
||||
extern const void *const wmode;
|
||||
extern const void *const wresult;
|
||||
extern const void *const *const current_window;
|
||||
extern const int topline;
|
||||
|
||||
int
|
||||
change_input(const int c){
|
||||
MOUSE *p; /* mouse data */
|
||||
change = calloc(totallines, sizeof(*change));
|
||||
|
||||
switch(c){
|
||||
case '*': /* invert page */
|
||||
for(int i = 0; topline + i < nextline; i++){
|
||||
change[topline + i] = !change[topline + i];
|
||||
for(int i = 0; topref + i < nextline; i++){
|
||||
change[topref + i] = !change[topref + i];
|
||||
}
|
||||
window_change |= CH_RESULT;
|
||||
break;
|
||||
case ctrl('A'): /* invert all lines */
|
||||
for(unsigned i = 0; i < totallines; i++) {
|
||||
change[i] = !change[i];
|
||||
}
|
||||
window_change |= CH_RESULT;
|
||||
break;
|
||||
case ctrl('X'): /* mouse selection */
|
||||
if ((p = getmouseaction(DUMMYCHAR)) == NULL) {
|
||||
@ -569,7 +569,7 @@ change_input(const int c){
|
||||
}
|
||||
break;
|
||||
case ctrl('D'):
|
||||
changestring(input_line, newpat, change);
|
||||
changestring(input_line, newpat, change, totallines);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
@ -577,6 +577,7 @@ change_input(const int c){
|
||||
const int cc = dispchar2int(c);
|
||||
if(cc != -1){
|
||||
change[cc] = !change[cc];
|
||||
window_change |= CH_RESULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -585,13 +586,26 @@ change_input(const int c){
|
||||
}
|
||||
|
||||
int
|
||||
changestring(const char* from, const char* to, bool *change){
|
||||
changestring(const char* from,
|
||||
const char* to,
|
||||
const bool *const change,
|
||||
const int change_len
|
||||
){
|
||||
char newfile[PATHLEN + 1]; /* new file name */
|
||||
char oldfile[PATHLEN + 1]; /* old file name */
|
||||
char linenum[NUMLEN + 1]; /* file line number */
|
||||
char msg[MSGLEN + 1]; /* message */
|
||||
FILE *script; /* shell script file */
|
||||
|
||||
/* Return early */
|
||||
bool anymarked = false; /* any line marked */
|
||||
for(int i = 0; i < change_len; i++){
|
||||
if(change[i]){
|
||||
anymarked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!anymarked){ return false; }
|
||||
|
||||
/* open the temporary file */
|
||||
if((script = myfopen(temp2, "w")) == NULL) {
|
||||
@ -608,8 +622,7 @@ changestring(const char* from, const char* to, bool *change){
|
||||
++i)
|
||||
{
|
||||
/* see if the line is to be changed */
|
||||
if (change[i] == false) { break; }
|
||||
anymarked = true;
|
||||
if (!change[i]) { break; }
|
||||
|
||||
/* if this is a new file */
|
||||
if (strcmp(newfile, oldfile) != 0) {
|
||||
@ -618,8 +631,7 @@ changestring(const char* from, const char* to, bool *change){
|
||||
if (access(newfile, WRITE) != 0) {
|
||||
snprintf(msg, sizeof(msg), "Cannot write to file %s", newfile);
|
||||
postmsg(msg);
|
||||
anymarked = false;
|
||||
break;
|
||||
goto end;
|
||||
}
|
||||
/* if there was an old file */
|
||||
if (*oldfile != '\0') {
|
||||
@ -660,20 +672,15 @@ changestring(const char* from, const char* to, bool *change){
|
||||
fprintf(script, "/gp\n"); /* and print */
|
||||
}
|
||||
fprintf(script, "w\nq\n!\n"); /* write and quit */
|
||||
fflush(script);
|
||||
|
||||
/* if any line was marked */
|
||||
if (anymarked == true) {
|
||||
/* edit the files */
|
||||
fprintf(stderr, "Changed lines:\n\r");
|
||||
execute("sh", "sh", temp2, NULL);
|
||||
askforchar();
|
||||
}
|
||||
|
||||
changing = false;
|
||||
mousemenu();
|
||||
/* edit the files */
|
||||
fprintf(stderr, "Changed lines:\n\r");
|
||||
execute("sh", "sh", temp2, NULL);
|
||||
askforchar();
|
||||
end:
|
||||
fclose(script);
|
||||
free(change);
|
||||
return(anymarked);
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
@ -698,6 +705,8 @@ handle_input(const int c){
|
||||
}
|
||||
assert("'current_window' dangling.");
|
||||
break; /* NOTREACHED */
|
||||
case INPUT_CHANGE_TO:
|
||||
return interpret(c);
|
||||
case INPUT_CHANGE:
|
||||
return change_input(c);
|
||||
}
|
||||
|
@ -37,9 +37,9 @@
|
||||
|
||||
/* private library */
|
||||
char *compath(char *pathname);
|
||||
char *egrepinit(char *egreppat);
|
||||
char *egrepinit(const char *egreppat);
|
||||
char *logdir(char *name);
|
||||
const char *basename(char *path);
|
||||
const char *basename(const char *path);
|
||||
FILE *myfopen(char *path, char *mode);
|
||||
char *mygetenv(char *variable, char *deflt);
|
||||
int myopen(char *path, int flag, int mode);
|
||||
|
13
src/main.c
13
src/main.c
@ -259,7 +259,7 @@ static inline void linemode_event_loop(void){
|
||||
int c;
|
||||
|
||||
if (*input_line != '\0') { /* do any optional search */
|
||||
if (search() == true) {
|
||||
if (search(input_line) == true) {
|
||||
/* print the total number of lines in
|
||||
* verbose mode */
|
||||
if (verbosemode == true)
|
||||
@ -272,7 +272,7 @@ static inline void linemode_event_loop(void){
|
||||
}
|
||||
if (onesearch == true) {
|
||||
myexit(0);
|
||||
/* falseTREACHED */
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
for (char *s;;) {
|
||||
@ -281,7 +281,7 @@ static inline void linemode_event_loop(void){
|
||||
printf(">> ");
|
||||
fflush(stdout);
|
||||
if (fgets(buf, sizeof(buf), stdin) == NULL) {
|
||||
myexit(0);
|
||||
myexit(0);
|
||||
}
|
||||
/* remove any trailing newline character */
|
||||
if (*(s = buf + strlen(buf) - 1) == '\n') {
|
||||
@ -300,7 +300,7 @@ static inline void linemode_event_loop(void){
|
||||
case '9': /* samuel only */
|
||||
field = *buf - '0';
|
||||
strcpy(input_line, buf + 1);
|
||||
if (search() == false) {
|
||||
if (search(input_line) == false) {
|
||||
printf("Unable to search database\n");
|
||||
} else {
|
||||
printf("cscope: %d lines\n", totallines);
|
||||
@ -348,8 +348,9 @@ static inline void linemode_event_loop(void){
|
||||
case 'q': /* quit */
|
||||
case ctrl('D'):
|
||||
case ctrl('Z'):
|
||||
myexit(0);
|
||||
|
||||
myexit(0);
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "cscope: unknown command '%s'\n", buf);
|
||||
break;
|
||||
|
@ -156,7 +156,7 @@ void
|
||||
mousemenu(void)
|
||||
{
|
||||
if (mouse == true) {
|
||||
if (changing == true) {
|
||||
if (input_mode == INPUT_CHANGE) {
|
||||
loadmenu(changemenu);
|
||||
}
|
||||
else {
|
||||
|
@ -35,9 +35,9 @@
|
||||
#include "global.h"
|
||||
|
||||
const char *
|
||||
basename(char *path)
|
||||
basename(const char *path)
|
||||
{
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
if ((s = strrchr(path, '/')) != 0) {
|
||||
return(s + 1);
|
||||
|
@ -33,31 +33,32 @@ static void redisplay_function(){
|
||||
|
||||
static void callback_handler(char* line){
|
||||
if(!line){ return; }
|
||||
strncpy(input_line, line, PATLEN);
|
||||
|
||||
switch(input_mode){
|
||||
case INPUT_NORMAL:
|
||||
search();
|
||||
break;
|
||||
case INPUT_CHANGE:
|
||||
changestring(change);
|
||||
input_mode = INPUT_NORMAL;
|
||||
strncpy(input_line, line, PATLEN);
|
||||
search(input_line);
|
||||
curdispline = 0;
|
||||
PCS_reset();
|
||||
current_page = 0;
|
||||
break;
|
||||
case INPUT_CHANGE_TO:
|
||||
strncpy(newpat, line, PATLEN);
|
||||
change = calloc(totallines, sizeof(*change));
|
||||
input_mode = INPUT_CHANGE;
|
||||
horswp_field();
|
||||
return;
|
||||
}
|
||||
|
||||
switch(field){
|
||||
case CHANGE:
|
||||
input_mode = INPUT_CHANGE;
|
||||
input_mode = INPUT_CHANGE_TO;
|
||||
break;
|
||||
case DEFINITION:
|
||||
case FILENAME:
|
||||
if(totallines == 1){ editref(0); }
|
||||
break;
|
||||
}
|
||||
|
||||
curdispline = 0;
|
||||
PCS_reset();
|
||||
current_page = 0;
|
||||
}
|
||||
|
||||
static int ctrl_z(){
|
||||
@ -112,7 +113,7 @@ void rlinit(){
|
||||
rl_bind_key(7, rl_rubout); // XXX: 7 is backspace for some reason (on my system anyways?)
|
||||
rl_bind_key(KEY_BACKSPACE, rl_rubout);
|
||||
|
||||
rl_bind_key(EOF, exit);
|
||||
rl_bind_key(EOF, myexit);
|
||||
rl_bind_key(ctrl('Z'), ctrl_z);
|
||||
rl_bind_key(ctrl('Z'), toggle_caseless);
|
||||
rl_bind_key(ctrl('R'), rebuild_reference);
|
||||
|
@ -6,8 +6,8 @@ struct FILE;
|
||||
/* Page cursor stack */
|
||||
static FILE** hto_page = &refsfound;
|
||||
#define PCS_MAXPAGE 16
|
||||
static long PCS_pos[PCS_MAXPAGE] = {0};
|
||||
static int PCS_top = 0;
|
||||
static size_t PCS_pos[PCS_MAXPAGE] = {0};
|
||||
static size_t PCS_top = 0;
|
||||
|
||||
long seekpage(size_t i){
|
||||
if(i > PCS_MAXPAGE-1){ return -1; }
|
||||
@ -31,7 +31,7 @@ long seekrelline(unsigned i){
|
||||
size_t lc = 0;
|
||||
while(lc < i){
|
||||
const char c = getc(*hto_page);
|
||||
assert(("seekrelline() tried to read past the reference file", !(c == EOF)));
|
||||
assert("seekrelline() tried to read past the reference file" && !(c == EOF));
|
||||
if(c == '\n'){ ++lc; }
|
||||
}
|
||||
return ftell(*hto_page);
|
||||
|
Loading…
Reference in New Issue
Block a user