@@ -113,7 +113,13 @@ BOOL CALLBACK ConsoleDialog::run_dlgProc(HWND hWnd, UINT message, WPARAM wParam,
113113
114114 SetMenuItemInfo (m_hContext, 2 , FALSE , &mi);
115115
116- UINT cmdID = TrackPopupMenu (m_hContext, TPM_RETURNCMD , GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam), 0 , _hSelf, NULL );
116+ // Thanks MS for corrupting the value of BOOL. :-/
117+ // From the documentation (http://msdn.microsoft.com/en-us/library/ms648002.aspx):
118+ //
119+ // If you specify TPM_RETURNCMD in the uFlags parameter, the return value is the menu-item
120+ // identifier of the item that the user selected. If the user cancels the menu without making
121+ // a selection, or if an error occurs, then the return value is zero.
122+ INT cmdID = (INT )TrackPopupMenu (m_hContext, TPM_RETURNCMD , GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam), 0 , _hSelf, NULL );
117123
118124 switch (cmdID)
119125 {
@@ -220,7 +226,6 @@ void ConsoleDialog::historyPrevious()
220226 ::SetWindowTextA (m_hInput, m_changes[m_currentHistory].c_str());
221227 ::SendMessage (m_hInput, EM_SETSEL , m_changes[m_currentHistory].size(), m_changes[m_currentHistory].size());
222228 }
223-
224229 }
225230}
226231
@@ -266,9 +271,7 @@ void ConsoleDialog::historyNext()
266271 // Set it as the changed string
267272 ::SetWindowTextA (m_hInput, m_changes[m_currentHistory].c_str());
268273 ::SendMessage (m_hInput, EM_SETSEL , m_changes[m_currentHistory].size(), m_changes[m_currentHistory].size());
269-
270274 }
271-
272275 }
273276}
274277
@@ -430,10 +433,10 @@ void ConsoleDialog::createOutputWindow(HWND hParentWindow)
430433 callScintilla (SCI_SETLEXER , SCLEX_CONTAINER );
431434}
432435
433- void ConsoleDialog::writeText (int length, const char *text)
436+ void ConsoleDialog::writeText (size_t length, const char *text)
434437{
435438 ::SendMessage (m_scintilla, SCI_SETREADONLY , 0 , 0 );
436- for (int i = 0 ; i < length; ++i)
439+ for (idx_t i = 0 ; i < length; ++i)
437440 {
438441 if (text[i] == ' \r ' )
439442 {
@@ -456,12 +459,12 @@ void ConsoleDialog::writeText(int length, const char *text)
456459}
457460
458461
459- void ConsoleDialog::writeError (int length, const char *text)
462+ void ConsoleDialog::writeError (size_t length, const char *text)
460463{
461464 int docLength = callScintilla (SCI_GETLENGTH );
462465 int realLength = length;
463466 callScintilla (SCI_SETREADONLY , 0 );
464- for (int i = 0 ; i < length; ++i)
467+ for (idx_t i = 0 ; i < length; ++i)
465468 {
466469 if (text[i] == ' \r ' )
467470 {
@@ -564,9 +567,9 @@ void ConsoleDialog::onStyleNeeded(SCNotification* notification)
564567 LineDetails lineDetails;
565568 for (int lineNumber = startLine; lineNumber <= endLine; ++lineNumber)
566569 {
567- lineDetails.lineLength = callScintilla (SCI_GETLINE , lineNumber);
570+ lineDetails.lineLength = ( size_t ) callScintilla (SCI_GETLINE , lineNumber);
568571
569- if (lineDetails.lineLength > 0 )
572+ if (lineDetails.lineLength != SIZE_MAX )
570573 {
571574 lineDetails.line = new char [lineDetails.lineLength + 1 ];
572575 callScintilla (SCI_GETLINE , lineNumber, reinterpret_cast <LPARAM >(lineDetails.line ));
@@ -675,8 +678,8 @@ bool ConsoleDialog::parseVSErrorLine(LineDetails *lineDetails)
675678 bool retVal = false ;
676679 styleState = SS_BEGIN ;
677680
678- int pos = 0 ;
679- lineDetails->errorLineNo = - 1 ;
681+ idx_t pos = 0 ;
682+ lineDetails->errorLineNo = IDX_MAX ;
680683
681684 while (styleState != SS_EXIT )
682685 {
@@ -725,8 +728,8 @@ bool ConsoleDialog::parseVSErrorLine(LineDetails *lineDetails)
725728
726729 case SS_LINENUMBER :
727730 {
728- int startLineNoPos = pos;
729- int endLineNoPos;
731+ idx_t startLineNoPos = pos;
732+ idx_t endLineNoPos;
730733 while (lineDetails->line [pos] >= ' 0' && lineDetails->line [pos] <= ' 9' && pos < lineDetails->lineLength )
731734 {
732735 ++pos;
@@ -757,7 +760,7 @@ bool ConsoleDialog::parseVSErrorLine(LineDetails *lineDetails)
757760
758761 char *lineNumber = new char [endLineNoPos - startLineNoPos + 2 ];
759762 strncpy_s (lineNumber, endLineNoPos - startLineNoPos + 2 , lineDetails->line + startLineNoPos, endLineNoPos - startLineNoPos);
760- lineDetails->errorLineNo = atoi (lineNumber) - 1 ;
763+ lineDetails->errorLineNo = strtoul (lineNumber, NULL , 0 ) - 1 ;
761764 delete[] lineNumber;
762765 lineDetails->filenameEnd = startLineNoPos - 1 ;
763766 retVal = true ;
@@ -809,9 +812,9 @@ bool ConsoleDialog::parseGCCErrorLine(LineDetails *lineDetails)
809812 bool retVal = false ;
810813 styleState = SS_FILENAME ;
811814
812- int pos = 0 ;
815+ idx_t pos = 0 ;
813816 lineDetails->filenameStart = 0 ;
814- lineDetails->errorLineNo = - 1 ;
817+ lineDetails->errorLineNo = IDX_MAX ;
815818
816819 while (styleState != SS_EXIT )
817820 {
@@ -861,15 +864,15 @@ bool ConsoleDialog::parseGCCErrorLine(LineDetails *lineDetails)
861864
862865 case SS_LINENUMBER :
863866 {
864- int startLineNoPos = pos;
867+ idx_t startLineNoPos = pos;
865868 while (lineDetails->line [pos] >= ' 0' && lineDetails->line [pos] <= ' 9' && pos < lineDetails->lineLength )
866869 {
867870 ++pos;
868871 }
869872 if (pos < (lineDetails->lineLength + 1 )
870873 && lineDetails->line [pos] == ' :' )
871874 {
872- lineDetails->errorLineNo = atoi (lineDetails->line + startLineNoPos) - 1 ;
875+ lineDetails->errorLineNo = strtoul (lineDetails->line + startLineNoPos, NULL , 0 ) - 1 ;
873876
874877 // If the line number came out as 0, ie. there wasn't any,
875878 // then the line is not a gcc error
@@ -929,8 +932,8 @@ bool ConsoleDialog::parsePythonErrorLine(LineDetails *lineDetails)
929932
930933 bool retVal = false ;
931934 styleState = SS_BEGIN ;
932- lineDetails->errorLineNo = - 1 ;
933- int pos = 0 ;
935+ lineDetails->errorLineNo = IDX_MAX ;
936+ idx_t pos = 0 ;
934937 while (styleState != SS_EXIT )
935938 {
936939 switch (styleState)
@@ -979,7 +982,7 @@ bool ConsoleDialog::parsePythonErrorLine(LineDetails *lineDetails)
979982 break ;
980983
981984 case SS_LINENUMBER :
982- lineDetails->errorLineNo = atoi (lineDetails->line + pos) - 1 ;
985+ lineDetails->errorLineNo = strtoul (lineDetails->line + pos, NULL , 0 ) - 1 ;
983986 styleState = SS_EXIT ;
984987 break ;
985988
@@ -992,29 +995,21 @@ bool ConsoleDialog::parsePythonErrorLine(LineDetails *lineDetails)
992995 return retVal;
993996}
994997
995-
996-
997-
998-
999-
1000-
1001998void ConsoleDialog::onHotspotClick (SCNotification* notification)
1002999{
1003-
10041000 int lineNumber = callScintilla (SCI_LINEFROMPOSITION , notification->position );
10051001 LineDetails lineDetails;
1006- lineDetails.lineLength = callScintilla (SCI_GETLINE , lineNumber);
1002+ lineDetails.lineLength = ( size_t ) callScintilla (SCI_GETLINE , lineNumber);
10071003
1008- if (lineDetails.lineLength > 0 )
1004+ if (lineDetails.lineLength != SIZE_MAX )
1005+ {
1006+ lineDetails.line = new char [lineDetails.lineLength + 1 ];
1007+ callScintilla (SCI_GETLINE , lineNumber, reinterpret_cast <LPARAM >(lineDetails.line ));
1008+ lineDetails.line [lineDetails.lineLength ] = ' \0 ' ;
1009+ if (parseLine (&lineDetails))
10091010 {
1010- lineDetails.line = new char [lineDetails.lineLength + 1 ];
1011- callScintilla (SCI_GETLINE , lineNumber, reinterpret_cast <LPARAM >(lineDetails.line ));
1012- lineDetails.line [lineDetails.lineLength ] = ' \0 ' ;
1013- if (parseLine (&lineDetails))
1014- {
1015- lineDetails.line [lineDetails.filenameEnd ] = ' \0 ' ;
1016- m_console->openFile (lineDetails.line + lineDetails.filenameStart , lineDetails.errorLineNo );
1017- }
1011+ lineDetails.line [lineDetails.filenameEnd ] = ' \0 ' ;
1012+ m_console->openFile (lineDetails.line + lineDetails.filenameStart , lineDetails.errorLineNo );
10181013 }
1019-
1014+ }
10201015}
0 commit comments