diff --git a/.gitignore b/.gitignore
index a49c101..160b5b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,7 @@ bin
autom4te.cache
config.log
config.status
+*.sdf
+*.opensdf
+*.user
+build
diff --git a/contrib/vs/config.bat b/contrib/vs/config.bat
new file mode 100644
index 0000000..f71d875
--- /dev/null
+++ b/contrib/vs/config.bat
@@ -0,0 +1,107 @@
+@echo off
+setlocal enabledelayedexpansion
+
+set PACKAGE_NAME="tl-parser"
+set PACKAGE_TARNAME="tl-parser"
+set PACKAGE_VERSION="1.0"
+set PACKAGE_STRING="tl-parser %PACKAGE_VERSION:~1%"
+set PACKAGE_BUGREPORT=""
+set PACKAGE_URL=""
+
+set CONFIG_HEADER_IN=..\..\config.h.in
+set CONFIG_HEADER=config.h
+set DEFAULT_OUT_FOLDER=build
+set OUT_PATH=""
+set SOURCE_LIST=()
+
+:rem Parse Args
+for %%a in (%*) do (
+ if defined arg (
+ if /I "-o"=="!arg!" set OUT_PATH=%%a
+ set set arg=
+ )
+ if /I "%%a" geq "-" (
+ set arg=%%a
+ ) else (
+ set set arg=
+ )
+)
+if %OUT_PATH%=="" (
+ set OUT_PATH=%DEFAULT_OUT_FOLDER%
+)
+
+:rem Make output folder if not exists
+if not exist !OUT_PATH! mkdir !OUT_PATH!
+
+:rem Copy source files to the output folder
+for %%i in %SOURCE_LIST% do (
+ if not exist %OUT_PATH%\%%i (
+ echo |set /p=Copying file: %%i
+ copy %%i "%OUT_PATH%\%%i" 1>NUL && (
+ echo Done
+ ) || (
+ echo Failed
+ )
+ )
+)
+
+set OUT_PATH="%OUT_PATH%\%CONFIG_HEADER%"
+if exist %OUT_PATH% exit /B 0
+
+:rem Copy config.h.in to the output folder
+echo |set /p=Copying file: %CONFIG_HEADER%
+copy %CONFIG_HEADER_IN% %OUT_PATH% 1>NUL && (
+ echo Done
+) || (
+ echo Failed
+ exit /B %ERRORLEVEL%
+)
+
+:rem Configure config.h
+echo |set /p=Configurating file: config.h
+call :find_and_replace "#undef PACKAGE_BUGREPORT" "#define PACKAGE_BUGREPORT %PACKAGE_BUGREPORT%"
+call :find_and_replace "#undef PACKAGE_NAME" "#define PACKAGE_NAME %PACKAGE_NAME%"
+call :find_and_replace "#undef PACKAGE_STRING" "#define PACKAGE_STRING %PACKAGE_STRING%"
+call :find_and_replace "#undef PACKAGE_TARNAME" "#define PACKAGE_TARNAME %PACKAGE_TARNAME%"
+call :find_and_replace "#undef PACKAGE_URL" "#define PACKAGE_URL %PACKAGE_URL%"
+call :find_and_replace "#undef PACKAGE_VERSION" "#define PACKAGE_VERSION %PACKAGE_VERSION%"
+
+call :find_and_replace "#undef HAVE_FCNTL_H" "#define HAVE_FCNTL_H 1"
+call :find_and_replace "#undef HAVE_INTTYPES_H" "#define HAVE_INTTYPES_H 1"
+call :find_and_replace "#undef HAVE_LIBZ" "#define HAVE_LIBZ 1"
+call :find_and_replace "#undef HAVE_MALLOC" "#define HAVE_MALLOC 1"
+call :find_and_replace "#undef HAVE_MEMORY_H" "#define HAVE_MEMORY_H 1"
+call :find_and_replace "#undef HAVE_MEMSET" "#define HAVE_MEMSET 1"
+call :find_and_replace "#undef HAVE_REALLOC" "#define HAVE_REALLOC 1"
+call :find_and_replace "#undef HAVE_STDINT_H" "#define HAVE_STDINT_H 1"
+call :find_and_replace "#undef HAVE_STDLIB_H" "#define HAVE_STDLIB_H 1"
+call :find_and_replace "#undef HAVE_STRDUP" "#define HAVE_STRDUP 1"
+call :find_and_replace "#undef HAVE_STRING_H" "#define HAVE_STRING_H 1"
+call :find_and_replace "#undef HAVE_SYS_STAT_H" "#define HAVE_SYS_STAT_H 1"
+call :find_and_replace "#undef HAVE_SYS_TYPES_H" "#define HAVE_SYS_TYPES_H 1"
+call :find_and_replace "#undef STDC_HEADERS" "#define STDC_HEADERS 1"
+call :find_and_replace "#undef inline" "#define inline __inline"
+call :find_and_replace "#undef" "// #undef"
+
+if %ERRORLEVEL% == 0 echo Done
+if not %ERRORLEVEL% == 0 (
+ echo Failed
+ if exist %OUT_PATH% del /q /f %OUT_PATH%
+)
+exit /B %ERRORLEVEL%
+
+:find_and_replace
+set FIND_STR=%1
+set "FIND_STR=!FIND_STR:~1,-1!"
+set REPLACE_STR=%2 %3
+set "REPLACE_STR=!REPLACE_STR:~1,-2!"
+
+for /f "delims=" %%i in ('type "%OUT_PATH%" ^| find /n /v "" ^& break ^> "%OUT_PATH%" ') do (
+ set "line=%%i"
+ setlocal enableDelayedExpansion
+ set "line=!line:*]%FIND_STR%=%REPLACE_STR%!"
+ set "line=!line:*]=!"
+ >>"%OUT_PATH%" echo(!line!
+ endlocal
+)
+exit /B %ERRORLEVEL%
diff --git a/contrib/vs/tl-parser.sln b/contrib/vs/tl-parser.sln
new file mode 100644
index 0000000..8365b79
--- /dev/null
+++ b/contrib/vs/tl-parser.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tl-parser", "tl-parser.vcxproj", "{14022761-9F27-4A2D-B7EA-F41FB9B3274C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {14022761-9F27-4A2D-B7EA-F41FB9B3274C}.Debug|x64.ActiveCfg = Debug|x64
+ {14022761-9F27-4A2D-B7EA-F41FB9B3274C}.Debug|x64.Build.0 = Debug|x64
+ {14022761-9F27-4A2D-B7EA-F41FB9B3274C}.Debug|x86.ActiveCfg = Debug|Win32
+ {14022761-9F27-4A2D-B7EA-F41FB9B3274C}.Debug|x86.Build.0 = Debug|Win32
+ {14022761-9F27-4A2D-B7EA-F41FB9B3274C}.Release|x64.ActiveCfg = Release|x64
+ {14022761-9F27-4A2D-B7EA-F41FB9B3274C}.Release|x64.Build.0 = Release|x64
+ {14022761-9F27-4A2D-B7EA-F41FB9B3274C}.Release|x86.ActiveCfg = Release|Win32
+ {14022761-9F27-4A2D-B7EA-F41FB9B3274C}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/contrib/vs/tl-parser.vcxproj b/contrib/vs/tl-parser.vcxproj
new file mode 100644
index 0000000..96e044a
--- /dev/null
+++ b/contrib/vs/tl-parser.vcxproj
@@ -0,0 +1,208 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {14022761-9F27-4A2D-B7EA-F41FB9B3274C}
+ Win32Proj
+ tlparser
+ 8.1
+
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+ Application
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ build\$(Configuration)\
+ build\$(Configuration)\build\
+ $(VC_IncludePath);$(WindowsSDK_IncludePath);$(IntDir);$(ProjectDir);
+ *.h;$(ExtensionsToDeleteOnClean)
+
+
+ true
+ build\$(Platform)\$(Configuration)\
+ build\$(Platform)\$(Configuration)\build\
+ $(VC_IncludePath);$(WindowsSDK_IncludePath);$(IntDir);$(ProjectDir);
+ *.h;$(ExtensionsToDeleteOnClean)
+
+
+ false
+ build\$(Configuration)\
+ build\$(Configuration)\build\
+ $(VC_IncludePath);$(WindowsSDK_IncludePath);$(IntDir);$(ProjectDir);
+ *.h;$(ExtensionsToDeleteOnClean)
+
+
+ false
+ build\$(Platform)\$(Configuration)\
+ build\$(Platform)\$(Configuration)\build\
+ $(VC_IncludePath);$(WindowsSDK_IncludePath);$(IntDir);$(ProjectDir);
+ *.h;$(ExtensionsToDeleteOnClean)
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ false
+ CompileAsC
+
+
+ Console
+ true
+
+
+ %(AdditionalDependencies)
+
+
+ config.bat -o $(IntDir)
+
+
+
+
+
+
+
+
+ Level3
+ Disabled
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+ config.bat -o $(IntDir)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+
+
+ Console
+ true
+ true
+ true
+
+
+ %(AdditionalDependencies)
+
+
+ config.bat -o $(IntDir)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ _CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+
+
+ Console
+ true
+ true
+ true
+
+
+ config.bat -o $(IntDir)
+
+
+
+
+
+
diff --git a/contrib/vs/tl-parser.vcxproj.filters b/contrib/vs/tl-parser.vcxproj.filters
new file mode 100644
index 0000000..2ba314f
--- /dev/null
+++ b/contrib/vs/tl-parser.vcxproj.filters
@@ -0,0 +1,48 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/contrib/vs/wingetopt.c b/contrib/vs/wingetopt.c
new file mode 100644
index 0000000..09dac17
--- /dev/null
+++ b/contrib/vs/wingetopt.c
@@ -0,0 +1,82 @@
+/*
+POSIX getopt for Windows
+
+AT&T Public License
+
+Code given out at the 1985 UNIFORUM conference in Dallas.
+*/
+
+#ifndef __GNUC__
+
+#include "wingetopt.h"
+#include
+#include
+
+#ifndef NULL
+#define NULL 0
+#endif
+#define EOF (-1)
+#define ERR(s, c) if(opterr){\
+ char errbuf[2];\
+ errbuf[0] = c; errbuf[1] = '\n';\
+ fputs(argv[0], stderr);\
+ fputs(s, stderr);\
+ fputc(c, stderr);}
+//(void) write(2, argv[0], (unsigned)strlen(argv[0]));\
+ //(void) write(2, s, (unsigned)strlen(s));\
+ //(void) write(2, errbuf, 2);}
+
+int opterr = 1;
+int optind = 1;
+int optopt;
+char *optarg;
+
+int
+getopt(argc, argv, opts)
+int argc;
+char **argv, *opts;
+{
+ static int sp = 1;
+ register int c;
+ register char *cp;
+
+ if (sp == 1)
+ if (optind >= argc ||
+ argv[optind][0] != '-' || argv[optind][1] == '\0')
+ return(EOF);
+ else if (strcmp(argv[optind], "--") == (int)NULL) {
+ optind++;
+ return(EOF);
+ }
+ optopt = c = argv[optind][sp];
+ if (c == ':' || (cp = strchr(opts, c)) == NULL) {
+ ERR(": illegal option -- ", c);
+ if (argv[optind][++sp] == '\0') {
+ optind++;
+ sp = 1;
+ }
+ return('?');
+ }
+ if (*++cp == ':') {
+ if (argv[optind][sp + 1] != '\0')
+ optarg = &argv[optind++][sp + 1];
+ else if (++optind >= argc) {
+ ERR(": option requires an argument -- ", c);
+ sp = 1;
+ return('?');
+ }
+ else
+ optarg = argv[optind++];
+ sp = 1;
+ }
+ else {
+ if (argv[optind][++sp] == '\0') {
+ sp = 1;
+ optind++;
+ }
+ optarg = NULL;
+ }
+ return(c);
+}
+
+#endif /* __GNUC__ */
\ No newline at end of file
diff --git a/contrib/vs/wingetopt.h b/contrib/vs/wingetopt.h
new file mode 100644
index 0000000..4372c66
--- /dev/null
+++ b/contrib/vs/wingetopt.h
@@ -0,0 +1,32 @@
+/*
+POSIX getopt for Windows
+
+AT&T Public License
+
+Code given out at the 1985 UNIFORUM conference in Dallas.
+*/
+
+#ifdef __GNUC__
+#include
+#endif
+#ifndef __GNUC__
+
+#ifndef _WINGETOPT_H_
+#define _WINGETOPT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ extern int opterr;
+ extern int optind;
+ extern int optopt;
+ extern char *optarg;
+ extern int getopt(int argc, char **argv, char *opts);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GETOPT_H_ */
+#endif /* __GNUC__ */
\ No newline at end of file
diff --git a/portable_endian.h b/portable_endian.h
index da0d140..b39a51e 100644
--- a/portable_endian.h
+++ b/portable_endian.h
@@ -65,7 +65,9 @@
#elif defined(__WINDOWS__)
# include
+# ifdef __MINGW32__
# include
+# endif
# if BYTE_ORDER == LITTLE_ENDIAN
diff --git a/tl-parser.c b/tl-parser.c
index b021185..1238035 100644
--- a/tl-parser.c
+++ b/tl-parser.c
@@ -25,7 +25,13 @@
#define _FILE_OFFSET_BITS 64
#include "config.h"
+#if defined(_MSC_VER)
+#include
+#include
+#include
+#else
#include
+#endif
#include
#include
#include
@@ -241,8 +247,58 @@ char *parse_lex (void) {
parse.lex.len = 1;
parse.lex.type = lex_char;
return (parse.lex.ptr = p);
- case 'a'...'z':
- case 'A'...'Z':
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
parse.lex.flags = 0;
if (is_uletter (curch)) {
while (is_ident_char (nextch ()));
@@ -305,7 +361,16 @@ char *parse_lex (void) {
parse.lex.len = parse.text + parse.pos - p;
parse.lex.type = lex_lc_ident;
return (parse.lex.ptr = p);
- case '0'...'9':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
while (is_digit (nextch ()));
parse.lex.len = parse.text + parse.pos - p;
parse.lex.type = lex_num;
@@ -321,7 +386,11 @@ char *parse_lex (void) {
int expect (char *s) {
if (!parse.lex.ptr || parse.lex.ptr == (void *)-1 || parse.lex.type == lex_error || parse.lex.type == lex_none || parse.lex.len != (int)strlen (s) || memcmp (s, parse.lex.ptr, parse.lex.len)) {
static char buf[1000];
- sprintf (buf, "Expected %s", s);
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ sprintf_s(buf, 1000, "Expected %s", s);
+#else
+ sprintf(buf, "Expected %s", s);
+#endif
parse_error (buf);
return -1;
} else {
@@ -331,15 +400,27 @@ int expect (char *s) {
}
struct parse *tl_init_parse_file (const char *fname) {
- int fd = open (fname, O_RDONLY);
- if (fd < 0) {
- fprintf (stderr, "Error %m\n");
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ int fd = 0;
+ if (_sopen_s(&fd, fname, _O_RDONLY | _O_BINARY, _SH_DENYNO, _S_IREAD | _S_IWRITE) != 0) {
+ char errorStr[256] = { 0 };
+ strerror_s(errorStr, 256, errno);
+ fprintf(stderr, "Error %s\n", errorStr);
+#elif defined(WIN32) || defined(_WIN32)
+ int fd = open(fname, O_RDONLY | O_BINARY);
+ if (fd < 0) {
+ fprintf(stderr, "Error %s\n", strerror(errno));
+#else
+ int fd = open(fname, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "Error %m\n");
+#endif
assert (0);
return 0;
}
long long size = lseek (fd, 0, SEEK_END);
if (size <= 0) {
- fprintf (stderr, "size is %lld. Too small.\n", size);
+ fprintf (stderr, "size is %"_PRINTF_INT64_"d. Too small.\n", size);
return 0;
}
static struct parse save;
@@ -1352,7 +1433,11 @@ void tl_buf_add_tree (struct tl_combinator_tree *T, int x) {
tl_buf_add_string_q ((char *)v->data, -1, x);
if (T->type == type_num && T->type_flags) {
static char _buf[30];
- sprintf (_buf, "+%lld", T->type_flags);
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ sprintf_s(_buf, 30, "+%"_PRINTF_INT64_"d", T->type_flags);
+#else
+ sprintf(_buf, "+%"_PRINTF_INT64_"d", T->type_flags);
+#endif
tl_buf_add_string_q (_buf, -1, 0);
}
}
@@ -1379,7 +1464,7 @@ void tl_buf_add_tree (struct tl_combinator_tree *T, int x) {
case act_nat_const:
{
static char _buf[30];
- snprintf (_buf, 29, "%lld", T->type_flags);
+ snprintf (_buf, 29, "%"_PRINTF_INT64_"d", T->type_flags);
tl_buf_add_string_q (_buf, -1, x);
return;
}
@@ -1389,7 +1474,11 @@ void tl_buf_add_tree (struct tl_combinator_tree *T, int x) {
tl_buf_add_string_q ((char *)v->data, -1, x);
tl_buf_add_string_q (".", -1, 0);
static char _buf[30];
- sprintf (_buf, "%lld", T->left->type_flags);
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ sprintf_s(_buf, 30, "%"_PRINTF_INT64_"d", T->left->type_flags);
+#else
+ sprintf(_buf, "%"_PRINTF_INT64_"d", T->left->type_flags);
+#endif
tl_buf_add_string_q (_buf, -1, 0);
tl_buf_add_string_q ("?", -1, 0);
tl_buf_add_tree (T->right, 0);
@@ -1421,7 +1510,11 @@ int tl_print_combinator (struct tl_constructor *c) {
tl_buf_reset ();
tl_buf_add_string_nospace (c->real_id ? c->real_id : c->id, -1);
static char _buf[10];
- sprintf (_buf, "#%08x", c->name);
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ sprintf_s(_buf, 10, "#%08x", c->name);
+#else
+ sprintf(_buf, "#%08x", c->name);
+#endif
tl_buf_add_string_nospace (_buf, -1);
tl_buf_add_tree (c->left, 1);
tl_buf_add_string ("=", -1);
@@ -1517,7 +1610,7 @@ struct tl_combinator_tree *tl_union (struct tl_combinator_tree *L, struct tl_com
return 0;
}
if (L->type_len > 0 && ((L->type_flags & 1) != (R->type == type_num || R->type == type_num_value))) {
- TL_ERROR ("Argument types mistmatch: L->type_flags = %lld, R->type = %s\n", L->flags, TL_TYPE (R->type));
+ TL_ERROR ("Argument types mistmatch: L->type_flags = %"_PRINTF_INT64_"d, R->type = %s\n", L->flags, TL_TYPE (R->type));
return 0;
}
v->type = type_type;
@@ -1904,7 +1997,11 @@ struct tl_combinator_tree *tl_parse_args134 (struct tree *T) {
char *name = S->data;
if (!name) {
static char s[20];
- sprintf (s, "%lld", lrand48 () * (1ll << 32) + lrand48 ());
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ sprintf_s(s, 20, "%"_PRINTF_INT64_"d", lrand48() * (1ll << 32) + lrand48());
+#else
+ sprintf(s, "%"_PRINTF_INT64_"d", lrand48() * (1ll << 32) + lrand48());
+#endif
name = s;
}
struct tl_var *v = tl_add_var (name, S, tt);
diff --git a/tl-parser.h b/tl-parser.h
index faa142b..7eb7524 100644
--- a/tl-parser.h
+++ b/tl-parser.h
@@ -24,6 +24,21 @@
#ifndef __TL_PARSER_NEW_H__
#define __TL_PARSER_NEW_H__
+#if defined(WIN32) || defined(_WIN32)
+#define lrand48() rand()
+#define _PRINTF_INT64_ "I64"
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+#define read _read
+#define write _write
+#define close _close
+#define lseek _lseek
+#define strdup _strdup
+#define __attribute__(x)
+#endif
+#else
+#define _PRINTF_INT64_ "ll"
+#endif
+
enum lex_type {
lex_error,
lex_char,
diff --git a/tlc.c b/tlc.c
index cd0300f..d0edd20 100644
--- a/tlc.c
+++ b/tlc.c
@@ -28,9 +28,15 @@
#include
#include
-#include "tl-parser.h"
-
+#if defined(_MSC_VER)
+#include
+#include
+#include
+#include "wingetopt.h"
+#else
#include
+#endif
+#include "tl-parser.h"
#include
#include
#include
@@ -56,8 +62,16 @@ void usage (void) {
}
int vkext_write (const char *filename) {
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ int f = 0;
+ assert(_sopen_s(&f, filename, _O_CREAT | _O_WRONLY | _O_TRUNC | _O_BINARY, _SH_DENYNO, _S_IREAD | _S_IWRITE) == 0);
+#elif defined(WIN32) || defined(_WIN32)
+ int f = open(filename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0640);
+ assert(f >= 0);
+#else
int f = open (filename, O_CREAT | O_WRONLY | O_TRUNC, 0640);
assert (f >= 0);
+#endif
write_types (f);
close (f);
return 0;