Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions source/compiler/sc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,31 @@ static int command(void)
cell val;
preproc_expr(&val,NULL);
sc_needsemicolon=(int)val;
} else if (strcmp(str,"once")==0) {
char symname[sNAMEMAX];
symbol *included;
/* make it compatible for Windows paths with '\\' directory separator */
char* basefname=inpfname;
for (char* _cchar=inpfname; *_cchar!='\0'; _cchar++)
if (*_cchar=='/'||*_cchar=='\\')
basefname=_cchar+1;
/* assign '_inc_includename' string to symname */
strcpy(symname,"_inc_");
strlcat(symname,basefname,sizeof symname);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How closely does this replicate all the behaviour here: https://github.com/pawn-lang/compiler/wiki/File-Inclusion

/* check if '_inc_includename' is already in global symbols table or not */
included=find_symbol(&glbtab,symname,fcurrent,-1,NULL);
if (included==NULL)
/* couldn't find '_inc_includename' in symbols table */
add_constant(symname,1,sGLOBAL,0); // add symname ('_inc_includename') to global symbols table
else {
/* found '_inc_includename' symbol in global symbols table */
if (!SKIPPING) {
assert(inpf!=NULL);
if (inpf!=inpf_org)
pc_closesrc(inpf); // close input file (like #endinput)
inpf=NULL;
} /* if */
}
} else if (strcmp(str,"tabsize")==0) {
cell val;
preproc_expr(&val,NULL);
Expand Down