mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 12:52:46 +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;
|
def_t *def;
|
||||||
int int_val;
|
int int_val;
|
||||||
float float_val;
|
float float_val;
|
||||||
string_t string_val;
|
char *string_val;
|
||||||
float vector_val[3];
|
float vector_val[3];
|
||||||
float quaternion_val[4];
|
float quaternion_val[4];
|
||||||
} e;
|
} e;
|
||||||
|
|
|
@ -130,7 +130,7 @@ print_expr (expr_t *e)
|
||||||
printf ("%g", e->e.float_val);
|
printf ("%g", e->e.float_val);
|
||||||
break;
|
break;
|
||||||
case ex_string:
|
case ex_string:
|
||||||
printf ("\"%s\"", strings + e->e.string_val);
|
printf ("\"%s\"", e->e.string_val);
|
||||||
break;
|
break;
|
||||||
case ex_vector:
|
case ex_vector:
|
||||||
printf ("'%g", e->e.vector_val[0]);
|
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 *buf;
|
||||||
char *s1, *s2;
|
char *s1, *s2;
|
||||||
|
|
||||||
s1 = strings + e1->e.string_val;
|
s1 = e1->e.string_val;
|
||||||
s2 = strings + e2->e.string_val;
|
s2 = e2->e.string_val;
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case '+':
|
case '+':
|
||||||
len = strlen (s1) + strlen (s2) + 1;
|
len = strlen (s1) + strlen (s2) + 1;
|
||||||
buf = alloca (len);
|
buf = malloc (len);
|
||||||
strcpy (buf, s1);
|
strcpy (buf, s1);
|
||||||
strcat (buf, s2);
|
strcat (buf, s2);
|
||||||
e1->e.string_val = ReuseString (buf);
|
e1->e.string_val = buf;
|
||||||
break;
|
break;
|
||||||
case LT:
|
case LT:
|
||||||
e1->type = ex_int;
|
e1->type = ex_int;
|
||||||
|
@ -502,8 +502,7 @@ unary_expr (int op, expr_t *e)
|
||||||
e->type = ex_int;
|
e->type = ex_int;
|
||||||
return e;
|
return e;
|
||||||
case ex_string:
|
case ex_string:
|
||||||
e->e.int_val = !e->e.string_val
|
e->e.int_val = !e->e.string_val || !e->e.string_val[0];
|
||||||
|| !G_STRING(e->e.string_val)[0];
|
|
||||||
e->type = ex_int;
|
e->type = ex_int;
|
||||||
return e;
|
return e;
|
||||||
case ex_vector:
|
case ex_vector:
|
||||||
|
|
|
@ -261,7 +261,7 @@ make_string (char *token)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
pr_file_p = token + 1;
|
pr_file_p = token;
|
||||||
PR_LexString ();
|
PR_LexString ();
|
||||||
str = malloc (pr_token_len + 1);
|
str = malloc (pr_token_len + 1);
|
||||||
memcpy (str, pr_token, pr_token_len + 1);
|
memcpy (str, pr_token, pr_token_len + 1);
|
||||||
|
|
|
@ -510,7 +510,7 @@ const
|
||||||
{
|
{
|
||||||
$$ = new_expr ();
|
$$ = new_expr ();
|
||||||
$$->type = ex_string;
|
$$->type = ex_string;
|
||||||
$$->e.string_val = ReuseString ($1);
|
$$->e.string_val = $1;
|
||||||
}
|
}
|
||||||
| VECTOR_VAL {}
|
| VECTOR_VAL {}
|
||||||
{
|
{
|
||||||
|
@ -625,12 +625,12 @@ build_function (function_t *f)
|
||||||
void
|
void
|
||||||
emit_function (function_t *f, expr_t *e)
|
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);
|
printf (" %s =\n{\n", f->def->name);
|
||||||
while (e) {
|
while (e) {
|
||||||
print_expr (e);
|
print_expr (e);
|
||||||
puts("");
|
puts("");
|
||||||
e = e->next;
|
e = e->next;
|
||||||
}
|
}
|
||||||
printf ("}\n");
|
printf ("}\n");*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue