summaryrefslogtreecommitdiff
path: root/strings/my_vsnprintf.c
diff options
context:
space:
mode:
authormonty@narttu.mysql.fi <>2003-11-03 14:01:59 +0200
committermonty@narttu.mysql.fi <>2003-11-03 14:01:59 +0200
commita444a3449f87ad4c8060fe5769c0bae7a1b64eaf (patch)
treef9406690fb9f579e21f4877826d439fb785d6902 /strings/my_vsnprintf.c
parentd9eca0e1271a5d8c9305ca1b7b9eada084cb61dc (diff)
downloadmariadb-git-a444a3449f87ad4c8060fe5769c0bae7a1b64eaf.tar.gz
Simplified 'wrong xxx name' error messages by introducing 'general' ER_WRONG_NAME error
Cleaned up (and disabled part of) date/time/datetime format patch. One can't anymore change default read/write date/time/formats. This is becasue the non standard datetime formats can't be compared as strings and MySQL does still a lot of datetime comparisons as strings Changed flag argument to str_to_TIME() and get_date() from bool to uint Removed THD from str_to_xxxx functions and Item class. Fixed core dump when doing --print-defaults Move some common string functions to strfunc.cc Dates as strings are now of type my_charset_bin instead of default_charset() Introduce IDENT_QUOTED to not have to create an extra copy of simple identifiers (all chars < 128) Removed xxx_FORMAT_TYPE enums and replaced them with the old TIMESTAMP_xxx enums Renamed some TIMESTAMP_xxx enums to more appropriate names Use defines instead of integers for date/time/datetime string lengths Added to build system and use the new my_strtoll10() function.
Diffstat (limited to 'strings/my_vsnprintf.c')
-rw-r--r--strings/my_vsnprintf.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c
index deb9448857e..4fd288d257e 100644
--- a/strings/my_vsnprintf.c
+++ b/strings/my_vsnprintf.c
@@ -95,26 +95,32 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */
{
register int iarg;
- char *to_start= to;
- if ((uint) (end-to) < max(16,length))
- break;
+ uint res_length, to_length;
+ char *store_start= to, *store_end;
+ char buff[16];
+
+ if ((to_length= (uint) (end-to)) < 16 || length)
+ store_start= buff;
iarg = va_arg(ap, int);
if (*fmt == 'd')
- to=int10_to_str((long) iarg,to, -10);
+ store_end= int10_to_str((long) iarg, store_start, -10);
else
- to=int10_to_str((long) (uint) iarg,to,10);
+ store_end= int10_to_str((long) (uint) iarg, store_start, 10);
+ if ((res_length= (uint) (store_end - store_start)) > to_length)
+ break; /* num doesn't fit in output */
/* If %#d syntax was used, we have to pre-zero/pre-space the string */
- if (length)
+ if (store_start == buff)
{
- uint res_length= (uint) (to - to_start);
+ length= min(length, to_length);
if (res_length < length)
{
uint diff= (length- res_length);
- bmove_upp(to+diff, to, res_length);
- bfill(to-res_length, diff, pre_zero ? '0' : ' ');
+ bfill(to, diff, pre_zero ? '0' : ' ');
to+= diff;
}
+ bmove(to, store_start, res_length);
}
+ to+= res_length;
continue;
}
/* We come here on '%%', unknown code or too long parameter */