From: <sch...@us...> - 2010-07-02 15:14:20
|
Revision: 7464 http://octave.svn.sourceforge.net/octave/?rev=7464&view=rev Author: schloegl Date: 2010-07-02 15:14:14 +0000 (Fri, 02 Jul 2010) Log Message: ----------- tolower/toupper/toascii/arg/printf addressed within oct2mat - no extra functions needed Modified Paths: -------------- trunk/octave-forge/extra/oct2mat/inst/generate_basics.m trunk/octave-forge/extra/oct2mat/inst/oct2mat trunk/octave-forge/extra/oct2mat/inst/test_oct2mat.m Modified: trunk/octave-forge/extra/oct2mat/inst/generate_basics.m =================================================================== --- trunk/octave-forge/extra/oct2mat/inst/generate_basics.m 2010-07-02 14:18:40 UTC (rev 7463) +++ trunk/octave-forge/extra/oct2mat/inst/generate_basics.m 2010-07-02 15:14:14 UTC (rev 7464) @@ -20,15 +20,10 @@ % Copyright (C) 2010 by Alois Schloegl <a.s...@ie...> % This is part of Octave-Forge's Oct2Mat -f = {'arg', 'function phi = arg(x)\n phi = angle(x);'; ... - 'rows', 'function n = rows(x)\n n = size(x,1);'; ... +f = {'rows', 'function n = rows(x)\n n = size(x,1);'; ... 'columns', 'function n = columns(x)\n n = size(x,2);'; ... 'ismatrix', 'function n = ismatrix(x)\n n = isnumeric(x) || islogical(x) || ischar(x);'; ... - 'printf', 'function x = printf(s,varargin)\n x = fprintf(1,s,varargin{:});'; ... - 'tolower', 'function n = tolower(x)\n n = lower(x);'; ... - 'toupper', 'function n = toupper(x)\n n = upper(x);'; ... - 'toascii', 'function n = toascii(x)\n n = abs(x);'; ... - 'vec', 'function x = vec(x)\n x = x(:);'; ... + 'vec', 'function x = vec(x,i)\n if nargin<==1, x = x(:); elseif nargin==2, x=x(i); else error(''vec has invalid number of arguments''); end;\n'; ... 'rindex', 'function x = rindex(s,t)\n idx = findstr(s,t);\n if isempty(idx), x = 0;\n else x = idx(end); end'; ... 'substr', 'function y = substr(s,i,j)\n if i<0, i=length(s)+i+1; end;\n if nargin<3, y = s(i:end);\n else y = s(i:i+j-1); end'; ... 'file_in_loadpath', 'function name=file_in_loadpath(file)\n name=file_in_path(path,file);' ... Modified: trunk/octave-forge/extra/oct2mat/inst/oct2mat =================================================================== --- trunk/octave-forge/extra/oct2mat/inst/oct2mat 2010-07-02 14:18:40 UTC (rev 7463) +++ trunk/octave-forge/extra/oct2mat/inst/oct2mat 2010-07-02 15:14:14 UTC (rev 7464) @@ -354,6 +354,7 @@ #### replace "dd.ee.(kk) = vv;" with "setfield(dd.ee,kk,vv);" -------------- $0 = gensub(/^([ \t]*)(\<[[:alnum:]_\.]*)\.\((\<[^\(]*)\)[ \t]*=[ \t]*([^;]*);[ \t]*$/,"\\1setfield(\\2,\\3,\\4)", "g"); + #### keywords gsub(/\<endfunction\>/,""); gsub(/\<endif\>/,"end"); gsub(/\<endwhile\>/,"end"); @@ -362,8 +363,13 @@ gsub(/\<endclassdef\>/,"end"); gsub(/\<end_try_catch\>/,"end"); gsub(/\<struct_contains\>/,"isfield"); - gsub(/\<tolower[ \t]*\(/,"lower("); - gsub(/\<toupper[ \t]*\(/,"upper("); + + #### builtin-functions + gsub(/\<arg[ \t]*\(/, "angle("); + gsub(/\<printf[ \t]*\(/, "fprintf(1,"); + gsub(/\<toascii[ \t]*\(/, "abs("); + gsub(/\<tolower[ \t]*\(/, "lower("); + gsub(/\<toupper[ \t]*\(/, "upper("); gsub(/\<cell[ \t]*\([ \t]*\)[ \t]*;/, "{};"); ## cell() -> {} gsub("SEEK_CUR",0); gsub("SEEK_END",1); @@ -381,6 +387,7 @@ $0 = gensub(/^([ \t]*[[:alpha:]_\(\)\{\}]+)([ \t]*=[ \t]*)([[:alnum:]_\(\)\{\}]+)([ \t]*=[ \t]*)([[:alnum:]_\(\)\{\}]+[ \t]*;)[ \t]*[\n\r]*$/,"\\3\\4\\5 \\1\\2\\3;","g"); $0 = gensub(/^([ \t]*[[:alpha:]_\(\)\{\}]+)([ \t]*=[ \t]*)([[:alnum:]_\(\)\{\}]+)([ \t]*=[ \t]*)([[:alnum:]_\(\)\{\}]+[ \t]*;)[ \t]*[\n\r]*$/,"\\3\\4\\5 \\1\\2\\3;","g"); $0 = gensub(/^([ \t]*[[:alpha:]_\(\)\{\}]+)([ \t]*=[ \t]*)([[:alnum:]_\(\)\{\}]+)([ \t]*=[ \t]*)([[:alnum:]_\(\)\{\}]+[ \t]*;)[ \t]*[\n\r]*$/,"\\3\\4\\5 \\1\\2\\3;","g"); + $0 = gensub(/^([ \t]*[[:alpha:]_\(\)\{\}]+)([ \t]*=[ \t]*)([[:alnum:]_\(\)\{\}]+)([ \t]*=[ \t]*)([[:alnum:]_\(\)\{\}]+[ \t]*;)[ \t]*[\n\r]*$/,"\\3\\4\\5 \\1\\2\\3;","g"); } ############################################################# Modified: trunk/octave-forge/extra/oct2mat/inst/test_oct2mat.m =================================================================== --- trunk/octave-forge/extra/oct2mat/inst/test_oct2mat.m 2010-07-02 14:18:40 UTC (rev 7463) +++ trunk/octave-forge/extra/oct2mat/inst/test_oct2mat.m 2010-07-02 15:14:14 UTC (rev 7464) @@ -208,4 +208,7 @@ ++jj; --llcol; - [tolower(xyz),toupper(xyz)] + {tolower(xyz),toupper(xyz),arg(Z),toascii([64,10,13,32,9,64])} + printf('abc= %s','xyz'); + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |