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

View File

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

View File

@ -248,7 +248,7 @@ void makefilelist(void) {
if(namefile == NULL) {
/* No namefile --> make a list of all the source files
* in the directories */
for(i = 0; i < nsrcdirs; ++i) {
for(unsigned i = 0; i < nsrcdirs; i++) {
scan_dir(srcdirs[i], recurse_dir);
}
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);
const char *tooltip;
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
* finish, and returns its exit code.
*/
/*VARARGS1*/
int execute(char *a, ...) /* NOTE: "exec" is already defined on u370 */
{
va_list ap;
@ -73,7 +71,7 @@ int execute(char *a, ...) /* NOTE: "exec" is already defined on u370 */
fflush(stdout);
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__
/* HBB 20010313: in MSDOG, everything is completely different.

View File

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

View File

@ -100,9 +100,8 @@ struct keystruct keyword[] = {
static struct keystruct *hashtab[HASHMOD]; /* pointer table */
/* put the keywords into the symbol table */
void initsymtab(void) {
for(unsigned i = 1; i < KEYWORDS; ++i) {
for(unsigned i = 1; i < KEYWORDS; i++) {
struct keystruct *p = keyword + i;
int j = hash(p->text) % HASHMOD;
p->next = hashtab[j];
@ -111,7 +110,6 @@ void initsymtab(void) {
}
/* see if this identifier is a keyword */
char * lookup(char *ident, bool do_compressed) {
struct keystruct *p;
int c;
@ -126,7 +124,7 @@ char * lookup(char *ident, bool do_compressed) {
}
}
/* this is an identifier */
return (NULL);
return NULL;
}
/* 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(signal(SIGINT, SIG_IGN) != SIG_IGN) {
/* cleanup on the interrupt and quit signals */
signal(SIGINT, myexit);
signal(SIGQUIT, myexit);
}
/* cleanup on the hangup signal */
signal(SIGHUP, myexit);
/* ditto the TERM signal */
signal(SIGHUP, myexit);
signal(SIGTERM, myexit);
/* 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 */
static void initcompress(void) {
static
void initcompress(void) {
int i;
if(compress == true) {
@ -194,7 +194,8 @@ void myexit(int sig) {
exit(sig);
}
static inline void linemode_event_loop(void) {
static inline
void linemode_event_loop(void) {
int c;
if(*input_line != '\0') { /* do any optional search */
@ -203,14 +204,13 @@ static inline void linemode_event_loop(void) {
* verbose mode */
if(verbosemode == true) printf(PROGRAM_NAME ": %d lines\n", totallines);
while((c = getc(refsfound)) != EOF)
while((c = getc(refsfound)) != EOF) {
putchar(c);
}
}
}
if(onesearch == true) {
myexit(0);
/* NOTREACHED */
}
if(onesearch == true) { myexit(0); }
for(char *s;;) {
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(;;) {
display();
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);
/* 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
* up-to-date or doesn't exist in the relative directory,
* so a database in the current directory will be