aboutsummaryrefslogtreecommitdiff
path: root/src/printf.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2008-07-08 19:34:06 +0000
committerdrh <drh@noemail.net>2008-07-08 19:34:06 +0000
commitf089aa459e97f6f8ed27efdc958e8ee642b0b4bb (patch)
tree345a713531ba65de2f6888ed1b76fafd5fb1dda8 /src/printf.c
parent0880a7463364f3fd0428c8457c89c5fefae977ea (diff)
downloadsqlite-f089aa459e97f6f8ed27efdc958e8ee642b0b4bb.tar.gz
sqlite-f089aa459e97f6f8ed27efdc958e8ee642b0b4bb.zip
Completely rework the sqlite3SetString() primitive so that it honors the
SQLITE_LIMIT_LENGTH and avoids the use of strlen(). (CVS 5374) FossilOrigin-Name: 8ed04b1e26a55306e4baf3e93fb084514134d603
Diffstat (limited to 'src/printf.c')
-rw-r--r--src/printf.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/printf.c b/src/printf.c
index dc8d71105..5a75fca22 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -5,7 +5,7 @@
** an historical reference. Most of the "enhancements" have been backed
** out so that the functionality is now the same as standard printf().
**
-** $Id: printf.c,v 1.87 2008/06/16 20:51:16 drh Exp $
+** $Id: printf.c,v 1.88 2008/07/08 19:34:07 drh Exp $
**
**************************************************************************
**
@@ -221,7 +221,7 @@ static void appendSpace(StrAccum *pAccum, int N){
** seems to make a big difference in determining how fast this beast
** will run.
*/
-static void vxprintf(
+void sqlite3VXPrintf(
StrAccum *pAccum, /* Accumulate results here */
int useExtended, /* Allow extended %-conversions */
const char *fmt, /* Format string */
@@ -794,14 +794,14 @@ char *sqlite3StrAccumFinish(StrAccum *p){
void sqlite3StrAccumReset(StrAccum *p){
if( p->zText!=p->zBase ){
sqlite3_free(p->zText);
- p->zText = 0;
}
+ p->zText = 0;
}
/*
** Initialize a string accumulator
*/
-static void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){
+void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){
p->zText = p->zBase = zBase;
p->nChar = 0;
p->nAlloc = n;
@@ -821,7 +821,7 @@ char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
StrAccum acc;
sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),
db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH);
- vxprintf(&acc, 1, zFormat, ap);
+ sqlite3VXPrintf(&acc, 1, zFormat, ap);
z = sqlite3StrAccumFinish(&acc);
if( acc.mallocFailed && db ){
db->mallocFailed = 1;
@@ -852,7 +852,7 @@ char *sqlite3_vmprintf(const char *zFormat, va_list ap){
StrAccum acc;
sqlite3_initialize();
sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
- vxprintf(&acc, 0, zFormat, ap);
+ sqlite3VXPrintf(&acc, 0, zFormat, ap);
z = sqlite3StrAccumFinish(&acc);
return z;
}
@@ -888,7 +888,7 @@ char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
sqlite3StrAccumInit(&acc, zBuf, n, 0);
acc.useMalloc = 0;
va_start(ap,zFormat);
- vxprintf(&acc, 0, zFormat, ap);
+ sqlite3VXPrintf(&acc, 0, zFormat, ap);
va_end(ap);
z = sqlite3StrAccumFinish(&acc);
return z;
@@ -907,7 +907,7 @@ void sqlite3DebugPrintf(const char *zFormat, ...){
sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0);
acc.useMalloc = 0;
va_start(ap,zFormat);
- vxprintf(&acc, 0, zFormat, ap);
+ sqlite3VXPrintf(&acc, 0, zFormat, ap);
va_end(ap);
sqlite3StrAccumFinish(&acc);
fprintf(stdout,"%s", zBuf);