From 97fbbaaf8f3fca98be2cb7486c6483ee7ccb8040 Mon Sep 17 00:00:00 2001 From: Joseph Poirier Date: Wed, 17 Jun 2015 16:34:26 -0500 Subject: [PATCH] system includes before user includes, and cleanup --- expression.c | 1 - parse.c | 6 ++---- picoc.c | 11 ++++++----- picoc.h | 10 ++++------ platform.c | 3 +-- platform.h | 25 ++++++++++++++----------- 6 files changed, 27 insertions(+), 29 deletions(-) diff --git a/expression.c b/expression.c index f861990..a44823a 100644 --- a/expression.c +++ b/expression.c @@ -1,6 +1,5 @@ /* picoc expression evaluator - a stack-based expression evaluation system * which handles operator precedence */ - #include "interpreter.h" diff --git a/parse.c b/parse.c index 3bc89d6..8930341 100644 --- a/parse.c +++ b/parse.c @@ -1,13 +1,12 @@ /* picoc parser - parses source and executes statements */ - #include "picoc.h" #include "interpreter.h" static enum ParseResult ParseStatementMaybeRun(struct ParseState *Parser, int Condition, int CheckTrailingSemicolon); static int ParseCountParams(struct ParseState *Parser); -static int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable, - int DoAssignment); +static int ParseArrayInitialiser(struct ParseState *Parser, + struct Value *NewVariable, int DoAssignment); static void ParseDeclarationAssignment(struct ParseState *Parser, struct Value *NewVariable, int DoAssignment); static int ParseDeclaration(struct ParseState *Parser, enum LexToken Token); @@ -379,7 +378,6 @@ int ParseDeclaration(struct ParseState *Parser, enum LexToken Token) Token = LexGetToken(Parser, NULL, false); if (Token == TokenComma) LexGetToken(Parser, NULL, true); - } while (Token == TokenComma); return true; diff --git a/picoc.c b/picoc.c index b426666..b283658 100644 --- a/picoc.c +++ b/picoc.c @@ -1,17 +1,18 @@ /* picoc main program - this varies depending on your operating system and * how you're using picoc */ +/* platform-dependent code for running programs is in this file */ +#if defined(UNIX_HOST) || defined(WIN32) +#include +#include +#include +#endif /* include only picoc.h here - should be able to use it with only the external interfaces, no internals from interpreter.h */ #include "picoc.h" -/* platform-dependent code for running programs is in this file */ #if defined(UNIX_HOST) || defined(WIN32) -#include -#include -#include - #include "LICENSE.h" /* Override via STACKSIZE environment variable */ diff --git a/picoc.h b/picoc.h index f848e5d..0274613 100644 --- a/picoc.h +++ b/picoc.h @@ -3,6 +3,7 @@ #ifndef PICOC_H #define PICOC_H + /* picoc version number */ #ifdef VER /* VER is the git hash number, obtained via the Makefile */ @@ -13,13 +14,10 @@ #include "interpreter.h" - -#if defined(UNIX_HOST) || defined(WIN32) -#include - -/* this has to be a macro, otherwise errors will occur due to the stack being corrupt */ +/* this has to be a macro, otherwise errors will occur due to + the stack being corrupt */ #define PicocPlatformSetExitPoint(pc) setjmp((pc)->PicocExitBuf) -#endif + /* parse.c */ extern void PicocParse(Picoc *pc, const char *FileName, const char *Source, diff --git a/platform.c b/platform.c index 9b14461..b519afd 100644 --- a/platform.c +++ b/platform.c @@ -249,8 +249,7 @@ void PlatformVPrintf(IOFILE *Stream, const char *Format, va_list Args) default: break; } - } - else + } else PrintCh(*FPos, Stream); } } diff --git a/platform.h b/platform.h index a1a90d9..44c602d 100644 --- a/platform.h +++ b/platform.h @@ -14,6 +14,16 @@ #include #include +/* host platform includes */ +#ifdef UNIX_HOST +# include +# include +#elif defined(WIN32) /*(predefined on MSVC)*/ +#else +# error ***** A platform must be explicitly defined! ***** +#endif + + /* configurable options */ /* select your host type (or do it in the Makefile): #define UNIX_HOST @@ -22,6 +32,10 @@ */ #define USE_READLINE +#if defined(WIN32) /*(predefined on MSVC)*/ +#undef USE_READLINE +#endif + /* undocumented, but probably useful */ #undef DEBUG_HEAP #undef DEBUG_EXPRESSIONS @@ -52,17 +66,6 @@ #define INTERACTIVE_PROMPT_STATEMENT "picoc> " #define INTERACTIVE_PROMPT_LINE " > " - -/* host platform includes */ -#ifdef UNIX_HOST -# include -# include -#elif defined(WIN32) /*(predefined on MSVC)*/ -#undef USE_READLINE -#else -# error ***** A platform must be explicitly defined! ***** -#endif - extern jmp_buf ExitBuf; #endif /* PLATFORM_H */