Regular Expression bug in Visual Studio 2005

I already encountered similar issue once before but did not write down the details.

Text:

#define TBN_GETBUTTONINFO (TBN_FIRST-0)
#define TBN_BEGINDRAG (TBN_FIRST-1)
#define TBN_ENDDRAG (TBN_FIRST-2)
#define TBN_BEGINADJUST (TBN_FIRST-3)
#define TBN_ENDADJUST (TBN_FIRST-4)
#define TBN_RESET (TBN_FIRST-5)
#define TBN_QUERYINSERT (TBN_FIRST-6)
#define TBN_QUERYDELETE (TBN_FIRST-7)
#define TBN_TOOLBARCHANGE (TBN_FIRST-8)
#define TBN_CUSTHELP (TBN_FIRST-9)

Find What (using regular expressions):

^\#define:b+({([A-z\_])+}):b+.+$

Replace With:

#define MSG_\1(nIdentifier, Function) CC_MSG_WM_NOTIFY(\1, NMHDR, nIdentifier, Function)

Visual Studio C++.NET 2003 (correct):

#define MSG_TBN_GETBUTTONINFO(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_GETBUTTONINFO, NMHDR, nIdentifier, Function)
#define MSG_TBN_BEGINDRAG(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_BEGINDRAG, NMHDR, nIdentifier, Function)
#define MSG_TBN_ENDDRAG(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_ENDDRAG, NMHDR, nIdentifier, Function)
#define MSG_TBN_BEGINADJUST(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_BEGINADJUST, NMHDR, nIdentifier, Function)
#define MSG_TBN_ENDADJUST(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_ENDADJUST, NMHDR, nIdentifier, Function)
#define MSG_TBN_RESET(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_RESET, NMHDR, nIdentifier, Function)
#define MSG_TBN_QUERYINSERT(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_QUERYINSERT, NMHDR, nIdentifier, Function)
#define MSG_TBN_QUERYDELETE(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_QUERYDELETE, NMHDR, nIdentifier, Function)
#define MSG_TBN_TOOLBARCHANGE(nIdentifier, Function) CC_MSG_WM_NOTIFY(TBN_TOOLBARCHANGE, NMHDR, nIdentifier, Function)

Visual Studio C++.NET 2005 (wrong):

#define TBN_GETBUTTONINFO (TBN_FIRST-0)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)
#define MSG_(nIdentifier, Function) CC_MSG_WM_NOTIFY(, NMHDR, nIdentifier, Function)

Leave a Reply