Skip to content

Commit cb4c34b

Browse files
author
zik.saleeba
committed
Created Visual Studio 2011 project.
Modified to compile under Visual Studio 2011. git-svn-id: http://picoc.googlecode.com/svn/trunk@572 21eae674-98b7-11dd-bd71-f92a316d2d60
1 parent bd7634d commit cb4c34b

File tree

15 files changed

+432
-66
lines changed

15 files changed

+432
-66
lines changed

cstdlib/stdio.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ void StdioFprintfWord(StdOutStream *Stream, const char *Format, unsigned int Val
114114

115115
else if (Stream->StrOutLen >= 0)
116116
{
117-
int CCount = snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
118-
Stream->StrOutPtr += CCount;
117+
#ifndef WIN32
118+
int CCount = snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
119+
#else
120+
int CCount = _snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
121+
#endif
122+
Stream->StrOutPtr += CCount;
119123
Stream->StrOutLen -= CCount;
120124
Stream->CharCount += CCount;
121125
}
@@ -135,8 +139,12 @@ void StdioFprintfFP(StdOutStream *Stream, const char *Format, double Value)
135139

136140
else if (Stream->StrOutLen >= 0)
137141
{
142+
#ifndef WIN32
138143
int CCount = snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
139-
Stream->StrOutPtr += CCount;
144+
#else
145+
int CCount = _snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
146+
#endif
147+
Stream->StrOutPtr += CCount;
140148
Stream->StrOutLen -= CCount;
141149
Stream->CharCount += CCount;
142150
}
@@ -156,7 +164,11 @@ void StdioFprintfPointer(StdOutStream *Stream, const char *Format, void *Value)
156164

157165
else if (Stream->StrOutLen >= 0)
158166
{
167+
#ifndef WIN32
159168
int CCount = snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
169+
#else
170+
int CCount = _snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
171+
#endif
160172
Stream->StrOutPtr += CCount;
161173
Stream->StrOutLen -= CCount;
162174
Stream->CharCount += CCount;
@@ -414,7 +426,11 @@ void StdioFerror(struct ParseState *Parser, struct Value *ReturnValue, struct Va
414426

415427
void StdioFileno(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
416428
{
429+
#ifndef WIN32
417430
ReturnValue->Val->Integer = fileno(Param[0]->Val->Pointer);
431+
#else
432+
ReturnValue->Val->Integer = _fileno(Param[0]->Val->Pointer);
433+
#endif
418434
}
419435

420436
void StdioFflush(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)

cstdlib/string.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void StringStrncat(struct ParseState *Parser, struct Value *ReturnValue, struct
3535
ReturnValue->Val->Pointer = strncat(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
3636
}
3737

38+
#ifndef WIN32
3839
void StringIndex(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
3940
{
4041
ReturnValue->Val->Pointer = index(Param[0]->Val->Pointer, Param[1]->Val->Integer);
@@ -44,6 +45,7 @@ void StringRindex(struct ParseState *Parser, struct Value *ReturnValue, struct V
4445
{
4546
ReturnValue->Val->Pointer = rindex(Param[0]->Val->Pointer, Param[1]->Val->Integer);
4647
}
48+
#endif
4749

4850
void StringStrlen(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
4951
{
@@ -125,6 +127,7 @@ void StringStrxfrm(struct ParseState *Parser, struct Value *ReturnValue, struct
125127
ReturnValue->Val->Integer = strxfrm(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
126128
}
127129

130+
#ifndef WIN32
128131
void StringStrdup(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
129132
{
130133
ReturnValue->Val->Pointer = strdup(Param[0]->Val->Pointer);
@@ -134,12 +137,15 @@ void StringStrtok_r(struct ParseState *Parser, struct Value *ReturnValue, struct
134137
{
135138
ReturnValue->Val->Pointer = strtok_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
136139
}
140+
#endif
137141

138142
/* all string.h functions */
139143
struct LibraryFunction StringFunctions[] =
140144
{
141-
{ StringIndex, "char *index(char *,int);" },
145+
#ifndef WIN32
146+
{ StringIndex, "char *index(char *,int);" },
142147
{ StringRindex, "char *rindex(char *,int);" },
148+
#endif
143149
{ StringMemcpy, "void *memcpy(void *,void *,int);" },
144150
{ StringMemmove, "void *memmove(void *,void *,int);" },
145151
{ StringMemchr, "void *memchr(char *,int,int);" },
@@ -162,8 +168,10 @@ struct LibraryFunction StringFunctions[] =
162168
{ StringStrstr, "char *strstr(char *,char *);" },
163169
{ StringStrtok, "char *strtok(char *,char *);" },
164170
{ StringStrxfrm, "int strxfrm(char *,char *,int);" },
165-
{ StringStrdup, "char *strdup(char *);" },
171+
#ifndef WIN32
172+
{ StringStrdup, "char *strdup(char *);" },
166173
{ StringStrtok_r, "char *strtok_r(char *,char *,char **);" },
174+
#endif
167175
{ NULL, NULL }
168176
};
169177

cstdlib/time.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,44 @@ void StdGmtime(struct ParseState *Parser, struct Value *ReturnValue, struct Valu
4141
ReturnValue->Val->Pointer = gmtime(Param[0]->Val->Pointer);
4242
}
4343

44-
void StdGmtime_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
45-
{
46-
ReturnValue->Val->Pointer = gmtime_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
47-
}
48-
4944
void StdLocaltime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
5045
{
5146
ReturnValue->Val->Pointer = localtime(Param[0]->Val->Pointer);
5247
}
5348

5449
void StdMktime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
5550
{
56-
ReturnValue->Val->Integer = mktime(Param[0]->Val->Pointer);
51+
ReturnValue->Val->Integer = (int)mktime(Param[0]->Val->Pointer);
5752
}
5853

5954
void StdTime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
6055
{
61-
ReturnValue->Val->Integer = time(Param[0]->Val->Pointer);
56+
ReturnValue->Val->Integer = (int)time(Param[0]->Val->Pointer);
6257
}
6358

6459
void StdStrftime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
6560
{
6661
ReturnValue->Val->Integer = strftime(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Pointer, Param[3]->Val->Pointer);
6762
}
6863

64+
#ifndef WIN32
6965
void StdStrptime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
7066
{
7167
extern char *strptime(const char *s, const char *format, struct tm *tm);
7268

7369
ReturnValue->Val->Pointer = strptime(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
7470
}
7571

72+
void StdGmtime_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
73+
{
74+
ReturnValue->Val->Pointer = gmtime_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
75+
}
76+
7677
void StdTimegm(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
7778
{
7879
ReturnValue->Val->Integer = timegm(Param[0]->Val->Pointer);
7980
}
81+
#endif
8082

8183
/* handy structure definitions */
8284
const char StdTimeDefs[] = "\
@@ -94,13 +96,15 @@ struct LibraryFunction StdTimeFunctions[] =
9496
{ StdDifftime, "double difftime(int, int);" },
9597
#endif
9698
{ StdGmtime, "struct tm *gmtime(int *);" },
97-
{ StdGmtime_r, "struct tm *gmtime_r(int *, struct tm *);" },
9899
{ StdLocaltime, "struct tm *localtime(int *);" },
99100
{ StdMktime, "int mktime(struct tm *ptm);" },
100101
{ StdTime, "int time(int *);" },
101102
{ StdStrftime, "int strftime(char *, int, char *, struct tm *);" },
103+
#ifndef WIN32
102104
{ StdStrptime, "char *strptime(char *, char *, struct tm *);" },
105+
{ StdGmtime_r, "struct tm *gmtime_r(int *, struct tm *);" },
103106
{ StdTimegm, "int timegm(struct tm *);" },
107+
#endif
104108
{ NULL, NULL }
105109
};
106110

expression.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,11 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct
370370
switch (DestValue->Typ->Base)
371371
{
372372
case TypeInt: DestValue->Val->Integer = ExpressionCoerceInteger(SourceValue); break;
373-
case TypeShort: DestValue->Val->ShortInteger = ExpressionCoerceInteger(SourceValue); break;
374-
case TypeChar: DestValue->Val->Character = ExpressionCoerceUnsignedInteger(SourceValue); break;
373+
case TypeShort: DestValue->Val->ShortInteger = (short)ExpressionCoerceInteger(SourceValue); break;
374+
case TypeChar: DestValue->Val->Character = (unsigned char)ExpressionCoerceUnsignedInteger(SourceValue); break;
375375
case TypeLong: DestValue->Val->LongInteger = ExpressionCoerceInteger(SourceValue); break;
376376
case TypeUnsignedInt: DestValue->Val->UnsignedInteger = ExpressionCoerceUnsignedInteger(SourceValue); break;
377-
case TypeUnsignedShort: DestValue->Val->UnsignedShortInteger = ExpressionCoerceUnsignedInteger(SourceValue); break;
377+
case TypeUnsignedShort: DestValue->Val->UnsignedShortInteger = (unsigned short)ExpressionCoerceUnsignedInteger(SourceValue); break;
378378
case TypeUnsignedLong: DestValue->Val->UnsignedLongInteger = ExpressionCoerceUnsignedInteger(SourceValue); break;
379379

380380
#ifndef NO_FP
@@ -1171,7 +1171,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
11711171

11721172
ExpressionStackPushValueNode(Parser, &StackTop, MacroResult);
11731173
}
1174-
else if (VariableValue->Typ == TypeVoid)
1174+
else if (VariableValue->Typ == &VoidType)
11751175
ProgramFail(Parser, "a void value isn't much use here");
11761176
else
11771177
ExpressionStackPushLValue(Parser, &StackTop, VariableValue, 0); /* it's a value variable */

include.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ void IncludeInit()
2525
#ifndef BUILTIN_MINI_STDLIB
2626
IncludeRegister("ctype.h", NULL, &StdCtypeFunctions[0], NULL);
2727
IncludeRegister("errno.h", &StdErrnoSetupFunc, NULL, NULL);
28-
#ifndef NO_FP
28+
# ifndef NO_FP
2929
IncludeRegister("math.h", &MathSetupFunc, &MathFunctions[0], NULL);
30-
#endif
30+
# endif
3131
IncludeRegister("stdbool.h", &StdboolSetupFunc, NULL, StdboolDefs);
3232
IncludeRegister("stdio.h", &StdioSetupFunc, &StdioFunctions[0], StdioDefs);
3333
IncludeRegister("stdlib.h", &StdlibSetupFunc, &StdlibFunctions[0], NULL);
3434
IncludeRegister("string.h", &StringSetupFunc, &StringFunctions[0], NULL);
3535
IncludeRegister("time.h", &StdTimeSetupFunc, &StdTimeFunctions[0], StdTimeDefs);
36-
IncludeRegister("unistd.h", &UnistdSetupFunc, &UnistdFunctions[0], UnistdDefs);
36+
# ifndef WIN32
37+
IncludeRegister("unistd.h", &UnistdSetupFunc, &UnistdFunctions[0], UnistdDefs);
38+
# endif
3739
#endif
3840
}
3941

lex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define MAX_CHAR_VALUE 255 /* maximum value which can be represented by a "char" data type */
2929

3030
static union AnyValue LexAnyValue;
31-
static struct Value LexValue = { TypeVoid, &LexAnyValue, NULL, FALSE, FALSE, FALSE };
31+
static struct Value LexValue = { &VoidType, &LexAnyValue, NULL, FALSE, FALSE, FALSE };
3232

3333
struct ReservedWord
3434
{

msvc/picoc/picoc.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 11
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "picoc", "picoc.vcxproj", "{C0156FB3-55AB-4F82-8A97-A776DFC57951}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Win32 = Debug|Win32
9+
Release|Win32 = Release|Win32
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{C0156FB3-55AB-4F82-8A97-A776DFC57951}.Debug|Win32.ActiveCfg = Debug|Win32
13+
{C0156FB3-55AB-4F82-8A97-A776DFC57951}.Debug|Win32.Build.0 = Debug|Win32
14+
{C0156FB3-55AB-4F82-8A97-A776DFC57951}.Release|Win32.ActiveCfg = Release|Win32
15+
{C0156FB3-55AB-4F82-8A97-A776DFC57951}.Release|Win32.Build.0 = Release|Win32
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

msvc/picoc/picoc.vcxproj

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.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+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and '$(VisualStudioVersion)' == ''">$(VCTargetsPath11)</VCTargetsPath>
15+
</PropertyGroup>
16+
<PropertyGroup Label="Globals">
17+
<ProjectGuid>{C0156FB3-55AB-4F82-8A97-A776DFC57951}</ProjectGuid>
18+
<Keyword>Win32Proj</Keyword>
19+
<RootNamespace>picoc</RootNamespace>
20+
</PropertyGroup>
21+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
22+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
23+
<ConfigurationType>Application</ConfigurationType>
24+
<UseDebugLibraries>true</UseDebugLibraries>
25+
<PlatformToolset>v110</PlatformToolset>
26+
<CharacterSet>Unicode</CharacterSet>
27+
</PropertyGroup>
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
29+
<ConfigurationType>Application</ConfigurationType>
30+
<UseDebugLibraries>false</UseDebugLibraries>
31+
<PlatformToolset>v110</PlatformToolset>
32+
<WholeProgramOptimization>true</WholeProgramOptimization>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
36+
<ImportGroup Label="ExtensionSettings">
37+
</ImportGroup>
38+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
39+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
40+
</ImportGroup>
41+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
42+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
43+
</ImportGroup>
44+
<PropertyGroup Label="UserMacros" />
45+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
46+
<LinkIncremental>true</LinkIncremental>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
49+
<LinkIncremental>false</LinkIncremental>
50+
</PropertyGroup>
51+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
52+
<ClCompile>
53+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
54+
<WarningLevel>Level3</WarningLevel>
55+
<Optimization>Disabled</Optimization>
56+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
57+
</ClCompile>
58+
<Link>
59+
<SubSystem>Console</SubSystem>
60+
<GenerateDebugInformation>true</GenerateDebugInformation>
61+
</Link>
62+
</ItemDefinitionGroup>
63+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<ClCompile>
65+
<WarningLevel>Level3</WarningLevel>
66+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
67+
<Optimization>MaxSpeed</Optimization>
68+
<FunctionLevelLinking>true</FunctionLevelLinking>
69+
<IntrinsicFunctions>true</IntrinsicFunctions>
70+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
71+
</ClCompile>
72+
<Link>
73+
<SubSystem>Console</SubSystem>
74+
<GenerateDebugInformation>true</GenerateDebugInformation>
75+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
76+
<OptimizeReferences>true</OptimizeReferences>
77+
</Link>
78+
</ItemDefinitionGroup>
79+
<ItemGroup>
80+
<ClCompile Include="..\..\clibrary.c" />
81+
<ClCompile Include="..\..\cstdlib\ctype.c" />
82+
<ClCompile Include="..\..\cstdlib\errno.c" />
83+
<ClCompile Include="..\..\cstdlib\math.c" />
84+
<ClCompile Include="..\..\cstdlib\stdbool.c" />
85+
<ClCompile Include="..\..\cstdlib\stdio.c" />
86+
<ClCompile Include="..\..\cstdlib\stdlib.c" />
87+
<ClCompile Include="..\..\cstdlib\string.c" />
88+
<ClCompile Include="..\..\cstdlib\time.c" />
89+
<ClCompile Include="..\..\debug.c" />
90+
<ClCompile Include="..\..\expression.c" />
91+
<ClCompile Include="..\..\heap.c" />
92+
<ClCompile Include="..\..\include.c" />
93+
<ClCompile Include="..\..\lex.c" />
94+
<ClCompile Include="..\..\parse.c" />
95+
<ClCompile Include="..\..\picoc.c" />
96+
<ClCompile Include="..\..\platform.c" />
97+
<ClCompile Include="..\..\platform\library_msvc.c" />
98+
<ClCompile Include="..\..\platform\platform_msvc.c" />
99+
<ClCompile Include="..\..\table.c" />
100+
<ClCompile Include="..\..\type.c" />
101+
<ClCompile Include="..\..\variable.c" />
102+
</ItemGroup>
103+
<ItemGroup>
104+
<ClInclude Include="..\..\interpreter.h" />
105+
<ClInclude Include="..\..\picoc.h" />
106+
<ClInclude Include="..\..\platform.h" />
107+
</ItemGroup>
108+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
109+
<ImportGroup Label="ExtensionTargets">
110+
</ImportGroup>
111+
</Project>

0 commit comments

Comments
 (0)