Index: src/printf.c ================================================================== --- src/printf.c +++ src/printf.c @@ -11,10 +11,25 @@ ** routines format strings much like the printf() from the standard C ** library, though the implementation here has enhancements to support ** SQLlite. */ #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. */ @@ -222,13 +237,17 @@ bArgList = useIntern = 0; } 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); break; }