Commit 38269efa authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Fix bug 741352

parent 5f6cd454
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
#endif

#ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2011-03-23)"
#define KICAD_BUILD_VERSION "(2011-03-25)"
#endif

// uncomment this line only when creating a stable version
+4 −3
Original line number Diff line number Diff line
@@ -43,9 +43,10 @@ void CVPCB_MAINFRAME::WriteStuffList( wxCommandEvent& event )
    {
        if( component.m_Module.empty() )
            continue;
        fprintf( FileEquiv, "comp = \"%s\" module = \"%s\"\n",
                 TO_UTF8( component.m_Reference ),
                 TO_UTF8( component.m_Module ) );

        fprintf( FileEquiv, "comp = %s module = %s\n",
                 EscapedUTF8( component.m_Reference ).c_str(),
                 EscapedUTF8( component.m_Module ).c_str() );
    }

    fclose( FileEquiv );
+10 −20
Original line number Diff line number Diff line
@@ -113,8 +113,10 @@ bool LIB_FIELD::Save( FILE* ExportFile )
    if( text.IsEmpty() )
        text = wxT( "~" );

    if( fprintf( ExportFile, "F%d \"%s\" %d %d %d %c %c %c %c%c%c",
                 m_id, TO_UTF8( text ), m_Pos.x, m_Pos.y, m_Size.x,
    if( fprintf( ExportFile, "F%d %s %d %d %d %c %c %c %c%c%c",
                 m_id,
                 EscapedUTF8( text ).c_str(),       // wraps in quotes
                 m_Pos.x, m_Pos.y, m_Size.x,
                 m_Orient == 0 ? 'H' : 'V',
                 (m_Attributs & TEXT_NO_VISIBLE ) ? 'I' : 'V',
                 hjustify, vjustify,
@@ -129,10 +131,11 @@ bool LIB_FIELD::Save( FILE* ExportFile )
     */
    wxString defName = TEMPLATE_FIELDNAME::GetDefaultFieldName( m_id );

    if( m_id >= FIELD1 && !m_name.IsEmpty()
        && m_name != defName
        && fprintf( ExportFile, " \"%s\"", TO_UTF8( m_name ) ) < 0 )
    if( m_id >= FIELD1 && !m_name.IsEmpty() && m_name != defName
        && fprintf( ExportFile, " %s", EscapedUTF8( m_name ).c_str() ) < 0 )
    {
        return false;
    }

    if( fprintf( ExportFile, "\n" ) < 0 )
        return false;
@@ -148,8 +151,6 @@ bool LIB_FIELD::Load( char* line, wxString& errorMsg )
    char  textVisible;
    char  textHJustify;
    char  textVJustify[256];
    char  fieldUserName[1024];
    char* text;

    if( sscanf( line + 1, "%d", &m_id ) != 1 || m_id < 0 )
    {
@@ -169,21 +170,12 @@ bool LIB_FIELD::Load( char* line, wxString& errorMsg )

    if( *line == 0 )
        return false;
    line++;

    text = line;

    /* Find end of text. */
    while( *line && (*line != '"') )
        line++;
    line += ReadDelimitedText( &m_Text, line );

    if( *line == 0 )
        return false;

    *line = 0;
    line++;

    fieldUserName[0] = 0;
    memset( textVJustify, 0, sizeof( textVJustify ) );

    cnt = sscanf( line, " %d %d %d %c %c %c %s", &m_Pos.x, &m_Pos.y, &m_Size.y,
@@ -196,7 +188,6 @@ bool LIB_FIELD::Load( char* line, wxString& errorMsg )
        return false;
    }

    m_Text = FROM_UTF8( text );
    m_Size.x = m_Size.y;

    if( textOrient == 'H' )
@@ -270,8 +261,7 @@ bool LIB_FIELD::Load( char* line, wxString& errorMsg )
    }
    else
    {
        ReadDelimitedText( fieldUserName, line, sizeof( fieldUserName ) );
        m_name = FROM_UTF8( fieldUserName );
        ReadDelimitedText( &m_name, line );
    }

    return true;
+9 −23
Original line number Diff line number Diff line
@@ -1195,12 +1195,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
        {
            int  fieldNdx;

            char FieldUserName[1024];
            wxString fieldText;
            GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER;
            GRTextVertJustifyType  vjustify = GR_TEXT_VJUSTIFY_CENTER;

            FieldUserName[0] = 0;

            ptcar = (char*) aLine;

            while( *ptcar && (*ptcar != '"') )
@@ -1213,9 +1211,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
                return false;
            }

            for( ptcar++, ii = 0; ; ii++, ptcar++ )
            {
                Name1[ii] = *ptcar;
            ptcar += ReadDelimitedText( &fieldText, ptcar );
            if( *ptcar == 0 )
            {
                aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ),
@@ -1223,22 +1219,12 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
                return false;
            }

                if( *ptcar == '"' )
                {
                    Name1[ii] = 0;
                    ptcar++;
                    break;
                }
            }

            fieldNdx = atoi( line + 2 );

            ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) );
            ReadDelimitedText( &fieldName, ptcar );

            if( !FieldUserName[0] )
            if( fieldName.IsEmpty() )
                fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx );
            else
                fieldName = FROM_UTF8( FieldUserName );

            if( fieldNdx >= GetFieldCount() )
            {
@@ -1264,7 +1250,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
                GetField( fieldNdx )->m_Name = fieldName;
            }

            GetField( fieldNdx )->m_Text = FROM_UTF8( Name1 );
            GetField( fieldNdx )->m_Text = fieldText;
            memset( Char3, 0, sizeof(Char3) );
            if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1,
                               &GetField( fieldNdx )->m_Pos.x,
+4 −4
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
#include "sch_component.h"
#include "sch_field.h"
#include "template_fieldnames.h"

#include "kicad_string.h"

SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) :
    SCH_ITEM( aParent, SCH_FIELD_T ),
@@ -329,9 +329,9 @@ bool SCH_FIELD::Save( FILE* aFile ) const
    else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
        vjustify = 'T';

    if( fprintf( aFile, "F %d \"%s\" %c %-3d %-3d %-3d %4.4X %c %c%c%c",
    if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
                 m_FieldId,
                 TO_UTF8( m_Text ),
                 EscapedUTF8( m_Text ).c_str(),     // wraps in quotes too
                 m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V',
                 m_Pos.x, m_Pos.y,
                 m_Size.x,
@@ -346,7 +346,7 @@ bool SCH_FIELD::Save( FILE* aFile ) const
    // Save field name, if the name is user definable
    if( m_FieldId >= FIELD1 )
    {
        if( fprintf( aFile, " \"%s\"", TO_UTF8( m_Name ) ) == EOF )
        if( fprintf( aFile, " %s", EscapedUTF8( m_Name ).c_str() ) == EOF )
        {
            return false;
        }
Loading