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 */
@ -89,10 +87,8 @@ 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,6 +136,8 @@ 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 */
{
unsigned i;
for(i = 0; i < symbols; ++i) { for(i = 0; i < symbols; ++i) {
if(length == symbol[i].length && if(length == symbol[i].length &&
strncmp(my_yytext + first, my_yytext + symbol[i].first, length) == strncmp(my_yytext + first, my_yytext + symbol[i].first, length) ==
@ -149,6 +149,7 @@ void crossref(char *srcfile) {
} }
if(i == symbols) { /* if not already in list */ if(i == symbols) { /* if not already in list */
savesymbol(token, entry_no); savesymbol(token, entry_no);
}
} }
break; break;