diff options
Diffstat (limited to 'do/each')
-rw-r--r-- | do/each | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/do/each b/do/each new file mode 100644 index 0000000000..735012659e --- /dev/null +++ b/do/each @@ -0,0 +1,33 @@ +int +do_each(TARG,hash,gimme,arglast) +STR *TARG; +HASH *hash; +int gimme; +int *arglast; +{ + STR **st = stack->ary_array; + register int sp = arglast[0]; + HENT *entry = hiternext(hash); + int i; + char *tmps; + + if (mystrk) { + str_free(mystrk); + mystrk = Nullstr; + } + + if (entry) { + if (gimme == G_ARRAY) { + tmps = hiterkey(entry, &i); + if (!i) + tmps = ""; + st[++sp] = mystrk = str_make(tmps,i); + } + st[++sp] = TARG; + str_sset(TARG,hiterval(hash,entry)); + STABSET(TARG); + return sp; + } + else + return sp; +} |