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