mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Fixed a bug with having comments after options in config files.
Bug ID: 235
This commit is contained in:
parent
209e44c1a2
commit
8b87a1aa0e
1 changed files with 28 additions and 2 deletions
|
@ -72,6 +72,7 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args,MEM_ROOT *alloc,
|
|||
const char *dir, const char *config_file,
|
||||
const char *ext, TYPELIB *group);
|
||||
|
||||
static char *remove_end_comment(char *ptr);
|
||||
|
||||
void load_defaults(const char *conf_file, const char **groups,
|
||||
int *argc, char ***argv)
|
||||
|
@ -297,9 +298,11 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
|
|||
}
|
||||
if (!read_values)
|
||||
continue;
|
||||
if (!(end=value=strchr(ptr,'=')))
|
||||
end=strend(ptr); /* Option without argument */
|
||||
end= remove_end_comment(ptr);
|
||||
if ((value= strchr(ptr, '=')))
|
||||
end= value; /* Option without argument */
|
||||
for ( ; isspace(end[-1]) ; end--) ;
|
||||
|
||||
if (!value)
|
||||
{
|
||||
if (!(tmp=alloc_root(alloc,(uint) (end-ptr)+3)))
|
||||
|
@ -368,6 +371,29 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
|
|||
}
|
||||
|
||||
|
||||
static char *remove_end_comment(char *ptr)
|
||||
{
|
||||
char quote= 0;
|
||||
|
||||
for (; *ptr; ptr++)
|
||||
{
|
||||
if (*ptr == '\'' || *ptr == '\"')
|
||||
{
|
||||
if (!quote)
|
||||
quote= *ptr;
|
||||
else if (quote == *ptr)
|
||||
quote= 0;
|
||||
}
|
||||
if (!quote && *ptr == '#') /* We are not inside a comment */
|
||||
{
|
||||
*ptr= 0;
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
void print_defaults(const char *conf_file, const char **groups)
|
||||
{
|
||||
#ifdef __WIN__
|
||||
|
|
Loading…
Reference in a new issue