mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Rework the localtime logic yet again in order to make all branches reachable
and to follow GNU standards for HAVE_LOCALTIME_R-type macros. Ticket [bd484a090c8077]. FossilOrigin-Name: 176248095b8056443ebcbff819e575bd100f5e50
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Simplifications\sto\sthe\slocaltime()\sinterface.\s\sFix\sthe\scase\swhere\nlocaltime_r()\sis\savailable\sso\sthat\sit\sworks.\s\sTicket\s[bd484a090c8077].
|
C Rework\sthe\slocaltime\slogic\syet\sagain\sin\sorder\sto\smake\sall\sbranches\sreachable\nand\sto\sfollow\sGNU\sstandards\sfor\sHAVE_LOCALTIME_R-type\smacros.\nTicket\s[bd484a090c8077].
|
||||||
D 2011-06-21T14:35:30.890
|
D 2011-06-21T15:01:25.129
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e
|
F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -131,7 +131,7 @@ F src/build.c 5a428625d21ad409514afb40ad083bee25dd957a
|
|||||||
F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a
|
F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a
|
||||||
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
|
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
|
||||||
F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4
|
F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4
|
||||||
F src/date.c 2c5b336a05029c1647f7a4fe03d7ee50b9747bba
|
F src/date.c 8eb16dd5c0fea761f65f1ed98b2c2e8fbaea800c
|
||||||
F src/delete.c cecc926c70783452f3e8eb452c728291ce1a0b21
|
F src/delete.c cecc926c70783452f3e8eb452c728291ce1a0b21
|
||||||
F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106
|
F src/expr.c ab46ab0f0c44979a8164ca31728d7d10ae5e8106
|
||||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||||
@@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00
|
|||||||
F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576
|
F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d
|
F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d
|
||||||
P 0e82175fd86f0ca5da90676aaee3118a70264d85
|
P 5b68dae320d0fa3dc433826811e5018a47461de7
|
||||||
R 39249556a57f6de5d465bb75e25a77c9
|
R ed41c3134b790559b6de3aa9dbc8d008
|
||||||
U drh
|
U drh
|
||||||
Z f3f5de06e02a4cdc489a3c883165212f
|
Z 9cf1abaccd2a2f678b16a61368320667
|
||||||
|
@@ -1 +1 @@
|
|||||||
5b68dae320d0fa3dc433826811e5018a47461de7
|
176248095b8056443ebcbff819e575bd100f5e50
|
63
src/date.c
63
src/date.c
@@ -50,22 +50,6 @@
|
|||||||
|
|
||||||
#ifndef SQLITE_OMIT_DATETIME_FUNCS
|
#ifndef SQLITE_OMIT_DATETIME_FUNCS
|
||||||
|
|
||||||
/*
|
|
||||||
** On recent Windows platforms, the localtime_s() function is available
|
|
||||||
** as part of the "Secure CRT". It is essentially equivalent to
|
|
||||||
** localtime_r() available under most POSIX platforms, except that the
|
|
||||||
** order of the parameters is reversed.
|
|
||||||
**
|
|
||||||
** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.
|
|
||||||
**
|
|
||||||
** If the user has not indicated to use localtime_r() or localtime_s()
|
|
||||||
** already, check for an MSVC build environment that provides
|
|
||||||
** localtime_s().
|
|
||||||
*/
|
|
||||||
#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \
|
|
||||||
defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
|
|
||||||
#define HAVE_LOCALTIME_S 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** A structure for holding a single date and time.
|
** A structure for holding a single date and time.
|
||||||
@@ -411,6 +395,23 @@ static void clearYMD_HMS_TZ(DateTime *p){
|
|||||||
p->validTZ = 0;
|
p->validTZ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** On recent Windows platforms, the localtime_s() function is available
|
||||||
|
** as part of the "Secure CRT". It is essentially equivalent to
|
||||||
|
** localtime_r() available under most POSIX platforms, except that the
|
||||||
|
** order of the parameters is reversed.
|
||||||
|
**
|
||||||
|
** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.
|
||||||
|
**
|
||||||
|
** If the user has not indicated to use localtime_r() or localtime_s()
|
||||||
|
** already, check for an MSVC build environment that provides
|
||||||
|
** localtime_s().
|
||||||
|
*/
|
||||||
|
#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \
|
||||||
|
defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
|
||||||
|
#define HAVE_LOCALTIME_S 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_LOCALTIME
|
#ifndef SQLITE_OMIT_LOCALTIME
|
||||||
/*
|
/*
|
||||||
** The following routine implements the rough equivalent of localtime_r()
|
** The following routine implements the rough equivalent of localtime_r()
|
||||||
@@ -423,24 +424,28 @@ static void clearYMD_HMS_TZ(DateTime *p){
|
|||||||
*/
|
*/
|
||||||
int osLocaltime(time_t *t, struct tm *pTm){
|
int osLocaltime(time_t *t, struct tm *pTm){
|
||||||
int rc;
|
int rc;
|
||||||
|
#if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
|
||||||
|
&& (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
|
||||||
|
struct tm *pX;
|
||||||
|
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
|
||||||
|
sqlite3_mutex_enter(mutex);
|
||||||
|
pX = localtime(t);
|
||||||
|
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
||||||
|
if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;
|
||||||
|
#endif
|
||||||
|
if( pX ) *pTm = *pX;
|
||||||
|
sqlite3_mutex_leave(mutex);
|
||||||
|
rc = pX==0;
|
||||||
|
#else
|
||||||
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
||||||
if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
|
if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LOCALTIME_R
|
#if defined(HAVE_LOCALTIME_R) && HAVE_LOCALTIME_R
|
||||||
rc = localtime_r(t, pTm)==0;
|
rc = localtime_r(t, pTm)==0;
|
||||||
#elif defined(HAVE_LOCALTIME_S) && HAVE_LOCALTIME_S
|
|
||||||
rc = localtime_s(pTm, t);
|
|
||||||
#else
|
#else
|
||||||
{
|
rc = localtime_s(pTm, t);
|
||||||
struct tm *pX;
|
#endif /* HAVE_LOCALTIME_R */
|
||||||
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
|
#endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */
|
||||||
sqlite3_mutex_enter(mutex);
|
|
||||||
pX = localtime(t);
|
|
||||||
if( pX ) *pTm = *pX;
|
|
||||||
sqlite3_mutex_leave(mutex);
|
|
||||||
rc = pX==0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
#endif /* SQLITE_OMIT_LOCALTIME */
|
#endif /* SQLITE_OMIT_LOCALTIME */
|
||||||
|
Reference in New Issue
Block a user