void qspRestoreVarsList(QSPVar *vars, int varsCount) { int i; QSPVar *var; if (vars) { for (i = 0; i < varsCount; ++i) { if (!(var = qspVarReference(vars[i].Name, QSP_TRUE))) { while (i < varsCount) { free(vars[i].Name); qspEmptyVar(vars + i); ++i; } free(vars); return; } free(vars[i].Name); qspEmptyVar(var); qspMoveVar(var, vars + i); } free(vars); } }
int qspPrepareLocalVars(QSPVar **vars) { QSPVar *var, *savedVars; int i, j, ind, varsCount = 0; for (i = qspSavedVarsGroupsCount - 1; i >= 0; --i) varsCount += qspSavedVarsGroups[i].VarsCount; if (!varsCount) { *vars = 0; return 0; } savedVars = (QSPVar *)malloc(varsCount * sizeof(QSPVar)); ind = 0; for (i = qspSavedVarsGroupsCount - 1; i >= 0; --i) { for (j = qspSavedVarsGroups[i].VarsCount - 1; j >= 0; --j) { if (!(var = qspVarReference(qspSavedVarsGroups[i].Vars[j].Name, QSP_TRUE))) { while (--ind >= 0) qspEmptyVar(savedVars + ind); free(savedVars); return 0; } qspMoveVar(savedVars + ind, var); qspMoveVar(var, &qspSavedVarsGroups[i].Vars[j]); ++ind; } } *vars = savedVars; return varsCount; }
void qspRestoreLocalVars(QSPVar *savedVars, int varsCount, QSPVarsGroup *savedGroups, int groupsCount) { QSPVar *var; int i, j, ind; if (savedVars) { ind = 0; for (i = groupsCount - 1; i >= 0; --i) { for (j = savedGroups[i].VarsCount - 1; j >= 0; --j) { if (!(var = qspVarReference(savedGroups[i].Vars[j].Name, QSP_TRUE))) { while (ind < varsCount) { qspEmptyVar(savedVars + ind); ++ind; } free(savedVars); return; } qspMoveVar(&savedGroups[i].Vars[j], var); qspMoveVar(var, savedVars + ind); ++ind; } } free(savedVars); } }
void qspClearLocalVars(QSPVar *savedVars, int varsCount) { int i; if (savedVars) { for (i = 0; i < varsCount; ++i) qspEmptyVar(savedVars + i); free(savedVars); } }
void qspClearVarsList(QSPVar *vars, int varsCount) { int i; if (vars) { for (i = 0; i < varsCount; ++i) { free(vars[i].Name); qspEmptyVar(vars + i); } free(vars); } }
void qspPrepareGlobalVars() { int i, j; QSPVar *var; for (i = qspSavedVarsGroupsCount - 1; i >= 0; --i) { for (j = qspSavedVarsGroups[i].VarsCount - 1; j >= 0; --j) { if (!(var = qspVarReference(qspSavedVarsGroups[i].Vars[j].Name, QSP_TRUE))) return; qspEmptyVar(var); qspMoveVar(var, &qspSavedVarsGroups[i].Vars[j]); } } }
QSP_BOOL qspStatementCopyArr(QSPVariant *args, int count, QSP_CHAR **jumpTo, int extArg) { int start, num; QSPVar *dest, *src; if (!(dest = qspVarReferenceWithType(QSP_STR(args[0]), QSP_TRUE, 0))) return QSP_FALSE; if (!(src = qspVarReferenceWithType(QSP_STR(args[1]), QSP_FALSE, 0))) return QSP_FALSE; if (dest != src) { start = (count >= 3 ? QSP_NUM(args[2]) : 0); num = (count == 4 ? QSP_NUM(args[3]) : src->ValsCount); qspEmptyVar(dest); qspCopyVar(dest, src, start, num); } return QSP_FALSE; }
void qspClearVars(QSP_BOOL isFirst) { int i; QSPVar *var = qspVars; for (i = 0; i < QSP_VARSCOUNT; ++i) { if (isFirst) qspInitVarData(var); else { if (var->Name) free(var->Name); qspEmptyVar(var); } var->Name = nullptr; ++var; } }
static void qspRemoveArray(QSP_CHAR *name) { QSPVar *var; if (!(var = qspVarReferenceWithType(name, QSP_FALSE, 0))) return; qspEmptyVar(var); }