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 */
/****************************************************************************/
#include "fctsys.h"
#include <time.h>
#include "common.h"
#include "macros.h"
/*********************************************************************/
......@@ -24,7 +25,7 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
for( ii = 0, jj = 0; ii < NbMaxChar - 1; jj++, source++ )
{
if( *source == 0 )
break; /* fin de ligne */
break; /* E.O.L. */
if( *source == '"' ) /* delimiteur trouve */
{
if( flag )
......@@ -37,7 +38,7 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
}
}
*dest = 0; /* Null terminaison */
*dest = 0; /* Null termined */
return jj;
}
......@@ -46,8 +47,8 @@ int ReadDelimitedText( char* dest, char* source, int NbMaxChar )
char* StrPurge( char* text )
/********************************/
/* Supprime les caracteres Space en debut de la ligne text
* retourne un pointeur sur le 1er caractere non Space de text
/* Remove training space in text
* return a pointer on the first not space char in text
*/
{
char* ptspace;
......@@ -72,10 +73,10 @@ char* StrPurge( char* text )
char* GetLine( FILE* File, char* Line, int* LineNum, int SizeLine )
/*****************************************************************/
/* Routine de lecture de 1 ligne utile
* retourne la 1ere ligne utile lue.
* elimine lignes vides et commentaires
* incremente *LineNum a chaque ligne lue
/* Read lines from File
* Skip void lines and comments (starting by #)
* return the first non void line.
* increments *LineNum for ecah line
*/
{
do {
......@@ -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;
struct tm* Date;
wxString datetime;
time( &Time_Buf );
Date = gmtime( &Time_Buf );
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 );
datetime = DateAndTime();
strcpy( aBuffer, CONV_TO_UTF8( datetime ) );
return Line;
return aBuffer;
}
/*******************************/
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;
time( &Time_Buf );
Date = gmtime( &Time_Buf );
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 );
wxDateTime datetime = wxDateTime::Now();
datetime.SetCountry( wxDateTime::Country_Default );
Line = datetime.Format( wxDefaultDateTimeFormat, wxDateTime::Local );
return Line;
}
......@@ -135,9 +134,9 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
/************************************************************/
/*
* routine (compatible qsort() ) de comparaison pour classement alphabtique
* Analogue a strncmp() mais les nombres sont compars selon leur valeur numrique
* et non pas par leur code ascii
* sort() function
* Same as strncmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit
*/
{
int i;
......@@ -148,7 +147,7 @@ int StrLenNumCmp( const wxChar* str1, const wxChar* str2, int NbMax )
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;
while( isdigit( *str1 ) )
......@@ -185,10 +184,9 @@ int StrNumICmp( const wxChar* str1, const wxChar* str2 )
/***********************************************/
/*
* routine (compatible qsort() ) de comparaison pour classement alphabtique,
* avec lower case == upper case.
* Analogue a stricmp() mais les nombres sont compars selon leur valeur numrique
* et non pas par leur code ascii
* sort() function
* Same as stricmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit
*/
{
return StrLenNumICmp( str1, str2, 32735 );
......@@ -200,10 +198,9 @@ int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax )
/**************************************************************/
/*
* routine (compatible qsort() ) de comparaison pour classement alphabetique,
* avec lower case == upper case.
* Analogue a stricmp() mais les nombres sont compares selon leur valeur numerique
* et non pas par leur code ascii
* sort() function
* Same as strnicmp() but numbers in strings
* are compared according to the value, not the ascii value of each digit
*/
{
int i;
......@@ -214,7 +211,7 @@ int StrLenNumICmp( const wxChar* str1, const wxChar* str2, int NbMax )
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;
while( isdigit( *str1 ) )
......@@ -265,13 +262,17 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
if( case_sensitive )
{
wild = pattern.GetData(); string = string_to_tst.GetData();
wild = pattern.GetData();
string = string_to_tst.GetData();
}
else
{
_pattern = pattern; _pattern.MakeUpper();
_string_to_tst = string_to_tst; _string_to_tst.MakeUpper();
wild = _pattern.GetData(); string = _string_to_tst.GetData();
_pattern = pattern;
_pattern.MakeUpper();
_string_to_tst = string_to_tst;
_string_to_tst.MakeUpper();
wild = _pattern.GetData();
string = _string_to_tst.GetData();
}
while( (*string) && (*wild != '*') )
......@@ -285,7 +286,7 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
{
if( *wild == '*' )
{
if( ! * ++wild )
if( !*++wild )
return 1;
mp = wild;
cp = string + 1;
......@@ -307,23 +308,7 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
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++;
}
return !*wild;
}
......@@ -331,9 +316,10 @@ void ChangeSpaces( char* Text, int NewChar )
char* to_point( char* Text )
/**************************/
/* convertit les , en . dans une chaine. utilis pour compenser
* l'internalisationde la fct printf
/* convertit les , en . dans une chaine. utilise pour compenser
* l'internalisation de la fct printf
* qui genere les flottants avec une virgule au lieu du point
* Obsolete: use SetLocaleTo_C_standard insteed
*/
{
char* line = Text;
......@@ -372,4 +358,3 @@ char* strupper( char* Text )
return Text;
}
......@@ -119,6 +119,8 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
wxString Name, msg;
Ki_PageDescr* PlotSheet;
wxString datetime = DateAndTime( );
LibNames = GetLibNames();
for( int ii = 0; LibNames[ii] != NULL; ii++ )
{
......@@ -130,12 +132,15 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
MyFree( LibNames );
// Creates header
if( fprintf( aFile, "%s %s %d\n", EESCHEMA_FILE_STAMP,
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) == EOF
|| fprintf( aFile, "LIBS:%s\n", CONV_TO_UTF8( Name ) ) == EOF )
{
if( fprintf( aFile, "%s %s %d", EESCHEMA_FILE_STAMP,
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) == 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;
}
SaveLayers( aFile );
......
......@@ -61,14 +61,6 @@ setpage.o: ../share/setpage.cpp
drawframe.o: ../share/drawframe.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
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.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
$(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp
lay2plot.o: lay2plot.cpp
classpcb.o: ../pcbnew/classpcb.cpp
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
......@@ -116,83 +106,8 @@ collectors.o: ../pcbnew/collectors.cpp
class_track.o: ../pcbnew/class_track.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
$(CXX) -c $(EDACPPFLAGS) -o $@ ../share/$*.cpp
affiche.o: affiche.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
undelete.o: ../pcbnew/undelete.cpp
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
......@@ -39,15 +39,6 @@ asked by: Dick Hollenbeck
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
asked by: dick
================================================================================
......@@ -63,13 +54,6 @@ asked by: jp Charras
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:
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