diff --git a/cpp/frameset.cpp b/cpp/frameset.cpp index 27edc0b..06ce6bd 100644 --- a/cpp/frameset.cpp +++ b/cpp/frameset.cpp @@ -83,7 +83,7 @@ void FrameSet::handleMatch(const internal::RangePatternMatch* match, Status* ok) ok->clearError(); Frame start, end; - size_t step = 1; + long step = 1; switch (num) { diff --git a/cpp/private/frameset_p.cpp b/cpp/private/frameset_p.cpp index b27bb77..17b867e 100644 --- a/cpp/private/frameset_p.cpp +++ b/cpp/private/frameset_p.cpp @@ -28,6 +28,9 @@ bool getRangePatternMatch(RangePatternMatch &match, const std::string &range) { // Complex range: 1-10x2 static const char* s_pattern3 = R"(^(-?\d+)-(-?\d+)([:xy])(-?\d+)$)"; + match.stepMod.clear(); + match.step = 1; + #if HAVE_REGEX == 1 static const auto flags = std::regex_constants::optimize|std::regex_constants::ECMAScript; static const std::regex s_rxRange1(s_pattern1, flags); @@ -36,9 +39,6 @@ bool getRangePatternMatch(RangePatternMatch &match, const std::string &range) { std::smatch submatch; - match.stepMod.clear(); - match.step = 1; - if ( std::regex_match(range, submatch, s_rxRange1) ) { match.matches = 2; match.start = std::stol(submatch[1].str(), nullptr); @@ -58,7 +58,7 @@ bool getRangePatternMatch(RangePatternMatch &match, const std::string &range) { match.start = std::stol(submatch[1].str(), nullptr); match.end = std::stol(submatch[2].str(), nullptr); match.stepMod = submatch[3].str(); - match.step = std::stoul(submatch[4].str(), nullptr); + match.step = std::stol(submatch[4].str(), nullptr); return true; } #else diff --git a/cpp/private/frameset_p.h b/cpp/private/frameset_p.h index afda85a..6640a08 100644 --- a/cpp/private/frameset_p.h +++ b/cpp/private/frameset_p.h @@ -37,7 +37,7 @@ struct RangePatternMatch { ; Frame start; Frame end; std::string stepMod; - size_t step; + long step; }; // Regular expression patterns for matching frame set strings. diff --git a/cpp/ranges/ranges.cpp b/cpp/ranges/ranges.cpp index 68cb35b..258779d 100644 --- a/cpp/ranges/ranges.cpp +++ b/cpp/ranges/ranges.cpp @@ -11,7 +11,7 @@ namespace fileseq { -Range::Range(long start, long end, int step) +Range::Range(long start, long end, long step) : m_start(start) , m_end(end) , m_step(step) @@ -103,7 +103,7 @@ bool Range::contains(long value) const { } -long Range::closestInRange(long value, long start, long end, int step) const { +long Range::closestInRange(long value, long start, long end, long step) const { // Possibly clamp the value if it is outside the range if (end >= start) { if (value < start) { @@ -137,7 +137,7 @@ long Range::value(size_t idx, Status* ok) const { // Calculate the value as an offset from the start long l_start = start(); long l_end = end(); - int l_step = step(); + long l_step = step(); long val = l_start + (l_step * idx); @@ -303,7 +303,7 @@ bool predDecRangeDone(long val, long end) { return val >= end; } -void Ranges::appendUnique(long start, long end, int step) { +void Ranges::appendUnique(long start, long end, long step) { if (step == 0) { // Invalid step. Do nothing. return; @@ -451,7 +451,7 @@ void Ranges::normalized(Ranges &outRanges, bool invert) const { long start = 0; long end = 0; long current = 0; - int step = 0; + long step = 0; bool keepValue = false; size_t pending = 0; diff --git a/cpp/ranges/ranges.h b/cpp/ranges/ranges.h index 58d49ae..334a59b 100644 --- a/cpp/ranges/ranges.h +++ b/cpp/ranges/ranges.h @@ -34,7 +34,7 @@ class RangeIterator { // Advance to the next value. bool next(); - // Returns whether the interator points to a valid range + // Returns whether the iterator points to a valid range bool isValid() const { return m_range != NULL; } private: @@ -58,7 +58,7 @@ class Range { // If step value == 0, it will automatically default // to a propert increment depending on whether start is // less than or greather than end. - Range(long start, long end, int step=0); + Range(long start, long end, long step=0); virtual ~Range() {} @@ -77,7 +77,7 @@ class Range { long end() const; // returns the stepping value used in the range - int step() const { return m_step; } + long step() const { return m_step; } // returns the smallest value in the range long min() const { return (start() < end() ? start() : end()); } @@ -122,12 +122,12 @@ class Range { // closestInRange finds the closest valid value within the range, // to a given value. Values outside the range are clipped to either // the range min or max. - long closestInRange(long value, long start, long end, int step=0) const; + long closestInRange(long value, long start, long end, long step=0) const; private: long m_start; long m_end; - int m_step; + long m_step; mutable long m_cachedEnd; mutable bool m_isEndCached; @@ -221,14 +221,14 @@ class Ranges { // to the total range list. // Values in new range may duplicate values in // existing ranges. - void append(long start, long end, int step=0) { + void append(long start, long end, long step=0) { m_blocks.push_back(new Range(start, end, step)); } // creates and adds another range of values // to the total range list. Only unique values from the // given range are appended to the total range. - void appendUnique(long start, long end, int step=0); + void appendUnique(long start, long end, long step=0); // returns true if a given value is a valid // value within the total range.