more cmdlib cleanup

This commit is contained in:
Bill Currie 2002-06-01 04:41:25 +00:00
parent 3b7ddfb22a
commit 8f2d1fa2d9
19 changed files with 171 additions and 37 deletions

View file

@ -25,34 +25,10 @@
#define __CMDLIB__
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <stdarg.h>
#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

View file

@ -26,7 +26,6 @@
# include "config.h"
#endif
#include "cmdlib.h"
#include <stdio.h>
#include <setjmp.h>

View file

@ -30,6 +30,17 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include "QF/dstring.h"
#include "QF/hash.h"
#include "QF/pr_obj.h"

View file

@ -39,6 +39,8 @@ static const char rcsid[] =
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#ifdef NeXT
#include <libc.h>
@ -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++;

View file

@ -30,6 +30,17 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include "qfcc.h"
static int auxfunctions_size;

View file

@ -30,6 +30,15 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <QF/mathlib.h>

View file

@ -30,6 +30,15 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <QF/dstring.h>

View file

@ -30,6 +30,17 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#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

View file

@ -30,6 +30,17 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include "QF/dstring.h"
#include "QF/hash.h"
#include "QF/pr_obj.h"

View file

@ -22,6 +22,12 @@ static const char rcsid[] =
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <QF/va.h>
@ -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')

View file

@ -22,6 +22,14 @@ static const char rcsid[] =
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <QF/hash.h>
#include <QF/sys.h>

View file

@ -22,6 +22,14 @@ static const char rcsid[] =
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include "QF/hash.h"
#include "qfcc.h"

View file

@ -22,6 +22,13 @@ static const char rcsid[] =
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <QF/hash.h>

View file

@ -31,6 +31,18 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <ctype.h>
#include <QF/hash.h>
#include <QF/sys.h>
#include "qfcc.h"

View file

@ -31,6 +31,17 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <QF/hash.h>
#include <QF/sys.h>

View file

@ -51,7 +51,13 @@ static const char rcsid[] =
#ifdef HAVE_PROCESS_H
# include <process.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <getopt.h>
@ -62,6 +68,7 @@ static const char rcsid[] =
#include <QF/qendian.h>
#include <QF/sys.h>
#include "cmdlib.h"
#include "qfcc.h"
#include "class.h"
#include "type.h"

View file

@ -30,6 +30,17 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <QF/dstring.h>
#include <QF/hash.h>
#include <QF/pr_obj.h>

View file

@ -30,6 +30,17 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <QF/hash.h>
#include <QF/sys.h>

View file

@ -30,6 +30,15 @@
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include "QF/dstring.h"