explicit casts, add includes

This commit is contained in:
Joseph Poirier 2015-06-17 16:57:50 -05:00
parent 97fbbaaf8f
commit 011ee0f3eb
11 changed files with 21 additions and 17 deletions

View file

@ -1,4 +1,5 @@
/* */ /* */
#include <math.h>
#include "../interpreter.h" #include "../interpreter.h"

View file

@ -1,4 +1,5 @@
/* */ /* */
#include <stdbool.h>
#include "../interpreter.h" #include "../interpreter.h"

View file

@ -1,10 +1,10 @@
/* */ /* */
#include <stdio.h>
#include <errno.h> #include <errno.h>
#include "../interpreter.h" #include "../interpreter.h"
#define MAX_FORMAT 80 #define MAX_FORMAT (80)
#define MAX_SCANF_ARGS 10 #define MAX_SCANF_ARGS (10)
static int Stdio_ZeroValue = 0; static int Stdio_ZeroValue = 0;
static int EOFValue = EOF; static int EOFValue = EOF;

View file

@ -1,4 +1,5 @@
/* */ /* */
#include <stdlib.h>
#include "../interpreter.h" #include "../interpreter.h"

View file

@ -1,4 +1,5 @@
/* */ /* */
#include <string.h>
#include "../interpreter.h" #include "../interpreter.h"
@ -176,13 +177,13 @@ void StringStrxfrm(struct ParseState *Parser, struct Value *ReturnValue,
void StringStrdup(struct ParseState *Parser, struct Value *ReturnValue, void StringStrdup(struct ParseState *Parser, struct Value *ReturnValue,
struct Value **Param, int NumArgs) struct Value **Param, int NumArgs)
{ {
ReturnValue->Val->Pointer = strdup(Param[0]->Val->Pointer); ReturnValue->Val->Pointer = (void*)strdup(Param[0]->Val->Pointer);
} }
void StringStrtok_r(struct ParseState *Parser, struct Value *ReturnValue, void StringStrtok_r(struct ParseState *Parser, struct Value *ReturnValue,
struct Value **Param, int NumArgs) struct Value **Param, int NumArgs)
{ {
ReturnValue->Val->Pointer = strtok_r(Param[0]->Val->Pointer, ReturnValue->Val->Pointer = (void*)strtok_r(Param[0]->Val->Pointer,
Param[1]->Val->Pointer, Param[2]->Val->Pointer); Param[1]->Val->Pointer, Param[2]->Val->Pointer);
} }
#endif #endif

View file

@ -82,7 +82,7 @@ void StdStrptime(struct ParseState *Parser, struct Value *ReturnValue,
void StdGmtime_r(struct ParseState *Parser, struct Value *ReturnValue, void StdGmtime_r(struct ParseState *Parser, struct Value *ReturnValue,
struct Value **Param, int NumArgs) struct Value **Param, int NumArgs)
{ {
ReturnValue->Val->Pointer = gmtime_r(Param[0]->Val->Pointer, ReturnValue->Val->Pointer = (void*)gmtime_r(Param[0]->Val->Pointer,
Param[1]->Val->Pointer); Param[1]->Val->Pointer);
} }

View file

@ -192,7 +192,7 @@ void UnistdGetpagesize(struct ParseState *Parser, struct Value *ReturnValue,
void UnistdGetpass(struct ParseState *Parser, struct Value *ReturnValue, void UnistdGetpass(struct ParseState *Parser, struct Value *ReturnValue,
struct Value **Param, int NumArgs) struct Value **Param, int NumArgs)
{ {
ReturnValue->Val->Pointer = getpass(Param[0]->Val->Pointer); ReturnValue->Val->Pointer = (void*)getpass(Param[0]->Val->Pointer);
} }
#if 0 #if 0

View file

@ -749,7 +749,7 @@ void ExpressionPrefixOperator(struct ParseState *Parser,
/* pointer prefix arithmetic */ /* pointer prefix arithmetic */
int Size = TypeSize(TopValue->Typ->FromType, 0, true); int Size = TypeSize(TopValue->Typ->FromType, 0, true);
struct Value *StackValue; struct Value *StackValue;
void *ResultPtr; void *ResultPtr = 0;
if (Op != TokenUnaryNot && TopValue->Val->Pointer == NULL) if (Op != TokenUnaryNot && TopValue->Val->Pointer == NULL)
ProgramFail(Parser, "a. invalid use of a NULL pointer"); ProgramFail(Parser, "a. invalid use of a NULL pointer");
if (!TopValue->IsLValue) if (!TopValue->IsLValue)

14
lex.c
View file

@ -54,13 +54,13 @@ struct ReservedWord {
static struct ReservedWord ReservedWords[] = { static struct ReservedWord ReservedWords[] = {
/* wrf, when optimizations are set escaping certain chars is required or they disappear */ /* wrf, when optimizations are set escaping certain chars is required or they disappear */
{"\#define", TokenHashDefine}, {"#define", TokenHashDefine},
{"\#else", TokenHashElse}, {"#else", TokenHashElse},
{"\#endif", TokenHashEndif}, {"#endif", TokenHashEndif},
{"\#if", TokenHashIf}, {"#if", TokenHashIf},
{"\#ifdef", TokenHashIfdef}, {"#ifdef", TokenHashIfdef},
{"\#ifndef", TokenHashIfndef}, {"#ifndef", TokenHashIfndef},
{"\#include", TokenHashInclude}, {"#include", TokenHashInclude},
{"auto", TokenAutoType}, {"auto", TokenAutoType},
{"break", TokenBreak}, {"break", TokenBreak},
{"case", TokenCase}, {"case", TokenCase},

View file

@ -6,7 +6,7 @@
/* picoc version number */ /* picoc version number */
#ifdef VER #ifdef VER
/* VER is the git hash number, obtained via the Makefile */ /* VER, the git hash number, and TAG are obtained via the Makefile */
#define PICOC_VERSION TAG " r" VER #define PICOC_VERSION TAG " r" VER
#else #else
#define PICOC_VERSION "v2.2" #define PICOC_VERSION "v2.2"

View file

@ -50,7 +50,7 @@
#define ALIGN_TYPE double #define ALIGN_TYPE double
#else #else
/* the default data type to use for alignment */ /* the default data type to use for alignment */
#define ALIGN_TYPE void * #define ALIGN_TYPE void*
#endif #endif
#define GLOBAL_TABLE_SIZE (97) /* global variable table */ #define GLOBAL_TABLE_SIZE (97) /* global variable table */