From 6783c4dc81afb15297d09a3496132735ca884411 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Mon, 30 Oct 2023 00:40:29 +0000 Subject: [PATCH] Fix a qcc crash and some quirks. --- engine/qclib/qcc_pr_comp.c | 8 ++++---- engine/qclib/qccguistuff.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 00e988801..c98207f25 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -6248,7 +6248,7 @@ nolength: if (reqtype) { - QCC_PR_ParseWarning(WARN_FORMATSTRING, "%s: %s%s%s requires %s at arg %i (got %s%s%s)", funcname, col_name, formatbuf, col_none, reqtype, thisarg+1, col_type, TypeName(ARGCTYPE(thisarg), temp, sizeof(temp)), col_none); + QCC_PR_ParseWarning(WARN_FORMATSTRING, "%s: %s%s%s requires %s%s%s at arg %i (got %s%s%s)", funcname, col_name,formatbuf,col_none, col_type,reqtype,col_none, thisarg+1, col_type,TypeName(ARGCTYPE(thisarg), temp, sizeof(temp)),col_none); switch(ARGCTYPE(thisarg)->type) { case ev_string: @@ -7330,7 +7330,7 @@ QCC_sref_t QCC_PR_GenerateFunctionCallRef (QCC_sref_t newself, QCC_sref_t func, asz = 3-(ofs%3); if (ofs+asz > arglist[i]->cast->size) asz = arglist[i]->cast->size-ofs; - while (!copyop[asz-1] || !QCC_OPCodeValid(&pr_opcodes[copyop[asz-1]])) + while (asz > 3 || !copyop[asz-1] || (asz>1&&!QCC_OPCodeValid(&pr_opcodes[copyop[asz-1]]))) asz--; //can't do that size... if (copyop[0] == OP_STORE_F) @@ -9260,7 +9260,7 @@ QCC_ref_t *QCC_PR_ParseRefArrayPointer (QCC_ref_t *retbuf, QCC_ref_t *r, pbool a else { /*automatic runtime bounds checks on strings, I'm not going to check this too much...*/ - r = QCC_PR_BuildRef(retbuf, REF_STRING, QCC_RefToDef(r, true), tmp, type_float, r->readonly); + r = QCC_PR_BuildRef(retbuf, REF_STRING, QCC_RefToDef(r, true), tmp, (tmp.cast->type != ev_float)?type_integer:type_float, r->readonly); return QCC_PR_ParseRefArrayPointer(retbuf, r, allowarrayassign, makearraypointers); } } @@ -11918,7 +11918,7 @@ QCC_sref_t QCC_RefToDef(QCC_ref_t *ref, pbool freetemps) case REF_FIELD: return QCC_PR_ExpandField(ref->base, ref->index, ref->cast, freetemps?0:(STFL_PRESERVEA|STFL_PRESERVEB)); case REF_STRING: - if (ref->index.cast->type == ev_float) + if (ref->cast->type == ev_float) { idx = QCC_SupplyConversion(ref->index, ev_float, true); return QCC_PR_StatementFlags(&pr_opcodes[OP_LOADP_C], ref->base, idx, NULL, freetemps?0:(STFL_PRESERVEA|STFL_PRESERVEB)); diff --git a/engine/qclib/qccguistuff.c b/engine/qclib/qccguistuff.c index 3e8cce506..f6dcfffa0 100644 --- a/engine/qclib/qccguistuff.c +++ b/engine/qclib/qccguistuff.c @@ -891,10 +891,10 @@ int GUI_ParseCommandLine(const char *args, pbool keepsrcanddir) args=next; } - if (paramlen) - parameters[paramlen-1] = '\0'; - else - *parameters = '\0'; + + while (paramlen>0 && (parameters[paramlen-1] == ' ' || parameters[paramlen-1] == '\t')) + paramlen--; + parameters[paramlen] = '\0'; qccpersisthunk = (mode!=1); return mode;