From: Ian S. <ian...@st...> - 2005-10-05 14:49:51
|
Matt, Does your commit mean that previously, if I globbed for *abc, then FOOabcBAR would pass? That is not standard globbing behaviour, and I suggest making your "$" fix non-optional. Additionally there may need to be a "^" in the rexexp too. Ian. ml...@us... wrote: > Update of /cvsroot/vxl/vxl/core/vul > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17184 > > Modified Files: > vul_file_iterator.cxx vul_file_iterator.h > Log Message: > added support for matching EOL > > Index: vul_file_iterator.cxx > =================================================================== > RCS file: /cvsroot/vxl/vxl/core/vul/vul_file_iterator.cxx,v > retrieving revision 1.24 > retrieving revision 1.25 > diff -w -U2 -d -r1.24 -r1.25 > --- vul_file_iterator.cxx 19 Sep 2004 19:14:18 -0000 1.24 > +++ vul_file_iterator.cxx 5 Oct 2005 14:35:20 -0000 1.25 > @@ -46,5 +46,5 @@ > } > > - vul_file_iterator_data(char const* glob); > + vul_file_iterator_data(char const* glob, bool match_eol); > > void mkname() { > @@ -88,5 +88,5 @@ > }; > > -vul_file_iterator_data::vul_file_iterator_data(char const* glob) > +vul_file_iterator_data::vul_file_iterator_data(char const* glob, bool match_eol) > { > original_dirname_ = vul_file::dirname(glob); > @@ -127,4 +127,7 @@ > } > > + if(match_eol) > + re += '$'; > + > reg_exp_.compile(re.c_str()); > > @@ -157,5 +160,5 @@ > vul_reg_exp reg_exp_; > > - vul_file_iterator_data(char const* glob); > + vul_file_iterator_data(char const* glob, bool match_eol); > > void mkname() { > @@ -198,5 +201,6 @@ > }; > > -vul_file_iterator_data::vul_file_iterator_data(char const* glob) > +vul_file_iterator_data::vul_file_iterator_data(char const* glob, > + bool match_eol) > { > original_dirname_ = vul_file::dirname(glob) + "/"; > @@ -236,4 +240,7 @@ > } > > + if(match_eol) > + re += '$'; > + > reg_exp_.compile(re.c_str()); > > @@ -246,8 +253,9 @@ > > // ----------------------------------------------------------------------------- > + > vul_file_iterator::vul_file_iterator(char const* glob) > { > p = 0; > - reset(glob); > + reset(glob, false); > } > > @@ -255,5 +263,17 @@ > { > p = 0; > - reset(glob.c_str()); > + reset(glob.c_str(), false); > +} > + > +vul_file_iterator::vul_file_iterator(char const* glob, bool match_eol) > +{ > + p = 0; > + reset(glob, match_eol); > +} > + > +vul_file_iterator::vul_file_iterator(vcl_string const& glob, bool match_eol) > +{ > + p = 0; > + reset(glob.c_str(), match_eol); > } > > @@ -263,8 +283,8 @@ > } > > -void vul_file_iterator::reset(char const* glob) > +void vul_file_iterator::reset(char const* glob, bool match_eol) > { > delete p; > - p = new vul_file_iterator_data(glob); > + p = new vul_file_iterator_data(glob, match_eol); > } > > > Index: vul_file_iterator.h > =================================================================== > RCS file: /cvsroot/vxl/vxl/core/vul/vul_file_iterator.h,v > retrieving revision 1.10 > retrieving revision 1.11 > diff -w -U2 -d -r1.10 -r1.11 > --- vul_file_iterator.h 19 Sep 2004 19:14:18 -0000 1.10 > +++ vul_file_iterator.h 5 Oct 2005 14:35:20 -0000 1.11 > @@ -16,4 +16,5 @@ > // Peter Vanroose 27/05/2001: Corrected the documentation > // Ian Scott 12/06/2003: Added filen?m[abc].* notation to unix and dos version > +// Matt Leotta 04/10/2005: Added match_eol option > // \endverbatim > > @@ -38,4 +39,14 @@ > // rather than opendir/glob/etc. > // > +// By default the file iterator does not match the end of a line > +// so "/dir/" matches the same as "/dir/*". When this is not the > +// desired effect enable the match_eol flag > +// \code > +// for (vul_file_iterator fn("/dir/file?",true); fn; ++fn) { > +// ... use fn() as filename > +// } > +// \endcode > +// this will match "/dir/file1" but not "/dir/file12" > +// > // Valid glob patterns are unix-like - '?' matches precisely one character > // '*' matches any sequence (including empty), [abc] matches either 'a' or 'b' or 'c' > @@ -54,4 +65,12 @@ > vul_file_iterator(vcl_string const& glob); > > + //: Initialize, and scan to get first file from "glob" > + // \param match_eol enables matching of the end of line > + vul_file_iterator(char const* glob, bool match_eol); > + > + //: Initialize, and scan to get first file from "glob" > + // \param match_eol enables matching of the end of line > + vul_file_iterator(vcl_string const& glob, bool match_eol); > + > ~vul_file_iterator(); > > @@ -79,5 +98,5 @@ > > //: Run a new match > - void reset(char const* glob); > + void reset(char const* glob, bool match_eol = false); > > protected: > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Vxl-commit mailing list > Vxl...@li... > https://lists.sourceforge.net/lists/listinfo/vxl-commit |