diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-07-19 10:59:11 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-07-19 10:59:11 -0700 |
commit | bb4a05032bca677db30699e590e0595d255604ab (patch) | |
tree | 320bb7e0ce2afe205fb42da9619d1b831af5cf8d /builtin_set.cpp | |
parent | 7039e01136dc6365251a45fc15f8d7b4e52f6167 (diff) | |
parent | b25b5bf5f6b2bb6b06ab3d4a460e65a973c3b7a9 (diff) |
Merge branch 'index_range'
Diffstat (limited to 'builtin_set.cpp')
-rw-r--r-- | builtin_set.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/builtin_set.cpp b/builtin_set.cpp index 5915e91d..57b47759 100644 --- a/builtin_set.cpp +++ b/builtin_set.cpp @@ -238,9 +238,31 @@ static int parse_index( std::vector<long> &indexes, l_ind = var_count+l_ind+1; } - indexes.push_back( l_ind ); src = end; + if ( *src==L'.' && *(src+1)==L'.' ){ + src+=2; + long l_ind2 = wcstol( src, &end, 10 ); + if( end==src || errno ) + { + return 1; + } + src = end; + + if( l_ind2 < 0 ) + { + l_ind2 = var_count+l_ind2+1; + } + int direction = l_ind2<l_ind ? -1 : 1 ; + for (long jjj = l_ind; jjj*direction <= l_ind2*direction; jjj+=direction) { + // debug(0, L"Expand range [set]: %i\n", jjj); + indexes.push_back( jjj ); count++; + } + } + else { + indexes.push_back( l_ind ); + count++; + } while (iswspace(*src)) src++; } |