ash: fix indentation and style. no code changes
This commit is contained in:
parent
d0762e3d52
commit
a0f82e928a
104
shell/ash.c
104
shell/ash.c
@ -1402,8 +1402,7 @@ struct cmdentry {
|
||||
|
||||
static const char *pathopt; /* set by padvance */
|
||||
|
||||
static void shellexec(char **, const char *, int)
|
||||
ATTRIBUTE_NORETURN;
|
||||
static void shellexec(char **, const char *, int) ATTRIBUTE_NORETURN;
|
||||
static char *padvance(const char **, const char *);
|
||||
static void find_command(char *, struct cmdentry *, int, const char *);
|
||||
static struct builtincmd *find_builtin(const char *);
|
||||
@ -1701,8 +1700,8 @@ static void init(void)
|
||||
|
||||
p = lookupvar("PWD");
|
||||
if (p)
|
||||
if (*p != '/' || stat(p, &st1) || stat(".", &st2) ||
|
||||
st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
|
||||
if (*p != '/' || stat(p, &st1) || stat(".", &st2)
|
||||
|| st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
|
||||
p = 0;
|
||||
setpwd(p, 0);
|
||||
}
|
||||
@ -2092,7 +2091,6 @@ reset(void)
|
||||
{
|
||||
clearredir(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ASH_ALIAS
|
||||
@ -2534,8 +2532,7 @@ setpwd(const char *val, int setold)
|
||||
|
||||
|
||||
|
||||
static void exverror(int, const char *, va_list)
|
||||
ATTRIBUTE_NORETURN;
|
||||
static void exverror(int, const char *, va_list) ATTRIBUTE_NORETURN;
|
||||
|
||||
/*
|
||||
* Called to raise an exception. Since C doesn't include exceptions, we
|
||||
@ -3563,10 +3560,8 @@ prehash(union node *n)
|
||||
{
|
||||
struct cmdentry entry;
|
||||
|
||||
if (n->type == NCMD && n->ncmd.args)
|
||||
if (goodname(n->ncmd.args->narg.text))
|
||||
find_command(n->ncmd.args->narg.text, &entry, 0,
|
||||
pathval());
|
||||
if (n->type == NCMD && n->ncmd.args && goodname(n->ncmd.args->narg.text))
|
||||
find_command(n->ncmd.args->narg.text, &entry, 0, pathval());
|
||||
}
|
||||
|
||||
|
||||
@ -4211,7 +4206,8 @@ clearcmdentry(int firstchange)
|
||||
if ((cmdp->cmdtype == CMDNORMAL &&
|
||||
cmdp->param.index >= firstchange)
|
||||
|| (cmdp->cmdtype == CMDBUILTIN &&
|
||||
builtinloc >= firstchange)) {
|
||||
builtinloc >= firstchange)
|
||||
) {
|
||||
*pp = cmdp->next;
|
||||
ckfree(cmdp);
|
||||
} else {
|
||||
@ -4351,8 +4347,8 @@ unsetfunc(const char *name)
|
||||
{
|
||||
struct tblentry *cmdp;
|
||||
|
||||
if ((cmdp = cmdlookup(name, 0)) != NULL &&
|
||||
cmdp->cmdtype == CMDFUNCTION)
|
||||
cmdp = cmdlookup(name, 0);
|
||||
if (cmdp!= NULL && cmdp->cmdtype == CMDFUNCTION)
|
||||
delete_cmd_entry();
|
||||
}
|
||||
|
||||
@ -4985,7 +4981,7 @@ expbackq(union node *cmd, int quoted, int quotes)
|
||||
read:
|
||||
if (in.fd < 0)
|
||||
break;
|
||||
i = safe_read(in.fd, buf, sizeof buf);
|
||||
i = safe_read(in.fd, buf, sizeof(buf));
|
||||
TRACE(("expbackq: read returns %d\n", i));
|
||||
if (i <= 0)
|
||||
break;
|
||||
@ -5202,8 +5198,7 @@ vsplus:
|
||||
|
||||
if (subtype == VSASSIGN || subtype == VSQUESTION) {
|
||||
if (varlen < 0) {
|
||||
if (subevalvar(p, var, 0, subtype, startloc,
|
||||
varflags, 0)) {
|
||||
if (subevalvar(p, var, 0, subtype, startloc, varflags, 0)) {
|
||||
varflags &= ~VSNUL;
|
||||
/*
|
||||
* Remove any recorded regions beyond
|
||||
@ -5505,7 +5500,7 @@ ifsbreakup(char *string, struct arglist *arglist)
|
||||
continue;
|
||||
}
|
||||
*q = '\0';
|
||||
sp = (struct strlist *)stalloc(sizeof *sp);
|
||||
sp = (struct strlist *)stalloc(sizeof(*sp));
|
||||
sp->text = start;
|
||||
*arglist->lastp = sp;
|
||||
arglist->lastp = &sp->next;
|
||||
@ -5546,7 +5541,7 @@ ifsbreakup(char *string, struct arglist *arglist)
|
||||
return;
|
||||
|
||||
add:
|
||||
sp = (struct strlist *)stalloc(sizeof *sp);
|
||||
sp = (struct strlist *)stalloc(sizeof(*sp));
|
||||
sp->text = start;
|
||||
*arglist->lastp = sp;
|
||||
arglist->lastp = &sp->next;
|
||||
@ -5636,7 +5631,7 @@ addfname(const char *name)
|
||||
{
|
||||
struct strlist *sp;
|
||||
|
||||
sp = (struct strlist *)stalloc(sizeof *sp);
|
||||
sp = (struct strlist *)stalloc(sizeof(*sp));
|
||||
sp->text = sstrdup(name);
|
||||
*exparg.lastp = sp;
|
||||
exparg.lastp = &sp->next;
|
||||
@ -5743,8 +5738,7 @@ out:
|
||||
scopy(dp->d_name, enddir);
|
||||
addfname(expdir);
|
||||
} else {
|
||||
for (p = enddir, cp = dp->d_name;
|
||||
(*p++ = *cp++) != '\0';)
|
||||
for (p = enddir, cp = dp->d_name; (*p++ = *cp++) != '\0';)
|
||||
continue;
|
||||
p[-1] = '/';
|
||||
expmeta(p, endname);
|
||||
@ -7397,7 +7391,9 @@ dowait(int block, struct job *job)
|
||||
sp = jp->ps;
|
||||
do {
|
||||
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;
|
||||
thisjob = jp;
|
||||
}
|
||||
@ -7427,7 +7423,8 @@ gotjob:
|
||||
thisjob->changed = 1;
|
||||
|
||||
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;
|
||||
#if JOBS
|
||||
if (state == JOBSTOPPED) {
|
||||
@ -7913,7 +7910,7 @@ int ash_main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
#if PROFILE
|
||||
monitor(4, etext, profile_buf, sizeof profile_buf, 50);
|
||||
monitor(4, etext, profile_buf, sizeof(profile_buf), 50);
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_EDITING
|
||||
@ -8680,6 +8677,7 @@ copynode(union node *n)
|
||||
return NULL;
|
||||
new = funcblock;
|
||||
funcblock = (char *) funcblock + nodesize[n->type];
|
||||
|
||||
switch (n->type) {
|
||||
case NCMD:
|
||||
new->ncmd.redirect = copynode(n->ncmd.redirect);
|
||||
@ -8769,8 +8767,7 @@ copynodelist(struct nodelist *lp)
|
||||
lpp = &start;
|
||||
while (lp) {
|
||||
*lpp = funcblock;
|
||||
funcblock = (char *) funcblock +
|
||||
SHELL_ALIGN(sizeof(struct nodelist));
|
||||
funcblock = (char *) funcblock + SHELL_ALIGN(sizeof(struct nodelist));
|
||||
(*lpp)->n = copynode(lp->n);
|
||||
lp = lp->next;
|
||||
lpp = &(*lpp)->next;
|
||||
@ -8981,7 +8978,7 @@ setparam(char **argv)
|
||||
int nparam;
|
||||
|
||||
for (nparam = 0 ; argv[nparam] ; nparam++);
|
||||
ap = newparam = ckmalloc((nparam + 1) * sizeof *ap);
|
||||
ap = newparam = ckmalloc((nparam + 1) * sizeof(*ap));
|
||||
while (*argv) {
|
||||
*ap++ = savestr(*argv++);
|
||||
}
|
||||
@ -10293,8 +10290,9 @@ quotemark:
|
||||
dblquote = 1;
|
||||
goto quotemark;
|
||||
case CENDQUOTE:
|
||||
if (eofmark != NULL && arinest == 0 &&
|
||||
varnest == 0) {
|
||||
if (eofmark != NULL && arinest == 0
|
||||
&& varnest == 0
|
||||
) {
|
||||
USTPUTC(c, out);
|
||||
} else {
|
||||
if (dqvarnest == 0) {
|
||||
@ -10399,7 +10397,8 @@ endword:
|
||||
backquotelist = bqlist;
|
||||
grabstackblock(len);
|
||||
wordtext = out;
|
||||
return lasttoken = TWORD;
|
||||
lasttoken = TWORD;
|
||||
return lasttoken;
|
||||
/* end of readtoken routine */
|
||||
|
||||
|
||||
@ -10423,7 +10422,7 @@ checkend: {
|
||||
}
|
||||
}
|
||||
if (c == *eofmark) {
|
||||
if (pfgets(line, sizeof line) != NULL) {
|
||||
if (pfgets(line, sizeof(line)) != NULL) {
|
||||
char *p, *q;
|
||||
|
||||
p = line;
|
||||
@ -10562,12 +10561,10 @@ parsesub: {
|
||||
STPUTC(c, out);
|
||||
c = pgetc();
|
||||
} while (is_digit(c));
|
||||
}
|
||||
else if (is_special(c)) {
|
||||
} else if (is_special(c)) {
|
||||
USTPUTC(c, out);
|
||||
c = pgetc();
|
||||
}
|
||||
else
|
||||
} else
|
||||
badsub: synerror("Bad substitution");
|
||||
|
||||
STPUTC('=', out);
|
||||
@ -10776,7 +10773,6 @@ done:
|
||||
* Parse an arithmetic expansion (indicate start of one and set state)
|
||||
*/
|
||||
parsearith: {
|
||||
|
||||
if (++arinest == 1) {
|
||||
prevsyntax = syntax;
|
||||
syntax = ARISYNTAX;
|
||||
@ -10994,8 +10990,8 @@ static int noclobberopen(const char *fname)
|
||||
* revealed that it was a regular file, and the file has not been
|
||||
* replaced, return the file descriptor.
|
||||
*/
|
||||
if (fstat(fd, &finfo2) == 0 && !S_ISREG(finfo2.st_mode) &&
|
||||
finfo.st_dev == finfo2.st_dev && finfo.st_ino == finfo2.st_ino)
|
||||
if (fstat(fd, &finfo2) == 0 && !S_ISREG(finfo2.st_mode)
|
||||
&& finfo.st_dev == finfo2.st_dev && finfo.st_ino == finfo2.st_ino)
|
||||
return fd;
|
||||
|
||||
/* The file has been replaced. badness. */
|
||||
@ -11157,8 +11153,8 @@ redirect(union node *redir, int flags)
|
||||
n = redir;
|
||||
do {
|
||||
fd = n->nfile.fd;
|
||||
if ((n->nfile.type == NTOFD || n->nfile.type == NFROMFD) &&
|
||||
n->ndup.dupfd == fd)
|
||||
if ((n->nfile.type == NTOFD || n->nfile.type == NFROMFD)
|
||||
&& n->ndup.dupfd == fd)
|
||||
continue; /* redirect from/to same file descriptor */
|
||||
|
||||
newfd = openredirect(n);
|
||||
@ -11776,8 +11772,9 @@ setsignal(int signo)
|
||||
return;
|
||||
}
|
||||
if (act.sa_handler == SIG_IGN) {
|
||||
if (mflag && (signo == SIGTSTP ||
|
||||
signo == SIGTTIN || signo == SIGTTOU)) {
|
||||
if (mflag && (signo == SIGTSTP || signo == SIGTTIN
|
||||
|| signo == SIGTTOU)
|
||||
) {
|
||||
tsig = S_IGN; /* don't hard ignore these */
|
||||
} else
|
||||
tsig = S_HARD_IGN;
|
||||
@ -12993,8 +12990,7 @@ ulimitcmd(int argc, char **argv)
|
||||
else {
|
||||
val = (rlim_t) 0;
|
||||
|
||||
while ((c = *p++) >= '0' && c <= '9')
|
||||
{
|
||||
while ((c = *p++) >= '0' && c <= '9') {
|
||||
val = (val * 10) + (long)(c - '0');
|
||||
if (val < (rlim_t) 0)
|
||||
break;
|
||||
@ -13231,8 +13227,8 @@ static int tok_have_assign(operator op)
|
||||
|
||||
static int is_right_associativity(operator prec)
|
||||
{
|
||||
return (prec == PREC(TOK_ASSIGN) || prec == PREC(TOK_EXPONENT) ||
|
||||
prec == PREC(TOK_CONDITIONAL));
|
||||
return (prec == PREC(TOK_ASSIGN) || prec == PREC(TOK_EXPONENT)
|
||||
|| prec == PREC(TOK_CONDITIONAL));
|
||||
}
|
||||
|
||||
|
||||
@ -13281,11 +13277,10 @@ static int arith_lookup_val(v_n_t *t)
|
||||
/* restore previous ptr after recursiving */
|
||||
prev_chk_var_recursive = cur;
|
||||
return errcode;
|
||||
} else {
|
||||
}
|
||||
/* allow undefined var as 0 */
|
||||
t->val = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -13298,8 +13293,8 @@ static int arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr)
|
||||
arith_t numptr_val, rez;
|
||||
int ret_arith_lookup_val;
|
||||
|
||||
if (NUMPTR == numstack) goto err; /* There is no operator that can work
|
||||
without arguments */
|
||||
/* There is no operator that can work without arguments */
|
||||
if (NUMPTR == numstack) goto err;
|
||||
numptr_m1 = NUMPTR - 1;
|
||||
|
||||
/* check operand is var with noninteger value */
|
||||
@ -13545,7 +13540,8 @@ static arith_t arith(const char *expr, int *perrcode)
|
||||
ret:
|
||||
*perrcode = errcode;
|
||||
return numstack->val;
|
||||
} else {
|
||||
}
|
||||
|
||||
/* Continue processing the expression. */
|
||||
if (arith_isspace(arithval)) {
|
||||
/* Skip whitespace */
|
||||
@ -13668,11 +13664,9 @@ static arith_t arith(const char *expr, int *perrcode)
|
||||
|
||||
/* Push this operator to the stack and remember it. */
|
||||
*stackptr++ = lasttok = op;
|
||||
|
||||
prologue:
|
||||
++expr;
|
||||
}
|
||||
}
|
||||
} /* while */
|
||||
}
|
||||
#endif /* CONFIG_ASH_MATH_SUPPORT */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user