mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 22:22:17 +00:00
cut off too-long strings in disassembly
This commit is contained in:
parent
aa314ed147
commit
b93125c678
1 changed files with 11 additions and 3 deletions
14
exec.c
14
exec.c
|
@ -296,11 +296,19 @@ qcint prog_tempstring(qc_program *prog, const char *_str)
|
|||
return at;
|
||||
}
|
||||
|
||||
static int print_escaped_string(const char *str)
|
||||
static int print_escaped_string(const char *str, size_t maxlen)
|
||||
{
|
||||
int len = 2;
|
||||
putchar('"');
|
||||
--maxlen; /* because we're lazy and have escape sequences */
|
||||
while (*str) {
|
||||
if (len >= maxlen) {
|
||||
putchar('.');
|
||||
putchar('.');
|
||||
putchar('.');
|
||||
len += 3;
|
||||
break;
|
||||
}
|
||||
switch (*str) {
|
||||
case '\a': len += 2; putchar('\\'); putchar('a'); break;
|
||||
case '\b': len += 2; putchar('\\'); putchar('b'); break;
|
||||
|
@ -324,7 +332,7 @@ static int print_escaped_string(const char *str)
|
|||
|
||||
static void trace_print_global(qc_program *prog, unsigned int glob, int vtype)
|
||||
{
|
||||
static char spaces[40+1] = " ";
|
||||
static char spaces[28+1] = " ";
|
||||
prog_section_def *def;
|
||||
qcany *value;
|
||||
int len;
|
||||
|
@ -362,7 +370,7 @@ static void trace_print_global(qc_program *prog, unsigned int glob, int vtype)
|
|||
value->vector[2]);
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
len += print_escaped_string(prog_getstring(prog, value->string));
|
||||
len += print_escaped_string(prog_getstring(prog, value->string), sizeof(spaces)-len-5);
|
||||
len += printf(",");
|
||||
/* len += printf("\"%s\",", prog_getstring(prog, value->string)); */
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue