Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
5720d72b71
commit
8fd8aad5c4
@ -13,8 +13,8 @@
|
|||||||
* The above copyright notice and this permission notice shall be included in
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
@ -182,7 +182,8 @@ static int cat(const char *filename)
|
|||||||
|
|
||||||
while ((l = read(fd, buf, sizeof(buf))) > 0)
|
while ((l = read(fd, buf, sizeof(buf))) > 0)
|
||||||
{
|
{
|
||||||
ssize_t off, w;
|
ssize_t off;
|
||||||
|
ssize_t w;
|
||||||
|
|
||||||
off = 0;
|
off = 0;
|
||||||
while (off < l)
|
while (off < l)
|
||||||
@ -217,13 +218,14 @@ static struct Value *lvalue(struct Value *value)
|
|||||||
struct Pc lvpc = g_pc;
|
struct Pc lvpc = g_pc;
|
||||||
|
|
||||||
sym = g_pc.token->u.identifier->sym;
|
sym = g_pc.token->u.identifier->sym;
|
||||||
assert(g_pass == DECLARE || sym->type == GLOBALVAR || sym->type == GLOBALARRAY
|
assert(g_pass == DECLARE || sym->type == GLOBALVAR
|
||||||
|| sym->type == LOCALVAR);
|
|| sym->type == GLOBALARRAY || sym->type == LOCALVAR);
|
||||||
|
|
||||||
if ((g_pc.token + 1)->type == T_OP)
|
if ((g_pc.token + 1)->type == T_OP)
|
||||||
{
|
{
|
||||||
struct Pc idxpc;
|
struct Pc idxpc;
|
||||||
unsigned int dim, capacity;
|
unsigned int dim;
|
||||||
|
unsigned int capacity;
|
||||||
int *idx;
|
int *idx;
|
||||||
|
|
||||||
g_pc.token += 2;
|
g_pc.token += 2;
|
||||||
@ -328,10 +330,8 @@ static struct Value *lvalue(struct Value *value)
|
|||||||
switch (g_pass)
|
switch (g_pass)
|
||||||
{
|
{
|
||||||
case INTERPRET:
|
case INTERPRET:
|
||||||
return VAR_SCALAR_VALUE(sym->type ==
|
return VAR_SCALAR_VALUE(sym->type == GLOBALVAR ? &(sym->u.var) :
|
||||||
GLOBALVAR ? &(sym->u.var) : Auto_local(&g_stack,
|
Auto_local(&g_stack, sym->u.local.offset));
|
||||||
sym->
|
|
||||||
u.local.offset));
|
|
||||||
|
|
||||||
case DECLARE:
|
case DECLARE:
|
||||||
return Value_nullValue(V_INTEGER);
|
return Value_nullValue(V_INTEGER);
|
||||||
@ -353,7 +353,7 @@ static struct Value *func(struct Value *value)
|
|||||||
{
|
{
|
||||||
struct Identifier *ident;
|
struct Identifier *ident;
|
||||||
struct Pc funcpc = g_pc;
|
struct Pc funcpc = g_pc;
|
||||||
int firstslot = -99;
|
long int firstslot = -99;
|
||||||
int args = 0;
|
int args = 0;
|
||||||
struct Symbol *sym;
|
struct Symbol *sym;
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ static struct Value *func(struct Value *value)
|
|||||||
ident->sym->u.sub.retType != V_VOID)
|
ident->sym->u.sub.retType != V_VOID)
|
||||||
{
|
{
|
||||||
struct Var *v = Auto_pushArg(&g_stack);
|
struct Var *v = Auto_pushArg(&g_stack);
|
||||||
Var_new(v, ident->sym->u.sub.retType, 0, (const unsigned int *)0, 0);
|
Var_new(v, ident->sym->u.sub.retType, 0, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +418,10 @@ static struct Value *func(struct Value *value)
|
|||||||
Value_clone(value, v->value);
|
Value_clone(value, v->value);
|
||||||
while (g_stack.stackPointer > firstslot)
|
while (g_stack.stackPointer > firstslot)
|
||||||
{
|
{
|
||||||
Var_destroy(&g_stack.slot[--g_stack.stackPointer].var);
|
long int stackPointer;
|
||||||
|
|
||||||
|
stackPointer = --g_stack.stackPointer;
|
||||||
|
Var_destroy(&g_stack.slot[stackPointer].var);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
@ -444,7 +447,10 @@ static struct Value *func(struct Value *value)
|
|||||||
{
|
{
|
||||||
while (g_stack.stackPointer > firstslot)
|
while (g_stack.stackPointer > firstslot)
|
||||||
{
|
{
|
||||||
Var_destroy(&g_stack.slot[--g_stack.stackPointer].var);
|
long int stackPointer;
|
||||||
|
|
||||||
|
stackPointer = --g_stack.stackPointer;
|
||||||
|
Var_destroy(&g_stack.slot[stackPointer].var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +490,8 @@ static struct Value *func(struct Value *value)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
nomore = (g_pass == COMPILE &&
|
nomore = (g_pass == COMPILE &&
|
||||||
!(sym->type == BUILTINFUNCTION && sym->u.sub.u.bltin.next));
|
!(sym->type == BUILTINFUNCTION &&
|
||||||
|
sym->u.sub.u.bltin.next));
|
||||||
argerr = 0;
|
argerr = 0;
|
||||||
if (args < sym->u.sub.argLength)
|
if (args < sym->u.sub.argLength)
|
||||||
{
|
{
|
||||||
@ -595,8 +602,8 @@ static struct Value *func(struct Value *value)
|
|||||||
if (strchr(value->u.error.msg, '\n') == (char *)0)
|
if (strchr(value->u.error.msg, '\n') == (char *)0)
|
||||||
{
|
{
|
||||||
Auto_setError(&g_stack,
|
Auto_setError(&g_stack,
|
||||||
Program_lineNumber(&g_program, &g_pc), &g_pc,
|
Program_lineNumber(&g_program, &g_pc),
|
||||||
value);
|
&g_pc, value);
|
||||||
Program_PCtoError(&g_program, &g_pc, value);
|
Program_PCtoError(&g_program, &g_pc, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,7 +625,8 @@ static struct Value *func(struct Value *value)
|
|||||||
|
|
||||||
Value_destroy(value);
|
Value_destroy(value);
|
||||||
}
|
}
|
||||||
while ((r = Program_skipEOL(&g_program, &g_pc, STDCHANNEL, 1)));
|
while ((r = Program_skipEOL(&g_program, &g_pc,
|
||||||
|
STDCHANNEL, 1)));
|
||||||
|
|
||||||
if (!r)
|
if (!r)
|
||||||
{
|
{
|
||||||
@ -687,7 +695,8 @@ static struct Value *func(struct Value *value)
|
|||||||
*
|
*
|
||||||
* i6:
|
* i6:
|
||||||
* E -> op E . reduce 3
|
* E -> op E . reduce 3
|
||||||
* E -> E . op E op* shift 1 *=if stack[-2] contains op of unary lower priority
|
* E -> E . op E op* shift 1 *=if stack[-2] contains op of unary
|
||||||
|
* lower priority
|
||||||
*
|
*
|
||||||
* i7:
|
* i7:
|
||||||
* E -> ( E . ) ) shift 9
|
* E -> ( E . ) ) shift 9
|
||||||
@ -695,8 +704,9 @@ static struct Value *func(struct Value *value)
|
|||||||
*
|
*
|
||||||
* i8:
|
* i8:
|
||||||
* E -> E op E . reduce 2
|
* E -> E op E . reduce 2
|
||||||
* E -> E . op E op* shift 1 *=if stack[-2] contains op of lower priority or if
|
* E -> E . op E op* shift 1 *=if stack[-2] contains op of lower
|
||||||
* if it is of equal priority and right associative
|
* priority or if it is of equal
|
||||||
|
* priority and right associative
|
||||||
* i9:
|
* i9:
|
||||||
* E -> ( E ) . reduce 4
|
* E -> ( E ) . reduce 4
|
||||||
*/
|
*/
|
||||||
@ -705,7 +715,11 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
{
|
{
|
||||||
/* Variables */
|
/* Variables */
|
||||||
|
|
||||||
static const int gotoState[10] = { 5, 8, 6, 7, -1, -1, -1, -1, -1, -1 };
|
static const int gotoState[10] =
|
||||||
|
{
|
||||||
|
5, 8, 6, 7, -1, -1, -1, -1, -1, -1
|
||||||
|
};
|
||||||
|
|
||||||
int capacity = 10;
|
int capacity = 10;
|
||||||
struct Pdastack
|
struct Pdastack
|
||||||
{
|
{
|
||||||
@ -716,6 +730,7 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
} u;
|
} u;
|
||||||
char state;
|
char state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Pdastack *pdastack = malloc(capacity * sizeof(struct Pdastack));
|
struct Pdastack *pdastack = malloc(capacity * sizeof(struct Pdastack));
|
||||||
struct Pdastack *sp = pdastack;
|
struct Pdastack *sp = pdastack;
|
||||||
struct Pdastack *stackEnd = pdastack + capacity - 1;
|
struct Pdastack *stackEnd = pdastack + capacity - 1;
|
||||||
@ -743,17 +758,18 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
{
|
{
|
||||||
if (ip == T_IDENTIFIER)
|
if (ip == T_IDENTIFIER)
|
||||||
{
|
{
|
||||||
/* printf("state %d: shift 4\n",sp->state); */
|
/* printf("state %d: shift 4\n",sp->state);
|
||||||
/* printf("state 4: reduce E -> value\n"); */
|
* printf("state 4: reduce E -> value\n");
|
||||||
|
*/
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
sp->state = gotoState[(sp - 1)->state];
|
sp->state = gotoState[(sp - 1)->state];
|
||||||
if (g_pass == COMPILE)
|
if (g_pass == COMPILE)
|
||||||
{
|
{
|
||||||
if (((g_pc.token + 1)->type == T_OP ||
|
if (((g_pc.token + 1)->type == T_OP ||
|
||||||
Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
|
Auto_find(&g_stack, g_pc.token->u.identifier) == 0)
|
||||||
Global_find(&g_globals, g_pc.token->u.identifier,
|
&& Global_find(&g_globals, g_pc.token->u.identifier,
|
||||||
(g_pc.token + 1)->type == T_OP) == 0)
|
(g_pc.token + 1)->type == T_OP) == 0)
|
||||||
{
|
{
|
||||||
Value_new_ERROR(value, UNDECLARED);
|
Value_new_ERROR(value, UNDECLARED);
|
||||||
goto error;
|
goto error;
|
||||||
@ -786,8 +802,9 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
}
|
}
|
||||||
else if (ip == T_INTEGER)
|
else if (ip == T_INTEGER)
|
||||||
{
|
{
|
||||||
/* printf("state %d: shift 4\n",sp->state); */
|
/* printf("state %d: shift 4\n",sp->state);
|
||||||
/* printf("state 4: reduce E -> value\n"); */
|
* printf("state 4: reduce E -> value\n");
|
||||||
|
*/
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
sp->state = gotoState[(sp - 1)->state];
|
sp->state = gotoState[(sp - 1)->state];
|
||||||
@ -796,8 +813,9 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
}
|
}
|
||||||
else if (ip == T_REAL)
|
else if (ip == T_REAL)
|
||||||
{
|
{
|
||||||
/* printf("state %d: shift 4\n",sp->state); */
|
/* printf("state %d: shift 4\n",sp->state);
|
||||||
/* printf("state 4: reduce E -> value\n"); */
|
* printf("state 4: reduce E -> value\n");
|
||||||
|
*/
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
sp->state = gotoState[(sp - 1)->state];
|
sp->state = gotoState[(sp - 1)->state];
|
||||||
@ -815,8 +833,9 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
}
|
}
|
||||||
else if (ip == T_HEXINTEGER)
|
else if (ip == T_HEXINTEGER)
|
||||||
{
|
{
|
||||||
/* printf("state %d: shift 4\n",sp->state); */
|
/* printf("state %d: shift 4\n",sp->state);
|
||||||
/* printf("state 4: reduce E -> value\n"); */
|
* printf("state 4: reduce E -> value\n");
|
||||||
|
*/
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
sp->state = gotoState[(sp - 1)->state];
|
sp->state = gotoState[(sp - 1)->state];
|
||||||
@ -825,8 +844,9 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
}
|
}
|
||||||
else if (ip == T_OCTINTEGER)
|
else if (ip == T_OCTINTEGER)
|
||||||
{
|
{
|
||||||
/* printf("state %d: shift 4\n",sp->state); */
|
/* printf("state %d: shift 4\n",sp->state);
|
||||||
/* printf("state 4: reduce E -> value\n"); */
|
* printf("state 4: reduce E -> value\n");
|
||||||
|
*/
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
sp->state = gotoState[(sp - 1)->state];
|
sp->state = gotoState[(sp - 1)->state];
|
||||||
@ -844,8 +864,9 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
}
|
}
|
||||||
else if (ip == T_STRING)
|
else if (ip == T_STRING)
|
||||||
{
|
{
|
||||||
/* printf("state %d: shift 4\n",sp->state); */
|
/* printf("state %d: shift 4\n",sp->state);
|
||||||
/* printf("state 4: reduce E -> value\n"); */
|
* printf("state 4: reduce E -> value\n");
|
||||||
|
*/
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
sp->state = gotoState[(sp - 1)->state];
|
sp->state = gotoState[(sp - 1)->state];
|
||||||
@ -911,7 +932,9 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
{
|
{
|
||||||
assert(TOKEN_ISUNARYOPERATOR((sp - 1)->u.token));
|
assert(TOKEN_ISUNARYOPERATOR((sp - 1)->u.token));
|
||||||
|
|
||||||
/* printf("state %d: shift 1 (not reducing E -> op E)\n", sp->state); */
|
/* printf("state %d: shift 1 (not reducing E -> op E)\n",
|
||||||
|
* sp->state);
|
||||||
|
*/
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
sp->state = 1;
|
sp->state = 1;
|
||||||
@ -969,8 +992,9 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
}
|
}
|
||||||
else if (ip == T_CP)
|
else if (ip == T_CP)
|
||||||
{
|
{
|
||||||
/* printf("state %d: shift 9\n",sp->state); */
|
/* printf("state %d: shift 9\n",sp->state);
|
||||||
/* printf("state 9: reduce E -> ( E )\n"); */
|
* printf("state 9: reduce E -> ( E )\n");
|
||||||
|
*/
|
||||||
|
|
||||||
--sp;
|
--sp;
|
||||||
sp->state = gotoState[(sp - 1)->state];
|
sp->state = gotoState[(sp - 1)->state];
|
||||||
@ -990,11 +1014,9 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
{
|
{
|
||||||
int p1, p2;
|
int p1, p2;
|
||||||
|
|
||||||
if (TOKEN_ISBINARYOPERATOR(ip)
|
if (TOKEN_ISBINARYOPERATOR(ip) &&
|
||||||
&&
|
(((p1 = TOKEN_BINARYPRIORITY((sp - 1)->u.token)) <
|
||||||
(((p1 = TOKEN_BINARYPRIORITY((sp - 1)->u.token)) < (p2 =
|
(p2 = TOKEN_BINARYPRIORITY(ip))) ||
|
||||||
TOKEN_BINARYPRIORITY
|
|
||||||
(ip))) ||
|
|
||||||
(p1 == p2 && TOKEN_ISRIGHTASSOCIATIVE((sp - 1)->u.token))))
|
(p1 == p2 && TOKEN_ISRIGHTASSOCIATIVE((sp - 1)->u.token))))
|
||||||
{
|
{
|
||||||
/* printf("state %d: shift 1\n",sp->state); */
|
/* printf("state %d: shift 1\n",sp->state); */
|
||||||
@ -1008,8 +1030,8 @@ static struct Value *eval(struct Value *value, const char *desc)
|
|||||||
{
|
{
|
||||||
/* printf("state %d: reduce E -> E op E\n",sp->state); */
|
/* printf("state %d: reduce E -> E op E\n",sp->state); */
|
||||||
|
|
||||||
if (Value_commonType[(sp - 2)->u.value.type][sp->u.value.type]
|
if (Value_commonType[(sp - 2)->u.value.type]
|
||||||
== V_ERROR)
|
[sp->u.value.type] == V_ERROR)
|
||||||
{
|
{
|
||||||
Value_destroy(&sp->u.value);
|
Value_destroy(&sp->u.value);
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
@ -1143,6 +1165,7 @@ error:
|
|||||||
case 8:
|
case 8:
|
||||||
Value_destroy(&sp->u.value);
|
Value_destroy(&sp->u.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
--sp;
|
--sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1551,7 +1574,7 @@ static void pushLabel(enum labeltype_e type, struct Pc *patch)
|
|||||||
more =
|
more =
|
||||||
realloc(g_labelstack,
|
realloc(g_labelstack,
|
||||||
sizeof(struct labelstack_s) *
|
sizeof(struct labelstack_s) *
|
||||||
(g_labelstack_capacity ? (g_labelstack_capacity *= 2) : (32)));
|
(g_labelstack_capacity ? g_labelstack_capacity *= 2 : 32));
|
||||||
g_labelstack = more;
|
g_labelstack = more;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1562,7 +1585,8 @@ static void pushLabel(enum labeltype_e type, struct Pc *patch)
|
|||||||
|
|
||||||
static struct Pc *popLabel(enum labeltype_e type)
|
static struct Pc *popLabel(enum labeltype_e type)
|
||||||
{
|
{
|
||||||
if (g_labelstack_index == 0 || g_labelstack[g_labelstack_index - 1].type != type)
|
if (g_labelstack_index == 0 ||
|
||||||
|
g_labelstack[g_labelstack_index - 1].type != type)
|
||||||
{
|
{
|
||||||
return (struct Pc *)0;
|
return (struct Pc *)0;
|
||||||
}
|
}
|
||||||
@ -1801,7 +1825,7 @@ static struct Value *assign(struct Value *value)
|
|||||||
int i, used = 0, capacity = 0;
|
int i, used = 0, capacity = 0;
|
||||||
struct Value retyped_value;
|
struct Value retyped_value;
|
||||||
|
|
||||||
for (;;)
|
for (; ; )
|
||||||
{
|
{
|
||||||
if (used == capacity)
|
if (used == capacity)
|
||||||
{
|
{
|
||||||
@ -2008,7 +2032,8 @@ static void runline(struct Token *line)
|
|||||||
{
|
{
|
||||||
struct String s;
|
struct String s;
|
||||||
|
|
||||||
Auto_setError(&g_stack, Program_lineNumber(&g_program, &g_pc), &g_pc, &value);
|
Auto_setError(&g_stack, Program_lineNumber(&g_program, &g_pc),
|
||||||
|
&g_pc, &value);
|
||||||
Program_PCtoError(&g_program, &g_pc, &value);
|
Program_PCtoError(&g_program, &g_pc, &value);
|
||||||
g_labelstack_index = 0;
|
g_labelstack_index = 0;
|
||||||
FS_putChars(STDCHANNEL, _("Error: "));
|
FS_putChars(STDCHANNEL, _("Error: "));
|
||||||
@ -2044,8 +2069,8 @@ static void runline(struct Token *line)
|
|||||||
{
|
{
|
||||||
if (strchr(value.u.error.msg, '\n') == (char *)0)
|
if (strchr(value.u.error.msg, '\n') == (char *)0)
|
||||||
{
|
{
|
||||||
Auto_setError(&g_stack, Program_lineNumber(&g_program, &g_pc), &g_pc,
|
Auto_setError(&g_stack, Program_lineNumber(&g_program, &g_pc),
|
||||||
&value);
|
&g_pc, &value);
|
||||||
Program_PCtoError(&g_program, &g_pc, &value);
|
Program_PCtoError(&g_program, &g_pc, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2105,8 +2130,8 @@ static struct Value *evalGeometry(struct Value *value, unsigned int *dim,
|
|||||||
{
|
{
|
||||||
++g_pc.token;
|
++g_pc.token;
|
||||||
exprpc = g_pc;
|
exprpc = g_pc;
|
||||||
if (eval(value, _("dimension"))->type == V_ERROR ||
|
if (eval(value, _("dimension"))->type == V_ERROR || (g_pass != DECLARE
|
||||||
(g_pass != DECLARE && Value_retype(value, V_INTEGER)->type == V_ERROR))
|
&& Value_retype(value, V_INTEGER)->type == V_ERROR))
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -2158,7 +2183,8 @@ static struct Value *convert(struct Value *value, struct Value *l,
|
|||||||
|
|
||||||
datainput = t->u.datainput;
|
datainput = t->u.datainput;
|
||||||
v = Value_vali(datainput, &end, &overflow);
|
v = Value_vali(datainput, &end, &overflow);
|
||||||
if (end == datainput || (*end != '\0' && *end != ' ' && *end != '\t'))
|
if (end == datainput ||
|
||||||
|
(*end != '\0' && *end != ' ' && *end != '\t'))
|
||||||
{
|
{
|
||||||
return Value_new_ERROR(value, BADCONVERSION, _("integer"));
|
return Value_new_ERROR(value, BADCONVERSION, _("integer"));
|
||||||
}
|
}
|
||||||
@ -2187,7 +2213,8 @@ static struct Value *convert(struct Value *value, struct Value *l,
|
|||||||
|
|
||||||
datainput = t->u.datainput;
|
datainput = t->u.datainput;
|
||||||
v = Value_vald(datainput, &end, &overflow);
|
v = Value_vald(datainput, &end, &overflow);
|
||||||
if (end == datainput || (*end != '\0' && *end != ' ' && *end != '\t'))
|
if (end == datainput ||
|
||||||
|
(*end != '\0' && *end != ' ' && *end != '\t'))
|
||||||
{
|
{
|
||||||
return Value_new_ERROR(value, BADCONVERSION, _("real"));
|
return Value_new_ERROR(value, BADCONVERSION, _("real"));
|
||||||
}
|
}
|
||||||
@ -2201,6 +2228,7 @@ static struct Value *convert(struct Value *value, struct Value *l,
|
|||||||
VALUE_NEW_REAL(l, v);
|
VALUE_NEW_REAL(l, v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case V_STRING:
|
case V_STRING:
|
||||||
{
|
{
|
||||||
Value_destroy(l);
|
Value_destroy(l);
|
||||||
@ -2285,14 +2313,14 @@ more:
|
|||||||
{
|
{
|
||||||
++g_pc.token;
|
++g_pc.token;
|
||||||
}
|
}
|
||||||
else if ((g_pc.token->type == T_COLON && (g_pc.token + 1)->type != T_ELSE) ||
|
else if ((g_pc.token->type == T_COLON && (g_pc.token + 1)->type != T_ELSE)
|
||||||
g_pc.token->type == T_QUOTE)
|
|| g_pc.token->type == T_QUOTE)
|
||||||
{
|
{
|
||||||
++g_pc.token;
|
++g_pc.token;
|
||||||
goto more;
|
goto more;
|
||||||
}
|
}
|
||||||
else if ((g_pass == DECLARE || g_pass == COMPILE) && g_pc.token->type != T_EOL &&
|
else if ((g_pass == DECLARE || g_pass == COMPILE) &&
|
||||||
g_pc.token->type != T_ELSE)
|
g_pc.token->type != T_EOL && g_pc.token->type != T_ELSE)
|
||||||
{
|
{
|
||||||
return Value_new_ERROR(value, MISSINGCOLON);
|
return Value_new_ERROR(value, MISSINGCOLON);
|
||||||
}
|
}
|
||||||
@ -2419,8 +2447,8 @@ void bas_interpreter(void)
|
|||||||
{
|
{
|
||||||
struct Pc where;
|
struct Pc where;
|
||||||
|
|
||||||
if (Program_goLine(&g_program, line->u.integer, &where) ==
|
if (Program_goLine(&g_program, line->u.integer, &where)
|
||||||
(struct Pc *)0)
|
== (struct Pc *)0)
|
||||||
{
|
{
|
||||||
FS_putChars(STDCHANNEL, _("No such line\n"));
|
FS_putChars(STDCHANNEL, _("No such line\n"));
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
* The above copyright notice and this permission notice shall be included in
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
@ -100,8 +100,11 @@
|
|||||||
static struct FileStream **g_file;
|
static struct FileStream **g_file;
|
||||||
static int g_capacity;
|
static int g_capacity;
|
||||||
static int g_used;
|
static int g_used;
|
||||||
static const int g_open_mode[4] = { 0, O_RDONLY, O_WRONLY, O_RDWR };
|
|
||||||
static char g_errmsgbuf[80];
|
static char g_errmsgbuf[80];
|
||||||
|
static const int g_open_mode[4] =
|
||||||
|
{
|
||||||
|
0, O_RDONLY, O_WRONLY, O_RDWR
|
||||||
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
@ -205,7 +208,8 @@ static int opened(int dev, int mode)
|
|||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
fd = (g_file[dev]->randomfd != -1 ? g_file[dev]->randomfd : g_file[dev]->binaryfd);
|
fd = (g_file[dev]->randomfd != -1 ?
|
||||||
|
g_file[dev]->randomfd : g_file[dev]->binaryfd);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
snprintf(g_errmsgbuf, sizeof(g_errmsgbuf),
|
snprintf(g_errmsgbuf, sizeof(g_errmsgbuf),
|
||||||
@ -270,6 +274,7 @@ static int edit(int chn, int nl)
|
|||||||
FS_putChar(chn, *buf);
|
FS_putChar(chn, *buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
FS_flush(chn);
|
FS_flush(chn);
|
||||||
@ -301,7 +306,7 @@ static int edit(int chn, int nl)
|
|||||||
#ifdef CONFIG_INTERPRETER_BAS_VT100
|
#ifdef CONFIG_INTERPRETER_BAS_VT100
|
||||||
/* Could use vt100_clrtoeol */
|
/* Could use vt100_clrtoeol */
|
||||||
#endif
|
#endif
|
||||||
/* Is the previous character in the buffer 2 character escape sequence? */
|
/* Is the previous char in buffer 2 char escape sequence? */
|
||||||
|
|
||||||
if (f->inBuf[f->inCapacity - 1] >= '\0' &&
|
if (f->inBuf[f->inCapacity - 1] >= '\0' &&
|
||||||
f->inBuf[f->inCapacity - 1] < ' ')
|
f->inBuf[f->inCapacity - 1] < ' ')
|
||||||
@ -311,7 +316,7 @@ static int edit(int chn, int nl)
|
|||||||
FS_putChars(chn, "\b\b \b\b");
|
FS_putChars(chn, "\b\b \b\b");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Yes.. erase one characters */
|
/* Yes.. erase one characters */
|
||||||
|
|
||||||
FS_putChars(chn, "\b \b");
|
FS_putChars(chn, "\b \b");
|
||||||
@ -335,7 +340,7 @@ static int edit(int chn, int nl)
|
|||||||
#elif defined(CONFIG_EOL_IS_LF)
|
#elif defined(CONFIG_EOL_IS_LF)
|
||||||
if (ch != '\n')
|
if (ch != '\n')
|
||||||
#elif defined(CONFIG_EOL_IS_EITHER_CRLF)
|
#elif defined(CONFIG_EOL_IS_EITHER_CRLF)
|
||||||
if (ch != '\n' && ch != '\r' )
|
if (ch != '\n' && ch != '\r')
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* No.. escape control characters other than newline and
|
/* No.. escape control characters other than newline and
|
||||||
@ -540,7 +545,8 @@ int FS_openinChn(int chn, const char *name, int mode)
|
|||||||
|
|
||||||
/* Serial devices on Linux should be opened non-blocking, otherwise the
|
/* Serial devices on Linux should be opened non-blocking, otherwise the
|
||||||
* open() may block already. Named pipes can not be opened non-blocking in
|
* open() may block already. Named pipes can not be opened non-blocking in
|
||||||
* write-only mode, so first try non-blocking, then blocking. */
|
* write-only mode, so first try non-blocking, then blocking.
|
||||||
|
*/
|
||||||
|
|
||||||
if ((fd = open(name, fl | O_NONBLOCK)) == -1)
|
if ((fd = open(name, fl | O_NONBLOCK)) == -1)
|
||||||
{
|
{
|
||||||
@ -631,15 +637,16 @@ int FS_openoutChn(int chn, const char *name, int mode, int append)
|
|||||||
|
|
||||||
fl = g_open_mode[mode] | (append ? O_APPEND : 0);
|
fl = g_open_mode[mode] | (append ? O_APPEND : 0);
|
||||||
|
|
||||||
/* Serial devices on Linux should be opened non-blocking, otherwise the */
|
/* Serial devices on Linux should be opened non-blocking, otherwise the
|
||||||
/* open() may block already. Named pipes can not be opened non-blocking */
|
* open() may block already. Named pipes can not be opened non-blocking
|
||||||
/* in write-only mode, so first try non-blocking, then blocking. */
|
* in write-only mode, so first try non-blocking, then blocking.
|
||||||
|
*/
|
||||||
|
|
||||||
fd = open(name, fl | O_CREAT | (append ? 0 : O_TRUNC) | O_NONBLOCK, 0666);
|
fd = open(name, fl | O_CREAT | (append ? 0 : O_TRUNC) | O_NONBLOCK, 0666);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
if (errno != ENXIO ||
|
if (errno != ENXIO || -1 ==
|
||||||
(fd = open(name, fl | O_CREAT | (append ? 0 : O_TRUNC), 0666)) == -1)
|
(fd = open(name, fl | O_CREAT | (append ? 0 : O_TRUNC), 0666)))
|
||||||
{
|
{
|
||||||
FS_errmsg = strerror(errno);
|
FS_errmsg = strerror(errno);
|
||||||
return -1;
|
return -1;
|
||||||
@ -803,7 +810,8 @@ int FS_close(int dev)
|
|||||||
if (g_file[dev]->outfd >= 0)
|
if (g_file[dev]->outfd >= 0)
|
||||||
{
|
{
|
||||||
if (g_file[dev]->tty &&
|
if (g_file[dev]->tty &&
|
||||||
(g_file[dev]->outforeground != -1 || g_file[dev]->outbackground != -1))
|
(g_file[dev]->outforeground != -1 ||
|
||||||
|
g_file[dev]->outbackground != -1))
|
||||||
{
|
{
|
||||||
resetcolour(dev);
|
resetcolour(dev);
|
||||||
}
|
}
|
||||||
@ -928,7 +936,8 @@ int FS_truncate(int chn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((o = lseek(fd, 0, SEEK_CUR)) == (off_t) - 1 || ftruncate(fd, o + 1) == -1)
|
if ((o = lseek(fd, 0, SEEK_CUR)) == (off_t) - 1 ||
|
||||||
|
ftruncate(fd, o + 1) == -1)
|
||||||
{
|
{
|
||||||
FS_errmsg = strerror(errno);
|
FS_errmsg = strerror(errno);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1143,8 +1152,8 @@ int FS_getbinaryString(int chn, struct String *s)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->length &&
|
if (s->length && s->length !=
|
||||||
(len = read(g_file[chn]->binaryfd, s->character, s->length)) != s->length)
|
(len = read(g_file[chn]->binaryfd, s->character, s->length)))
|
||||||
{
|
{
|
||||||
if (len == -1)
|
if (len == -1)
|
||||||
{
|
{
|
||||||
@ -1231,9 +1240,8 @@ int FS_nextcol(int dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
f = g_file[dev];
|
f = g_file[dev];
|
||||||
if (f->outPos % f->outColWidth
|
if (f->outPos % f->outColWidth && f->outLineWidth &&
|
||||||
&& f->outLineWidth
|
((f->outPos / f->outColWidth + 2) * f->outColWidth) > f->outLineWidth)
|
||||||
&& ((f->outPos / f->outColWidth + 2) * f->outColWidth) > f->outLineWidth)
|
|
||||||
{
|
{
|
||||||
return FS_putChar(dev, '\n');
|
return FS_putChar(dev, '\n');
|
||||||
}
|
}
|
||||||
@ -1497,7 +1505,7 @@ int FS_inkeyChar(int dev, int ms)
|
|||||||
FD_SET(f->infd, &just_infd);
|
FD_SET(f->infd, &just_infd);
|
||||||
timeout.tv_sec = ms / 1000;
|
timeout.tv_sec = ms / 1000;
|
||||||
timeout.tv_usec = (ms % 1000) * 1000;
|
timeout.tv_usec = (ms % 1000) * 1000;
|
||||||
switch (select(f->infd + 1, &just_infd, (fd_set *) 0, (fd_set *) 0, &timeout))
|
switch (select(f->infd + 1, &just_infd, NULL, NULL, &timeout))
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
@ -1635,8 +1643,9 @@ long int FS_lof(int chn)
|
|||||||
|
|
||||||
assert(fd != -1);
|
assert(fd != -1);
|
||||||
|
|
||||||
/* Get the size of the file */
|
/* Get the size of the file
|
||||||
/* Save the current file position */
|
* Save the current file position
|
||||||
|
*/
|
||||||
|
|
||||||
curpos = lseek(fd, 0, SEEK_CUR);
|
curpos = lseek(fd, 0, SEEK_CUR);
|
||||||
if (curpos == (off_t)-1)
|
if (curpos == (off_t)-1)
|
||||||
@ -1679,7 +1688,8 @@ long int FS_recLength(int chn)
|
|||||||
void FS_field(int chn, struct String *s, long int position, long int length)
|
void FS_field(int chn, struct String *s, long int position, long int length)
|
||||||
{
|
{
|
||||||
assert(g_file[chn]);
|
assert(g_file[chn]);
|
||||||
String_joinField(s, &g_file[chn]->field, g_file[chn]->recBuf + position, length);
|
String_joinField(s, &g_file[chn]->field,
|
||||||
|
g_file[chn]->recBuf + position, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FS_seek(int chn, long int record)
|
int FS_seek(int chn, long int record)
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* apps/nshlib/nsh_envcmds.c
|
* apps/nshlib/nsh_envcmds.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011-2012, 2018 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2012, 2018 Gregory Nutt. All rights
|
||||||
|
* reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -95,7 +96,7 @@ static inline FAR const char *nsh_getwd(const char *wd)
|
|||||||
static inline char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl,
|
static inline char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl,
|
||||||
const char *dirpath, const char *relpath)
|
const char *dirpath, const char *relpath)
|
||||||
{
|
{
|
||||||
char *alloc;
|
FAR char *alloc;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* Handle the special case where the dirpath is simply "/" */
|
/* Handle the special case where the dirpath is simply "/" */
|
||||||
@ -103,7 +104,7 @@ static inline char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl,
|
|||||||
if (strcmp(dirpath, "/") == 0)
|
if (strcmp(dirpath, "/") == 0)
|
||||||
{
|
{
|
||||||
len = strlen(relpath) + 2;
|
len = strlen(relpath) + 2;
|
||||||
alloc = (char*)malloc(len);
|
alloc = (FAR char *)malloc(len);
|
||||||
if (alloc)
|
if (alloc)
|
||||||
{
|
{
|
||||||
sprintf(alloc, "/%s", relpath);
|
sprintf(alloc, "/%s", relpath);
|
||||||
@ -112,7 +113,7 @@ static inline char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
len = strlen(dirpath) + strlen(relpath) + 2;
|
len = strlen(dirpath) + strlen(relpath) + 2;
|
||||||
alloc = (char*)malloc(len);
|
alloc = (FAR char *)malloc(len);
|
||||||
if (alloc)
|
if (alloc)
|
||||||
{
|
{
|
||||||
sprintf(alloc, "%s/%s", dirpath, relpath);
|
sprintf(alloc, "%s/%s", dirpath, relpath);
|
||||||
@ -389,23 +390,24 @@ int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = &argv[1][1];
|
value = &argv[1][1];
|
||||||
while(*value && *value != ' ')
|
while (*value && *value != ' ')
|
||||||
{
|
{
|
||||||
popt = strchr(opts, *value++);
|
popt = strchr(opts, *value++);
|
||||||
if (popt == NULL)
|
if (popt == NULL)
|
||||||
{
|
{
|
||||||
nsh_error(vtbl, g_fmtarginvalid, argv[0], "set", NSH_ERRNO);
|
nsh_error(vtbl, g_fmtarginvalid,
|
||||||
|
argv[0], "set", NSH_ERRNO);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op == '+')
|
if (op == '+')
|
||||||
{
|
{
|
||||||
vtbl->np.np_flags |= 1 << (popt-opts);
|
vtbl->np.np_flags |= 1 << (popt - opts);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vtbl->np.np_flags &= ~(1 << (popt-opts));
|
vtbl->np.np_flags &= ~(1 << (popt - opts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,8 +418,8 @@ int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NSH_HAVE_VARS
|
#ifdef NSH_HAVE_VARS
|
||||||
if (ret == OK && (argc == 3 || argc == 4))
|
if (ret == OK && (argc == 3 || argc == 4))
|
||||||
@ -431,7 +433,7 @@ int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
|
|
||||||
/* Trim whitespace from the value */
|
/* Trim whitespace from the value */
|
||||||
|
|
||||||
value = nsh_trimspaces(argv[ndx+1]);
|
value = nsh_trimspaces(argv[ndx + 1]);
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_VARS
|
#ifdef CONFIG_NSH_VARS
|
||||||
#ifndef CONFIG_DISABLE_ENVIRON
|
#ifndef CONFIG_DISABLE_ENVIRON
|
||||||
@ -442,8 +444,8 @@ int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
* a local variable that shadows the environment variable.
|
* a local variable that shadows the environment variable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
oldvalue = getenv(argv[ndx]);
|
oldvalue = getenv(argv[ndx]);
|
||||||
if (oldvalue == NULL)
|
if (oldvalue == NULL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Set the NSH variable */
|
/* Set the NSH variable */
|
||||||
|
@ -265,7 +265,7 @@ int tftpc_parseargs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If a bad argument was encountered, then return without processing the command */
|
/* If a bad argument was encountered, then return without processing */
|
||||||
|
|
||||||
if (badarg)
|
if (badarg)
|
||||||
{
|
{
|
||||||
@ -669,7 +669,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_HWADDR
|
#ifdef HAVE_HWADDR
|
||||||
/* REVISIT: How will we handle Ethernet and SLIP networks together? */
|
/* REVISIT: How will we handle Ethernet and SLIP together? */
|
||||||
|
|
||||||
else if (!strcmp(tmp, "hw"))
|
else if (!strcmp(tmp, "hw"))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user