ash: fix indentation and style. no code changes

This commit is contained in:
Denis Vlasenko 2007-02-18 12:35:30 +00:00
parent d0762e3d52
commit a0f82e928a

View File

@ -1154,32 +1154,32 @@ static pointer funcblock; /* block to allocate function from */
static char *funcstring; /* block to allocate strings from */ static char *funcstring; /* block to allocate strings from */
static const short nodesize[26] = { static const short nodesize[26] = {
SHELL_ALIGN(sizeof (struct ncmd)), SHELL_ALIGN(sizeof(struct ncmd)),
SHELL_ALIGN(sizeof (struct npipe)), SHELL_ALIGN(sizeof(struct npipe)),
SHELL_ALIGN(sizeof (struct nredir)), SHELL_ALIGN(sizeof(struct nredir)),
SHELL_ALIGN(sizeof (struct nredir)), SHELL_ALIGN(sizeof(struct nredir)),
SHELL_ALIGN(sizeof (struct nredir)), SHELL_ALIGN(sizeof(struct nredir)),
SHELL_ALIGN(sizeof (struct nbinary)), SHELL_ALIGN(sizeof(struct nbinary)),
SHELL_ALIGN(sizeof (struct nbinary)), SHELL_ALIGN(sizeof(struct nbinary)),
SHELL_ALIGN(sizeof (struct nbinary)), SHELL_ALIGN(sizeof(struct nbinary)),
SHELL_ALIGN(sizeof (struct nif)), SHELL_ALIGN(sizeof(struct nif)),
SHELL_ALIGN(sizeof (struct nbinary)), SHELL_ALIGN(sizeof(struct nbinary)),
SHELL_ALIGN(sizeof (struct nbinary)), SHELL_ALIGN(sizeof(struct nbinary)),
SHELL_ALIGN(sizeof (struct nfor)), SHELL_ALIGN(sizeof(struct nfor)),
SHELL_ALIGN(sizeof (struct ncase)), SHELL_ALIGN(sizeof(struct ncase)),
SHELL_ALIGN(sizeof (struct nclist)), SHELL_ALIGN(sizeof(struct nclist)),
SHELL_ALIGN(sizeof (struct narg)), SHELL_ALIGN(sizeof(struct narg)),
SHELL_ALIGN(sizeof (struct narg)), SHELL_ALIGN(sizeof(struct narg)),
SHELL_ALIGN(sizeof (struct nfile)), SHELL_ALIGN(sizeof(struct nfile)),
SHELL_ALIGN(sizeof (struct nfile)), SHELL_ALIGN(sizeof(struct nfile)),
SHELL_ALIGN(sizeof (struct nfile)), SHELL_ALIGN(sizeof(struct nfile)),
SHELL_ALIGN(sizeof (struct nfile)), SHELL_ALIGN(sizeof(struct nfile)),
SHELL_ALIGN(sizeof (struct nfile)), SHELL_ALIGN(sizeof(struct nfile)),
SHELL_ALIGN(sizeof (struct ndup)), SHELL_ALIGN(sizeof(struct ndup)),
SHELL_ALIGN(sizeof (struct ndup)), SHELL_ALIGN(sizeof(struct ndup)),
SHELL_ALIGN(sizeof (struct nhere)), SHELL_ALIGN(sizeof(struct nhere)),
SHELL_ALIGN(sizeof (struct nhere)), SHELL_ALIGN(sizeof(struct nhere)),
SHELL_ALIGN(sizeof (struct nnot)), SHELL_ALIGN(sizeof(struct nnot)),
}; };
@ -1402,8 +1402,7 @@ struct cmdentry {
static const char *pathopt; /* set by padvance */ static const char *pathopt; /* set by padvance */
static void shellexec(char **, const char *, int) static void shellexec(char **, const char *, int) ATTRIBUTE_NORETURN;
ATTRIBUTE_NORETURN;
static char *padvance(const char **, const char *); static char *padvance(const char **, const char *);
static void find_command(char *, struct cmdentry *, int, const char *); static void find_command(char *, struct cmdentry *, int, const char *);
static struct builtincmd *find_builtin(const char *); static struct builtincmd *find_builtin(const char *);
@ -1701,8 +1700,8 @@ static void init(void)
p = lookupvar("PWD"); p = lookupvar("PWD");
if (p) if (p)
if (*p != '/' || stat(p, &st1) || stat(".", &st2) || if (*p != '/' || stat(p, &st1) || stat(".", &st2)
st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
p = 0; p = 0;
setpwd(p, 0); setpwd(p, 0);
} }
@ -2092,7 +2091,6 @@ reset(void)
{ {
clearredir(0); clearredir(0);
} }
} }
#ifdef CONFIG_ASH_ALIAS #ifdef CONFIG_ASH_ALIAS
@ -2118,7 +2116,7 @@ setalias(const char *name, const char *val)
ap->flag &= ~ALIASDEAD; ap->flag &= ~ALIASDEAD;
} else { } else {
/* not found */ /* not found */
ap = ckmalloc(sizeof (struct alias)); ap = ckmalloc(sizeof(struct alias));
ap->name = savestr(name); ap->name = savestr(name);
ap->val = savestr(val); ap->val = savestr(val);
ap->flag = 0; ap->flag = 0;
@ -2534,8 +2532,7 @@ setpwd(const char *val, int setold)
static void exverror(int, const char *, va_list) static void exverror(int, const char *, va_list) ATTRIBUTE_NORETURN;
ATTRIBUTE_NORETURN;
/* /*
* Called to raise an exception. Since C doesn't include exceptions, we * Called to raise an exception. Since C doesn't include exceptions, we
@ -2670,7 +2667,7 @@ sh_warnx(const char *fmt, ...)
static const char * static const char *
errmsg(int e, const char *em) errmsg(int e, const char *em)
{ {
if(e == ENOENT || e == ENOTDIR) { if (e == ENOENT || e == ENOTDIR) {
return em; return em;
} }
@ -3297,7 +3294,7 @@ evalcommand(union node *cmd, int flags)
argc++; argc++;
} }
argv = nargv = stalloc(sizeof (char *) * (argc + 1)); argv = nargv = stalloc(sizeof(char *) * (argc + 1));
for (sp = arglist.list ; sp ; sp = sp->next) { for (sp = arglist.list ; sp ; sp = sp->next) {
TRACE(("evalcommand arg: %s\n", sp->text)); TRACE(("evalcommand arg: %s\n", sp->text));
*nargv++ = sp->text; *nargv++ = sp->text;
@ -3338,11 +3335,11 @@ evalcommand(union node *cmd, int flags)
dprintf(preverrout_fd, p, expandstr(ps4val())); dprintf(preverrout_fd, p, expandstr(ps4val()));
sp = varlist.list; sp = varlist.list;
for(n = 0; n < 2; n++) { for (n = 0; n < 2; n++) {
while (sp) { while (sp) {
dprintf(preverrout_fd, p, sp->text); dprintf(preverrout_fd, p, sp->text);
sp = sp->next; sp = sp->next;
if(*p == '%') { if (*p == '%') {
p--; p--;
} }
} }
@ -3563,10 +3560,8 @@ prehash(union node *n)
{ {
struct cmdentry entry; struct cmdentry entry;
if (n->type == NCMD && n->ncmd.args) if (n->type == NCMD && n->ncmd.args && goodname(n->ncmd.args->narg.text))
if (goodname(n->ncmd.args->narg.text)) find_command(n->ncmd.args->narg.text, &entry, 0, pathval());
find_command(n->ncmd.args->narg.text, &entry, 0,
pathval());
} }
@ -4211,7 +4206,8 @@ clearcmdentry(int firstchange)
if ((cmdp->cmdtype == CMDNORMAL && if ((cmdp->cmdtype == CMDNORMAL &&
cmdp->param.index >= firstchange) cmdp->param.index >= firstchange)
|| (cmdp->cmdtype == CMDBUILTIN && || (cmdp->cmdtype == CMDBUILTIN &&
builtinloc >= firstchange)) { builtinloc >= firstchange)
) {
*pp = cmdp->next; *pp = cmdp->next;
ckfree(cmdp); ckfree(cmdp);
} else { } else {
@ -4257,7 +4253,7 @@ cmdlookup(const char *name, int add)
pp = &cmdp->next; pp = &cmdp->next;
} }
if (add && cmdp == NULL) { if (add && cmdp == NULL) {
cmdp = *pp = ckmalloc(sizeof (struct tblentry) - ARB cmdp = *pp = ckmalloc(sizeof(struct tblentry) - ARB
+ strlen(name) + 1); + strlen(name) + 1);
cmdp->next = NULL; cmdp->next = NULL;
cmdp->cmdtype = CMDUNKNOWN; cmdp->cmdtype = CMDUNKNOWN;
@ -4351,8 +4347,8 @@ unsetfunc(const char *name)
{ {
struct tblentry *cmdp; struct tblentry *cmdp;
if ((cmdp = cmdlookup(name, 0)) != NULL && cmdp = cmdlookup(name, 0);
cmdp->cmdtype == CMDFUNCTION) if (cmdp!= NULL && cmdp->cmdtype == CMDFUNCTION)
delete_cmd_entry(); delete_cmd_entry();
} }
@ -4641,7 +4637,7 @@ expandarg(union node *arg, struct arglist *arglist, int flag)
} else { } else {
if (flag & EXP_REDIR) /*XXX - for now, just remove escapes */ if (flag & EXP_REDIR) /*XXX - for now, just remove escapes */
rmescapes(p); rmescapes(p);
sp = (struct strlist *)stalloc(sizeof (struct strlist)); sp = (struct strlist *)stalloc(sizeof(struct strlist));
sp->text = p; sp->text = p;
*exparg.lastp = sp; *exparg.lastp = sp;
exparg.lastp = &sp->next; exparg.lastp = &sp->next;
@ -4985,7 +4981,7 @@ expbackq(union node *cmd, int quoted, int quotes)
read: read:
if (in.fd < 0) if (in.fd < 0)
break; break;
i = safe_read(in.fd, buf, sizeof buf); i = safe_read(in.fd, buf, sizeof(buf));
TRACE(("expbackq: read returns %d\n", i)); TRACE(("expbackq: read returns %d\n", i));
if (i <= 0) if (i <= 0)
break; break;
@ -5202,8 +5198,7 @@ vsplus:
if (subtype == VSASSIGN || subtype == VSQUESTION) { if (subtype == VSASSIGN || subtype == VSQUESTION) {
if (varlen < 0) { if (varlen < 0) {
if (subevalvar(p, var, 0, subtype, startloc, if (subevalvar(p, var, 0, subtype, startloc, varflags, 0)) {
varflags, 0)) {
varflags &= ~VSNUL; varflags &= ~VSNUL;
/* /*
* Remove any recorded regions beyond * Remove any recorded regions beyond
@ -5450,7 +5445,7 @@ recordregion(int start, int end, int nulonly)
ifsp = &ifsfirst; ifsp = &ifsfirst;
} else { } else {
INTOFF; INTOFF;
ifsp = (struct ifsregion *)ckmalloc(sizeof (struct ifsregion)); ifsp = (struct ifsregion *)ckmalloc(sizeof(struct ifsregion));
ifsp->next = NULL; ifsp->next = NULL;
ifslastp->next = ifsp; ifslastp->next = ifsp;
INTON; INTON;
@ -5505,7 +5500,7 @@ ifsbreakup(char *string, struct arglist *arglist)
continue; continue;
} }
*q = '\0'; *q = '\0';
sp = (struct strlist *)stalloc(sizeof *sp); sp = (struct strlist *)stalloc(sizeof(*sp));
sp->text = start; sp->text = start;
*arglist->lastp = sp; *arglist->lastp = sp;
arglist->lastp = &sp->next; arglist->lastp = &sp->next;
@ -5546,7 +5541,7 @@ ifsbreakup(char *string, struct arglist *arglist)
return; return;
add: add:
sp = (struct strlist *)stalloc(sizeof *sp); sp = (struct strlist *)stalloc(sizeof(*sp));
sp->text = start; sp->text = start;
*arglist->lastp = sp; *arglist->lastp = sp;
arglist->lastp = &sp->next; arglist->lastp = &sp->next;
@ -5636,7 +5631,7 @@ addfname(const char *name)
{ {
struct strlist *sp; struct strlist *sp;
sp = (struct strlist *)stalloc(sizeof *sp); sp = (struct strlist *)stalloc(sizeof(*sp));
sp->text = sstrdup(name); sp->text = sstrdup(name);
*exparg.lastp = sp; *exparg.lastp = sp;
exparg.lastp = &sp->next; exparg.lastp = &sp->next;
@ -5743,8 +5738,7 @@ out:
scopy(dp->d_name, enddir); scopy(dp->d_name, enddir);
addfname(expdir); addfname(expdir);
} else { } else {
for (p = enddir, cp = dp->d_name; for (p = enddir, cp = dp->d_name; (*p++ = *cp++) != '\0';)
(*p++ = *cp++) != '\0';)
continue; continue;
p[-1] = '/'; p[-1] = '/';
expmeta(p, endname); expmeta(p, endname);
@ -6226,7 +6220,7 @@ pushstring(char *s, void *ap)
INTOFF; INTOFF;
/*dprintf("*** calling pushstring: %s, %d\n", s, len);*/ /*dprintf("*** calling pushstring: %s, %d\n", s, len);*/
if (parsefile->strpush) { if (parsefile->strpush) {
sp = ckmalloc(sizeof (struct strpush)); sp = ckmalloc(sizeof(struct strpush));
sp->prev = parsefile->strpush; sp->prev = parsefile->strpush;
parsefile->strpush = sp; parsefile->strpush = sp;
} else } else
@ -6357,7 +6351,7 @@ pushfile(void)
parsefile->lleft = parselleft; parsefile->lleft = parselleft;
parsefile->nextc = parsenextc; parsefile->nextc = parsenextc;
parsefile->linno = plinno; parsefile->linno = plinno;
pf = (struct parsefile *)ckmalloc(sizeof (struct parsefile)); pf = (struct parsefile *)ckmalloc(sizeof(struct parsefile));
pf->prev = parsefile; pf->prev = parsefile;
pf->fd = -1; pf->fd = -1;
pf->strpush = NULL; pf->strpush = NULL;
@ -7102,7 +7096,7 @@ makejob(union node *node, int nprocs)
jp->used = 1; jp->used = 1;
jp->ps = &jp->ps0; jp->ps = &jp->ps0;
if (nprocs > 1) { if (nprocs > 1) {
jp->ps = ckmalloc(nprocs * sizeof (struct procstat)); jp->ps = ckmalloc(nprocs * sizeof(struct procstat));
} }
TRACE(("makejob(0x%lx, %d) returns %%%d\n", (long)node, nprocs, TRACE(("makejob(0x%lx, %d) returns %%%d\n", (long)node, nprocs,
jobno(jp))); jobno(jp)));
@ -7397,7 +7391,9 @@ dowait(int block, struct job *job)
sp = jp->ps; sp = jp->ps;
do { do {
if (sp->pid == pid) { if (sp->pid == pid) {
TRACE(("Job %d: changing status of proc %d from 0x%x to 0x%x\n", jobno(jp), pid, sp->status, status)); TRACE(("Job %d: changing status of proc %d "
"from 0x%x to 0x%x\n",
jobno(jp), pid, sp->status, status));
sp->status = status; sp->status = status;
thisjob = jp; thisjob = jp;
} }
@ -7427,7 +7423,8 @@ gotjob:
thisjob->changed = 1; thisjob->changed = 1;
if (thisjob->state != state) { if (thisjob->state != state) {
TRACE(("Job %d: changing state from %d to %d\n", jobno(thisjob), thisjob->state, state)); TRACE(("Job %d: changing state from %d to %d\n",
jobno(thisjob), thisjob->state, state));
thisjob->state = state; thisjob->state = state;
#if JOBS #if JOBS
if (state == JOBSTOPPED) { if (state == JOBSTOPPED) {
@ -7913,7 +7910,7 @@ int ash_main(int argc, char **argv)
#endif #endif
#if PROFILE #if PROFILE
monitor(4, etext, profile_buf, sizeof profile_buf, 50); monitor(4, etext, profile_buf, sizeof(profile_buf), 50);
#endif #endif
#if ENABLE_FEATURE_EDITING #if ENABLE_FEATURE_EDITING
@ -7966,7 +7963,7 @@ int ash_main(int argc, char **argv)
if (hp == NULL) { if (hp == NULL) {
hp = lookupvar("HOME"); hp = lookupvar("HOME");
if(hp != NULL) { if (hp != NULL) {
char *defhp = concat_path_file(hp, ".ash_history"); char *defhp = concat_path_file(hp, ".ash_history");
setvar("HISTFILE", defhp, 0); setvar("HISTFILE", defhp, 0);
free(defhp); free(defhp);
@ -8680,6 +8677,7 @@ copynode(union node *n)
return NULL; return NULL;
new = funcblock; new = funcblock;
funcblock = (char *) funcblock + nodesize[n->type]; funcblock = (char *) funcblock + nodesize[n->type];
switch (n->type) { switch (n->type) {
case NCMD: case NCMD:
new->ncmd.redirect = copynode(n->ncmd.redirect); new->ncmd.redirect = copynode(n->ncmd.redirect);
@ -8769,8 +8767,7 @@ copynodelist(struct nodelist *lp)
lpp = &start; lpp = &start;
while (lp) { while (lp) {
*lpp = funcblock; *lpp = funcblock;
funcblock = (char *) funcblock + funcblock = (char *) funcblock + SHELL_ALIGN(sizeof(struct nodelist));
SHELL_ALIGN(sizeof(struct nodelist));
(*lpp)->n = copynode(lp->n); (*lpp)->n = copynode(lp->n);
lp = lp->next; lp = lp->next;
lpp = &(*lpp)->next; lpp = &(*lpp)->next;
@ -8981,7 +8978,7 @@ setparam(char **argv)
int nparam; int nparam;
for (nparam = 0 ; argv[nparam] ; nparam++); for (nparam = 0 ; argv[nparam] ; nparam++);
ap = newparam = ckmalloc((nparam + 1) * sizeof *ap); ap = newparam = ckmalloc((nparam + 1) * sizeof(*ap));
while (*argv) { while (*argv) {
*ap++ = savestr(*argv++); *ap++ = savestr(*argv++);
} }
@ -9096,7 +9093,7 @@ static void change_lc_ctype(const char *value)
/* Roughly copied from bash.. */ /* Roughly copied from bash.. */
static void change_random(const char *value) static void change_random(const char *value)
{ {
if(value == NULL) { if (value == NULL) {
/* "get", generate */ /* "get", generate */
char buf[16]; char buf[16];
@ -9124,7 +9121,7 @@ getopts(char *optstr, char *optvar, char **optfirst, int *param_optind, int *opt
char s[12]; char s[12];
char **optnext; char **optnext;
if(*param_optind < 1) if (*param_optind < 1)
return 1; return 1;
optnext = optfirst + *param_optind - 1; optnext = optfirst + *param_optind - 1;
@ -9446,7 +9443,7 @@ list(int nlflag)
n1 = n2; n1 = n2;
} }
else { else {
n3 = (union node *)stalloc(sizeof (struct nbinary)); n3 = (union node *)stalloc(sizeof(struct nbinary));
n3->type = NSEMI; n3->type = NSEMI;
n3->nbinary.ch1 = n1; n3->nbinary.ch1 = n1;
n3->nbinary.ch2 = n2; n3->nbinary.ch2 = n2;
@ -9504,7 +9501,7 @@ andor(void)
} }
checkkwd = CHKNL | CHKKWD | CHKALIAS; checkkwd = CHKNL | CHKKWD | CHKALIAS;
n2 = pipeline(); n2 = pipeline();
n3 = (union node *)stalloc(sizeof (struct nbinary)); n3 = (union node *)stalloc(sizeof(struct nbinary));
n3->type = t; n3->type = t;
n3->nbinary.ch1 = n1; n3->nbinary.ch1 = n1;
n3->nbinary.ch2 = n2; n3->nbinary.ch2 = n2;
@ -9530,15 +9527,15 @@ pipeline(void)
tokpushback++; tokpushback++;
n1 = command(); n1 = command();
if (readtoken() == TPIPE) { if (readtoken() == TPIPE) {
pipenode = (union node *)stalloc(sizeof (struct npipe)); pipenode = (union node *)stalloc(sizeof(struct npipe));
pipenode->type = NPIPE; pipenode->type = NPIPE;
pipenode->npipe.backgnd = 0; pipenode->npipe.backgnd = 0;
lp = (struct nodelist *)stalloc(sizeof (struct nodelist)); lp = (struct nodelist *)stalloc(sizeof(struct nodelist));
pipenode->npipe.cmdlist = lp; pipenode->npipe.cmdlist = lp;
lp->n = n1; lp->n = n1;
do { do {
prev = lp; prev = lp;
lp = (struct nodelist *)stalloc(sizeof (struct nodelist)); lp = (struct nodelist *)stalloc(sizeof(struct nodelist));
checkkwd = CHKNL | CHKKWD | CHKALIAS; checkkwd = CHKNL | CHKKWD | CHKALIAS;
lp->n = command(); lp->n = command();
prev->next = lp; prev->next = lp;
@ -9548,7 +9545,7 @@ pipeline(void)
} }
tokpushback++; tokpushback++;
if (negate) { if (negate) {
n2 = (union node *)stalloc(sizeof (struct nnot)); n2 = (union node *)stalloc(sizeof(struct nnot));
n2->type = NNOT; n2->type = NNOT;
n2->nnot.com = n1; n2->nnot.com = n1;
return n2; return n2;
@ -9576,7 +9573,7 @@ command(void)
synexpect(-1); synexpect(-1);
/* NOTREACHED */ /* NOTREACHED */
case TIF: case TIF:
n1 = (union node *)stalloc(sizeof (struct nif)); n1 = (union node *)stalloc(sizeof(struct nif));
n1->type = NIF; n1->type = NIF;
n1->nif.test = list(0); n1->nif.test = list(0);
if (readtoken() != TTHEN) if (readtoken() != TTHEN)
@ -9584,7 +9581,7 @@ command(void)
n1->nif.ifpart = list(0); n1->nif.ifpart = list(0);
n2 = n1; n2 = n1;
while (readtoken() == TELIF) { while (readtoken() == TELIF) {
n2->nif.elsepart = (union node *)stalloc(sizeof (struct nif)); n2->nif.elsepart = (union node *)stalloc(sizeof(struct nif));
n2 = n2->nif.elsepart; n2 = n2->nif.elsepart;
n2->type = NIF; n2->type = NIF;
n2->nif.test = list(0); n2->nif.test = list(0);
@ -9603,7 +9600,7 @@ command(void)
case TWHILE: case TWHILE:
case TUNTIL: { case TUNTIL: {
int got; int got;
n1 = (union node *)stalloc(sizeof (struct nbinary)); n1 = (union node *)stalloc(sizeof(struct nbinary));
n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL; n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL;
n1->nbinary.ch1 = list(0); n1->nbinary.ch1 = list(0);
if ((got=readtoken()) != TDO) { if ((got=readtoken()) != TDO) {
@ -9617,14 +9614,14 @@ TRACE(("expecting DO got %s %s\n", tokname(got), got == TWORD ? wordtext : ""));
case TFOR: case TFOR:
if (readtoken() != TWORD || quoteflag || ! goodname(wordtext)) if (readtoken() != TWORD || quoteflag || ! goodname(wordtext))
synerror("Bad for loop variable"); synerror("Bad for loop variable");
n1 = (union node *)stalloc(sizeof (struct nfor)); n1 = (union node *)stalloc(sizeof(struct nfor));
n1->type = NFOR; n1->type = NFOR;
n1->nfor.var = wordtext; n1->nfor.var = wordtext;
checkkwd = CHKKWD | CHKALIAS; checkkwd = CHKKWD | CHKALIAS;
if (readtoken() == TIN) { if (readtoken() == TIN) {
app = &ap; app = &ap;
while (readtoken() == TWORD) { while (readtoken() == TWORD) {
n2 = (union node *)stalloc(sizeof (struct narg)); n2 = (union node *)stalloc(sizeof(struct narg));
n2->type = NARG; n2->type = NARG;
n2->narg.text = wordtext; n2->narg.text = wordtext;
n2->narg.backquote = backquotelist; n2->narg.backquote = backquotelist;
@ -9636,7 +9633,7 @@ TRACE(("expecting DO got %s %s\n", tokname(got), got == TWORD ? wordtext : ""));
if (lasttoken != TNL && lasttoken != TSEMI) if (lasttoken != TNL && lasttoken != TSEMI)
synexpect(-1); synexpect(-1);
} else { } else {
n2 = (union node *)stalloc(sizeof (struct narg)); n2 = (union node *)stalloc(sizeof(struct narg));
n2->type = NARG; n2->type = NARG;
n2->narg.text = (char *)dolatstr; n2->narg.text = (char *)dolatstr;
n2->narg.backquote = NULL; n2->narg.backquote = NULL;
@ -9656,11 +9653,11 @@ TRACE(("expecting DO got %s %s\n", tokname(got), got == TWORD ? wordtext : ""));
t = TDONE; t = TDONE;
break; break;
case TCASE: case TCASE:
n1 = (union node *)stalloc(sizeof (struct ncase)); n1 = (union node *)stalloc(sizeof(struct ncase));
n1->type = NCASE; n1->type = NCASE;
if (readtoken() != TWORD) if (readtoken() != TWORD)
synexpect(TWORD); synexpect(TWORD);
n1->ncase.expr = n2 = (union node *)stalloc(sizeof (struct narg)); n1->ncase.expr = n2 = (union node *)stalloc(sizeof(struct narg));
n2->type = NARG; n2->type = NARG;
n2->narg.text = wordtext; n2->narg.text = wordtext;
n2->narg.backquote = backquotelist; n2->narg.backquote = backquotelist;
@ -9674,14 +9671,14 @@ TRACE(("expecting DO got %s %s\n", tokname(got), got == TWORD ? wordtext : ""));
next_case: next_case:
checkkwd = CHKNL | CHKKWD; checkkwd = CHKNL | CHKKWD;
t = readtoken(); t = readtoken();
while(t != TESAC) { while (t != TESAC) {
if (lasttoken == TLP) if (lasttoken == TLP)
readtoken(); readtoken();
*cpp = cp = (union node *)stalloc(sizeof (struct nclist)); *cpp = cp = (union node *)stalloc(sizeof(struct nclist));
cp->type = NCLIST; cp->type = NCLIST;
app = &cp->nclist.pattern; app = &cp->nclist.pattern;
for (;;) { for (;;) {
*app = ap = (union node *)stalloc(sizeof (struct narg)); *app = ap = (union node *)stalloc(sizeof(struct narg));
ap->type = NARG; ap->type = NARG;
ap->narg.text = wordtext; ap->narg.text = wordtext;
ap->narg.backquote = backquotelist; ap->narg.backquote = backquotelist;
@ -9708,7 +9705,7 @@ next_case:
*cpp = NULL; *cpp = NULL;
goto redir; goto redir;
case TLP: case TLP:
n1 = (union node *)stalloc(sizeof (struct nredir)); n1 = (union node *)stalloc(sizeof(struct nredir));
n1->type = NSUBSHELL; n1->type = NSUBSHELL;
n1->nredir.n = list(0); n1->nredir.n = list(0);
n1->nredir.redirect = NULL; n1->nredir.redirect = NULL;
@ -9740,7 +9737,7 @@ redir:
*rpp = NULL; *rpp = NULL;
if (redir) { if (redir) {
if (n1->type != NSUBSHELL) { if (n1->type != NSUBSHELL) {
n2 = (union node *)stalloc(sizeof (struct nredir)); n2 = (union node *)stalloc(sizeof(struct nredir));
n2->type = NREDIR; n2->type = NREDIR;
n2->nredir.n = n1; n2->nredir.n = n1;
n1 = n2; n1 = n2;
@ -9772,7 +9769,7 @@ simplecmd(void) {
checkkwd = savecheckkwd; checkkwd = savecheckkwd;
switch (readtoken()) { switch (readtoken()) {
case TWORD: case TWORD:
n = (union node *)stalloc(sizeof (struct narg)); n = (union node *)stalloc(sizeof(struct narg));
n->type = NARG; n->type = NARG;
n->narg.text = wordtext; n->narg.text = wordtext;
n->narg.backquote = backquotelist; n->narg.backquote = backquotelist;
@ -9824,7 +9821,7 @@ out:
*app = NULL; *app = NULL;
*vpp = NULL; *vpp = NULL;
*rpp = NULL; *rpp = NULL;
n = (union node *)stalloc(sizeof (struct ncmd)); n = (union node *)stalloc(sizeof(struct ncmd));
n->type = NCMD; n->type = NCMD;
n->ncmd.args = args; n->ncmd.args = args;
n->ncmd.assign = vars; n->ncmd.assign = vars;
@ -9837,7 +9834,7 @@ makename(void)
{ {
union node *n; union node *n;
n = (union node *)stalloc(sizeof (struct narg)); n = (union node *)stalloc(sizeof(struct narg));
n->type = NARG; n->type = NARG;
n->narg.next = NULL; n->narg.next = NULL;
n->narg.text = wordtext; n->narg.text = wordtext;
@ -9918,7 +9915,7 @@ parseheredoc(void)
} }
readtoken1(pgetc(), here->here->type == NHERE? SQSYNTAX : DQSYNTAX, readtoken1(pgetc(), here->here->type == NHERE? SQSYNTAX : DQSYNTAX,
here->eofmark, here->striptabs); here->eofmark, here->striptabs);
n = (union node *)stalloc(sizeof (struct narg)); n = (union node *)stalloc(sizeof(struct narg));
n->narg.type = NARG; n->narg.type = NARG;
n->narg.next = NULL; n->narg.next = NULL;
n->narg.text = wordtext; n->narg.text = wordtext;
@ -10283,7 +10280,7 @@ readtoken1(int firstc, int syntax, char *eofmark, int striptabs)
break; break;
case CSQUOTE: case CSQUOTE:
syntax = SQSYNTAX; syntax = SQSYNTAX;
quotemark: quotemark:
if (eofmark == NULL) { if (eofmark == NULL) {
USTPUTC(CTLQUOTEMARK, out); USTPUTC(CTLQUOTEMARK, out);
} }
@ -10293,8 +10290,9 @@ quotemark:
dblquote = 1; dblquote = 1;
goto quotemark; goto quotemark;
case CENDQUOTE: case CENDQUOTE:
if (eofmark != NULL && arinest == 0 && if (eofmark != NULL && arinest == 0
varnest == 0) { && varnest == 0
) {
USTPUTC(c, out); USTPUTC(c, out);
} else { } else {
if (dqvarnest == 0) { if (dqvarnest == 0) {
@ -10369,7 +10367,7 @@ quotemark:
c = pgetc_macro(); c = pgetc_macro();
} }
} }
endword: endword:
#ifdef CONFIG_ASH_MATH_SUPPORT #ifdef CONFIG_ASH_MATH_SUPPORT
if (syntax == ARISYNTAX) if (syntax == ARISYNTAX)
synerror("Missing '))'"); synerror("Missing '))'");
@ -10399,7 +10397,8 @@ endword:
backquotelist = bqlist; backquotelist = bqlist;
grabstackblock(len); grabstackblock(len);
wordtext = out; wordtext = out;
return lasttoken = TWORD; lasttoken = TWORD;
return lasttoken;
/* end of readtoken routine */ /* end of readtoken routine */
@ -10423,7 +10422,7 @@ checkend: {
} }
} }
if (c == *eofmark) { if (c == *eofmark) {
if (pfgets(line, sizeof line) != NULL) { if (pfgets(line, sizeof(line)) != NULL) {
char *p, *q; char *p, *q;
p = line; p = line;
@ -10452,7 +10451,7 @@ parseredir: {
char fd = *out; char fd = *out;
union node *np; union node *np;
np = (union node *)stalloc(sizeof (struct nfile)); np = (union node *)stalloc(sizeof(struct nfile));
if (c == '>') { if (c == '>') {
np->nfile.fd = 1; np->nfile.fd = 1;
c = pgetc(); c = pgetc();
@ -10470,12 +10469,12 @@ parseredir: {
np->nfile.fd = 0; np->nfile.fd = 0;
switch (c = pgetc()) { switch (c = pgetc()) {
case '<': case '<':
if (sizeof (struct nfile) != sizeof (struct nhere)) { if (sizeof(struct nfile) != sizeof(struct nhere)) {
np = (union node *)stalloc(sizeof (struct nhere)); np = (union node *)stalloc(sizeof(struct nhere));
np->nfile.fd = 0; np->nfile.fd = 0;
} }
np->type = NHERE; np->type = NHERE;
heredoc = (struct heredoc *)stalloc(sizeof (struct heredoc)); heredoc = (struct heredoc *)stalloc(sizeof(struct heredoc));
heredoc->here = np; heredoc->here = np;
if ((c = pgetc()) == '-') { if ((c = pgetc()) == '-') {
heredoc->striptabs = 1; heredoc->striptabs = 1;
@ -10562,13 +10561,11 @@ parsesub: {
STPUTC(c, out); STPUTC(c, out);
c = pgetc(); c = pgetc();
} while (is_digit(c)); } while (is_digit(c));
} } else if (is_special(c)) {
else if (is_special(c)) {
USTPUTC(c, out); USTPUTC(c, out);
c = pgetc(); c = pgetc();
} } else
else badsub: synerror("Bad substitution");
badsub: synerror("Bad substitution");
STPUTC('=', out); STPUTC('=', out);
flags = 0; flags = 0;
@ -10721,7 +10718,7 @@ done:
nlpp = &bqlist; nlpp = &bqlist;
while (*nlpp) while (*nlpp)
nlpp = &(*nlpp)->next; nlpp = &(*nlpp)->next;
*nlpp = (struct nodelist *)stalloc(sizeof (struct nodelist)); *nlpp = (struct nodelist *)stalloc(sizeof(struct nodelist));
(*nlpp)->next = NULL; (*nlpp)->next = NULL;
parsebackquote = oldstyle; parsebackquote = oldstyle;
@ -10776,7 +10773,6 @@ done:
* Parse an arithmetic expansion (indicate start of one and set state) * Parse an arithmetic expansion (indicate start of one and set state)
*/ */
parsearith: { parsearith: {
if (++arinest == 1) { if (++arinest == 1) {
prevsyntax = syntax; prevsyntax = syntax;
syntax = ARISYNTAX; syntax = ARISYNTAX;
@ -10835,10 +10831,10 @@ endofname(const char *name)
char *p; char *p;
p = (char *) name; p = (char *) name;
if (! is_name(*p)) if (!is_name(*p))
return p; return p;
while (*++p) { while (*++p) {
if (! is_in_name(*p)) if (!is_in_name(*p))
break; break;
} }
return p; return p;
@ -10994,8 +10990,8 @@ static int noclobberopen(const char *fname)
* revealed that it was a regular file, and the file has not been * revealed that it was a regular file, and the file has not been
* replaced, return the file descriptor. * replaced, return the file descriptor.
*/ */
if (fstat(fd, &finfo2) == 0 && !S_ISREG(finfo2.st_mode) && if (fstat(fd, &finfo2) == 0 && !S_ISREG(finfo2.st_mode)
finfo.st_dev == finfo2.st_dev && finfo.st_ino == finfo2.st_ino) && finfo.st_dev == finfo2.st_dev && finfo.st_ino == finfo2.st_ino)
return fd; return fd;
/* The file has been replaced. badness. */ /* The file has been replaced. badness. */
@ -11145,7 +11141,7 @@ redirect(union node *redir, int flags)
INTOFF; INTOFF;
if (flags & REDIR_PUSH) { if (flags & REDIR_PUSH) {
struct redirtab *q; struct redirtab *q;
q = ckmalloc(sizeof (struct redirtab)); q = ckmalloc(sizeof(struct redirtab));
q->next = redirlist; q->next = redirlist;
redirlist = q; redirlist = q;
q->nullredirs = nullredirs - 1; q->nullredirs = nullredirs - 1;
@ -11157,8 +11153,8 @@ redirect(union node *redir, int flags)
n = redir; n = redir;
do { do {
fd = n->nfile.fd; fd = n->nfile.fd;
if ((n->nfile.type == NTOFD || n->nfile.type == NFROMFD) && if ((n->nfile.type == NTOFD || n->nfile.type == NFROMFD)
n->ndup.dupfd == fd) && n->ndup.dupfd == fd)
continue; /* redirect from/to same file descriptor */ continue; /* redirect from/to same file descriptor */
newfd = openredirect(n); newfd = openredirect(n);
@ -11776,8 +11772,9 @@ setsignal(int signo)
return; return;
} }
if (act.sa_handler == SIG_IGN) { if (act.sa_handler == SIG_IGN) {
if (mflag && (signo == SIGTSTP || if (mflag && (signo == SIGTSTP || signo == SIGTTIN
signo == SIGTTIN || signo == SIGTTOU)) { || signo == SIGTTOU)
) {
tsig = S_IGN; /* don't hard ignore these */ tsig = S_IGN; /* don't hard ignore these */
} else } else
tsig = S_HARD_IGN; tsig = S_HARD_IGN;
@ -11887,11 +11884,11 @@ setinteractive(int on)
setsignal(SIGQUIT); setsignal(SIGQUIT);
setsignal(SIGTERM); setsignal(SIGTERM);
#if !ENABLE_FEATURE_SH_EXTRA_QUIET #if !ENABLE_FEATURE_SH_EXTRA_QUIET
if(is_interactive > 1) { if (is_interactive > 1) {
/* Looks like they want an interactive shell */ /* Looks like they want an interactive shell */
static int do_banner; static int do_banner;
if(!do_banner) { if (!do_banner) {
out1fmt( out1fmt(
"\n\n%s Built-in shell (ash)\n" "\n\n%s Built-in shell (ash)\n"
"Enter 'help' for a list of built-in commands.\n\n", "Enter 'help' for a list of built-in commands.\n\n",
@ -12083,7 +12080,7 @@ setvareq(char *s, int flags)
if (flags & VNOSET) if (flags & VNOSET)
return; return;
/* not found */ /* not found */
vp = ckmalloc(sizeof (*vp)); vp = ckmalloc(sizeof(*vp));
vp->next = *vpp; vp->next = *vpp;
vp->func = NULL; vp->func = NULL;
*vpp = vp; *vpp = vp;
@ -12131,10 +12128,10 @@ lookupvar(const char *name)
* As soon as they're unset, they're no longer dynamic, and dynamic * As soon as they're unset, they're no longer dynamic, and dynamic
* lookup will no longer happen at that point. -- PFM. * lookup will no longer happen at that point. -- PFM.
*/ */
if((v->flags & VDYNAMIC)) if ((v->flags & VDYNAMIC))
(*v->func)(NULL); (*v->func)(NULL);
#endif #endif
if(!(v->flags & VUNSET)) if (!(v->flags & VUNSET))
return strchrnul(v->text, '=') + 1; return strchrnul(v->text, '=') + 1;
} }
@ -12275,7 +12272,7 @@ static void mklocal(char *name)
struct var *vp; struct var *vp;
INTOFF; INTOFF;
lvp = ckmalloc(sizeof (struct localvar)); lvp = ckmalloc(sizeof(struct localvar));
if (LONE_DASH(name)) { if (LONE_DASH(name)) {
char *p; char *p;
p = ckmalloc(sizeof(optlist)); p = ckmalloc(sizeof(optlist));
@ -12568,7 +12565,7 @@ letcmd(int argc, char **argv)
arith_t i = 0; arith_t i = 0;
ap = argv + 1; ap = argv + 1;
if(!*ap) if (!*ap)
sh_error("expression expected"); sh_error("expression expected");
for (ap = argv + 1; *ap; ap++) { for (ap = argv + 1; *ap; ap++) {
i = dash_arith(*ap); i = dash_arith(*ap);
@ -12993,8 +12990,7 @@ ulimitcmd(int argc, char **argv)
else { else {
val = (rlim_t) 0; val = (rlim_t) 0;
while ((c = *p++) >= '0' && c <= '9') while ((c = *p++) >= '0' && c <= '9') {
{
val = (val * 10) + (long)(c - '0'); val = (val * 10) + (long)(c - '0');
if (val < (rlim_t) 0) if (val < (rlim_t) 0)
break; break;
@ -13158,7 +13154,7 @@ typedef unsigned char operator;
#define TOK_REM_ASSIGN tok_decl(3,2) #define TOK_REM_ASSIGN tok_decl(3,2)
/* all assign is right associativity and precedence eq, but (7+3)<<5 > 256 */ /* all assign is right associativity and precedence eq, but (7+3)<<5 > 256 */
#define convert_prec_is_assing(prec) do { if(prec == 3) prec = 2; } while(0) #define convert_prec_is_assing(prec) do { if (prec == 3) prec = 2; } while (0)
/* conditional is right associativity too */ /* conditional is right associativity too */
#define TOK_CONDITIONAL tok_decl(4,0) #define TOK_CONDITIONAL tok_decl(4,0)
@ -13231,8 +13227,8 @@ static int tok_have_assign(operator op)
static int is_right_associativity(operator prec) static int is_right_associativity(operator prec)
{ {
return (prec == PREC(TOK_ASSIGN) || prec == PREC(TOK_EXPONENT) || return (prec == PREC(TOK_ASSIGN) || prec == PREC(TOK_EXPONENT)
prec == PREC(TOK_CONDITIONAL)); || prec == PREC(TOK_CONDITIONAL));
} }
@ -13255,18 +13251,18 @@ static chk_var_recursive_looped_t *prev_chk_var_recursive;
static int arith_lookup_val(v_n_t *t) static int arith_lookup_val(v_n_t *t)
{ {
if(t->var) { if (t->var) {
const char * p = lookupvar(t->var); const char * p = lookupvar(t->var);
if(p) { if (p) {
int errcode; int errcode;
/* recursive try as expression */ /* recursive try as expression */
chk_var_recursive_looped_t *cur; chk_var_recursive_looped_t *cur;
chk_var_recursive_looped_t cur_save; chk_var_recursive_looped_t cur_save;
for(cur = prev_chk_var_recursive; cur; cur = cur->next) { for (cur = prev_chk_var_recursive; cur; cur = cur->next) {
if(strcmp(cur->var, t->var) == 0) { if (strcmp(cur->var, t->var) == 0) {
/* expression recursion loop detected */ /* expression recursion loop detected */
return -5; return -5;
} }
@ -13281,11 +13277,10 @@ static int arith_lookup_val(v_n_t *t)
/* restore previous ptr after recursiving */ /* restore previous ptr after recursiving */
prev_chk_var_recursive = cur; prev_chk_var_recursive = cur;
return errcode; return errcode;
} else { }
/* allow undefined var as 0 */ /* allow undefined var as 0 */
t->val = 0; t->val = 0;
} }
}
return 0; return 0;
} }
@ -13298,13 +13293,13 @@ static int arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr)
arith_t numptr_val, rez; arith_t numptr_val, rez;
int ret_arith_lookup_val; int ret_arith_lookup_val;
if (NUMPTR == numstack) goto err; /* There is no operator that can work /* There is no operator that can work without arguments */
without arguments */ if (NUMPTR == numstack) goto err;
numptr_m1 = NUMPTR - 1; numptr_m1 = NUMPTR - 1;
/* check operand is var with noninteger value */ /* check operand is var with noninteger value */
ret_arith_lookup_val = arith_lookup_val(numptr_m1); ret_arith_lookup_val = arith_lookup_val(numptr_m1);
if(ret_arith_lookup_val) if (ret_arith_lookup_val)
return ret_arith_lookup_val; return ret_arith_lookup_val;
rez = numptr_m1->val; rez = numptr_m1->val;
@ -13328,20 +13323,20 @@ static int arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr)
--NUMPTR; --NUMPTR;
numptr_val = rez; numptr_val = rez;
if (op == TOK_CONDITIONAL) { if (op == TOK_CONDITIONAL) {
if(! numptr_m1->contidional_second_val_initialized) { if (! numptr_m1->contidional_second_val_initialized) {
/* protect $((expr1 ? expr2)) without ": expr" */ /* protect $((expr1 ? expr2)) without ": expr" */
goto err; goto err;
} }
rez = numptr_m1->contidional_second_val; rez = numptr_m1->contidional_second_val;
} else if(numptr_m1->contidional_second_val_initialized) { } else if (numptr_m1->contidional_second_val_initialized) {
/* protect $((expr1 : expr2)) without "expr ? " */ /* protect $((expr1 : expr2)) without "expr ? " */
goto err; goto err;
} }
numptr_m1 = NUMPTR - 1; numptr_m1 = NUMPTR - 1;
if(op != TOK_ASSIGN) { if (op != TOK_ASSIGN) {
/* check operand is var with noninteger value for not '=' */ /* check operand is var with noninteger value for not '=' */
ret_arith_lookup_val = arith_lookup_val(numptr_m1); ret_arith_lookup_val = arith_lookup_val(numptr_m1);
if(ret_arith_lookup_val) if (ret_arith_lookup_val)
return ret_arith_lookup_val; return ret_arith_lookup_val;
} }
if (op == TOK_CONDITIONAL) { if (op == TOK_CONDITIONAL) {
@ -13394,29 +13389,29 @@ static int arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr)
rez = rez ? rez = rez ?
numptr_val : numptr_m1->contidional_second_val; numptr_val : numptr_m1->contidional_second_val;
} }
else if(op == TOK_EXPONENT) { else if (op == TOK_EXPONENT) {
if(numptr_val < 0) if (numptr_val < 0)
return -3; /* exponent less than 0 */ return -3; /* exponent less than 0 */
else { else {
arith_t c = 1; arith_t c = 1;
if(numptr_val) if (numptr_val)
while(numptr_val--) while (numptr_val--)
c *= rez; c *= rez;
rez = c; rez = c;
} }
} }
else if(numptr_val==0) /* zero divisor check */ else if (numptr_val==0) /* zero divisor check */
return -2; return -2;
else if (op == TOK_DIV || op == TOK_DIV_ASSIGN) else if (op == TOK_DIV || op == TOK_DIV_ASSIGN)
rez /= numptr_val; rez /= numptr_val;
else if (op == TOK_REM || op == TOK_REM_ASSIGN) else if (op == TOK_REM || op == TOK_REM_ASSIGN)
rez %= numptr_val; rez %= numptr_val;
} }
if(tok_have_assign(op)) { if (tok_have_assign(op)) {
char buf[32]; char buf[32];
if(numptr_m1->var == NULL) { if (numptr_m1->var == NULL) {
/* Hmm, 1=2 ? */ /* Hmm, 1=2 ? */
goto err; goto err;
} }
@ -13428,9 +13423,9 @@ static int arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr)
#endif #endif
setvar(numptr_m1->var, buf, 0); setvar(numptr_m1->var, buf, 0);
/* after saving, make previous value for v++ or v-- */ /* after saving, make previous value for v++ or v-- */
if(op == TOK_POST_INC) if (op == TOK_POST_INC)
rez--; rez--;
else if(op == TOK_POST_DEC) else if (op == TOK_POST_DEC)
rez++; rez++;
} }
numptr_m1->val = rez; numptr_m1->val = rez;
@ -13513,7 +13508,7 @@ static arith_t arith(const char *expr, int *perrcode)
*stackptr++ = lasttok = TOK_LPAREN; /* start off with a left paren */ *stackptr++ = lasttok = TOK_LPAREN; /* start off with a left paren */
*perrcode = errcode = 0; *perrcode = errcode = 0;
while(1) { while (1) {
if ((arithval = *expr) == 0) { if ((arithval = *expr) == 0) {
if (p == endexpression) { if (p == endexpression) {
/* Null expression. */ /* Null expression. */
@ -13538,20 +13533,21 @@ static arith_t arith(const char *expr, int *perrcode)
err: err:
return (*perrcode = -1); return (*perrcode = -1);
} }
if(numstack->var) { if (numstack->var) {
/* expression is $((var)) only, lookup now */ /* expression is $((var)) only, lookup now */
errcode = arith_lookup_val(numstack); errcode = arith_lookup_val(numstack);
} }
ret: ret:
*perrcode = errcode; *perrcode = errcode;
return numstack->val; return numstack->val;
} else { }
/* Continue processing the expression. */ /* Continue processing the expression. */
if (arith_isspace(arithval)) { if (arith_isspace(arithval)) {
/* Skip whitespace */ /* Skip whitespace */
goto prologue; goto prologue;
} }
if((p = endofname(expr)) != expr) { if ((p = endofname(expr)) != expr) {
size_t var_name_size = (p-expr) + 1; /* trailing zero */ size_t var_name_size = (p-expr) + 1; /* trailing zero */
numstackptr->var = alloca(var_name_size); numstackptr->var = alloca(var_name_size);
@ -13571,22 +13567,22 @@ static arith_t arith(const char *expr, int *perrcode)
#endif #endif
goto num; goto num;
} }
for(p = op_tokens; ; p++) { for (p = op_tokens; ; p++) {
const char *o; const char *o;
if(*p == 0) { if (*p == 0) {
/* strange operator not found */ /* strange operator not found */
goto err; goto err;
} }
for(o = expr; *p && *o == *p; p++) for (o = expr; *p && *o == *p; p++)
o++; o++;
if(! *p) { if (! *p) {
/* found */ /* found */
expr = o - 1; expr = o - 1;
break; break;
} }
/* skip tail uncompared token */ /* skip tail uncompared token */
while(*p) while (*p)
p++; p++;
/* skip zero delim */ /* skip zero delim */
p++; p++;
@ -13594,7 +13590,7 @@ static arith_t arith(const char *expr, int *perrcode)
op = p[1]; op = p[1];
/* post grammar: a++ reduce to num */ /* post grammar: a++ reduce to num */
if(lasttok == TOK_POST_INC || lasttok == TOK_POST_DEC) if (lasttok == TOK_POST_INC || lasttok == TOK_POST_DEC)
lasttok = TOK_NUM; lasttok = TOK_NUM;
/* Plus and minus are binary (not unary) _only_ if the last /* Plus and minus are binary (not unary) _only_ if the last
@ -13655,11 +13651,11 @@ static arith_t arith(const char *expr, int *perrcode)
if (prev_prec < prec) if (prev_prec < prec)
break; break;
/* check right assoc */ /* check right assoc */
if(prev_prec == prec && is_right_associativity(prec)) if (prev_prec == prec && is_right_associativity(prec))
break; break;
} }
errcode = arith_apply(*--stackptr, numstack, &numstackptr); errcode = arith_apply(*--stackptr, numstack, &numstackptr);
if(errcode) goto ret; if (errcode) goto ret;
} }
if (op == TOK_RPAREN) { if (op == TOK_RPAREN) {
goto err; goto err;
@ -13668,11 +13664,9 @@ static arith_t arith(const char *expr, int *perrcode)
/* Push this operator to the stack and remember it. */ /* Push this operator to the stack and remember it. */
*stackptr++ = lasttok = op; *stackptr++ = lasttok = op;
prologue: prologue:
++expr; ++expr;
} } /* while */
}
} }
#endif /* CONFIG_ASH_MATH_SUPPORT */ #endif /* CONFIG_ASH_MATH_SUPPORT */