/ Check-in [97ef4f50]
Login

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

Overview
Comment:Clean up obsolete comments in printf.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 97ef4f5013731fa3a0f72451b7e8c9aec5523104
User & Date: drh 2011-10-12 18:52:59
Context
2011-10-12
19:04
Suppress a compiler warning that occurs with SQLITE_OMIT_VIRTUALTABLE. check-in: 6bedb49d user: drh tags: trunk
18:52
Clean up obsolete comments in printf.c. check-in: 97ef4f50 user: drh tags: trunk
17:00
Clarify a comment and fix a code formatting issue in btree.c. check-in: 4f1a558d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/printf.c.

     3      3   ** the public domain.  The original comments are included here for
     4      4   ** completeness.  They are very out-of-date but might be useful as
     5      5   ** an historical reference.  Most of the "enhancements" have been backed
     6      6   ** out so that the functionality is now the same as standard printf().
     7      7   **
     8      8   **************************************************************************
     9      9   **
    10         -** The following modules is an enhanced replacement for the "printf" subroutines
    11         -** found in the standard C library.  The following enhancements are
    12         -** supported:
    13         -**
    14         -**      +  Additional functions.  The standard set of "printf" functions
    15         -**         includes printf, fprintf, sprintf, vprintf, vfprintf, and
    16         -**         vsprintf.  This module adds the following:
    17         -**
    18         -**           *  snprintf -- Works like sprintf, but has an extra argument
    19         -**                          which is the size of the buffer written to.
    20         -**
    21         -**           *  mprintf --  Similar to sprintf.  Writes output to memory
    22         -**                          obtained from malloc.
    23         -**
    24         -**           *  xprintf --  Calls a function to dispose of output.
    25         -**
    26         -**           *  nprintf --  No output, but returns the number of characters
    27         -**                          that would have been output by printf.
    28         -**
    29         -**           *  A v- version (ex: vsnprintf) of every function is also
    30         -**              supplied.
    31         -**
    32         -**      +  A few extensions to the formatting notation are supported:
    33         -**
    34         -**           *  The "=" flag (similar to "-") causes the output to be
    35         -**              be centered in the appropriately sized field.
    36         -**
    37         -**           *  The %b field outputs an integer in binary notation.
    38         -**
    39         -**           *  The %c field now accepts a precision.  The character output
    40         -**              is repeated by the number of times the precision specifies.
    41         -**
    42         -**           *  The %' field works like %c, but takes as its character the
    43         -**              next character of the format string, instead of the next
    44         -**              argument.  For example,  printf("%.78'-")  prints 78 minus
    45         -**              signs, the same as  printf("%.78c",'-').
    46         -**
    47         -**      +  When compiled using GCC on a SPARC, this version of printf is
    48         -**         faster than the library printf for SUN OS 4.1.
    49         -**
    50         -**      +  All functions are fully reentrant.
    51         -**
           10  +** This file contains code for a set of "printf"-like routines.  These
           11  +** routines format strings much like the printf() from the standard C
           12  +** library, though the implementation here has enhancements to support
           13  +** SQLlite.
    52     14   */
    53     15   #include "sqliteInt.h"
    54     16   
    55     17   /*
    56     18   ** Conversion types fall into various categories as defined by the
    57     19   ** following enumeration.
    58     20   */
................................................................................
   183    145     if( N>0 ){
   184    146       sqlite3StrAccumAppend(pAccum, zSpaces, N);
   185    147     }
   186    148   }
   187    149   
   188    150   /*
   189    151   ** On machines with a small stack size, you can redefine the
   190         -** SQLITE_PRINT_BUF_SIZE to be less than 350.
          152  +** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired.
   191    153   */
   192    154   #ifndef SQLITE_PRINT_BUF_SIZE
   193    155   # define SQLITE_PRINT_BUF_SIZE 70
   194    156   #endif
   195    157   #define etBUFSIZE SQLITE_PRINT_BUF_SIZE  /* Size of the output buffer */
   196    158   
   197    159   /*
   198         -** The root program.  All variations call this core.
   199         -**
   200         -** INPUTS:
   201         -**   func   This is a pointer to a function taking three arguments
   202         -**            1. A pointer to anything.  Same as the "arg" parameter.
   203         -**            2. A pointer to the list of characters to be output
   204         -**               (Note, this list is NOT null terminated.)
   205         -**            3. An integer number of characters to be output.
   206         -**               (Note: This number might be zero.)
   207         -**
   208         -**   arg    This is the pointer to anything which will be passed as the
   209         -**          first argument to "func".  Use it for whatever you like.
   210         -**
   211         -**   fmt    This is the format string, as in the usual print.
   212         -**
   213         -**   ap     This is a pointer to a list of arguments.  Same as in
   214         -**          vfprint.
   215         -**
   216         -** OUTPUTS:
   217         -**          The return value is the total number of characters sent to
   218         -**          the function "func".  Returns -1 on a error.
   219         -**
   220         -** Note that the order in which automatic variables are declared below
   221         -** seems to make a big difference in determining how fast this beast
   222         -** will run.
          160  +** Render a string given by "fmt" into the StrAccum object.
   223    161   */
   224    162   void sqlite3VXPrintf(
   225    163     StrAccum *pAccum,                  /* Accumulate results here */
   226    164     int useExtended,                   /* Allow extended %-conversions */
   227    165     const char *fmt,                   /* Format string */
   228    166     va_list ap                         /* arguments */
   229    167   ){
................................................................................
   238    176     etByte flag_blanksign;     /* True if " " flag is present */
   239    177     etByte flag_alternateform; /* True if "#" flag is present */
   240    178     etByte flag_altform2;      /* True if "!" flag is present */
   241    179     etByte flag_zeropad;       /* True if field width constant starts with zero */
   242    180     etByte flag_long;          /* True if "l" flag is present */
   243    181     etByte flag_longlong;      /* True if the "ll" flag is present */
   244    182     etByte done;               /* Loop termination flag */
          183  +  etByte xtype = 0;          /* Conversion paradigm */
          184  +  char prefix;               /* Prefix character.  "+" or "-" or " " or '\0'. */
   245    185     sqlite_uint64 longvalue;   /* Value for integer types */
   246    186     LONGDOUBLE_TYPE realvalue; /* Value for real types */
   247    187     const et_info *infop;      /* Pointer to the appropriate info structure */
   248         -  char buf[etBUFSIZE];       /* Conversion buffer */
   249    188     char *zOut;                /* Rendering buffer */
   250    189     int nOut;                  /* Size of the rendering buffer */
   251         -  char prefix;               /* Prefix character.  "+" or "-" or " " or '\0'. */
   252         -  etByte xtype = 0;          /* Conversion paradigm */
   253         -  char *zExtra;              /* Extra memory used for etTCLESCAPE conversions */
          190  +  char *zExtra;              /* Malloced memory used by some conversion */
   254    191   #ifndef SQLITE_OMIT_FLOATING_POINT
   255    192     int  exp, e2;              /* exponent of real numbers */
          193  +  int nsd;                   /* Number of significant digits returned */
   256    194     double rounder;            /* Used for rounding floating point values */
   257    195     etByte flag_dp;            /* True if decimal point should be shown */
   258    196     etByte flag_rtz;           /* True if trailing zeros should be removed */
   259         -  int nsd;                   /* Number of significant digits returned */
   260    197   #endif
          198  +  char buf[etBUFSIZE];       /* Conversion buffer */
   261    199   
   262    200     length = 0;
   263    201     bufpt = 0;
   264    202     for(; (c=(*fmt))!=0; ++fmt){
   265    203       if( c!='%' ){
   266    204         int amt;
   267    205         bufpt = (char *)fmt;