mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
fix lost initial char of string constants
make expression strings char * instead of string_t (don't put them into pr_strings prematurely);
This commit is contained in:
parent
53b66ef2e0
commit
90b5c57266
4 changed files with 11 additions and 12 deletions
|
@ -30,7 +30,7 @@ typedef struct expr_s {
|
|||
def_t *def;
|
||||
int int_val;
|
||||
float float_val;
|
||||
string_t string_val;
|
||||
char *string_val;
|
||||
float vector_val[3];
|
||||
float quaternion_val[4];
|
||||
} e;
|
||||
|
|
|
@ -130,7 +130,7 @@ print_expr (expr_t *e)
|
|||
printf ("%g", e->e.float_val);
|
||||
break;
|
||||
case ex_string:
|
||||
printf ("\"%s\"", strings + e->e.string_val);
|
||||
printf ("\"%s\"", e->e.string_val);
|
||||
break;
|
||||
case ex_vector:
|
||||
printf ("'%g", e->e.vector_val[0]);
|
||||
|
@ -153,16 +153,16 @@ do_op_string (int op, expr_t *e1, expr_t *e2)
|
|||
char *buf;
|
||||
char *s1, *s2;
|
||||
|
||||
s1 = strings + e1->e.string_val;
|
||||
s2 = strings + e2->e.string_val;
|
||||
s1 = e1->e.string_val;
|
||||
s2 = e2->e.string_val;
|
||||
|
||||
switch (op) {
|
||||
case '+':
|
||||
len = strlen (s1) + strlen (s2) + 1;
|
||||
buf = alloca (len);
|
||||
buf = malloc (len);
|
||||
strcpy (buf, s1);
|
||||
strcat (buf, s2);
|
||||
e1->e.string_val = ReuseString (buf);
|
||||
e1->e.string_val = buf;
|
||||
break;
|
||||
case LT:
|
||||
e1->type = ex_int;
|
||||
|
@ -502,8 +502,7 @@ unary_expr (int op, expr_t *e)
|
|||
e->type = ex_int;
|
||||
return e;
|
||||
case ex_string:
|
||||
e->e.int_val = !e->e.string_val
|
||||
|| !G_STRING(e->e.string_val)[0];
|
||||
e->e.int_val = !e->e.string_val || !e->e.string_val[0];
|
||||
e->type = ex_int;
|
||||
return e;
|
||||
case ex_vector:
|
||||
|
|
|
@ -261,7 +261,7 @@ make_string (char *token)
|
|||
{
|
||||
char *str;
|
||||
|
||||
pr_file_p = token + 1;
|
||||
pr_file_p = token;
|
||||
PR_LexString ();
|
||||
str = malloc (pr_token_len + 1);
|
||||
memcpy (str, pr_token, pr_token_len + 1);
|
||||
|
|
|
@ -510,7 +510,7 @@ const
|
|||
{
|
||||
$$ = new_expr ();
|
||||
$$->type = ex_string;
|
||||
$$->e.string_val = ReuseString ($1);
|
||||
$$->e.string_val = $1;
|
||||
}
|
||||
| VECTOR_VAL {}
|
||||
{
|
||||
|
@ -625,12 +625,12 @@ build_function (function_t *f)
|
|||
void
|
||||
emit_function (function_t *f, expr_t *e)
|
||||
{
|
||||
PR_PrintType (f->def->type);
|
||||
/* PR_PrintType (f->def->type);
|
||||
printf (" %s =\n{\n", f->def->name);
|
||||
while (e) {
|
||||
print_expr (e);
|
||||
puts("");
|
||||
e = e->next;
|
||||
}
|
||||
printf ("}\n");
|
||||
printf ("}\n");*/
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue