mirror of
https://github.com/sheumann/hush.git
synced 2024-07-08 01:28:56 +00:00
uncuddle function scope brackets
This commit is contained in:
parent
1c943eb88a
commit
10a11e23ba
232
editors/awk.c
232
editors/awk.c
@ -473,8 +473,8 @@ static void syntax_error(const char * const message)
|
|||||||
|
|
||||||
/* ---- hash stuff ---- */
|
/* ---- hash stuff ---- */
|
||||||
|
|
||||||
static unsigned int hashidx(char *name) {
|
static unsigned int hashidx(char *name)
|
||||||
|
{
|
||||||
register unsigned int idx=0;
|
register unsigned int idx=0;
|
||||||
|
|
||||||
while (*name) idx = *name++ + (idx << 6) - idx;
|
while (*name) idx = *name++ + (idx << 6) - idx;
|
||||||
@ -482,8 +482,8 @@ static unsigned int hashidx(char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create new hash */
|
/* create new hash */
|
||||||
static xhash *hash_init(void) {
|
static xhash *hash_init(void)
|
||||||
|
{
|
||||||
xhash *newhash;
|
xhash *newhash;
|
||||||
|
|
||||||
newhash = (xhash *)xcalloc(1, sizeof(xhash));
|
newhash = (xhash *)xcalloc(1, sizeof(xhash));
|
||||||
@ -494,8 +494,8 @@ static xhash *hash_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* find item in hash, return ptr to data, NULL if not found */
|
/* find item in hash, return ptr to data, NULL if not found */
|
||||||
static void *hash_search(xhash *hash, char *name) {
|
static void *hash_search(xhash *hash, char *name)
|
||||||
|
{
|
||||||
hash_item *hi;
|
hash_item *hi;
|
||||||
|
|
||||||
hi = hash->items [ hashidx(name) % hash->csize ];
|
hi = hash->items [ hashidx(name) % hash->csize ];
|
||||||
@ -508,8 +508,8 @@ static void *hash_search(xhash *hash, char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* grow hash if it becomes too big */
|
/* grow hash if it becomes too big */
|
||||||
static void hash_rebuild(xhash *hash) {
|
static void hash_rebuild(xhash *hash)
|
||||||
|
{
|
||||||
unsigned int newsize, i, idx;
|
unsigned int newsize, i, idx;
|
||||||
hash_item **newitems, *hi, *thi;
|
hash_item **newitems, *hi, *thi;
|
||||||
|
|
||||||
@ -536,8 +536,8 @@ static void hash_rebuild(xhash *hash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* find item in hash, add it if necessary. Return ptr to data */
|
/* find item in hash, add it if necessary. Return ptr to data */
|
||||||
static void *hash_find(xhash *hash, char *name) {
|
static void *hash_find(xhash *hash, char *name)
|
||||||
|
{
|
||||||
hash_item *hi;
|
hash_item *hi;
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
int l;
|
int l;
|
||||||
@ -564,8 +564,8 @@ static void *hash_find(xhash *hash, char *name) {
|
|||||||
#define newfile(name) (rstream *) hash_find ( fdhash , (name) )
|
#define newfile(name) (rstream *) hash_find ( fdhash , (name) )
|
||||||
#define newfunc(name) (func *) hash_find ( fnhash , (name) )
|
#define newfunc(name) (func *) hash_find ( fnhash , (name) )
|
||||||
|
|
||||||
static void hash_remove(xhash *hash, char *name) {
|
static void hash_remove(xhash *hash, char *name)
|
||||||
|
{
|
||||||
hash_item *hi, **phi;
|
hash_item *hi, **phi;
|
||||||
|
|
||||||
phi = &(hash->items[ hashidx(name) % hash->csize ]);
|
phi = &(hash->items[ hashidx(name) % hash->csize ]);
|
||||||
@ -584,8 +584,8 @@ static void hash_remove(xhash *hash, char *name) {
|
|||||||
|
|
||||||
/* ------ some useful functions ------ */
|
/* ------ some useful functions ------ */
|
||||||
|
|
||||||
static void skip_spaces(char **s) {
|
static void skip_spaces(char **s)
|
||||||
|
{
|
||||||
register char *p = *s;
|
register char *p = *s;
|
||||||
|
|
||||||
while(*p == ' ' || *p == '\t' ||
|
while(*p == ' ' || *p == '\t' ||
|
||||||
@ -595,8 +595,8 @@ static void skip_spaces(char **s) {
|
|||||||
*s = p;
|
*s = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *nextword(char **s) {
|
static char *nextword(char **s)
|
||||||
|
{
|
||||||
register char *p = *s;
|
register char *p = *s;
|
||||||
|
|
||||||
while (*(*s)++) ;
|
while (*(*s)++) ;
|
||||||
@ -604,8 +604,8 @@ static char *nextword(char **s) {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char nextchar(char **s) {
|
static char nextchar(char **s)
|
||||||
|
{
|
||||||
register char c, *pps;
|
register char c, *pps;
|
||||||
|
|
||||||
c = *((*s)++);
|
c = *((*s)++);
|
||||||
@ -615,20 +615,20 @@ static char nextchar(char **s) {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int isalnum_(int c) {
|
static inline int isalnum_(int c)
|
||||||
|
{
|
||||||
return (isalnum(c) || c == '_');
|
return (isalnum(c) || c == '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
static FILE *afopen(const char *path, const char *mode) {
|
static FILE *afopen(const char *path, const char *mode)
|
||||||
|
{
|
||||||
return (*path == '-' && *(path+1) == '\0') ? stdin : bb_xfopen(path, mode);
|
return (*path == '-' && *(path+1) == '\0') ? stdin : bb_xfopen(path, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------- working with variables (set/get/copy/etc) -------- */
|
/* -------- working with variables (set/get/copy/etc) -------- */
|
||||||
|
|
||||||
static xhash *iamarray(var *v) {
|
static xhash *iamarray(var *v)
|
||||||
|
{
|
||||||
var *a = v;
|
var *a = v;
|
||||||
|
|
||||||
while (a->type & VF_CHILD)
|
while (a->type & VF_CHILD)
|
||||||
@ -641,8 +641,8 @@ static xhash *iamarray(var *v) {
|
|||||||
return a->x.array;
|
return a->x.array;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_array(xhash *array) {
|
static void clear_array(xhash *array)
|
||||||
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
hash_item *hi, *thi;
|
hash_item *hi, *thi;
|
||||||
|
|
||||||
@ -660,8 +660,8 @@ static void clear_array(xhash *array) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* clear a variable */
|
/* clear a variable */
|
||||||
static var *clrvar(var *v) {
|
static var *clrvar(var *v)
|
||||||
|
{
|
||||||
if (!(v->type & VF_FSTR))
|
if (!(v->type & VF_FSTR))
|
||||||
free(v->string);
|
free(v->string);
|
||||||
|
|
||||||
@ -672,8 +672,8 @@ static var *clrvar(var *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* assign string value to variable */
|
/* assign string value to variable */
|
||||||
static var *setvar_p(var *v, char *value) {
|
static var *setvar_p(var *v, char *value)
|
||||||
|
{
|
||||||
clrvar(v);
|
clrvar(v);
|
||||||
v->string = value;
|
v->string = value;
|
||||||
handle_special(v);
|
handle_special(v);
|
||||||
@ -682,22 +682,22 @@ static var *setvar_p(var *v, char *value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* same as setvar_p but make a copy of string */
|
/* same as setvar_p but make a copy of string */
|
||||||
static var *setvar_s(var *v, char *value) {
|
static var *setvar_s(var *v, char *value)
|
||||||
|
{
|
||||||
return setvar_p(v, (value && *value) ? bb_xstrdup(value) : NULL);
|
return setvar_p(v, (value && *value) ? bb_xstrdup(value) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* same as setvar_s but set USER flag */
|
/* same as setvar_s but set USER flag */
|
||||||
static var *setvar_u(var *v, char *value) {
|
static var *setvar_u(var *v, char *value)
|
||||||
|
{
|
||||||
setvar_s(v, value);
|
setvar_s(v, value);
|
||||||
v->type |= VF_USER;
|
v->type |= VF_USER;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set array element to user string */
|
/* set array element to user string */
|
||||||
static void setari_u(var *a, int idx, char *s) {
|
static void setari_u(var *a, int idx, char *s)
|
||||||
|
{
|
||||||
register var *v;
|
register var *v;
|
||||||
static char sidx[12];
|
static char sidx[12];
|
||||||
|
|
||||||
@ -707,8 +707,8 @@ static void setari_u(var *a, int idx, char *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* assign numeric value to variable */
|
/* assign numeric value to variable */
|
||||||
static var *setvar_i(var *v, double value) {
|
static var *setvar_i(var *v, double value)
|
||||||
|
{
|
||||||
clrvar(v);
|
clrvar(v);
|
||||||
v->type |= VF_NUMBER;
|
v->type |= VF_NUMBER;
|
||||||
v->number = value;
|
v->number = value;
|
||||||
@ -716,8 +716,8 @@ static var *setvar_i(var *v, double value) {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *getvar_s(var *v) {
|
static char *getvar_s(var *v)
|
||||||
|
{
|
||||||
/* if v is numeric and has no cached string, convert it to string */
|
/* if v is numeric and has no cached string, convert it to string */
|
||||||
if ((v->type & (VF_NUMBER | VF_CACHED)) == VF_NUMBER) {
|
if ((v->type & (VF_NUMBER | VF_CACHED)) == VF_NUMBER) {
|
||||||
fmt_num(buf, MAXVARFMT, getvar_s(V[CONVFMT]), v->number, TRUE);
|
fmt_num(buf, MAXVARFMT, getvar_s(V[CONVFMT]), v->number, TRUE);
|
||||||
@ -727,8 +727,8 @@ static char *getvar_s(var *v) {
|
|||||||
return (v->string == NULL) ? "" : v->string;
|
return (v->string == NULL) ? "" : v->string;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double getvar_i(var *v) {
|
static double getvar_i(var *v)
|
||||||
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if ((v->type & (VF_NUMBER | VF_CACHED)) == 0) {
|
if ((v->type & (VF_NUMBER | VF_CACHED)) == 0) {
|
||||||
@ -749,8 +749,8 @@ static double getvar_i(var *v) {
|
|||||||
return v->number;
|
return v->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
static var *copyvar(var *dest, var *src) {
|
static var *copyvar(var *dest, var *src)
|
||||||
|
{
|
||||||
if (dest != src) {
|
if (dest != src) {
|
||||||
clrvar(dest);
|
clrvar(dest);
|
||||||
dest->type |= (src->type & ~VF_DONTTOUCH);
|
dest->type |= (src->type & ~VF_DONTTOUCH);
|
||||||
@ -762,21 +762,21 @@ static var *copyvar(var *dest, var *src) {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
static var *incvar(var *v) {
|
static var *incvar(var *v)
|
||||||
|
{
|
||||||
return setvar_i(v, getvar_i(v)+1.);
|
return setvar_i(v, getvar_i(v)+1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return true if v is number or numeric string */
|
/* return true if v is number or numeric string */
|
||||||
static int is_numeric(var *v) {
|
static int is_numeric(var *v)
|
||||||
|
{
|
||||||
getvar_i(v);
|
getvar_i(v);
|
||||||
return ((v->type ^ VF_DIRTY) & (VF_NUMBER | VF_USER | VF_DIRTY));
|
return ((v->type ^ VF_DIRTY) & (VF_NUMBER | VF_USER | VF_DIRTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return 1 when value of v corresponds to true, 0 otherwise */
|
/* return 1 when value of v corresponds to true, 0 otherwise */
|
||||||
static int istrue(var *v) {
|
static int istrue(var *v)
|
||||||
|
{
|
||||||
if (is_numeric(v))
|
if (is_numeric(v))
|
||||||
return (v->number == 0) ? 0 : 1;
|
return (v->number == 0) ? 0 : 1;
|
||||||
else
|
else
|
||||||
@ -784,8 +784,8 @@ static int istrue(var *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* temporary variables allocator. Last allocated should be first freed */
|
/* temporary variables allocator. Last allocated should be first freed */
|
||||||
static var *nvalloc(int n) {
|
static var *nvalloc(int n)
|
||||||
|
{
|
||||||
nvblock *pb = NULL;
|
nvblock *pb = NULL;
|
||||||
var *v, *r;
|
var *v, *r;
|
||||||
int size;
|
int size;
|
||||||
@ -818,8 +818,8 @@ static var *nvalloc(int n) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nvfree(var *v) {
|
static void nvfree(var *v)
|
||||||
|
{
|
||||||
var *p;
|
var *p;
|
||||||
|
|
||||||
if (v < cb->nv || v >= cb->pos)
|
if (v < cb->nv || v >= cb->pos)
|
||||||
@ -848,8 +848,8 @@ static void nvfree(var *v) {
|
|||||||
/* Parse next token pointed by global pos, place results into global t.
|
/* Parse next token pointed by global pos, place results into global t.
|
||||||
* If token isn't expected, give away. Return token class
|
* If token isn't expected, give away. Return token class
|
||||||
*/
|
*/
|
||||||
static unsigned long next_token(unsigned long expected) {
|
static unsigned long next_token(unsigned long expected)
|
||||||
|
{
|
||||||
char *p, *pp, *s;
|
char *p, *pp, *s;
|
||||||
char *tl;
|
char *tl;
|
||||||
unsigned long tc, *ti;
|
unsigned long tc, *ti;
|
||||||
@ -999,8 +999,8 @@ static unsigned long next_token(unsigned long expected) {
|
|||||||
|
|
||||||
static void rollback_token(void) { t.rollback = TRUE; }
|
static void rollback_token(void) { t.rollback = TRUE; }
|
||||||
|
|
||||||
static node *new_node(unsigned long info) {
|
static node *new_node(unsigned long info)
|
||||||
|
{
|
||||||
register node *n;
|
register node *n;
|
||||||
|
|
||||||
n = (node *)xcalloc(sizeof(node), 1);
|
n = (node *)xcalloc(sizeof(node), 1);
|
||||||
@ -1009,8 +1009,8 @@ static node *new_node(unsigned long info) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static node *mk_re_node(char *s, node *n, regex_t *re) {
|
static node *mk_re_node(char *s, node *n, regex_t *re)
|
||||||
|
{
|
||||||
n->info = OC_REGEXP;
|
n->info = OC_REGEXP;
|
||||||
n->l.re = re;
|
n->l.re = re;
|
||||||
n->r.ire = re + 1;
|
n->r.ire = re + 1;
|
||||||
@ -1020,16 +1020,16 @@ static node *mk_re_node(char *s, node *n, regex_t *re) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static node *condition(void) {
|
static node *condition(void)
|
||||||
|
{
|
||||||
next_token(TC_SEQSTART);
|
next_token(TC_SEQSTART);
|
||||||
return parse_expr(TC_SEQTERM);
|
return parse_expr(TC_SEQTERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse expression terminated by given argument, return ptr
|
/* parse expression terminated by given argument, return ptr
|
||||||
* to built subtree. Terminator is eaten by parse_expr */
|
* to built subtree. Terminator is eaten by parse_expr */
|
||||||
static node *parse_expr(unsigned long iexp) {
|
static node *parse_expr(unsigned long iexp)
|
||||||
|
{
|
||||||
node sn;
|
node sn;
|
||||||
node *cn = &sn;
|
node *cn = &sn;
|
||||||
node *vn, *glptr;
|
node *vn, *glptr;
|
||||||
@ -1144,8 +1144,8 @@ static node *parse_expr(unsigned long iexp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add node to chain. Return ptr to alloc'd node */
|
/* add node to chain. Return ptr to alloc'd node */
|
||||||
static node *chain_node(unsigned long info) {
|
static node *chain_node(unsigned long info)
|
||||||
|
{
|
||||||
register node *n;
|
register node *n;
|
||||||
|
|
||||||
if (! seq->first)
|
if (! seq->first)
|
||||||
@ -1164,8 +1164,8 @@ static node *chain_node(unsigned long info) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chain_expr(unsigned long info) {
|
static void chain_expr(unsigned long info)
|
||||||
|
{
|
||||||
node *n;
|
node *n;
|
||||||
|
|
||||||
n = chain_node(info);
|
n = chain_node(info);
|
||||||
@ -1174,8 +1174,8 @@ static void chain_expr(unsigned long info) {
|
|||||||
rollback_token();
|
rollback_token();
|
||||||
}
|
}
|
||||||
|
|
||||||
static node *chain_loop(node *nn) {
|
static node *chain_loop(node *nn)
|
||||||
|
{
|
||||||
node *n, *n2, *save_brk, *save_cont;
|
node *n, *n2, *save_brk, *save_cont;
|
||||||
|
|
||||||
save_brk = break_ptr;
|
save_brk = break_ptr;
|
||||||
@ -1198,8 +1198,8 @@ static node *chain_loop(node *nn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* parse group and attach it to chain */
|
/* parse group and attach it to chain */
|
||||||
static void chain_group(void) {
|
static void chain_group(void)
|
||||||
|
{
|
||||||
unsigned long c;
|
unsigned long c;
|
||||||
node *n, *n2, *n3;
|
node *n, *n2, *n3;
|
||||||
|
|
||||||
@ -1300,8 +1300,8 @@ static void chain_group(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_program(char *p) {
|
static void parse_program(char *p)
|
||||||
|
{
|
||||||
unsigned long tclass;
|
unsigned long tclass;
|
||||||
node *cn;
|
node *cn;
|
||||||
func *f;
|
func *f;
|
||||||
@ -1363,8 +1363,8 @@ static void parse_program(char *p) {
|
|||||||
|
|
||||||
/* -------- program execution part -------- */
|
/* -------- program execution part -------- */
|
||||||
|
|
||||||
static node *mk_splitter(char *s, tsplitter *spl) {
|
static node *mk_splitter(char *s, tsplitter *spl)
|
||||||
|
{
|
||||||
register regex_t *re, *ire;
|
register regex_t *re, *ire;
|
||||||
node *n;
|
node *n;
|
||||||
|
|
||||||
@ -1388,8 +1388,8 @@ static node *mk_splitter(char *s, tsplitter *spl) {
|
|||||||
* storage space. Return ptr to regex (if result points to preg, it should
|
* storage space. Return ptr to regex (if result points to preg, it should
|
||||||
* be later regfree'd manually
|
* be later regfree'd manually
|
||||||
*/
|
*/
|
||||||
static regex_t *as_regex(node *op, regex_t *preg) {
|
static regex_t *as_regex(node *op, regex_t *preg)
|
||||||
|
{
|
||||||
var *v;
|
var *v;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
@ -1405,15 +1405,15 @@ static regex_t *as_regex(node *op, regex_t *preg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* gradually increasing buffer */
|
/* gradually increasing buffer */
|
||||||
static void qrealloc(char **b, int n, int *size) {
|
static void qrealloc(char **b, int n, int *size)
|
||||||
|
{
|
||||||
if (! *b || n >= *size)
|
if (! *b || n >= *size)
|
||||||
*b = xrealloc(*b, *size = n + (n>>1) + 80);
|
*b = xrealloc(*b, *size = n + (n>>1) + 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* resize field storage space */
|
/* resize field storage space */
|
||||||
static void fsrealloc(int size) {
|
static void fsrealloc(int size)
|
||||||
|
{
|
||||||
static int maxfields = 0;
|
static int maxfields = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1435,8 +1435,8 @@ static void fsrealloc(int size) {
|
|||||||
nfields = size;
|
nfields = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int awk_split(char *s, node *spl, char **slist) {
|
static int awk_split(char *s, node *spl, char **slist)
|
||||||
|
{
|
||||||
int l, n=0;
|
int l, n=0;
|
||||||
char c[4];
|
char c[4];
|
||||||
char *s1;
|
char *s1;
|
||||||
@ -1496,8 +1496,8 @@ static int awk_split(char *s, node *spl, char **slist) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void split_f0(void) {
|
static void split_f0(void)
|
||||||
|
{
|
||||||
static char *fstrings = NULL;
|
static char *fstrings = NULL;
|
||||||
int i, n;
|
int i, n;
|
||||||
char *s;
|
char *s;
|
||||||
@ -1523,8 +1523,8 @@ static void split_f0(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* perform additional actions when some internal variables changed */
|
/* perform additional actions when some internal variables changed */
|
||||||
static void handle_special(var *v) {
|
static void handle_special(var *v)
|
||||||
|
{
|
||||||
int n;
|
int n;
|
||||||
char *b, *sep, *s;
|
char *b, *sep, *s;
|
||||||
int sl, l, len, i, bsize;
|
int sl, l, len, i, bsize;
|
||||||
@ -1576,8 +1576,8 @@ static void handle_special(var *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* step through func/builtin/etc arguments */
|
/* step through func/builtin/etc arguments */
|
||||||
static node *nextarg(node **pn) {
|
static node *nextarg(node **pn)
|
||||||
|
{
|
||||||
node *n;
|
node *n;
|
||||||
|
|
||||||
n = *pn;
|
n = *pn;
|
||||||
@ -1590,8 +1590,8 @@ static node *nextarg(node **pn) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hashwalk_init(var *v, xhash *array) {
|
static void hashwalk_init(var *v, xhash *array)
|
||||||
|
{
|
||||||
char **w;
|
char **w;
|
||||||
hash_item *hi;
|
hash_item *hi;
|
||||||
int i;
|
int i;
|
||||||
@ -1612,8 +1612,8 @@ static void hashwalk_init(var *v, xhash *array) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hashwalk_next(var *v) {
|
static int hashwalk_next(var *v)
|
||||||
|
{
|
||||||
char **w;
|
char **w;
|
||||||
|
|
||||||
w = v->x.walker;
|
w = v->x.walker;
|
||||||
@ -1625,15 +1625,15 @@ static int hashwalk_next(var *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* evaluate node, return 1 when result is true, 0 otherwise */
|
/* evaluate node, return 1 when result is true, 0 otherwise */
|
||||||
static int ptest(node *pattern) {
|
static int ptest(node *pattern)
|
||||||
|
{
|
||||||
static var v;
|
static var v;
|
||||||
|
|
||||||
return istrue(evaluate(pattern, &v));
|
return istrue(evaluate(pattern, &v));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read next record from stream rsm into a variable v */
|
/* read next record from stream rsm into a variable v */
|
||||||
static int awk_getline(rstream *rsm, var *v) {
|
static int awk_getline(rstream *rsm, var *v)
|
||||||
|
{
|
||||||
char *b;
|
char *b;
|
||||||
regmatch_t pmatch[2];
|
regmatch_t pmatch[2];
|
||||||
int a, p, pp=0, size;
|
int a, p, pp=0, size;
|
||||||
@ -1724,8 +1724,8 @@ static int awk_getline(rstream *rsm, var *v) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fmt_num(char *b, int size, char *format, double n, int int_as_int) {
|
static int fmt_num(char *b, int size, char *format, double n, int int_as_int)
|
||||||
|
{
|
||||||
int r=0;
|
int r=0;
|
||||||
char c, *s=format;
|
char c, *s=format;
|
||||||
|
|
||||||
@ -1746,8 +1746,8 @@ static int fmt_num(char *b, int size, char *format, double n, int int_as_int) {
|
|||||||
|
|
||||||
|
|
||||||
/* formatted output into an allocated buffer, return ptr to buffer */
|
/* formatted output into an allocated buffer, return ptr to buffer */
|
||||||
static char *awk_printf(node *n) {
|
static char *awk_printf(node *n)
|
||||||
|
{
|
||||||
char *b = NULL;
|
char *b = NULL;
|
||||||
char *fmt, *s, *s1, *f;
|
char *fmt, *s, *s1, *f;
|
||||||
int i, j, incr, bsize;
|
int i, j, incr, bsize;
|
||||||
@ -1804,8 +1804,8 @@ static char *awk_printf(node *n) {
|
|||||||
* all matches. If src or dst is NULL, use $0. If ex=TRUE, enable
|
* all matches. If src or dst is NULL, use $0. If ex=TRUE, enable
|
||||||
* subexpression matching (\1-\9)
|
* subexpression matching (\1-\9)
|
||||||
*/
|
*/
|
||||||
static int awk_sub(node *rn, char *repl, int nm, var *src, var *dest, int ex) {
|
static int awk_sub(node *rn, char *repl, int nm, var *src, var *dest, int ex)
|
||||||
|
{
|
||||||
char *ds = NULL;
|
char *ds = NULL;
|
||||||
char *sp, *s;
|
char *sp, *s;
|
||||||
int c, i, j, di, rl, so, eo, nbs, n, dssize;
|
int c, i, j, di, rl, so, eo, nbs, n, dssize;
|
||||||
@ -1870,8 +1870,8 @@ static int awk_sub(node *rn, char *repl, int nm, var *src, var *dest, int ex) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static var *exec_builtin(node *op, var *res) {
|
static var *exec_builtin(node *op, var *res)
|
||||||
|
{
|
||||||
int (*to_xxx)(int);
|
int (*to_xxx)(int);
|
||||||
var *tv;
|
var *tv;
|
||||||
node *an[4];
|
node *an[4];
|
||||||
@ -2030,8 +2030,8 @@ lo_cont:
|
|||||||
*/
|
*/
|
||||||
#define XC(n) ((n) >> 8)
|
#define XC(n) ((n) >> 8)
|
||||||
|
|
||||||
static var *evaluate(node *op, var *res) {
|
static var *evaluate(node *op, var *res)
|
||||||
|
{
|
||||||
/* This procedure is recursive so we should count every byte */
|
/* This procedure is recursive so we should count every byte */
|
||||||
static var *fnargs = NULL;
|
static var *fnargs = NULL;
|
||||||
static unsigned int seed = 1;
|
static unsigned int seed = 1;
|
||||||
@ -2541,8 +2541,8 @@ re_cont:
|
|||||||
|
|
||||||
/* -------- main & co. -------- */
|
/* -------- main & co. -------- */
|
||||||
|
|
||||||
static int awk_exit(int r) {
|
static int awk_exit(int r)
|
||||||
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
hash_item *hi;
|
hash_item *hi;
|
||||||
static var tv;
|
static var tv;
|
||||||
@ -2568,8 +2568,8 @@ static int awk_exit(int r) {
|
|||||||
|
|
||||||
/* if expr looks like "var=value", perform assignment and return 1,
|
/* if expr looks like "var=value", perform assignment and return 1,
|
||||||
* otherwise return 0 */
|
* otherwise return 0 */
|
||||||
static int is_assignment(char *expr) {
|
static int is_assignment(char *expr)
|
||||||
|
{
|
||||||
char *exprc, *s, *s0, *s1;
|
char *exprc, *s, *s0, *s1;
|
||||||
|
|
||||||
exprc = bb_xstrdup(expr);
|
exprc = bb_xstrdup(expr);
|
||||||
@ -2590,8 +2590,8 @@ static int is_assignment(char *expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* switch to next input file */
|
/* switch to next input file */
|
||||||
static rstream *next_input_file(void) {
|
static rstream *next_input_file(void)
|
||||||
|
{
|
||||||
static rstream rsm;
|
static rstream rsm;
|
||||||
FILE *F = NULL;
|
FILE *F = NULL;
|
||||||
char *fname, *ind;
|
char *fname, *ind;
|
||||||
@ -2621,8 +2621,8 @@ static rstream *next_input_file(void) {
|
|||||||
return &rsm;
|
return &rsm;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int awk_main(int argc, char **argv) {
|
extern int awk_main(int argc, char **argv)
|
||||||
|
{
|
||||||
char *s, *s1;
|
char *s, *s1;
|
||||||
int i, j, c;
|
int i, j, c;
|
||||||
var *v;
|
var *v;
|
||||||
|
Loading…
Reference in New Issue
Block a user