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

@ -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
@ -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
@ -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 {
@ -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();
} }
@ -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
@ -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);
@ -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
@ -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++);
} }
@ -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) {
@ -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;
@ -10562,12 +10561,10 @@ 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);
@ -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;
@ -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. */
@ -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;
@ -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;
@ -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));
} }
@ -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,8 +13293,8 @@ 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 */
@ -13545,7 +13540,8 @@ static arith_t arith(const char *expr, int *perrcode)
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 */
@ -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 */