version 1.39, 2014/09/21 13:43:25 |
version 1.40, 2015/01/23 13:18:40 |
|
|
static bool |
static bool |
VarUniq(struct Name *word, bool addSpace, Buffer buf, void *lastp) |
VarUniq(struct Name *word, bool addSpace, Buffer buf, void *lastp) |
{ |
{ |
struct Name *last = (struct Name *)lastp; |
struct Name *last = lastp; |
|
|
/* does not match */ |
/* does not match */ |
if (last->s == NULL || last->e - last->s != word->e - word->s || |
if (last->s == NULL || last->e - last->s != word->e - word->s || |
|
|
static bool |
static bool |
VarLoop(struct Name *word, bool addSpace, Buffer buf, void *vp) |
VarLoop(struct Name *word, bool addSpace, Buffer buf, void *vp) |
{ |
{ |
struct LoopStuff *v = (struct LoopStuff *)vp; |
struct LoopStuff *v = vp; |
|
|
if (addSpace) |
if (addSpace) |
Buf_AddSpace(buf); |
Buf_AddSpace(buf); |
|
|
static char * |
static char * |
finish_loop(const char *s, const struct Name *n UNUSED , void *p) |
finish_loop(const char *s, const struct Name *n UNUSED , void *p) |
{ |
{ |
struct LoopStuff *l = (struct LoopStuff *)p; |
struct LoopStuff *l = p; |
|
|
return Var_Subst(s, NULL, l->err); |
return Var_Subst(s, NULL, l->err); |
} |
} |
|
|
static char * |
static char * |
do_def(const char *s, const struct Name *n UNUSED, void *arg) |
do_def(const char *s, const struct Name *n UNUSED, void *arg) |
{ |
{ |
VarPattern *v = (VarPattern *)arg; |
VarPattern *v = arg; |
if (s == NULL) { |
if (s == NULL) { |
free_patternarg(v); |
free_patternarg(v); |
return NULL; |
return NULL; |
|
|
static char * |
static char * |
do_undef(const char *s, const struct Name *n UNUSED, void *arg) |
do_undef(const char *s, const struct Name *n UNUSED, void *arg) |
{ |
{ |
VarPattern *v = (VarPattern *)arg; |
VarPattern *v = arg; |
if (s != NULL) { |
if (s != NULL) { |
free_patternarg(v); |
free_patternarg(v); |
return NULL; |
return NULL; |
|
|
static char * |
static char * |
do_assign(const char *s, const struct Name *n, void *arg) |
do_assign(const char *s, const struct Name *n, void *arg) |
{ |
{ |
VarPattern *v = (VarPattern *)arg; |
VarPattern *v = arg; |
char *msg; |
char *msg; |
char *result; |
char *result; |
|
|
|
|
static char * |
static char * |
do_exec(const char *s UNUSED, const struct Name *n UNUSED, void *arg) |
do_exec(const char *s UNUSED, const struct Name *n UNUSED, void *arg) |
{ |
{ |
VarPattern *v = (VarPattern *)arg; |
VarPattern *v = arg; |
char *msg; |
char *msg; |
char *result; |
char *result; |
|
|
|
|
{ |
{ |
size_t len; |
size_t len; |
const char *ptr; |
const char *ptr; |
VarPattern *pat = (VarPattern *)patp; |
VarPattern *pat = patp; |
|
|
if (*word->s != '\0') { |
if (*word->s != '\0') { |
if (addSpace) |
if (addSpace) |
|
|
{ |
{ |
size_t wordLen; /* Length of word */ |
size_t wordLen; /* Length of word */ |
const char *cp; /* General pointer */ |
const char *cp; /* General pointer */ |
VarPattern *pattern = (VarPattern *)patternp; |
VarPattern *pattern = patternp; |
|
|
wordLen = word->e - word->s; |
wordLen = word->e - word->s; |
if ((pattern->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) != |
if ((pattern->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) != |
|
|
static char * |
static char * |
VarQuote(const char *str, const struct Name *n UNUSED, void *islistp) |
VarQuote(const char *str, const struct Name *n UNUSED, void *islistp) |
{ |
{ |
int islist = *((int *)islistp); |
int *p = islistp; |
|
int islist = *p; |
|
|
BUFFER buf; |
BUFFER buf; |
/* This should cover most shells :-( */ |
/* This should cover most shells :-( */ |
|
|
static void |
static void |
free_looparg(void *arg) |
free_looparg(void *arg) |
{ |
{ |
struct LoopStuff *l = (struct LoopStuff *)arg; |
struct LoopStuff *l = arg; |
|
|
Var_DeleteLoopVar(l->var); |
Var_DeleteLoopVar(l->var); |
free(l->expand); |
free(l->expand); |
|
|
static void |
static void |
free_patternarg(void *p) |
free_patternarg(void *p) |
{ |
{ |
VarPattern *vp = (VarPattern *)p; |
VarPattern *vp = p; |
|
|
free(vp->lbuffer); |
free(vp->lbuffer); |
free(vp->rhs); |
free(vp->rhs); |
|
|
do_regex(const char *s, const struct Name *n UNUSED, void *arg) |
do_regex(const char *s, const struct Name *n UNUSED, void *arg) |
{ |
{ |
VarREPattern p2; |
VarREPattern p2; |
VarPattern *p = (VarPattern *)arg; |
VarPattern *p = arg; |
int error; |
int error; |
char *result; |
char *result; |
|
|