Merge master

This commit is contained in:
Emil 2023-08-04 11:54:19 -06:00
commit ff21fa6438

View File

@ -1,7 +1,7 @@
/*=========================================================================== /*===========================================================================
Copyright (c) 1998-2000, The Santa Cruz Operation Copyright (c) 1998-2000, The Santa Cruz Operation
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
@ -14,7 +14,7 @@
*Neither name of The Santa Cruz Operation nor the names of its contributors *Neither name of The Santa Cruz Operation nor the names of its contributors
may be used to endorse or promote products derived from this software may be used to endorse or promote products derived from this software
without specific prior written permission. without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
@ -27,7 +27,7 @@
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. DAMAGE.
=========================================================================*/ =========================================================================*/
/* cscope - interactive C symbol cross-reference /* cscope - interactive C symbol cross-reference
@ -99,7 +99,7 @@ static int fldline; /* input field line */
static sigjmp_buf env; /* setjmp/longjmp buffer */ static sigjmp_buf env; /* setjmp/longjmp buffer */
static char lastmsg[MSGLEN + 1]; /* last message displayed */ static char lastmsg[MSGLEN + 1]; /* last message displayed */
static const char helpstring[] = "Press the ? key for help"; static const char helpstring[] = "Press the ? key for help";
static const char selprompt[] = static const char selprompt[] =
"Select lines to change (press the ? key for help): "; "Select lines to change (press the ? key for help): ";
typedef char * (*FP)(char *); /* pointer to function returning a character pointer */ typedef char * (*FP)(char *); /* pointer to function returning a character pointer */
@ -273,7 +273,7 @@ static inline void display_results(){
} }
srctxtw -= numlen+1; srctxtw -= numlen+1;
/* 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; topline = nextline;
for (disprefs = 0, screenline = WRESULT_TABLE_BODY_START; for (disprefs = 0, screenline = WRESULT_TABLE_BODY_START;
@ -284,7 +284,7 @@ static inline void display_results(){
if ( if (
fscanf(refsfound, "%" PATHLEN_STR "s%" PATHLEN_STR "s%" NUMLEN_STR "s %" TEMPSTRING_LEN_STR "[^\n]", fscanf(refsfound, "%" PATHLEN_STR "s%" PATHLEN_STR "s%" NUMLEN_STR "s %" TEMPSTRING_LEN_STR "[^\n]",
file, file,
function, function,
linenum, linenum,
tempstring tempstring
) )
@ -296,7 +296,7 @@ static inline void display_results(){
} }
++nextline; ++nextline;
displine[disprefs] = screenline; displine[disprefs] = screenline;
wprintw(wresult, "%c", dispchars[disprefs]); wprintw(wresult, "%c", dispchars[disprefs]);
/* display any change mark */ /* display any change mark */
@ -344,7 +344,7 @@ static inline void display_results(){
for (;;) { for (;;) {
/* if the source line does not fit */ /* if the source line does not fit */
if ((i = strlen(s)) > srctxtw) { if ((i = strlen(s)) > srctxtw) {
/* find the nearest blank */ /* find the nearest blank */
for (i = srctxtw; s[i] != ' ' && i > 0; --i) { for (i = srctxtw; s[i] != ' ' && i > 0; --i) {
; ;
@ -357,7 +357,7 @@ static inline void display_results(){
/* print up to this point */ /* print up to this point */
wprintw(wresult, "%.*s", i, s); wprintw(wresult, "%.*s", i, s);
s += i; s += i;
/* if line didn't wrap around */ /* if line didn't wrap around */
if (i < srctxtw) { if (i < srctxtw) {
waddch(wresult, '\n'); /* go to next line */ waddch(wresult, '\n'); /* go to next line */
@ -380,14 +380,14 @@ static inline void display_results(){
/* break out of two loops */ /* break out of two loops */
goto endrefs; goto endrefs;
} }
/* erase the reference */ /* erase the reference */
while (--screenline >= displine[disprefs]) { while (--screenline >= displine[disprefs]) {
wmove(wresult, screenline, 0); wmove(wresult, screenline, 0);
wclrtoeol(wresult); wclrtoeol(wresult);
} }
++screenline; ++screenline;
/* go back to the beginning of this reference */ /* go back to the beginning of this reference */
--nextline; --nextline;
seekline(nextline); seekline(nextline);
@ -506,7 +506,7 @@ search(void)
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;
/* open the references found file for writing */ /* open the references found file for writing */
if (writerefsfound() == NO) { if (writerefsfound() == NO) {
return(NO); return(NO);
@ -529,7 +529,7 @@ search(void)
if ((rc = findinit(input_line)) == NOERROR) { if ((rc = findinit(input_line)) == NOERROR) {
(void) dbseek(0L); /* read the first block */ (void) dbseek(0L); /* read the first block */
findresult = (*f)(input_line); findresult = (*f)(input_line);
if (f == findcalledby) if (f == findcalledby)
funcexist = (*findresult == 'y'); funcexist = (*findresult == 'y');
findcleanup(); findcleanup();
@ -551,7 +551,7 @@ search(void)
/* rewind the cross-reference file */ /* rewind the cross-reference file */
(void) lseek(symrefs, (long) 0, 0); (void) lseek(symrefs, (long) 0, 0);
/* reopen the references found file for reading */ /* reopen the references found file for reading */
(void) fclose(refsfound); (void) fclose(refsfound);
if ((refsfound = myfopen(temp1, "rb")) == NULL) { if ((refsfound = myfopen(temp1, "rb")) == NULL) {
@ -561,24 +561,24 @@ search(void)
nextline = 1; nextline = 1;
totallines = 0; totallines = 0;
disprefs = 0; disprefs = 0;
/* see if it is empty */ /* see if it is empty */
if ((c = getc(refsfound)) == EOF) { if ((c = getc(refsfound)) == EOF) {
if (findresult != NULL) { if (findresult != NULL) {
(void) snprintf(lastmsg, sizeof(lastmsg), "Egrep %s in this pattern: %s", (void) snprintf(lastmsg, sizeof(lastmsg), "Egrep %s in this pattern: %s",
findresult, input_line); findresult, input_line);
} else if (rc == NOTSYMBOL) { } else if (rc == NOTSYMBOL) {
(void) snprintf(lastmsg, sizeof(lastmsg), "This is not a C symbol: %s", (void) snprintf(lastmsg, sizeof(lastmsg), "This is not a C symbol: %s",
input_line); input_line);
} else if (rc == REGCMPERROR) { } else if (rc == REGCMPERROR) {
(void) snprintf(lastmsg, sizeof(lastmsg), "Error in this regcomp(3) regular expression: %s", (void) snprintf(lastmsg, sizeof(lastmsg), "Error in this regcomp(3) regular expression: %s",
input_line); input_line);
} else if (funcexist == NO) { } else if (funcexist == NO) {
(void) snprintf(lastmsg, sizeof(lastmsg), "Function definition does not exist: %s", (void) snprintf(lastmsg, sizeof(lastmsg), "Function definition does not exist: %s",
input_line); input_line);
} else { } else {
(void) snprintf(lastmsg, sizeof(lastmsg), "Could not find the %s: %s", (void) snprintf(lastmsg, sizeof(lastmsg), "Could not find the %s: %s",
fields[field].text2, input_line); fields[field].text2, input_line);
} }
return(NO); return(NO);
@ -586,10 +586,10 @@ search(void)
/* put back the character read */ /* put back the character read */
(void) ungetc(c, refsfound); (void) ungetc(c, refsfound);
/* HBB 20041027: this used to hold a copy of the code of
* countrefs(), but with the crucial display width adjustments
* missing. Just call the real thing instead! */
countrefs(); countrefs();
window_change |= CH_RESULT;
return(YES); return(YES);
} }
@ -647,7 +647,7 @@ progress(char *what, long current, long max)
/* print error message on system call failure */ /* print error message on system call failure */
void void
myperror(char *text) myperror(char *text)
{ {
char msg[MSGLEN + 1]; /* message */ char msg[MSGLEN + 1]; /* message */
char *s; char *s;
@ -661,7 +661,7 @@ myperror(char *text)
/* postmsg clears the message line and prints the message */ /* postmsg clears the message line and prints the message */
void void
postmsg(char *msg) postmsg(char *msg)
{ {
if (linemode == YES || incurses == NO) { if (linemode == YES || incurses == NO) {
(void) printf("%s\n", msg); (void) printf("%s\n", msg);
@ -696,7 +696,7 @@ clearmsg2(void)
/* postmsg2 clears the second message line and prints the message */ /* postmsg2 clears the second message line and prints the message */
void void
postmsg2(char *msg) postmsg2(char *msg)
{ {
if (linemode == YES) { if (linemode == YES) {
(void) printf("%s\n", msg); (void) printf("%s\n", msg);
@ -710,19 +710,19 @@ postmsg2(char *msg)
/* display an error mesg - stdout or on second msg line */ /* display an error mesg - stdout or on second msg line */
void void
posterr(char *msg, ...) posterr(char *msg, ...)
{ {
va_list ap; va_list ap;
char errbuf[MSGLEN]; char errbuf[MSGLEN];
va_start(ap, msg); va_start(ap, msg);
if (linemode == YES || incurses == NO) if (linemode == YES || incurses == NO)
{ {
(void) vfprintf(stderr, msg, ap); (void) vfprintf(stderr, msg, ap);
(void) fputc('\n', stderr); (void) fputc('\n', stderr);
} else { } else {
vsnprintf(errbuf, sizeof(errbuf), msg, ap); vsnprintf(errbuf, sizeof(errbuf), msg, ap);
postmsg2(errbuf); postmsg2(errbuf);
} }
va_end(ap); va_end(ap);
} }
@ -750,7 +750,7 @@ postfatal(const char *msg, ...)
/* position references found file at specified line */ /* position references found file at specified line */
void void
seekline(unsigned int line) seekline(unsigned int line)
{ {
int c; int c;
@ -760,7 +760,7 @@ seekline(unsigned int line)
} }
/* go to the beginning of the file */ /* go to the beginning of the file */
rewind(refsfound); rewind(refsfound);
/* find the requested line */ /* find the requested line */
nextline = 1; nextline = 1;
while (nextline < line && (c = getc(refsfound)) != EOF) { while (nextline < line && (c = getc(refsfound)) != EOF) {
@ -804,7 +804,7 @@ pathcomponents(char *path, int components)
{ {
int i; int i;
char *s; char *s;
s = path + strlen(path) - 1; s = path + strlen(path) - 1;
for (i = 0; i < components; ++i) { for (i = 0; i < components; ++i) {
while (s > path && *--s != '/') { while (s > path && *--s != '/') {