Commit 8b87a1aa authored by unknown's avatar unknown

Fixed a bug with having comments after options in config files.

Bug ID: 235

parent 209e44c1
......@@ -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__
......
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