Hi, While i was writing the below code in a separate project inside visual studio express, It works fine!
Now when I am using the same code in a Adobe InDesign plugin then boost::regex_search fails..
I am not getting the exact reason...
Any idea for resolving this will be great help.
void MTSTestFunctions::ParseAllMarker(std::wstring& inText, std::vector &outMarkerInfoVec)
{
std::wstring::const_iterator start = inText.begin();
std::wstring::const_iterator end = inText.end();
boost::wregex pattern(L"((<.*?>)|(\\[[^[].*?[^]]\\])|(\\[\\[.*?\\]\\]))");
boost::wsmatch what;
boost::match_flag_type flags = boost::match_default;
int32 index = 0;
try
{
while(boost::regex_search(start, end, what, pattern, flags))
{
MarkerInfo tmpMarkerInfo;
tmpMarkerInfo.mMarkerText.assign(what[0]);
tmpMarkerInfo.mStartIndex = (what.position() + index);
index += what.position();
tmpMarkerInfo.mEndIndex = (index += what.position());
tmpMarkerInfo.mMarkerTextLength = (index + what.length());
index += what.length();
// update search position:
start = what[0].second;
// update flags:
flags |= boost::match_prev_avail;
flags |= boost::match_not_bob;
}
}
catch(std::runtime_error ex)
{
}
}
Thanks
Hi,
As per my recent finding, If I make project setting to use static version of the library then in that case
boost::regex_serach didn't work in InDesign plugin project. But If I change my project setting to use
shared build then the program crash. Giving "ITERATOR LIST CORRUPTED!" assert.
Also the InDesign plugin setting is such that it makes _SECURE_SCL = 0 and _HAS_ITERATOR_DEBUGGING = 0.
Any suggestion???
Thanks
Hi,
If I modify by above code as below for using std::tr1::regex the I gets the same crash...and error.
void MTSTestFunctions::ParseAllMarker(std::wstring& inTextO, std::vector<MarkerInfo> &outMarkerInfoVec)
{
std::wstring inText;
inText.assign(inTextO);
std::wstring::const_iterator start = inText.begin();
std::wstring::const_iterator end = inText.end();
std::tr1::wregex pattern(L"((<.*?>)|(\\[[^[].*?[^]]\\])|(\\[\\[.*?\\]\\]))");
std::tr1::wsmatch what;
std::tr1::regex_constants::match_flag_type flags = std::tr1::regex_constants::match_default;
int32 index = 0;
try
{
while(std::tr1::regex_search(start, end, what, pattern, flags))
{
MarkerInfo tmpMarkerInfo;
tmpMarkerInfo.mMarkerText.assign(what[0]);
tmpMarkerInfo.mStartIndex = (what.position() + index);
index += what.position();
tmpMarkerInfo.mEndIndex = (index += what.position());
tmpMarkerInfo.mMarkerTextLength = (index + what.length());
index += what.length();
// update search position:
start = what[0].second;
// update flags:
flags |= std::tr1::regex_constants::match_prev_avail;
//flags |= std::tr1::regex_constants::match_not_bob;
}
}
catch(std::runtime_error ex)
{
}
}
Hi Dirk,
The problem which I am facing is on Window XP, Visual studio 2008 Express.
Since plugin project makes the _HAS_ITERATOR_DEBUGGING and _SCL_SECURE to 0.
I think promblem is with that too
Also I have builded the latest boost library 1.49 wiht these Preprocessor set to 0. Still I am getting this crash at run time.
On mac things are running perfect!
---------------------------------------------------------------------- ----------------------------------------------------------
I have tested on Windows7, and yes the crash is still there.
#if _HAS_ITERATOR_DEBUGGING
CAlert::InformationAlert(PMString("_HAS_ITERATOR_DEBUGGING--YES").Set Translatable(kFalse));
#else
CAlert::InformationAlert(PMString("_HAS_ITERATOR_DEBUGGING---NO").Set Translatable(kFalse));
#endif
#if _SECURE_SCL
CAlert::InformationAlert(PMString("_SECURE_SCL--YES").SetTranslatable (kFalse));
#else
CAlert::InformationAlert(PMString("_SECURE_SCL---NO").SetTranslatable (kFalse));
#endif
Output has following result:
_HAS_ITERATOR_DEBUGGING---NO
_SECURE_SCL--YES
So in the project setting I have set the Preprocessor Macro value of _SECURE_SCL=0
Then there comes a lot of warnings regarding the Macro redefinition and continue and tested the build, But the crash is not resolved yet.
---------------------------------------------------------------------- ---------------------------------------------------------------------- --------------------------------------------------------------
further I have tested the same code on another Machine Window7 64bits, VS2008 Express, InDesign CS4 Release
In this case
_HAS_ITERATOR_DEBUGGING---NO
_SECURE_SCL-- NO
and the code was working fine without the crash.
---------------------------------------------------------------------- ---------------------------------------------------------------------- ---------------------------------------------------------------
Any advice?????
Thanks
Yes, Windows is a problem.
Just kidding.
Use the dll provided by InDesign, or if you really need a different version for compatibility with prebuilt external libraries, make sure that you don't call InDesign's methods and InDesign does not call yours and those of any third library. E.g. you isolate the code into a separate dll and ensure that the linker does not import or export any questionable symbols. On the Mac I'd use otool and nmedit for that.
Dirk
Hi Dirk,
I have installed the release version today and used the lib provided with the InDesign CS4 SDK (InDesignCS4ProductsSDK_Build578) , everthing worked.
Again when I have switched to DEBUG and used the debug version of the lib provided by the InDesignCS4ProductsSDK_Build578, programms crashed!
For now I am trying to build the latest boost library 1.49 with _SECURE_SCL set to 1 and _HAS_ITERATOR_DEBUGGING set to 0. Because when I debuf my program like code below
it seems that the project setting for _SECURE_SCL is 1 and _HAS_ITERATOR_DEBUGGING is 0.
#if _HAS_ITERATOR_DEBUGGING
CAlert::InformationAlert(PMString("_HAS_ITERATOR_DEBUGGING 1").SetTranslatable(kFalse));
#else
CAlert::InformationAlert(PMString("_HAS_ITERATOR_DEBUGGING 0").SetTranslatable(kFalse));
#endif
#if _SECURE_SCL
CAlert::InformationAlert(PMString("_SECURE_SCL 1").SetTranslatable(kFalse));
#else
CAlert::InformationAlert(PMString("_SECURE_SCL 0").SetTranslatable(kFalse));
#endif
I just want to conform/know (for Adobe Employee if someone is reading this) what they have set for these preprocessor macro when they have builded the Boost regex library which they have supplied with the SDK version (InDesignCS4ProductsSDK_Build578). As I haven't got this setting anywhere mentioned in the SDK.
Please let me know if I am missing something!!
Thanks a lot Dirk!
North America
Europe, Middle East and Africa
Asia Pacific