Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ".pwn" to the official list of extensions. #701

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion source/compiler/sc.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ SC_FUNC cell do_static_check(int use_warning);
SC_FUNC void pushstk(stkitem val);
SC_FUNC stkitem popstk(void);
SC_FUNC void clearstk(void);
SC_FUNC int plungequalifiedfile(char *name); /* explicit path included */
SC_FUNC int plungequalifiedfile(char *name,char new_extensions); /* explicit path included */
Copy link
Contributor

@Daniel-Cortez Daniel-Cortez Jun 18, 2022

Choose a reason for hiding this comment

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

Suggested change
SC_FUNC int plungequalifiedfile(char *name,char new_extensions); /* explicit path included */
SC_FUNC int plungequalifiedfile(char *name,int new_extensions); /* explicit path included */

In this codebase boolean values are usually stored in variables of type int. Not sure why, but still...

SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths); /* search through "include" paths */
SC_FUNC int number(cell *val,const unsigned char *curptr);
SC_FUNC void preprocess(void);
Expand Down
4 changes: 2 additions & 2 deletions source/compiler/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ int pc_compile(int argc, char *argv[])
if (strcmp(incfname,sDEF_PREFIX)==0) {
plungefile(incfname,FALSE,TRUE); /* parse "default.inc" */
} else {
if (!plungequalifiedfile(incfname)) /* parse "prefix" include file */
if (!plungequalifiedfile(incfname,1)) /* parse "prefix" include file */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (!plungequalifiedfile(incfname,1)) /* parse "prefix" include file */
if (!plungequalifiedfile(incfname,TRUE)) /* parse "prefix" include file */

error(100,incfname); /* cannot read from ... (fatal error) */
} /* if */
} /* if */
Expand Down Expand Up @@ -755,7 +755,7 @@ int pc_compile(int argc, char *argv[])
if (strcmp(incfname,sDEF_PREFIX)==0)
plungefile(incfname,FALSE,TRUE); /* parse "default.inc" (again) */
else
plungequalifiedfile(incfname); /* parse implicit include file (again) */
plungequalifiedfile(incfname,1); /* parse implicit include file (again) */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
plungequalifiedfile(incfname,1); /* parse implicit include file (again) */
plungequalifiedfile(incfname,TRUE); /* parse implicit include file (again) */

} /* if */
warnstack_init();
preprocess(); /* fetch first line */
Expand Down
15 changes: 8 additions & 7 deletions source/compiler/sc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@ SC_FUNC void clearstk(void)
assert(stktop==0);
}

SC_FUNC int plungequalifiedfile(char *name)
SC_FUNC int plungequalifiedfile(char *name,char new_extensions)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SC_FUNC int plungequalifiedfile(char *name,char new_extensions)
SC_FUNC int plungequalifiedfile(char *name,int new_extensions)

{
static char extensions[][6] = { "", ".inc", ".p", ".pawn" };
unsigned int skipped_extensions=new_extensions?0:1;
static char extensions[][6] = { "", ".inc", ".p", ".pawn", ".pwn"};
int found;
struct stat st;
FILE *fp;
char *path;
char *real_path;
char *ext;
int ext_idx;
unsigned int ext_idx;

fp=NULL;
ext_idx=0;
Expand Down Expand Up @@ -178,7 +179,7 @@ static char extensions[][6] = { "", ".inc", ".p", ".pawn" };
found=FALSE;
} /* if */
ext_idx++;
} while (!found && ext_idx<arraysize(extensions));
} while (!found && ext_idx<arraysize(extensions)-skipped_extensions);
if (!found) {
*ext='\0'; /* restore filename */
free(path);
Expand Down Expand Up @@ -227,7 +228,7 @@ SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths)
int result=FALSE;

if (try_currentpath) {
result=plungequalifiedfile(name);
result=plungequalifiedfile(name,0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
result=plungequalifiedfile(name,0);
result=plungequalifiedfile(name,FALSE);

if (!result) {
/* failed to open the file in the active directory, try to open the file
* in the same directory as the current file --but first check whether
Expand All @@ -240,7 +241,7 @@ SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths)
char path[_MAX_PATH];
strlcpy(path,inpfname,len+1);
strlcat(path,name,arraysize(path));
result=plungequalifiedfile(path);
result=plungequalifiedfile(path,1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
result=plungequalifiedfile(path,1);
result=plungequalifiedfile(path,TRUE);

} /* if */
} /* if */
} /* if */
Expand All @@ -253,7 +254,7 @@ SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths)
char path[_MAX_PATH];
strlcpy(path,ptr,arraysize(path));
strlcat(path,name,arraysize(path));
result=plungequalifiedfile(path);
result=plungequalifiedfile(path,1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
result=plungequalifiedfile(path,1);
result=plungequalifiedfile(path,TRUE);

} /* for */
} /* if */
return result;
Expand Down