mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-30 23:51:46 +00:00
Merge branch 'master' into cooking
This commit is contained in:
commit
685fa54daf
15 changed files with 91 additions and 91 deletions
4
ast.c
4
ast.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (C) 2012, 2013
|
||||
* Wolfgang Bumiller
|
||||
* Dale Weiler
|
||||
* Dale Weiler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -2131,7 +2131,7 @@ bool ast_entfield_codegen(ast_entfield *self, ast_function *func, bool lvalue, i
|
|||
} else {
|
||||
*out = ir_block_create_load_from_ent(func->curblock, ast_ctx(self), ast_function_label(func, "efv"),
|
||||
ent, field, self->expression.vtype);
|
||||
/* Done AFTER error checking:
|
||||
/* Done AFTER error checking:
|
||||
codegen_output_type(self, *out);
|
||||
*/
|
||||
}
|
||||
|
|
2
ast.h
2
ast.h
|
@ -238,7 +238,7 @@ struct ast_binary_s
|
|||
ast_expression *left;
|
||||
ast_expression *right;
|
||||
ast_binary_ref refs;
|
||||
|
||||
|
||||
};
|
||||
ast_binary* ast_binary_new(lex_ctx ctx,
|
||||
int op,
|
||||
|
|
2
conout.c
2
conout.c
|
@ -288,7 +288,7 @@ int con_change(const char *out, const char *err) {
|
|||
/*
|
||||
* Defaultizer because stdio.h shouldn't be used anywhere except here
|
||||
* and inside file.c To prevent mis-match of wrapper-interfaces.
|
||||
*/
|
||||
*/
|
||||
FILE *con_default_out() {
|
||||
return (console.handle_out = stdout);
|
||||
}
|
||||
|
|
24
correct.c
24
correct.c
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 2012, 2013
|
||||
* Dale Weiler
|
||||
* Wolfgang Bumiller
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
|
@ -51,11 +51,11 @@
|
|||
* Bayesian interpretation. You can read more about it from here:
|
||||
* http://www.celiagreen.com/charlesmccreery/statistics/bayestutorial.pdf
|
||||
* (which is probably the only good online documentation for bayes theroy
|
||||
* no lie. Everything else just sucks ..)
|
||||
*
|
||||
* no lie. Everything else just sucks ..)
|
||||
*
|
||||
* Bayes' Thereom suggests something like the following:
|
||||
* AC P(I|C) P(C) / P(I)
|
||||
*
|
||||
*
|
||||
* However since P(I) is the same for every possibility of I, we can
|
||||
* completley ignore it giving just:
|
||||
* AC P(I|C) P(C)
|
||||
|
@ -72,7 +72,7 @@
|
|||
* 3: AC, the control mechanisim, an enumerator if you will, one that
|
||||
* enumerates all feasible values of C, to determine the one that
|
||||
* gives the greatest probability score.
|
||||
*
|
||||
*
|
||||
* In reality the requirement for a more complex expression involving
|
||||
* two seperate models is considerably a waste. But one must recognize
|
||||
* that P(C|I) is already conflating two factors. It's just much simpler
|
||||
|
@ -85,8 +85,8 @@
|
|||
* distance no greater than one. Knowing this we can optimize for most
|
||||
* cases of mistakes without taking a performance hit. Which is what we
|
||||
* base longer edit distances off of. Opposed to the original method of
|
||||
* I had concieved of checking everything.
|
||||
*
|
||||
* I had concieved of checking everything.
|
||||
*
|
||||
* A little information on additional algorithms used:
|
||||
*
|
||||
* Initially when I implemented this corrector, it was very slow.
|
||||
|
@ -117,8 +117,8 @@
|
|||
* char-to-index map into the branches. We've complelty made the trie
|
||||
* accesses entierly constant in lookup time. No really, a lookup is
|
||||
* literally trie[str[0]] [str[1]] [2] .... .value.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* Future Work (If we really need it)
|
||||
*
|
||||
* Currently we can only distinguish one source of error in the
|
||||
|
@ -128,7 +128,7 @@
|
|||
* Currently the error model has been fairly trivial, the smaller the
|
||||
* edit distance the smaller the error. This usually causes some un-
|
||||
* expected problems. e.g reciet->recite yields recipt. For QuakeC
|
||||
* this could become a problem when lots of identifiers are involved.
|
||||
* this could become a problem when lots of identifiers are involved.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -314,7 +314,7 @@ void correct_del(correct_trie_t* dictonary, size_t **data) {
|
|||
* not in the mood to figure out that logic. This is a reminder to
|
||||
* do it, or for someone else to :-) correct_edit however would also
|
||||
* need to take a size_t ** to carry it along (would all the argument
|
||||
* overhead be worth it?)
|
||||
* overhead be worth it?)
|
||||
*/
|
||||
static GMQCC_INLINE size_t correct_deletion(const char *ident, char **array) {
|
||||
size_t itr = 0;
|
||||
|
@ -421,7 +421,7 @@ static GMQCC_INLINE int correct_exist(char **array, register size_t *sizes, size
|
|||
/*
|
||||
* We can save tons of calls to memcmp if we simply ignore comparisions
|
||||
* that we know cannot contain the same length.
|
||||
*/
|
||||
*/
|
||||
if (sizes[itr] == len && !memcmp(array[itr], ident, len))
|
||||
return 1;
|
||||
}
|
||||
|
|
12
fs.c
12
fs.c
|
@ -33,7 +33,7 @@
|
|||
* to adding support for some other larger IO tasks (in the test-suite,
|
||||
* or even the QCVM we'll need it). There is also a third possibility of
|
||||
* building .dat files directly from zip files (which would be very cool
|
||||
* at least I think so).
|
||||
* at least I think so).
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
/* {{{ */
|
||||
|
@ -41,7 +41,7 @@
|
|||
* Visual Studio has security CRT features which I actually want to support
|
||||
* if we ever port to Windows 8, and want GMQCC to be API safe.
|
||||
*
|
||||
* We handle them here, for all file-operations.
|
||||
* We handle them here, for all file-operations.
|
||||
*/
|
||||
|
||||
static void file_exception (
|
||||
|
@ -128,7 +128,7 @@
|
|||
|
||||
/*
|
||||
* These are implemented as just generic wrappers to keep consistency in
|
||||
* the API. Not as macros though
|
||||
* the API. Not as macros though
|
||||
*/
|
||||
void fs_file_close(FILE *fp) {
|
||||
/* Invokes file_exception on windows if fp is null */
|
||||
|
@ -221,7 +221,7 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) {
|
|||
/*
|
||||
* Now we implement some directory functionality. Windows lacks dirent.h
|
||||
* this is such a pisss off, we implement it here.
|
||||
*/
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
DIR *fs_dir_open(const char *name) {
|
||||
DIR *dir = (DIR*)mem_a(sizeof(DIR) + strlen(name));
|
||||
|
@ -231,7 +231,7 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) {
|
|||
strncpy(dir->dd_name, name, strlen(name));
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
int fs_dir_close(DIR *dir) {
|
||||
FindClose((HANDLE)dir->dd_handle);
|
||||
mem_d ((void*)dir);
|
||||
|
@ -267,7 +267,7 @@ int fs_file_getline(char **lineptr, size_t *n, FILE *stream) {
|
|||
|
||||
if (!rets)
|
||||
return NULL;
|
||||
|
||||
|
||||
if ((data = (struct dirent*)mem_a(sizeof(struct dirent)))) {
|
||||
strncpy(data->d_name, info.cFileName, FILENAME_MAX - 1);
|
||||
data->d_name[FILENAME_MAX - 1] = '\0'; /* terminate */
|
||||
|
|
4
ftepp.c
4
ftepp.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (C) 2012, 2013
|
||||
* Wolfgang Bumiller
|
||||
* Dale Weiler
|
||||
* Dale Weiler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -76,7 +76,7 @@ typedef struct ftepp_s {
|
|||
/*
|
||||
* Implement the predef subsystem now. We can do this safely with the
|
||||
* help of lexer contexts.
|
||||
*/
|
||||
*/
|
||||
static uint32_t ftepp_predef_countval = 0;
|
||||
static uint32_t ftepp_predef_randval = 0;
|
||||
|
||||
|
|
8
gmqcc.h
8
gmqcc.h
|
@ -168,7 +168,7 @@ GMQCC_IND_STRING(GMQCC_VERSION_PATCH) \
|
|||
typedef __int64 int64_t;
|
||||
#endif /*! _MSC_VER */
|
||||
|
||||
/*
|
||||
/*
|
||||
*windows makes these prefixed because they're C99
|
||||
* TODO: utility versions that are type-safe and not
|
||||
* just plain textual subsitution.
|
||||
|
@ -263,7 +263,7 @@ GMQCC_IND_STRING(GMQCC_VERSION_PATCH) \
|
|||
* On windows systems where we're not compiling with MING32 we need a
|
||||
* little extra help on dependinces for implementing our own dirent.h
|
||||
* in fs.c.
|
||||
*/
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
# define _WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
@ -421,7 +421,7 @@ void util_htrm (hash_table_t *ht, const char *key, void (*cb)(void*));
|
|||
|
||||
void *util_htget (hash_table_t *ht, const char *key);
|
||||
void *util_htgeth(hash_table_t *ht, const char *key, size_t hash);
|
||||
|
||||
|
||||
/*===================================================================*/
|
||||
/*============================ file.c ===============================*/
|
||||
/*===================================================================*/
|
||||
|
@ -432,7 +432,7 @@ int fs_file_getc (FILE *);
|
|||
int fs_file_printf (FILE *, const char *, ...);
|
||||
int fs_file_puts (FILE *, const char *);
|
||||
int fs_file_seek (FILE *, long int, int);
|
||||
long int fs_file_tell (FILE *);
|
||||
long int fs_file_tell (FILE *);
|
||||
|
||||
size_t fs_file_read (void *, size_t, size_t, FILE *);
|
||||
size_t fs_file_write (const void *, size_t, size_t, FILE *);
|
||||
|
|
16
intrin.h
16
intrin.h
|
@ -87,7 +87,7 @@ ast_expression *intrin_pow(parser_t *parser) {
|
|||
* local *= x;
|
||||
* }
|
||||
* return local;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
static ast_value *value = NULL;
|
||||
|
||||
|
@ -226,7 +226,7 @@ ast_expression *intrin_mod(parser_t *parser) {
|
|||
* float mod(float x, float y) {
|
||||
* return x - y * floor(x / y);
|
||||
* }
|
||||
*/
|
||||
*/
|
||||
static ast_value *value = NULL;
|
||||
|
||||
if (!value) {
|
||||
|
@ -321,8 +321,8 @@ ast_expression *intrin_isnan(parser_t *parser) {
|
|||
* local = x;
|
||||
*
|
||||
* return (x != local);
|
||||
* }
|
||||
*/
|
||||
* }
|
||||
*/
|
||||
static ast_value *value = NULL;
|
||||
|
||||
if (!value) {
|
||||
|
@ -330,7 +330,7 @@ ast_expression *intrin_isnan(parser_t *parser) {
|
|||
ast_value *local = ast_value_new (parser_ctx(parser), "local", TYPE_FLOAT);
|
||||
ast_block *body = ast_block_new (parser_ctx(parser));
|
||||
ast_function *func = NULL;
|
||||
|
||||
|
||||
INTRIN_VAL(value, "isnan", func, "<float>", TYPE_FLOAT);
|
||||
|
||||
vec_push(body->locals, local);
|
||||
|
@ -399,8 +399,8 @@ ast_expression *intrin_func(parser_t *parser, const char *name) {
|
|||
/*
|
||||
* jesus fucking christ, Blub design something less fucking
|
||||
* impossible to use, like a ast_is_builtin(ast_expression *), also
|
||||
* use a hashtable :P
|
||||
*/
|
||||
* use a hashtable :P
|
||||
*/
|
||||
if ((find = (void*)parser_find_global(parser, name)) && ((ast_value*)find)->expression.vtype == TYPE_FUNCTION)
|
||||
for (i = 0; i < vec_size(parser->functions); ++i)
|
||||
if (((ast_value*)find)->name && !strcmp(parser->functions[i]->name, ((ast_value*)find)->name) && parser->functions[i]->builtin < 0)
|
||||
|
@ -409,7 +409,7 @@ ast_expression *intrin_func(parser_t *parser, const char *name) {
|
|||
if ((find = util_htget(intrin_intrinsics(), name))) {
|
||||
/* intrinsic is in table. This will "generate the function" so
|
||||
* to speak (if it's not already generated).
|
||||
*/
|
||||
*/
|
||||
return ((intrin_t*)find)->intrin(parser);
|
||||
}
|
||||
|
||||
|
|
2
ir.c
2
ir.c
|
@ -3812,7 +3812,7 @@ void ir_function_dump(ir_function *f, char *ind,
|
|||
}
|
||||
if (vec_size(f->blocks))
|
||||
{
|
||||
oprintf("%slife passes: %i\n", ind, (int)f->run_id);
|
||||
oprintf("%slife passes: %i\n", ind, (int)f->run_id);
|
||||
for (i = 0; i < vec_size(f->blocks); ++i) {
|
||||
ir_block_dump(f->blocks[i], ind, oprintf);
|
||||
}
|
||||
|
|
2
lexer.c
2
lexer.c
|
@ -1235,7 +1235,7 @@ int lex_do(lex_file *lex)
|
|||
/*
|
||||
case '+':
|
||||
case '-':
|
||||
*/
|
||||
*/
|
||||
case '*':
|
||||
case '/':
|
||||
case '<':
|
||||
|
|
8
opts.c
8
opts.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (C) 2012, 2013
|
||||
* Wolfgang Bumiller
|
||||
* Dale Weiler
|
||||
* Dale Weiler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -269,7 +269,7 @@ static char *opts_ini_load(const char *section, const char *name, const char *va
|
|||
/*
|
||||
* undef all of these because they may still be defined like in my
|
||||
* case they where.
|
||||
*/
|
||||
*/
|
||||
#undef GMQCC_TYPE_FLAGS
|
||||
#undef GMQCC_TYPE_OPTIMIZATIONS
|
||||
#undef GMQCC_TYPE_WARNS
|
||||
|
@ -347,7 +347,7 @@ void opts_ini_init(const char *file) {
|
|||
size_t line;
|
||||
FILE *ini;
|
||||
|
||||
|
||||
|
||||
if (!file) {
|
||||
/* try ini */
|
||||
if (!(ini = fs_file_open((file = "gmqcc.ini"), "r")))
|
||||
|
@ -366,4 +366,4 @@ void opts_ini_init(const char *file) {
|
|||
}
|
||||
|
||||
fs_file_close(ini);
|
||||
}
|
||||
}
|
||||
|
|
42
pak.c
42
pak.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2013
|
||||
* Dale Weiler
|
||||
* Dale Weiler
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
|
@ -25,7 +25,7 @@
|
|||
/*
|
||||
* The PAK format uses a FOURCC concept for storing the magic ident within
|
||||
* the header as a uint32_t.
|
||||
*/
|
||||
*/
|
||||
#define PAK_FOURCC ((uint32_t)(('P' | ('A' << 8) | ('C' << 16) | ('K' << 24))))
|
||||
|
||||
typedef struct {
|
||||
|
@ -36,7 +36,7 @@ typedef struct {
|
|||
* best to store the directories at the end of the file opposed
|
||||
* to the front, since it allows easy insertion without having
|
||||
* to load the entire file into memory again.
|
||||
*/
|
||||
*/
|
||||
uint32_t diroff;
|
||||
uint32_t dirlen;
|
||||
} pak_header_t;
|
||||
|
@ -47,7 +47,7 @@ typedef struct {
|
|||
* describes a file (with directories/nested ones too in it's
|
||||
* file name). Hence it can be a file, file with directory, or
|
||||
* file with directories.
|
||||
*/
|
||||
*/
|
||||
typedef struct {
|
||||
char name[56];
|
||||
uint32_t pos;
|
||||
|
@ -58,7 +58,7 @@ typedef struct {
|
|||
* Used to get the next token from a string, where the
|
||||
* strings themselfs are seperated by chracters from
|
||||
* `sep`. This is essentially strsep.
|
||||
*/
|
||||
*/
|
||||
static char *pak_tree_sep(char **str, const char *sep) {
|
||||
char *beg = *str;
|
||||
char *end;
|
||||
|
@ -158,13 +158,13 @@ static pak_file_t *pak_open_read(const char *file) {
|
|||
/*
|
||||
* Time to read in the directory handles and prepare the directories
|
||||
* vector. We're going to be reading some the file inwards soon.
|
||||
*/
|
||||
*/
|
||||
fs_file_seek(pak->handle, pak->header.diroff, SEEK_SET);
|
||||
|
||||
/*
|
||||
* Read in all directories from the PAK file. These are considered
|
||||
* to be the "file entries".
|
||||
*/
|
||||
*/
|
||||
for (itr = 0; itr < pak->header.dirlen / 64; itr++) {
|
||||
pak_directory_t dir;
|
||||
fs_file_read (&dir, sizeof(pak_directory_t), 1, pak->handle);
|
||||
|
@ -184,14 +184,14 @@ static pak_file_t *pak_open_write(const char *file) {
|
|||
/*
|
||||
* Generate the required directory structure / tree for
|
||||
* writing this PAK file too.
|
||||
*/
|
||||
*/
|
||||
pak_tree_build(file);
|
||||
|
||||
if (!(pak->handle = fs_file_open(file, "wb"))) {
|
||||
/*
|
||||
* The directory tree that was created, needs to be
|
||||
* removed entierly if we failed to open a file.
|
||||
*/
|
||||
*/
|
||||
/* TODO backup directory clean */
|
||||
|
||||
mem_d(pak);
|
||||
|
@ -239,13 +239,13 @@ bool pak_exists(pak_file_t *pak, const char *file, pak_directory_t **dir) {
|
|||
|
||||
if (!pak || !file)
|
||||
return false;
|
||||
|
||||
|
||||
for (itr = 0; itr < vec_size(pak->directories); itr++) {
|
||||
if (!strcmp(pak->directories[itr].name, file)) {
|
||||
/*
|
||||
* Store back a pointer to the directory that matches
|
||||
* the request if requested (NULL is not allowed).
|
||||
*/
|
||||
*/
|
||||
if (dir) {
|
||||
*dir = &(pak->directories[itr]);
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ bool pak_exists(pak_file_t *pak, const char *file, pak_directory_t **dir) {
|
|||
|
||||
/*
|
||||
* Extraction abilities. These work as you expect them to.
|
||||
*/
|
||||
*/
|
||||
bool pak_extract_one(pak_file_t *pak, const char *file, const char *outdir) {
|
||||
pak_directory_t *dir = NULL;
|
||||
unsigned char *dat = NULL;
|
||||
|
@ -276,7 +276,7 @@ bool pak_extract_one(pak_file_t *pak, const char *file, const char *outdir) {
|
|||
/*
|
||||
* Generate the directory structure / tree that will be required
|
||||
* to store the extracted file.
|
||||
*/
|
||||
*/
|
||||
pak_tree_build(file);
|
||||
|
||||
/* TODO portable path seperators */
|
||||
|
@ -285,7 +285,7 @@ bool pak_extract_one(pak_file_t *pak, const char *file, const char *outdir) {
|
|||
/*
|
||||
* Now create the file, if this operation fails. Then abort
|
||||
* It shouldn't fail though.
|
||||
*/
|
||||
*/
|
||||
if (!(out = fs_file_open(local, "wb"))) {
|
||||
mem_d(dat);
|
||||
return false;
|
||||
|
@ -336,8 +336,8 @@ bool pak_insert_one(pak_file_t *pak, const char *file) {
|
|||
/*
|
||||
* We don't allow insertion on files that already exist within the
|
||||
* pak file. Weird shit can happen if we allow that ;). We also
|
||||
* don't allow insertion if the pak isn't opened in write mode.
|
||||
*/
|
||||
* don't allow insertion if the pak isn't opened in write mode.
|
||||
*/
|
||||
if (!pak || !file || !pak->insert || pak_exists(pak, file, NULL))
|
||||
return false;
|
||||
|
||||
|
@ -358,7 +358,7 @@ bool pak_insert_one(pak_file_t *pak, const char *file) {
|
|||
/*
|
||||
* We're limited to 56 bytes for a file name string, that INCLUDES
|
||||
* the directory and '/' seperators.
|
||||
*/
|
||||
*/
|
||||
if (strlen(file) >= 56) {
|
||||
fs_file_close(fp);
|
||||
return false;
|
||||
|
@ -369,7 +369,7 @@ bool pak_insert_one(pak_file_t *pak, const char *file) {
|
|||
/*
|
||||
* Allocate some memory for loading in the data that will be
|
||||
* redirected into the PAK file.
|
||||
*/
|
||||
*/
|
||||
if (!(dat = (unsigned char *)mem_a(dir.len))) {
|
||||
fs_file_close(fp);
|
||||
return false;
|
||||
|
@ -391,7 +391,7 @@ bool pak_insert_one(pak_file_t *pak, const char *file) {
|
|||
/*
|
||||
* Like pak_insert_one, except this collects files in all directories
|
||||
* from a root directory, and inserts them all.
|
||||
*/
|
||||
*/
|
||||
bool pak_insert_all(pak_file_t *pak, const char *dir) {
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
|
@ -422,12 +422,12 @@ bool pak_close(pak_file_t *pak) {
|
|||
/*
|
||||
* In insert mode we need to patch the header, and write
|
||||
* our directory entries at the end of the file.
|
||||
*/
|
||||
*/
|
||||
if (pak->insert) {
|
||||
pak->header.dirlen = vec_size(pak->directories) * 64;
|
||||
pak->header.diroff = ftell(pak->handle);
|
||||
|
||||
/* patch header */
|
||||
/* patch header */
|
||||
fs_file_seek (pak->handle, 0, SEEK_SET);
|
||||
fs_file_write(&(pak->header), sizeof(pak_header_t), 1, pak->handle);
|
||||
|
||||
|
|
14
parser.c
14
parser.c
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 2012, 2013
|
||||
* Wolfgang Bumiller
|
||||
* Dale Weiler
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
|
@ -1902,7 +1902,7 @@ static bool parse_sya_operand(parser_t *parser, shunt *sy, bool with_labels)
|
|||
} else {
|
||||
var = intrin_func(parser, parser_tokval(parser));
|
||||
}
|
||||
|
||||
|
||||
if (!var) {
|
||||
char *correct = NULL;
|
||||
size_t i;
|
||||
|
@ -5171,7 +5171,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
|
|||
/*
|
||||
* store the vstring back to var for alias and
|
||||
* deprecation messages.
|
||||
*/
|
||||
*/
|
||||
if (var->expression.flags & AST_FLAG_DEPRECATED ||
|
||||
var->expression.flags & AST_FLAG_ALIAS)
|
||||
var->desc = vstring;
|
||||
|
@ -5268,7 +5268,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
|
|||
ast_value_set_name(proto->expression.params[i], var->expression.params[i]->name);
|
||||
if (!parser_check_qualifiers(parser, var, proto)) {
|
||||
retval = false;
|
||||
if (proto->desc)
|
||||
if (proto->desc)
|
||||
mem_d(proto->desc);
|
||||
proto = NULL;
|
||||
goto cleanup;
|
||||
|
@ -5409,13 +5409,13 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
|
|||
/*
|
||||
* add alias to aliases table and to corrector
|
||||
* so corrections can apply for aliases as well.
|
||||
*/
|
||||
*/
|
||||
util_htset(parser->aliases, var->name, find);
|
||||
|
||||
/*
|
||||
* add to corrector so corrections can work
|
||||
* even for aliases too.
|
||||
*/
|
||||
*/
|
||||
correct_add (
|
||||
vec_last(parser->correct_variables),
|
||||
&vec_last(parser->correct_variables_score),
|
||||
|
@ -5441,7 +5441,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
|
|||
/*
|
||||
* add to corrector so corrections can work
|
||||
* even for aliases too.
|
||||
*/
|
||||
*/
|
||||
correct_add (
|
||||
vec_last(parser->correct_variables),
|
||||
&vec_last(parser->correct_variables_score),
|
||||
|
|
28
test.c
28
test.c
|
@ -210,7 +210,7 @@ int task_pclose(FILE **handles) {
|
|||
* This will perform compilation and execution
|
||||
* -fail
|
||||
* This will perform compilation, but requires
|
||||
* the compilation to fail in order to succeed.
|
||||
* the compilation to fail in order to succeed.
|
||||
*
|
||||
* This must be provided, this tag is NOT optional.
|
||||
*
|
||||
|
@ -329,7 +329,7 @@ bool task_template_generate(task_template_t *tmpl, char tag, const char *file, s
|
|||
/*
|
||||
* Create some padding for the description to align the
|
||||
* printing of the rules file.
|
||||
*/
|
||||
*/
|
||||
if ((desclen = strlen(tmpl->description)) > pad[0])
|
||||
pad[0] = desclen;
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ task_template_t *task_template_compile(const char *file, const char *dir, size_t
|
|||
/*
|
||||
* Create some padding for the printing to align the
|
||||
* printing of the rules file to the console.
|
||||
*/
|
||||
*/
|
||||
if ((filepadd = strlen(fullfile)) > pad[1])
|
||||
pad[1] = filepadd;
|
||||
|
||||
|
@ -859,7 +859,7 @@ void task_destroy(void) {
|
|||
/*
|
||||
* Only remove the log files if the test actually compiled otherwise
|
||||
* forget about it (or if it didn't compile, and the procedure type
|
||||
* was set to -fail (meaning it shouldn't compile) .. stil remove)
|
||||
* was set to -fail (meaning it shouldn't compile) .. stil remove)
|
||||
*/
|
||||
if (task_tasks[i].compiled || !strcmp(task_tasks[i].tmpl->proceduretype, "-fail")) {
|
||||
if (remove(task_tasks[i].stdoutlogfile))
|
||||
|
@ -887,7 +887,7 @@ void task_destroy(void) {
|
|||
* This executes the QCVM task for a specificly compiled progs.dat
|
||||
* using the template passed into it for call-flags and user defined
|
||||
* messages IF the procedure type is -execute, otherwise it matches
|
||||
* the preprocessor output.
|
||||
* the preprocessor output.
|
||||
*/
|
||||
bool task_trymatch(task_template_t *tmpl, char ***line) {
|
||||
bool success = true;
|
||||
|
@ -972,7 +972,7 @@ bool task_trymatch(task_template_t *tmpl, char ***line) {
|
|||
/*
|
||||
* Copy to output vector for diagnostics if execution match
|
||||
* fails.
|
||||
*/
|
||||
*/
|
||||
vec_push(*line, data);
|
||||
|
||||
/* reset */
|
||||
|
@ -1022,7 +1022,7 @@ void task_schedualize(size_t *pad) {
|
|||
for (; i < vec_size(task_tasks); i++) {
|
||||
memset(space[1], 0, sizeof(space[1]));
|
||||
snprintf(space[1], sizeof(space[1]), "%d", (int)(i + 1));
|
||||
|
||||
|
||||
con_out("test #%u %*s", i + 1, strlen(space[0]) - strlen(space[1]), "");
|
||||
|
||||
util_debug("TEST", "executing task: %d: %s\n", i, task_tasks[i].tmpl->description);
|
||||
|
@ -1086,7 +1086,7 @@ void task_schedualize(size_t *pad) {
|
|||
task_tasks[i].tmpl->rulesfile,
|
||||
(pad[1] + pad[2] - strlen(task_tasks[i].tmpl->rulesfile)) + (strlen(task_type(task_tasks[i].tmpl)) - pad[2]),
|
||||
task_type(task_tasks[i].tmpl)
|
||||
|
||||
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
@ -1094,7 +1094,7 @@ void task_schedualize(size_t *pad) {
|
|||
/*
|
||||
* If we made it here that concludes the task is to be executed
|
||||
* in the virtual machine (or the preprocessor output needs to
|
||||
* be matched).
|
||||
* be matched).
|
||||
*/
|
||||
if (!task_trymatch(task_tasks[i].tmpl, &match)) {
|
||||
size_t d = 0;
|
||||
|
@ -1136,7 +1136,7 @@ void task_schedualize(size_t *pad) {
|
|||
* Print the non-expected out (since we are simply not expecting it)
|
||||
* This will help track down bugs in template files that fail to match
|
||||
* something.
|
||||
*/
|
||||
*/
|
||||
if (vec_size(match) > vec_size(task_tasks[i].tmpl->comparematch)) {
|
||||
for (d = 0; d < vec_size(match) - vec_size(task_tasks[i].tmpl->comparematch); d++) {
|
||||
con_out(" Expected: Nothing | Got: \"%s\"\n",
|
||||
|
@ -1144,7 +1144,7 @@ void task_schedualize(size_t *pad) {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (j = 0; j < vec_size(match); j++)
|
||||
mem_d(match[j]);
|
||||
|
@ -1161,7 +1161,7 @@ void task_schedualize(size_t *pad) {
|
|||
task_tasks[i].tmpl->rulesfile,
|
||||
(pad[1] + pad[2] - strlen(task_tasks[i].tmpl->rulesfile)) + (strlen(task_type(task_tasks[i].tmpl))- pad[2]),
|
||||
task_type(task_tasks[i].tmpl)
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
mem_d(data);
|
||||
|
@ -1192,11 +1192,11 @@ GMQCC_WARN bool test_perform(const char *curdir, const char *defs) {
|
|||
/*
|
||||
* If the default definition file isn't set to anything. We will
|
||||
* use the default_defs here, which is "defs.qc"
|
||||
*/
|
||||
*/
|
||||
if (!defs) {
|
||||
defs = default_defs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
task_precleanup(curdir);
|
||||
if (!task_propagate(curdir, pad, defs)) {
|
||||
|
|
14
util.c
14
util.c
|
@ -262,7 +262,7 @@ void util_debug(const char *area, const char *ms, ...) {
|
|||
/*
|
||||
* only required if big endian .. otherwise no need to swap
|
||||
* data.
|
||||
*/
|
||||
*/
|
||||
#if PLATFORM_BYTE_ORDER == GMQCC_BYTE_ORDER_BIG
|
||||
static GMQCC_INLINE void util_swap16(uint16_t *d, size_t l) {
|
||||
while (l--) {
|
||||
|
@ -402,7 +402,7 @@ static const uint16_t util_crc16_table[] = {
|
|||
/* Non - Reflected */
|
||||
uint16_t util_crc16(uint16_t current, const char *k, size_t len) {
|
||||
register uint16_t h = current;
|
||||
for (; len; --len, ++k)
|
||||
for (; len; --len, ++k)
|
||||
h = util_crc16_table[(h>>8)^((unsigned char)*k)]^(h<<8);
|
||||
return h;
|
||||
}
|
||||
|
@ -410,9 +410,9 @@ uint16_t util_crc16(uint16_t current, const char *k, size_t len) {
|
|||
#if 0
|
||||
uint16_t util_crc16(const char *k, int len, const short clamp) {
|
||||
register uint16_t h= (uint16_t)0xFFFFFFFF;
|
||||
for (; len; --len, ++k)
|
||||
for (; len; --len, ++k)
|
||||
h = util_crc16_table[(h^((unsigned char)*k))&0xFF]^(h>>8);
|
||||
return (~h)%clamp;
|
||||
return (~h)%clamp;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -674,7 +674,7 @@ void util_htdel(hash_table_t *ht) {
|
|||
* Portable implementation of vasprintf/asprintf. Assumes vsnprintf
|
||||
* exists, otherwise compiler error.
|
||||
*
|
||||
* TODO: fix for MSVC ....
|
||||
* TODO: fix for MSVC ....
|
||||
*/
|
||||
int util_vasprintf(char **dat, const char *fmt, va_list args) {
|
||||
int ret;
|
||||
|
@ -686,7 +686,7 @@ int util_vasprintf(char **dat, const char *fmt, va_list args) {
|
|||
* formatted string if it overflows. However there is a MSVC
|
||||
* intrinsic (which is documented wrong) called _vcsprintf which
|
||||
* will return the required amount to allocate.
|
||||
*/
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
char *str;
|
||||
if ((len = _vscprintf(fmt, args)) < 0) {
|
||||
|
@ -779,7 +779,7 @@ static GMQCC_INLINE void mt_generate() {
|
|||
* a branch that is executed every iteration from [0, MT_SIZE).
|
||||
*
|
||||
* Please see: http://www.quadibloc.com/crypto/co4814.htm for more
|
||||
* information on how this clever trick works.
|
||||
* information on how this clever trick works.
|
||||
*/
|
||||
static const uint32_t matrix[2] = {
|
||||
0x00000000,
|
||||
|
|
Loading…
Reference in a new issue