Commit 03d85728 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

bugfix

parent cc63f5f8
Loading
Loading
Loading
Loading
+37 −10
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "general.h"
#include "protos.h"
#include "sch_sheet.h"
#include "kicad_string.h"


/* m_Edge define on which edge the pin is positionned:
@@ -258,14 +259,40 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg )
    char    name[256];
    char    connectType[256];
    char    sheetSide[256];
    char*   line = aLine.Line();
    char*   cp;

    /* Read coordinates. */
    if( sscanf( ((char*)aLine), "%s %s %s %s %d %d %d",
                number, name, connectType, sheetSide, &m_Pos.x, &m_Pos.y, &size ) != 7 )
    static const char delims[] = " \t";

    // Read coordinates.
    D( printf( "line: \"%s\"\n", line );)

    cp = strtok( line, delims );

    strncpy( number, cp, sizeof(number) );
    number[sizeof(number)-1] = 0;

    cp += strlen( number ) + 1;

    cp += ReadDelimitedText( name, cp, sizeof(name) );

    cp = strtok( cp, delims );
    strncpy( connectType, cp, sizeof(connectType) );
    connectType[sizeof(connectType)-1] = 0;

    cp = strtok( NULL, delims );
    strncpy( sheetSide, cp, sizeof(sheetSide) );
    sheetSide[sizeof(sheetSide)-1] = 0;

    cp += strlen( sheetSide ) + 1;

    int r = sscanf( cp, "%d %d %d", &m_Pos.x, &m_Pos.y, &size );
    if( r != 3 )
    {
        aErrorMsg.Printf( wxT( "EESchema file sheet hierarchical label error at line %d.\n" ),
                          aLine.LineNumber() );
        aErrorMsg << FROM_UTF8( ((char*)aLine) );

        aErrorMsg << FROM_UTF8( line );
        return false;
    }