mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-30 15:41:12 +00:00
Whitespace fixes
This commit is contained in:
parent
e0ea101838
commit
4580dcf1ea
4 changed files with 107 additions and 107 deletions
4
gmqcc.h
4
gmqcc.h
|
@ -153,9 +153,9 @@
|
||||||
* just plain textual subsitution.
|
* just plain textual subsitution.
|
||||||
*/
|
*/
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# define snprintf(X, Y, Z, ...) _snprintf(X, Y, Z, __VA_ARGS__)
|
# define snprintf(X, Y, Z, ...) _snprintf(X, Y, Z, __VA_ARGS__)
|
||||||
/* strtof doesn't exist -> strtod does though :) */
|
/* strtof doesn't exist -> strtod does though :) */
|
||||||
# define strtof(X, Y) (float)(strtod(X, Y))
|
# define strtof(X, Y) (float)(strtod(X, Y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
62
lexer.h
62
lexer.h
|
@ -28,23 +28,23 @@ typedef struct token_s token;
|
||||||
#include "ast.h"
|
#include "ast.h"
|
||||||
|
|
||||||
struct token_s {
|
struct token_s {
|
||||||
int ttype;
|
int ttype;
|
||||||
|
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
vector v;
|
vector v;
|
||||||
int i;
|
int i;
|
||||||
double f;
|
double f;
|
||||||
int t; /* type */
|
int t; /* type */
|
||||||
} constval;
|
} constval;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
struct token_s *next;
|
struct token_s *next;
|
||||||
struct token_s *prev;
|
struct token_s *prev;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lex_ctx ctx;
|
lex_ctx ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -100,34 +100,34 @@ typedef struct {
|
||||||
} frame_macro;
|
} frame_macro;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FILE *file;
|
FILE *file;
|
||||||
const char *open_string;
|
const char *open_string;
|
||||||
size_t open_string_length;
|
size_t open_string_length;
|
||||||
size_t open_string_pos;
|
size_t open_string_pos;
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
size_t line;
|
size_t line;
|
||||||
size_t sline; /* line at the start of a token */
|
size_t sline; /* line at the start of a token */
|
||||||
|
|
||||||
char peek[256];
|
char peek[256];
|
||||||
size_t peekpos;
|
size_t peekpos;
|
||||||
|
|
||||||
bool eof;
|
bool eof;
|
||||||
|
|
||||||
token tok; /* not a pointer anymore */
|
token tok; /* not a pointer anymore */
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool noops;
|
bool noops;
|
||||||
bool nodigraphs; /* used when lexing string constants */
|
bool nodigraphs; /* used when lexing string constants */
|
||||||
bool preprocessing; /* whitespace and EOLs become actual tokens */
|
bool preprocessing; /* whitespace and EOLs become actual tokens */
|
||||||
bool mergelines; /* backslash at the end of a line escapes the newline */
|
bool mergelines; /* backslash at the end of a line escapes the newline */
|
||||||
} flags;
|
} flags;
|
||||||
|
|
||||||
int framevalue;
|
int framevalue;
|
||||||
frame_macro *frames;
|
frame_macro *frames;
|
||||||
char *modelname;
|
char *modelname;
|
||||||
|
|
||||||
size_t push_line;
|
size_t push_line;
|
||||||
} lex_file;
|
} lex_file;
|
||||||
|
|
||||||
lex_file* lex_open (const char *file);
|
lex_file* lex_open (const char *file);
|
||||||
|
|
126
parser.c
126
parser.c
|
@ -113,34 +113,34 @@ static ast_expression* parse_expression(parser_t *parser, bool stopatcomma);
|
||||||
|
|
||||||
static void parseerror(parser_t *parser, const char *fmt, ...)
|
static void parseerror(parser_t *parser, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
parser->errors++;
|
parser->errors++;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
con_vprintmsg(LVL_ERROR, parser->lex->tok.ctx.file, parser->lex->tok.ctx.line, "parse error", fmt, ap);
|
con_vprintmsg(LVL_ERROR, parser->lex->tok.ctx.file, parser->lex->tok.ctx.line, "parse error", fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns true if it counts as an error */
|
/* returns true if it counts as an error */
|
||||||
static bool GMQCC_WARN parsewarning(parser_t *parser, int warntype, const char *fmt, ...)
|
static bool GMQCC_WARN parsewarning(parser_t *parser, int warntype, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
bool r;
|
bool r;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
r = vcompile_warning(parser->lex->tok.ctx, warntype, fmt, ap);
|
r = vcompile_warning(parser->lex->tok.ctx, warntype, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool GMQCC_WARN genwarning(lex_ctx ctx, int warntype, const char *fmt, ...)
|
static bool GMQCC_WARN genwarning(lex_ctx ctx, int warntype, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
bool r;
|
bool r;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
r = vcompile_warning(ctx, warntype, fmt, ap);
|
r = vcompile_warning(ctx, warntype, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
@ -4600,56 +4600,56 @@ static void generate_checksum(parser_t *parser)
|
||||||
size_t i;
|
size_t i;
|
||||||
ast_value *value;
|
ast_value *value;
|
||||||
|
|
||||||
crc = progdefs_crc_both(crc, "\n/* file generated by qcc, do not modify */\n\ntypedef struct\n{");
|
crc = progdefs_crc_both(crc, "\n/* file generated by qcc, do not modify */\n\ntypedef struct\n{");
|
||||||
crc = progdefs_crc_sum(crc, "\tint\tpad[28];\n");
|
crc = progdefs_crc_sum(crc, "\tint\tpad[28];\n");
|
||||||
/*
|
/*
|
||||||
progdefs_crc_file("\tint\tpad;\n");
|
progdefs_crc_file("\tint\tpad;\n");
|
||||||
progdefs_crc_file("\tint\tofs_return[3];\n");
|
progdefs_crc_file("\tint\tofs_return[3];\n");
|
||||||
progdefs_crc_file("\tint\tofs_parm0[3];\n");
|
progdefs_crc_file("\tint\tofs_parm0[3];\n");
|
||||||
progdefs_crc_file("\tint\tofs_parm1[3];\n");
|
progdefs_crc_file("\tint\tofs_parm1[3];\n");
|
||||||
progdefs_crc_file("\tint\tofs_parm2[3];\n");
|
progdefs_crc_file("\tint\tofs_parm2[3];\n");
|
||||||
progdefs_crc_file("\tint\tofs_parm3[3];\n");
|
progdefs_crc_file("\tint\tofs_parm3[3];\n");
|
||||||
progdefs_crc_file("\tint\tofs_parm4[3];\n");
|
progdefs_crc_file("\tint\tofs_parm4[3];\n");
|
||||||
progdefs_crc_file("\tint\tofs_parm5[3];\n");
|
progdefs_crc_file("\tint\tofs_parm5[3];\n");
|
||||||
progdefs_crc_file("\tint\tofs_parm6[3];\n");
|
progdefs_crc_file("\tint\tofs_parm6[3];\n");
|
||||||
progdefs_crc_file("\tint\tofs_parm7[3];\n");
|
progdefs_crc_file("\tint\tofs_parm7[3];\n");
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < parser->crc_globals; ++i) {
|
for (i = 0; i < parser->crc_globals; ++i) {
|
||||||
if (!ast_istype(parser->globals[i], ast_value))
|
if (!ast_istype(parser->globals[i], ast_value))
|
||||||
continue;
|
continue;
|
||||||
value = (ast_value*)(parser->globals[i]);
|
value = (ast_value*)(parser->globals[i]);
|
||||||
switch (value->expression.vtype) {
|
switch (value->expression.vtype) {
|
||||||
case TYPE_FLOAT: crc = progdefs_crc_both(crc, "\tfloat\t"); break;
|
case TYPE_FLOAT: crc = progdefs_crc_both(crc, "\tfloat\t"); break;
|
||||||
case TYPE_VECTOR: crc = progdefs_crc_both(crc, "\tvec3_t\t"); break;
|
case TYPE_VECTOR: crc = progdefs_crc_both(crc, "\tvec3_t\t"); break;
|
||||||
case TYPE_STRING: crc = progdefs_crc_both(crc, "\tstring_t\t"); break;
|
case TYPE_STRING: crc = progdefs_crc_both(crc, "\tstring_t\t"); break;
|
||||||
case TYPE_FUNCTION: crc = progdefs_crc_both(crc, "\tfunc_t\t"); break;
|
case TYPE_FUNCTION: crc = progdefs_crc_both(crc, "\tfunc_t\t"); break;
|
||||||
default:
|
default:
|
||||||
crc = progdefs_crc_both(crc, "\tint\t");
|
crc = progdefs_crc_both(crc, "\tint\t");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
crc = progdefs_crc_both(crc, value->name);
|
crc = progdefs_crc_both(crc, value->name);
|
||||||
crc = progdefs_crc_both(crc, ";\n");
|
crc = progdefs_crc_both(crc, ";\n");
|
||||||
}
|
}
|
||||||
crc = progdefs_crc_both(crc, "} globalvars_t;\n\ntypedef struct\n{\n");
|
crc = progdefs_crc_both(crc, "} globalvars_t;\n\ntypedef struct\n{\n");
|
||||||
for (i = 0; i < parser->crc_fields; ++i) {
|
for (i = 0; i < parser->crc_fields; ++i) {
|
||||||
if (!ast_istype(parser->fields[i], ast_value))
|
if (!ast_istype(parser->fields[i], ast_value))
|
||||||
continue;
|
continue;
|
||||||
value = (ast_value*)(parser->fields[i]);
|
value = (ast_value*)(parser->fields[i]);
|
||||||
switch (value->expression.next->expression.vtype) {
|
switch (value->expression.next->expression.vtype) {
|
||||||
case TYPE_FLOAT: crc = progdefs_crc_both(crc, "\tfloat\t"); break;
|
case TYPE_FLOAT: crc = progdefs_crc_both(crc, "\tfloat\t"); break;
|
||||||
case TYPE_VECTOR: crc = progdefs_crc_both(crc, "\tvec3_t\t"); break;
|
case TYPE_VECTOR: crc = progdefs_crc_both(crc, "\tvec3_t\t"); break;
|
||||||
case TYPE_STRING: crc = progdefs_crc_both(crc, "\tstring_t\t"); break;
|
case TYPE_STRING: crc = progdefs_crc_both(crc, "\tstring_t\t"); break;
|
||||||
case TYPE_FUNCTION: crc = progdefs_crc_both(crc, "\tfunc_t\t"); break;
|
case TYPE_FUNCTION: crc = progdefs_crc_both(crc, "\tfunc_t\t"); break;
|
||||||
default:
|
default:
|
||||||
crc = progdefs_crc_both(crc, "\tint\t");
|
crc = progdefs_crc_both(crc, "\tint\t");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
crc = progdefs_crc_both(crc, value->name);
|
crc = progdefs_crc_both(crc, value->name);
|
||||||
crc = progdefs_crc_both(crc, ";\n");
|
crc = progdefs_crc_both(crc, ";\n");
|
||||||
}
|
}
|
||||||
crc = progdefs_crc_both(crc, "} entvars_t;\n\n");
|
crc = progdefs_crc_both(crc, "} entvars_t;\n\n");
|
||||||
|
|
||||||
code_crc = crc;
|
code_crc = crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parser_t *parser;
|
static parser_t *parser;
|
||||||
|
|
22
test.c
22
test.c
|
@ -169,12 +169,12 @@ int task_pclose(FILE **handles) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define _WIN32_LEAN_AND_MEAN
|
# define _WIN32_LEAN_AND_MEAN
|
||||||
# define popen _popen
|
# define popen _popen
|
||||||
# define pclose _pclose
|
# define pclose _pclose
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
/*
|
/*
|
||||||
* Bidirectional piping implementation for windows using CreatePipe and DuplicateHandle +
|
* Bidirectional piping implementation for windows using CreatePipe and DuplicateHandle +
|
||||||
* other hacks.
|
* other hacks.
|
||||||
|
@ -199,10 +199,10 @@ int task_pclose(FILE **handles) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef __MINGW32__
|
# ifdef __MINGW32__
|
||||||
/* mingw32 has dirent.h */
|
/* mingw32 has dirent.h */
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
# elif defined (_MSC_VER)
|
# elif defined (_MSC_VER)
|
||||||
/*
|
/*
|
||||||
* visual studio lacks dirent.h it's a posix thing
|
* visual studio lacks dirent.h it's a posix thing
|
||||||
* so we emulate it with the WinAPI.
|
* so we emulate it with the WinAPI.
|
||||||
|
@ -280,9 +280,9 @@ int task_pclose(FILE **handles) {
|
||||||
* Visual studio also lacks S_ISDIR for sys/stat.h, so we emulate this as well
|
* Visual studio also lacks S_ISDIR for sys/stat.h, so we emulate this as well
|
||||||
* which is not hard at all.
|
* which is not hard at all.
|
||||||
*/
|
*/
|
||||||
# undef S_ISDIR /* undef just incase */
|
# undef S_ISDIR /* undef just incase */
|
||||||
# define S_ISDIR(X) ((X)&_S_IFDIR)
|
# define S_ISDIR(X) ((X)&_S_IFDIR)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TASK_COMPILE 0
|
#define TASK_COMPILE 0
|
||||||
|
|
Loading…
Reference in a new issue