diff --git a/gerbview/X2_gerber_attributes.cpp b/gerbview/X2_gerber_attributes.cpp index 44e2589ac8..3baf308db2 100644 --- a/gerbview/X2_gerber_attributes.cpp +++ b/gerbview/X2_gerber_attributes.cpp @@ -133,7 +133,7 @@ bool X2_ATTRIBUTE::ParseAttribCmd( FILE* aFile, char *aBuffer, int aBuffSize, ch } // end of current line, read another one. - if( aBuffer ) + if( aBuffer && aFile ) { if( fgets( aBuffer, aBuffSize, aFile ) == NULL ) { diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index 4bb44cdacd..7771245735 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -104,10 +104,10 @@ void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem, wxSize aPenSize, bool aLayerNegative ); -// Getber X2 files have a file attribute which specify the type of image +// Gerber X2 files have a file attribute which specify the type of image // (copper, solder paste ... and sides tpo, bottom or inner copper layers) // Excellon drill files do not have attributes, so, just to identify the image -// In gerbview, we add this attribute, like a Gerber drill file +// In gerbview, we add this attribute, similat to a Gerber drill file static const char file_attribute[] = ".FileFunction,Other,Drill*"; static EXCELLON_CMD excellonHeaderCmdList[] = @@ -314,7 +314,7 @@ bool EXCELLON_IMAGE::LoadFile( const wxString & aFullFileName ) X2_ATTRIBUTE dummy; char* text = (char*)file_attribute; int dummyline = 0; - dummy.ParseAttribCmd( m_Current_File, NULL, 0, text, dummyline ); + dummy.ParseAttribCmd( NULL, NULL, 0, text, dummyline ); delete m_FileFunction; m_FileFunction = new X2_ATTRIBUTE_FILEFUNCTION( dummy ); diff --git a/gerbview/gerber_file_image.h b/gerbview/gerber_file_image.h index a8e2a73e3d..f071231d00 100644 --- a/gerbview/gerber_file_image.h +++ b/gerbview/gerber_file_image.h @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2010-2016 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2010-2018 Jean-Pierre Charras jp.charras at wanadoo.fr + * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -175,9 +175,8 @@ private: // 0 = no negative items found // 1 = have negative items found /** - * Function GetNextLine * test for an end of line - * if an end of line is found: + * if a end of line is found: * read a new line * @param aBuff = buffer (size = GERBER_BUFZ) to fill with a new line * @param aText = pointer to the last useful char in aBuff @@ -190,6 +189,44 @@ private: bool GetEndOfBlock( char* aBuff, unsigned int aBuffSize, char*& aText, FILE* aGerberFile ); + /** + * reads a single RS274X command terminated with a % + */ + bool ReadRS274XCommand( char *aBuff, unsigned int aBuffSize, char*& aText ); + + /** + * executes a RS274X command + */ + bool ExecuteRS274XCommand( int aCommand, char* aBuff, + unsigned int aBuffSize, char*& aText ); + + /** + * reads two bytes of data and assembles them into an int with the first + * byte in the sequence put into the most significant part of a 16 bit value + * to build a RS274X command identifier. + * @param text A reference to a pointer to read bytes from and to advance as + * they are read. + * @return a RS274X command identifier. + */ + int ReadXCommandID( char*& text ); + + /** + * reads in an aperture macro and saves it in m_aperture_macros. + * @param aBuff a character buffer at least GERBER_BUFZ long that can be + * used to read successive lines from the gerber file. + * @param text A reference to a character pointer which gives the initial + * text to read from. + * @param aBuffSize is the size of aBuff + * @param gerber_file Which file to read from for continuation. + * @return bool - true if a macro was read in successfully, else false. + */ + bool ReadApertureMacro( char *aBuff, unsigned int aBuffSize, + char* & text, FILE * gerber_file ); + + // functions to execute G commands or D basic commands: + bool Execute_G_Command( char*& text, int G_command ); + bool Execute_DCODE_Command( char*& text, int D_command ); + public: GERBER_FILE_IMAGE( int layer ); virtual ~GERBER_FILE_IMAGE(); @@ -275,7 +312,6 @@ public: wxPoint ReadXYCoord( char*& Text ); /** - * Function ReadIJCoord * Returns the current coordinate type pointed to by InnJnn Text (InnnnJmmmm) * These coordinates are relative, so if coordinate is absent, it's value * defaults to 0 @@ -286,48 +322,6 @@ public: int GCodeNumber( char*& Text ); int DCodeNumber( char*& Text ); - // functions to execute G commands or D commands: - bool Execute_G_Command( char*& text, int G_command ); - bool Execute_DCODE_Command( char*& text, int D_command ); - - /** - * Function ReadRS274XCommand - * reads a single RS274X command terminated with a % - */ - bool ReadRS274XCommand( char *aBuff, unsigned int aBuffSize, char*& aText ); - - /** - * Function ExecuteRS274XCommand - * executes a RS274X command - */ - bool ExecuteRS274XCommand( int aCommand, char* aBuff, - unsigned int aBuffSize, char*& aText ); - - /** - * reads two bytes of data and assembles them into an int with the first - * byte in the sequence put into the most significant part of a 16 bit value - * to build a RS274X command identifier. - * @param text A reference to a pointer to read bytes from and to advance as - * they are read. - * @return a RS274X command identifier. - */ - int ReadXCommandID( char*& text ); - - /** - * Function ReadApertureMacro - * reads in an aperture macro and saves it in m_aperture_macros. - * @param aBuff a character buffer at least GERBER_BUFZ long that can be - * used to read successive lines from the gerber file. - * @param text A reference to a character pointer which gives the initial - * text to read from. - * @param aBuffSize is the size of aBuff - * @param gerber_file Which file to read from for continuation. - * @return bool - true if a macro was read in successfully, else false. - */ - bool ReadApertureMacro( char *aBuff, unsigned int aBuffSize, - char* & text, FILE * gerber_file ); - - /** * Function GetDCODEOrCreate * returns a pointer to the D_CODE within this GERBER for the given diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index 707070332e..92bf9232ef 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -6,7 +6,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index 3c64999c51..6f153023dd 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2007-2016 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2007-2018 Jean-Pierre Charras jp.charras at wanadoo.fr + * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License