From 64d9a383186a3b45b7e3ef3ae65ced13ff983202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Wed, 12 May 2010 11:50:27 +0200 Subject: [PATCH] Macro-processor: integer ranges with lower bound greater than upper bound are now empty (for consistency with MATLAB) --- macro/MacroValue.cc | 6 ------ macro/MacroValue.hh | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/macro/MacroValue.cc b/macro/MacroValue.cc index d2118075..98833cab 100644 --- a/macro/MacroValue.cc +++ b/macro/MacroValue.cc @@ -325,12 +325,6 @@ IntMV::new_range(MacroDriver &driver, const MacroValue *mv1, const MacroValue *m int v2 = mv2i->value; vector result; - if (v2 < v1) - { - int x = v2; - v2 = v1; - v1 = x; - } for (; v1 <= v2; v1++) result.push_back(v1); return new ArrayMV(driver, result); diff --git a/macro/MacroValue.hh b/macro/MacroValue.hh index 52b566f4..e379a602 100644 --- a/macro/MacroValue.hh +++ b/macro/MacroValue.hh @@ -153,7 +153,7 @@ public: //! Creates a integer range /*! Arguments must be of type IntMV. Returns an integer array containing all integers between mv1 and mv2. - If mv2 < mv1, constructs the range in decreasing order. + If mv2 < mv1, returns an empty range (for consistency with MATLAB). */ static const MacroValue *new_range(MacroDriver &driver, const MacroValue *mv1, const MacroValue *mv2) throw (TypeError); };