From: <sch...@us...> - 2010-05-21 10:01:42
|
Revision: 7327 http://octave.svn.sourceforge.net/octave/?rev=7327&view=rev Author: schloegl Date: 2010-05-21 10:01:35 +0000 (Fri, 21 May 2010) Log Message: ----------- replace list functions like nth(), append(), which became obsolete with 3.4 etc. Modified Paths: -------------- trunk/octave-forge/extra/graceplot/inst/alternatives/print.m trunk/octave-forge/extra/tk_octave/inst/tk_dialog.m trunk/octave-forge/extra/tk_octave/inst/tk_menu.m trunk/octave-forge/extra/tk_octave/inst/tk_scale.m trunk/octave-forge/main/symbolic/inst/symfsolve.m trunk/octave-forge/main/symbolic/src/symbols.cc trunk/octave-forge/main/symbolic/src/symlsolve.cc trunk/octave-forge/main/vrml/inst/test_vrml_faces.m trunk/octave-forge/main/vrml/inst/vrml_PointLight.m trunk/octave-forge/main/vrml/inst/vrml_TimeSensor.m trunk/octave-forge/main/vrml/inst/vrml_faces.m trunk/octave-forge/main/vrml/inst/vrml_interp.m trunk/octave-forge/main/vrml/inst/vrml_newname.m trunk/octave-forge/main/vrml/inst/vrml_points.m Modified: trunk/octave-forge/extra/graceplot/inst/alternatives/print.m =================================================================== --- trunk/octave-forge/extra/graceplot/inst/alternatives/print.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/extra/graceplot/inst/alternatives/print.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -1,3 +1,4 @@ + ## Copyright (C) 2001 Laurent Mazet ## ## This program is free software; it is distributed in the hope that it @@ -124,7 +125,7 @@ va_arg_cnt = 1; for i=1:nargin - arg = nth (varargin, va_arg_cnt++); + arg = varargin{va_arg_cnt++}; if ischar(arg) if strcmp(arg, "-color") use_color = 1; @@ -412,3 +413,4 @@ endif endfunction + Modified: trunk/octave-forge/extra/tk_octave/inst/tk_dialog.m =================================================================== --- trunk/octave-forge/extra/tk_octave/inst/tk_dialog.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/extra/tk_octave/inst/tk_dialog.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -64,7 +64,7 @@ #varargin = list(varargin, all_va_args); for argnum=1:length(varargin) - arg = nth (varargin, argnum); + arg = varargin{argnum}; if (! ischar(arg)) error("The arguments must be strings.\n"); return Modified: trunk/octave-forge/extra/tk_octave/inst/tk_menu.m =================================================================== --- trunk/octave-forge/extra/tk_octave/inst/tk_menu.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/extra/tk_octave/inst/tk_menu.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -36,10 +36,8 @@ nopt = nargin - 1; -va_arg_cnt = 1; - for i = 1:nopt - tk_cmd( sprintf ("button .master.b%d -text \"%s\" -command { set menuChoice %d; quit}", i, nth (varargin, va_arg_cnt++), i) ); + tk_cmd( sprintf ("button .master.b%d -text \"%s\" -command { set menuChoice %d; quit}", i, varargin{i}, i) ); tk_cmd( sprintf ("pack .master.b%d -fill x", i) ); endfor Modified: trunk/octave-forge/extra/tk_octave/inst/tk_scale.m =================================================================== --- trunk/octave-forge/extra/tk_octave/inst/tk_scale.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/extra/tk_octave/inst/tk_scale.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -1,3 +1,4 @@ + ## Copyright (C) 1998, 1999, 2000 Joao Cardoso. ## ## This program is free software; you can redistribute it and/or modify it @@ -52,11 +53,11 @@ va_arg_cnt = 1; for i=1:nopt - desc = nth (varargin, va_arg_cnt++); - val = nth (varargin, va_arg_cnt++); - min_val = nth (varargin, va_arg_cnt++); - max_val = nth (varargin, va_arg_cnt++); - inc_val = nth (varargin, va_arg_cnt++); + desc = varargin{va_arg_cnt++}; + val = varargin{va_arg_cnt++}; + min_val = varargin{va_arg_cnt++}; + max_val = varargin{va_arg_cnt++}; + inc_val = varargin{va_arg_cnt++}; tk_cmd( sprintf("set val_%d %f", i, val) ); tk_cmd( sprintf("scale .master.s%d -from %f -to %f \ @@ -69,9 +70,9 @@ tk_cmd( "tkwait window .master" ); -vr_val_cnt = 1; for i=1:nopt - varargout{vr_val_cnt++} = eval([tk_cmd(sprintf("set val_%d",i)), ";"]); + varargout{i} = eval([tk_cmd(sprintf("set val_%d",i)), ";"]); endfor endfunction + Modified: trunk/octave-forge/main/symbolic/inst/symfsolve.m =================================================================== --- trunk/octave-forge/main/symbolic/inst/symfsolve.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/symbolic/inst/symfsolve.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -83,7 +83,7 @@ !strcmp(typeinfo(varargin{i}),"ex") ) break; endif - eqns=append(eqns,varargin{i}); + eqns{end+1} = varargin{i}; arg_count = arg_count+1; endfor endif @@ -117,7 +117,7 @@ for i=(arg_count+1):2:nargin tmp = disp(varargin{i}); if all(isalnum(tmp) | tmp=="_" | tmp==",") - vars=append(vars,varargin{i}); + vars{end+1} = varargin{i}; X0((i-arg_count+1)/2)=varargin{i+1}; else error("Error in symbol-value pair arguments.") @@ -133,7 +133,7 @@ # cell-array of relations - this should work for a list of strings ("x==3") too. for i=1:nvars tmp = disp(varargin{arg_count+1}{i}); - vars = append(vars,sym(strtok(tmp,"=="))); + vars{end+1} = {sym(strtok(tmp,"=="))}; X0(i) = str2num(tmp((findstr(tmp,"==")+2):length(tmp))); endfor else Modified: trunk/octave-forge/main/symbolic/src/symbols.cc =================================================================== --- trunk/octave-forge/main/symbolic/src/symbols.cc 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/symbolic/src/symbols.cc 2010-05-21 10:01:35 UTC (rev 7327) @@ -373,7 +373,8 @@ gripe_wrong_type_arg ("subs",args(0)); return retval; } - if (!(args(1).is_list() || args(1).is_cell())) { + //if (!(args(1).is_list() || args(1).is_cell())) { + if (!(args(1).is_cell())) { if (!get_symbol (args(1), the_sym)) { gripe_wrong_type_arg("subs",args(1)); return retval; Modified: trunk/octave-forge/main/symbolic/src/symlsolve.cc =================================================================== --- trunk/octave-forge/main/symbolic/src/symlsolve.cc 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/symbolic/src/symlsolve.cc 2010-05-21 10:01:35 UTC (rev 7327) @@ -46,7 +46,7 @@ } try { - if(args(0).is_list() || args(0).is_cell()) { + if(args(0).is_cell()) { octave_value_list oct_eqn_list(args(0).list_value()); for(i=0;i<oct_eqn_list.length();i++) { if(!get_relation(oct_eqn_list(i),relation)) { @@ -67,7 +67,7 @@ eqns.append(relation); } - if(args(1).is_list() || args(1).is_cell()) { + if(args(1).is_cell()) { octave_value_list oct_vars(args(1).list_value()); for(i=0;i<oct_vars.length();i++) { if(!get_symbol(oct_vars(i),expression)) { Modified: trunk/octave-forge/main/vrml/inst/test_vrml_faces.m =================================================================== --- trunk/octave-forge/main/vrml/inst/test_vrml_faces.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/vrml/inst/test_vrml_faces.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -25,7 +25,7 @@ 2 3 1 2; 4 4 4 3]; -trgl = list ([1 2 4],[2 3 4],[3 1 4],[1 2 3]); +trgl = {[1 2 4],[2 3 4],[3 1 4],[1 2 3]}; slight = vrml_PointLight ("location", [0,5,0]); Modified: trunk/octave-forge/main/vrml/inst/vrml_PointLight.m =================================================================== --- trunk/octave-forge/main/vrml/inst/vrml_PointLight.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/vrml/inst/vrml_PointLight.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -56,7 +56,7 @@ elseif !(isnumeric(val) && isnan (val)) # Check validity of field - if ! struct_contains (tpl, key) + if ! isfield (tpl, key) error (sprintf ("vrml_PointLight : unknown field '%s'",key)); end @@ -67,7 +67,7 @@ end end s = sprintf ("PointLight {\n%s}\n", body); -if struct_contains (h,"DEF") && !isempty (h.DEF) +if isfield (h,"DEF") && !isempty (h.DEF) s = ["DEF ",h.DEF," ",s]; end endfunction Modified: trunk/octave-forge/main/vrml/inst/vrml_TimeSensor.m =================================================================== --- trunk/octave-forge/main/vrml/inst/vrml_TimeSensor.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/vrml/inst/vrml_TimeSensor.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -36,27 +36,29 @@ "loop", "SFBool" ); -headpar = list (); +headpar = {}; dnode = struct (); # Transform varargin into key-value pairs i = j = k = 1; # i:pos in new varargin, j:pos in headpar, # k:pos is old varargin. while i <= length (varargin) && \ - ! (ischar (nth (varargin,i)) && struct_contains (tpl, nth (varargin,i))) + ! (ischar (varargin{i}) && isfield (tpl, varargin{i})) if j <= length (headpar) if verbose - printf ("vrml_TimeSensor : Assume arg %i is '%s'\n",k,nth(headpar,j)); + printf ("vrml_TimeSensor : Assume arg %i is '%s'\n",k,headpar{j}); end - varargin = splice (varargin, i, 0, headpar(j++)); + ##varargin = splice (varargin, i, 0, headpar(j)); + varargin = {varargin{1:i-1}, headpar(j), varargin{i:end}}; + j ++; i += 2; k++; else error ("vrml_TimeSensor : Argument %i should be string, not '%s'",\ - k,typeinfo (nth (varargin, i))); + k,typeinfo (varargin{i})); end end @@ -65,76 +67,55 @@ DEF = 0; -l = list ("TimeSensor {\n"); +l = {"TimeSensor {\n"}; i = 1; while i < length (varargin) - k = nth (varargin, i++); # Read key + k = varargin{i++}; # Read key if ! ischar (k) error ("vrml_TimeSensor : Arg n. %i should be a string, not a %s.",\ i-1, typeinfo (k)); end - if ! struct_contains (tpl, k) && ! strcmp (k,"DEF") + if ! isfield (tpl, k) && ! strcmp (k,"DEF") error ("vrml_TimeSensor : Unknown field '%s'. Should be one of :\n%s",\ k, sprintf (" '%s'\n",fieldnames (tpl)'{:})); end - v = nth (varargin, i++); # Read value + v = varargin{i++}; # Read value # Add DEF if strcmp (k,"DEF") if verbose, printf ("vrml_TimeSensor : Defining node '%s'\n",v); end if DEF, error ("vrml_TimeSensor : Multiple DEFs found"); end - l = splice (l,1,0,list ("DEF ",v," ")); + ##l = splice (l,1,0,{"DEF ",v," "}); + varargin = {"DEF ",v," ",l}; DEF = 1; else # Add data field if verbose printf ("vrml_TimeSensor : Adding '%s' of type %s, with arg of type %s\n",\ - k,tpl.(k),typeinfo (v)); + k,getfield(tpl,k),typeinfo (v)); end - if strcmp (tpl.(k)(2:length(tpl.(k))), "FNode") + tmp = getfield(tpl,k); + if strcmp (tmp(2:end), "FNode") if verbose, printf ("vrml_TimeSensor : Trying to learn type of node\n"); end - if is_list (v) # v is list of arguments - - # Check whether 1st arg is node type's name. - tn = nth (v,1); - - if all (exist (["vrml_",tn]) != [2,3,5]) - # If it isn't type's name, use default type. - if struct_contains (dnode, k) - if verbose - printf ("vrml_TimeSensor : Using default type : %s\n",dnode.(k)); - end - v = splice (v, 1, 0, list (dnode.(k))); - else - error ("vrml_TimeSensor : Can't determine type of node '%s'",k); - end - else - if verbose - printf ("vrml_TimeSensor : 1st list element is type : %s\n",tn); - end - end - # If v is not a list, maybe it has a default - # node type type (otherwise, it's be sent - # plain. - elseif struct_contains (dnode, k) + if isfield (dnode, k) if verbose printf ("vrml_TimeSensor : Using default type : %s\n",dnode.(k)); end - v = list (dnode.(k), v); + v = {getfield(dnode,k), v}; end end - l = append (l, k, " ", data2vrml (tpl.(k), v),"\n"); + l = {l{:}, k, " ", data2vrml(getfield(tpl,k),v),"\n"}; end end -l = append (l, "}\n"); -s = leval ("strcat", l); +l{end+1} = "}\n"; +s = feval ("strcat", l{:}); endfunction Modified: trunk/octave-forge/main/vrml/inst/vrml_faces.m =================================================================== --- trunk/octave-forge/main/vrml/inst/vrml_faces.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/vrml/inst/vrml_faces.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -95,7 +95,7 @@ i = 1; while nargin>=i - tmp = nth (varargin, i++); + tmp = varargin{i++}; if ! ischar(tmp) , error ("vrml_faces : Non-string option : \n") ; ## keyboard @@ -103,7 +103,7 @@ if index(opt1,[" ",tmp," "]) , - tmp2 = nth (varargin, i++) ; + tmp2 = varargin{i++} ; eval([tmp,"=tmp2;"]) ; @@ -131,11 +131,7 @@ ## printf ("creaseAngle = %8.3f\n",creaseAngle); - ## TODO : s/list/cell/g; Should put this code in sometime soon - ## if is_list (f), tmp={}; for i=1:length(f), tmp{i}=nth(f,i);end; f=tmp; end; - ## if is_list (f), nfaces = length (f); else nfaces = columns (f); end - - if is_list (f), nfaces = length (f); else nfaces = columns (f); end + nfaces = columns (f); if ismatrix(f) if rows (f) < 3 error ("Faces matrix 'f' has %i < 3 rows, so it does not define faces", @@ -254,7 +250,7 @@ ## TODO : s/list/cell/g; Should put this code in sometime soon ## Code below seems useless # Faces - if is_list (f), nfaces = length (f); else nfaces = columns (f); end + if iscell (f), nfaces = length (f); else nfaces = columns (f); end tpl0 = sprintf ("%%%dd, ",floor (log10 (max (1, columns (x))))+1); @@ -265,15 +261,15 @@ # Determine total number of vertices, number # of vertices per face and indexes of # vertices of each face - ## TODO : s/list/cell/g; Should put this code in sometime soon - ## if iscell (f), ... f{i} - if is_list (f) - + if iscell (f) npts = 0; - for i = 1:length (f), npts += ptsface(i) = 1+length (nth (f,i)); end + for i = 1:length (f), + ptsface(i) = 1+length (f{i}); + npts += ptsface(i); + end ii = [0, cumsum(ptsface)]'; all_indexes = -ones (1,npts); - for i = 1:length (f), all_indexes(ii(i)+1:ii(i+1)-1) = nth (f,i) - 1; end + for i = 1:length (f), all_indexes(ii(i)+1:ii(i+1)-1) = f{i} - 1; end else f = [f;-ones(1,columns(f))]; npts = sum (ptsface = (sum (!! f))); Modified: trunk/octave-forge/main/vrml/inst/vrml_interp.m =================================================================== --- trunk/octave-forge/main/vrml/inst/vrml_interp.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/vrml/inst/vrml_interp.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -27,15 +27,17 @@ "Position" , "Position", "scal" , "Scalar", "Scalar" , "Scalar"); -if struct_contains (nname, typ) +if isfield (nname, typ) typs = nname.(typ); elseif ischar(typ) - e2 = leval ("sprintf",\ - append (list(" '%s'\n"), fieldnames (nname))); +# e2 = leval ("sprintf",\ +# append (list(" '%s'\n"), fieldnames (nname))); + e2 = sprintf(" '%s'\n", fieldnames (nname){:}); error ("vrml_interp : Unknown type '%s'. Should be in:\n%s",typ,e2); else - e2 = leval ("sprintf",\ - append (list(" '%s;\n"), fieldnames (nname))); +# e2 = leval ("sprintf",\ +# append (list(" '%s;\n"), fieldnames (nname))); + e2 = sprintf(" '%s'\n", fieldnames (nname){:}); error ("vrml_interp : typ should be a string in:\n%s",typ,e2); end Modified: trunk/octave-forge/main/vrml/inst/vrml_newname.m =================================================================== --- trunk/octave-forge/main/vrml/inst/vrml_newname.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/vrml/inst/vrml_newname.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -14,7 +14,7 @@ if isempty (root), root = "N"; end n = sprintf ([root,"%0d"],100000*rand()); -while struct_contains (vrml_namespace, n) +while isfield (vrml_namespace, n) n = sprintf ([root,"%0d"],100000*rand()); end endfunction Modified: trunk/octave-forge/main/vrml/inst/vrml_points.m =================================================================== --- trunk/octave-forge/main/vrml/inst/vrml_points.m 2010-05-21 09:36:39 UTC (rev 7326) +++ trunk/octave-forge/main/vrml/inst/vrml_points.m 2010-05-21 10:01:35 UTC (rev 7327) @@ -1,3 +1,4 @@ + ## Copyright (C) 2002 Etienne Grossmann. All rights reserved. ## ## This program is free software; you can redistribute it and/or modify it @@ -65,7 +66,7 @@ while i <= nargin-1 - tmp = nth (varargin,i++); + tmp = varargin{i++}; if strcmp(tmp,"hide") , hide = 1; elseif strcmp(tmp,"balls") , @@ -74,20 +75,20 @@ cubes = 1; elseif strcmp(tmp,"rad") , - rad = nth (varargin,i++); + rad = varargin{i++}; elseif strcmp(tmp,"nums") , nums = 1; elseif strcmp(tmp,"emit") , - emit = nth (varargin,i++); + emit = varargin{i++}; elseif strcmp(tmp,"col") , - col = nth (varargin,i++); + col = varargin{i++}; elseif strcmp(tmp,"name") , - name = nth (varargin,i++); + name = varargin{i++}; elseif strcmp(tmp,"tran") , - tran = nth (varargin,i++); + tran = varargin{i++}; end end @@ -218,3 +219,4 @@ end endfunction + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |