Commit 0745188d authored by charras's avatar charras

some cleanup. Use local time now in DateAndTime. Time in files is now local time

parent f7f5ceae
/****************************************************************************/ /****************************************************************************/
/* MODULE: string.cpp */ /* string.cpp */
/* ROLE: fonctions complementaires de traitement de chaines de caracteres */ /* ROLE: fonctions complementaires de traitement de chaines de caracteres */
/****************************************************************************/ /****************************************************************************/
#include "fctsys.h" #include "fctsys.h"
#include <time.h> #include <time.h>
#include "common.h" #include "common.h"
#include "macros.h"
/*********************************************************************/ /*********************************************************************/
...@@ -24,7 +25,7 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar ) ...@@ -24,7 +25,7 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
for( ii = 0, jj = 0; ii < NbMaxChar - 1; jj++, source++ ) for( ii = 0, jj = 0; ii < NbMaxChar - 1; jj++, source++ )
{ {
if( *source == 0 ) if( *source == 0 )
break; /* fin de ligne */ break; /* E.O.L. */
if( *source == '"' ) /* delimiteur trouve */ if( *source == '"' ) /* delimiteur trouve */
{ {
if( flag ) if( flag )
...@@ -37,7 +38,7 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar ) ...@@ -37,7 +38,7 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
} }
} }
*dest = 0; /* Null terminaison */ *dest = 0; /* Null termined */
return jj; return jj;
} }
...@@ -46,8 +47,8 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar ) ...@@ -46,8 +47,8 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
char* StrPurge( char* text ) char* StrPurge( char* text )
/********************************/ /********************************/
/* Supprime les caracteres Space en debut de la ligne text /* Remove training space in text
* retourne un pointeur sur le 1er caractere non Space de text * return a pointer on the first not space char in text
*/ */
{ {
char* ptspace; char* ptspace;
...@@ -72,10 +73,10 @@ char* StrPurge( char* text ) ...@@ -72,10 +73,10 @@ char* StrPurge( char* text )
char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine ) char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine )
/*****************************************************************/ /*****************************************************************/
/* Routine de lecture de 1 ligne utile /* Read lines from File
* retourne la 1ere ligne utile lue. * Skip void lines and comments (starting by #)
* elimine lignes vides et commentaires * return the first non void line.
* incremente *LineNum a chaque ligne lue * increments *LineNum for ecah line
*/ */
{ {
do { do {
...@@ -92,39 +93,37 @@ char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine ) ...@@ -92,39 +93,37 @@ char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine )
/*******************************/ /*******************************/
char* DateAndTime( char* Line ) char* DateAndTime( char* aBuffer )
/*******************************/ /*******************************/
/* Retourne la chaine de caractere donnant date+heure */
/* return in aBuffer the date and time
* time is the local time.
*/
{ {
time_t Time_Buf; wxString datetime;
struct tm* Date;
time( &Time_Buf ); datetime = DateAndTime();
Date = gmtime( &Time_Buf ); strcpy( aBuffer, CONV_TO_UTF8( datetime ) );
sprintf( Line, "%d/%d/%d-%2.2d:%2.2d:%2.2d",
Date->tm_mday, Date->tm_mon + 1, Date->tm_year + 1900,
Date->tm_hour, Date->tm_min, Date->tm_sec );
return Line; return aBuffer;
} }
/*******************************/ /*******************************/
wxString DateAndTime() wxString DateAndTime()
/*******************************/ /*******************************/
/* Retourne la chaine de caractere donnant date+heure */
/* return a wxString filled with the date and time
* note: does the same thing than strftime()
* time is the local time.
*/
{ {
time_t Time_Buf;
struct tm* Date;
wxString Line; wxString Line;
time( &Time_Buf ); wxDateTime datetime = wxDateTime::Now();
Date = gmtime( &Time_Buf ); datetime.SetCountry( wxDateTime::Country_Default );
Line = datetime.Format( wxDefaultDateTimeFormat, wxDateTime::Local );
Line.Printf( wxT( "%d/%d/%d-%2.2d:%2.2d:%2.2d" ),
Date->tm_mday, Date->tm_mon + 1, Date->tm_year + 1900,
Date->tm_hour, Date->tm_min, Date->tm_sec );
return Line; return Line;
} }
...@@ -135,9 +134,9 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax ) ...@@ -135,9 +134,9 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
/************************************************************/ /************************************************************/
/* /*
* routine (compatible qsort() ) de comparaison pour classement alphabtique * sort() function
* Analogue a strncmp() mais les nombres sont compars selon leur valeur numrique * Same as strncmp() but numbers in strings
* et non pas par leur code ascii * are compared according to the value, not the ascii value of each digit
*/ */
{ {
int i; int i;
...@@ -148,7 +147,7 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax ) ...@@ -148,7 +147,7 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
for( i = 0; i < NbMax; i++ ) for( i = 0; i < NbMax; i++ )
{ {
if( isdigit( *str1 ) && isdigit( *str2 ) ) /* nombres en jeu */ if( isdigit( *str1 ) && isdigit( *str2 ) ) /* digit found */
{ {
nb1 = 0; nb2 = 0; nb1 = 0; nb2 = 0;
while( isdigit( *str1 ) ) while( isdigit( *str1 ) )
...@@ -185,10 +184,9 @@ int StrNumICmp( const wxChar* str1, const wxChar* str2 ) ...@@ -185,10 +184,9 @@ int StrNumICmp( const wxChar* str1, const wxChar* str2 )
/***********************************************/ /***********************************************/
/* /*
* routine (compatible qsort() ) de comparaison pour classement alphabtique, * sort() function
* avec lower case == upper case. * Same as stricmp() but numbers in strings
* Analogue a stricmp() mais les nombres sont compars selon leur valeur numrique * are compared according to the value, not the ascii value of each digit
* et non pas par leur code ascii
*/ */
{ {
return StrLenNumICmp( str1, str2, 32735 ); return StrLenNumICmp( str1, str2, 32735 );
...@@ -200,10 +198,9 @@ int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax ) ...@@ -200,10 +198,9 @@ int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax )
/**************************************************************/ /**************************************************************/
/* /*
* routine (compatible qsort() ) de comparaison pour classement alphabetique, * sort() function
* avec lower case == upper case. * Same as strnicmp() but numbers in strings
* Analogue a stricmp() mais les nombres sont compares selon leur valeur numerique * are compared according to the value, not the ascii value of each digit
* et non pas par leur code ascii
*/ */
{ {
int i; int i;
...@@ -214,7 +211,7 @@ int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax ) ...@@ -214,7 +211,7 @@ int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax )
for( i = 0; i < NbMax; i++ ) for( i = 0; i < NbMax; i++ )
{ {
if( isdigit( *str1 ) && isdigit( *str2 ) ) /* nombres en jeu */ if( isdigit( *str1 ) && isdigit( *str2 ) ) /* find number */
{ {
nb1 = 0; nb2 = 0; nb1 = 0; nb2 = 0;
while( isdigit( *str1 ) ) while( isdigit( *str1 ) )
...@@ -265,13 +262,17 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst, ...@@ -265,13 +262,17 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
if( case_sensitive ) if( case_sensitive )
{ {
wild = pattern.GetData(); string = string_to_tst.GetData(); wild = pattern.GetData();
string = string_to_tst.GetData();
} }
else else
{ {
_pattern = pattern; _pattern.MakeUpper(); _pattern = pattern;
_string_to_tst = string_to_tst; _string_to_tst.MakeUpper(); _pattern.MakeUpper();
wild = _pattern.GetData(); string = _string_to_tst.GetData(); _string_to_tst = string_to_tst;
_string_to_tst.MakeUpper();
wild = _pattern.GetData();
string = _string_to_tst.GetData();
} }
while( (*string) && (*wild != '*') ) while( (*string) && (*wild != '*') )
...@@ -285,7 +286,7 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst, ...@@ -285,7 +286,7 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
{ {
if( *wild == '*' ) if( *wild == '*' )
{ {
if( ! * ++wild ) if( !*++wild )
return 1; return 1;
mp = wild; mp = wild;
cp = string + 1; cp = string + 1;
...@@ -307,23 +308,7 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst, ...@@ -307,23 +308,7 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
wild++; wild++;
} }
return ! * wild; return !*wild;
}
/***********************************************/
void ChangeSpaces( char* Text, int NewChar )
/***********************************************/
/* Change dans un texte les espaces en NewChar */
{
if( Text == NULL )
return;
while( *Text )
{
if( *Text == ' ' )
*Text = (char) NewChar;
Text++;
}
} }
...@@ -331,9 +316,10 @@ void ChangeSpaces( char* Text, int NewChar ) ...@@ -331,9 +316,10 @@ void ChangeSpaces( char* Text, int NewChar )
char* to_point( char* Text ) char* to_point( char* Text )
/**************************/ /**************************/
/* convertit les , en . dans une chaine. utilis pour compenser /* convertit les , en . dans une chaine. utilise pour compenser
* l'internalisationde la fct printf * l'internalisation de la fct printf
* qui genere les flottants avec une virgule au lieu du point * qui genere les flottants avec une virgule au lieu du point
* Obsolete: use SetLocaleTo_C_standard insteed
*/ */
{ {
char* line = Text; char* line = Text;
...@@ -372,4 +358,3 @@ char* strupper( char* Text ) ...@@ -372,4 +358,3 @@ char* strupper( char* Text )
return Text; return Text;
} }
...@@ -119,6 +119,8 @@ bool SCH_SCREEN::Save( FILE* aFile ) const ...@@ -119,6 +119,8 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
wxString Name, msg; wxString Name, msg;
Ki_PageDescr* PlotSheet; Ki_PageDescr* PlotSheet;
wxString datetime = DateAndTime( );
LibNames = GetLibNames(); LibNames = GetLibNames();
for( int ii = 0; LibNames[ii] != NULL; ii++ ) for( int ii = 0; LibNames[ii] != NULL; ii++ )
{ {
...@@ -130,12 +132,15 @@ bool SCH_SCREEN::Save( FILE* aFile ) const ...@@ -130,12 +132,15 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
MyFree( LibNames ); MyFree( LibNames );
// Creates header // Creates header
if( fprintf( aFile, "%s %s %d\n", EESCHEMA_FILE_STAMP, if( fprintf( aFile, "%s %s %d", EESCHEMA_FILE_STAMP,
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) == EOF SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) == EOF )
|| fprintf( aFile, "LIBS:%s\n", CONV_TO_UTF8( Name ) ) == EOF ) return FALSE;
{
if( fprintf( aFile, " date %s\n", CONV_TO_UTF8(datetime) ) == EOF )
return FALSE;
if( fprintf( aFile, "LIBS:%s\n", CONV_TO_UTF8( Name ) ) == EOF )
return FALSE; return FALSE;
}
SaveLayers( aFile ); SaveLayers( aFile );
......
...@@ -61,14 +61,6 @@ setpage.o: ../share/setpage.cpp ...@@ -61,14 +61,6 @@ setpage.o: ../share/setpage.cpp
drawframe.o: ../share/drawframe.cpp drawframe.o: ../share/drawframe.cpp
$(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp $(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp
controle.o: controle.cpp
hotkeys.o: hotkeys.cpp hotkeys.h
set_color.o: set_color.cpp set_color.h
files.o: files.cpp
class_board_connected_item.o: ../pcbnew/class_board_connected_item.cpp class_board_connected_item.o: ../pcbnew/class_board_connected_item.cpp
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp $(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
...@@ -96,8 +88,6 @@ sel_layer.o: ../pcbnew/sel_layer.cpp ...@@ -96,8 +88,6 @@ sel_layer.o: ../pcbnew/sel_layer.cpp
wxprint.o: ../share/wxprint.cpp ../share/dialog_print.cpp ../share/dialog_print.h wxprint.o: ../share/wxprint.cpp ../share/dialog_print.cpp ../share/dialog_print.h
$(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp $(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp
lay2plot.o: lay2plot.cpp
classpcb.o: ../pcbnew/classpcb.cpp classpcb.o: ../pcbnew/classpcb.cpp
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp $(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
...@@ -116,83 +106,8 @@ collectors.o: ../pcbnew/collectors.cpp ...@@ -116,83 +106,8 @@ collectors.o: ../pcbnew/collectors.cpp
class_track.o: ../pcbnew/class_track.cpp class_track.o: ../pcbnew/class_track.cpp
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp $(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
$(TARGET).o: $(TARGET).cpp
gerbview_config.o: gerbview_config.cpp gerbview_config.h
tracepcb.o: tracepcb.cpp
block.o: block.cpp
trpiste.o: trpiste.cpp
surbrill.o: surbrill.cpp
pcbtexte.o: pcbtexte.cpp
zoom.o: ../share/zoom.cpp zoom.o: ../share/zoom.cpp
$(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp $(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp
affiche.o: affiche.cpp undelete.o: ../pcbnew/undelete.cpp
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
reglage.o: reglage.cpp
editrack.o: editrack.cpp
deltrack.o: deltrack.cpp
track.o: track.cpp
editrout.o: editrout.cpp autorout.h
editmod.o: editmod.cpp autorout.h
editpads.o: editpads.cpp
editedge.o: editedge.cpp
cotation.o: cotation.cpp
editexte.o: editexte.cpp
clean.o: clean.cpp autorout.h
pcbplot.o: pcbplot.cpp
plothpgl.o: plothpgl.cpp
plotgerb.o: plotgerb.cpp pcbplot.h
printps.o: printps.cpp pcbplot.h
readgerb.o: readgerb.cpp pcbplot.h
plot_rtn.o: plot_rtn.cpp pcbplot.h
gendrill.o: gendrill.cpp pcbplot.h
librairi.o: librairi.cpp autorout.h librairi.h
docedit.o: docedit.cpp
edgemod.o: edgemod.cpp
autorout.o: autorout.cpp cell.h autorout.fct autorout.h
setlayer.o: setlayer.cpp
dist.o: dist.cpp cell.h autorout.fct
zones.o: zones.cpp cell.h autorout.fct
undelete.o: undelete.cpp
ioascii.o: ioascii.cpp
chrono.o: chrono.cpp pcbnew.h
coordbox.o: coordbox.cpp
mirepcb.o: mirepcb.cpp
dragsegm.o: dragsegm.cpp drag.h
...@@ -39,15 +39,6 @@ asked by: Dick Hollenbeck ...@@ -39,15 +39,6 @@ asked by: Dick Hollenbeck
class editor from a UI perspective. class editor from a UI perspective.
2008-Feb-8 Assigned To: Jean-Pierre, per his email
asked by: Dick Hollenbeck
================================================================================
1) Remove the requirement to route tracks or vias for situations where a zone is.
2) Support connections from zones to vias, and zones to tracks, and zones to pads.
Review the GEDA source code and other sources to gather ideas before doing 2).
2008-Feb-8 Assigned To: dick 2008-Feb-8 Assigned To: dick
asked by: dick asked by: dick
================================================================================ ================================================================================
...@@ -63,13 +54,6 @@ asked by: jp Charras ...@@ -63,13 +54,6 @@ asked by: jp Charras
Use the collector classes in eeschema. Use the collector classes in eeschema.
2007-Nov-30 Assigned To: nobody
asked by: Dick Hollenbeck
================================================================================
wxString DateAndTime()
It seems the above function should be using a more user friendly "local time",
not gmtime.
2008-Apr-29 Assigned To: 2008-Apr-29 Assigned To:
asked by: Dick Hollenbeck asked by: Dick Hollenbeck
......
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