summaryrefslogtreecommitdiff
path: root/mysys/my_error.c
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2004-06-01 17:29:13 +0400
committerunknown <sergefp@mysql.com>2004-06-01 17:29:13 +0400
commit4d3dce7fc168fc36932fbca5ad206a12f0a93c9f (patch)
tree8096a9267dc5bff6adfac7f21fcd12e413e7519d /mysys/my_error.c
parentbab2231f7112e9808a1429c1409cc610131323b5 (diff)
parent9626b4d073ed62746e23e2b04afbeb184bc57f40 (diff)
downloadmariadb-git-4d3dce7fc168fc36932fbca5ad206a12f0a93c9f.tar.gz
Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/dbdata/psergey/mysql-4.1-ps-merge mysys/my_error.c: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/mysqld.cc: Auto merged sql/share/czech/errmsg.txt: Auto merged sql/sql_class.h: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/share/dutch/errmsg.txt: Auto merged sql/share/english/errmsg.txt: Auto merged sql/share/estonian/errmsg.txt: Auto merged sql/share/french/errmsg.txt: Auto merged sql/share/german/errmsg.txt: Auto merged sql/share/greek/errmsg.txt: Auto merged sql/share/hungarian/errmsg.txt: Auto merged sql/share/italian/errmsg.txt: Auto merged sql/share/japanese/errmsg.txt: Auto merged sql/share/korean/errmsg.txt: Auto merged sql/share/norwegian-ny/errmsg.txt: Auto merged sql/share/norwegian/errmsg.txt: Auto merged sql/share/polish/errmsg.txt: Auto merged sql/share/portuguese/errmsg.txt: Auto merged sql/share/romanian/errmsg.txt: Auto merged sql/share/russian/errmsg.txt: Auto merged sql/share/slovak/errmsg.txt: Auto merged sql/share/spanish/errmsg.txt: Auto merged sql/share/swedish/errmsg.txt: Auto merged sql/share/ukrainian/errmsg.txt: Auto merged
Diffstat (limited to 'mysys/my_error.c')
-rw-r--r--mysys/my_error.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/mysys/my_error.c b/mysys/my_error.c
index 33d79bbc5e6..b16c39085fd 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -33,6 +33,12 @@ char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
nr Errno
MyFlags Flags
... variable list
+ NOTE
+ The following subset of printf format is supported:
+ "%[0-9.-]*l?[sdu]", where all length flags are parsed but ignored.
+
+ Additionally "%.*s" is supported and "%.*[ud]" is correctly parsed but
+ length value is ignored.
*/
int my_error(int nr,myf MyFlags, ...)
@@ -43,7 +49,10 @@ int my_error(int nr,myf MyFlags, ...)
reg2 char *endpos;
char * par;
char ebuff[ERRMSGSIZE+20];
+ int prec_chars;
+ my_bool prec_supplied;
DBUG_ENTER("my_error");
+ LINT_INIT(prec_chars); /* protected by prec_supplied */
va_start(ap,MyFlags);
DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d", nr, MyFlags, errno));
@@ -59,7 +68,6 @@ int my_error(int nr,myf MyFlags, ...)
if (tpos[0] != '%')
{
*endpos++= *tpos++; /* Copy ordinary char */
- olen++;
continue;
}
if (*++tpos == '%') /* test if %% */
@@ -68,21 +76,48 @@ int my_error(int nr,myf MyFlags, ...)
}
else
{
- /* Skipp if max size is used (to be compatible with printf) */
- while (my_isdigit(&my_charset_latin1, *tpos) || *tpos == '.' || *tpos == '-')
- tpos++;
- if (*tpos == 'l') /* Skipp 'l' argument */
- tpos++;
+ /*
+ Skip size/precision flags to be compatible with printf.
+ The only size/precision flag supported is "%.*s".
+ "%.*u" and "%.*d" cause
+ */
+ prec_supplied= 0;
+ if (*tpos== '.')
+ {
+ tpos++;
+ olen--;
+ if (*tpos == '*')
+ {
+ tpos++;
+ olen--;
+ prec_chars= va_arg(ap, int); /* get length parameter */
+ prec_supplied= 1;
+ }
+ }
+
+ if (!prec_supplied)
+ {
+ while (my_isdigit(&my_charset_latin1, *tpos) || *tpos == '.' ||
+ *tpos == '-')
+ tpos++;
+
+ if (*tpos == 'l') /* Skipp 'l' argument */
+ tpos++;
+ }
+
if (*tpos == 's') /* String parameter */
{
par = va_arg(ap, char *);
plen = (uint) strlen(par);
+ if (prec_supplied && prec_chars > 0)
+ plen= min((uint)prec_chars, plen);
if (olen + plen < ERRMSGSIZE+2) /* Replace if possible */
{
- endpos=strmov(endpos,par);
- tpos++;
- olen+=plen-2;
- continue;
+ memcpy(endpos,par, plen);
+ endpos += plen;
+ tpos++;
+ olen+=plen-2;
+ continue;
}
}
else if (*tpos == 'd' || *tpos == 'u') /* Integer parameter */