Boost logo

Boost Users :

From: Giany2k (giany2k_at_[hidden])
Date: 2002-03-13 23:07:28


Hi,

Can anyone explain to me why I get "Abnormal program termination" at the
exit of the function shown below in the example. The error occurs when
exiting the function after it was called second time.

//----------------------------------------------------------------------
-----

#include <vcl.h>
#pragma hdrstop

#include <boost/regex.hpp>
#include <string>

#include "Unit1.h"
//----------------------------------------------------------------------
-----
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//----------------------------------------------------------------------
-----
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
        Edit1->Clear();
}
//----------------------------------------------------------------------
-----
using namespace boost;
using namespace std;

void __fastcall TForm1::Button1Click(TObject *Sender)
{
        Memo1->Clear();
        if ( Edit1->Text.IsEmpty() )
                return;

        regex e( std::string(Edit1->Text.c_str()) );
        cmatch what;
        string response;
        TFileStream* file = new TFileStream( "1.htm", fmOpenRead );

        response.resize(file->Size+1);
        file->Read(response.begin(), file->Size);

        response[file->Size] = 0;

        delete file;

        std::string::const_iterator start;

        start = response.begin();

        while( regex_search( start, what, e ) )
        {
                for ( unsigned int i = 0 ; i < what.size() ; i++ )
                {
                        std::string result = std::string(what[i].first,
what[i].second);
                        Memo1->Lines->Add( result.c_str() );
                }
                Memo1->Lines->Add("");
                start = what[0].second;
        }
}
//----------------------------------------------------------------------
-----


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