tGScanner from files bug workaround for Win32 - vaccinewars - be a doctor and t… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 208b0fef94da2cc898ae5eb89b5af27558e08f29 | |
parent 8f548a99c170fe2832460898159bf6bbcbd899f1 | |
Author: Ben Webb <[email protected]> | |
Date: Sat, 28 Apr 2001 17:42:19 +0000 | |
GScanner from files bug workaround for Win32 | |
Diffstat: | |
M src/dopewars.c | 13 +++++++++++++ | |
1 file changed, 13 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/src/dopewars.c b/src/dopewars.c | |
t@@ -1234,19 +1234,32 @@ void CopyDrugs(struct DRUGS *dest,struct DRUGS *src) { | |
} | |
void ReadConfigFile(char *FileName) { | |
+/* Read a configuration file given by "FileName"; GScanner under Win32 */ | |
+/* doesn't work properly with files, so we use a nasty workaround */ | |
FILE *fp; | |
+#ifdef CYGWIN | |
+ char *buf; | |
+#endif | |
GScanner *scanner; | |
fp=fopen(FileName,"r"); | |
if (fp) { | |
scanner=g_scanner_new(&ScannerConfig); | |
scanner->input_name=FileName; | |
+#ifdef CYGWIN | |
+ read_string(fp,&buf); if (!buf) { fclose(fp); return; } | |
+ g_scanner_input_text(scanner,buf,strlen(buf)); | |
+#else | |
g_scanner_input_file(scanner,fileno(fp)); | |
+#endif | |
while (!g_scanner_eof(scanner)) if (!ParseNextConfig(scanner)) { | |
g_scanner_error(scanner, | |
_("Unable to process configuration file line")); | |
} | |
g_scanner_destroy(scanner); | |
fclose(fp); | |
+#ifdef CYGWIN | |
+ g_free(buf); | |
+#endif | |
} | |
} | |