SF.net SVN: mahogany:[7581] trunk/M
[email protected] Sat, 05 Dec 2009 00:18:49 +0000
| Newsgroups | gmane.mail.mahogany.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 7581
http://mahogany.svn.sourceforge.net/mahogany/?rev=7581&view=rev
Author: vadz
Date: 2009-12-05 00:18:49 +0000 (Sat, 05 Dec 2009)
Log Message:
-----------
more fixes for [not] accessing the the last string character by index to avoid VC9 CRT asserts
Modified Paths:
--------------
trunk/M/include/Sequence.h
trunk/M/src/classes/Sequence.cpp
Modified: trunk/M/include/Sequence.h
===================================================================
--- trunk/M/include/Sequence.h 2009-12-04 23:29:27 UTC (rev 7580)
+++ trunk/M/include/Sequence.h 2009-12-05 00:18:49 UTC (rev 7581)
@@ -69,6 +69,13 @@
/// finish the current range, return true if we had any
bool DoFlush();
+ /// get char at the given position in m_seq returning '\0' for out of range
+ /// indices
+ char GetCharAt(size_t pos) const
+ {
+ return pos == m_seq.length() ? '\0' : m_seq[pos];
+ }
+
/// get the number at given position and increment it to the pos after it
UIdType GetNumberAt(size_t& pos) const;
Modified: trunk/M/src/classes/Sequence.cpp
===================================================================
--- trunk/M/src/classes/Sequence.cpp 2009-12-04 23:29:27 UTC (rev 7580)
+++ trunk/M/src/classes/Sequence.cpp 2009-12-05 00:18:49 UTC (rev 7581)
@@ -207,7 +207,7 @@
UIdType Sequence::GetNumberAt(size_t& pos) const
{
UIdType n = 0;
- while ( pos < m_seq.length() && isdigit(m_seq[pos]) )
+ while ( isdigit(GetCharAt(pos)) )
{
n *= 10;
n += m_seq[pos++] - '0';
@@ -227,7 +227,7 @@
UIdType Sequence::GetNext(UIdType n, size_t& cookie) const
{
- switch ( (wxChar)m_seq[cookie] )
+ switch ( GetCharAt(cookie) )
{
case ':':
// we're inside a range, check if we didn't exhaust it
@@ -241,10 +241,10 @@
cookie = pos;
}
- if ( m_seq[cookie] != '\0' )
+ if ( GetCharAt(cookie) != '\0' )
{
// nothing else can follow the end of the range
- ASSERT_MSG( m_seq[cookie] == ',', _T("bad sequence string format") );
+ ASSERT_MSG( GetCharAt(cookie) == ',', "bad sequence string format" );
cookie++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev