Problem using regex library in Windows/cygwin
Hi, I have a problem using the Boost regex library. I have isolated the problem to the attached piece of code. For some reason the output returned by the function that uses regex is garbage. I have tested the same program on a Linux version of boost and it works fine. I wonder if the problem is on the Windows installation. Could someone using Windows or Cygwin test this and tell me if it works? I've just re-installed the cygwin version (1.33.1-3) and I still get the same error. Here is a typical interaction. It should extract the XML attribute and value but instead it returns garbage: [diego@valencia ~...af/src]$ g++ -o regexError.exe regexError.cpp -lboost_regex-gcc-mt [diego@valencia ~...af/src]$ regexError Write a fragment of XML: this <test arg="a1">is a test</test> yeah Write the XML tag to search: test Found element is a test Searching arg="a1" Found attribute 1g with value a1 Write a fragment of XML: this <test a2="more">is another test</test> Write the XML tag to search: test Found element is another test Searching a2="more" Found attribute or with value morY Write a fragment of XML: end [diego@valencia ~...af/src]$ -- Do you want to know what is going on in Language Technology in Australia and New Zealand? Join ALTA -- http://www.alta.asn.au/ This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily the views of Macquarie University. --------------------------------------------------------------------- Diego MOLLA ALIOD diego@ics.mq.edu.au Department of Computing http://www.ics.mq.edu.au/~diego Macquarie University
Diego Molla wrote:
Hi,
I have a problem using the Boost regex library. I have isolated the problem to the attached piece of code. For some reason the output returned by the function that uses regex is garbage. I have tested the same program on a Linux version of boost and it works fine. I wonder if the problem is on the Windows installation. Could someone using Windows or Cygwin test this and tell me if it works?
There's at least one issue with your code, in: if (regex_search(what[1].str(),what,attrMarkup)) { the result of what[1].str() is a temporary string object: by the time the call returns the object has gone out of scope, and the iterators stored in "what" are invalid. HTH, John.
participants (2)
-
Diego Molla
-
John Maddock