Boost logo

Boost Users :

From: Marty Eaves (Marty.Eaves_at_[hidden])
Date: 2006-06-16 14:49:29


John,

Thanks, I'll look into the STL compatibility. We were using STL port
with VC6, but I think we are using the Microsoft STL with VC7. I'll
double check.

As far as test cases go, the regex string looks like this:

"^(((((((((19)|(20)|(21)))){0,1}((((0)|(1)|(2)|(3)|(4)|(5)|(6)|(7)|(8)|(
9)))(((0)|(1)|(2)|(3)|(4)|(5)|(6)|(7)|(8)|(9))))){0,1}(((01)|(02)|(03)|(
04)|(05)|(06)|(07)|(08)|(09)|(10)|(11)|(12)))(((01)|(02)|(03)|(04)|(05)|
(06)|(07)|(08)|(09)|(10)|(11)|(12)|(13)|(14)|(15)|(16)|(17)|(18)|(19)|(2
0)|(21)|(22)|(23)|(24)|(25)|(26)|(27)|(28)|(29)|(30)|(31)))))))"

As back ground information, this string was generated from a SRGS date
DTMF grammar. I am attempting to modify the code to try to determine
which parts of the regex string where used in the match. This is
necessary to implement support for the <tag> element in the SRGS
grammar. I am looking into potentially trying to use "named groups"
whenever a <tag> is encountered in the SRGS grammar as the "regex
grammar" is getting generated. Thus I am starting to play with the
extended match functionality. I have not modified any code yet, other
than using the BOOST_REGEX_MATCH_EXTRA flag in user.hpp. This appears
to cause the exception detailed in the call stack.

The test case failing is using the above grammar with the value of into
the "inputValue" parameter set to "2" in the code snippet below:

    else
    { // no termchar
        std::string tmpString;
        boost::match_results<std::string::const_iterator> what;

        try
        {
            boost::regex e(regex_grammar.c_str());
            // return false for partial match, true for full match, or
throw for
            // impossible match based on what we have so far...

            if(0 == boost::regex_match(inputData, what, e,
boost::match_default | boost::match_partial | boost::match_extra))
            {
               // the input so far could not possibly be valid so reject
it:
               return SEQUENCE_NOMATCH;
            }
        }
        catch(...)
        {

            VXML_LOG::CLogBuff log(LOG_REC_SIZE,IVILOG_VXML_MODULE);
            log.WriteRecord("CDtmfGrammar_custom::check",
// pTrm->GetLine(),
                         0,
                         IVILOG_CLASS_TRACE,
                         __FILE__,__LINE__,
                         "Exception from Boost regex caught. Grammar =
(%s)",regex_grammar.c_str());

            return SEQUENCE_NOMATCH;
        }

        // OK so far so good, but have we finished?

        if(what[0].matched)
        {
           GRAMMAR_RETM_ITER iter=m_input_map.find(inputData.c_str());
           if (iter != m_input_map.end())
           {
               if(pResultValue)
                   *pResultValue = (*iter).second;
           }
           else
           {
               if(pResultValue)
               {
                  slotData = CDtmfGrammar::addWhiteSpaces(inputData);
                  *pResultValue = slotData.c_str();
               }
           }
           // excellent, we have a result:
                   {
                boost::regex e(regex_grammar.c_str());

                std::string newInput;
                                bool matchOccurred = false;

                // loop thru 1 2 3 4 5 6 7 8 9 0 * # A B C D
                                std::string charArray =
"1234567890*#ABCD";
                                 
                for(unsigned int x=0; x < charArray.length(); x++)
                                {
                                    newInput = inputData +
charArray.substr(x,1);

                    if(0 != boost::regex_match(newInput, what, e,
boost::match_default | boost::match_partial | boost::match_extra))
                    {
                        matchOccurred = true;
                        break;
                    }
                                }
                                
                                if(!matchOccurred)
                                    return SEQUENCE_OK; // we are done.
                   }
        }
        // what we have so far is only a partial match...
        return SEQUENCE_MORE;
    }
}
 

________________________________

Marty Eaves

STAFF SOFTWARE ENGINEER
CALL PROCESSING & MEDIA SERVICES

RESEARCH AND DEVELOPMENT
INTERVOICE, INC.

P: (972) 454-8348
marty.eaves_at_[hidden]

________________________________

Intervoice: Connecting People and Information.

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of John Maddock
Sent: Thursday, June 15, 2006 1:22 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] Trap in regex library (help requested)

Marty Eaves wrote:
> I am having an issue using the regex library. I am developing in VC7
> and this issue occurs with both Boost 1.33.0 and 1.33.1. I have
> recently tried to start retrieving capture information in the regex
> matches by using the match_result and sub_match classes. In order to
> use these classes, the compile flag BOOST_REGEX_MATCH_EXTRA is
> required
> to be turned on (enabled in user.hpp). With the library is built with
> this flag on, I will get the following trap when the method calling
> regex_match() returns.

Just a clarification: you only need that define if you want extended
capture
information. You can access regular Perl style marked sub-expressions
perfectly well without it.

> An unhandled exception of type 'System.NullReferenceException'
> occurred
> in tg12.exe
>
>
>
> Additional information: Object reference not set to an instance of an
> object
>
>
>
> This exception appears to occur in the cleanup logic of the
> ~match_results() destructor. I have yet to make any changes to the
> code
> to use the match_results object. In other words, the code I am using
> worked previously without the BOOST_REGEX_MATCH_EXTRA flag enabled.
> Are
> there any compiler options required?

No none, if I'm reading your stack trace right it's std::vector that's
causing the failure: there's nothing fancy going on inside sub_match
just a
scoped_ptr to a vector or sub_matches. Do you have a test case I can
look
at? If you're using managed code (looks like you are?) you might want
to
double check to see if there are any known issues using that with the
STL.

John.

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

This e-mail transmission may contain information that is proprietary, privileged and/or confidential and is intended exclusively for the person(s) to whom it is addressed. Any use, copying, retention or disclosure by any person other than the intended recipient or the intended recipient's designees is strictly prohibited. If you are the intended recipient, you must treat the information in confidence and in accordance with all laws related to the privacy and confidentiality of such information. If you are not the intended recipient or their designee, please notify the sender immediately by return e-mail and delete all copies of this email, including all attachments.


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