diff options
author | unknown <serg@serg.mylan> | 2004-08-19 03:02:09 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-08-19 03:02:09 +0200 |
commit | ae2bf6275e971f45cdfda8dada9a9bfd6f75e746 (patch) | |
tree | bb710739af8b8fd4ec8ff388deaf56c37a27d24a /strings/my_vsnprintf.c | |
parent | 945625ebaa21468fdf0b2a3c1786fca50bdd5aa2 (diff) | |
download | mariadb-git-ae2bf6275e971f45cdfda8dada9a9bfd6f75e746.tar.gz |
after merge fixes
strings/my_vsnprintf.c:
%.#s support in my_vsnprintf
BitKeeper/etc/ignore:
Added EXCEPTIONS-CLIENT to the ignore list
Diffstat (limited to 'strings/my_vsnprintf.c')
-rw-r--r-- | strings/my_vsnprintf.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 784c4762724..71b5f345fda 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -27,7 +27,7 @@ %#[l]d %#[l]u %#[l]x - %#.#s Note #.# is skiped + %#.#s Note first # is ignored RETURN length of result string @@ -47,7 +47,7 @@ int my_snprintf(char* to, size_t n, const char* fmt, ...) int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) { char *start=to, *end=to+n-1; - uint length, num_state, pre_zero, have_long; + uint length, width, pre_zero, have_long; for (; *fmt ; fmt++) { @@ -62,23 +62,18 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) /* Read max fill size (only used with %d and %u) */ if (*fmt == '-') fmt++; - length= num_state= pre_zero= have_long= 0; - for (;; fmt++) + length= width= pre_zero= have_long= 0; + for (;my_isdigit(&my_charset_latin1,*fmt); fmt++) { - if (my_isdigit(&my_charset_latin1,*fmt)) - { - if (!num_state) - { - length=length*10+ (uint) (*fmt-'0'); - if (!length) - pre_zero= 1; /* first digit was 0 */ - } - continue; - } - if (*fmt != '.' || num_state) - break; - num_state= 1; + length=length*10+ (uint) (*fmt-'0'); + if (!length) + pre_zero= 1; /* first digit was 0 */ } + if (*fmt == '.') + for (fmt++;my_isdigit(&my_charset_latin1,*fmt); fmt++) + width=width*10+ (uint) (*fmt-'0'); + else + width= ~0; if (*fmt == 'l') { fmt++; @@ -90,6 +85,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) uint plen,left_len = (uint)(end-to)+1; if (!par) par = (char*)"(null)"; plen = (uint) strlen(par); + set_if_smaller(plen,width); if (left_len <= plen) plen = left_len - 1; to=strnmov(to,par,plen); |