From: <cde...@us...> - 2010-11-17 17:07:43
|
Revision: 7931 http://octave.svn.sourceforge.net/octave/?rev=7931&view=rev Author: cdemills Date: 2010-11-17 17:07:37 +0000 (Wed, 17 Nov 2010) Log Message: ----------- Try to detect more cases of badly formatted regexpes Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_name2idx.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2010-11-17 15:12:16 UTC (rev 7930) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2010-11-17 17:07:37 UTC (rev 7931) @@ -160,7 +160,10 @@ unwind_protect_cleanup fclose(fid); end_unwind_protect - eol = '(\r\n|\n|\r|\f|\x85)'; + %# explicit list taken from 'man pcrepattern' -- we enclose all + %# vertical separators in case the underlying regexp engine + %# doesn't have them all. + eol = '(\r\n|\n|\v|\f|\r|\x85)'; %# cut into lines -- include the EOL to have a one-to-one %# matching between line numbers. Use a non-greedy match. lines = regexp(in, ['.*?' eol], 'match'); Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_name2idx.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_name2idx.m 2010-11-17 15:12:16 UTC (rev 7930) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_name2idx.m 2010-11-17 17:07:37 UTC (rev 7931) @@ -61,15 +61,16 @@ %# translate list of variables to list of indices for indi= 1:size(subs, 1), %# regexp doesn't like empty patterns - if isempty(subs{indi}), continue, endif - %# convert '*' from standard pattern to regexp pattern - subs{indi} = regexprep(subs{indi}, '([^\.]|^)\*', "$1.*"); - %# quote '|[]()?$', otherwise the regexp will stall forever/fail + if isempty(subs{indi}), continue, endif + %# convert from standard pattern to regexp pattern + subs{indi} = regexprep(subs{indi}, '([^\.\\])(\*|\?)', "$1.$2"); + %# quote repetition ops at begining of line, otherwise the regexp + %# will stall forever/fail subs{indi} = regexprep(subs{indi}, \ - '([^\\])([\|\[\(\)\]\?\$])', "$1\\$2"); - %# work at start of line too - subs{indi} = regexprep(subs{indi}, \ - '^([\|\[\(\)\]\?\$])', "\\$1"); + '^([\*\+\?\{\}\|])', "\\$1"); + %# detect | followed by EOL + subs{indi} = regexprep(subs{indi}, '([^\\])\|$', "$1\\|"); + if 0 == index(subs{indi}, ':'), for indj = 1:min(length(names), count), %# sanity check if ~isempty(regexp(names{indj}, subs{indi})), Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m 2010-11-17 15:12:16 UTC (rev 7930) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m 2010-11-17 17:07:37 UTC (rev 7931) @@ -254,7 +254,7 @@ if ~strcmp(output_type, df._type{indc(indi)}), if dummy, continue; endif %# unmixable args -- falls back to type of parent container - error("Selected columns not compatible with cat() -- use 'cell' as output format"); + error("Selected columns %s not compatible with cat() -- use 'cell' as output format", mat2str(indc)); %# dead code -- suppress previous line for switching automagically the output format to df output_type = class(df); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |