diff options
author | drh <drh@noemail.net> | 2003-06-16 03:08:18 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2003-06-16 03:08:18 +0000 |
commit | d93d8a812e9631688bda8e57388e0114ee5154a8 (patch) | |
tree | f758d388c7d763b17bbaf46be47c16f73693e4f4 /src/printf.c | |
parent | 3fc673e622148f787a8c2188c2c2d2fbcacd2a05 (diff) | |
download | sqlite-d93d8a812e9631688bda8e57388e0114ee5154a8.tar.gz sqlite-d93d8a812e9631688bda8e57388e0114ee5154a8.zip |
Add the %z format to the sqlite_mprintf() and related functions. (CVS 1028)
FossilOrigin-Name: eca1398eaac67d772aff2676a470d9a6d96a93ca
Diffstat (limited to 'src/printf.c')
-rw-r--r-- | src/printf.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/printf.c b/src/printf.c index 67144b26d..69fbed76d 100644 --- a/src/printf.c +++ b/src/printf.c @@ -66,6 +66,7 @@ enum et_type { /* The type of the format field */ etGENERIC, /* Floating or exponential, depending on exponent. %g */ etSIZE, /* Return number of characters processed so far. %n */ etSTRING, /* Strings. %s */ + etDYNSTRING, /* Dynamically allocated strings. %z */ etPERCENT, /* Percent symbol. %% */ etCHARX, /* Characters. %c */ etERROR, /* Used to indicate no such conversion type */ @@ -97,6 +98,7 @@ typedef struct et_info { /* Information about each format field */ static et_info fmtinfo[] = { { 'd', 10, "0123456789", 1, 0, etRADIX, }, { 's', 0, 0, 0, 0, etSTRING, }, + { 'z', 0, 0, 0, 0, etDYNSTRING, }, { 'q', 0, 0, 0, 0, etSQLESCAPE, }, { 'Q', 0, 0, 0, 0, etSQLESCAPE2, }, { 'c', 0, 0, 0, 0, etCHARX, }, @@ -549,8 +551,13 @@ static int vxprintf( bufpt = buf; break; case etSTRING: + case etDYNSTRING: bufpt = va_arg(ap,char*); - if( bufpt==0 ) bufpt = "(null)"; + if( bufpt==0 ){ + bufpt = ""; + }else if( xtype==etDYNSTRING ){ + zExtra = bufpt; + } length = strlen(bufpt); if( precision>=0 && precision<length ) length = precision; break; @@ -632,7 +639,11 @@ static int vxprintf( } } if( zExtra ){ - sqliteFree(zExtra); + if( xtype==etDYNSTRING ){ + free(zExtra); + }else{ + sqliteFree(zExtra); + } } }/* End for loop over the format string */ return errorflag ? -1 : count; |