v_voicebox_update

PURPOSE ^

V_VOICEBOX_UPDATE update v_voicebox calls by prefixing with 'v_'

SYNOPSIS ^

function n=v_voicebox_update(fn,m)

DESCRIPTION ^

V_VOICEBOX_UPDATE update v_voicebox calls by prefixing with 'v_'
  Inputs: fn   file or folder name to update [default: current folder]
          m    'r' to search recursively through the folder tree
               's' silent mode: do not print out statistics
               'v' verbose: list files as they are updated
               'V' extra verbose: list files even if not updated
               'b' do not backup old file

 Outputs: n    number of files updated

 This routine is not all that smart. Words that match the function names
 included in the 'vbn' list below will be updated even if they are inside
 strings (except for the last string on a line). Local variables that
 share the name of a v_voicebox function will also be modified.

 vbp lists function names that may have an argument list
 vbn lists function names that may be called without arguments

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function n=v_voicebox_update(fn,m)
0002 %V_VOICEBOX_UPDATE update v_voicebox calls by prefixing with 'v_'
0003 %  Inputs: fn   file or folder name to update [default: current folder]
0004 %          m    'r' to search recursively through the folder tree
0005 %               's' silent mode: do not print out statistics
0006 %               'v' verbose: list files as they are updated
0007 %               'V' extra verbose: list files even if not updated
0008 %               'b' do not backup old file
0009 %
0010 % Outputs: n    number of files updated
0011 %
0012 % This routine is not all that smart. Words that match the function names
0013 % included in the 'vbn' list below will be updated even if they are inside
0014 % strings (except for the last string on a line). Local variables that
0015 % share the name of a v_voicebox function will also be modified.
0016 %
0017 % vbp lists function names that may have an argument list
0018 % vbn lists function names that may be called without arguments
0019 vbp='activlev|activlevg|atan2sc|axisenlarge|bark2frq|berk2prob|besselratio|besselratioi|bitsprec|cblabel|ccwarpf|cent2frq|cep2pow|choosenk|choosrnk|convfft|correlogram|distchar|distchpf|disteusq|distisar|distispf|distitar|distitpf|ditherq|dlyapsq|dualdiag|dypsa|enframe|entropy|erb2frq|estnoiseg|estnoisem|ewgrpdel|fig2emf|fig2pdf|figbolden|filtbankm|filterbank|finishat|fopenmkd|frac2bin|fram2wav|frq2bark|frq2cent|frq2erb|frq2mel|frq2midi|fxpefac|fxrapt|gammabank|gammalns|gausprod|gaussmix|gaussmixd|gaussmixg|gaussmixk|gaussmixm|gaussmixp|gaussmixt|glotlf|glotros|gmmlpdf|histndim|hostipinfo|huffman|hypergeom1f1|imagehomog|importsii|irdct|irfft|kmeanhar|kmeanlbg|lambda2rgb|ldatrace|lin2pcma|lin2pcmu|lognmpdf|logsum|lpcaa2ao|lpcaa2dl|lpcaa2rf|lpcao2rf|lpcar2am|lpcar2cc|lpcar2db|lpcar2ff|lpcar2fm|lpcar2im|lpcar2ls|lpcar2pf|lpcar2pp|lpcar2ra|lpcar2rf|lpcar2rr|lpcar2zz|lpcauto|lpcbwexp|lpccc2ar|lpccc2cc|lpccc2db|lpccc2ff|lpccc2pf|lpcconv|lpccovar|lpccw2zz|lpcdb2pf|lpcdl2aa|lpcff2pf|lpcfq2zz|lpcifilt|lpcim2ar|lpcis2rf|lpcla2rf|lpclo2rf|lpcls2ar|lpcpf2cc|lpcpf2ff|lpcpf2rr|lpcpp2cw|lpcpp2pz|lpcpz2zz|lpcra2ar|lpcra2pf|lpcra2pp|lpcrand|lpcrf2aa|lpcrf2ao|lpcrf2ar|lpcrf2is|lpcrf2la|lpcrf2lo|lpcrf2rr|lpcrr2am|lpcrr2ar|lpcss2zz|lpcstable|lpczz2ar|lpczz2cc|lpczz2ss|m2htmlpwd|maxfilt|maxgauss|meansqtf|mel2frq|melbankm|melcepst|midi2frq|minspane|mintrace|modspect|momfilt|mos2pesq|nearnonz|normcdflog|overlapadd|paramsetch|pcma2lin|pcmu2lin|pdfmoments|peak2dquad|permutes|pesq2mos|phon2sone|polygonarea|polygonwind|polygonxline|potsband|pow2cep|prob2berk|psycdigit|psycest|psycestu|psychofunc|qrabs|qrdivide|qrdotdiv|qrdotmult|qrmult|qrpermute|quadpeak|randfilt|randiscr|randvec|rdct|readaif|readau|readcnx|readflac|readhtk|readsfs|readsph|readwav|rectifyhomog|regexfiles|rfft|rhartley|rnsubset|rotation|rotax2qr|roteu2qr|roteu2ro|rotmc2qc|rotmr2qr|rotpl2ro|rotqc2mc|rotqc2qr|rotqr2ax|rotqr2eu|rotqr2mr|rotqr2qc|rotqr2ro|rotqrmean|rotqrvec|rotro2eu|rotro2pl|rotro2qr|rsfft|sapisynth|schmitt|sigalign|skew3d|snrseg|sone2phon|soundspeed|specsub|specsubm|spendred|spgrambw|sphrharm|sprintcpx|sprintsi|ssubmmse|ssubmmsev|stdspectrum|stoi2prob|teager|texthvc|tilefigs|txalign|unixwhich|upolyhedron|usasi|vadsohn|voicebox|vonmisespdf|wavread|wavwrite|winenvar|writehtk|writewav|xticksi|xyzticksi|yticksi|zerocros|zerotrim|zoomfft';
0020 if nargin<2 || isempty(m)
0021     m='';
0022 end
0023 lm=lower(m);
0024 if nargin<1 || isempty(fn)
0025     fn='.'; % do files in current folder
0026 end
0027 if exist(fn,'dir')
0028     ff=v_regexfiles('\.m$',fn,char('n'+('r'-'n')*any(m=='r')));
0029 elseif exist(fn,'file')
0030     ff={fn};
0031 else
0032     error('first argument must be a file or folder name');
0033 end
0034 n=0;
0035 for i=1:length(ff)
0036     fid=fopen(ff{i},'rt');
0037     s=fread(fid,'*char')';
0038     fclose(fid);
0039     t=regexprep(s,['\<(' vbp ')\>(?![^''\n]*''[^''\n]*\n)'],'v_$1'); % keyword unless followed by a single quote somewhere on the same line
0040     if numel(t)>numel(s)
0041         if ~any(m=='b')
0042             if ~movefile(ff{i},[ff{i} '.old'])
0043                 error(sprintf('Cannot rename %s\n',ff{i}));
0044             end
0045         end
0046         fid=fopen(ff{i},'wt');
0047         if fid<0
0048             error(sprintf('Cannot write to %s\n',ff{i}));
0049         end
0050         fwrite(fid,t,'*char');
0051         fclose(fid);
0052         n=n+1;
0053         if any(lm=='v')
0054             nch=floor((length(t)-length(s))/2);
0055             if nch>1
0056                 fprintf(1,'%d changes in %s\n',nch,ff{i});
0057             else
0058                 fprintf(1,'%d change in %s\n',nch,ff{i});
0059             end
0060         end
0061     elseif any(m=='V')
0062         fprintf(1,'No changes in %s\n',ff{i});
0063     end
0064 end
0065 if ~any(m=='s')
0066     if any(lm=='v') && n>0
0067         fprintf(1,'===========\n');
0068     end
0069     if length(ff)>1
0070         fprintf(1,'%d of %d files updated\n',n,length(ff));
0071     else
0072         fprintf(1,'%d of %d file updated\n',n,length(ff));
0073     end
0074 end

Generated by m2html © 2003