diff options
Diffstat (limited to 'cppawk-include/cons-priv.h')
-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) } |