From 67a29b927e09fffa27c441f0e32fff38164ae56d Mon Sep 17 00:00:00 2001 From: Zeex Date: Sun, 22 Feb 2015 23:08:32 +0600 Subject: [PATCH] Revert "Fix freeze when include file is a directory" This reverts commit cebb44800ee81f0a71dc594a3f542df892134c0a. --- source/compiler/sc2.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index d5a7c70..93d321e 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -124,19 +124,22 @@ SC_FUNC void clearstk(void) SC_FUNC int plungequalifiedfile(char *name) { -static char *extensions[] = { ".inc", ".p", ".pawn", "" }; +static char *extensions[] = { ".inc", ".p", ".pawn" }; FILE *fp; char *ext; int ext_idx; ext_idx=0; do { + fp=(FILE*)pc_opensrc(name); ext=strchr(name,'\0'); /* save position */ - /* try to append an extension */ - strcpy(ext,extensions[ext_idx]); - fp=pc_opensrc(name); - if (fp==NULL) - *ext='\0'; /* on failure, restore filename */ + if (fp==NULL) { + /* try to append an extension */ + strcpy(ext,extensions[ext_idx]); + fp=(FILE*)pc_opensrc(name); + if (fp==NULL) + *ext='\0'; /* on failure, restore filename */ + } /* if */ ext_idx++; } while (fp==NULL && ext_idx<(sizeof extensions / sizeof extensions[0])); if (fp==NULL) { @@ -3017,3 +3020,4 @@ static char itohstr[30]; *ptr='\0'; /* and a zero-terminator */ return itohstr; } +