-
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
+// Copyright (C) DIGITEO - 2009-2010 - Allan CORNET
+// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS
//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution. The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-
-function path=get_function_path(name)
-libname=whereis(name)
-if libname==[] then
- warning(" """+name +'"" is not a library function')
- path=[]
-else
- execstr('t=string('+libname+')')
- path=t(1)+name+'.sci'
- if strindex(path,['SCI/','SCI\'])==1 then
- path=SCI+part(path,4:length(path))
- end
- if fileinfo(path)==[] then
- warning(msprintf(gettext("%s: There is no file named %s.sci in the library directory %s.\n"),"get_function_path",name,t(1)))
- path=[]
- end
-end
-endfunction
+// Copyright (C) 2012 - 2016 - Scilab Enterprises
+//
+// This file is hereby licensed under the terms of the GNU GPL v2.0,
+// pursuant to article 5.3.4 of the CeCILL v.2.1.
+// This file was originally licensed under the terms of the CeCILL v2.1,
+// and continues to be available under such terms.
+// For more information, see the COPYING file which you should have received
+// along with this program.
+
+function path = get_function_path(name)
+
+ path = [];
+ rhs = argn(2);
+
+ if rhs == 0 then
+ error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"), "get_function_path", 1));
+ end
+ if type(name) <> 10 then
+ error(msprintf(_("%s: Wrong type for input argument #%d: string expected.\n"),"get_function_path",1));
+ end
+
+ if size(name,"*") <> 1 then
+ error(msprintf(_("%s: Wrong size for input argument #%d: string expected.\n"),"get_function_path",1));
+ end
+
+ libname = whereis(name);
+
+ if libname <> [] & libname <> "script" & type(evstr(name))==13 then
+ for i = 1:size(libname,"*")
+ [funcnames, pathlib] = libraryinfo(libname(i));
+ path = [path ; fullfile(pathlib, name + ".sci")];
+ end
+ path = pathconvert(path,%F);
+ end
+
+endfunction