From 99292c7601778ceb81134a38cda8c0c134e9f76c Mon Sep 17 00:00:00 2001
From: Marco Ratto <marco.ratto@jrc.ec.europa.eu>
Date: Wed, 26 Oct 2011 09:48:37 +0200
Subject: [PATCH] license('test', ' ... ') gives 1 even if the license exists
 but it is not active, implying a crash of the dynare matlab session.

(partial cherry pick from commit ed9e9560b04b109d715b0835c8f2f68103c466bf)
---
 matlab/dynare_config.m | 2 +-
 matlab/dynare_solve.m  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m
index a899b6ebd..9b9d99023 100644
--- a/matlab/dynare_config.m
+++ b/matlab/dynare_config.m
@@ -52,7 +52,7 @@ if ~exist('OCTAVE_VERSION')
     addpath([dynareroot '/missing/rows_columns'])
     % Replacement for vec() (inexistent under MATLAB)
     addpath([dynareroot '/missing/vec'])
-    if ~license('test', 'statistics_toolbox')
+    if isempty(license('inuse','statistics_toolbox'))
         % Replacements for functions of the stats toolbox
         addpath([dynareroot '/missing/stats/'])
     end
diff --git a/matlab/dynare_solve.m b/matlab/dynare_solve.m
index 401946da0..22ae57aa2 100644
--- a/matlab/dynare_solve.m
+++ b/matlab/dynare_solve.m
@@ -38,7 +38,7 @@ global options_
 options_ = set_default_option(options_,'solve_algo',2);
 info = 0;
 if options_.solve_algo == 0
-    if ~exist('OCTAVE_VERSION') && ~license('test', 'optimization_toolbox')
+    if ~exist('OCTAVE_VERSION') && isempty(license('inuse','optimization_toolbox'))
         error('You can''t use solve_algo=0 since you don''t have MATLAB''s Optimization Toolbox')
     end
     options=optimset('fsolve');
-- 
GitLab