styling and such, nothing of substance

This commit is contained in:
anon 2024-11-10 13:07:10 +01:00
parent 30e5ee9995
commit 9646ef6752
8 changed files with 60 additions and 55 deletions

View File

@ -93,12 +93,14 @@ static bool samelist(FILE *oldrefs, char **names, int count);
/* Error handling routine if inverted index creation fails */ /* Error handling routine if inverted index creation fails */
static void cannotindex(void) { static void cannotindex(void) {
fprintf(stderr, PROGRAM_NAME ": cannot create inverted index; ignoring -q option\n");
invertedindex = false; invertedindex = false;
errorsfound = true; errorsfound = true;
fprintf(stderr, PROGRAM_NAME ": removed files %s and %s\n", newinvname, newinvpost);
fprintf(stderr, PROGRAM_NAME ": cannot create inverted index; ignoring -q option\n");
unlink(newinvname); unlink(newinvname);
unlink(newinvpost); unlink(newinvpost);
fprintf(stderr, PROGRAM_NAME ": removed files %s and %s\n", newinvname, newinvpost);
} }
/* see if the name list is the same in the cross-reference file */ /* see if the name list is the same in the cross-reference file */
@ -108,14 +110,15 @@ static bool samelist(FILE *oldrefs, char **names, int count) {
int i; int i;
/* see if the number of names is the same */ /* see if the number of names is the same */
if(fscanf(oldrefs, "%d", &oldcount) != 1 || oldcount != count) { return (false); } if(fscanf(oldrefs, "%d", &oldcount) != 1 || oldcount != count) { return false; }
/* see if the name list is the same */ /* see if the name list is the same */
for(i = 0; i < count; ++i) { for(i = 0; i < count; ++i) {
if((1 != fscanf(oldrefs, " %[^\n]", oldname)) || strnotequal(oldname, names[i])) { if((1 != fscanf(oldrefs, " %[^\n]", oldname))
return (false); || strnotequal(oldname, names[i])) {
return false;
} }
} }
return (true); return true;
} }
/* create the file name(s) used for a new cross-referene */ /* create the file name(s) used for a new cross-referene */
@ -139,7 +142,6 @@ void setup_build_filenames(char *reffile) {
} }
/* open the database */ /* open the database */
void opendatabase(void) { void opendatabase(void) {
if((symrefs = vpopen(reffile, O_BINARY | O_RDONLY)) == -1) { if((symrefs = vpopen(reffile, O_BINARY | O_RDONLY)) == -1) {
cannotopen(reffile); cannotopen(reffile);
@ -204,11 +206,10 @@ void build(void) {
/* if there is an old cross-reference and its current directory matches */ /* if there is an old cross-reference and its current directory matches */
/* or this is an unconditional build */ /* or this is an unconditional build */
if((oldrefs = vpfopen(reffile, "rb")) != NULL && unconditional == false && if((oldrefs = vpfopen(reffile, "rb")) != NULL
fscanf(oldrefs, PROGRAM_NAME " %d %" PATHLEN_STR "s", &fileversion, olddir) == && !unconditional
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 */
fstat(fileno(oldrefs), &file_status); fstat(fileno(oldrefs), &file_status);
reftime = file_status.st_mtime; reftime = file_status.st_mtime;
@ -216,12 +217,10 @@ void build(void) {
bool oldcompress = true; bool oldcompress = true;
bool oldinvertedindex = false; bool oldinvertedindex = false;
bool oldtruncate = false; bool oldtruncate = false;
int c;
/* see if there are options in the database */ /* see if there are options in the database */
for(;;) { for(int c;;) {
while((c = getc(oldrefs)) == ' ') while((c = getc(oldrefs)) == ' ') { ; }
; /* do nothing */
if(c != '-') { if(c != '-') {
ungetc(c, oldrefs); ungetc(c, oldrefs);
break; break;
@ -452,7 +451,8 @@ void build(void) {
} }
/* string comparison function for qsort */ /* string comparison function for qsort */
static int compare(const void *arg_s1, const void *arg_s2) { static
int compare(const void *arg_s1, const void *arg_s2) {
const char **s1 = (const char **)arg_s1; const char **s1 = (const char **)arg_s1;
const char **s2 = (const char **)arg_s2; const char **s2 = (const char **)arg_s2;
@ -472,7 +472,8 @@ void seek_to_trailer(FILE *f) {
} }
/* get the next file name in the old cross-reference */ /* get the next file name in the old cross-reference */
static char *getoldfile(void) { static
char *getoldfile(void) {
static char file[PATHLEN + 1]; /* file name in old crossref */ static char file[PATHLEN + 1]; /* file name in old crossref */
if(blockp != NULL) { if(blockp != NULL) {
@ -481,13 +482,14 @@ static char *getoldfile(void) {
skiprefchar(); skiprefchar();
fetch_string_from_dbase(file, sizeof(file)); fetch_string_from_dbase(file, sizeof(file));
if(file[0] != '\0') { /* if not end-of-crossref */ if(file[0] != '\0') { /* if not end-of-crossref */
return (file); return file;
} }
return (NULL); return NULL;
} }
} while(scanpast('\t') != NULL); } while(scanpast('\t') != NULL);
} }
return (NULL);
return NULL;
} }
/* Free all storage allocated for filenames: */ /* Free all storage allocated for filenames: */
@ -499,7 +501,8 @@ void free_newbuildfiles(void) {
/* output the cscope version, current directory, database format options, and /* output the cscope version, current directory, database format options, and
the database trailer offset */ the database trailer offset */
static void putheader(char *dir) { static
void putheader(char *dir) {
dboffset = fprintf(newrefs, PROGRAM_NAME " %d %s", FILEVERSION, dir); dboffset = fprintf(newrefs, PROGRAM_NAME " %d %s", FILEVERSION, dir);
if(compress == false) { dboffset += fprintf(newrefs, " -c"); } if(compress == false) { dboffset += fprintf(newrefs, " -c"); }
if(invertedindex == true) { if(invertedindex == true) {
@ -519,8 +522,9 @@ static void putheader(char *dir) {
} }
/* put the name list into the cross-reference file */ /* put the name list into the cross-reference file */
static void putlist(char **names, int count) {
int i, size = 0; int i, size = 0;
static
void putlist(char **names, int count) {
fprintf(newrefs, "%d\n", count); fprintf(newrefs, "%d\n", count);
if(names == srcfiles) { if(names == srcfiles) {
@ -540,7 +544,8 @@ static void putlist(char **names, int count) {
} }
/* copy this file's symbol data */ /* copy this file's symbol data */
static void copydata(void) { static
void copydata(void) {
char *cp; char *cp;
setmark('\t'); setmark('\t');
@ -574,8 +579,8 @@ static void copydata(void) {
} }
/* copy this file's symbol data and output the inverted index postings */ /* copy this file's symbol data and output the inverted index postings */
static
static void copyinverted(void) { void copyinverted(void) {
char *cp; char *cp;
char c; char c;
int type; /* reference type (mark character) */ int type; /* reference type (mark character) */
@ -640,7 +645,8 @@ static void copyinverted(void) {
} }
/* replace the old file with the new file */ /* replace the old file with the new file */
static void movefile(char *new, char *old) { static
void movefile(char *new, char *old) {
unlink(old); unlink(old);
if(rename(new, old) == -1) { if(rename(new, old) == -1) {
myperror(PROGRAM_NAME); myperror(PROGRAM_NAME);
@ -650,7 +656,8 @@ static void movefile(char *new, char *old) {
} }
/* process the #included file in the old database */ /* process the #included file in the old database */
static void fetch_include_from_dbase(char *s, size_t length) { static
void fetch_include_from_dbase(char *s, size_t length) {
dbputc(INCLUDE); dbputc(INCLUDE);
skiprefchar(); skiprefchar();
fetch_string_from_dbase(s, length); fetch_string_from_dbase(s, length);

View File

@ -213,8 +213,8 @@ void putfilename(char *srcfile) {
} }
/* output the symbols and source line */ /* output the symbols and source line */
static
static void putcrossref(void) { void putcrossref(void) {
unsigned int i, j; unsigned int i, j;
unsigned char c; unsigned char c;
bool blank; /* blank indicator */ bool blank; /* blank indicator */

View File

@ -248,7 +248,7 @@ void makefilelist(void) {
if(namefile == NULL) { if(namefile == NULL) {
/* No namefile --> make a list of all the source files /* No namefile --> make a list of all the source files
* in the directories */ * in the directories */
for(i = 0; i < nsrcdirs; ++i) { for(unsigned i = 0; i < nsrcdirs; i++) {
scan_dir(srcdirs[i], recurse_dir); scan_dir(srcdirs[i], recurse_dir);
} }
return; return;

View File

@ -793,7 +793,8 @@ void ogsnames(char *file, char **subsystem, char **book) {
} }
} }
static inline void display_tooltip(void) { static inline
void display_tooltip(void) {
wmove(wtooltip, 0, 0); wmove(wtooltip, 0, 0);
const char *tooltip; const char *tooltip;
if(*current_window == winput) { if(*current_window == winput) {

View File

@ -58,8 +58,6 @@ static pid_t myfork(void);
/* execute forks and executes a program or shell script, waits for it to /* execute forks and executes a program or shell script, waits for it to
* finish, and returns its exit code. * finish, and returns its exit code.
*/ */
/*VARARGS1*/
int execute(char *a, ...) /* NOTE: "exec" is already defined on u370 */ int execute(char *a, ...) /* NOTE: "exec" is already defined on u370 */
{ {
va_list ap; va_list ap;
@ -73,7 +71,7 @@ int execute(char *a, ...) /* NOTE: "exec" is already defined on u370 */
fflush(stdout); fflush(stdout);
va_start(ap, a); va_start(ap, a);
for(p = 0; (argv[p] = va_arg(ap, char *)) != 0; p++) { } for(p = 0; (argv[p] = va_arg(ap, char *)) != 0; p++) { ; }
#ifdef __MSDOS__ #ifdef __MSDOS__
/* HBB 20010313: in MSDOG, everything is completely different. /* HBB 20010313: in MSDOG, everything is completely different.

View File

@ -88,8 +88,8 @@ static char *SUPFING, *supfing;
static char thisterm[TERMMAX]; static char thisterm[TERMMAX];
typedef union logicalblk { typedef union logicalblk {
long invblk[BLOCKSIZE / sizeof(long)]; long invblk[BLOCKSIZE / sizeof(long)];
char chrblk[BLOCKSIZE]; char chrblk[BLOCKSIZE];
} t_logicalblk; } t_logicalblk;
static t_logicalblk logicalblk; static t_logicalblk logicalblk;

View File

@ -100,9 +100,8 @@ struct keystruct keyword[] = {
static struct keystruct *hashtab[HASHMOD]; /* pointer table */ static struct keystruct *hashtab[HASHMOD]; /* pointer table */
/* put the keywords into the symbol table */ /* put the keywords into the symbol table */
void initsymtab(void) { void initsymtab(void) {
for(unsigned i = 1; i < KEYWORDS; ++i) { for(unsigned i = 1; i < KEYWORDS; i++) {
struct keystruct *p = keyword + i; struct keystruct *p = keyword + i;
int j = hash(p->text) % HASHMOD; int j = hash(p->text) % HASHMOD;
p->next = hashtab[j]; p->next = hashtab[j];
@ -111,7 +110,6 @@ void initsymtab(void) {
} }
/* see if this identifier is a keyword */ /* see if this identifier is a keyword */
char * lookup(char *ident, bool do_compressed) { char * lookup(char *ident, bool do_compressed) {
struct keystruct *p; struct keystruct *p;
int c; int c;
@ -126,7 +124,7 @@ char * lookup(char *ident, bool do_compressed) {
} }
} }
/* this is an identifier */ /* this is an identifier */
return (NULL); return NULL;
} }
/* form hash value for string */ /* form hash value for string */

View File

@ -95,17 +95,16 @@ static inline void screenmode_event_loop(void);
static inline void siginit(void) { static inline
void siginit(void) {
/* if running in the foreground */ /* if running in the foreground */
if(signal(SIGINT, SIG_IGN) != SIG_IGN) { if(signal(SIGINT, SIG_IGN) != SIG_IGN) {
/* cleanup on the interrupt and quit signals */ /* cleanup on the interrupt and quit signals */
signal(SIGINT, myexit); signal(SIGINT, myexit);
signal(SIGQUIT, myexit); signal(SIGQUIT, myexit);
} }
/* cleanup on the hangup signal */
signal(SIGHUP, myexit);
/* ditto the TERM signal */ signal(SIGHUP, myexit);
signal(SIGTERM, myexit); signal(SIGTERM, myexit);
/* ignore PIPE signal, so myexit() will have a chance to clean up in /* ignore PIPE signal, so myexit() will have a chance to clean up in
@ -134,7 +133,8 @@ void cannotwrite(const char *const file) {
} }
/* set up the digraph character tables for text compression */ /* set up the digraph character tables for text compression */
static void initcompress(void) { static
void initcompress(void) {
int i; int i;
if(compress == true) { if(compress == true) {
@ -194,7 +194,8 @@ void myexit(int sig) {
exit(sig); exit(sig);
} }
static inline void linemode_event_loop(void) { 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 */
@ -203,14 +204,13 @@ static inline void linemode_event_loop(void) {
* verbose mode */ * verbose mode */
if(verbosemode == true) printf(PROGRAM_NAME ": %d lines\n", totallines); if(verbosemode == true) printf(PROGRAM_NAME ": %d lines\n", totallines);
while((c = getc(refsfound)) != EOF) while((c = getc(refsfound)) != EOF) {
putchar(c); putchar(c);
}
} }
} }
if(onesearch == true) {
myexit(0); if(onesearch == true) { myexit(0); }
/* NOTREACHED */
}
for(char *s;;) { for(char *s;;) {
char buf[PATLEN + 2]; char buf[PATLEN + 2];
@ -290,7 +290,8 @@ static inline void linemode_event_loop(void) {
} }
} }
static inline void screenmode_event_loop(void) { static inline
void screenmode_event_loop(void) {
for(;;) { for(;;) {
display(); display();
handle_input(wgetch(stdscr)); // NOTE: getch() does not return KEY_* codes handle_input(wgetch(stdscr)); // NOTE: getch() does not return KEY_* codes
@ -347,8 +348,8 @@ int main(int argc, char **argv) {
snprintf(temp2, sizeof(temp2), "%s/" PROGRAM_NAME ".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) {
/* put it in the home directory if the database may not be /* put it in the home directory if the database may not be
* up-to-date or doesn't exist in the relative directory, * up-to-date or doesn't exist in the relative directory,
* so a database in the current directory will be * so a database in the current directory will be