apps/nshlib: Back out 516a7433444ad4234c468c9729bf9990f4752e65. While the change is fuly functional and adds a pleasing symmetry to the control commands, it is also redundant and serves no real purpose other than requiring more FLASH.

This commit is contained in:
Gregory Nutt 2018-08-12 06:15:29 -06:00
parent f759ad3196
commit f2ef84f048
3 changed files with 14 additions and 41 deletions

View File

@ -122,18 +122,15 @@ Looping
These works from the command line but are primarily intended for use
within NSH scripts (see the sh command). The syntax is as follows:
while [!] <test-cmd>; do <cmd-sequence>; done
while <test-cmd>; do <cmd-sequence>; done
Execute <cmd-sequence> as long as <test-cmd> has an exit status of
zero (OR non-zero if inverted with '!').
zero.
until [!] <test-cmd>; do <cmd-sequence>; done
until <test-cmd>; do <cmd-sequence>; done
Execute <cmd-sequence> as long as <test-cmd> has a non-zero exit
status (OR zero if inverted with '!').
Note that 'while' is equivalent to 'until' if the command result is
inverted.
status.
A break command is also supported. The break command is only meaningful
within the body of the a while or until loop, between the do and done

View File

@ -776,8 +776,7 @@ enum nsh_lp_e
struct nsh_loop_s
{
uint8_t lp_enable : 1; /* Loop command processing is enabled */
uint8_t lp_inverted : 1; /* TRUE: inverted logic ('while ! <cmd>') */
uint8_t lp_unused : 4;
uint8_t lp_unused : 5;
uint8_t lp_state : 2; /* Loop state (see enume nsh_lp_e) */
#ifndef CONFIG_NSH_DISABLE_ITEF
uint8_t lp_iendx; /* Saved if-then-else-fi index */

View File

@ -439,8 +439,6 @@ static int nsh_saveresult(FAR struct nsh_vtbl_s *vtbl, bool result)
if (np->np_lpstate[np->np_lpndx].lp_state == NSH_LOOP_WHILE)
{
result ^= np->np_lpstate[np->np_lpndx].lp_inverted;
np->np_fail = false;
np->np_lpstate[np->np_lpndx].lp_enable = (result == OK);
return OK;
@ -457,8 +455,6 @@ static int nsh_saveresult(FAR struct nsh_vtbl_s *vtbl, bool result)
else if (np->np_lpstate[np->np_lpndx].lp_state == NSH_LOOP_UNTIL)
{
result ^= np->np_lpstate[np->np_lpndx].lp_inverted;
np->np_fail = false;
np->np_lpstate[np->np_lpndx].lp_enable = (result != OK);
return OK;
@ -1774,7 +1770,6 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd,
bool whilematch;
bool untilmatch;
bool enable;
bool inverted = false;
int ret;
if (cmd != NULL)
@ -1797,22 +1792,6 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd,
goto errout;
}
/* Check for inverted logic */
if (strcmp(*ppcmd, "!") == 0)
{
inverted = true;
/* Get the next cmd */
*ppcmd = nsh_argument(vtbl, saveptr, memlist);
if (*ppcmd == NULL || **ppcmd == '\0')
{
nsh_output(vtbl, g_fmtarginvalid, cmd);
goto errout;
}
}
/* Verify that "while" or "until" is valid in this context */
if (
@ -1849,13 +1828,12 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd,
np->np_jump = false;
#endif
np->np_lpndx++;
np->np_lpstate[np->np_lpndx].lp_state = state;
np->np_lpstate[np->np_lpndx].lp_enable = enable;
np->np_lpstate[np->np_lpndx].lp_inverted = inverted;
np->np_lpstate[np->np_lpndx].lp_state = state;
np->np_lpstate[np->np_lpndx].lp_enable = enable;
#ifndef CONFIG_NSH_DISABLE_ITEF
np->np_lpstate[np->np_lpndx].lp_iendx = np->np_iendx;
np->np_lpstate[np->np_lpndx].lp_iendx = np->np_iendx;
#endif
np->np_lpstate[np->np_lpndx].lp_topoffs = offset;
np->np_lpstate[np->np_lpndx].lp_topoffs = offset;
}
/* Check if the token is "do" */
@ -1959,13 +1937,12 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd,
errout:
#ifndef NSH_DISABLE_SEMICOLON
np->np_jump = false;
np->np_jump = false;
#endif
np->np_lpndx = 0;
np->np_lpstate[0].lp_state = NSH_LOOP_NORMAL;
np->np_lpstate[0].lp_enable = true;
np->np_lpstate[0].lp_inverted = false;
np->np_lpstate[0].lp_topoffs = 0;
np->np_lpndx = 0;
np->np_lpstate[0].lp_state = NSH_LOOP_NORMAL;
np->np_lpstate[0].lp_enable = true;
np->np_lpstate[0].lp_topoffs = 0;
return ERROR;
}
#endif