From 1fac87f84723a3d6e7e13c091e39b09e0dea1aa5 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 9 Jul 2002 07:53:12 +0000 Subject: [PATCH] #99372# Fixed lcl_ParseText to return the line number instead of 0. --- basctl/source/basicide/brkdlg.cxx | 43 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/basctl/source/basicide/brkdlg.cxx b/basctl/source/basicide/brkdlg.cxx index 11af1fd12883..f41e12163b10 100644 --- a/basctl/source/basicide/brkdlg.cxx +++ b/basctl/source/basicide/brkdlg.cxx @@ -2,9 +2,9 @@ * * $RCSfile: brkdlg.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: tbe $ $Date: 2001-09-06 09:17:41 $ + * last change: $Author: sb $ $Date: 2002-07-09 08:53:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,6 +59,7 @@ * ************************************************************************/ +#include #pragma hdrstop #include @@ -76,30 +77,28 @@ #endif #include +// FIXME Why does BreakPointDialog allow only USHORT for break-point line +// numbers, whereas BreakPoint supports ULONG? -/************************** - Soll-Aufbau des Strings: - # -**************************/ - -BOOL lcl_ParseText( String aText, USHORT& rLineNr ) +bool lcl_ParseText( String aText, USHORT& rLineNr ) { - // Blanks ? - aText.EraseLeadingChars( ' ' ); - if ( !aText.Len() ) - return FALSE; - if ( aText.GetChar( 0 ) != '#' ) - return FALSE; - aText.EraseLeadingChars( ' ' ); - if ( !aText.Len() ) - return FALSE; - - rLineNr = (USHORT) aText.ToInt32(); - return TRUE; + // aText should look like "# n" where + // n > 0 && n < std::numeric_limits< USHORT >::max(). + // All spaces are ignored, so there can even be spaces within the + // number n. (Maybe it would be better to ignore all whitespace instead + // of just spaces.) + aText.EraseAllChars(' '); + if (aText.GetChar(0) != '#') + return false; + aText.Erase(0, 1); + // XXX Assumes that USHORT is contained within sal_Int32: + sal_Int32 n = aText.ToInt32(); + if (n <= 0 || n > std::numeric_limits< USHORT >::max()) + return false; + rLineNr = static_cast< USHORT >(n); + return true; } - - BreakPointDialog::BreakPointDialog( Window* pParent, BreakPointList& rBrkPntList ) : ModalDialog( pParent, IDEResId( RID_BASICIDE_BREAKPOINTDLG ) ), aComboBox( this, IDEResId( RID_CB_BRKPOINTS ) ),