From fcb9255ba943d0a0420cf6eec6d807f666c0a4ac Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Sat, 3 Jul 2010 14:26:04 +0000 Subject: [PATCH] Added stdbool.h module and removed old TRUE and FALSE defs which are not standard C git-svn-id: http://picoc.googlecode.com/svn/trunk@451 21eae674-98b7-11dd-bd71-f92a316d2d60 --- Makefile | 2 +- cstdlib/stdio.c | 7 ------- cstdlib/stdlib.c | 7 ------- include.c | 5 +++-- picoc.h | 4 ++++ platform/library_srv1.c | 2 +- platform/library_unix.c | 2 +- 7 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index e2c9615..86771a0 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ SRCS = picoc.c table.c lex.c parse.c expression.c heap.c type.c \ variable.c clibrary.c platform.c include.c \ platform/platform_unix.c platform/library_unix.c \ cstdlib/stdio.c cstdlib/math.c cstdlib/string.c cstdlib/stdlib.c \ - cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c + cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c cstdlib/stdbool.c OBJS := $(SRCS:%.c=%.o) all: depend $(TARGET) diff --git a/cstdlib/stdio.c b/cstdlib/stdio.c index 86f8705..6b42ca9 100644 --- a/cstdlib/stdio.c +++ b/cstdlib/stdio.c @@ -10,7 +10,6 @@ FILE *CStdOut; static int ZeroValue = 0; -static int TRUEValue = 1; static int EOFValue = EOF; static int SEEK_SETValue = SEEK_SET; static int SEEK_CURValue = SEEK_CUR; @@ -687,12 +686,6 @@ void StdioSetupFunc(void) /* define NULL, TRUE and FALSE */ if (!VariableDefined(TableStrRegister("NULL"))) VariableDefinePlatformVar(NULL, "NULL", &IntType, (union AnyValue *)&ZeroValue, FALSE); - - if (!VariableDefined(TableStrRegister("TRUE"))) - { - VariableDefinePlatformVar(NULL, "TRUE", &IntType, (union AnyValue *)&TRUEValue, FALSE); - VariableDefinePlatformVar(NULL, "FALSE", &IntType, (union AnyValue *)&ZeroValue, FALSE); - } } /* portability-related I/O calls */ diff --git a/cstdlib/stdlib.c b/cstdlib/stdlib.c index 564fbb7..ed1e9c9 100644 --- a/cstdlib/stdlib.c +++ b/cstdlib/stdlib.c @@ -4,7 +4,6 @@ #ifndef BUILTIN_MINI_STDLIB static int ZeroValue = 0; -static int TRUEValue = 1; void StdlibAtof(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) { @@ -164,12 +163,6 @@ void StdlibSetupFunc(void) /* define NULL, TRUE and FALSE */ if (!VariableDefined(TableStrRegister("NULL"))) VariableDefinePlatformVar(NULL, "NULL", &IntType, (union AnyValue *)&ZeroValue, FALSE); - - if (!VariableDefined(TableStrRegister("TRUE"))) - { - VariableDefinePlatformVar(NULL, "TRUE", &IntType, (union AnyValue *)&TRUEValue, FALSE); - VariableDefinePlatformVar(NULL, "FALSE", &IntType, (union AnyValue *)&ZeroValue, FALSE); - } } #endif /* !BUILTIN_MINI_STDLIB */ diff --git a/include.c b/include.c index d7e9ec9..617fa94 100644 --- a/include.c +++ b/include.c @@ -20,10 +20,11 @@ void IncludeInit() { IncludeRegister("ctype.h", NULL, &StdCtypeFunctions[0], NULL); IncludeRegister("errno.h", &StdErrnoSetupFunc, NULL, NULL); - IncludeRegister("stdio.h", &StdioSetupFunc, &StdioFunctions[0], StdioDefs); IncludeRegister("math.h", &MathSetupFunc, &MathFunctions[0], NULL); - IncludeRegister("string.h", &StringSetupFunc, &StringFunctions[0], NULL); + IncludeRegister("stdbool.h", &StdboolSetupFunc, NULL, StdboolDefs); + IncludeRegister("stdio.h", &StdioSetupFunc, &StdioFunctions[0], StdioDefs); IncludeRegister("stdlib.h", &StdlibSetupFunc, &StdlibFunctions[0], NULL); + IncludeRegister("string.h", &StringSetupFunc, &StringFunctions[0], NULL); IncludeRegister("time.h", &StdTimeSetupFunc, &StdTimeFunctions[0], StdTimeDefs); } diff --git a/picoc.h b/picoc.h index 5299080..59fd36b 100644 --- a/picoc.h +++ b/picoc.h @@ -442,4 +442,8 @@ void StdErrnoSetupFunc(void); /* ctype.c */ extern struct LibraryFunction StdCtypeFunctions[]; +/* stdbool.c */ +extern const char StdboolDefs[]; +void StdboolSetupFunc(void); + #endif /* PICOC_H */ diff --git a/platform/library_srv1.c b/platform/library_srv1.c index 6b6f7ed..78e2c08 100644 --- a/platform/library_srv1.c +++ b/platform/library_srv1.c @@ -805,5 +805,5 @@ struct LibraryFunction SRV1Functions[] = void PlatformLibraryInit() { - IncludeRegister("srv1.h", &SRV1SetupFunc, &SRV1Functions, NULL); + IncludeRegister("srv1.h", &SRV1SetupFunc, &SRV1Functions[0], NULL); } diff --git a/platform/library_unix.c b/platform/library_unix.c index a2df558..36866c4 100644 --- a/platform/library_unix.c +++ b/platform/library_unix.c @@ -25,5 +25,5 @@ struct LibraryFunction UnixFunctions[] = void PlatformLibraryInit() { - IncludeRegister("picoc_unix.h", &UnixSetupFunc, &UnixFunctions, NULL); + IncludeRegister("picoc_unix.h", &UnixSetupFunc, &UnixFunctions[0], NULL); }