Commit bc16d9d7 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

simplifications, typo

parent 558af6d7
Loading
Loading
Loading
Loading
+41 −29
Original line number Original line Diff line number Diff line
@@ -39,8 +39,7 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFile
    SCH_ITEM*       Pnext;
    SCH_ITEM*       Pnext;
    SCH_ITEM*       item;
    SCH_ITEM*       item;
    wxString        MsgDiag;            // Error and log messages
    wxString        MsgDiag;            // Error and log messages

    char*           line;
#define line        ((char*)reader)


    if( screen == NULL )
    if( screen == NULL )
        return FALSE;
        return FALSE;
@@ -68,18 +67,22 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFile
    PrintMsg( MsgDiag );
    PrintMsg( MsgDiag );


    if( !reader.ReadLine()
    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!" );
        MsgDiag = FullFileName + _( " is NOT an EESchema file!" );
        DisplayError( this, MsgDiag );
        DisplayError( this, MsgDiag );
        return FALSE;
        return FALSE;
    }
    }


    line = reader.Line();

    // get the file version here.
    // get the file version here.
    char *strversion = line + 9 + sizeof(SCHEMATIC_HEAD_STRING);
    char *strversion = line + 9 + sizeof(SCHEMATIC_HEAD_STRING);

    // Skip blanks
    // Skip blanks
    while( *strversion && *strversion < '0' )
    while( *strversion && *strversion < '0' )
        strversion++;
        strversion++;

    int  version = atoi(strversion);
    int  version = atoi(strversion);


    if( version > EESCHEMA_VERSION )
    if( version > EESCHEMA_VERSION )
@@ -101,7 +104,7 @@ again." );
    }
    }
#endif
#endif


    if( !reader.ReadLine() || strncmp( line, "LIBS:", 5 ) != 0 )
    if( !reader.ReadLine() || strncmp( reader, "LIBS:", 5 ) != 0 )
    {
    {
        MsgDiag = FullFileName + _( " is NOT an EESchema file!" );
        MsgDiag = FullFileName + _( " is NOT an EESchema file!" );
        DisplayError( this, MsgDiag );
        DisplayError( this, MsgDiag );
@@ -112,6 +115,8 @@ again." );


    while( reader.ReadLine() )
    while( reader.ReadLine() )
    {
    {
        line = reader.Line();

        item = NULL;
        item = NULL;


        char* sline = line;
        char* sline = line;
@@ -264,18 +269,23 @@ static void LoadLayers( LINE_READER* aLine )
/* Read the schematic header. */
/* Read the schematic header. */
bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* aScreen )
bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* aScreen )
{
{
    char Text[256], buf[1024];
    char            Text[256];
    char            buf[1024];
    int             ii;
    int             ii;
    Ki_PageDescr*   wsheet = &g_Sheet_A4;
    Ki_PageDescr*   wsheet = &g_Sheet_A4;
    wxSize          PageSize;
    char*           line;

    static Ki_PageDescr* SheetFormatList[] =
    static Ki_PageDescr* SheetFormatList[] =
    {
    {
        &g_Sheet_A4,   &g_Sheet_A3,   &g_Sheet_A2,   &g_Sheet_A1, &g_Sheet_A0,
        &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_A,    &g_Sheet_B,    &g_Sheet_C,    &g_Sheet_D,  &g_Sheet_E,
        &g_Sheet_user, NULL
        &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 );
    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 \
        aMsgDiag.Printf( wxT( "EESchema file dimension definition error \
line %d, \aAbort reading file.\n" ),
line %d, \aAbort reading file.\n" ),
                         aLine->LineNumber() );
                         aLine->LineNumber() );
        aMsgDiag << CONV_FROM_UTF8( ((char*)(*aLine)) );
        aMsgDiag << CONV_FROM_UTF8( line );
    }
    }


    aScreen->m_CurrentSheetDesc = wsheet;
    aScreen->m_CurrentSheetDesc = wsheet;
@@ -310,65 +320,67 @@ line %d, \aAbort reading file.\n" ),
        if( !aLine->ReadLine() )
        if( !aLine->ReadLine() )
            return TRUE;
            return TRUE;


        if( strnicmp( ((char*)(*aLine)), "$End", 4 ) == 0 )
        line = aLine->Line();

        if( strnicmp( line, "$End", 4 ) == 0 )
            break;
            break;


        if( strnicmp( ((char*)(*aLine)), "Sheet", 2 ) == 0 )
        if( strnicmp( line, "Sheet", 2 ) == 0 )
            sscanf( ((char*)(*aLine)) + 5, " %d %d",
            sscanf( line + 5, " %d %d",
                    &aScreen->m_ScreenNumber, &aScreen->m_NumberOfScreen );
                    &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 );
            aScreen->m_Title = CONV_FROM_UTF8( buf );
            continue;
            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 );
            aScreen->m_Date = CONV_FROM_UTF8( buf );
            continue;
            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 );
            aScreen->m_Revision = CONV_FROM_UTF8( buf );
            continue;
            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 );
            aScreen->m_Company = CONV_FROM_UTF8( buf );
            continue;
            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 );
            aScreen->m_Commentaire1 = CONV_FROM_UTF8( buf );
            continue;
            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 );
            aScreen->m_Commentaire2 = CONV_FROM_UTF8( buf );
            continue;
            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 );
            aScreen->m_Commentaire3 = CONV_FROM_UTF8( buf );
            continue;
            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 );
            aScreen->m_Commentaire4 = CONV_FROM_UTF8( buf );
            continue;
            continue;
        }
        }
+26 −19
Original line number Original line Diff line number Diff line
@@ -1037,22 +1037,25 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
    int         newfmt = 0;
    int         newfmt = 0;
    char*       ptcar;
    char*       ptcar;
    wxString    fieldName;
    wxString    fieldName;
    char*       line = aLine.Line();


    m_convert = 1;
    m_convert = 1;


    if( ((char*)aLine)[0] == '$' )
    if( line[0] == '$' )
    {
    {
        newfmt = 1;
        newfmt = 1;


        if( !aLine.ReadLine() )
        if( !aLine.ReadLine() )
            return TRUE;
            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" ),
        aErrorMsg.Printf( wxT( "EESchema Component descr error at line %d, aborted" ),
                          aLine.LineNumber() );
                          aLine.LineNumber() );
        aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( ((char*)aLine) );
        aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( line );
        return false;
        return false;
    }
    }


@@ -1135,13 +1138,15 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
        if( !aLine.ReadLine() )
        if( !aLine.ReadLine() )
            return false;
            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
            // Set fields position to a default position (that is the
            // component position.  For existing fields, the real position
            // 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;
                    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:
            /* format:
             * AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1"
             * 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.
             * C99 is the reference given this path.
             */
             */
            int ii;
            int ii;
            ptcar = ((char*)aLine) + 2;
            ptcar = line + 2;


            //copy the path.
            //copy the path.
            ii     = ReadDelimitedText( Name1, ptcar, 255 );
            ii     = ReadDelimitedText( Name1, ptcar, 255 );
@@ -1183,7 +1188,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
            AddHierarchicalReference( path, ref, multi );
            AddHierarchicalReference( path, ref, multi );
            GetField( REFERENCE )->m_Text = ref;
            GetField( REFERENCE )->m_Text = ref;
        }
        }
        else if( ((char*)aLine)[0] == 'F' )
        else if( line[0] == 'F' )
        {
        {
            int  fieldNdx;
            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) );
            ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) );


@@ -1310,7 +1315,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
            break;
            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" ),
        aErrorMsg.Printf( wxT( "Component unit & pos error at line %d, aborted" ),
                          aLine.LineNumber() );
                          aLine.LineNumber() );
@@ -1334,7 +1339,9 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
        if( !aLine.ReadLine() )
        if( !aLine.ReadLine() )
            return false;
            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" ),
            aErrorMsg.Printf( wxT( "Component End expected at line %d, aborted" ),
                              aLine.LineNumber() );
                              aLine.LineNumber() );
+1 −1
Original line number Original line Diff line number Diff line
@@ -17,7 +17,7 @@ char* strlower( char* Text );


/**
/**
 * Function ReadDelimitedText
 * 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
 * The extracted string will be null terminated even if truncation is necessary
 * because aDestSize was not large enough.
 * because aDestSize was not large enough.
 *
 *