mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 01:41:10 +00:00
Fix case label lookup.
It looks like I had forgotten that the compare function is supposed to return true/false (unlike memcmp's sorting ability). Also, avoid the pointers in the value struct as they can change without notice. Using enums in switches now works nicely, including warnings for unused enum values.
This commit is contained in:
parent
8ac2c3a04d
commit
29df4ac7ee
2 changed files with 8 additions and 4 deletions
|
@ -6,13 +6,13 @@ I = in progress
|
|||
W = waiting on other work
|
||||
|
||||
X fix object files
|
||||
X fix enums in switch statements (use tables (treat as int), check missing)
|
||||
M arrays in structures
|
||||
M unnamed function parameters for prototypes/typdefs etc.
|
||||
I optimizations (esp CSE)
|
||||
I fix used/uninitialized warnings
|
||||
o id id;
|
||||
o vec = [x, y, z]; expressions (nice feature in fteqcc)
|
||||
o fix enums in switch statements (use tables (treat as int), check missing)
|
||||
o arrays in entities
|
||||
o optional arguments for functions (alternative to overloading)
|
||||
vector(vector fwd, optional vector up) vectoangles = #51;
|
||||
|
|
|
@ -68,6 +68,8 @@ get_value (expr_t *e)
|
|||
{
|
||||
if (e->type == ex_symbol)
|
||||
return e->e.symbol->s.value;
|
||||
if (e->type != ex_value)
|
||||
internal_error (e, "bogus case label");
|
||||
return e->e.value;
|
||||
}
|
||||
|
||||
|
@ -80,7 +82,7 @@ get_hash (const void *_cl, void *unused)
|
|||
if (!cl->value)
|
||||
return 0;
|
||||
val = get_value (cl->value);
|
||||
return Hash_Buffer (val, sizeof (*val));
|
||||
return Hash_Buffer (&val->v, sizeof (val->v)) + val->type;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -99,8 +101,10 @@ compare (const void *_cla, const void *_clb, void *unused)
|
|||
if (extract_type (v1) != extract_type (v2))
|
||||
return 0;
|
||||
val1 = get_value (v1);
|
||||
val2 = get_value (v1);
|
||||
return memcmp (val1, val2, sizeof (*val1));
|
||||
val2 = get_value (v2);
|
||||
if (val1->type != val2->type)
|
||||
return 0;
|
||||
return memcmp (&val1->v, &val2->v, sizeof (val1->v)) == 0;
|
||||
}
|
||||
|
||||
struct expr_s *
|
||||
|
|
Loading…
Reference in a new issue