diff --git a/scintilla/win32/PlatWin.cxx b/scintilla/win32/PlatWin.cxx index 5fd3e5795..e4c69a08e 100644 --- a/scintilla/win32/PlatWin.cxx +++ b/scintilla/win32/PlatWin.cxx @@ -782,14 +782,14 @@ void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil DWORD valEmpty = dwordFromBGRA(0,0,0,0); DWORD valFill = dwordFromBGRA( - static_cast(GetBValue(fill.AsLong()) * alphaFill / 255), - static_cast(GetGValue(fill.AsLong()) * alphaFill / 255), - static_cast(GetRValue(fill.AsLong()) * alphaFill / 255), + static_cast(fill.GetBlue() * alphaFill / 255), + static_cast(fill.GetGreen() * alphaFill / 255), + static_cast(fill.GetRed() * alphaFill / 255), static_cast(alphaFill)); DWORD valOutline = dwordFromBGRA( - static_cast(GetBValue(outline.AsLong()) * alphaOutline / 255), - static_cast(GetGValue(outline.AsLong()) * alphaOutline / 255), - static_cast(GetRValue(outline.AsLong()) * alphaOutline / 255), + static_cast(outline.GetBlue() * alphaFill / 255), + static_cast(outline.GetGreen() * alphaFill / 255), + static_cast(outline.GetRed() * alphaFill / 255), static_cast(alphaOutline)); DWORD *pixels = static_cast(image); for (int y=0; yhExitThread = CreateEvent(NULL,TRUE,FALSE,NULL); lpdl->hTerminatedThread = CreateEvent(NULL,TRUE,TRUE,NULL); - lvc; - pszHeader; - return TRUE; - } diff --git a/src/Edit.c b/src/Edit.c index 0185a1bcd..b68abde87 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1719,7 +1719,6 @@ void EditTitleCase(HWND hwnd) UINT cpEdit; int i; BOOL bNewWord = TRUE; - BOOL bWordEnd = TRUE; BOOL bChanged = FALSE; #ifdef BOOKMARK_EDITION @@ -2207,6 +2206,7 @@ void EditHex2Char(HWND hwnd) { if (SendMessage(hwnd,SCI_GETSELTEXT,0,0) <= COUNTOF(ch)) { SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)ch); + ch[31] = '\0'; if (StrChrIA(ch,' ') || StrChrIA(ch,'\t') || StrChrIA(ch,'\r') || StrChrIA(ch,'\n') || StrChrIA(ch,'-')) return; @@ -2262,13 +2262,14 @@ void EditModifyNumber(HWND hwnd,BOOL bIncrease) { if (iSelEnd - iSelStart) { - char chFormat[32] = ""; - char chNumber[32]; + char chFormat[32] = { '\0' }; + char chNumber[32] = { '\0' }; int iNumber; int iWidth; if (SendMessage(hwnd,SCI_GETSELTEXT,0,0) <= COUNTOF(chNumber)) { SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)chNumber); + chNumber[31] = '\0'; if (StrChrIA(chNumber,'-')) return; @@ -2397,7 +2398,7 @@ void EditTabsToSpaces(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS) for (iTextW = 0; iTextW < cchTextW; iTextW++) { WCHAR w = pszTextW[iTextW]; - if (w == L'\t' && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) { + if (w == L'\t' && (!bOnlyIndentingWS || bIsLineStart)) { for (j = 0; j < nTabWidth - i % nTabWidth; j++) pszConvW[cchConvW++] = L' '; i = 0; @@ -2527,7 +2528,7 @@ void EditSpacesToTabs(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS) for (iTextW = 0; iTextW < cchTextW; iTextW++) { WCHAR w = pszTextW[iTextW]; - if ((w == L' ' || w == L'\t') && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) { + if ((w == L' ' || w == L'\t') && (!bOnlyIndentingWS || bIsLineStart)) { space[j++] = w; if (j == nTabWidth - i % nTabWidth || w == L'\t') { if (j > 1 || pszTextW[iTextW+1] == L' ' || pszTextW[iTextW+1] == L'\t') @@ -2814,14 +2815,14 @@ void EditMoveDown(HWND hwnd) // void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend) { - char mszPrefix1[256*3] = ""; - char mszPrefix2[256*3] = ""; + char mszPrefix1[256*3] = { '\0' }; + char mszPrefix2[256*3] = { '\0' }; BOOL bPrefixNum = FALSE; int iPrefixNum = 0; int iPrefixNumWidth = 1; char *pszPrefixNumPad = ""; - char mszAppend1[256*3] = ""; - char mszAppend2[256*3] = ""; + char mszAppend1[256*3] = { '\0' }; + char mszAppend2[256*3] = { '\0' }; BOOL bAppendNum = FALSE; int iAppendNum = 0; int iAppendNumWidth = 1; @@ -3168,7 +3169,7 @@ void EditAlignText(HWND hwnd,int nMode) else { - char tchLineBuf[BUFSIZE_ALIGN*3] = ""; + char tchLineBuf[BUFSIZE_ALIGN*3] = { '\0' }; WCHAR wchLineBuf[BUFSIZE_ALIGN*3] = L""; WCHAR *pWords[BUFSIZE_ALIGN*3/2]; WCHAR *p = wchLineBuf; @@ -3361,8 +3362,8 @@ void EditAlignText(HWND hwnd,int nMode) // void EditEncloseSelection(HWND hwnd,LPCWSTR pwszOpen,LPCWSTR pwszClose) { - char mszOpen[256*3] = ""; - char mszClose[256*3] = ""; + char mszOpen[256*3] = { '\0' }; + char mszClose[256*3] = { '\0' }; int mbcp; int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0); @@ -3427,7 +3428,7 @@ void EditEncloseSelection(HWND hwnd,LPCWSTR pwszOpen,LPCWSTR pwszClose) // void EditToggleLineComments(HWND hwnd,LPCWSTR pwszComment,BOOL bInsertAtStart) { - char mszComment[256*3] = ""; + char mszComment[256*3] = { '\0' }; int cchComment; int mbcp; int iAction = 0; @@ -4745,7 +4746,7 @@ void EditEnsureSelectionVisible(HWND hwnd) // void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt) { - WCHAR tch[256] = L""; + WCHAR tch[256] = { L'\0' }; WCHAR *p; DWORD cch = 0; UINT cpEdit; diff --git a/src/Helpers.c b/src/Helpers.c index 2c2deb935..0afec039c 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -1014,8 +1014,8 @@ void PathRelativeToApp( // void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bExpandEnv) { - WCHAR wchPath[MAX_PATH]; - WCHAR wchResult[MAX_PATH]; + WCHAR wchPath[MAX_PATH] = { L'\0'}; + WCHAR wchResult[MAX_PATH] = { L'\0'}; if (lpszSrc == NULL) { ZeroMemory(lpszDest, (cchDest == 0) ? MAX_PATH : cchDest); @@ -1026,8 +1026,11 @@ void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bExpand SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,wchPath); PathAppend(wchPath,lpszSrc+CSTRLEN("%CSIDL:MYDOCUMENTS%")); } - else + else { + if (lpszSrc) { lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath)); + } + } if (bExpandEnv) ExpandEnvironmentStringsEx(wchPath,COUNTOF(wchPath)); diff --git a/src/Helpers.h b/src/Helpers.h index d09b22a25..eaa959b02 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -19,7 +19,8 @@ extern HINSTANCE g_hInstance; extern UINT16 g_uWinVer; -#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0])) +#define UNUSED(expr) (void)(expr) +#define COUNTOF(ar) ARRAYSIZE(ar) //#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0])) #define CSTRLEN(s) (COUNTOF(s)-1) diff --git a/src/Notepad3.c b/src/Notepad3.c index 88b08f603..bca0a16f3 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -738,9 +738,6 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int n OleUninitialize(); return(int)(msg.wParam); - - hPrevInst; - } @@ -2921,10 +2918,9 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) case IDM_EDIT_SWAP: if (SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0) == 0) { - int iNewPos = -1; int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); SendMessage(hwndEdit,SCI_PASTE,0,0); - iNewPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); + int iNewPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); SendMessage(hwndEdit,SCI_SETSEL,iPos,iNewPos); SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CLEARCLIPBOARD,1),0); } diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 815017b32..70972f5c3 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -289,7 +289,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Zoom &In\tCtrl++", IDM_VIEW_ZOOMIN MENUITEM "Zoom &Out\tCtrl+-", IDM_VIEW_ZOOMOUT - MENUITEM "Reset &Zoom\tCtrl+/", IDM_VIEW_RESETZOOM + MENUITEM "Reset &Zoom\tCtrl+0", IDM_VIEW_RESETZOOM END POPUP "&Settings" BEGIN @@ -305,7 +305,7 @@ BEGIN MENUITEM "Sticky Window &Position", IDM_VIEW_STICKYWINPOS MENUITEM "&Always On Top\tAlt+T", IDM_VIEW_ALWAYSONTOP MENUITEM "Minimi&ze To Tray", IDM_VIEW_MINTOTRAY - MENUITEM "Transparent &Mode\tCtrl+0", IDM_VIEW_TRANSPARENT + MENUITEM "Transparent &Mode\tCtrl+Numpad_*", IDM_VIEW_TRANSPARENT MENUITEM SEPARATOR MENUITEM "Single &File Instance", IDM_VIEW_SINGLEFILEINSTANCE MENUITEM "File &Change Notification...\tAlt+F5", IDM_VIEW_CHANGENOTIFY @@ -375,7 +375,7 @@ END IDR_MAINWND ACCELERATORS BEGIN - "0", IDM_VIEW_TRANSPARENT, VIRTKEY, CONTROL, NOINVERT + "0", IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT "0", IDM_FILE_NEWWINDOW2, VIRTKEY, ALT, NOINVERT "0", IDM_VIEW_WORDWRAPSYMBOLS, VIRTKEY, SHIFT, CONTROL, NOINVERT "1", CMD_STRINGIFY, VIRTKEY, CONTROL, NOINVERT @@ -468,7 +468,6 @@ BEGIN VK_DELETE, CMD_CTRLDEL, VIRTKEY, CONTROL, NOINVERT VK_DELETE, IDM_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT VK_DELETE, IDM_EDIT_DELETELINERIGHT, VIRTKEY, SHIFT, CONTROL, NOINVERT - VK_DIVIDE, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT VK_DOWN, IDM_EDIT_MOVELINEDOWN, VIRTKEY, SHIFT, CONTROL, NOINVERT VK_ESCAPE, CMD_ESCAPE, VIRTKEY, NOINVERT VK_ESCAPE, CMD_SHIFTESC, VIRTKEY, SHIFT, NOINVERT @@ -513,7 +512,12 @@ BEGIN VK_F9, IDM_FILE_MANAGEFAV, VIRTKEY, ALT, NOINVERT VK_F9, CMD_COPYPATHNAME, VIRTKEY, SHIFT, NOINVERT VK_F9, IDM_EDIT_INSERT_PATHNAME, VIRTKEY, SHIFT, CONTROL, NOINVERT - VK_OEM_2, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT + VK_OEM_2, IDM_EDIT_LINECOMMENT, VIRTKEY, CONTROL, NOINVERT + VK_OEM_2, IDM_EDIT_STREAMCOMMENT, VIRTKEY, SHIFT, CONTROL, NOINVERT + VK_DIVIDE, IDM_EDIT_LINECOMMENT, VIRTKEY, CONTROL, NOINVERT + VK_DIVIDE, IDM_EDIT_STREAMCOMMENT, VIRTKEY, SHIFT, CONTROL, NOINVERT + VK_NUMPAD0, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT + VK_MULTIPLY, IDM_VIEW_TRANSPARENT, VIRTKEY, CONTROL, NOINVERT VK_OEM_COMMA, CMD_JUMP2SELSTART, VIRTKEY, CONTROL, NOINVERT VK_OEM_MINUS, IDM_VIEW_ZOOMOUT, VIRTKEY, CONTROL, NOINVERT VK_OEM_MINUS, CMD_DECREASENUM, VIRTKEY, CONTROL, ALT, NOINVERT diff --git a/src/Styles.c b/src/Styles.c index 0c60d1b15..b63671fdb 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -2709,7 +2709,7 @@ void Style_Load() // default scheme iDefaultLexer = IniSectionGetInt(pIniSection,L"DefaultScheme",0); - iDefaultLexer = min(max(iDefaultLexer,0),NUMLEXERS-1); + iDefaultLexer = min(max(iDefaultLexer,0),COUNTOF(pLexArray)-1); // auto select bAutoSelect = (IniSectionGetInt(pIniSection,L"AutoSelect",1)) ? 1 : 0; @@ -2721,7 +2721,7 @@ void Style_Load() cyStyleSelectDlg = IniSectionGetInt(pIniSection,L"SelectDlgSizeY",0); cyStyleSelectDlg = max(cyStyleSelectDlg,324); - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { LoadIniSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection); if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt, pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions))) @@ -2783,7 +2783,7 @@ void Style_Save() } ZeroMemory(pIniSection,cchIniSection); - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions); i = 0; while (pLexArray[iLexer]->Styles[i].iStyle != -1) { @@ -2826,7 +2826,7 @@ BOOL Style_Import(HWND hwnd) WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { if (GetPrivateProfileSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection,szFile)) { if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt, pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions))) @@ -2878,7 +2878,7 @@ BOOL Style_Export(HWND hwnd) WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024); int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions); i = 0; while (pLexArray[iLexer]->Styles[i].iStyle != -1) { @@ -3418,7 +3418,7 @@ PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch,BOOL bCheckNames) if (!bCheckNames) { - for (i = 0; i < NUMLEXERS; i++) { + for (i = 0; i < COUNTOF(pLexArray); i++) { ZeroMemory(tch,sizeof(WCHAR)*COUNTOF(tch)); lstrcpy(tch,pLexArray[i]->szExtensions); @@ -3441,7 +3441,7 @@ PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch,BOOL bCheckNames) int cch = lstrlen(lpszMatch); if (cch >= 3) { - for (i = 0; i < NUMLEXERS; i++) { + for (i = 0; i < COUNTOF(pLexArray); i++) { if (StrCmpNI(pLexArray[i]->pszName,lpszMatch,cch) == 0) return(pLexArray[i]); } @@ -3625,7 +3625,7 @@ void Style_SetXMLLexer(HWND hwnd) // void Style_SetLexerFromID(HWND hwnd,int id) { - if (id >= 0 && id < NUMLEXERS) { + if (id >= 0 && id < COUNTOF(pLexArray)) { Style_SetLexer(hwnd,pLexArray[id]); } } @@ -4448,7 +4448,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP SHGFI_SMALLICON | SHGFI_SYSICONINDEX),TVSIL_NORMAL); // Add lexers - for (i = 0; i < NUMLEXERS; i++) + for (i = 0; i < COUNTOF(pLexArray); i++) { if (!found && lstrcmp(pLexArray[i]->pszName,pLexCurrent->pszName) == 0) { @@ -4959,7 +4959,7 @@ void Style_ConfigDlg(HWND hwnd) // Backup Styles c = 0; - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { StyleBackup[c++] = StrDup(pLexArray[iLexer]->szExtensions); i = 0; while (pLexArray[iLexer]->Styles[i].iStyle != -1) { @@ -4976,7 +4976,7 @@ void Style_ConfigDlg(HWND hwnd) { // Restore Styles c = 0; - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) { + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { lstrcpy(pLexArray[iLexer]->szExtensions,StyleBackup[c++]); i = 0; while (pLexArray[iLexer]->Styles[i].iStyle != -1) { @@ -5075,7 +5075,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR ListView_InsertColumn(hwndLV,0,&lvc); // Add lexers - for (i = 0; i < NUMLEXERS; i++) + for (i = 0; i < COUNTOF(pLexArray); i++) Style_AddLexerToListView(hwndLV,pLexArray[i]); ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER); diff --git a/src/Styles.h b/src/Styles.h index 36297e038..877e5f3f8 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -31,7 +31,7 @@ typedef struct _editstyle typedef struct _keywordlist { - char *pszKeyWords[9]; + char *pszKeyWords[KEYWORDSET_MAX + 1]; } KEYWORDLIST, *PKEYWORDLIST;