Skip to content

Commit

Permalink
Fixed a problem with declarations for libraries not being compatible …
Browse files Browse the repository at this point in the history
…with

some C90 compilers.
  • Loading branch information
zik.saleeba committed Jul 1, 2010
1 parent a746cb8 commit 2b8f04d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions clibrary.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "picoc.h"

/* initialise a library */
void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction (*FuncList)[])
void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList)
{
struct ParseState Parser;
int Count;
Expand All @@ -11,13 +11,13 @@ void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct Libr
void *Tokens;
const char *IntrinsicName = TableStrRegister("c library");

for (Count = 0; (*FuncList)[Count].Prototype != NULL; Count++)
for (Count = 0; FuncList[Count].Prototype != NULL; Count++)
{
Tokens = LexAnalyse(IntrinsicName, (*FuncList)[Count].Prototype, strlen((char *)(*FuncList)[Count].Prototype), NULL);
LexInitParser(&Parser, (*FuncList)[Count].Prototype, Tokens, IntrinsicName, TRUE);
Tokens = LexAnalyse(IntrinsicName, FuncList[Count].Prototype, strlen((char *)FuncList[Count].Prototype), NULL);
LexInitParser(&Parser, FuncList[Count].Prototype, Tokens, IntrinsicName, TRUE);
TypeParse(&Parser, &ReturnType, &Identifier);
NewValue = ParseFunctionDefinition(&Parser, ReturnType, Identifier);
NewValue->Val->FuncDef.Intrinsic = (*FuncList)[Count].Func;
NewValue->Val->FuncDef.Intrinsic = FuncList[Count].Func;
HeapFreeMem(Tokens);
}
}
Expand Down
16 changes: 8 additions & 8 deletions include.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct IncludeLibrary
{
const char *IncludeName;
void (*SetupFunction)(void);
struct LibraryFunction (*FuncList)[];
struct LibraryFunction *FuncList;
const char *SetupCSource;
struct IncludeLibrary *NextLib;
};
Expand All @@ -18,13 +18,13 @@ struct IncludeLibrary *IncludeLibList = NULL;
/* initialise the built-in include libraries */
void IncludeInit()
{
IncludeRegister("ctype.h", NULL, &StdCtypeFunctions, NULL);
IncludeRegister("ctype.h", NULL, &StdCtypeFunctions[0], NULL);
IncludeRegister("errno.h", &StdErrnoSetupFunc, NULL, NULL);
IncludeRegister("stdio.h", &StdioSetupFunc, &StdioFunctions, StdioDefs);
IncludeRegister("math.h", &MathSetupFunc, &MathFunctions, NULL);
IncludeRegister("string.h", &StringSetupFunc, &StringFunctions, NULL);
IncludeRegister("stdlib.h", &StdlibSetupFunc, &StdlibFunctions, NULL);
IncludeRegister("time.h", &StdTimeSetupFunc, &StdTimeFunctions, StdTimeDefs);
IncludeRegister("stdio.h", &StdioSetupFunc, &StdioFunctions[0], StdioDefs);
IncludeRegister("math.h", &MathSetupFunc, &MathFunctions[0], NULL);
IncludeRegister("string.h", &StringSetupFunc, &StringFunctions[0], NULL);
IncludeRegister("stdlib.h", &StdlibSetupFunc, &StdlibFunctions[0], NULL);
IncludeRegister("time.h", &StdTimeSetupFunc, &StdTimeFunctions[0], StdTimeDefs);
}

/* clean up space used by the include system */
Expand All @@ -42,7 +42,7 @@ void IncludeCleanup()
}

/* register a new build-in include file */
void IncludeRegister(const char *IncludeName, void (*SetupFunction)(void), struct LibraryFunction (*FuncList)[], const char *SetupCSource)
void IncludeRegister(const char *IncludeName, void (*SetupFunction)(void), struct LibraryFunction *FuncList, const char *SetupCSource)
{
struct IncludeLibrary *NewLib = HeapAllocMem(sizeof(struct IncludeLibrary));
NewLib->IncludeName = TableStrRegister(IncludeName);
Expand Down
4 changes: 2 additions & 2 deletions picoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void *VariableDereferencePointer(struct ParseState *Parser, struct Value *Pointe

/* clibrary.c */
void BasicIOInit();
void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction (*FuncList)[]);
void LibraryInit(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList);
void CLibraryInit();
void PrintCh(char OutCh, IOFILE *Stream);
void PrintSimpleInt(long Num, FILE *Stream);
Expand Down Expand Up @@ -411,7 +411,7 @@ void Cleanup();
/* include.c */
void IncludeInit();
void IncludeCleanup();
void IncludeRegister(const char *IncludeName, void (*SetupFunction)(void), struct LibraryFunction (*FuncList)[], const char *SetupCSource);
void IncludeRegister(const char *IncludeName, void (*SetupFunction)(void), struct LibraryFunction *FuncList, const char *SetupCSource);
void IncludeFile(char *Filename);

/* stdio.c */
Expand Down

0 comments on commit 2b8f04d

Please sign in to comment.