Boost logo

Boost Users :

From: Kosta Adarchenko (kosta_adar_at_[hidden])
Date: 2004-08-12 20:26:48


 
Here is the problem:
I want to find a simple regular _expression something like
\\d\\d\\d\\d\\d\\d in a large file (15 mb) using VC++ 7.1 .
I use Spirit's File Iterator as the input iterator for the search algorithm.
 
After some seven thousands hits the match algo throughs the memory exhausted exception.
So I cought the exception and moved the iterator by one, printed the location it points to in my searched file to view the problematic section for the regex find algorithm.
After the "problematic section" of some 300 chars ends the algorithm keeps working fine.
here is the code.
//-------------------------------------------------------------------------------------------
void TheFunction()
{
  
//print the problematic section here
ofstream of;
of.open("d:\\err1.txt");
boost::spirit::file_iterator< > begin("d:\\log1.txt");
boost::spirit::file_iterator<> beginning_saved(begin); //save the beginning in order to compare later
boost::spirit::file_iterator< > ending;
ending= begin.make_end();
boost::match_results<boost::spirit::file_iterator<char > > what;
boost::match_flag_type flags = boost::match_default;
long matchescounter=0;
std::exception e;
  
  int i;
   bool found;
  found=false;
   try
    {
  found=boost::regex_search(begin, ending, what, _expression, flags);
  if (found)
   {
     begin =what[0].second;
     cout<<what[0];
     matchescounter=1;
   }
    }
    catch (std::exception &e)
    {
    cout<<e.what();
   
    }
 while(found)
   {
      
      
    try
    {
        found=boost::regex_search(begin, ending, what, _expression, flags);
     begin =what[0].second;
  
  if (found)
   {
   cout<<matchescounter<<"----------"<<what[0]<<"-------------------"<<what[0].second-beginning_saved<<"\n";
      matchescounter++;
   }
    }
    catch (std::exception &e)
    {
  
  cout<<*begin;
      of<<*begin;
   begin+=1;
    }
  
    }
  
   cout<<"---------------the end------------\n";
   cout<<matchescounter;
   of.close();
}
//---------------------------------------------------------------------------------------
I have noticed that the problem happens not with all large files, but with quite a bit of them.
After I have received the problematic section in my file, I ran the program on it and it did not raise any exceptions.
Please , help me I have a Graduate project to complete within 3 weeks from now, and this is one of the major bugs I have not resolved.
 
Yours truely, Kosta.
Desparatly waiting for your reply.

                
---------------------------------
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now.



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