Commit fe47e535 authored by unknown's avatar unknown

New function to search for charset using charset name rather than collation name

parent f94cc9b6
......@@ -206,6 +206,7 @@ extern const char *get_charset_name(uint cs_number);
extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
extern my_bool set_default_charset(uint cs, myf flags);
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, myf flags);
extern my_bool set_default_charset_by_name(const char *cs_name, myf flags);
extern void free_charsets(void);
extern char *list_charsets(myf want_flags); /* my_free() this string... */
......
......@@ -615,14 +615,6 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
}
static CHARSET_INFO *get_internal_charset_by_name(const char *name, myf flags)
{
uint cs_number=get_charset_number(name);
return cs_number ? get_internal_charset(cs_number,flags) : NULL;
}
CHARSET_INFO *get_charset(uint cs_number, myf flags)
{
CHARSET_INFO *cs;
......@@ -664,9 +656,38 @@ my_bool set_default_charset(uint cs, myf flags)
CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags)
{
uint cs_number;
CHARSET_INFO *cs;
(void) init_available_charsets(MYF(0)); /* If it isn't initialized */
cs=get_internal_charset_by_name(cs_name, flags);
cs_number=get_charset_number(cs_name);
cs= cs_number ? get_internal_charset(cs_number,flags) : NULL;
if (!cs && (flags & MY_WME))
{
char index_file[FN_REFLEN];
strmov(get_charsets_dir(index_file),MY_CHARSET_INDEX);
my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_name, index_file);
}
return cs;
}
CHARSET_INFO *get_charset_by_csname(const char *cs_name, myf flags)
{
CHARSET_INFO *cs=NULL;
CHARSET_INFO **css;
(void) init_available_charsets(MYF(0)); /* If it isn't initialized */
for (css= all_charsets; css < all_charsets+255; ++css)
{
if ( css[0] && css[0]->csname && !strcmp(css[0]->csname, cs_name))
{
cs= css[0]->number ? get_internal_charset(css[0]->number,flags) : NULL;
break;
}
}
if (!cs && (flags & MY_WME))
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment