mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Make sure of the strchrnul() library function on platforms where it is
available. FossilOrigin-Name: ef1aa10b7f54912cba71cd0a98c5055d501de54f
This commit is contained in:
23
src/printf.c
23
src/printf.c
@@ -14,6 +14,21 @@
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
/*
|
||||
** If the strchrnul() library function is available, then set
|
||||
** HAVE_STRCHRNUL. If that routine is not available, this module
|
||||
** will supply its own. The built-in version is slower than
|
||||
** the glibc version so the glibc version is definitely preferred.
|
||||
*/
|
||||
#if !defined(HAVE_STRCHRNUL)
|
||||
# if defined(__linux__) && defined(_GNU_SOURCE)
|
||||
# define HAVE_STRCHRNUL 1
|
||||
# else
|
||||
# define HAVE_STRCHRNUL 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** Conversion types fall into various categories as defined by the
|
||||
** following enumeration.
|
||||
@@ -224,9 +239,13 @@ void sqlite3VXPrintf(
|
||||
for(; (c=(*fmt))!=0; ++fmt){
|
||||
if( c!='%' ){
|
||||
bufpt = (char *)fmt;
|
||||
while( (c=(*++fmt))!='%' && c!=0 ){};
|
||||
#if HAVE_STRCHRNUL
|
||||
fmt = strchrnul(fmt, '%');
|
||||
#else
|
||||
do{ fmt++; }while( *fmt && *fmt != '%' );
|
||||
#endif
|
||||
sqlite3StrAccumAppend(pAccum, bufpt, (int)(fmt - bufpt));
|
||||
if( c==0 ) break;
|
||||
if( *fmt==0 ) break;
|
||||
}
|
||||
if( (c=(*++fmt))==0 ){
|
||||
sqlite3StrAccumAppend(pAccum, "%", 1);
|
||||
|
||||
Reference in New Issue
Block a user