From 86a1641ac1cdd283e6a4c511d2c12635b38f63aa Mon Sep 17 00:00:00 2001 From: Berni Date: Wed, 13 Apr 2011 04:02:22 -0700 Subject: [PATCH] Fix compiler hanging when #including a directory (bug 4822, r=dvander) --- sourcepawn/compiler/libpawnc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sourcepawn/compiler/libpawnc.c b/sourcepawn/compiler/libpawnc.c index 3331335b..e0e736a2 100644 --- a/sourcepawn/compiler/libpawnc.c +++ b/sourcepawn/compiler/libpawnc.c @@ -29,6 +29,11 @@ #include "sc.h" #include "memfile.h" +#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined DARWIN +#include +#include +#endif + /* pc_printf() * Called for general purpose "console" output. This function prints general * purpose messages; errors go through pc_error(). The function is modelled @@ -100,6 +105,17 @@ static char *prefix[3]={ "error", "fatal error", "warning" }; */ void *pc_opensrc(char *filename) { + #if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined DARWIN + struct stat fileInfo; + if (stat(filename, &fileInfo) != 0) { + return NULL; + } + + if (S_ISDIR(fileInfo.st_mode)) { + return NULL; + } + #endif + return fopen(filename,"rt"); }