Mini Basic: some cosmetic changes

This commit is contained in:
Gregory Nutt 2016-08-11 10:34:32 -06:00
parent 47daad13fa
commit fb3fa286d5

@ -1163,6 +1163,7 @@ static void doinput(void)
break; break;
case STRID: case STRID:
{
if (*lv.sval) if (*lv.sval)
{ {
free(*lv.sval); free(*lv.sval);
@ -1189,10 +1190,11 @@ static void doinput(void)
seterror(ERR_OUTOFMEMORY); seterror(ERR_OUTOFMEMORY);
return; return;
} }
}
break; break;
default: default:
return; break;
} }
} }
@ -1239,6 +1241,7 @@ static void lvalue(FAR struct mb_lvalue_s *lv)
switch (g_token) switch (g_token)
{ {
case FLTID: case FLTID:
{
getid(g_string, name, &len); getid(g_string, name, &len);
match(FLTID); match(FLTID);
var = findvariable(name); var = findvariable(name);
@ -1256,9 +1259,11 @@ static void lvalue(FAR struct mb_lvalue_s *lv)
lv->type = FLTID; lv->type = FLTID;
lv->dval = &var->dval; lv->dval = &var->dval;
lv->sval = 0; lv->sval = 0;
}
break; break;
case STRID: case STRID:
{
getid(g_string, name, &len); getid(g_string, name, &len);
match(STRID); match(STRID);
var = findvariable(name); var = findvariable(name);
@ -1276,10 +1281,12 @@ static void lvalue(FAR struct mb_lvalue_s *lv)
lv->type = STRID; lv->type = STRID;
lv->sval = &var->sval; lv->sval = &var->sval;
lv->dval = 0; lv->dval = 0;
}
break; break;
case DIMFLTID: case DIMFLTID:
case DIMSTRID: case DIMSTRID:
{
type = (g_token == DIMFLTID) ? FLTID : STRID; type = (g_token == DIMFLTID) ? FLTID : STRID;
getid(g_string, name, &len); getid(g_string, name, &len);
match(g_token); match(g_token);
@ -1289,14 +1296,17 @@ static void lvalue(FAR struct mb_lvalue_s *lv)
switch (dimvar->ndims) switch (dimvar->ndims)
{ {
case 1: case 1:
{
index[0] = integer(expr()); index[0] = integer(expr());
if (g_errorflag == 0) if (g_errorflag == 0)
{ {
valptr = getdimvar(dimvar, index[0]); valptr = getdimvar(dimvar, index[0]);
} }
}
break; break;
case 2: case 2:
{
index[0] = integer(expr()); index[0] = integer(expr());
match(COMMA); match(COMMA);
index[1] = integer(expr()); index[1] = integer(expr());
@ -1304,9 +1314,11 @@ static void lvalue(FAR struct mb_lvalue_s *lv)
{ {
valptr = getdimvar(dimvar, index[0], index[1]); valptr = getdimvar(dimvar, index[0], index[1]);
} }
}
break; break;
case 3: case 3:
{
index[0] = integer(expr()); index[0] = integer(expr());
match(COMMA); match(COMMA);
index[1] = integer(expr()); index[1] = integer(expr());
@ -1316,9 +1328,11 @@ static void lvalue(FAR struct mb_lvalue_s *lv)
{ {
valptr = getdimvar(dimvar, index[0], index[1], index[2]); valptr = getdimvar(dimvar, index[0], index[1], index[2]);
} }
}
break; break;
case 4: case 4:
{
index[0] = integer(expr()); index[0] = integer(expr());
match(COMMA); match(COMMA);
index[1] = integer(expr()); index[1] = integer(expr());
@ -1331,9 +1345,11 @@ static void lvalue(FAR struct mb_lvalue_s *lv)
valptr = valptr =
getdimvar(dimvar, index[0], index[1], index[2], index[3]); getdimvar(dimvar, index[0], index[1], index[2], index[3]);
} }
}
break; break;
case 5: case 5:
{
index[0] = integer(expr()); index[0] = integer(expr());
match(COMMA); match(COMMA);
index[1] = integer(expr()); index[1] = integer(expr());
@ -1348,6 +1364,7 @@ static void lvalue(FAR struct mb_lvalue_s *lv)
valptr = valptr =
getdimvar(dimvar, index[0], index[1], index[2], index[3]); getdimvar(dimvar, index[0], index[1], index[2], index[3]);
} }
}
break; break;
} }
@ -1375,6 +1392,7 @@ static void lvalue(FAR struct mb_lvalue_s *lv)
assert(0); assert(0);
} }
} }
}
break; break;
default: default:
@ -1455,9 +1473,15 @@ static int boolfactor(void)
if (!strleft || !strright) if (!strleft || !strright)
{ {
if (strleft) if (strleft)
{
free(strleft); free(strleft);
}
if (strright) if (strright)
{
free(strright); free(strright);
}
return 0; return 0;
} }
cmp = strcmp(strleft, strright); cmp = strcmp(strleft, strright);