summaryrefslogtreecommitdiff
path: root/mysys/mf_iocache2.c
diff options
context:
space:
mode:
authormonty@narttu.mysql.fi <>2000-11-17 02:36:46 +0200
committermonty@narttu.mysql.fi <>2000-11-17 02:36:46 +0200
commit22415489f2bef07e1617cb93a5c3f3a8c332ce25 (patch)
tree09e51a2c4d96c3afa0d966f7469e46432fc6dc58 /mysys/mf_iocache2.c
parentca2cca8dce9fa5029f5a96d6b266e0fbdc4bc5f8 (diff)
downloadmariadb-git-22415489f2bef07e1617cb93a5c3f3a8c332ce25.tar.gz
Fixes for bugs in the usage of IO_CACHE
Diffstat (limited to 'mysys/mf_iocache2.c')
-rw-r--r--mysys/mf_iocache2.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index 80cea47a80f..b77bddb942a 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -128,30 +128,38 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
uint my_b_printf(IO_CACHE *info, const char* fmt, ...)
{
+ int result;
va_list args;
+ va_start(args,fmt);
+ result=my_b_vprintf(info, fmt, args);
+ va_end(args);
+ return result;
+}
+
+
+uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
+{
reg1 char *to= info->rc_pos;
char *end=info->rc_end;
uint out_length=0;
- va_start(args,fmt);
-
for (; *fmt ; fmt++)
{
- if (fmt[0] != '%')
+ if (*fmt++ != '%')
{
/* Copy everything until '%' or end of string */
- const char *start=fmt;
+ const char *start=fmt-1;
uint length;
- for (fmt++ ; *fmt && *fmt != '%' ; fmt++ ) ;
+ for (; *fmt && *fmt != '%' ; fmt++ ) ;
length= (uint) (fmt - start);
out_length+=length;
if (my_b_write(info, start, length))
goto err;
if (!*fmt) /* End of format */
{
- va_end(args);
return out_length;
}
+ fmt++;
/* Found one '%' */
}
/* Skipp if max size is used (to be compatible with printf) */
@@ -203,10 +211,8 @@ uint my_b_printf(IO_CACHE *info, const char* fmt, ...)
out_length++;
}
}
- va_end(args);
return out_length;
err:
return (uint) -1;
- va_end(args);
}