diff options
author | monty@narttu.mysql.fi <> | 2000-11-17 02:36:46 +0200 |
---|---|---|
committer | monty@narttu.mysql.fi <> | 2000-11-17 02:36:46 +0200 |
commit | 22415489f2bef07e1617cb93a5c3f3a8c332ce25 (patch) | |
tree | 09e51a2c4d96c3afa0d966f7469e46432fc6dc58 /mysys | |
parent | ca2cca8dce9fa5029f5a96d6b266e0fbdc4bc5f8 (diff) | |
download | mariadb-git-22415489f2bef07e1617cb93a5c3f3a8c332ce25.tar.gz |
Fixes for bugs in the usage of IO_CACHE
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/mf_iocache2.c | 22 | ||||
-rw-r--r-- | mysys/my_vsnprintf.c | 1 | ||||
-rw-r--r-- | mysys/thr_lock.c | 4 |
3 files changed, 17 insertions, 10 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); } diff --git a/mysys/my_vsnprintf.c b/mysys/my_vsnprintf.c index b394adf2a96..ac89e3bcf1a 100644 --- a/mysys/my_vsnprintf.c +++ b/mysys/my_vsnprintf.c @@ -35,6 +35,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) continue; } /* Skipp if max size is used (to be compatible with printf) */ + fmt++; while (isdigit(*fmt) || *fmt == '.' || *fmt == '-') fmt++; if (*fmt == 's') /* String parameter */ diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index df360447e69..b9a9d5274ee 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -422,8 +422,8 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) /* Request for READ lock */ if (lock->write.data) { - /* We can get allow a read lock even if there is already a write lock - one the table in one the following cases: + /* We can allow a read lock even if there is already a write lock + on the table in one the following cases: - This thread alread have a write lock on the table - The write lock is TL_WRITE_ALLOW_READ or TL_WRITE_DELAYED and the read lock is TL_READ_HIGH_PRIORITY or TL_READ |