diff options
Diffstat (limited to 'mysys/default.c')
-rw-r--r-- | mysys/default.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/mysys/default.c b/mysys/default.c index 81290322223..056f686e16f 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000-2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -166,6 +166,12 @@ int load_defaults(const char *conf_file, const char **groups, if ((error= search_default_file(&args, &alloc, "", forced_default_file, "", &group)) < 0) goto err; + if (error > 0) + { + fprintf(stderr, "Could not open required defaults file: %s\n", + forced_default_file); + goto err; + } } else if (dirname_length(conf_file)) { @@ -214,7 +220,7 @@ int load_defaults(const char *conf_file, const char **groups, res= (char**) (ptr+sizeof(alloc)); /* copy name + found arguments + command line arguments to new array */ - res[0]=argv[0][0]; + res[0]= argv[0][0]; /* Name MUST be set, even by embedded library */ memcpy((gptr) (res+1), args.buffer, args.elements*sizeof(char*)); /* Skipp --defaults-file and --defaults-extra-file */ (*argc)-= args_used; @@ -224,11 +230,12 @@ int load_defaults(const char *conf_file, const char **groups, if (*argc >= 2 && !strcmp(argv[0][1],"--print-defaults")) { found_print_defaults=1; - --*argc; ++*argv; /* skipp argument */ + --*argc; ++*argv; /* skip argument */ } - memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1), - (*argc-1)*sizeof(char*)); + if (*argc) + memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1), + (*argc-1)*sizeof(char*)); res[args.elements+ *argc]=0; /* last null */ (*argc)+=args.elements; @@ -250,6 +257,7 @@ int load_defaults(const char *conf_file, const char **groups, err: fprintf(stderr,"Fatal error in defaults handling. Program aborted\n"); exit(1); + return 0; /* Keep compiler happy */ } @@ -329,7 +337,7 @@ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, { line++; /* Ignore comment and empty lines */ - for (ptr=buff ; isspace(*ptr) ; ptr++ ) ; + for (ptr=buff ; my_isspace(&my_charset_latin1,*ptr) ; ptr++ ) ; if (*ptr == '#' || *ptr == ';' || !*ptr) continue; if (*ptr == '[') /* Group name */ @@ -342,7 +350,7 @@ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, name,line); goto err; } - for ( ; isspace(end[-1]) ; end--) ; /* Remove end space */ + for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;/* Remove end space */ end[0]=0; read_values=find_type(ptr,group,3) > 0; continue; @@ -359,8 +367,7 @@ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, end= remove_end_comment(ptr); if ((value= strchr(ptr, '='))) end= value; /* Option without argument */ - for ( ; isspace(end[-1]) ; end--) ; - + for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ; if (!value) { if (!(tmp=alloc_root(alloc,(uint) (end-ptr)+3))) @@ -373,13 +380,13 @@ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, { /* Remove pre- and end space */ char *value_end; - for (value++ ; isspace(*value); value++) ; + for (value++ ; my_isspace(&my_charset_latin1,*value); value++) ; value_end=strend(value); /* We don't have to test for value_end >= value as we know there is an '=' before */ - for ( ; isspace(value_end[-1]) ; value_end--) ; + for ( ; my_isspace(&my_charset_latin1,value_end[-1]) ; value_end--) ; if (value_end < value) /* Empty string */ value_end=value; @@ -461,7 +468,8 @@ static char *remove_end_comment(char *ptr) else if (quote == *ptr) quote= 0; } - if (!quote && *ptr == '#') /* We are not inside a string */ + /* We are not inside a string */ + if (!quote && *ptr == '#') { *ptr= 0; return ptr; |