on master help sign in
Add proper visual studio debugging support
commitb379e7769fbbefdc108647aa362b4e2af2f6637a authorNeil Mitchell <ndmitchell@gmail.com> dateWed 30 Nov 2016, 19:08 (10 years ago) parent3548c3c
5 files changed+221−24
go.bat−2 main.c−22 vs/hexml.sln+28 vs/hexml.vcxproj+153 vs/main.c+40
go.batdeleted−2
@@ -1,2 +0,0 @@
1−rem sos -p .*.c -c "go 2>&1 | head -n12"
2−gcc -c hexml.c -O3 && gcc -c main.c -O3 && gcc -o hexml hexml.o main.o && hexml
main.cdeleted−22
@@ -1,22 +0,0 @@
1−#include "hexml.h"
2−#include <stdio.h>
3−#include <malloc.h>
4−
5−void main()
6−{
7− setbuf(stdout, NULL);
8− char* body = "<?xml version=\"1.0\" lang=\"ja\"?><foo><bar baz=\"qux\">quux</bar><bar baz=\"bar\">hoge</bar><piyo>&gt;piyopiyo&lt;</piyo></foo><foo2 />";
9− body = "<test>X</test> ";
10− document* doc = document_parse(body, -1);
11− char* err = document_error(doc);
12− if (err == NULL)
13− {
14− int len = document_render(doc, NULL, 0);
15− char* s = malloc(len + 1);
16− document_render(doc, s, len);
17− s[len] = 0;
18− printf("Parse successful, %s\n", s);
19− }
20− else
21− printf("Parse failed, %s\n", err);
22−}
vs/hexml.slnnew file+28
@@ -0,0 +1,28 @@
1+
2+Microsoft Visual Studio Solution File, Format Version 12.00
3+# Visual Studio 14
4+VisualStudioVersion = 14.0.25420.1
5+MinimumVisualStudioVersion = 10.0.40219.1
6+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hexml", "hexml.vcxproj", "{9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}"
7+EndProject
8+Global
9+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+ Debug|x64 = Debug|x64
11+ Debug|x86 = Debug|x86
12+ Release|x64 = Release|x64
13+ Release|x86 = Release|x86
14+ EndGlobalSection
15+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+ {9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}.Debug|x64.ActiveCfg = Debug|x64
17+ {9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}.Debug|x64.Build.0 = Debug|x64
18+ {9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}.Debug|x86.ActiveCfg = Debug|Win32
19+ {9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}.Debug|x86.Build.0 = Debug|Win32
20+ {9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}.Release|x64.ActiveCfg = Release|x64
21+ {9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}.Release|x64.Build.0 = Release|x64
22+ {9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}.Release|x86.ActiveCfg = Release|Win32
23+ {9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}.Release|x86.Build.0 = Release|Win32
24+ EndGlobalSection
25+ GlobalSection(SolutionProperties) = preSolution
26+ HideSolutionNode = FALSE
27+ EndGlobalSection
28+EndGlobal
vs/hexml.vcxprojnew file+153
@@ -0,0 +1,153 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+ <ItemGroup Label="ProjectConfigurations">
4+ <ProjectConfiguration Include="Debug|Win32">
5+ <Configuration>Debug</Configuration>
6+ <Platform>Win32</Platform>
7+ </ProjectConfiguration>
8+ <ProjectConfiguration Include="Release|Win32">
9+ <Configuration>Release</Configuration>
10+ <Platform>Win32</Platform>
11+ </ProjectConfiguration>
12+ <ProjectConfiguration Include="Debug|x64">
13+ <Configuration>Debug</Configuration>
14+ <Platform>x64</Platform>
15+ </ProjectConfiguration>
16+ <ProjectConfiguration Include="Release|x64">
17+ <Configuration>Release</Configuration>
18+ <Platform>x64</Platform>
19+ </ProjectConfiguration>
20+ </ItemGroup>
21+ <ItemGroup>
22+ <ClCompile Include="..\cbits\hexml.c" />
23+ <ClInclude Include="..\cbits\hexml.h" />
24+ <ClCompile Include="main.c" />
25+ </ItemGroup>
26+ <PropertyGroup Label="Globals">
27+ <ProjectGuid>{9DA5F6EE-A35E-4ED6-ABC2-A7707392E6EB}</ProjectGuid>
28+ <Keyword>Win32Proj</Keyword>
29+ <RootNamespace>hexml</RootNamespace>
30+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
31+ </PropertyGroup>
32+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
33+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
34+ <ConfigurationType>Application</ConfigurationType>
35+ <UseDebugLibraries>true</UseDebugLibraries>
36+ <PlatformToolset>v140</PlatformToolset>
37+ <CharacterSet>Unicode</CharacterSet>
38+ </PropertyGroup>
39+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
40+ <ConfigurationType>Application</ConfigurationType>
41+ <UseDebugLibraries>false</UseDebugLibraries>
42+ <PlatformToolset>v140</PlatformToolset>
43+ <WholeProgramOptimization>true</WholeProgramOptimization>
44+ <CharacterSet>Unicode</CharacterSet>
45+ </PropertyGroup>
46+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
47+ <ConfigurationType>Application</ConfigurationType>
48+ <UseDebugLibraries>true</UseDebugLibraries>
49+ <PlatformToolset>v140</PlatformToolset>
50+ <CharacterSet>Unicode</CharacterSet>
51+ </PropertyGroup>
52+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
53+ <ConfigurationType>Application</ConfigurationType>
54+ <UseDebugLibraries>false</UseDebugLibraries>
55+ <PlatformToolset>v140</PlatformToolset>
56+ <WholeProgramOptimization>true</WholeProgramOptimization>
57+ <CharacterSet>Unicode</CharacterSet>
58+ </PropertyGroup>
59+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
60+ <ImportGroup Label="ExtensionSettings">
61+ </ImportGroup>
62+ <ImportGroup Label="Shared">
63+ </ImportGroup>
64+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
65+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66+ </ImportGroup>
67+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
68+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
69+ </ImportGroup>
70+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
71+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
72+ </ImportGroup>
73+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
74+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
75+ </ImportGroup>
76+ <PropertyGroup Label="UserMacros" />
77+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
78+ <LinkIncremental>true</LinkIncremental>
79+ </PropertyGroup>
80+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
81+ <LinkIncremental>true</LinkIncremental>
82+ </PropertyGroup>
83+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
84+ <LinkIncremental>false</LinkIncremental>
85+ </PropertyGroup>
86+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
87+ <LinkIncremental>false</LinkIncremental>
88+ </PropertyGroup>
89+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
90+ <ClCompile>
91+ <PrecompiledHeader>
92+ </PrecompiledHeader>
93+ <WarningLevel>Level3</WarningLevel>
94+ <Optimization>Disabled</Optimization>
95+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
96+ </ClCompile>
97+ <Link>
98+ <SubSystem>Console</SubSystem>
99+ <GenerateDebugInformation>true</GenerateDebugInformation>
100+ </Link>
101+ </ItemDefinitionGroup>
102+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
103+ <ClCompile>
104+ <PrecompiledHeader>
105+ </PrecompiledHeader>
106+ <WarningLevel>Level3</WarningLevel>
107+ <Optimization>Disabled</Optimization>
108+ <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
109+ <AdditionalIncludeDirectories>..\cbits</AdditionalIncludeDirectories>
110+ </ClCompile>
111+ <Link>
112+ <SubSystem>Console</SubSystem>
113+ <GenerateDebugInformation>true</GenerateDebugInformation>
114+ </Link>
115+ </ItemDefinitionGroup>
116+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
117+ <ClCompile>
118+ <WarningLevel>Level3</WarningLevel>
119+ <PrecompiledHeader>
120+ </PrecompiledHeader>
121+ <Optimization>MaxSpeed</Optimization>
122+ <FunctionLevelLinking>true</FunctionLevelLinking>
123+ <IntrinsicFunctions>true</IntrinsicFunctions>
124+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
125+ </ClCompile>
126+ <Link>
127+ <SubSystem>Console</SubSystem>
128+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
129+ <OptimizeReferences>true</OptimizeReferences>
130+ <GenerateDebugInformation>true</GenerateDebugInformation>
131+ </Link>
132+ </ItemDefinitionGroup>
133+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
134+ <ClCompile>
135+ <WarningLevel>Level3</WarningLevel>
136+ <PrecompiledHeader>
137+ </PrecompiledHeader>
138+ <Optimization>MaxSpeed</Optimization>
139+ <FunctionLevelLinking>true</FunctionLevelLinking>
140+ <IntrinsicFunctions>true</IntrinsicFunctions>
141+ <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
142+ </ClCompile>
143+ <Link>
144+ <SubSystem>Console</SubSystem>
145+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
146+ <OptimizeReferences>true</OptimizeReferences>
147+ <GenerateDebugInformation>true</GenerateDebugInformation>
148+ </Link>
149+ </ItemDefinitionGroup>
150+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
151+ <ImportGroup Label="ExtensionTargets">
152+ </ImportGroup>
153+</Project>
vs/main.cnew file+40
@@ -0,0 +1,40 @@
1+#include "hexml.h"
2+#include <stdio.h>
3+#include <malloc.h>
4+#include <time.h>
5+#include <string.h>
6+#include <assert.h>
7+
8+char* readFile(char* file)
9+{
10+ FILE* f = fopen(file, "rb");
11+ fseek(f, 0, SEEK_END);
12+ int len = ftell(f);
13+ fseek(f, 0, SEEK_SET);
14+ char* res = malloc(len + 1);
15+ res[len] = 0;
16+ int n = fread(res, 1, len, f);
17+ assert(n == len);
18+ fclose(f);
19+ return res;
20+}
21+
22+char* example = "<?xml version=\"1.0\" lang=\"ja\"?><foo><bar baz=\"qux\">quux</bar><bar baz=\"bar\">hoge</bar><piyo>&gt;piyopiyo&lt;</piyo></foo><foo2 />";
23+
24+void main(int argc, char **argv)
25+{
26+ setbuf(stdout, NULL);
27+ char* body = argv[1] == NULL ? example : readFile(argv[1]);
28+ document* doc = document_parse(body, -1);
29+ char* err = document_error(doc);
30+ if (err == NULL)
31+ {
32+ int len = node_render(doc, document_node(doc), NULL, 0);
33+ char* s = malloc(len + 1);
34+ node_render(doc, document_node(doc), s, len);
35+ s[len] = 0;
36+ printf("Parse successful\n"); // , %s\n", s);
37+ }
38+ else
39+ printf("Parse failed, %s\n", err);
40+}