diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2009-10-15 17:23:43 +0500 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2009-10-15 17:23:43 +0500 |
commit | d8c3f2263f3deaadff957a0047460e8058cffccf (patch) | |
tree | e38788d80d85437efb1819550af226f7b2e2c195 /mysys | |
parent | 3929dddcd76130529cabfbd68cfff024e6b5c80d (diff) | |
download | mariadb-git-d8c3f2263f3deaadff957a0047460e8058cffccf.tar.gz |
WL#751 Error message construction, backport
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/errors.c | 5 | ||||
-rw-r--r-- | mysys/my_error.c | 24 |
2 files changed, 18 insertions, 11 deletions
diff --git a/mysys/errors.c b/mysys/errors.c index 8d3303cac9f..4000c5c4e52 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -106,3 +106,8 @@ void wait_for_free_space(const char *filename, int errors) MY_WAIT_GIVE_USER_A_MESSAGE * MY_WAIT_FOR_USER_TO_FIX_PANIC ); VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC)); } + +const char **get_global_errmsgs() +{ + return globerrs; +} diff --git a/mysys/my_error.c b/mysys/my_error.c index e407e7706fc..ff9156faf82 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -48,11 +48,11 @@ */ static struct my_err_head { - struct my_err_head *meh_next; /* chain link */ - const char **meh_errmsgs; /* error messages array */ - int meh_first; /* error number matching array slot 0 */ - int meh_last; /* error number matching last slot */ -} my_errmsgs_globerrs = {NULL, globerrs, EE_ERROR_FIRST, EE_ERROR_LAST}; + struct my_err_head *meh_next; /* chain link */ + const char** (*get_errmsgs) (); /* returns error message format */ + int meh_first; /* error number matching array slot 0 */ + int meh_last; /* error number matching last slot */ +} my_errmsgs_globerrs = {NULL, get_global_errmsgs, EE_ERROR_FIRST, EE_ERROR_LAST}; static struct my_err_head *my_errmsgs_list= &my_errmsgs_globerrs; @@ -84,12 +84,13 @@ void my_error(int nr, myf MyFlags, ...) /* get the error message string. Default, if NULL or empty string (""). */ if (! (format= (meh_p && (nr >= meh_p->meh_first)) ? - meh_p->meh_errmsgs[nr - meh_p->meh_first] : NULL) || ! *format) + meh_p->get_errmsgs()[nr - meh_p->meh_first] : NULL) || ! *format) (void) my_snprintf (ebuff, sizeof(ebuff), "Unknown error %d", nr); else { va_start(args,MyFlags); - (void) my_vsnprintf (ebuff, sizeof(ebuff), format, args); + (void) my_vsnprintf_ex(&my_charset_utf8_general_ci, ebuff, + sizeof(ebuff), format, args); va_end(args); } (*error_handler_hook)(nr, ebuff, MyFlags); @@ -117,7 +118,8 @@ void my_printf_error(uint error, const char *format, myf MyFlags, ...) error, MyFlags, errno, format)); va_start(args,MyFlags); - (void) my_vsnprintf (ebuff, sizeof(ebuff), format, args); + (void) my_vsnprintf_ex(&my_charset_utf8_general_ci, ebuff, + sizeof(ebuff), format, args); va_end(args); (*error_handler_hook)(error, ebuff, MyFlags); DBUG_VOID_RETURN; @@ -161,7 +163,7 @@ void my_message(uint error, const char *str, register myf MyFlags) != 0 Error */ -int my_error_register(const char **errmsgs, int first, int last) +int my_error_register(const char** (*get_errmsgs) (), int first, int last) { struct my_err_head *meh_p; struct my_err_head **search_meh_pp; @@ -170,7 +172,7 @@ int my_error_register(const char **errmsgs, int first, int last) if (! (meh_p= (struct my_err_head*) my_malloc(sizeof(struct my_err_head), MYF(MY_WME)))) return 1; - meh_p->meh_errmsgs= errmsgs; + meh_p->get_errmsgs= get_errmsgs; meh_p->meh_first= first; meh_p->meh_last= last; @@ -241,7 +243,7 @@ const char **my_error_unregister(int first, int last) *search_meh_pp= meh_p->meh_next; /* Save the return value and free the header. */ - errmsgs= meh_p->meh_errmsgs; + errmsgs= meh_p->get_errmsgs(); my_free((uchar*) meh_p, MYF(0)); return errmsgs; |