mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
minor cleanups and use escapes when printing strings
This commit is contained in:
parent
2ac0f40f7a
commit
4472f943c5
4 changed files with 82 additions and 53 deletions
|
@ -439,9 +439,11 @@ static const char *
|
|||
value_string (progs_t *pr, etype_t type, pr_type_t *val)
|
||||
{
|
||||
static dstring_t *line;
|
||||
ddef_t *def;
|
||||
int ofs;
|
||||
ddef_t *def;
|
||||
int ofs;
|
||||
edict_t *edict;
|
||||
dfunction_t *f;
|
||||
const char *str;
|
||||
|
||||
if (!line)
|
||||
line = dstring_new ();
|
||||
|
@ -452,11 +454,38 @@ value_string (progs_t *pr, etype_t type, pr_type_t *val)
|
|||
case ev_string:
|
||||
if (!PR_StringValid (pr, val->string_var))
|
||||
return "*** invalid ***";
|
||||
dsprintf (line, "\"%s\"", PR_GetString (pr, val->string_var));
|
||||
str = PR_GetString (pr, val->string_var);
|
||||
dstring_copystr (line, "\"");
|
||||
while (*str) {
|
||||
const char *s;
|
||||
|
||||
for (s = str; *s && !strchr ("\"\n\t", *s); s++)
|
||||
;
|
||||
if (s != str)
|
||||
dstring_appendsubstr (line, str, s - str);
|
||||
if (*s) {
|
||||
switch (*s) {
|
||||
case '\"':
|
||||
dstring_appendstr (line, "\\\"");
|
||||
break;
|
||||
case '\n':
|
||||
dstring_appendstr (line, "\\n");
|
||||
break;
|
||||
case '\t':
|
||||
dstring_appendstr (line, "\\t");
|
||||
break;
|
||||
default:
|
||||
dasprintf (line, "\\x%02x", *s & 0xff);
|
||||
}
|
||||
s++;
|
||||
}
|
||||
str = s;
|
||||
}
|
||||
dstring_appendstr (line, "\"");
|
||||
break;
|
||||
case ev_entity:
|
||||
dsprintf (line, "entity %i",
|
||||
NUM_FOR_BAD_EDICT (pr, PROG_TO_EDICT (pr, val->entity_var)));
|
||||
edict = PROG_TO_EDICT (pr, val->entity_var);
|
||||
dsprintf (line, "entity %i", NUM_FOR_BAD_EDICT (pr, edict));
|
||||
break;
|
||||
case ev_func:
|
||||
if (val->func_var < 0 || val->func_var >= pr->progs->numfunctions)
|
||||
|
|
|
@ -56,50 +56,6 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
cvar_t *pr_boundscheck;
|
||||
cvar_t *pr_deadbeef_ents;
|
||||
cvar_t *pr_deadbeef_locals;
|
||||
|
||||
int pr_type_size[ev_type_count] = {
|
||||
1, // ev_void
|
||||
1, // ev_string
|
||||
1, // ev_float
|
||||
3, // ev_vector
|
||||
1, // ev_entity
|
||||
1, // ev_field
|
||||
1, // ev_func
|
||||
1, // ev_pointer
|
||||
4, // ev_quaternion
|
||||
1, // ev_integer
|
||||
1, // ev_uinteger
|
||||
0, // ev_short value in opcode
|
||||
0, // ev_struct variable
|
||||
0, // ev_object variable
|
||||
0, // ev_class variable
|
||||
2, // ev_sel
|
||||
0, // ev_array variable
|
||||
};
|
||||
|
||||
const char *pr_type_name[ev_type_count] = {
|
||||
"void",
|
||||
"string",
|
||||
"float",
|
||||
"vector",
|
||||
"entity",
|
||||
"field",
|
||||
"function",
|
||||
"pointer",
|
||||
"quaternion",
|
||||
"integer",
|
||||
"uinteger",
|
||||
"short",
|
||||
"struct",
|
||||
"object",
|
||||
"Class",
|
||||
"SEL",
|
||||
"array",
|
||||
};
|
||||
|
||||
/*
|
||||
ED_ClearEdict
|
||||
|
||||
|
@ -289,7 +245,8 @@ NUM_FOR_EDICT (progs_t *pr, edict_t *e)
|
|||
b = NUM_FOR_BAD_EDICT (pr, e);
|
||||
|
||||
if (b && (b < 0 || b >= *(pr)->num_edicts))
|
||||
PR_RunError (pr, "NUM_FOR_EDICT: bad pointer %d %p %p", b, e, * (pr)->edicts);
|
||||
PR_RunError (pr, "NUM_FOR_EDICT: bad pointer %d %p %p", b, e,
|
||||
*(pr)->edicts);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,9 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
cvar_t *pr_boundscheck;
|
||||
cvar_t *pr_deadbeef_ents;
|
||||
cvar_t *pr_deadbeef_locals;
|
||||
cvar_t *pr_faultchecks;
|
||||
|
||||
static const char *
|
||||
|
|
|
@ -48,10 +48,50 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
|
||||
hashtab_t *opcode_table;
|
||||
|
||||
int pr_type_size[ev_type_count] = {
|
||||
1, // ev_void
|
||||
1, // ev_string
|
||||
1, // ev_float
|
||||
3, // ev_vector
|
||||
1, // ev_entity
|
||||
1, // ev_field
|
||||
1, // ev_func
|
||||
1, // ev_pointer
|
||||
4, // ev_quaternion
|
||||
1, // ev_integer
|
||||
1, // ev_uinteger
|
||||
0, // ev_short value in opcode
|
||||
0, // ev_struct variable
|
||||
0, // ev_object variable
|
||||
0, // ev_class variable
|
||||
2, // ev_sel
|
||||
0, // ev_array variable
|
||||
};
|
||||
|
||||
const char *pr_type_name[ev_type_count] = {
|
||||
"void",
|
||||
"string",
|
||||
"float",
|
||||
"vector",
|
||||
"entity",
|
||||
"field",
|
||||
"function",
|
||||
"pointer",
|
||||
"quaternion",
|
||||
"integer",
|
||||
"uinteger",
|
||||
"short",
|
||||
"struct",
|
||||
"object",
|
||||
"Class",
|
||||
"SEL",
|
||||
"array",
|
||||
};
|
||||
|
||||
// default format is "%Ga, %Gb, %gc"
|
||||
// V PR_GlobalString, void
|
||||
// G PR_GlobalString
|
||||
// g PR_GlobalStringNoContents
|
||||
// V global_string, contents, void
|
||||
// G global_string, contents
|
||||
// g global_string, no contents
|
||||
// s as short
|
||||
// O address + short
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue