From 5aa957bcfff826866341ae779a1a175e594e882f Mon Sep 17 00:00:00 2001 From: Lorenzo Marcantonio Date: Thu, 24 May 2012 21:52:04 -0400 Subject: [PATCH] Rationalize numeric time stamps to type time_t. --- common/common.cpp | 6 +++--- eeschema/class_library.h | 1 + eeschema/netlist.h | 2 +- eeschema/sch_component.h | 2 +- include/base_struct.h | 6 +++--- include/class_collector.h | 6 +++--- include/common.h | 2 +- include/wxPcbStruct.h | 2 +- pcbnew/controle.cpp | 2 +- pcbnew/legacy_plugin.cpp | 16 ++++++++-------- pcbnew/netlist_reader.h | 1 + pcbnew/zones_by_polygon_fill_functions.cpp | 4 ++-- 12 files changed, 26 insertions(+), 24 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index d24e7518c4..7f0e4cc6e1 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -325,10 +325,10 @@ bool ProcessExecute( const wxString& aCommandLine, int aFlags ) } -unsigned long GetNewTimeStamp() +time_t GetNewTimeStamp() { - static unsigned long oldTimeStamp; - unsigned long newTimeStamp; + static time_t oldTimeStamp; + time_t newTimeStamp; newTimeStamp = time( NULL ); diff --git a/eeschema/class_library.h b/eeschema/class_library.h index 423d024f64..36bf8cf4ce 100644 --- a/eeschema/class_library.h +++ b/eeschema/class_library.h @@ -91,6 +91,7 @@ class CMP_LIBRARY { int type; ///< Library type indicator. wxFileName fileName; ///< Library file name. + // ZZZ why this a wxDateTime where others are time_t? wxDateTime timeStamp; ///< Library save time and date. int versionMajor; ///< Library major version number. int versionMinor; ///< Library minor version number. diff --git a/eeschema/netlist.h b/eeschema/netlist.h index 9ab8ce4b16..5521c20783 100644 --- a/eeschema/netlist.h +++ b/eeschema/netlist.h @@ -73,7 +73,7 @@ private: SCH_SHEET_PATH m_SheetPath; ///< The sheet path for this reference. bool m_IsNew; ///< True if not yet annotated. int m_SheetNum; ///< The sheet number for the reference. - unsigned long m_TimeStamp; ///< The time stamp for the reference. + time_t m_TimeStamp; ///< The time stamp for the reference. wxString* m_Value; ///< The component value of the refernce. It is the ///< same for all instances. int m_NumRef; ///< The numeric part of the reference designator. diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 6be67912e4..5087154371 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -195,7 +195,7 @@ public: * @see m_PathsAndReferences * @param aNewTimeStamp = new time stamp */ - void SetTimeStamp( long aNewTimeStamp ); + void SetTimeStamp( time_t aNewTimeStamp ); EDA_RECT GetBoundingBox() const; diff --git a/include/base_struct.h b/include/base_struct.h index 9350085124..6053b11758 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -400,7 +400,7 @@ protected: EDA_ITEM* m_Parent; /* Linked list: Link (parent struct) */ EDA_ITEM* m_Son; /* Linked list: Link (son struct) */ - unsigned long m_TimeStamp; ///< Time stamp used for logical links + time_t m_TimeStamp; ///< Time stamp used for logical links /// Set to true to override the visibility setting of the item. bool m_forceVisible; @@ -430,8 +430,8 @@ public: */ KICAD_T Type() const { return m_StructType; } - void SetTimeStamp( unsigned long aNewTimeStamp ) { m_TimeStamp = aNewTimeStamp; } - unsigned long GetTimeStamp() const { return m_TimeStamp; } + void SetTimeStamp( time_t aNewTimeStamp ) { m_TimeStamp = aNewTimeStamp; } + time_t GetTimeStamp() const { return m_TimeStamp; } EDA_ITEM* Next() const { return (EDA_ITEM*) Pnext; } EDA_ITEM* Back() const { return (EDA_ITEM*) Pback; } diff --git a/include/class_collector.h b/include/class_collector.h index 54cec07cdf..e51b32fe96 100644 --- a/include/class_collector.h +++ b/include/class_collector.h @@ -68,7 +68,7 @@ protected: EDA_RECT m_RefBox; /// The time at which the collection was made. - int m_TimeAtCollection; + time_t m_TimeAtCollection; public: @@ -205,7 +205,7 @@ public: } - int GetTime() + time_t GetTime() { return m_TimeAtCollection; } @@ -229,7 +229,7 @@ public: bool IsSimilarPointAndTime( const wxPoint& aRefPos ) { const int distMax = 2; // adjust these here - const int timeMax = 3; // seconds, I think + const time_t timeMax = 3; // seconds int dx = abs( aRefPos.x - m_RefPos.x ); int dy = abs( aRefPos.y - m_RefPos.y ); diff --git a/include/common.h b/include/common.h index 6309230033..a033987e1d 100644 --- a/include/common.h +++ b/include/common.h @@ -572,7 +572,7 @@ void InitKiCadAbout( wxAboutDialogInfo& info ); /** * @return an unique time stamp that changes after each call */ -unsigned long GetNewTimeStamp(); +time_t GetNewTimeStamp(); int DisplayColorFrame( wxWindow* parent, int OldColor ); int GetCommandOptions( const int argc, const char** argv, diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index fcb51db4d1..daf0211155 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -1202,7 +1202,7 @@ public: * @param aTimestamp = Timestamp for the zone to delete, used if aZone == * NULL */ - void Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp = 0 ); + void Delete_OldZone_Fill( SEGZONE* aZone, time_t aTimestamp = 0 ); /** * Function Delete_LastCreatedCorner diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 5e685aba76..3e8b52b9e4 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -153,7 +153,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) /* Remove redundancies: sometime, zones are found twice, * because zones can be filled by overlapping segments (this is a fill option) */ - unsigned long timestampzone = 0; + time_t timestampzone = 0; for( int ii = 0; ii < m_Collector->GetCount(); ii++ ) { diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 0fce1c79d4..3453663550 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -930,7 +930,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() int layer = intParse( data, &data ); long edittime = hexParse( data, &data ); - long timestamp = hexParse( data, &data ); + time_t timestamp = hexParse( data, &data ); data = strtok( (char*) data+1, delims ); @@ -957,7 +957,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE() else if( TESTLINE( "Sc" ) ) // timestamp { - long timestamp = hexParse( line + SZ( "Sc" ) ); + time_t timestamp = hexParse( line + SZ( "Sc" ) ); module->SetTimeStamp( timestamp ); } @@ -1676,7 +1676,7 @@ void LEGACY_PLUGIN::loadPCB_LINE() dseg->SetAngle( angle ); // m_Angle break; case 3: - long timestamp; + time_t timestamp; timestamp = hexParse( data ); dseg->SetTimeStamp( timestamp ); break; @@ -1841,7 +1841,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT() int layer = intParse( line + SZ( "De" ), &data ); int notMirrored = intParse( data, &data ); - long timestamp = hexParse( data, &data ); + time_t timestamp = hexParse( data, &data ); char* style = strtok( (char*) data, delims ); char* hJustify = strtok( NULL, delims ); @@ -1940,7 +1940,7 @@ void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType ) #endif int makeType; - long timeStamp; + time_t timeStamp; int layer, type, flags, net_code; // parse the 2nd line to determine the type of object @@ -2132,7 +2132,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() else if( TESTLINE( "ZInfo" ) ) // general info found { // e.g. 'ZInfo 479194B1 310 "COMMON"' - long timestamp = hexParse( line + SZ( "ZInfo" ), &data ); + time_t timestamp = hexParse( line + SZ( "ZInfo" ), &data ); int netcode = intParse( data, &data ); if( ReadDelimitedText( buf, data, sizeof(buf) ) > (int) sizeof(buf) ) @@ -2348,7 +2348,7 @@ void LEGACY_PLUGIN::loadDIMENSION() else if( TESTLINE( "Ge" ) ) { int layer; - long timestamp; + time_t timestamp; int shape; sscanf( line + SZ( "Ge" ), " %d %d %lX", &shape, &layer, ×tamp ); @@ -2542,7 +2542,7 @@ void LEGACY_PLUGIN::loadPCB_TARGET() BIU pos_y = biuParse( data, &data ); BIU size = biuParse( data, &data ); BIU width = biuParse( data, &data ); - long timestamp = hexParse( data ); + time_t timestamp = hexParse( data ); if( layer < FIRST_NO_COPPER_LAYER ) layer = FIRST_NO_COPPER_LAYER; diff --git a/pcbnew/netlist_reader.h b/pcbnew/netlist_reader.h index c75d58f0f4..dabf7b8a95 100644 --- a/pcbnew/netlist_reader.h +++ b/pcbnew/netlist_reader.h @@ -78,6 +78,7 @@ public: wxString m_Footprint; // the footprint name found in netlist, the in .cmp file wxString m_Reference; // the schematic reference found in netlist wxString m_Value; // the schematic value found in netlist + // ZZZ This timestamp is string, not time_t wxString m_TimeStamp; // the schematic full time stamp found in netlist wxString m_Libpart; // the schematic libpart found in netlist wxArrayString m_FootprintFilter; // a footprint filters list found in old format netlist diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index 35bd1d1565..2705b44831 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -53,10 +53,10 @@ * @param aZone = zone segment within the zone to delete. Can be NULL * @param aTimestamp = Timestamp for the zone to delete, used if aZone == NULL */ -void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp ) +void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, time_t aTimestamp ) { bool modify = false; - unsigned long TimeStamp; + time_t TimeStamp; if( aZone == NULL ) TimeStamp = aTimestamp;