[iter] Allow negative step in hb_iota()
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 9 May 2019 18:20:41 +0000 (11:20 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 9 May 2019 18:31:13 +0000 (11:31 -0700)
src/hb-iter.hh

index 1f3c819..a998125 100644 (file)
@@ -567,7 +567,7 @@ struct
 {
   template <typename T = unsigned, typename S = unsigned> hb_counter_iter_t<T, S>
   operator () (T start = 0u, S&& step = 1u) const
-  { return hb_counter_iter_t<T, S> (start, hb_int_max (T), step); }
+  { return hb_counter_iter_t<T, S> (start, step >= 0 ? hb_int_max (T) : hb_int_min (T), step); }
 }
 HB_FUNCOBJ (hb_iota);
 struct