summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <jani@hynda.(none)>2003-05-14 16:47:55 +0300
committerunknown <jani@hynda.(none)>2003-05-14 16:47:55 +0300
commit8b87a1aa0e6328a67c2c72f11612134ed5eb7597 (patch)
tree7888db0099b54c28c876ace54f07402fbcfaba66 /mysys
parent209e44c1a2921423acc51eae888aa16293153619 (diff)
downloadmariadb-git-8b87a1aa0e6328a67c2c72f11612134ed5eb7597.tar.gz
Fixed a bug with having comments after options in config files.
Bug ID: 235
Diffstat (limited to 'mysys')
-rw-r--r--mysys/default.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/mysys/default.c b/mysys/default.c
index c47d2719ab5..3ff240da3a1 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -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__