From 8aab369f4ea7b9c7acb0bdc7a3810edfeaefef36 Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Tue, 18 Nov 2008 20:32:53 +0000 Subject: [PATCH] isspace() handles characters in range 0-255 only --- pcbnew/dsn.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pcbnew/dsn.cpp b/pcbnew/dsn.cpp index 918a114b4a..13feb3db5b 100644 --- a/pcbnew/dsn.cpp +++ b/pcbnew/dsn.cpp @@ -621,6 +621,18 @@ void LEXER::ThrowIOError( wxString aText, int charOffset ) throw (IOError) } +/** + * Function isspace + * strips the upper bits of the int to ensure the value passed to ::isspace() is + * in the range of 0-255 + */ +static inline bool isSpace( int cc ) +{ + // make sure int passed to ::isspace() is 0-255 + return ::isspace( cc & 0xff ); +} + + DSN_T LEXER::NextTok() throw (IOError) { char* cur = next; @@ -643,7 +655,7 @@ L_read: cur = start; // skip leading whitespace - while( curstart && !isspace( cur[-1] ) ) + if( *cur == '-' && cur>start && !isSpace( cur[-1] ) ) { head = cur+1; curText.clear(); @@ -730,7 +742,7 @@ L_read: while( head