From 2a3a0acaf8aee4904e9050f4b07befa71ba7f743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr> 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) (cherry picked from commit 891ad2256464580b1a831b3508c1a82b1e1c66d3) --- preprocessor/macro/MacroValue.cc | 6 ------ preprocessor/macro/MacroValue.hh | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/preprocessor/macro/MacroValue.cc b/preprocessor/macro/MacroValue.cc index d211807560..98833caba4 100644 --- a/preprocessor/macro/MacroValue.cc +++ b/preprocessor/macro/MacroValue.cc @@ -325,12 +325,6 @@ IntMV::new_range(MacroDriver &driver, const MacroValue *mv1, const MacroValue *m int v2 = mv2i->value; vector<int> result; - if (v2 < v1) - { - int x = v2; - v2 = v1; - v1 = x; - } for (; v1 <= v2; v1++) result.push_back(v1); return new ArrayMV<int>(driver, result); diff --git a/preprocessor/macro/MacroValue.hh b/preprocessor/macro/MacroValue.hh index 52b566f4c4..e379a60262 100644 --- a/preprocessor/macro/MacroValue.hh +++ b/preprocessor/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); }; -- GitLab