run GNU protoize
protect header files nuke some dead code regenerate configure script let silly code die
This commit is contained in:
138
eval.c
138
eval.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: eval.c,v 1.5 2004/10/28 11:11:17 tg Exp $ */
|
||||
/** $MirBSD: eval.c,v 1.6 2004/10/28 11:53:41 tg Exp $ */
|
||||
/* $OpenBSD: eval.c,v 1.14 2003/11/10 21:26:39 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -10,7 +10,7 @@
|
||||
#include "ksh_dir.h"
|
||||
#include "ksh_stat.h"
|
||||
|
||||
__RCSID("$MirBSD: eval.c,v 1.5 2004/10/28 11:11:17 tg Exp $");
|
||||
__RCSID("$MirBSD: eval.c,v 1.6 2004/10/28 11:53:41 tg Exp $");
|
||||
|
||||
/*
|
||||
* string expansion
|
||||
@ -60,9 +60,7 @@ static void alt_expand(XPtrV *wp, char *start, char *exp_start,
|
||||
|
||||
/* compile and expand word */
|
||||
char *
|
||||
substitute(cp, f)
|
||||
const char *cp;
|
||||
int f;
|
||||
substitute(const char *cp, int f)
|
||||
{
|
||||
struct source *s, *sold;
|
||||
|
||||
@ -81,9 +79,7 @@ substitute(cp, f)
|
||||
* expand arg-list
|
||||
*/
|
||||
char **
|
||||
eval(ap, f)
|
||||
char **ap;
|
||||
int f;
|
||||
eval(char **ap, int f)
|
||||
{
|
||||
XPtrV w;
|
||||
|
||||
@ -108,9 +104,7 @@ eval(ap, f)
|
||||
* expand string
|
||||
*/
|
||||
char *
|
||||
evalstr(cp, f)
|
||||
char *cp;
|
||||
int f;
|
||||
evalstr(char *cp, int f)
|
||||
{
|
||||
XPtrV w;
|
||||
|
||||
@ -126,9 +120,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;
|
||||
|
||||
@ -161,10 +153,10 @@ typedef struct SubType {
|
||||
} SubType;
|
||||
|
||||
void
|
||||
expand(cp, wp, f)
|
||||
char *cp; /* input word */
|
||||
XPtrV *wp; /* output words */
|
||||
int f; /* DO* flags */
|
||||
expand(char *cp, XPtrV *wp, int f)
|
||||
/* input word */
|
||||
/* output words */
|
||||
/* DO* flags */
|
||||
{
|
||||
int UNINITIALIZED(c);
|
||||
int type; /* expansion type */
|
||||
@ -691,12 +683,12 @@ 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, int *slenp)
|
||||
|
||||
|
||||
|
||||
/* becomes qualifier type */
|
||||
/* " " len (=, :=, etc.) valid iff *stypep != 0 */
|
||||
{
|
||||
int c;
|
||||
int state; /* next state: XBASE, XARG, XSUB, XNULLSUB */
|
||||
@ -842,9 +834,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;
|
||||
@ -896,10 +886,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;
|
||||
@ -949,10 +936,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);
|
||||
|
||||
@ -972,10 +956,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;
|
||||
@ -989,12 +970,12 @@ 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, char **xpp, char *sp, XPtrV *wp, int check)
|
||||
/* dest string */
|
||||
/* ptr to dest end */
|
||||
/* source path */
|
||||
/* output list */
|
||||
/* GF_* flags */
|
||||
{
|
||||
char *np; /* next source component */
|
||||
char *xp = *xpp;
|
||||
@ -1135,56 +1116,9 @@ globit(xs, xpp, sp, wp, check)
|
||||
*--np = odirsep;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Check if p contains something that needs globbing; if it does, 0 is
|
||||
* returned; if not, p is copied into xs/xp after stripping any MAGICs
|
||||
*/
|
||||
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;
|
||||
{
|
||||
char *xp;
|
||||
int len = strlen(p);
|
||||
|
||||
XcheckN(*xs, *xpp, len);
|
||||
xp = *xpp;
|
||||
for (; *p; p++) {
|
||||
if (ISMAGIC(*p)) {
|
||||
int c = *++p;
|
||||
|
||||
if (c == '*' || c == '?')
|
||||
return 0;
|
||||
if (*p == '[') {
|
||||
char *q = p + 1;
|
||||
|
||||
if (ISMAGIC(*q) && q[1] == NOT)
|
||||
q += 2;
|
||||
if (ISMAGIC(*q) && q[1] == ']')
|
||||
q += 2;
|
||||
for (; *q; q++)
|
||||
if (ISMAGIC(*q) && *++q == ']')
|
||||
return 0;
|
||||
/* pass a literal [ through */
|
||||
}
|
||||
/* must be a MAGIC-MAGIC, or MAGIC-!, MAGIC--, etc. */
|
||||
}
|
||||
*xp++ = *p;
|
||||
}
|
||||
*xp = '\0';
|
||||
*xpp = xp;
|
||||
return 1;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/* 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;
|
||||
|
||||
@ -1214,11 +1148,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;
|
||||
@ -1256,8 +1186,7 @@ maybe_expand_tilde(p, dsp, dpp, isassign)
|
||||
*/
|
||||
|
||||
static char *
|
||||
tilde(cp)
|
||||
char *cp;
|
||||
tilde(char *cp)
|
||||
{
|
||||
char *dp;
|
||||
|
||||
@ -1283,8 +1212,7 @@ tilde(cp)
|
||||
*/
|
||||
|
||||
static char *
|
||||
homedir(name)
|
||||
char *name;
|
||||
homedir(char *name)
|
||||
{
|
||||
struct tbl *ap;
|
||||
|
||||
@ -1308,11 +1236,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 UNINITIALIZED(count);
|
||||
char *brace_start, *brace_end, *UNINITIALIZED(comma);
|
||||
|
Reference in New Issue
Block a user