From cbd43ee9df2ce8e045a4dc37ae492b8428b2bccb Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Tue, 14 May 2013 17:22:24 +0200
Subject: [PATCH] reporting: on error reading user options, print actual option
 passed not lowercase version of it

---
 matlab/reports/@graph/graph.m     | 5 ++---
 matlab/reports/@page/page.m       | 5 ++---
 matlab/reports/@report/report.m   | 6 ++----
 matlab/reports/@section/section.m | 6 ++----
 matlab/reports/@series/series.m   | 5 ++---
 matlab/reports/@table/table.m     | 6 ++----
 matlab/reports/@vspace/vspace.m   | 5 ++---
 7 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/matlab/reports/@graph/graph.m b/matlab/reports/@graph/graph.m
index c1bb5c951e..452281de32 100644
--- a/matlab/reports/@graph/graph.m
+++ b/matlab/reports/@graph/graph.m
@@ -77,13 +77,12 @@ elseif nargin > 1
 
     % overwrite default values
     for pair = reshape(varargin, 2, [])
-        field = lower(pair{1});
-        ind = strmatch(field, lower(optNames), 'exact');
+        ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
         assert(isempty(ind) || length(ind) == 1);
         if ~isempty(ind)
             o.(optNames{ind}) = pair{2};
         else
-            error('@graph.graph: %s is not a recognized option.', field);
+            error('@graph.graph: %s is not a recognized option.', pair{1});
         end
     end
 end
diff --git a/matlab/reports/@page/page.m b/matlab/reports/@page/page.m
index 8e2b305267..b36adb1c5f 100644
--- a/matlab/reports/@page/page.m
+++ b/matlab/reports/@page/page.m
@@ -52,13 +52,12 @@ elseif nargin > 1
 
     % overwrite default values
     for pair = reshape(varargin, 2, [])
-        field = lower(pair{1});
-        ind = strmatch(field, lower(optNames), 'exact');
+        ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
         assert(isempty(ind) || length(ind) == 1);
         if ~isempty(ind)
             o.(optNames{ind}) = pair{2};
         else
-            error('@page.page: %s is not a recognized option.', field);
+            error('@page.page: %s is not a recognized option.', pair{1});
         end
     end
 end
diff --git a/matlab/reports/@report/report.m b/matlab/reports/@report/report.m
index 5e306c6753..58c1634ed7 100644
--- a/matlab/reports/@report/report.m
+++ b/matlab/reports/@report/report.m
@@ -58,14 +58,12 @@ elseif nargin > 1
 
     % overwrite default values
     for pair = reshape(varargin, 2, [])
-        field = lower(pair{1});
-        ind = strmatch(field, lower(optNames), 'exact');
+        ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
         assert(isempty(ind) || length(ind) == 1);
         if ~isempty(ind)
             o.(optNames{ind}) = pair{2};
         else
-            error('@report.report: %s is not a recognized option.', ...
-                  field);
+            error('@report.report: %s is not a recognized option.', pair{1});
         end
     end
 end
diff --git a/matlab/reports/@section/section.m b/matlab/reports/@section/section.m
index aca48b8c18..7e6bb08249 100644
--- a/matlab/reports/@section/section.m
+++ b/matlab/reports/@section/section.m
@@ -40,14 +40,12 @@ elseif nargin > 1
 
     % overwrite default values
     for pair = reshape(varargin, 2, [])
-        field = lower(pair{1});
-        ind = strmatch(field, lower(optNames), 'exact');
+        ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
         assert(isempty(ind) || length(ind) == 1);
         if ~isempty(ind)
             o.(optNames{ind}) = pair{2};
         else
-            error('@section.section: %s is not a recognized option.', ...
-                  field);
+            error('@section.section: %s is not a recognized option.', pair{1});
         end
     end
 end
diff --git a/matlab/reports/@series/series.m b/matlab/reports/@series/series.m
index 1ef0d424ef..39b104d970 100644
--- a/matlab/reports/@series/series.m
+++ b/matlab/reports/@series/series.m
@@ -65,13 +65,12 @@ elseif nargin > 1
 
     % overwrite default values
     for pair = reshape(varargin, 2, [])
-        field = lower(pair{1});
-        ind = strmatch(field, lower(optNames), 'exact');
+        ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
         assert(isempty(ind) || length(ind) == 1);
         if ~isempty(ind)
             o.(optNames{ind}) = pair{2};
         else
-            error('@series.series: %s is not a recognized option.', field);
+            error('@series.series: %s is not a recognized option.', pair{1});
         end
     end
 end
diff --git a/matlab/reports/@table/table.m b/matlab/reports/@table/table.m
index f24a75c888..e7247a61be 100644
--- a/matlab/reports/@table/table.m
+++ b/matlab/reports/@table/table.m
@@ -62,14 +62,12 @@ elseif nargin > 1
 
     % overwrite default values
     for pair = reshape(varargin, 2, [])
-        field = lower(pair{1});
-        ind = strmatch(field, lower(optNames), 'exact');
+        ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
         assert(isempty(ind) || length(ind) == 1);
         if ~isempty(ind)
             o.(optNames{ind}) = pair{2};
         else
-            error('%s is not a recognized option to the Table constructor.', ...
-                  field);
+            error('%s is not a recognized option to the Table constructor.', pair{1});
         end
     end
 end
diff --git a/matlab/reports/@vspace/vspace.m b/matlab/reports/@vspace/vspace.m
index 0af84127e1..e61ca8149b 100644
--- a/matlab/reports/@vspace/vspace.m
+++ b/matlab/reports/@vspace/vspace.m
@@ -48,13 +48,12 @@ elseif nargin > 1
 
     % overwrite default values
     for pair = reshape(varargin, 2, [])
-        field = lower(pair{1});
-        ind = strmatch(field, lower(optNames), 'exact');
+        ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
         assert(isempty(ind) || length(ind) == 1);
         if ~isempty(ind)
             o.(optNames{ind}) = pair{2};
         else
-            error('@vspace.vspace: %s is not a recognized option.', field);
+            error('@vspace.vspace: %s is not a recognized option.', pair{1});
         end
     end
 end
-- 
GitLab