From: Wolfgang (Blub) Bumiller Date: Wed, 22 Aug 2012 15:41:24 +0000 (+0200) Subject: cut off too-long strings in disassembly X-Git-Tag: 0.1-rc1~88 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b93125c678034b9d3b47f231c76dee6b573aa7e7;p=xonotic%2Fgmqcc.git cut off too-long strings in disassembly --- diff --git a/exec.c b/exec.c index 8b4660b..dc93a38 100644 --- a/exec.c +++ b/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;