diff --git a/.gitignore b/.gitignore index 592aecf3..c9009951 100644 --- a/.gitignore +++ b/.gitignore @@ -42,9 +42,13 @@ gen.json extract_metadata test_sav_date test_double_decimals +generate_corpus *.csv *.json *.py *.tar.gz *.zip .DS_Store +**/*.vcxproj.user +Debug/ +Release/ diff --git a/VS17/PropertySheet.props b/VS17/PropertySheet.props new file mode 100644 index 00000000..1e9d00c3 --- /dev/null +++ b/VS17/PropertySheet.props @@ -0,0 +1,12 @@ + + + + + + + + READSTAT_VERSION="1.1.4";_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + + \ No newline at end of file diff --git a/VS17/ReadStat.sln b/VS17/ReadStat.sln new file mode 100644 index 00000000..a446b34a --- /dev/null +++ b/VS17/ReadStat.sln @@ -0,0 +1,96 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2047 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadStat", "ReadStat.vcxproj", "{7D9D3258-8850-466E-8A74-4F8025E6FA49}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadStat_Test_readstat", "ReadStat_Test_readstat\ReadStat_Test_readstat.vcxproj", "{E9408E27-6E13-46C9-B07D-9569BD078EF6}" + ProjectSection(ProjectDependencies) = postProject + {7D9D3258-8850-466E-8A74-4F8025E6FA49} = {7D9D3258-8850-466E-8A74-4F8025E6FA49} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadStat_App", "ReadStat_App\ReadStat_App.vcxproj", "{80188B4B-81A0-4113-A848-CB6483D185EA}" + ProjectSection(ProjectDependencies) = postProject + {7D9D3258-8850-466E-8A74-4F8025E6FA49} = {7D9D3258-8850-466E-8A74-4F8025E6FA49} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadStat_Test_double_decimals", "ReadStat_Test_double_decimals\ReadStat_Test_double_decimals.vcxproj", "{96AB8E29-11AC-40F0-871A-856DD9C78EAB}" + ProjectSection(ProjectDependencies) = postProject + {7D9D3258-8850-466E-8A74-4F8025E6FA49} = {7D9D3258-8850-466E-8A74-4F8025E6FA49} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadStat_Test_dta_days", "ReadStat_Test_dta_days\ReadStat_Test_dta_days.vcxproj", "{D6F08523-A8F5-4F2A-A57B-EC013A136DA6}" + ProjectSection(ProjectDependencies) = postProject + {7D9D3258-8850-466E-8A74-4F8025E6FA49} = {7D9D3258-8850-466E-8A74-4F8025E6FA49} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadStat_Test_sav_date", "ReadStat_Test_sav_date\ReadStat_Test_sav_date.vcxproj", "{D5265192-6034-4689-94FF-8B2060FBC309}" + ProjectSection(ProjectDependencies) = postProject + {7D9D3258-8850-466E-8A74-4F8025E6FA49} = {7D9D3258-8850-466E-8A74-4F8025E6FA49} + EndProjectSection +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 + {7D9D3258-8850-466E-8A74-4F8025E6FA49}.Debug|x64.ActiveCfg = Debug|x64 + {7D9D3258-8850-466E-8A74-4F8025E6FA49}.Debug|x64.Build.0 = Debug|x64 + {7D9D3258-8850-466E-8A74-4F8025E6FA49}.Debug|x86.ActiveCfg = Debug|Win32 + {7D9D3258-8850-466E-8A74-4F8025E6FA49}.Debug|x86.Build.0 = Debug|Win32 + {7D9D3258-8850-466E-8A74-4F8025E6FA49}.Release|x64.ActiveCfg = Release|x64 + {7D9D3258-8850-466E-8A74-4F8025E6FA49}.Release|x64.Build.0 = Release|x64 + {7D9D3258-8850-466E-8A74-4F8025E6FA49}.Release|x86.ActiveCfg = Release|Win32 + {7D9D3258-8850-466E-8A74-4F8025E6FA49}.Release|x86.Build.0 = Release|Win32 + {E9408E27-6E13-46C9-B07D-9569BD078EF6}.Debug|x64.ActiveCfg = Debug|x64 + {E9408E27-6E13-46C9-B07D-9569BD078EF6}.Debug|x64.Build.0 = Debug|x64 + {E9408E27-6E13-46C9-B07D-9569BD078EF6}.Debug|x86.ActiveCfg = Debug|Win32 + {E9408E27-6E13-46C9-B07D-9569BD078EF6}.Debug|x86.Build.0 = Debug|Win32 + {E9408E27-6E13-46C9-B07D-9569BD078EF6}.Release|x64.ActiveCfg = Release|x64 + {E9408E27-6E13-46C9-B07D-9569BD078EF6}.Release|x64.Build.0 = Release|x64 + {E9408E27-6E13-46C9-B07D-9569BD078EF6}.Release|x86.ActiveCfg = Release|Win32 + {E9408E27-6E13-46C9-B07D-9569BD078EF6}.Release|x86.Build.0 = Release|Win32 + {80188B4B-81A0-4113-A848-CB6483D185EA}.Debug|x64.ActiveCfg = Debug|x64 + {80188B4B-81A0-4113-A848-CB6483D185EA}.Debug|x64.Build.0 = Debug|x64 + {80188B4B-81A0-4113-A848-CB6483D185EA}.Debug|x86.ActiveCfg = Debug|Win32 + {80188B4B-81A0-4113-A848-CB6483D185EA}.Debug|x86.Build.0 = Debug|Win32 + {80188B4B-81A0-4113-A848-CB6483D185EA}.Release|x64.ActiveCfg = Release|x64 + {80188B4B-81A0-4113-A848-CB6483D185EA}.Release|x64.Build.0 = Release|x64 + {80188B4B-81A0-4113-A848-CB6483D185EA}.Release|x86.ActiveCfg = Release|Win32 + {80188B4B-81A0-4113-A848-CB6483D185EA}.Release|x86.Build.0 = Release|Win32 + {96AB8E29-11AC-40F0-871A-856DD9C78EAB}.Debug|x64.ActiveCfg = Debug|x64 + {96AB8E29-11AC-40F0-871A-856DD9C78EAB}.Debug|x64.Build.0 = Debug|x64 + {96AB8E29-11AC-40F0-871A-856DD9C78EAB}.Debug|x86.ActiveCfg = Debug|Win32 + {96AB8E29-11AC-40F0-871A-856DD9C78EAB}.Debug|x86.Build.0 = Debug|Win32 + {96AB8E29-11AC-40F0-871A-856DD9C78EAB}.Release|x64.ActiveCfg = Release|x64 + {96AB8E29-11AC-40F0-871A-856DD9C78EAB}.Release|x64.Build.0 = Release|x64 + {96AB8E29-11AC-40F0-871A-856DD9C78EAB}.Release|x86.ActiveCfg = Release|Win32 + {96AB8E29-11AC-40F0-871A-856DD9C78EAB}.Release|x86.Build.0 = Release|Win32 + {D6F08523-A8F5-4F2A-A57B-EC013A136DA6}.Debug|x64.ActiveCfg = Debug|x64 + {D6F08523-A8F5-4F2A-A57B-EC013A136DA6}.Debug|x64.Build.0 = Debug|x64 + {D6F08523-A8F5-4F2A-A57B-EC013A136DA6}.Debug|x86.ActiveCfg = Debug|Win32 + {D6F08523-A8F5-4F2A-A57B-EC013A136DA6}.Debug|x86.Build.0 = Debug|Win32 + {D6F08523-A8F5-4F2A-A57B-EC013A136DA6}.Release|x64.ActiveCfg = Release|x64 + {D6F08523-A8F5-4F2A-A57B-EC013A136DA6}.Release|x64.Build.0 = Release|x64 + {D6F08523-A8F5-4F2A-A57B-EC013A136DA6}.Release|x86.ActiveCfg = Release|Win32 + {D6F08523-A8F5-4F2A-A57B-EC013A136DA6}.Release|x86.Build.0 = Release|Win32 + {D5265192-6034-4689-94FF-8B2060FBC309}.Debug|x64.ActiveCfg = Debug|x64 + {D5265192-6034-4689-94FF-8B2060FBC309}.Debug|x64.Build.0 = Debug|x64 + {D5265192-6034-4689-94FF-8B2060FBC309}.Debug|x86.ActiveCfg = Debug|Win32 + {D5265192-6034-4689-94FF-8B2060FBC309}.Debug|x86.Build.0 = Debug|Win32 + {D5265192-6034-4689-94FF-8B2060FBC309}.Release|x64.ActiveCfg = Release|x64 + {D5265192-6034-4689-94FF-8B2060FBC309}.Release|x64.Build.0 = Release|x64 + {D5265192-6034-4689-94FF-8B2060FBC309}.Release|x86.ActiveCfg = Release|Win32 + {D5265192-6034-4689-94FF-8B2060FBC309}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B01A5CE6-8035-4FD5-A80B-1E63884D1506} + EndGlobalSection +EndGlobal diff --git a/VS17/ReadStat.vcxproj b/VS17/ReadStat.vcxproj new file mode 100644 index 00000000..9a0e2c39 --- /dev/null +++ b/VS17/ReadStat.vcxproj @@ -0,0 +1,261 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {7D9D3258-8850-466E-8A74-4F8025E6FA49} + Win32Proj + ReadStat + 10.0.17763.0 + + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + + + false + + + $(ProjectDir)..\..\iconv\include;%(AdditionalIncludeDirectories) + $(IntDir)FakePath\%(RelativeDir) + $(IntDir)FakePath\%(RelativeDir)\ + + + Windows + true + + + + + NotUsing + Level3 + Disabled + true + WIN64;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + $(ProjectDir)..\..\iconv\include;%(AdditionalIncludeDirectories) + $(IntDir)FakePath\%(RelativeDir) + $(IntDir)FakePath\%(RelativeDir)\ + + + Windows + true + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + + + false + + + $(ProjectDir)..\..\iconv\include;%(AdditionalIncludeDirectories) + $(IntDir)FakePath\%(RelativeDir) + $(IntDir)FakePath\%(RelativeDir)\ + + + Windows + true + true + true + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + $(ProjectDir)..\..\iconv\include;%(AdditionalIncludeDirectories) + $(IntDir)FakePath\%(RelativeDir) + $(IntDir)FakePath\%(RelativeDir)\ + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VS17/ReadStat.vcxproj.filters b/VS17/ReadStat.vcxproj.filters new file mode 100644 index 00000000..d722f68a --- /dev/null +++ b/VS17/ReadStat.vcxproj.filters @@ -0,0 +1,243 @@ + + + + + {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;ipp;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 + + + {36d69d1d-b944-4abc-9981-ca8572816f7a} + + + {88abd1ce-1660-482c-87b3-9d210ee57a1b} + + + {f7d7807e-0c88-4fd8-8d4a-4e1c18783cae} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\sas + + + Source Files\sas + + + Source Files\sas + + + Source Files\sas + + + Source Files\sas + + + Source Files\sas + + + Source Files\sas + + + Source Files\sas + + + Source Files\sas + + + Source Files\sas + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\spss + + + Source Files\stata + + + Source Files\stata + + + Source Files\stata + + + Source Files\stata + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/VS17/ReadStat_App/ReadStat_App.vcxproj b/VS17/ReadStat_App/ReadStat_App.vcxproj new file mode 100644 index 00000000..775a1606 --- /dev/null +++ b/VS17/ReadStat_App/ReadStat_App.vcxproj @@ -0,0 +1,222 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 15.0 + {80188B4B-81A0-4113-A848-CB6483D185EA} + Win32Proj + ReadStatApp + 10.0.17763.0 + ReadStat_App + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + ReadStat.lib;libiconvD.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName); + + + + + NotUsing + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + ReadStat.lib;libiconvD.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + ReadStat.lib;libiconv.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName); + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + ReadStat.lib;libiconv.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + + \ No newline at end of file diff --git a/VS17/ReadStat_App/ReadStat_App.vcxproj.filters b/VS17/ReadStat_App/ReadStat_App.vcxproj.filters new file mode 100644 index 00000000..15473541 --- /dev/null +++ b/VS17/ReadStat_App/ReadStat_App.vcxproj.filters @@ -0,0 +1,144 @@ + + + + + {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;ipp;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 + + + {91d99aae-1d30-4dab-923c-4e331303b7c8} + + + {de4b7ac4-3816-4eea-a44f-949af9bb3a37} + + + {8f2a21ef-feb4-4b94-bfa9-40433fb84f36} + + + {ddbd8e6f-15a8-42dc-ac41-a8dbf6b67fea} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\util + + + Source Files\util + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files\util + + + Header Files\util + + + \ No newline at end of file diff --git a/VS17/ReadStat_Test_double_decimals/ReadStat_Test_double_decimals.vcxproj b/VS17/ReadStat_Test_double_decimals/ReadStat_Test_double_decimals.vcxproj new file mode 100644 index 00000000..3d2f43c8 --- /dev/null +++ b/VS17/ReadStat_Test_double_decimals/ReadStat_Test_double_decimals.vcxproj @@ -0,0 +1,192 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {96AB8E29-11AC-40F0-871A-856DD9C78EAB} + Win32Proj + ReadStatTests + 10.0.17763.0 + ReadStat_Test_double_decimals + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + false + + + true + + + true + + + false + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName);%(AdditionalLibraryDirectories) + ReadStat.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName);%(AdditionalLibraryDirectories) + ReadStat.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + true + WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + ReadStat.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + ReadStat.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + + + + + + + + + \ No newline at end of file diff --git a/VS17/ReadStat_Test_double_decimals/ReadStat_Test_double_decimals.vcxproj.filters b/VS17/ReadStat_Test_double_decimals/ReadStat_Test_double_decimals.vcxproj.filters new file mode 100644 index 00000000..5f533212 --- /dev/null +++ b/VS17/ReadStat_Test_double_decimals/ReadStat_Test_double_decimals.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {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;ipp;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 + + + {bc66b4d8-b052-45e3-83e6-c757da36b820} + + + {4429e582-f8a5-49eb-b347-4bd29ed708c1} + + + + + Source Files + + + Source Files\write + + + + + Header Files\write + + + \ No newline at end of file diff --git a/VS17/ReadStat_Test_dta_days/ReadStat_Test_dta_days.vcxproj b/VS17/ReadStat_Test_dta_days/ReadStat_Test_dta_days.vcxproj new file mode 100644 index 00000000..737ede08 --- /dev/null +++ b/VS17/ReadStat_Test_dta_days/ReadStat_Test_dta_days.vcxproj @@ -0,0 +1,192 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {D6F08523-A8F5-4F2A-A57B-EC013A136DA6} + Win32Proj + ReadStatTests + 10.0.17763.0 + ReadStat_Test_dta_days + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + false + + + true + + + true + + + false + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName);%(AdditionalLibraryDirectories) + ReadStat.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName);%(AdditionalLibraryDirectories) + ReadStat.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + true + WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + ReadStat.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + ReadStat.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + + + + + + + + + \ No newline at end of file diff --git a/VS17/ReadStat_Test_dta_days/ReadStat_Test_dta_days.vcxproj.filters b/VS17/ReadStat_Test_dta_days/ReadStat_Test_dta_days.vcxproj.filters new file mode 100644 index 00000000..f01a8e29 --- /dev/null +++ b/VS17/ReadStat_Test_dta_days/ReadStat_Test_dta_days.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {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;ipp;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 + + + {a9dc55c0-eadc-4894-9f72-c59adba6368d} + + + {f0d789bb-6100-449e-9c28-91496e119e6a} + + + + + Header Files\util + + + + + Source Files + + + Source Files\util + + + \ No newline at end of file diff --git a/VS17/ReadStat_Test_readstat/ReadStat_Test_readstat.vcxproj b/VS17/ReadStat_Test_readstat/ReadStat_Test_readstat.vcxproj new file mode 100644 index 00000000..4e09878e --- /dev/null +++ b/VS17/ReadStat_Test_readstat/ReadStat_Test_readstat.vcxproj @@ -0,0 +1,209 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {E9408E27-6E13-46C9-B07D-9569BD078EF6} + Win32Proj + ReadStatTests + 10.0.17763.0 + ReadStat_Test_readstat + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + false + + + true + + + true + + + false + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName);%(AdditionalLibraryDirectories) + ReadStat.lib;libiconv.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName);%(AdditionalLibraryDirectories) + ReadStat.lib;libiconvD.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + true + WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + ReadStat.lib;libiconvD.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + ReadStat.lib;libiconv.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VS17/ReadStat_Test_readstat/ReadStat_Test_readstat.vcxproj.filters b/VS17/ReadStat_Test_readstat/ReadStat_Test_readstat.vcxproj.filters new file mode 100644 index 00000000..9c61d0ca --- /dev/null +++ b/VS17/ReadStat_Test_readstat/ReadStat_Test_readstat.vcxproj.filters @@ -0,0 +1,81 @@ + + + + + {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;ipp;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 + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/VS17/ReadStat_Test_sav_date/ReadStat_Test_sav_date.vcxproj b/VS17/ReadStat_Test_sav_date/ReadStat_Test_sav_date.vcxproj new file mode 100644 index 00000000..a1b4df3d --- /dev/null +++ b/VS17/ReadStat_Test_sav_date/ReadStat_Test_sav_date.vcxproj @@ -0,0 +1,192 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {D5265192-6034-4689-94FF-8B2060FBC309} + Win32Proj + ReadStatTests + 10.0.17763.0 + ReadStat_Test_sav_date + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + false + + + true + + + true + + + false + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName);%(AdditionalLibraryDirectories) + ReadStat.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + true + WIN32;_DEBUG;DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + $(ProjectDir)..\..\..\iconv\lib;..\$(ConfigurationName);%(AdditionalLibraryDirectories) + ReadStat.lib;%(AdditionalDependencies) + + + + + NotUsing + Level3 + Disabled + true + WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + ReadStat.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + NotUsing + Level3 + MaxSpeed + true + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + $(IntDir)FakePath\FakePath\%(RelativeDir) + $(ProjectDir)..\..\..\iconv\include + $(IntDir)FakePath\FakePath\%(RelativeDir)\ + + + Console + true + true + false + ReadStat.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(ProjectDir)..\..\..\iconv\lib64;..\x64\$(ConfigurationName) + + + + + + + + + + + + + \ No newline at end of file diff --git a/VS17/ReadStat_Test_sav_date/ReadStat_Test_sav_date.vcxproj.filters b/VS17/ReadStat_Test_sav_date/ReadStat_Test_sav_date.vcxproj.filters new file mode 100644 index 00000000..c84ab465 --- /dev/null +++ b/VS17/ReadStat_Test_sav_date/ReadStat_Test_sav_date.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {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;ipp;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 + + + {2348db41-955b-434d-b332-e856065fa485} + + + {46e899c2-0b26-4c91-877e-7ce755c899d7} + + + + + Source Files + + + Source Files\util + + + + + Header Files\util + + + \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index a037929b..1b83576d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,11 +1,14 @@ version: 0.1.{build} -os: Windows Server 2012 R2 +os: Windows Server 2016 + +image: Visual Studio 2017 platform: x64 environment: matrix: + - TOOLCHAIN: "msvc" - TOOLCHAIN: "msys2" - TOOLCHAIN: "cygwin" @@ -16,7 +19,28 @@ branches: skip_tags: true -build_script: +install: + - git clone https://github.com/pffang/libiconv-for-Windows.git C:\projects\iconv + - cd C:\projects\iconv + - git checkout 0e36d95873 + +for: +- + matrix: + only: + - TOOLCHAIN: "msvc" + + build: + parallel: true + project: VS17/ReadStat.sln + verbosity: minimal + +- + matrix: + except: + - TOOLCHAIN: "msvc" + + build_script: - ps: | if ($env:TOOLCHAIN -eq "msys2") { @@ -26,9 +50,9 @@ build_script: C:\msys64\usr\bin\bash -l -c "cd /c/projects/readstat && ./configure" C:\msys64\usr\bin\bash -l -c "cd /c/projects/readstat && make" } - else + elseif ($env:TOOLCHAIN -eq "cygwin") { - c:\cygwin64\setup-x86_64.exe -qnNdO -s http://cygwin.mirror.constant.com -l C:/cygwin64/var/cache/setup -P libiconv-devel -P ragel -P zlib-devel + C:\cygwin64\setup-x86_64.exe -qnNdO -s http://cygwin.mirror.constant.com -l C:/cygwin64/var/cache/setup -P libiconv-devel -P ragel -P zlib-devel C:\cygwin64\bin\sh -lc "cd /cygdrive/c/projects/readstat && ./autogen.sh" C:\cygwin64\bin\sh -lc "cd /cygdrive/c/projects/readstat && ./configure" C:\cygwin64\bin\sh -lc "cd /cygdrive/c/projects/readstat && make" @@ -41,10 +65,39 @@ test_script: $env:MSYSTEM="MINGW64" C:\msys64\usr\bin\bash -l -c "cd /c/projects/readstat && make check" } - else + elseif ($env:TOOLCHAIN -eq "cygwin") { C:\cygwin64\bin\sh -lc "cd /cygdrive/c/projects/readstat && make check" } + else + { + $state = "PASS" + $tests = @("readstat","double_decimals","sav_date","dta_days") + + Copy-Item "C:\projects\iconv\lib64\libiconvD.dll" -Destination "C:\projects\readstat\VS17\x64\Debug\" + + for($i=0 ; $i -lt $tests.Length ; $i++) + { + $currTest = $tests[$i] + $currExec = 'C:\projects\readstat\VS17\x64\Debug\ReadStat_Test_' + $currTest + '.exe;$?' + + echo "Running test $currTest..." + $success = Invoke-Expression $currExec + + if(-not $success){ + $state = "FAIL" + echo "Test result: FAIL" + } + else{ + echo "Test result: PASS" + } + } + + if($state -eq "FAIL") + { + exit 1 + } + } on_success: - ps: | @@ -52,7 +105,7 @@ on_success: { C:\msys64\usr\bin\bash -l -c "cd /c/projects/readstat && cat ./test-suite.log" } - else + elseif ($env:TOOLCHAIN -eq "cygwin") { C:\cygwin64\bin\sh -lc "cd /cygdrive/c/projects/readstat && cat ./test-suite.log" } diff --git a/src/bin/read_csv/json_metadata.c b/src/bin/read_csv/json_metadata.c index 4ef3d4c3..72d5d39f 100644 --- a/src/bin/read_csv/json_metadata.c +++ b/src/bin/read_csv/json_metadata.c @@ -1,6 +1,8 @@ #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include #include #include "jsmn.h" diff --git a/src/bin/readstat.c b/src/bin/readstat.c index 9ce4deff..b9fece0f 100644 --- a/src/bin/readstat.c +++ b/src/bin/readstat.c @@ -1,10 +1,30 @@ #include #include #include -#include +#if !defined _MSC_VER +# include +#endif #include #include -#include +#if !defined _MSC_VER +# include +#else +# include +# include +# include + +# define __need_clock_t +# include + +int gettimeofday(struct timeval* t, void* timezone) +{ + struct _timeb timebuffer; + _ftime_s(&timebuffer); + t->tv_sec = timebuffer.time; + t->tv_usec = 1000 * timebuffer.millitm; + return 0; +} +#endif #include #include "../readstat.h" @@ -27,6 +47,10 @@ #include "util/file_format.h" +#if defined _MSC_VER +#define unlink _unlink +#endif + typedef struct rs_ctx_s { rs_module_t *module; void *module_ctx; @@ -389,6 +413,16 @@ static int convert_file(const char *input_filename, const char *catalog_filename return 0; } +size_t readstat_strftime(char *s, size_t maxsize, const char *format, time_t timestamp) { +#if !defined _MSC_VER + return strftime(s, maxsize, format, localtime(×tamp)); +#else + struct tm ltm; + localtime_s(<m, ×tamp); + return strftime(s, maxsize, format, <m); +#endif +} + static int dump_metadata(readstat_metadata_t *metadata, void *ctx) { printf("Columns: %d\n", readstat_get_var_count(metadata)); printf("Rows: %d\n", readstat_get_row_count(metadata)); @@ -420,7 +454,7 @@ static int dump_metadata(readstat_metadata_t *metadata, void *ctx) { } if (timestamp) { char buffer[128]; - strftime(buffer, sizeof(buffer), "%d %b %Y %H:%M", localtime(×tamp)); + readstat_strftime(buffer, sizeof(buffer), "%d %b %Y %H:%M", timestamp); printf("Timestamp: %s\n", buffer); } return 0; diff --git a/src/bin/util/file_format.c b/src/bin/util/file_format.c index 5e8144c8..ee4bbd3e 100644 --- a/src/bin/util/file_format.c +++ b/src/bin/util/file_format.c @@ -1,5 +1,10 @@ #include -#include +#if defined(_MSC_VER) +# define strncasecmp _strnicmp +# define strcasecmp _stricmp +#else +# include +#endif #include "file_format.h" #include "../../readstat.h" diff --git a/src/bin/write/mod_csv.c b/src/bin/write/mod_csv.c index 4baa59ad..1051a3fe 100644 --- a/src/bin/write/mod_csv.c +++ b/src/bin/write/mod_csv.c @@ -1,7 +1,9 @@ #include #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include #include "../../readstat.h" diff --git a/src/bin/write/mod_readstat.c b/src/bin/write/mod_readstat.c index 81b90cd3..0ff3766d 100644 --- a/src/bin/write/mod_readstat.c +++ b/src/bin/write/mod_readstat.c @@ -1,7 +1,9 @@ #include #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include #include "../../readstat.h" diff --git a/src/bin/write/module_util.c b/src/bin/write/module_util.c index 1cf23088..fd72a67a 100644 --- a/src/bin/write/module_util.c +++ b/src/bin/write/module_util.c @@ -1,4 +1,6 @@ -#include +#if !defined(_MSC_VER) +# include +#endif #include int rs_ends_with(const char *filename, const char *ending) { diff --git a/src/readstat.h b/src/readstat.h index 46066f67..04a7b3fb 100644 --- a/src/readstat.h +++ b/src/readstat.h @@ -295,7 +295,11 @@ typedef int (*readstat_value_label_handler)(const char *val_labels, typedef void (*readstat_error_handler)(const char *error_message, void *ctx); typedef int (*readstat_progress_handler)(double progress, void *ctx); -#if defined _WIN32 || defined __CYGWIN__ +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +typedef _off_t readstat_off_t; +#elif defined _WIN32 || defined __CYGWIN__ typedef _off64_t readstat_off_t; #elif defined _AIX typedef off64_t readstat_off_t; diff --git a/src/readstat_io_unistd.c b/src/readstat_io_unistd.c index 915f205d..dd19dbc6 100644 --- a/src/readstat_io_unistd.c +++ b/src/readstat_io_unistd.c @@ -1,7 +1,9 @@ #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include "readstat.h" #include "readstat_io_unistd.h" @@ -14,7 +16,10 @@ #define UNISTD_OPEN_OPTIONS O_RDONLY #endif -#if defined _WIN32 || defined _AIX +#if defined _MSC_VER && defined WIN64 +#define lseek _lseeki64 +#elif defined _MSC_VER +#elif defined _WIN32 || defined _AIX #define lseek lseek64 #endif diff --git a/src/readstat_writer.c b/src/readstat_writer.c index 962a36d6..6ab17a2d 100644 --- a/src/readstat_writer.c +++ b/src/readstat_writer.c @@ -258,9 +258,13 @@ static readstat_error_t readstat_write_repeated_byte(readstat_writer_t *writer, if (len == 0) return READSTAT_OK; - char zeros[len]; + char *zeros = malloc(len); + memset(zeros, byte, len); - return readstat_write_bytes(writer, zeros, len); + readstat_error_t error = readstat_write_bytes(writer, zeros, len); + + free(zeros); + return error; } readstat_error_t readstat_write_zeros(readstat_writer_t *writer, size_t len) { diff --git a/src/sas/readstat_sas7bcat_read.c b/src/sas/readstat_sas7bcat_read.c index 77f16bd5..6c16622a 100644 --- a/src/sas/readstat_sas7bcat_read.c +++ b/src/sas/readstat_sas7bcat_read.c @@ -51,6 +51,7 @@ static readstat_error_t sas7bcat_parse_value_labels(const char *value_start, siz /* Doubles appear to be stored as big-endian, always */ int bswap_doubles = machine_is_little_endian(); int is_string = (name[0] == '$'); + char *label = NULL; if (value_offset == NULL) { retval = READSTAT_ERROR_MALLOC; @@ -117,8 +118,8 @@ static readstat_error_t sas7bcat_parse_value_labels(const char *value_start, siz goto cleanup; } if (ctx->value_label_handler) { - char label[4*label_len+1]; - retval = readstat_convert(label, sizeof(label), + label = realloc(label, 4 * label_len + 1); + retval = readstat_convert(label, 4 * label_len + 1, &lbp2[10], label_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; @@ -133,9 +134,8 @@ static readstat_error_t sas7bcat_parse_value_labels(const char *value_start, siz } cleanup: - if (value_offset) - free(value_offset); - + free(label); + free(value_offset); return retval; } diff --git a/src/sas/readstat_sas7bdat_write.c b/src/sas/readstat_sas7bdat_write.c index 19467ab7..37e3276b 100644 --- a/src/sas/readstat_sas7bdat_write.c +++ b/src/sas/readstat_sas7bdat_write.c @@ -699,11 +699,11 @@ static readstat_error_t sas7bdat_write_row_uncompressed(readstat_writer_t *write int16_t page_row_count = (writer->row_count - writer->current_row < rows_per_page ? writer->row_count - writer->current_row : rows_per_page); - char header[hinfo->page_header_size]; - memset(header, 0, sizeof(header)); + char *header = calloc(hinfo->page_header_size, 1); memcpy(&header[hinfo->page_header_size-6], &page_row_count, sizeof(int16_t)); memcpy(&header[hinfo->page_header_size-8], &page_type, sizeof(int16_t)); retval = readstat_write_bytes(writer, header, hinfo->page_header_size); + free(header); if (retval != READSTAT_OK) goto cleanup; } diff --git a/src/sas/readstat_sas_rle.c b/src/sas/readstat_sas_rle.c index 354da349..adb0289c 100644 --- a/src/sas/readstat_sas_rle.c +++ b/src/sas/readstat_sas_rle.c @@ -3,6 +3,11 @@ #include #include +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif + #include "readstat_sas_rle.h" #define SAS_RLE_COMMAND_COPY64 0 diff --git a/src/sas/readstat_xport_read.c b/src/sas/readstat_xport_read.c index eebcd0de..079865e8 100644 --- a/src/sas/readstat_xport_read.c +++ b/src/sas/readstat_xport_read.c @@ -280,10 +280,13 @@ static readstat_error_t xport_read_obs_header_record(xport_ctx_t *ctx) { static readstat_error_t xport_construct_format(char *dst, size_t dst_len, const char *src, size_t src_len, int width, int decimals) { - char format[4*src_len+1]; - readstat_error_t retval = readstat_convert(format, sizeof(format), src, src_len, NULL); - if (retval != READSTAT_OK) + char *format = malloc(4 * src_len + 1); + readstat_error_t retval = readstat_convert(format, 4 * src_len + 1, src, src_len, NULL); + + if (retval != READSTAT_OK) { + free(format); return retval; + } if (!format[0]) { *dst = '\0'; @@ -297,12 +300,15 @@ static readstat_error_t xport_construct_format(char *dst, size_t dst_len, snprintf(dst, dst_len, "%s", format); } + free(format); return retval; } static readstat_error_t xport_read_labels_v8(xport_ctx_t *ctx, int label_count) { readstat_error_t retval = READSTAT_OK; uint16_t labeldef[3]; + char *name = NULL; + char *label = NULL; int i; for (i=0; ivariables[index-1]; if (read_bytes(ctx, name, name_len) != name_len || @@ -356,6 +362,8 @@ static readstat_error_t xport_read_labels_v8(xport_ctx_t *ctx, int label_count) goto cleanup; cleanup: + free(name); + free(label); return retval; } @@ -363,6 +371,11 @@ static readstat_error_t xport_read_labels_v9(xport_ctx_t *ctx, int label_count) readstat_error_t retval = READSTAT_OK; uint16_t labeldef[5]; int i; + char *name = NULL; + char *format = NULL; + char *informat = NULL; + char *label = NULL; + for (i=0; ivariables[index-1]; @@ -429,6 +442,10 @@ static readstat_error_t xport_read_labels_v9(xport_ctx_t *ctx, int label_count) goto cleanup; cleanup: + free(name); + free(format); + free(informat); + free(label); return retval; } diff --git a/src/sas/readstat_xport_write.c b/src/sas/readstat_xport_write.c index 2ba6b86f..0d6360aa 100644 --- a/src/sas/readstat_xport_write.c +++ b/src/sas/readstat_xport_write.c @@ -12,6 +12,10 @@ #define XPORT_DEFAULT_VERISON 8 #define RECORD_LEN 80 +#if defined _MSC_VER +#define restrict __restrict +#endif + static void copypad(char * restrict dst, size_t dst_len, const char * restrict src) { char *dst_end = dst + dst_len; while (dst < dst_end && *src) diff --git a/src/spss/readstat_sav_write.c b/src/spss/readstat_sav_write.c index ec909b96..776974cd 100644 --- a/src/spss/readstat_sav_write.c +++ b/src/spss/readstat_sav_write.c @@ -3,7 +3,9 @@ #include #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include #include #include diff --git a/src/stata/readstat_dta_write.c b/src/stata/readstat_dta_write.c index 77cc20a3..fa103aa3 100644 --- a/src/stata/readstat_dta_write.c +++ b/src/stata/readstat_dta_write.c @@ -4,7 +4,9 @@ #include #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include #include "../readstat.h" @@ -523,7 +525,7 @@ static readstat_error_t dta_emit_variable_labels(readstat_writer_t *writer, dta_ static readstat_error_t dta_emit_characteristics(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; int i; - char buffer[ctx->ch_metadata_len]; + char *buffer = malloc(ctx->ch_metadata_len); if (ctx->expansion_len_len == 0) return READSTAT_OK; @@ -581,6 +583,7 @@ static readstat_error_t dta_emit_characteristics(readstat_writer_t *writer, dta_ goto cleanup; cleanup: + free(buffer); return error; } diff --git a/src/test/test_readstat.c b/src/test/test_readstat.c index 18b89526..122e9a41 100644 --- a/src/test/test_readstat.c +++ b/src/test/test_readstat.c @@ -2,9 +2,13 @@ #include #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include -#include +#if !defined(_MSC_VER) +# include +#endif #include "../readstat.h" #include "../readstat_iconv.h" @@ -32,8 +36,11 @@ static rt_test_args_t _test_args[] = { static void dump_buffer(rt_buffer_t *buffer, long format) { char filename[128]; - snprintf(filename, sizeof(filename), "/tmp/test_readstat.%s", - file_extension(format)); +#if !defined _MSC_VER + snprintf(filename, sizeof(filename), "/tmp/test_readstat.%s", file_extension(format)); +#else + snprintf(filename, sizeof(filename), "test_readstat.%s", file_extension(format)); +#endif #if DEBUG printf("Writing file buffer to %s\n", filename); int fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644); diff --git a/src/txt/readstat_sas_commands_read.c b/src/txt/readstat_sas_commands_read.c index f6d75c17..542043e8 100644 --- a/src/txt/readstat_sas_commands_read.c +++ b/src/txt/readstat_sas_commands_read.c @@ -1,7 +1,12 @@ #line 1 "src/txt/readstat_sas_commands_read.rl" #include -#include +#if defined(_MSC_VER) +# define strncasecmp _strnicmp +# define strcasecmp _stricmp +#else +# include +#endif #include "../readstat.h" #include "readstat_schema.h" @@ -3183,7 +3188,7 @@ readstat_schema_t *readstat_parse_sas_commands(readstat_parser_t *parser, break; case 25: #line 221 "src/txt/readstat_sas_commands_read.rl" - { label_type = LABEL_TYPE_DOUBLE; double_value = -integer; } + { label_type = LABEL_TYPE_DOUBLE; double_value = -(double)integer; } break; case 26: #line 222 "src/txt/readstat_sas_commands_read.rl" diff --git a/src/txt/readstat_sas_commands_read.rl b/src/txt/readstat_sas_commands_read.rl index 48dc2bad..63919c19 100644 --- a/src/txt/readstat_sas_commands_read.rl +++ b/src/txt/readstat_sas_commands_read.rl @@ -1,5 +1,10 @@ #include -#include +#if defined(_MSC_VER) +# define strncasecmp _strnicmp +# define strcasecmp _stricmp +#else +# include +#endif #include "../readstat.h" #include "readstat_schema.h" @@ -218,7 +223,7 @@ readstat_schema_t *readstat_parse_sas_commands(readstat_parser_t *parser, empty_cmd = ";"; - value_label = ( "-" integer %{ label_type = LABEL_TYPE_DOUBLE; double_value = -integer; } | + value_label = ( "-" integer %{ label_type = LABEL_TYPE_DOUBLE; double_value = -(double)integer; } | integer %{ label_type = LABEL_TYPE_DOUBLE; double_value = integer; } | integer whitespace+ "-" whitespace+ %{ first_integer = integer; } integer %{ label_type = LABEL_TYPE_RANGE; } | unquoted_string %{ label_type = LABEL_TYPE_STRING; } %copy_string | diff --git a/src/txt/readstat_spss_commands_read.c b/src/txt/readstat_spss_commands_read.c index 8a205726..0b737b3f 100644 --- a/src/txt/readstat_spss_commands_read.c +++ b/src/txt/readstat_spss_commands_read.c @@ -1,7 +1,12 @@ #line 1 "src/txt/readstat_spss_commands_read.rl" #include -#include +#if defined(_MSC_VER) +# define strncasecmp _strnicmp +# define strcasecmp _stricmp +#else +# include +#endif #include #include "../readstat.h" @@ -1984,7 +1989,7 @@ readstat_schema_t *readstat_parse_spss_commands(readstat_parser_t *parser, break; case 31: #line 259 "src/txt/readstat_spss_commands_read.rl" - { label_type = LABEL_TYPE_DOUBLE; double_value = -integer; } + { label_type = LABEL_TYPE_DOUBLE; double_value = -(double)integer; } break; case 32: #line 260 "src/txt/readstat_spss_commands_read.rl" diff --git a/src/txt/readstat_spss_commands_read.rl b/src/txt/readstat_spss_commands_read.rl index fb823151..7adf287c 100644 --- a/src/txt/readstat_spss_commands_read.rl +++ b/src/txt/readstat_spss_commands_read.rl @@ -1,5 +1,10 @@ #include -#include +#if defined(_MSC_VER) +# define strncasecmp _strnicmp +# define strcasecmp _stricmp +#else +# include +#endif #include #include "../readstat.h" @@ -256,7 +261,7 @@ readstat_schema_t *readstat_parse_spss_commands(readstat_parser_t *parser, missing_values_list = missing_values_item (whitespace+ missing_values_item)*; - value_label = ( "-" integer %{ label_type = LABEL_TYPE_DOUBLE; double_value = -integer; } | + value_label = ( "-" integer %{ label_type = LABEL_TYPE_DOUBLE; double_value = -(double)integer; } | integer %{ label_type = LABEL_TYPE_DOUBLE; double_value = integer; } | integer whitespace+ "-" whitespace+ %{ first_integer = integer; } integer %{ label_type = LABEL_TYPE_RANGE; } | quoted_string %{ label_type = LABEL_TYPE_STRING; } %copy_quoted_string ) diff --git a/src/txt/readstat_txt_read.c b/src/txt/readstat_txt_read.c index ea8786cb..46f93032 100644 --- a/src/txt/readstat_txt_read.c +++ b/src/txt/readstat_txt_read.c @@ -1,7 +1,8 @@ - #include #include -#include +#if !defined(_MSC_VER) +# include +#endif #include #include @@ -10,6 +11,10 @@ #include "../readstat_convert.h" #include "readstat_schema.h" +#if defined _MSC_VER +#define restrict __restrict +#endif + typedef struct txt_ctx_s { int rows; iconv_t converter; @@ -19,11 +24,11 @@ typedef struct txt_ctx_s { static readstat_error_t handle_value(readstat_parser_t *parser, iconv_t converter, int obs_index, readstat_schema_entry_t *entry, char *bytes, size_t len, void *ctx) { readstat_error_t error = READSTAT_OK; - char converted_value[4*len+1]; + char *converted_value = malloc(4*len+1); readstat_variable_t *variable = &entry->variable; readstat_value_t value = { .type = variable->type }; if (readstat_type_class(variable->type) == READSTAT_TYPE_CLASS_STRING) { - error = readstat_convert(converted_value, sizeof(converted_value), bytes, len, converter); + error = readstat_convert(converted_value, 4 * len + 1, bytes, len, converter); if (error != READSTAT_OK) goto cleanup; value.v.string_value = converted_value; @@ -43,6 +48,7 @@ static readstat_error_t handle_value(readstat_parser_t *parser, iconv_t converte error = READSTAT_ERROR_USER_ABORT; } cleanup: + free(converted_value); return error; }