diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-04-22 21:39:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-04-22 21:39:21 -0700 |
commit | 44e30eb85147c413c7e4959c2d8e50cf1de673a8 (patch) | |
tree | 31c1cfaef75c2a25da9931dd476c89d923187db8 /cppawk-include | |
parent | 83cca68f449d207c2a8862e3ef3a6e815cb02e91 (diff) | |
download | cppawk-44e30eb85147c413c7e4959c2d8e50cf1de673a8.tar.gz cppawk-44e30eb85147c413c7e4959c2d8e50cf1de673a8.tar.bz2 cppawk-44e30eb85147c413c7e4959c2d8e50cf1de673a8.zip |
fields: new parameters to select subrange.
Diffstat (limited to 'cppawk-include')
-rw-r--r-- | cppawk-include/cons-priv.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/cppawk-include/cons-priv.h b/cppawk-include/cons-priv.h index 6ca2c05..172f20f 100644 --- a/cppawk-include/cons-priv.h +++ b/cppawk-include/cons-priv.h @@ -336,12 +336,33 @@ function __keys(__array, } -function __fields( __tmp, __i, __val) +function __fields(__start, __count, + __tmp, __end, __val) { + if (!__present(__start)) + __start = 1 + + if (!__present(__count)) + __count = NF - __start + 1 + + if (__count < 1) + return __nil + + __end = __start + __count - 1 + + if (__end > NF) + __end = NF + + if (__start < 1) + __start = 1 + + if (__start > __end) + return __nil + __tmp = __list_begin() - __dofields (__i, __val) - __tmp = __list_add(__tmp, __val) + for (; __start <= __end; __start++) + __tmp = __list_add(__tmp, $(__start)) return __list_end(__tmp) } |