Commit bc16d9d7 authored by Dick Hollenbeck's avatar Dick Hollenbeck

simplifications, typo

parent 558af6d7
......@@ -39,8 +39,7 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFile
SCH_ITEM* Pnext;
SCH_ITEM* item;
wxString MsgDiag; // Error and log messages
#define line ((char*)reader)
char* line;
if( screen == NULL )
return FALSE;
......@@ -68,18 +67,22 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFile
PrintMsg( MsgDiag );
if( !reader.ReadLine()
|| strncmp( line + 9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1 ) != 0 )
|| strncmp( (char*)reader + 9, SCHEMATIC_HEAD_STRING, sizeof(SCHEMATIC_HEAD_STRING) - 1 ) != 0 )
{
MsgDiag = FullFileName + _( " is NOT an EESchema file!" );
DisplayError( this, MsgDiag );
return FALSE;
}
line = reader.Line();
// get the file version here.
char *strversion = line + 9 + sizeof(SCHEMATIC_HEAD_STRING);
// Skip blanks
while( *strversion && *strversion < '0' )
strversion++;
int version = atoi(strversion);
if( version > EESCHEMA_VERSION )
......@@ -101,7 +104,7 @@ again." );
}
#endif
if( !reader.ReadLine() || strncmp( line, "LIBS:", 5 ) != 0 )
if( !reader.ReadLine() || strncmp( reader, "LIBS:", 5 ) != 0 )
{
MsgDiag = FullFileName + _( " is NOT an EESchema file!" );
DisplayError( this, MsgDiag );
......@@ -112,6 +115,8 @@ again." );
while( reader.ReadLine() )
{
line = reader.Line();
item = NULL;
char* sline = line;
......@@ -264,18 +269,23 @@ static void LoadLayers( LINE_READER* aLine )
/* Read the schematic header. */
bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* aScreen )
{
char Text[256], buf[1024];
int ii;
Ki_PageDescr* wsheet = &g_Sheet_A4;
char Text[256];
char buf[1024];
int ii;
Ki_PageDescr* wsheet = &g_Sheet_A4;
wxSize PageSize;
char* line;
static Ki_PageDescr* SheetFormatList[] =
{
&g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0,
&g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E,
&g_Sheet_user, NULL
};
wxSize PageSize;
sscanf( ((char*)(*aLine)), "%s %s %d %d", Text, Text, &PageSize.x, &PageSize.y );
line = aLine->Line();
sscanf( line, "%s %s %d %d", Text, Text, &PageSize.x, &PageSize.y );
wxString pagename = CONV_FROM_UTF8( Text );
......@@ -300,7 +310,7 @@ bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* aScre
aMsgDiag.Printf( wxT( "EESchema file dimension definition error \
line %d, \aAbort reading file.\n" ),
aLine->LineNumber() );
aMsgDiag << CONV_FROM_UTF8( ((char*)(*aLine)) );
aMsgDiag << CONV_FROM_UTF8( line );
}
aScreen->m_CurrentSheetDesc = wsheet;
......@@ -310,65 +320,67 @@ line %d, \aAbort reading file.\n" ),
if( !aLine->ReadLine() )
return TRUE;
if( strnicmp( ((char*)(*aLine)), "$End", 4 ) == 0 )
line = aLine->Line();
if( strnicmp( line, "$End", 4 ) == 0 )
break;
if( strnicmp( ((char*)(*aLine)), "Sheet", 2 ) == 0 )
sscanf( ((char*)(*aLine)) + 5, " %d %d",
if( strnicmp( line, "Sheet", 2 ) == 0 )
sscanf( line + 5, " %d %d",
&aScreen->m_ScreenNumber, &aScreen->m_NumberOfScreen );
if( strnicmp( ((char*)(*aLine)), "Title", 2 ) == 0 )
if( strnicmp( line, "Title", 2 ) == 0 )
{
ReadDelimitedText( buf, ((char*)(*aLine)), 256 );
ReadDelimitedText( buf, line, 256 );
aScreen->m_Title = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( ((char*)(*aLine)), "Date", 2 ) == 0 )
if( strnicmp( line, "Date", 2 ) == 0 )
{
ReadDelimitedText( buf, ((char*)(*aLine)), 256 );
ReadDelimitedText( buf, line, 256 );
aScreen->m_Date = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( ((char*)(*aLine)), "Rev", 2 ) == 0 )
if( strnicmp( line, "Rev", 2 ) == 0 )
{
ReadDelimitedText( buf, ((char*)(*aLine)), 256 );
ReadDelimitedText( buf, line, 256 );
aScreen->m_Revision = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( ((char*)(*aLine)), "Comp", 4 ) == 0 )
if( strnicmp( line, "Comp", 4 ) == 0 )
{
ReadDelimitedText( buf, ((char*)(*aLine)), 256 );
ReadDelimitedText( buf, line, 256 );
aScreen->m_Company = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( ((char*)(*aLine)), "Comment1", 8 ) == 0 )
if( strnicmp( line, "Comment1", 8 ) == 0 )
{
ReadDelimitedText( buf, ((char*)(*aLine)), 256 );
ReadDelimitedText( buf, line, 256 );
aScreen->m_Commentaire1 = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( ((char*)(*aLine)), "Comment2", 8 ) == 0 )
if( strnicmp( line, "Comment2", 8 ) == 0 )
{
ReadDelimitedText( buf, ((char*)(*aLine)), 256 );
ReadDelimitedText( buf, line, 256 );
aScreen->m_Commentaire2 = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( ((char*)(*aLine)), "Comment3", 8 ) == 0 )
if( strnicmp( line, "Comment3", 8 ) == 0 )
{
ReadDelimitedText( buf, ((char*)(*aLine)), 256 );
ReadDelimitedText( buf, line, 256 );
aScreen->m_Commentaire3 = CONV_FROM_UTF8( buf );
continue;
}
if( strnicmp( ((char*)(*aLine)), "Comment4", 8 ) == 0 )
if( strnicmp( line, "Comment4", 8 ) == 0 )
{
ReadDelimitedText( buf, ((char*)(*aLine)), 256 );
ReadDelimitedText( buf, line, 256 );
aScreen->m_Commentaire4 = CONV_FROM_UTF8( buf );
continue;
}
......
......@@ -1031,28 +1031,31 @@ bool SCH_COMPONENT::Save( FILE* f ) const
bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
{
int ii;
char Name1[256], Name2[256],
Char1[256], Char2[256], Char3[256];
int newfmt = 0;
char* ptcar;
wxString fieldName;
int ii;
char Name1[256], Name2[256],
Char1[256], Char2[256], Char3[256];
int newfmt = 0;
char* ptcar;
wxString fieldName;
char* line = aLine.Line();
m_convert = 1;
if( ((char*)aLine)[0] == '$' )
if( line[0] == '$' )
{
newfmt = 1;
if( !aLine.ReadLine() )
return TRUE;
line = aLine.Line();
}
if( sscanf( &((char*)aLine)[1], "%s %s", Name1, Name2 ) != 2 )
if( sscanf( &line[1], "%s %s", Name1, Name2 ) != 2 )
{
aErrorMsg.Printf( wxT( "EESchema Component descr error at line %d, aborted" ),
aLine.LineNumber() );
aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( ((char*)aLine) );
aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( line );
return false;
}
......@@ -1135,13 +1138,15 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( !aLine.ReadLine() )
return false;
if( ((char*)aLine)[0] == 'U' )
line = aLine.Line();
if( line[0] == 'U' )
{
sscanf( ((char*)aLine) + 1, "%d %d %lX", &m_unit, &m_convert, &m_TimeStamp );
sscanf( line + 1, "%d %d %lX", &m_unit, &m_convert, &m_TimeStamp );
}
else if( ((char*)aLine)[0] == 'P' )
else if( line[0] == 'P' )
{
sscanf( ((char*)aLine) + 1, "%d %d", &m_Pos.x, &m_Pos.y );
sscanf( line + 1, "%d %d", &m_Pos.x, &m_Pos.y );
// Set fields position to a default position (that is the
// component position. For existing fields, the real position
......@@ -1152,7 +1157,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
GetField( i )->m_Pos = m_Pos;
}
}
else if( ((char*)aLine)[0] == 'A' && ((char*)aLine)[1] == 'R' )
else if( line[0] == 'A' && line[1] == 'R' )
{
/* format:
* AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1"
......@@ -1161,7 +1166,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
* C99 is the reference given this path.
*/
int ii;
ptcar = ((char*)aLine) + 2;
ptcar = line + 2;
//copy the path.
ii = ReadDelimitedText( Name1, ptcar, 255 );
......@@ -1183,7 +1188,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
AddHierarchicalReference( path, ref, multi );
GetField( REFERENCE )->m_Text = ref;
}
else if( ((char*)aLine)[0] == 'F' )
else if( line[0] == 'F' )
{
int fieldNdx;
......@@ -1223,7 +1228,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
}
fieldNdx = atoi( ((char*)aLine) + 2 );
fieldNdx = atoi( line + 2 );
ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) );
......@@ -1310,7 +1315,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
break;
}
if( sscanf( ((char*)aLine), "%d %d %d", &m_unit, &m_Pos.x, &m_Pos.y ) != 3 )
if( sscanf( line, "%d %d %d", &m_unit, &m_Pos.x, &m_Pos.y ) != 3 )
{
aErrorMsg.Printf( wxT( "Component unit & pos error at line %d, aborted" ),
aLine.LineNumber() );
......@@ -1334,7 +1339,9 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( !aLine.ReadLine() )
return false;
if( strnicmp( "$End", ((char*)aLine), 4 ) != 0 )
line = aLine.Line();
if( strnicmp( "$End", line, 4 ) != 0 )
{
aErrorMsg.Printf( wxT( "Component End expected at line %d, aborted" ),
aLine.LineNumber() );
......
......@@ -17,7 +17,7 @@ char* strlower( char* Text );
/**
* Function ReadDelimitedText
* extracts bytes from @a aSource delimited string segment to @a aDest buffer.
* copies bytes from @a aSource delimited string segment to @a aDest buffer.
* The extracted string will be null terminated even if truncation is necessary
* because aDestSize was not large enough.
*
......
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