when using -trace in qcvm: print a newline after every print that doesn't end in a newline, so that the next disassembled instruction doesn't appear mid-text

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-22 17:37:22 +02:00
parent be18550b02
commit aa314ed147

11
exec.c
View file

@ -562,9 +562,11 @@ static qcint prog_leavefunction(qc_program *prog)
bool prog_exec(qc_program *prog, prog_section_function *func, size_t flags, long maxjumps) bool prog_exec(qc_program *prog, prog_section_function *func, size_t flags, long maxjumps)
{ {
long jumpcount = 0; long jumpcount = 0;
size_t oldxflags = prog->xflags;
prog_section_statement *st; prog_section_statement *st;
prog->vmerror = 0; prog->vmerror = 0;
prog->xflags = flags;
st = prog->code + prog_enterfunction(prog, func); st = prog->code + prog_enterfunction(prog, func);
--st; --st;
@ -602,6 +604,7 @@ bool prog_exec(qc_program *prog, prog_section_function *func, size_t flags, long
}; };
cleanup: cleanup:
prog->xflags = oldxflags;
prog->localstack_count = 0; prog->localstack_count = 0;
prog->stack_count = 0; prog->stack_count = 0;
if (prog->vmerror) if (prog->vmerror)
@ -650,9 +653,15 @@ bool opts_memchk = false;
static int qc_print(qc_program *prog) static int qc_print(qc_program *prog)
{ {
size_t i; size_t i;
const char *laststr = NULL;
for (i = 0; i < prog->argc; ++i) { for (i = 0; i < prog->argc; ++i) {
qcany *str = (qcany*)(prog->globals + OFS_PARM0 + 3*i); qcany *str = (qcany*)(prog->globals + OFS_PARM0 + 3*i);
printf("%s", prog_getstring(prog, str->string)); printf("%s", (laststr = prog_getstring(prog, str->string)));
}
if (laststr && (prog->xflags & VMXF_TRACE)) {
size_t len = strlen(laststr);
if (!len || laststr[len-1] != '\n')
printf("\n");
} }
return 0; return 0;
} }