From 8f2d1fa2d9bbb53a2510bacfa84975b66e43052f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 1 Jun 2002 04:41:25 +0000 Subject: [PATCH] more cmdlib cleanup --- tools/qfcc/include/cmdlib.h | 25 ------------------------- tools/qfcc/include/qfcc.h | 1 - tools/qfcc/source/class.c | 11 +++++++++++ tools/qfcc/source/cmdlib.c | 4 ++-- tools/qfcc/source/debug.c | 11 +++++++++++ tools/qfcc/source/emit.c | 9 +++++++++ tools/qfcc/source/expr.c | 9 +++++++++ tools/qfcc/source/function.c | 17 +++++++++++++++-- tools/qfcc/source/method.c | 11 +++++++++++ tools/qfcc/source/pr_comp.c | 24 ++++++++++++++++++------ tools/qfcc/source/pr_def.c | 8 ++++++++ tools/qfcc/source/pr_imm.c | 8 ++++++++ tools/qfcc/source/pr_opcode.c | 7 +++++++ tools/qfcc/source/qc-lex.l | 12 ++++++++++++ tools/qfcc/source/qc-parse.y | 11 +++++++++++ tools/qfcc/source/qfcc.c | 9 ++++++++- tools/qfcc/source/struct.c | 11 +++++++++++ tools/qfcc/source/switch.c | 11 +++++++++++ tools/qfcc/source/type.c | 9 +++++++++ 19 files changed, 171 insertions(+), 37 deletions(-) diff --git a/tools/qfcc/include/cmdlib.h b/tools/qfcc/include/cmdlib.h index cfba9fe57..434faeaa4 100644 --- a/tools/qfcc/include/cmdlib.h +++ b/tools/qfcc/include/cmdlib.h @@ -25,34 +25,10 @@ #define __CMDLIB__ #include -#include -#include -#include -#include -#include -#include - -#ifndef _DEF_BYTE_ -# define _DEF_BYTE_ -typedef unsigned char byte; -#endif - -#ifndef _DEF_BOOL_ -# define _DEF_BOOL_ -typedef enum {false, true} qboolean; -#endif - -// the dec offsetof macro doesn't work very well... -#define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier) - -// set these before calling CheckParm -extern int myargc; -extern char **myargv; int FileLength (FILE *f); void Error (char *error, ...)__attribute__((format(printf, 1,2))); -int CheckParm (char *check); FILE *SafeOpenWrite (char *filename); FILE *SafeOpenRead (char *filename); @@ -64,6 +40,5 @@ int LoadFile (char *filename, void **bufferptr); char *Parse (char *data); extern char qfcc_com_token[1024]; -extern qboolean com_eof; #endif diff --git a/tools/qfcc/include/qfcc.h b/tools/qfcc/include/qfcc.h index 100eb5aa2..7f8b8ce6d 100644 --- a/tools/qfcc/include/qfcc.h +++ b/tools/qfcc/include/qfcc.h @@ -26,7 +26,6 @@ # include "config.h" #endif -#include "cmdlib.h" #include #include diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index 31ef7386b..79a6cf459 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -30,6 +30,17 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + #include "QF/dstring.h" #include "QF/hash.h" #include "QF/pr_obj.h" diff --git a/tools/qfcc/source/cmdlib.c b/tools/qfcc/source/cmdlib.c index db5556560..bd5a1f1aa 100644 --- a/tools/qfcc/source/cmdlib.c +++ b/tools/qfcc/source/cmdlib.c @@ -39,6 +39,8 @@ static const char rcsid[] = #endif #include #include +#include +#include #ifdef NeXT #include @@ -51,7 +53,6 @@ static const char rcsid[] = #define PATHSEPERATOR '/' char qfcc_com_token[1024]; -qboolean com_eof; /* Error @@ -93,7 +94,6 @@ Parse (char *data) skipwhite: while ((c = *data) <= ' ') { if (c == 0) { - com_eof = true; return NULL; // end of file; } data++; diff --git a/tools/qfcc/source/debug.c b/tools/qfcc/source/debug.c index ab9f109b2..6865d7d64 100644 --- a/tools/qfcc/source/debug.c +++ b/tools/qfcc/source/debug.c @@ -30,6 +30,17 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + #include "qfcc.h" static int auxfunctions_size; diff --git a/tools/qfcc/source/emit.c b/tools/qfcc/source/emit.c index 61f3b8ee5..974dbd778 100644 --- a/tools/qfcc/source/emit.c +++ b/tools/qfcc/source/emit.c @@ -30,6 +30,15 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif #include #include diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 6f50f3d25..fa68f9347 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -30,6 +30,15 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif #include #include diff --git a/tools/qfcc/source/function.c b/tools/qfcc/source/function.c index b5cb25ad8..e7d405da1 100644 --- a/tools/qfcc/source/function.c +++ b/tools/qfcc/source/function.c @@ -30,6 +30,17 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + #include "QF/dstring.h" #include "qfcc.h" @@ -125,8 +136,10 @@ build_scope (function_t *f, def_t *func, param_t *params) continue; // non-param selector def = PR_GetDef (p->type, p->name, func, func->alloc); f->parm_ofs[i] = def->ofs; - if (i > 0 && f->parm_ofs[i] < f->parm_ofs[i - 1]) - Error ("bad parm order"); + if (i > 0 && f->parm_ofs[i] < f->parm_ofs[i - 1]) { + error (0, "bad parm order"); + abort (); + } //printf ("%s%s %d\n", p == params ? "" : " ", p->name, def->ofs); def->used = 1; // don't warn for unused params PR_DefInitialized (def); // params are assumed to be initialized diff --git a/tools/qfcc/source/method.c b/tools/qfcc/source/method.c index 64e4b6cbb..816f30dba 100644 --- a/tools/qfcc/source/method.c +++ b/tools/qfcc/source/method.c @@ -30,6 +30,17 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + #include "QF/dstring.h" #include "QF/hash.h" #include "QF/pr_obj.h" diff --git a/tools/qfcc/source/pr_comp.c b/tools/qfcc/source/pr_comp.c index 0cfe1c30f..f6f6ecb83 100644 --- a/tools/qfcc/source/pr_comp.c +++ b/tools/qfcc/source/pr_comp.c @@ -22,6 +22,12 @@ static const char rcsid[] = #ifdef HAVE_CONFIG_H # include "config.h" #endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif #include @@ -44,8 +50,10 @@ PrecacheSound (def_t *e, int ch) } } - if (numsounds == MAX_SOUNDS) - Error ("PrecacheSound: numsounds == MAX_SOUNDS"); + if (numsounds == MAX_SOUNDS) { + error (0, "PrecacheSound: numsounds == MAX_SOUNDS"); + return; + } strcpy (precache_sounds[i], n); if (ch >= '1' && ch <= '9') @@ -73,8 +81,10 @@ PrecacheModel (def_t *e, int ch) } } - if (nummodels == MAX_MODELS) - Error ("PrecacheModels: nummodels == MAX_MODELS"); + if (nummodels == MAX_MODELS) { + error (0, "PrecacheModels: nummodels == MAX_MODELS"); + return; + } strcpy (precache_models[i], n); if (ch >= '1' && ch <= '9') @@ -102,8 +112,10 @@ PrecacheFile (def_t *e, int ch) } } - if (numfiles == MAX_FILES) - Error ("PrecacheFile: numfiles == MAX_FILES"); + if (numfiles == MAX_FILES) { + error (0, "PrecacheFile: numfiles == MAX_FILES"); + return; + } strcpy (precache_files[i], n); if (ch >= '1' && ch <= '9') diff --git a/tools/qfcc/source/pr_def.c b/tools/qfcc/source/pr_def.c index d59f972f2..6ffb7beff 100644 --- a/tools/qfcc/source/pr_def.c +++ b/tools/qfcc/source/pr_def.c @@ -22,6 +22,14 @@ static const char rcsid[] = #ifdef HAVE_CONFIG_H # include "config.h" #endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + #include #include diff --git a/tools/qfcc/source/pr_imm.c b/tools/qfcc/source/pr_imm.c index 1122a0ffd..f05c87212 100644 --- a/tools/qfcc/source/pr_imm.c +++ b/tools/qfcc/source/pr_imm.c @@ -22,6 +22,14 @@ static const char rcsid[] = #ifdef HAVE_CONFIG_H # include "config.h" #endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + #include "QF/hash.h" #include "qfcc.h" diff --git a/tools/qfcc/source/pr_opcode.c b/tools/qfcc/source/pr_opcode.c index c86ee2d5a..21bda8269 100644 --- a/tools/qfcc/source/pr_opcode.c +++ b/tools/qfcc/source/pr_opcode.c @@ -22,6 +22,13 @@ static const char rcsid[] = #ifdef HAVE_CONFIG_H # include "config.h" #endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include #include diff --git a/tools/qfcc/source/qc-lex.l b/tools/qfcc/source/qc-lex.l index d4bca12df..b929f45f2 100644 --- a/tools/qfcc/source/qc-lex.l +++ b/tools/qfcc/source/qc-lex.l @@ -31,6 +31,18 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include +#include + #include #include #include "qfcc.h" diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 8745bb799..d85cf9565 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -31,6 +31,17 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + #include #include diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index 0755c21e3..88594059e 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -51,7 +51,13 @@ static const char rcsid[] = #ifdef HAVE_PROCESS_H # include #endif - +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include #include #include @@ -62,6 +68,7 @@ static const char rcsid[] = #include #include +#include "cmdlib.h" #include "qfcc.h" #include "class.h" #include "type.h" diff --git a/tools/qfcc/source/struct.c b/tools/qfcc/source/struct.c index 40af9a7ef..47d01e16e 100644 --- a/tools/qfcc/source/struct.c +++ b/tools/qfcc/source/struct.c @@ -30,6 +30,17 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + #include #include #include diff --git a/tools/qfcc/source/switch.c b/tools/qfcc/source/switch.c index dd8af75c0..963d67ddb 100644 --- a/tools/qfcc/source/switch.c +++ b/tools/qfcc/source/switch.c @@ -30,6 +30,17 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#include + #include #include diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index 4d34c07ae..91820093f 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -30,6 +30,15 @@ static const char rcsid[] = "$Id$"; +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif #include #include "QF/dstring.h"