diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2019-09-01 11:48:01 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2019-09-01 11:48:01 -0400 |
commit | 5c41849e0e78e45db0dc4421f1779ef7bec726da (patch) | |
tree | ab2ac8627c02a10f763650d30d58aac4b4c372ab /builtin.c | |
parent | 8cc45af919dc56011dbf4c8965b9c1e4784e56d7 (diff) | |
download | egawk-5c41849e0e78e45db0dc4421f1779ef7bec726da.tar.gz egawk-5c41849e0e78e45db0dc4421f1779ef7bec726da.tar.bz2 egawk-5c41849e0e78e45db0dc4421f1779ef7bec726da.zip |
Hack the typeof function to return memory count info when the 2nd arg is PROCINFO.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -4049,8 +4049,19 @@ do_typeof(int nargs) /* Node_var_array is never UPREF'ed */ res = "array"; deref = false; - if (dbg) + if (dbg) { assoc_set(dbg, make_string("array_type", 10), make_string(arg->array_funcs->name, strlen(arg->array_funcs->name))); + if (arg == PROCINFO_node) { + int i; + for (i = 0; i < BLOCK_MAX; i++) { + char *p; + size_t l = 6 + strlen(nextfree[i].name); + emalloc(p, char *, l+1, "do_typeof"); + sprintf(p, "count_%s", nextfree[i].name); + assoc_set(dbg, make_str_node(p, l, ALREADY_MALLOCED), make_number((AWKNUM) (nextfree[i].cnt))); + } + } + } break; case Node_val: switch (fixtype(arg)->flags & (STRING|NUMBER|USER_INPUT|REGEX)) { |