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

Fix bug 741352

parent 5f6cd454
......@@ -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
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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,32 +1211,20 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
return false;
}
for( ptcar++, ii = 0; ; ii++, ptcar++ )
ptcar += ReadDelimitedText( &fieldText, ptcar );
if( *ptcar == 0 )
{
Name1[ii] = *ptcar;
if( *ptcar == 0 )
{
aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ),
aLine.LineNumber() );
return false;
}
if( *ptcar == '"' )
{
Name1[ii] = 0;
ptcar++;
break;
}
aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ),
aLine.LineNumber() );
return false;
}
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,
......
......@@ -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;
}
......
......@@ -480,14 +480,14 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
m_CurrentSheetDesc->m_Size.x, m_CurrentSheetDesc->m_Size.y ) < 0
|| fprintf( aFile, "encoding utf-8\n") < 0
|| fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreen ) < 0
|| fprintf( aFile, "Title \"%s\"\n", TO_UTF8( m_Title ) ) < 0
|| fprintf( aFile, "Date \"%s\"\n", TO_UTF8( m_Date ) ) < 0
|| fprintf( aFile, "Rev \"%s\"\n", TO_UTF8( m_Revision ) ) < 0
|| fprintf( aFile, "Comp \"%s\"\n", TO_UTF8( m_Company ) ) < 0
|| fprintf( aFile, "Comment1 \"%s\"\n", TO_UTF8( m_Commentaire1 ) ) < 0
|| fprintf( aFile, "Comment2 \"%s\"\n", TO_UTF8( m_Commentaire2 ) ) < 0
|| fprintf( aFile, "Comment3 \"%s\"\n", TO_UTF8( m_Commentaire3 ) ) < 0
|| fprintf( aFile, "Comment4 \"%s\"\n", TO_UTF8( m_Commentaire4 ) ) < 0
|| fprintf( aFile, "Title %s\n", EscapedUTF8( m_Title ).c_str() ) < 0
|| fprintf( aFile, "Date %s\n", EscapedUTF8( m_Date ).c_str() ) < 0
|| fprintf( aFile, "Rev %s\n", EscapedUTF8( m_Revision ).c_str() ) < 0
|| fprintf( aFile, "Comp %s\n", EscapedUTF8( m_Company ).c_str() ) < 0
|| fprintf( aFile, "Comment1 %s\n", EscapedUTF8( m_Commentaire1 ).c_str() ) < 0
|| fprintf( aFile, "Comment2 %s\n", EscapedUTF8( m_Commentaire2 ).c_str() ) < 0
|| fprintf( aFile, "Comment3 %s\n", EscapedUTF8( m_Commentaire3 ).c_str() ) < 0
|| fprintf( aFile, "Comment4 %s\n", EscapedUTF8( m_Commentaire4 ).c_str() ) < 0
|| fprintf( aFile, "$EndDescr\n" ) < 0 )
return false;
......
......@@ -26,7 +26,7 @@
#include "sch_sheet.h"
#include "sch_sheet_path.h"
#include "sch_component.h"
#include "kicad_string.h"
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_SHEET_T )
......@@ -131,14 +131,14 @@ bool SCH_SHEET::Save( FILE* aFile ) const
/* Save schematic sheetname and filename. */
if( !m_SheetName.IsEmpty() )
{
if( fprintf( aFile, "F0 \"%s\" %d\n", TO_UTF8( m_SheetName ),
if( fprintf( aFile, "F0 %s %d\n", EscapedUTF8( m_SheetName ).c_str(),
m_SheetNameSize ) == EOF )
return false;
}
if( !m_FileName.IsEmpty() )
{
if( fprintf( aFile, "F1 \"%s\" %d\n", TO_UTF8( m_FileName ),
if( fprintf( aFile, "F1 %s %d\n", EscapedUTF8( m_FileName ).c_str(),
m_FileNameSize ) == EOF )
return false;
}
......@@ -160,8 +160,7 @@ bool SCH_SHEET::Save( FILE* aFile ) const
bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
{
int ii, fieldNdx, size;
char Name1[256];
int fieldNdx, size;
SCH_SHEET_PIN* SheetLabel;
char* ptcar;
......@@ -231,24 +230,15 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
return false;
}
for( ptcar++, ii = 0; ; ii++, ptcar++ )
{
Name1[ii] = *ptcar;
if( *ptcar == 0 )
{
aErrorMsg.Printf( wxT( "EESchema file sheet field F at line %d, aborted\n" ),
aLine.LineNumber() );
aErrorMsg << FROM_UTF8( (char*) aLine );
return false;
}
wxString sheetName;
ptcar += ReadDelimitedText( &sheetName, ptcar );
if( *ptcar == '"' )
{
Name1[ii] = 0;
ptcar++;
break;
}
if( *ptcar == 0 )
{
aErrorMsg.Printf( wxT( "EESchema file sheet field F at line %d, aborted\n" ),
aLine.LineNumber() );
aErrorMsg << FROM_UTF8( (char*) aLine );
return false;
}
if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) )
......@@ -265,14 +255,12 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( fieldNdx == 0 )
{
m_SheetName = FROM_UTF8( Name1 );
m_SheetName = sheetName;
m_SheetNameSize = size;
}
else
{
SetFileName( FROM_UTF8( Name1 ) );
//printf( "in ReadSheetDescr : m_FileName = %s \n", Name1 );
SetFileName( sheetName );
m_FileNameSize = size;
}
}
......
......@@ -17,7 +17,7 @@
; General Product Description Definitions
!define PRODUCT_NAME "KiCad"
!define PRODUCT_VERSION "2011.03.23"
!define PRODUCT_VERSION "2011.03.25"
!define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/"
!define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/"
!define COMPANY_NAME ""
......
......@@ -362,7 +362,7 @@ bool DIMENSION::Save( FILE* aFile ) const
fprintf( aFile, "Va %d\n", m_Value );
if( !m_Text->m_Text.IsEmpty() )
fprintf( aFile, "Te \"%s\"\n", TO_UTF8( m_Text->m_Text ) );
fprintf( aFile, "Te %s\n", EscapedUTF8( m_Text->m_Text ).c_str() );
else
fprintf( aFile, "Te \"?\"\n" );
......
......@@ -370,7 +370,7 @@ int MODULE::Write_3D_Descr( FILE* File ) const
{
fprintf( File, "$SHAPE3D\n" );
fprintf( File, "Na \"%s\"\n", TO_UTF8( t3D->m_Shape3DName ) );
fprintf( File, "Na %s\n", EscapedUTF8( t3D->m_Shape3DName ).c_str() );
sprintf( buf, "Sc %lf %lf %lf\n",
t3D->m_MatScale.x,
......
......@@ -286,8 +286,8 @@ bool NETCLASS::Save( FILE* aFile ) const
bool result = true;
fprintf( aFile, "$" BRD_NETCLASS "\n" );
fprintf( aFile, "Name \"%s\"\n", TO_UTF8( m_Name ) );
fprintf( aFile, "Desc \"%s\"\n", TO_UTF8( GetDescription() ) );
fprintf( aFile, "Name %s\n", EscapedUTF8( m_Name ).c_str() );
fprintf( aFile, "Desc %s\n", EscapedUTF8( GetDescription() ).c_str() );
// Write parameters
......@@ -302,7 +302,7 @@ bool NETCLASS::Save( FILE* aFile ) const
// Write members:
for( const_iterator i = begin(); i!=end(); ++i )
fprintf( aFile, "AddNet \"%s\"\n", TO_UTF8( *i ) );
fprintf( aFile, "AddNet %s\n", EscapedUTF8( *i ).c_str() );
fprintf( aFile, "$End" BRD_NETCLASS "\n" );
......
......@@ -78,11 +78,9 @@ bool NETINFO_ITEM::Save( FILE* aFile ) const
bool success = false;
fprintf( aFile, "$EQUIPOT\n" );
fprintf( aFile, "Na %d \"%s\"\n", GetNet(), TO_UTF8( m_Netname ) );
fprintf( aFile, "Na %d %s\n", GetNet(), EscapedUTF8( m_Netname ).c_str() );
fprintf( aFile, "St %s\n", "~" );
// fprintf( aFile, "NetClass \"%s\"\n", TO_UTF8(m_NetClassName) );
if( fprintf( aFile, "$EndEQUIPOT\n" ) != sizeof("$EndEQUIPOT\n") - 1 )
goto out;
......
......@@ -558,18 +558,19 @@ bool D_PAD::Save( FILE* aFile ) const
fprintf( aFile, "At %s N %8.8X\n", texttype, m_Masque_Layer );
fprintf( aFile, "Ne %d \"%s\"\n", GetNet(), TO_UTF8( m_Netname ) );
fprintf( aFile, "Ne %d %s\n", GetNet(), EscapedUTF8( m_Netname ).c_str() );
fprintf( aFile, "Po %d %d\n", m_Pos0.x, m_Pos0.y );
if( m_LocalSolderMaskMargin != 0 )
fprintf( aFile, ".SolderMask %d\n", m_LocalSolderMaskMargin );
if( m_LocalSolderPasteMargin != 0 )
fprintf( aFile, ".SolderPaste %d\n", m_LocalSolderPasteMargin );
if( m_LocalSolderPasteMarginRatio != 0 )
fprintf( aFile,
".SolderPasteRatio %g\n",
m_LocalSolderPasteMarginRatio );
fprintf( aFile, ".SolderPasteRatio %g\n", m_LocalSolderPasteMarginRatio );
if( m_LocalClearance != 0 )
fprintf( aFile, ".LocalClearance %d\n", m_LocalClearance );
......
......@@ -87,7 +87,8 @@ bool TEXTE_MODULE::Save( FILE* aFile ) const
m_Mirror ? 'M' : 'N', m_NoShow ? 'I' : 'V',
GetLayer(),
m_Italic ? 'I' : 'N',
TO_UTF8( m_Text ) );
EscapedUTF8( m_Text ).c_str()
);
return ret > 20;
}
......@@ -101,37 +102,41 @@ bool TEXTE_MODULE::Save( FILE* aFile ) const
*/
int TEXTE_MODULE::ReadDescr( LINE_READER* aReader )
{
int success = true;
int type;
int layer;
char BufCar1[128], BufCar2[128], BufCar3[128], BufLine[256];
char *aLine;
int success = true;
int type;
char BufCar1[128], BufCar2[128], BufCar3[128];
char* line = aReader->Line();
aLine = aReader->Line();
int layer = SILKSCREEN_N_FRONT;
layer = SILKSCREEN_N_FRONT;
BufCar1[0] = 0;
BufCar2[0] = 0;
BufCar3[0] = 0;
if( sscanf( aLine + 1, "%d %d %d %d %d %d %d %s %s %d %s",
if( sscanf( line + 1, "%d %d %d %d %d %d %d %s %s %d %s",
&type,
&m_Pos0.x, &m_Pos0.y,
&m_Size.y, &m_Size.x,
&m_Orient, &m_Thickness,
BufCar1, BufCar2, &layer, BufCar3 ) >= 10 )
{
success = true;
}
if( (type != TEXT_is_REFERENCE) && (type != TEXT_is_VALUE) )
type = TEXT_is_DIVERS;
m_Type = type;
// Due to the pcbnew history, .m_Orient is saved in screen value
// but it is handled as relative to its parent footprint
m_Orient -= ( (MODULE*) m_Parent )->m_Orient;
if( BufCar1[0] == 'M' )
m_Mirror = true;
else
m_Mirror = false;
if( BufCar2[0] == 'I' )
m_NoShow = true;
else
......@@ -154,11 +159,13 @@ int TEXTE_MODULE::ReadDescr( LINE_READER* aReader )
SetLayer( layer );
/* Calculate the true position. */
// Calculate the true position.
SetDrawCoord();
/* Read the "text" string. */
ReadDelimitedText( BufLine, aLine, sizeof(BufLine) );
m_Text = FROM_UTF8( BufLine );
// Read the "text" string.
// @todo why is line not incremented, what are we reading here?
ReadDelimitedText( &m_Text, line );
// Test for a reasonable size:
if( m_Size.x < TEXTS_MIN_SIZE )
......
......@@ -107,9 +107,9 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
fprintf( aFile, "$CZONE_OUTLINE\n" );
// Save the outline main info
ret = fprintf( aFile, "ZInfo %8.8lX %d \"%s\"\n",
ret = fprintf( aFile, "ZInfo %8.8lX %d %s\n",
m_TimeStamp, m_NetCode,
TO_UTF8( m_Netname ) );
EscapedUTF8( m_Netname ).c_str() );
if( ret < 3 )
return false;
......
......@@ -386,17 +386,14 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event )
Module = (MODULE*) GetBoard()->m_Modules;
for( ; Module != NULL; Module = Module->Next() )
{
sprintf( line, "$MODULE \"%s\"\n",
TO_UTF8( Module->m_Reference->m_Text ) );
sprintf( line, "$MODULE %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() );
fputs( line, rptfile );
sprintf( line, "reference \"%s\"\n",
TO_UTF8( Module->m_Reference->m_Text ) );
sprintf( line, "reference %s\n", EscapedUTF8( Module->m_Reference->m_Text ).c_str() );
fputs( line, rptfile );
sprintf( line, "value \"%s\"\n",
TO_UTF8( Module->m_Value->m_Text ) );
sprintf( line, "value %s\n", EscapedUTF8( Module->m_Value->m_Text ).c_str() );
fputs( line, rptfile );
sprintf( line, "footprint \"%s\"\n", TO_UTF8( Module->m_LibRef ) );
sprintf( line, "footprint %s\n", EscapedUTF8( Module->m_LibRef ).c_str() );
fputs( line, rptfile );
msg = wxT( "attribut" );
......
......@@ -830,14 +830,14 @@ bool WriteSheetDescr( BASE_SCREEN* screen, FILE* File )
fprintf( File, "$SHEETDESCR\n" );
fprintf( File, "Sheet %s %d %d\n",
TO_UTF8( sheet->m_Name ), sheet->m_Size.x, sheet->m_Size.y );
fprintf( File, "Title \"%s\"\n", TO_UTF8( screen->m_Title ) );
fprintf( File, "Date \"%s\"\n", TO_UTF8( screen->m_Date ) );
fprintf( File, "Rev \"%s\"\n", TO_UTF8( screen->m_Revision ) );
fprintf( File, "Comp \"%s\"\n", TO_UTF8( screen->m_Company ) );
fprintf( File, "Comment1 \"%s\"\n", TO_UTF8( screen->m_Commentaire1 ) );
fprintf( File, "Comment2 \"%s\"\n", TO_UTF8( screen->m_Commentaire2 ) );
fprintf( File, "Comment3 \"%s\"\n", TO_UTF8( screen->m_Commentaire3 ) );
fprintf( File, "Comment4 \"%s\"\n", TO_UTF8( screen->m_Commentaire4 ) );
fprintf( File, "Title %s\n", EscapedUTF8( screen->m_Title ).c_str() );
fprintf( File, "Date %s\n", EscapedUTF8( screen->m_Date ).c_str() );
fprintf( File, "Rev %s\n", EscapedUTF8( screen->m_Revision ).c_str() );
fprintf( File, "Comp %s\n", EscapedUTF8( screen->m_Company ).c_str() );
fprintf( File, "Comment1 %s\n", EscapedUTF8( screen->m_Commentaire1 ).c_str() );
fprintf( File, "Comment2 %s\n", EscapedUTF8( screen->m_Commentaire2 ).c_str() );
fprintf( File, "Comment3 %s\n", EscapedUTF8( screen->m_Commentaire3 ).c_str() );
fprintf( File, "Comment4 %s\n", EscapedUTF8( screen->m_Commentaire4 ).c_str() );
fprintf( File, "$EndSHEETDESCR\n\n" );
return TRUE;
......
release version:
2011 mar 17
files (.zip,.tgz):
kicad-2011-03-23
kicad-2011-03-25
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