fix regression

This commit is contained in:
gemu2015 2021-02-03 07:06:57 +01:00
parent 1a07fc7deb
commit d47e4354a5

View File

@ -1597,6 +1597,7 @@ char *isvar(char *lp, uint8_t *vtype, struct T_INDEX *tind, float *fp, char *sp,
if (gv && gv->jo) { if (gv && gv->jo) {
// look for json input // look for json input
JsonParserObject *jpo = gv->jo;
char jvname[64]; char jvname[64];
strcpy(jvname, vname); strcpy(jvname, vname);
const char* str_value; const char* str_value;
@ -1609,12 +1610,12 @@ char *isvar(char *lp, uint8_t *vtype, struct T_INDEX *tind, float *fp, char *sp,
ja++; ja++;
// fetch array index // fetch array index
float fvar; float fvar;
GetNumericArgument(ja, OPER_EQU, &fvar, gv); GetNumericArgument(ja, OPER_EQU, &fvar, 0);
aindex = fvar; aindex = fvar;
if (aindex<1 || aindex>6) aindex = 1; if (aindex<1 || aindex>6) aindex = 1;
aindex--; aindex--;
} }
if (gv->jo->isValid()) { if (jpo->isValid()) {
char *subtype = strchr(jvname, '#'); char *subtype = strchr(jvname, '#');
char *subtype2; char *subtype2;
if (subtype) { if (subtype) {
@ -1627,23 +1628,23 @@ char *isvar(char *lp, uint8_t *vtype, struct T_INDEX *tind, float *fp, char *sp,
} }
} }
vn = jvname; vn = jvname;
str_value = (*gv->jo)[vn].getStr(); str_value = (*jpo)[vn].getStr();
if ((*gv->jo)[vn].isValid()) { if ((*jpo)[vn].isValid()) {
if (subtype) { if (subtype) {
JsonParserObject jobj1 = (*gv->jo)[vn]; JsonParserObject jobj1 = (*jpo)[vn];
if (jobj1.isValid()) { if (jobj1.isValid()) {
vn = subtype; vn = subtype;
gv->jo = &jobj1; jpo = &jobj1;
str_value = (*gv->jo)[vn].getStr(); str_value = (*jpo)[vn].getStr();
if ((*gv->jo)[vn].isValid()) { if ((*jpo)[vn].isValid()) {
// 2. stage // 2. stage
if (subtype2) { if (subtype2) {
JsonParserObject jobj2 = (*gv->jo)[vn]; JsonParserObject jobj2 = (*jpo)[vn];
if ((*gv->jo)[vn].isValid()) { if ((*jpo)[vn].isValid()) {
vn = subtype2; vn = subtype2;
gv->jo = &jobj2; jpo = &jobj2;
str_value = (*gv->jo)[vn].getStr(); str_value = (*jpo)[vn].getStr();
if ((*gv->jo)[vn].isValid()) { if ((*jpo)[vn].isValid()) {
goto skip; goto skip;
} else { } else {
goto chknext; goto chknext;
@ -1662,10 +1663,10 @@ char *isvar(char *lp, uint8_t *vtype, struct T_INDEX *tind, float *fp, char *sp,
skip: skip:
if (ja) { if (ja) {
// json array // json array
str_value = (*gv->jo)[vn].getArray()[aindex].getStr(); str_value = (*jpo)[vn].getArray()[aindex].getStr();
} }
if (str_value && *str_value) { if (str_value && *str_value) {
if ((*gv->jo)[vn].isStr()) { if ((*jpo)[vn].isStr()) {
if (!strncmp(str_value, "ON", 2)) { if (!strncmp(str_value, "ON", 2)) {
if (fp) *fp = 1; if (fp) *fp = 1;
goto nexit; goto nexit;
@ -1782,7 +1783,7 @@ chknext:
// var changed // var changed
struct T_INDEX ind; struct T_INDEX ind;
uint8_t vtype; uint8_t vtype;
isvar(vname + 4, &vtype, &ind, 0, 0, 0); isvar(vname + 4, &vtype, &ind, 0, 0, gv);
if (!ind.bits.constant) { if (!ind.bits.constant) {
uint8_t index = glob_script_mem.type[ind.index].index; uint8_t index = glob_script_mem.type[ind.index].index;
if (glob_script_mem.fvars[index] != glob_script_mem.s_fvars[index]) { if (glob_script_mem.fvars[index] != glob_script_mem.s_fvars[index]) {
@ -2024,7 +2025,7 @@ chknext:
struct T_INDEX ind; struct T_INDEX ind;
uint8_t vtype; uint8_t vtype;
uint8_t sindex = 0; uint8_t sindex = 0;
lp = isvar(lp + 3, &vtype, &ind, 0, 0, 0); lp = isvar(lp + 3, &vtype, &ind, 0, 0, gv);
if (vtype!=VAR_NV) { if (vtype!=VAR_NV) {
// found variable as result // found variable as result
if ((vtype&STYPE)==0) { if ((vtype&STYPE)==0) {
@ -2189,7 +2190,7 @@ chknext:
if (!strncmp(vname, "fwa(", 4)) { if (!strncmp(vname, "fwa(", 4)) {
struct T_INDEX ind; struct T_INDEX ind;
uint8_t vtype; uint8_t vtype;
lp = isvar(lp + 4, &vtype, &ind, 0, 0, 0); lp = isvar(lp + 4, &vtype, &ind, 0, 0, gv);
if (vtype!=VAR_NV && (vtype&STYPE)==0 && glob_script_mem.type[ind.index].bits.is_filter) { if (vtype!=VAR_NV && (vtype&STYPE)==0 && glob_script_mem.type[ind.index].bits.is_filter) {
// found array as result // found array as result
@ -2228,7 +2229,7 @@ chknext:
if (!strncmp(vname, "fra(", 4)) { if (!strncmp(vname, "fra(", 4)) {
struct T_INDEX ind; struct T_INDEX ind;
uint8_t vtype; uint8_t vtype;
lp = isvar(lp + 4, &vtype, &ind, 0, 0, 0); lp = isvar(lp + 4, &vtype, &ind, 0, 0, gv);
if (vtype!=VAR_NV && (vtype&STYPE)==0 && glob_script_mem.type[ind.index].bits.is_filter) { if (vtype!=VAR_NV && (vtype&STYPE)==0 && glob_script_mem.type[ind.index].bits.is_filter) {
// found array as result // found array as result
@ -3103,7 +3104,7 @@ chknext:
// var was updated // var was updated
struct T_INDEX ind; struct T_INDEX ind;
uint8_t vtype; uint8_t vtype;
isvar(vname + 4, &vtype, &ind, 0, 0, 0); isvar(vname + 4, &vtype, &ind, 0, 0, gv);
if (!ind.bits.constant) { if (!ind.bits.constant) {
if (!ind.bits.changed) { if (!ind.bits.changed) {
fvar = 0; fvar = 0;
@ -4040,7 +4041,7 @@ int16_t Run_script_sub(const char *type, int8_t tlen, struct GVARS *gv) {
lp += 3; lp += 3;
SCRIPT_SKIP_SPACES SCRIPT_SKIP_SPACES
lp_next = 0; lp_next = 0;
lp = isvar(lp, &vtype, &ind, 0, 0, 0); lp = isvar(lp, &vtype, &ind, 0, 0, gv);
if ((vtype!=VAR_NV) && (vtype&STYPE)==0) { if ((vtype!=VAR_NV) && (vtype&STYPE)==0) {
// numeric var // numeric var
uint8_t index = glob_script_mem.type[ind.index].index; uint8_t index = glob_script_mem.type[ind.index].index;
@ -4099,7 +4100,7 @@ int16_t Run_script_sub(const char *type, int8_t tlen, struct GVARS *gv) {
// was string, not number // was string, not number
lp = slp; lp = slp;
// get the string // get the string
lp = isvar(lp, &vtype, &ind, 0, cmpstr, 0); lp = isvar(lp, &vtype, &ind, 0, cmpstr, gv);
swflg = 0x81; swflg = 0x81;
} else { } else {
swflg = 1; swflg = 1;
@ -4240,7 +4241,7 @@ int16_t Run_script_sub(const char *type, int8_t tlen, struct GVARS *gv) {
#ifdef USE_LIGHT #ifdef USE_LIGHT
#ifdef USE_WS2812 #ifdef USE_WS2812
else if (!strncmp(lp, "ws2812(", 7)) { else if (!strncmp(lp, "ws2812(", 7)) {
lp = isvar(lp + 7, &vtype, &ind, 0, 0, 0); lp = isvar(lp + 7, &vtype, &ind, 0, 0, gv);
if (vtype!=VAR_NV) { if (vtype!=VAR_NV) {
SCRIPT_SKIP_SPACES SCRIPT_SKIP_SPACES
if (*lp!=')') { if (*lp!=')') {
@ -4604,7 +4605,7 @@ int16_t Run_script_sub(const char *type, int8_t tlen, struct GVARS *gv) {
if (*lp==nxttok) { if (*lp==nxttok) {
// fetch destination // fetch destination
lp++; lp++;
lp = isvar(lp, &vtype, &ind, 0, 0, 0); lp = isvar(lp, &vtype, &ind, 0, 0, gv);
if (vtype!=VAR_NV) { if (vtype!=VAR_NV) {
// found variable as result // found variable as result
uint8_t index = glob_script_mem.type[ind.index].index; uint8_t index = glob_script_mem.type[ind.index].index;