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