diff options
author | cmiller@zippy.cornsilk.net <> | 2007-08-07 06:48:46 -0400 |
---|---|---|
committer | cmiller@zippy.cornsilk.net <> | 2007-08-07 06:48:46 -0400 |
commit | e0139d23d9cef2a8382b4c7ad2949defb86e33e5 (patch) | |
tree | 3a634cc1b995987234cda26477db0be128ea2f1f /mysys/mf_iocache2.c | |
parent | 2073c488af74352c290952834274e5570b47e3d9 (diff) | |
parent | 869da2dd55453f278305ea8f5518712178827b1e (diff) | |
download | mariadb-git-e0139d23d9cef2a8382b4c7ad2949defb86e33e5.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.1-maint
into zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-maint
Diffstat (limited to 'mysys/mf_iocache2.c')
-rw-r--r-- | mysys/mf_iocache2.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 87ea995f518..39110445481 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -304,6 +304,7 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) uint minimum_width; /* as yet unimplemented */ uint minimum_width_sign; uint precision; /* as yet unimplemented for anything but %b */ + my_bool is_zero_padded; /* Store the location of the beginning of a format directive, for the @@ -337,11 +338,27 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) backtrack= fmt; fmt++; + is_zero_padded= FALSE; + minimum_width_sign= 1; minimum_width= 0; precision= 0; - minimum_width_sign= 1; /* Skip if max size is used (to be compatible with printf) */ - while (*fmt == '-') { fmt++; minimum_width_sign= -1; } + +process_flags: + switch (*fmt) + { + case '-': + minimum_width_sign= -1; fmt++; goto process_flags; + case '0': + is_zero_padded= TRUE; fmt++; goto process_flags; + case '#': + /** @todo Implement "#" conversion flag. */ fmt++; goto process_flags; + case ' ': + /** @todo Implement " " conversion flag. */ fmt++; goto process_flags; + case '+': + /** @todo Implement "+" conversion flag. */ fmt++; goto process_flags; + } + if (*fmt == '*') { precision= (int) va_arg(args, int); @@ -376,7 +393,7 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) { reg2 char *par = va_arg(args, char *); size_t length2 = strlen(par); - /* TODO: implement minimum width and precision */ + /* TODO: implement precision */ out_length+= length2; if (my_b_write(info, (uchar*) par, length2)) goto err; @@ -398,7 +415,21 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) if (*fmt == 'd') length2= (size_t) (int10_to_str((long) iarg,buff, -10) - buff); else - length2= (size_t) (int10_to_str((long) (uint) iarg,buff,10)- buff); + + /* minimum width padding */ + if (minimum_width > length2) + { + char *buffz; + + buffz= my_alloca(minimum_width - length2); + if (is_zero_padded) + memset(buffz, '0', minimum_width - length2); + else + memset(buffz, ' ', minimum_width - length2); + my_b_write(info, buffz, minimum_width - length2); + my_afree(buffz); + } + out_length+= length2; if (my_b_write(info, (uchar*) buff, length2)) goto err; |