Commit 62a4072c authored by Dick Hollenbeck's avatar Dick Hollenbeck

minor bugs

parent 938cb884
......@@ -346,6 +346,8 @@ int DSNLEXER::NextTok() throw( IO_ERROR )
if( cur >= limit )
{
L_read:
cur = start;
// blank lines are returned as "\n" and will have a len of 1.
// EOF will have a len of 0 and so is detectable.
int len = readLine();
......@@ -355,8 +357,6 @@ L_read:
goto exit;
}
cur = start;
// skip leading whitespace
while( cur<limit && isSpace(*cur) )
++cur;
......
......@@ -122,7 +122,10 @@ unsigned FILE_LINE_READER::ReadLine() throw( IO_ERROR )
expandCapacity( capacity * 2 );
}
if( length )
/* if( length ) RHH: this may now refer to a non-existent line but
* that leads to better error reporting on unexpected end of file.
*/
++lineNum;
return length;
......@@ -173,10 +176,11 @@ unsigned STRING_LINE_READER::ReadLine() throw( IO_ERROR )
memcpy( line, &lines[ndx], length );
++lineNum;
ndx += length;
}
++lineNum; // this gets incremented even if no bytes were read
line[length] = 0;
return length;
......
......@@ -634,14 +634,13 @@ void SCH_EDIT_FRAME::LoadSettings()
{
m_TemplateFieldNames.Parse( &lexer );
}
catch( IO_ERROR e )
catch( IO_ERROR& e )
{
// @todo show error msg
D( printf( "templatefieldnames parsing error: '%s'\n",
CONV_TO_UTF8( e.errorText ) ); )
}
}
}
......
......@@ -57,10 +57,13 @@ void LIB_TABLE::Parse( SCH_LIB_TABLE_LEXER* in ) throw( IO_ERROR )
ELT_T tok;
while( ( tok = in->NextTok() ) != T_RIGHT && tok != T_EOF )
while( ( tok = in->NextTok() ) != T_RIGHT )
{
// (lib (logical "LOGICAL")(type "TYPE")(full_uri "FULL_URI")(options "OPTIONS"))
if( tok == T_EOF )
in->Expecting( T_RIGHT );
if( tok != T_LEFT )
in->Expecting( T_LEFT );
......@@ -353,6 +356,7 @@ void LIB_TABLE::Test()
" (lib (logical www) (type http) (full_uri http://kicad.org/libs) (options \" \"))\n"
" (lib (logical meparts) (type dir) (full_uri /tmp/eeschema-lib) (options useVersioning))\n"
" (lib (logical old-project) (type schematic)(full_uri /tmp/old-schematic.sch) (options \" \"))\n"
")\n"
,
wxT( "inline text" ) // source
......@@ -416,8 +420,13 @@ int main( int argc, char** argv )
catch( PARSE_ERROR& ioe ) // most derived class first
{
printf( "%s\n", (const char*) ioe.errorText.ToUTF8() );
printf( "%s", ioe.inputLine.c_str() ); // rare not to have \n at end
printf( "%*s^\n", ioe.byteIndex-1, " " );
printf( "%s%s",
ioe.inputLine.c_str(),
ioe.inputLine.empty() || *ioe.inputLine.rbegin() != '\n' ?
"\n" : "" ); // rare not to have \n at end
printf( "%*s^\n", ioe.byteIndex>=1 ? ioe.byteIndex-1 : 0, "" );
}
catch( IO_ERROR& ioe )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment