mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
hash.h is now const correct as is a lot of qfcc
This commit is contained in:
parent
4aa47d728a
commit
e339e82c01
17 changed files with 40 additions and 35 deletions
|
@ -41,12 +41,12 @@ typedef struct hashlink_s {
|
|||
typedef struct hashtab_s {
|
||||
size_t tab_size;
|
||||
void *user_data;
|
||||
char *(*get_key)(void*,void*);
|
||||
const char *(*get_key)(void*,void*);
|
||||
void (*free_ele)(void*,void*);
|
||||
hashlink_t *tab[1]; // variable size
|
||||
} hashtab_t;
|
||||
|
||||
hashtab_t *Hash_NewTable (int tsize, char *(*gk)(void*,void*),
|
||||
hashtab_t *Hash_NewTable (int tsize, const char *(*gk)(void*,void*),
|
||||
void (*f)(void*,void*), void *ud);
|
||||
void Hash_DelTable (hashtab_t *tab);
|
||||
void Hash_FlushTable (hashtab_t *tab);
|
||||
|
|
|
@ -990,7 +990,7 @@ ED_LoadFromFile (progs_t * pr, char *data)
|
|||
Con_DPrintf ("%i entities inhibited\n", inhibit);
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
function_get_key (void *f, void *_pr)
|
||||
{
|
||||
progs_t *pr = (progs_t*)_pr;
|
||||
|
@ -998,7 +998,7 @@ function_get_key (void *f, void *_pr)
|
|||
return PR_GetString (pr, func->s_name);
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
var_get_key (void *d, void *_pr)
|
||||
{
|
||||
progs_t *pr = (progs_t*)_pr;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "QF/hash.h"
|
||||
#include "QF/progs.h"
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
strref_get_key (void *_sr, void *notused)
|
||||
{
|
||||
strref_t *sr = (strref_t*)_sr;
|
||||
|
|
|
@ -824,14 +824,14 @@ cmd_alias_free (void *_a, void *unused)
|
|||
free (a);
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
cmd_alias_get_key (void *_a, void *unused)
|
||||
{
|
||||
cmdalias_t *a = (cmdalias_t*)_a;
|
||||
return a->name;
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
cmd_get_key (void *c, void *unused)
|
||||
{
|
||||
cmd_function_t *cmd = (cmd_function_t*)c;
|
||||
|
|
|
@ -431,7 +431,7 @@ cvar_free (void *c, void *unused)
|
|||
free (cvar);
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
cvar_get_key (void *c, void *unused)
|
||||
{
|
||||
cvar_t *cvar = (cvar_t*)c;
|
||||
|
@ -446,7 +446,7 @@ calias_free (void *c, void *unused)
|
|||
free (calias);
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
calias_get_key (void *c, void *unused)
|
||||
{
|
||||
cvar_alias_t *calias = (cvar_alias_t*)c;
|
||||
|
|
|
@ -69,7 +69,7 @@ hash (const char *str)
|
|||
}
|
||||
|
||||
hashtab_t *
|
||||
Hash_NewTable (int tsize, char *(*gk)(void*,void*), void (*f)(void*,void*),
|
||||
Hash_NewTable (int tsize, const char *(*gk)(void*,void*), void (*f)(void*,void*),
|
||||
void *ud)
|
||||
{
|
||||
hashtab_t *tab = calloc (1, (size_t)&((hashtab_t*)0)->tab[tsize]);
|
||||
|
|
|
@ -716,7 +716,7 @@ COM_LoadStackFile (char *path, void *buffer, int bufsize)
|
|||
return buf;
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
pack_get_key (void *_p, void *unused)
|
||||
{
|
||||
packfile_t *p = (packfile_t *) _p;
|
||||
|
|
|
@ -69,7 +69,7 @@ int num_temp_skins;
|
|||
int skin_textures;
|
||||
int skin_fb_textures;
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
skin_get_key (void *_skin, void *unused)
|
||||
{
|
||||
skin_t *skin = (skin_t*)_skin;
|
||||
|
|
|
@ -69,7 +69,7 @@ int num_temp_skins;
|
|||
int skin_textures;
|
||||
int skin_fb_textures;
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
skin_get_key (void *_skin, void *unused)
|
||||
{
|
||||
skin_t *skin = (skin_t*)_skin;
|
||||
|
|
|
@ -252,7 +252,7 @@ typedef struct type_s
|
|||
typedef struct def_s
|
||||
{
|
||||
type_t *type;
|
||||
char *name;
|
||||
const char *name;
|
||||
struct def_s *next;
|
||||
struct def_s *scope_next; // to facilitate hash table removal
|
||||
gofs_t ofs;
|
||||
|
@ -293,7 +293,7 @@ struct function_s
|
|||
{
|
||||
int builtin; // if non 0, call an internal function
|
||||
int code; // first statement
|
||||
char *file; // source file with definition
|
||||
const char *file; // source file with definition
|
||||
int file_line;
|
||||
struct def_s *def;
|
||||
int parm_ofs[MAX_PARMS]; // allways contiguous, right?
|
||||
|
@ -369,9 +369,9 @@ type_t *PR_ParseType (void);
|
|||
char *PR_ParseName (void);
|
||||
def_t *PR_ParseImmediate (def_t *def);
|
||||
|
||||
qboolean PR_Check (token_type_t type, char *string);
|
||||
void PR_Expect (token_type_t type, char *string);
|
||||
void PR_ParseError (char *error, ...);
|
||||
qboolean PR_Check (token_type_t type, const char *string);
|
||||
void PR_Expect (token_type_t type, const char *string);
|
||||
void PR_ParseError (const char *error, ...);
|
||||
|
||||
|
||||
extern jmp_buf pr_parse_abort; // longjump with this on parse error
|
||||
|
@ -395,7 +395,7 @@ extern def_t *pr_scope;
|
|||
extern int pr_error_count;
|
||||
|
||||
void PR_NewLine (void);
|
||||
def_t *PR_GetDef (type_t *type, char *name, def_t *scope, qboolean allocate);
|
||||
def_t *PR_GetDef (type_t *type, const char *name, def_t *scope, qboolean allocate);
|
||||
def_t *PR_NewDef (type_t *type, const char *name, def_t *scope);
|
||||
void PR_FlushScope (def_t *scope);
|
||||
|
||||
|
@ -416,7 +416,7 @@ char *PR_ValueString (etype_t type, void *val);
|
|||
|
||||
void PR_ClearGrabMacros (void);
|
||||
|
||||
qboolean PR_CompileFile (char *string, char *filename);
|
||||
qboolean PR_CompileFile (char *string, const char *filename);
|
||||
|
||||
extern qboolean pr_dumpasm;
|
||||
|
||||
|
@ -464,7 +464,7 @@ extern char precache_files[MAX_FILES][MAX_DATA_PATH];
|
|||
extern int precache_files_block[MAX_SOUNDS];
|
||||
extern int numfiles;
|
||||
|
||||
int CopyString (char *str);
|
||||
int ReuseString (char *str);
|
||||
int CopyString (const char *str);
|
||||
int ReuseString (const char *str);
|
||||
|
||||
|
||||
|
|
|
@ -593,7 +593,7 @@ PR_ParseDefs (void)
|
|||
Compile the null-terminated text, adding definitions to the pr structure
|
||||
*/
|
||||
qboolean
|
||||
PR_CompileFile (char *string, char *filename)
|
||||
PR_CompileFile (char *string, const char *filename)
|
||||
{
|
||||
if (!pr.memory)
|
||||
Error ("PR_CompileFile: Didn't clear");
|
||||
|
|
|
@ -30,7 +30,7 @@ int pr_edict_size;
|
|||
|
||||
static hashtab_t *defs_by_name;
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
defs_get_key (void *_def, void *_tab)
|
||||
{
|
||||
def_t *def = (def_t*)_def;
|
||||
|
@ -49,7 +49,7 @@ defs_get_key (void *_def, void *_tab)
|
|||
If allocate is true, a new def will be allocated if it can't be found
|
||||
*/
|
||||
def_t *
|
||||
PR_GetDef (type_t *type, char *name, def_t *scope, qboolean allocate)
|
||||
PR_GetDef (type_t *type, const char *name, def_t *scope, qboolean allocate)
|
||||
{
|
||||
def_t *def;
|
||||
char element[MAX_NAME];
|
||||
|
|
|
@ -28,14 +28,14 @@ static hashtab_t *string_imm_defs;
|
|||
static hashtab_t *float_imm_defs;
|
||||
static hashtab_t *vector_imm_defs;
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
string_imm_get_key (void *_def, void *unused)
|
||||
{
|
||||
def_t *def = (def_t*)_def;
|
||||
return G_STRING (def->ofs);
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
float_imm_get_key (void *_def, void *unused)
|
||||
{
|
||||
def_t *def = (def_t*)_def;
|
||||
|
@ -44,7 +44,7 @@ float_imm_get_key (void *_def, void *unused)
|
|||
return rep;
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
vector_imm_get_key (void *_def, void *unused)
|
||||
{
|
||||
def_t *def = (def_t*)_def;
|
||||
|
|
|
@ -568,7 +568,7 @@ PR_Lex (void)
|
|||
Aborts the current file load
|
||||
*/
|
||||
void
|
||||
PR_ParseError (char *error, ...)
|
||||
PR_ParseError (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
@ -590,7 +590,7 @@ PR_ParseError (char *error, ...)
|
|||
to string
|
||||
*/
|
||||
void
|
||||
PR_Expect (token_type_t type, char *string)
|
||||
PR_Expect (token_type_t type, const char *string)
|
||||
{
|
||||
if (type != pr_token_type || strcmp (string, pr_token))
|
||||
PR_ParseError ("expected %s, found %s", string, pr_token);
|
||||
|
@ -605,7 +605,7 @@ PR_Expect (token_type_t type, char *string)
|
|||
Otherwise, return false and do nothing else.
|
||||
*/
|
||||
qboolean
|
||||
PR_Check (token_type_t type, char *string)
|
||||
PR_Check (token_type_t type, const char *string)
|
||||
{
|
||||
if (type != pr_token_type || strcmp (string, pr_token))
|
||||
return false;
|
||||
|
|
|
@ -169,7 +169,7 @@ PR_Statement (opcode_t * op, def_t * var_a, def_t * var_b)
|
|||
return var_c;
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
get_key (void *_op, void *_tab)
|
||||
{
|
||||
opcode_t *op = (opcode_t *)_op;
|
||||
|
|
|
@ -112,14 +112,14 @@ WriteFiles (void)
|
|||
*/
|
||||
static hashtab_t *strings_tab;
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
stings_get_key (void *_str, void *unsued)
|
||||
{
|
||||
return (char*)_str;
|
||||
}
|
||||
|
||||
int
|
||||
CopyString (char *str)
|
||||
CopyString (const char *str)
|
||||
{
|
||||
int old;
|
||||
|
||||
|
@ -134,7 +134,7 @@ CopyString (char *str)
|
|||
}
|
||||
|
||||
int
|
||||
ReuseString (char *str)
|
||||
ReuseString (const char *str)
|
||||
{
|
||||
char *s;
|
||||
|
||||
|
|
|
@ -2,10 +2,15 @@ string hello = "hello";
|
|||
string world = "world";
|
||||
float () main =
|
||||
{
|
||||
local string s;
|
||||
|
||||
print (hello + " " + world + "\n");
|
||||
if (hello < world)
|
||||
print (hello);
|
||||
if (world > hello)
|
||||
print (world);
|
||||
print ("\n");
|
||||
s = hello + world;
|
||||
s = s + "\n";
|
||||
print (s);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue