version 1.42, 2015/08/20 22:32:41 |
version 1.43, 2015/11/15 06:19:22 |
|
|
|
|
#include <ctype.h> |
#include <ctype.h> |
#include <sys/types.h> |
#include <sys/types.h> |
#ifndef MAKE_BOOTSTRAP |
|
#include <regex.h> |
#include <regex.h> |
#endif |
|
#include <stddef.h> |
#include <stddef.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
|
static bool VarLoop(struct Name *, bool, Buffer, void *); |
static bool VarLoop(struct Name *, bool, Buffer, void *); |
|
|
|
|
#ifndef MAKE_BOOTSTRAP |
|
static void VarREError(int, regex_t *, const char *); |
static void VarREError(int, regex_t *, const char *); |
static bool VarRESubstitute(struct Name *, bool, Buffer, void *); |
static bool VarRESubstitute(struct Name *, bool, Buffer, void *); |
static char *do_regex(const char *, const struct Name *, void *); |
static char *do_regex(const char *, const struct Name *, void *); |
|
|
char *replace; |
char *replace; |
int flags; |
int flags; |
} VarREPattern; |
} VarREPattern; |
#endif |
|
|
|
static bool VarSubstitute(struct Name *, bool, Buffer, void *); |
static bool VarSubstitute(struct Name *, bool, Buffer, void *); |
static char *VarGetPattern(SymTable *, int, const char **, int, int, |
static char *VarGetPattern(SymTable *, int, const char **, int, int, |
|
|
match_mod = {false, get_stringarg, NULL, VarMatch, free_stringarg}, |
match_mod = {false, get_stringarg, NULL, VarMatch, free_stringarg}, |
nomatch_mod = {false, get_stringarg, NULL, VarNoMatch, free_stringarg}, |
nomatch_mod = {false, get_stringarg, NULL, VarNoMatch, free_stringarg}, |
subst_mod = {false, get_spatternarg, NULL, VarSubstitute, free_patternarg}, |
subst_mod = {false, get_spatternarg, NULL, VarSubstitute, free_patternarg}, |
#ifndef MAKE_BOOTSTRAP |
|
resubst_mod = {false, get_patternarg, do_regex, NULL, free_patternarg}, |
resubst_mod = {false, get_patternarg, do_regex, NULL, free_patternarg}, |
#endif |
|
quote_mod = {false, check_quote, VarQuote, NULL , free}, |
quote_mod = {false, check_quote, VarQuote, NULL , free}, |
tail_mod = {false, check_empty, NULL, VarTail, NULL}, |
tail_mod = {false, check_empty, NULL, VarTail, NULL}, |
head_mod = {false, check_empty, NULL, VarHead, NULL}, |
head_mod = {false, check_empty, NULL, VarHead, NULL}, |
|
|
choose_mod['M'] = &match_mod; |
choose_mod['M'] = &match_mod; |
choose_mod['N'] = &nomatch_mod; |
choose_mod['N'] = &nomatch_mod; |
choose_mod['S'] = &subst_mod; |
choose_mod['S'] = &subst_mod; |
#ifndef MAKE_BOOTSTRAP |
|
choose_mod['C'] = &resubst_mod; |
choose_mod['C'] = &resubst_mod; |
#endif |
|
choose_mod['Q'] = "e_mod; |
choose_mod['Q'] = "e_mod; |
choose_mod['T'] = &tail_mod; |
choose_mod['T'] = &tail_mod; |
choose_mod['H'] = &head_mod; |
choose_mod['H'] = &head_mod; |
|
|
return true; |
return true; |
} |
} |
|
|
#ifndef MAKE_BOOTSTRAP |
|
/*- |
/*- |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
* VarREError -- |
* VarREError -- |
|
|
} |
} |
return addSpace||added; |
return addSpace||added; |
} |
} |
#endif |
|
|
|
/*- |
/*- |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
|
|
free(vp); |
free(vp); |
} |
} |
|
|
#ifndef MAKE_BOOTSTRAP |
|
static char * |
static char * |
do_regex(const char *s, const struct Name *n UNUSED, void *arg) |
do_regex(const char *s, const struct Name *n UNUSED, void *arg) |
{ |
{ |
|
|
free(p2.matches); |
free(p2.matches); |
return result; |
return result; |
} |
} |
#endif |
|
|
|
char * |
char * |
VarModifiers_Apply(char *str, const struct Name *name, SymTable *ctxt, |
VarModifiers_Apply(char *str, const struct Name *name, SymTable *ctxt, |