Skip to content

Commit

Permalink
Added stdbool.h module and removed old TRUE and FALSE defs which are …
Browse files Browse the repository at this point in the history
…not standard C
  • Loading branch information
zik.saleeba committed Jul 3, 2010
1 parent cc05698 commit fac5dce
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions cstdlib/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
7 changes: 0 additions & 7 deletions cstdlib/stdlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 */
5 changes: 3 additions & 2 deletions include.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions picoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 1 addition & 1 deletion platform/library_srv1.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,5 +805,5 @@ struct LibraryFunction SRV1Functions[] =

void PlatformLibraryInit()
{
IncludeRegister("srv1.h", &SRV1SetupFunc, &SRV1Functions, NULL);
IncludeRegister("srv1.h", &SRV1SetupFunc, &SRV1Functions[0], NULL);
}
2 changes: 1 addition & 1 deletion platform/library_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ struct LibraryFunction UnixFunctions[] =

void PlatformLibraryInit()
{
IncludeRegister("picoc_unix.h", &UnixSetupFunc, &UnixFunctions, NULL);
IncludeRegister("picoc_unix.h", &UnixSetupFunc, &UnixFunctions[0], NULL);
}

0 comments on commit fac5dce

Please sign in to comment.