Boost logo

Boost Users :

From: The Grumpiest Man You Know (mrgrumpyguts_at_[hidden])
Date: 2005-02-20 18:42:27


Hi,

I think this is a bug but I'm willing to believe I'm misusing
something. As a side point, I'm unsure of how to choose the regex
syntax. I think I use boost::regex::perl as the second argument to
the constructor but I haven't had much look with either that or the
char_classes value.

Anyway for me the snippet below the ----s hangs in the second
find_all_regex. Ok, it may not hang, it may be building up a nice big
core to dump but I only leave it for 20 seconds or so. This started
with me trying to use find_regex which segfaulted when I tried to
increment the iterator for the first time. I thought that might be me
so I tried the safer way of just asking someone else to do all the
real work :).

This might prompt calls of "known issue." if I haven't messed up. In
which case would someone care to hit me with a clue stick as to how I
should check before bugging the list?

Thanks for your time.

Using Debian unstable:
ii libboost-regex 1.32.0-2 regular expression library for C++
ii libboost-regex 1.32.0-2 regular expression library for C++

which I'm pretty sure is one for the library and one for the dev
headers but I'm a noob there too, so I could be wrong.

The compiler is:
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
--with-system-zlib --enable-nls --without-included-gettext
--enable-__cxa_atexit --enable-clocale=gnu --enable-debug
--enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc
i486-linux
Thread model: posix
gcc version 3.3.5 (Debian 1:3.3.5-8)

--------------

#include <string>
#include <iostream>

#include <boost/algorithm/string_regex.hpp>

template<class T>
std::ostream& operator<<(std::ostream& cout, const std::vector<T>& v)
{
  std::copy(v.begin(), v.end(), std::ostream_iterator<T>(cout, " "));

  return cout;
}

main()
{
  std::string line1("word -opt 5 -opt 45M -flag word -flag -opt word");

  typedef boost::find_iterator<std::string::iterator> fi;
  for (fi i = boost::make_find_iterator(line1,
boost::first_finder("word", boost::is_equal()));
       ! i.eof();
       ++i) {
    std::cout << boost::copy_iterator_range<std::string>(*i) << std::endl;
  }

  std::vector<std::string> result;
  boost::regex rx1(" [-a-z]*");
  boost::find_all_regex(result, line1, rx1);
  std::cout << result.size() << result << std::endl;

  result.clear();

  boost::regex rx2("[-a-z]*");
  boost::find_all_regex(result, line1, rx2);
  std::cout << result.size() << result << std::endl;

  std::cout << line1 << std::endl;
}

-- 
Blue Skies

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net