-// Copyright INRIA
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+n = 50;
+nstr = strcat(string(1:n),' ');
+fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
+ierr = execstr("sscanf(1,''%d'')", "errcatch");
+if ierr <> 999 then bugmes();quit;end
+[A1, A2, A3, A4, A5, A6, A7, A8] = sscanf(nstr, fstr);
+ref = 1:8 ;
+if or([A1, A2, A3, A4, A5, A6, A7, A8] <> ref) then bugmes();quit;end
+v = 'v';
+args = strcat( v(ones(n,1)) + string(1:n)',',');
+ierr = execstr('[' + args + '] = sscanf(nstr, fstr);','errcatch');
+ref = 1:n ;
+ierr = execstr('r = or([' + args + '] <> ref)','errcatch');
+if ierr <> 0 then bugmes();quit;end
+if r <> %f then bugmes();quit;end
+n = 500;
+nstr = strcat(string(1:n),' ');
+fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
+v = 'v';
+args = strcat( v(ones(n,1)) + string(1:n)',',');
+ierr = execstr('[' + args + '] = sscanf(nstr, fstr);','errcatch');
+if ierr <> 999 then bugmes();quit;end
+n = 50;
+nstr = strcat(string(1:n),' ');
+fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
+mputl(nstr,TMPDIR+'/fscanf.txt');
+[A1, A2, A3, A4, A5, A6, A7, A8] = fscanf(TMPDIR+'/fscanf.txt',fstr);
+ref = 1:8 ;
+if or([A1, A2, A3, A4, A5, A6, A7, A8] <> ref) then bugmes();quit;end
+v = 'v';
+args = strcat( v(ones(n,1)) + string(1:n)',',');
+ierr = execstr('[' + args + '] = fscanf(TMPDIR+''/fscanf.txt'', fstr);','errcatch');
+ref = 1:n ;
+ierr = execstr('r = or([' + args + '] <> ref)','errcatch');
+if ierr <> 0 then bugmes();quit;end
+if r <> %f then bugmes();quit;end
+n = 500;
+nstr = strcat(string(1:n),' ');
+fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
+v = 'v';
+args = strcat( v(ones(n,1)) + string(1:n)',',');
+ierr = execstr('[' + args + '] = fscanf(TMPDIR+''/fscanf.txt'', fstr);','errcatch');
+if ierr <> 999 then bugmes();quit;end
//test format %i %d
if sscanf('123','%i')<>123 then bugmes();quit;end
if sscanf(' 123','%i')<>123 then bugmes();quit;end
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) ????-2008 - INRIA
+// Copyright (C) 2008 - DIGITEO - Allan CORNET
//
// This file is distributed under the same license as the Scilab package.
// =============================================================================
+n = 50;
+nstr = strcat(string(1:n),' ');
+fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
+
+ierr = execstr("sscanf(1,''%d'')", "errcatch");
+if ierr <> 999 then pause,end
+
+[A1, A2, A3, A4, A5, A6, A7, A8] = sscanf(nstr, fstr);
+ref = 1:8 ;
+if or([A1, A2, A3, A4, A5, A6, A7, A8] <> ref) then pause,end
+
+v = 'v';
+args = strcat( v(ones(n,1)) + string(1:n)',',');
+ierr = execstr('[' + args + '] = sscanf(nstr, fstr);','errcatch');
+ref = 1:n ;
+ierr = execstr('r = or([' + args + '] <> ref)','errcatch');
+if ierr <> 0 then pause,end
+if r <> %f then pause,end
+
+n = 500;
+nstr = strcat(string(1:n),' ');
+fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
+v = 'v';
+args = strcat( v(ones(n,1)) + string(1:n)',',');
+ierr = execstr('[' + args + '] = sscanf(nstr, fstr);','errcatch');
+if ierr <> 999 then pause,end
+
+n = 50;
+nstr = strcat(string(1:n),' ');
+fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
+
+mputl(nstr,TMPDIR+'/fscanf.txt');
+[A1, A2, A3, A4, A5, A6, A7, A8] = fscanf(TMPDIR+'/fscanf.txt',fstr);
+ref = 1:8 ;
+if or([A1, A2, A3, A4, A5, A6, A7, A8] <> ref) then pause,end
+
+v = 'v';
+args = strcat( v(ones(n,1)) + string(1:n)',',');
+ierr = execstr('[' + args + '] = fscanf(TMPDIR+''/fscanf.txt'', fstr);','errcatch');
+ref = 1:n ;
+ierr = execstr('r = or([' + args + '] <> ref)','errcatch');
+if ierr <> 0 then pause,end
+if r <> %f then pause,end
+
+n = 500;
+nstr = strcat(string(1:n),' ');
+fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
+v = 'v';
+args = strcat( v(ones(n,1)) + string(1:n)',',');
+ierr = execstr('[' + args + '] = fscanf(TMPDIR+''/fscanf.txt'', fstr);','errcatch');
+if ierr <> 999 then pause,end
+
//test format %i %d
if sscanf('123','%i')<>123 then pause,end
if sscanf(' 123','%i')<>123 then pause,end
if a<>4|b<>'test'|c<>23.45 then pause,end
[a,b]=sscanf('123\n456','%e%e')
-if a<>123|b<>456 then pause,end
+if a<>123|b<>456 then pause,end
\ No newline at end of file
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) XXXX-2008 - INRIA
-//
+// Copyright (C) 2008 - DIGITEO - Allan CORNET
+//
// 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
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-function [v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,..
-v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30]= fscanf(fil,frmt)
+function varargout = fscanf(fil, frmt)
// fscanf - Emulator of C language fscanf
//!
-[lhs,rhs]=argn(0)
-v='v'
-args=strcat(v(ones(lhs,1))+string(1:lhs)',',')
-buf=read(fil,1,1,'(a)')
-execstr('['+args+']=sscanf(buf,frmt)')
+
+ [lhs, rhs] = argn(0);
+
+ MAXLHS = 50;
+ if lhs > MAXLHS then
+ error(999, msprintf(gettext("%s: Wrong number of output argument(s).\n"),"fscanf"));
+ end
+
+ if type(fil)<>10 then
+ error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"fscanf",1));
+ end
+
+ if size(fil,"*")<>1 then
+ error(999, msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n")),"fscanf",1);
+ end
+
+ if type(frmt)<>10 then
+ error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"fscanf",2));
+ end
+
+ if size(frmt,"*")<>1 then
+ error(999, msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n")),"fscanf",2);
+ end
+
+ v = 'v';
+ args = strcat( v(ones(lhs,1)) + string(1:lhs)',',');
+ buf = read(fil, 1, 1, '(a)');
+ execstr('[' + args + '] = sscanf(buf,frmt);');
+ execstr('varargout = list(' + args + ');');
+
endfunction
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) XXXX-2008 - INRIA
+// Copyright (C) 2008 - DIGITEO - Allan CORNET
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-function [v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,..
-v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30]=sscanf(buf,frmt)
+function varargout = sscanf(buf,frmt)
// sscanf - Emulator of C language sscanf
- [lhs,rhs] = argn(0)
+ [lhs,rhs] = argn(0);
+ MAXLHS = 50;
+ if lhs > MAXLHS then
+ error(999, msprintf(gettext("%s: Wrong number of output argument(s).\n"),"sscanf"));
+ end
+
hexdigits = [string(0:9),'a','b','c','d','e','f','A','B','C','D','E','F']
hexvalues = [0:15,10,11,12,13,14,15];
kbuf = 1;
sbuf = length(buf);
nv = lhs;
+ if type(buf)<>10 then
+ error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"sscanf",1));
+ end
+
+ if size(buf,"*")<>1 then
+ error(999, msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n")),"sscanf",1);
+ end
+
if type(frmt)<>10 then
- error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"sscanf",2));
+ error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"sscanf",2));
end
if size(frmt,"*")<>1 then
- error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n")),"sscanf",2);
+ error(999, msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n")),"sscanf",2);
end
lb = 1;
execstr("v"+string(k)+"=[]");
end
+ v = 'v';
+ args = strcat( v(ones(count,1)) + string(1:count)',',');
+ execstr('varargout = list(' + args + ');');
+
endfunction