summaryrefslogtreecommitdiff
path: root/bin/ksh/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ksh/eval.c')
-rw-r--r--bin/ksh/eval.c113
1 files changed, 35 insertions, 78 deletions
diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c
index b2f62c091d2..c14f5daaf27 100644
--- a/bin/ksh/eval.c
+++ b/bin/ksh/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.20 2004/12/18 21:25:44 millert Exp $ */
+/* $OpenBSD: eval.c,v 1.21 2004/12/20 11:34:26 otto Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -41,26 +41,21 @@ typedef struct Expand {
#define IFS_WS 1 /* have seen IFS white-space */
#define IFS_NWS 2 /* have seen IFS non-white-space */
-static int varsub(Expand *xp, char *sp, char *word, int *stypep, int *slenp);
-static int comsub(Expand *xp, char *cp);
-static char *trimsub(char *str, char *pat, int how);
-static void glob(char *cp, XPtrV *wp, int markdirs);
-static void globit(XString *xs, char **xpp, char *sp, XPtrV *wp,
- int check);
-static char *maybe_expand_tilde(char *p, XString *dsp, char **dpp,
- int isassign);
-static char *tilde(char *acp);
-static char *homedir(char *name);
+static int varsub(Expand *, char *, char *, int *, int *);
+static int comsub(Expand *, char *);
+static char *trimsub(char *, char *, int);
+static void glob(char *, XPtrV *, int);
+static void globit(XString *, char **, char *, XPtrV *, int);
+static char *maybe_expand_tilde(char *, XString *, char **, int);
+static char *tilde(char *);
+static char *homedir(char *);
#ifdef BRACE_EXPAND
-static void alt_expand(XPtrV *wp, char *start, char *exp_start,
- char *end, int fdo);
+static void alt_expand(XPtrV *, char *, char *, char *, int);
#endif
/* compile and expand word */
char *
-substitute(cp, f)
- const char *cp;
- int f;
+substitute(const char *cp, int f)
{
struct source *s, *sold;
@@ -79,9 +74,7 @@ substitute(cp, f)
* expand arg-list
*/
char **
-eval(ap, f)
- char **ap;
- int f;
+eval(char **ap, int f)
{
XPtrV w;
@@ -99,9 +92,7 @@ eval(ap, f)
* expand string
*/
char *
-evalstr(cp, f)
- char *cp;
- int f;
+evalstr(char *cp, int f)
{
XPtrV w;
@@ -117,9 +108,7 @@ evalstr(cp, f)
* used from iosetup to expand redirection files
*/
char *
-evalonestr(cp, f)
- char *cp;
- int f;
+evalonestr(char *cp, int f)
{
XPtrV w;
@@ -152,10 +141,9 @@ typedef struct SubType {
} SubType;
void
-expand(cp, wp, f)
- char *cp; /* input word */
- XPtrV *wp; /* output words */
- int f; /* DO* flags */
+expand(char *cp, /* input word */
+ XPtrV *wp, /* output words */
+ int f) /* DO* flags */
{
int c = 0;
int type; /* expansion type */
@@ -696,12 +684,9 @@ expand(cp, wp, f)
* Prepare to generate the string returned by ${} substitution.
*/
static int
-varsub(xp, sp, word, stypep, slenp)
- Expand *xp;
- char *sp;
- char *word;
- int *stypep; /* becomes qualifier type */
- int *slenp; /* " " len (=, :=, etc.) valid iff *stypep != 0 */
+varsub(Expand *xp, char *sp, char *word,
+ int *stypep, /* becomes qualifier type */
+ int *slenp) /* " " len (=, :=, etc.) valid iff *stypep != 0 */
{
int c;
int state; /* next state: XBASE, XARG, XSUB, XNULLSUB */
@@ -848,9 +833,7 @@ varsub(xp, sp, word, stypep, slenp)
* Run the command in $(...) and read its output.
*/
static int
-comsub(xp, cp)
- Expand *xp;
- char *cp;
+comsub(Expand *xp, char *cp)
{
Source *s, *sold;
struct op *t;
@@ -902,10 +885,7 @@ comsub(xp, cp)
*/
static char *
-trimsub(str, pat, how)
- char *str;
- char *pat;
- int how;
+trimsub(char *str, char *pat, int how)
{
char *end = strchr(str, 0);
char *p, c;
@@ -955,10 +935,7 @@ trimsub(str, pat, how)
/* XXX cp not const 'cause slashes are temporarily replaced with nulls... */
static void
-glob(cp, wp, markdirs)
- char *cp;
- XPtrV *wp;
- int markdirs;
+glob(char *cp, XPtrV *wp, int markdirs)
{
int oldsize = XPsize(*wp);
@@ -978,10 +955,7 @@ glob(cp, wp, markdirs)
* the number of matches found.
*/
int
-glob_str(cp, wp, markdirs)
- char *cp;
- XPtrV *wp;
- int markdirs;
+glob_str(char *cp, XPtrV *wp, int markdirs)
{
int oldsize = XPsize(*wp);
XString xs;
@@ -995,12 +969,11 @@ glob_str(cp, wp, markdirs)
}
static void
-globit(xs, xpp, sp, wp, check)
- XString *xs; /* dest string */
- char **xpp; /* ptr to dest end */
- char *sp; /* source path */
- XPtrV *wp; /* output list */
- int check; /* GF_* flags */
+globit(XString *xs, /* dest string */
+ char **xpp, /* ptr to dest end */
+ char *sp, /* source path */
+ XPtrV *wp, /* output list */
+ int check) /* GF_* flags */
{
char *np; /* next source component */
char *xp = *xpp;
@@ -1133,10 +1106,7 @@ globit(xs, xpp, sp, wp, check)
*/
static int copy_non_glob(XString *xs, char **xpp, char *p);
static int
-copy_non_glob(xs, xpp, p)
- XString *xs;
- char **xpp;
- char *p;
+copy_non_glob(XString *xs, char **xpp, char *p)
{
char *xp;
int len = strlen(p);
@@ -1173,10 +1143,7 @@ copy_non_glob(xs, xpp, p)
/* remove MAGIC from string */
char *
-debunk(dp, sp, dlen)
- char *dp;
- const char *sp;
- size_t dlen;
+debunk(char *dp, const char *sp, size_t dlen)
{
char *d, *s;
@@ -1206,11 +1173,7 @@ debunk(dp, sp, dlen)
* past the name, otherwise returns 0.
*/
static char *
-maybe_expand_tilde(p, dsp, dpp, isassign)
- char *p;
- XString *dsp;
- char **dpp;
- int isassign;
+maybe_expand_tilde(char *p, XString *dsp, char **dpp, int isassign)
{
XString ts;
char *dp = *dpp;
@@ -1247,8 +1210,7 @@ maybe_expand_tilde(p, dsp, dpp, isassign)
*/
static char *
-tilde(cp)
- char *cp;
+tilde(char *cp)
{
char *dp;
@@ -1274,8 +1236,7 @@ tilde(cp)
*/
static char *
-homedir(name)
- char *name;
+homedir(char *name)
{
struct tbl *ap;
@@ -1294,11 +1255,7 @@ homedir(name)
#ifdef BRACE_EXPAND
static void
-alt_expand(wp, start, exp_start, end, fdo)
- XPtrV *wp;
- char *start, *exp_start;
- char *end;
- int fdo;
+alt_expand(XPtrV *wp, char *start, char *exp_start, char *end, int fdo)
{
int count = 0;
char *brace_start, *brace_end, *comma = NULL;