From ea8166963b574357be73ae83eb1cb7704e206794 Mon Sep 17 00:00:00 2001 From: anon Date: Tue, 12 Nov 2024 21:21:24 +0100 Subject: [PATCH] simple edits --- source/crossref.c | 32 +++++++++++++------------------- source/main.c | 7 ++++--- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/source/crossref.c b/source/crossref.c index a4bf588..cfae99a 100644 --- a/source/crossref.c +++ b/source/crossref.c @@ -54,7 +54,7 @@ digits = 1; \ while(n >= BASE) { \ ++digits; \ - i = n; \ + int i = n; \ n /= BASE; \ *--s = i - n * BASE + '!'; \ } \ @@ -181,7 +181,6 @@ void crossref(char *srcfile) { } /* save the symbol in the list */ - static void savesymbol(int token, int num) { /* make sure there is room for the symbol */ if(symbols == msymbols) { @@ -198,7 +197,6 @@ static void savesymbol(int token, int num) { } /* output the file name */ - void putfilename(char *srcfile) { /* check for file system out of space */ /* note: dbputc is not used to avoid lint complaint */ @@ -343,15 +341,14 @@ void putcrossref(void) { /* HBB 20000421: new function, for avoiding memory leaks */ /* free the cross reference symbol table */ void freecrossref() { - if(symbol) free(symbol); + if (symbol) { free(symbol); } symbol = NULL; symbols = 0; } /* output the inverted index posting */ - void putposting(char *term, int type) { - long i, n; + long n; char *s; int digits; /* digits output */ long offset; /* function/macro database offset */ @@ -359,9 +356,9 @@ void putposting(char *term, int type) { /* get the function or macro name offset */ offset = fcnoffset; - if(macrooffset != 0) { offset = macrooffset; } + if (macrooffset != 0) { offset = macrooffset; } /* then update them to avoid negative relative name offset */ - switch(type) { + switch (type) { case DEFINE: macrooffset = dboffset; break; @@ -376,9 +373,9 @@ void putposting(char *term, int type) { return; /* null term */ } /* ignore a null term caused by a enum/struct/union without a tag */ - if(*term == '\0') { return; } + if (*term == '\0') { return; } /* skip any #include secondary type char (< or ") */ - if(type == INCLUDE) { ++term; } + if (type == INCLUDE) { ++term; } /* output the posting, which should be as small as possible to reduce the temp file size and sort time */ (void)fputs(term, postings); @@ -388,7 +385,7 @@ void putposting(char *term, int type) { in ascending line offset order to order the references as they appear withing a source file */ ltobase(lineoffset); - for(i = PRECISION - digits; i > 0; --i) { + for (long i = PRECISION - digits; i > 0; --i) { (void)putc('!', postings); } do { @@ -399,14 +396,14 @@ void putposting(char *term, int type) { (void)putc(type, postings); /* function or macro name offset */ - if(offset > 0) { + if (offset > 0) { (void)putc(' ', postings); ltobase(offset); do { (void)putc(*s, postings); } while(*++s != '\0'); } - if(putc('\n', postings) == EOF) { + if (putc('\n', postings) == EOF) { cannotwrite(temp1); /* NOTREACHED */ } @@ -414,10 +411,8 @@ void putposting(char *term, int type) { } /* put the string into the new database */ - void writestring(char *s) { unsigned char c; - int i; if(compress == false) { /* Save some I/O overhead by using puts() instead of putc(): */ @@ -425,7 +420,7 @@ void writestring(char *s) { return; } /* compress digraphs */ - for(i = 0; (c = s[i]) != '\0'; ++i) { + for(int i = 0; (c = s[i]) != '\0'; ++i) { if(/* dicode1[c] && dicode2[(unsigned char) s[i + 1]] */ IS_A_DICODE(c, s[i + 1])) { /* c = (0200 - 2) + dicode1[c] + dicode2[(unsigned char) s[i + 1]]; */ @@ -437,13 +432,12 @@ void writestring(char *s) { } /* print a warning message with the file name and line number */ - void warning(char *text) { - (void)fprintf(stderr, PROGRAM_NAME ": \"%s\", line %d: warning: %s\n", filename, myylineno, - text); + text + ); errorsfound = true; } diff --git a/source/main.c b/source/main.c index 7314de4..9e2d80d 100644 --- a/source/main.c +++ b/source/main.c @@ -314,8 +314,8 @@ int main(int argc, char **argv) { init_temp_files(); /* 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 @@ -323,7 +323,8 @@ int main(int argc, char **argv) { * the home directory */ snprintf(path, sizeof(path), "%s/%s", home, reffile); - if(isuptodate == false || access(path, READ) == 0) { + if (preserve_database == false + || access(path, READ) == 0) { reffile = strdup(path); snprintf(path, sizeof(path), "%s/%s", home, invname); invname = strdup(path);