/ Check-in [ef1aa10b]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make sure of the strchrnul() library function on platforms where it is available.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ef1aa10b7f54912cba71cd0a98c5055d501de54f
User & Date: drh 2014-09-18 01:50:09
Context
2014-09-18
02:20
Fix harmless warnings on 32-bit MSVC builds. check-in: 5192f964 user: drh tags: trunk
01:50
Make sure of the strchrnul() library function on platforms where it is available. check-in: ef1aa10b user: drh tags: trunk
01:29
Merge micro-optimizations into trunk after fixing the build on MSVC. Performance now shows 7.58% faster than the 3.8.6 release on x64 with gcc 4.8.1 and -Os. check-in: 1de558bc user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/printf.c.

     9      9   **
    10     10   ** This file contains code for a set of "printf"-like routines.  These
    11     11   ** routines format strings much like the printf() from the standard C
    12     12   ** library, though the implementation here has enhancements to support
    13     13   ** SQLlite.
    14     14   */
    15     15   #include "sqliteInt.h"
           16  +
           17  +/*
           18  +** If the strchrnul() library function is available, then set
           19  +** HAVE_STRCHRNUL.  If that routine is not available, this module
           20  +** will supply its own.  The built-in version is slower than
           21  +** the glibc version so the glibc version is definitely preferred.
           22  +*/
           23  +#if !defined(HAVE_STRCHRNUL)
           24  +# if defined(__linux__) && defined(_GNU_SOURCE)
           25  +#  define HAVE_STRCHRNUL 1
           26  +# else
           27  +#  define HAVE_STRCHRNUL 0
           28  +# endif
           29  +#endif
           30  +
    16     31   
    17     32   /*
    18     33   ** Conversion types fall into various categories as defined by the
    19     34   ** following enumeration.
    20     35   */
    21     36   #define etRADIX       1 /* Integer types.  %d, %x, %o, and so forth */
    22     37   #define etFLOAT       2 /* Floating point.  %f */
................................................................................
   220    235       useIntern = bFlags & SQLITE_PRINTF_INTERNAL;
   221    236     }else{
   222    237       bArgList = useIntern = 0;
   223    238     }
   224    239     for(; (c=(*fmt))!=0; ++fmt){
   225    240       if( c!='%' ){
   226    241         bufpt = (char *)fmt;
   227         -      while( (c=(*++fmt))!='%' && c!=0 ){};
          242  +#if HAVE_STRCHRNUL
          243  +      fmt = strchrnul(fmt, '%');
          244  +#else
          245  +      do{ fmt++; }while( *fmt && *fmt != '%' );
          246  +#endif
   228    247         sqlite3StrAccumAppend(pAccum, bufpt, (int)(fmt - bufpt));
   229         -      if( c==0 ) break;
          248  +      if( *fmt==0 ) break;
   230    249       }
   231    250       if( (c=(*++fmt))==0 ){
   232    251         sqlite3StrAccumAppend(pAccum, "%", 1);
   233    252         break;
   234    253       }
   235    254       /* Find out what flags are present */
   236    255       flag_leftjustify = flag_plussign = flag_blanksign =