Skip to content

Commit 0b2041b

Browse files
committed
Improved error message for triggers that won't recompile
1 parent 698bc2f commit 0b2041b

File tree

1 file changed

+74
-65
lines changed

1 file changed

+74
-65
lines changed

dialogs/world_prefs/configuration.cpp

Lines changed: 74 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,88 +2388,97 @@ void CMUSHclientDoc::RecompileRegularExpressions ()
23882388
int iAliasErrors = 0;
23892389
#endif // ALIASES_USE_UTF8
23902390

2391-
POSITION pos;
2392-
CString strName;
2393-
CString strRegexp;
2391+
CString sPluginName = "main world";
23942392

2395-
for (pos = GetTriggerMap ().GetStartPosition(); pos;)
2396-
{
2397-
CTrigger * pTrigger;
2398-
GetTriggerMap ().GetNextAssoc (pos, strName, pTrigger);
2393+
if (m_CurrentPlugin)
2394+
{
2395+
sPluginName = "plugin ";
2396+
sPluginName += m_CurrentPlugin->m_strName;
2397+
}
2398+
2399+
POSITION pos;
2400+
CString strName;
2401+
CString strRegexp;
23992402

2400-
if (pTrigger->regexp)
2403+
for (pos = GetTriggerMap ().GetStartPosition(); pos;)
2404+
{
2405+
CTrigger * pTrigger;
2406+
GetTriggerMap ().GetNextAssoc (pos, strName, pTrigger);
2407+
2408+
if (pTrigger->regexp)
2409+
{
2410+
delete pTrigger->regexp; // get rid of old one
2411+
if (pTrigger->bRegexp)
2412+
strRegexp = pTrigger->trigger;
2413+
else
2414+
strRegexp = ConvertToRegularExpression (pTrigger->trigger);
2415+
}
2416+
2417+
// compile regular expression
2418+
try
2419+
{
2420+
pTrigger->regexp = regcomp (strRegexp, (pTrigger->ignore_case ? PCRE_CASELESS : 0) |
2421+
(pTrigger->bMultiLine ? PCRE_MULTILINE : 0) |
2422+
(m_bUTF_8 ? PCRE_UTF8 : 0)
2423+
);
2424+
} // end of try
2425+
catch(CException* e)
24012426
{
2402-
delete pTrigger->regexp; // get rid of old one
2403-
if (pTrigger->bRegexp)
2404-
strRegexp = pTrigger->trigger;
2405-
else
2406-
strRegexp = ConvertToRegularExpression (pTrigger->trigger);
2407-
}
2408-
2409-
// compile regular expression
2410-
try
2411-
{
2412-
pTrigger->regexp = regcomp (strRegexp, (pTrigger->ignore_case ? PCRE_CASELESS : 0) |
2413-
(pTrigger->bMultiLine ? PCRE_MULTILINE : 0) |
2414-
(m_bUTF_8 ? PCRE_UTF8 : 0)
2415-
);
2416-
} // end of try
2417-
catch(CException* e)
2418-
{
2419-
e->Delete ();
2420-
iTriggerErrors++;
2421-
pTrigger->regexp = NULL;
2422-
} // end of catch
2423-
} // end of for each trigger
2427+
e->Delete ();
2428+
iTriggerErrors++;
2429+
ColourNote ("red", "",
2430+
TFormat ("In %s, could not recompile trigger (%s) matching on: %s.",
2431+
(LPCTSTR) sPluginName, (LPCTSTR) pTrigger->strInternalName, (LPCTSTR) strRegexp));
2432+
pTrigger->regexp = NULL;
2433+
} // end of catch
2434+
} // end of for each trigger
24242435

24252436
#if ALIASES_USE_UTF8
24262437

2427-
for (pos = GetAliasMap ().GetStartPosition(); pos;)
2428-
{
2429-
CAlias * pAlias;
2430-
GetAliasMap ().GetNextAssoc (pos, strName, pAlias);
2438+
for (pos = GetAliasMap ().GetStartPosition(); pos;)
2439+
{
2440+
CAlias * pAlias;
2441+
GetAliasMap ().GetNextAssoc (pos, strName, pAlias);
24312442

2432-
if (pAlias->regexp)
2443+
if (pAlias->regexp)
2444+
{
2445+
delete pAlias->regexp; // get rid of old one
2446+
if (pAlias->bRegexp)
2447+
strRegexp = pAlias->name;
2448+
else
2449+
strRegexp = ConvertToRegularExpression (pAlias->name);
2450+
}
2451+
2452+
// compile regular expression
2453+
try
24332454
{
2434-
delete pAlias->regexp; // get rid of old one
2435-
if (pAlias->bRegexp)
2436-
strRegexp = pAlias->name;
2437-
else
2438-
strRegexp = ConvertToRegularExpression (pAlias->name);
2439-
}
2440-
2441-
// compile regular expression
2442-
try
2443-
{
2444-
pAlias->regexp = regcomp (strRegexp, (pAlias->bIgnoreCase ? PCRE_CASELESS : 0) |
2445-
(m_bUTF_8 ? PCRE_UTF8 : 0)
2446-
);
2447-
} // end of try
2448-
catch(CException* e)
2449-
{
2450-
e->Delete ();
2451-
iAliasErrors++;
2452-
pAlias->regexp = NULL;
2453-
} // end of catch
2454-
} // end of for each alias
2455+
pAlias->regexp = regcomp (strRegexp, (pAlias->bIgnoreCase ? PCRE_CASELESS : 0) |
2456+
(m_bUTF_8 ? PCRE_UTF8 : 0)
2457+
);
2458+
} // end of try
2459+
catch(CException* e)
2460+
{
2461+
e->Delete ();
2462+
iAliasErrors++;
2463+
ColourNote ("red", "",
2464+
TFormat ("In %s, could not recompile alias (%s) matching on: %s.",
2465+
(LPCTSTR) sPluginName, (LPCTSTR) pAlias->strInternalName, (LPCTSTR) strRegexp));
2466+
pAlias->regexp = NULL;
2467+
} // end of catch
2468+
} // end of for each alias
24552469

24562470
#endif // ALIASES_USE_UTF8
24572471

2458-
const char * sPluginName = "(Main world)";
2459-
2460-
if (m_CurrentPlugin)
2461-
sPluginName = m_CurrentPlugin->m_strName;
2462-
24632472
if (iTriggerErrors)
24642473
ColourNote ("white", "red",
2465-
TFormat ("In plugin %s, %i trigger(s) could not be recompiled.",
2466-
sPluginName, iTriggerErrors));
2474+
TFormat ("In %s, %i trigger(s) could not be recompiled.",
2475+
(LPCTSTR) sPluginName, iTriggerErrors));
24672476

24682477
#if ALIASES_USE_UTF8
24692478
if (iAliasErrors)
24702479
ColourNote ("white", "red",
2471-
TFormat ("In plugin %s, %i alias(es) could not be recompiled.",
2472-
sPluginName, iAliasErrors));
2480+
TFormat ("In %s, %i alias(es) could not be recompiled.",
2481+
(LPCTSTR) sPluginName, iAliasErrors));
24732482
#endif // ALIASES_USE_UTF8
24742483

24752484
} // end of CMUSHclientDoc::RecompileRegularExpressions

0 commit comments

Comments
 (0)