diff options
Diffstat (limited to 'mysys/default.c')
-rw-r--r-- | mysys/default.c | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/mysys/default.c b/mysys/default.c index 0f8712d3298..26121cc0e56 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -1,19 +1,18 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, +/* Copyright (C) 2000 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /**************************************************************************** ** Add all options from files named "group".cnf from the default_directories @@ -48,6 +47,8 @@ char *defaults_extra_file=0; const char *default_directories[]= { #ifdef __WIN__ "C:/", +#elif defined(__NETWARE__) +"sys:/etc/", #else "/etc/", #endif @@ -55,7 +56,7 @@ const char *default_directories[]= { DATADIR, #endif "", /* Place for defaults_extra_dir */ -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(__NETWARE__) "~/", #endif NullS, @@ -84,7 +85,7 @@ void load_defaults(const char *conf_file, const char **groups, char *ptr,**res; DBUG_ENTER("load_defaults"); - init_alloc_root(&alloc,128,0); + init_alloc_root(&alloc,512,0); if (*argc >= 2 && !strcmp(argv[0][1],"--no-defaults")) { /* remove the --no-defaults argument and return only the other arguments */ @@ -96,6 +97,7 @@ void load_defaults(const char *conf_file, const char **groups, res[0]= **argv; /* Copy program name */ for (i=2 ; i < (uint) *argc ; i++) res[i-1]=argv[0][i]; + res[i-1]=0; /* End pointer */ (*argc)--; *argv=res; *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */ @@ -232,23 +234,23 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, return 0; /* Ignore wrong paths */ if (dir) { - strmov(name,dir); - convert_dirname(name); + end=convert_dirname(name, dir, NullS); if (dir[0] == FN_HOMELIB) /* Add . to filenames in home */ - strcat(name,"."); - strxmov(strend(name),config_file,ext,NullS); + *end++='.'; + strxmov(end,config_file,ext,NullS); } else { strmov(name,config_file); } fn_format(name,name,"","",4); -#if !defined(__WIN__) && !defined(OS2) +#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) { MY_STAT stat_info; if (!my_stat(name,&stat_info,MYF(0))) return 0; - if (stat_info.st_mode & S_IWOTH) /* ignore world-writeable files */ + /* ignore world-writeable _regular_ files */ + if (stat_info.st_mode & S_IWOTH && stat_info.st_mode & S_IFREG) { fprintf(stderr, "warning: World-writeable config file %s is ignored\n", name); @@ -384,16 +386,18 @@ void print_defaults(const char *conf_file, const char **groups) #endif for (dirs=default_directories ; *dirs; dirs++) { + const char *pos; + char *end; if (**dirs) - strmov(name,*dirs); + pos= *dirs; else if (defaults_extra_file) - strmov(name,defaults_extra_file); + pos= defaults_extra_file; else continue; - convert_dirname(name); + end=convert_dirname(name, pos, NullS); if (name[0] == FN_HOMELIB) /* Add . to filenames in home */ - strcat(name,"."); - strxmov(strend(name),conf_file,default_ext," ",NullS); + *end++='.'; + strxmov(end,conf_file,default_ext," ",NullS); fputs(name,stdout); } puts(""); @@ -410,4 +414,3 @@ void print_defaults(const char *conf_file, const char **groups) --defaults-file=# Only read default options from the given file #\n\ --defaults-extra-file=# Read this file after the global files are read"); } - |