more KNF, mostly whitespace, this time more manual labour applying style(9)
This commit is contained in:
63
eval.c
63
eval.c
@ -22,7 +22,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.58 2009/06/08 20:06:45 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.59 2009/06/10 18:12:45 tg Exp $");
|
||||
|
||||
#ifdef MKSH_SMALL
|
||||
#define MKSH_NOPWNAM
|
||||
@ -37,14 +37,14 @@ __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.58 2009/06/08 20:06:45 tg Exp $");
|
||||
|
||||
/* expansion generator state */
|
||||
typedef struct Expand {
|
||||
/* int type; */ /* see expand() */
|
||||
const char *str; /* string */
|
||||
/* int type; */ /* see expand() */
|
||||
const char *str; /* string */
|
||||
union {
|
||||
const char **strv;/* string[] */
|
||||
struct shf *shf; /* file */
|
||||
} u; /* source */
|
||||
struct tbl *var; /* variable in ${var..} */
|
||||
short split; /* split "$@" / call waitlast $() */
|
||||
const char **strv; /* string[] */
|
||||
struct shf *shf; /* file */
|
||||
} u; /* source */
|
||||
struct tbl *var; /* variable in ${var..} */
|
||||
short split; /* split "$@" / call waitlast $() */
|
||||
} Expand;
|
||||
|
||||
#define XBASE 0 /* scanning original */
|
||||
@ -312,13 +312,12 @@ expand(const char *cp, /* input word */
|
||||
}
|
||||
}
|
||||
continue;
|
||||
case OSUBST: /* ${{#}var{:}[=+-?#%]word} */
|
||||
/* format is:
|
||||
* OSUBST [{x] plain-variable-part \0
|
||||
* compiled-word-part CSUBST [}x]
|
||||
* This is where all syntax checking gets done...
|
||||
*/
|
||||
{
|
||||
case OSUBST: { /* ${{#}var{:}[=+-?#%]word} */
|
||||
/* format is:
|
||||
* OSUBST [{x] plain-variable-part \0
|
||||
* compiled-word-part CSUBST [}x]
|
||||
* This is where all syntax checking gets done...
|
||||
*/
|
||||
const char *varname = ++sp; /* skip the { or x (}) */
|
||||
int stype;
|
||||
int slen = 0;
|
||||
@ -543,7 +542,7 @@ expand(const char *cp, /* input word */
|
||||
* after :s here is
|
||||
* non-standard ksh, but is
|
||||
* consistent with rules for
|
||||
* other assignments. Not
|
||||
* other assignments. Not
|
||||
* sure what POSIX thinks of
|
||||
* this.
|
||||
* Not doing tilde expansion
|
||||
@ -574,7 +573,7 @@ expand(const char *cp, /* input word */
|
||||
/* skip word */
|
||||
sp += wdscan(sp, CSUBST) - sp;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
case CSUBST: /* only get here if expanding word */
|
||||
do_CSUBST:
|
||||
sp++; /* ({) skip the } or x */
|
||||
@ -629,15 +628,14 @@ expand(const char *cp, /* input word */
|
||||
doblank++;
|
||||
st = st->prev;
|
||||
continue;
|
||||
case '?':
|
||||
{
|
||||
case '?': {
|
||||
char *s = Xrestpos(ds, dp, st->base);
|
||||
|
||||
errorf("%s: %s", st->var->name,
|
||||
dp == s ?
|
||||
"parameter null or not set" :
|
||||
(debunk(s, s, strlen(s) + 1), s));
|
||||
}
|
||||
}
|
||||
case '0':
|
||||
case '/':
|
||||
dp = Xrestpos(ds, dp, st->base);
|
||||
@ -733,8 +731,9 @@ expand(const char *cp, /* input word */
|
||||
--newlines;
|
||||
} else {
|
||||
while ((c = shf_getc(x.u.shf)) == 0 || c == '\n')
|
||||
if (c == '\n')
|
||||
newlines++; /* Save newlines */
|
||||
if (c == '\n')
|
||||
/* Save newlines */
|
||||
newlines++;
|
||||
if (newlines && c != EOF) {
|
||||
shf_ungetc(c, x.u.shf);
|
||||
c = '\n';
|
||||
@ -758,13 +757,13 @@ expand(const char *cp, /* input word */
|
||||
if (c == 0 || (!quote && (f & DOBLANK) && doblank &&
|
||||
!make_magic && ctype(c, C_IFS))) {
|
||||
/* How words are broken up:
|
||||
* | value of c
|
||||
* word | ws nws 0
|
||||
* | value of c
|
||||
* word | ws nws 0
|
||||
* -----------------------------------
|
||||
* IFS_WORD w/WS w/NWS w
|
||||
* IFS_WS -/WS w/NWS -
|
||||
* IFS_NWS -/NWS w/NWS w
|
||||
* (w means generate a word)
|
||||
* IFS_WORD w/WS w/NWS w
|
||||
* IFS_WS -/WS w/NWS -
|
||||
* IFS_NWS -/NWS w/NWS w
|
||||
* (w means generate a word)
|
||||
* Note that IFS_NWS/0 generates a word (at&t ksh
|
||||
* doesn't do this, but POSIX does).
|
||||
*/
|
||||
@ -1183,7 +1182,7 @@ glob(char *cp, XPtrV *wp, int markdirs)
|
||||
#define GF_GLOBBED BIT(1) /* some globbing has been done */
|
||||
#define GF_MARKDIR BIT(2) /* add trailing / to directories */
|
||||
|
||||
/* Apply file globbing to cp and store the matching files in wp. Returns
|
||||
/* Apply file globbing to cp and store the matching files in wp. Returns
|
||||
* the number of matches found.
|
||||
*/
|
||||
int
|
||||
@ -1295,7 +1294,7 @@ globit(XString *xs, /* dest string */
|
||||
int len;
|
||||
int prefix_len;
|
||||
|
||||
/* xp = *xpp; copy_non_glob() may have re-alloc'd xs */
|
||||
/* xp = *xpp; copy_non_glob() may have re-alloc'd xs */
|
||||
*xp = '\0';
|
||||
prefix_len = Xlength(*xs, xp);
|
||||
dirp = opendir(prefix_len ? Xstring(*xs, xp) : ".");
|
||||
@ -1356,7 +1355,7 @@ debunk(char *dp, const char *sp, size_t dlen)
|
||||
return (dp);
|
||||
}
|
||||
|
||||
/* Check if p is an unquoted name, possibly followed by a / or :. If so
|
||||
/* Check if p is an unquoted name, possibly followed by a / or :. If so
|
||||
* puts the expanded version in *dcp,dp and returns a pointer in p just
|
||||
* past the name, otherwise returns 0.
|
||||
*/
|
||||
@ -1475,7 +1474,7 @@ alt_expand(XPtrV *wp, char *start, char *exp_start, char *end, int fdo)
|
||||
/* no valid expansions... */
|
||||
if (!p || count != 0) {
|
||||
/* Note that given a{{b,c} we do not expand anything (this is
|
||||
* what at&t ksh does. This may be changed to do the {b,c}
|
||||
* what at&t ksh does. This may be changed to do the {b,c}
|
||||
* expansion. }
|
||||
*/
|
||||
if (fdo & DOGLOB)
|
||||
|
Reference in New Issue
Block a user