diff options
author | drh <drh@noemail.net> | 2014-09-18 01:50:09 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-09-18 01:50:09 +0000 |
commit | 760b15984bc16e1e90eb89bc79daa25ba7dd9f40 (patch) | |
tree | fad706925b393d26f266b5ed3143312fbb2fb688 /src | |
parent | 9031494af2a0ce8f9ef9b3771f0d88e30f73d20d (diff) | |
download | sqlite-760b15984bc16e1e90eb89bc79daa25ba7dd9f40.tar.gz sqlite-760b15984bc16e1e90eb89bc79daa25ba7dd9f40.zip |
Make sure of the strchrnul() library function on platforms where it is
available.
FossilOrigin-Name: ef1aa10b7f54912cba71cd0a98c5055d501de54f
Diffstat (limited to 'src')
-rw-r--r-- | src/printf.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/printf.c b/src/printf.c index 8e71ad8bc..03e39085b 100644 --- a/src/printf.c +++ b/src/printf.c @@ -15,6 +15,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); |