nothing of significance

This commit is contained in:
anon 2024-11-14 11:28:28 +01:00
parent 6f97db5f58
commit a7fe078b33

View File

@ -41,8 +41,6 @@
#include "build.h" #include "build.h"
#include "scanner.h" #include "scanner.h"
#include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
/* convert long to a string in base BASE notation */ /* convert long to a string in base BASE notation */
@ -77,22 +75,20 @@ static long macrooffset; /* macro name database offset */
static unsigned long msymbols = SYMBOLINC; /* maximum number of symbols */ static unsigned long msymbols = SYMBOLINC; /* maximum number of symbols */
struct symbol { /* symbol data */ struct symbol { /* symbol data */
int type; /* type */ int type; /* type */
unsigned int first; /* index of first character in text */ unsigned int first; /* index of first character in text */
unsigned int last; /* index of last+1 character in text */ unsigned int last; /* index of last+1 character in text */
unsigned int length; /* symbol length */ unsigned int length; /* symbol length */
unsigned int fcn_level; /* function level of the symbol */ unsigned int fcn_level; /* function level of the symbol */
}; };
static struct symbol *symbol; static struct symbol *symbol;
static void putcrossref(void); static void putcrossref(void);
static void savesymbol(int token, int num); static void savesymbol(int token, int num);
void crossref(char *srcfile) { void crossref(char * srcfile) {
unsigned int i;
unsigned int length; /* symbol length */ unsigned int length; /* symbol length */
unsigned int entry_no; /* function level of the symbol */ unsigned int entry_no; /* function level of the symbol */
int token; /* current token */
struct stat st; struct stat st;
if(!((stat(srcfile, &st) == 0) && S_ISREG(st.st_mode))) { if(!((stat(srcfile, &st) == 0) && S_ISREG(st.st_mode))) {
@ -103,11 +99,13 @@ void crossref(char *srcfile) {
entry_no = 0; entry_no = 0;
/* open the source file */ /* open the source file */
if((yyin = myfopen(srcfile, "r")) == NULL) { yyin = myfopen(srcfile, "r");
if(!yyin) {
cannotopen(srcfile); cannotopen(srcfile);
errorsfound = true; errorsfound = true;
return; return;
} }
filename = srcfile; /* save the file name for warning messages */ filename = srcfile; /* save the file name for warning messages */
putfilename(srcfile); /* output the file name */ putfilename(srcfile); /* output the file name */
dbputc('\n'); dbputc('\n');
@ -119,7 +117,7 @@ void crossref(char *srcfile) {
symbols = 0; symbols = 0;
if(symbol == NULL) { symbol = malloc(msymbols * sizeof(*symbol)); } if(symbol == NULL) { symbol = malloc(msymbols * sizeof(*symbol)); }
for(;;) { for(;;) {
int token; /* current token */
/* get the next token */ /* get the next token */
switch(token = yylex()) { switch(token = yylex()) {
default: default:
@ -138,18 +136,21 @@ void crossref(char *srcfile) {
/* update entry_no if see function entry */ /* update entry_no if see function entry */
if(token == FCNDEF) { entry_no++; } if(token == FCNDEF) { entry_no++; }
/* see if the symbol is already in the list */ /* see if the symbol is already in the list */
for(i = 0; i < symbols; ++i) { {
if(length == symbol[i].length && unsigned i;
strncmp(my_yytext + first, my_yytext + symbol[i].first, length) == for(i = 0; i < symbols; ++i) {
0 && if(length == symbol[i].length &&
entry_no == symbol[i].fcn_level && strncmp(my_yytext + first, my_yytext + symbol[i].first, length) ==
token == symbol[i].type) { /* could be a::a() */ 0 &&
break; entry_no == symbol[i].fcn_level &&
} token == symbol[i].type) { /* could be a::a() */
} break;
if(i == symbols) { /* if not already in list */ }
savesymbol(token, entry_no); }
} if(i == symbols) { /* if not already in list */
savesymbol(token, entry_no);
}
}
break; break;
case NEWLINE: /* end of line containing symbols */ case NEWLINE: /* end of line containing symbols */