Commit 72209ac0 authored by Timothy Smith's avatar Timothy Smith
Browse files

Bug #38180 options are read from ~/my.cnf instead of ~/.my.cnf

Pull out some of unpack_dirname() into normalize_dirname(); this
new function does not expand "~" to the home directory.  Use this
function in unpack_dirname(), and use it during init_default_directories()
to remove duplicate entries without losing track of which directory
is a user's home dir.
parent 28e02b17
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -681,6 +681,7 @@ extern my_string fn_format(my_string to,const char *name,const char *dir,
			   const char *form, uint flag);
extern size_s strlength(const char *str);
extern void pack_dirname(my_string to,const char *from);
extern uint normalize_dirname(char * to, const char *from);
extern uint unpack_dirname(my_string to,const char *from);
extern uint cleanup_dirname(my_string to,const char *from);
extern uint system_filename(my_string to,const char *from);
+1 −2
Original line number Diff line number Diff line
@@ -965,8 +965,7 @@ static int add_directory(MEM_ROOT *alloc, const char *dir, const char **dirs)
  char *p;
  my_bool err __attribute__((unused));

  /* Normalize directory name */
  len= unpack_dirname(buf, dir);
  len= normalize_dirname(buf, dir);
  if (!(p= strmake_root(alloc, buf, len)))
    return 1;  /* Failure */
  /* Should never fail if DEFAULT_DIRS_SIZE is correct size */
+55 −24
Original line number Diff line number Diff line
@@ -266,32 +266,34 @@ void symdirget(char *dir)
#endif /* USE_SYMDIR */


/*
  Fixes a directroy name so that can be used by open()

  SYNOPSIS
    unpack_dirname()
    to			result-buffer, FN_REFLEN characters. may be == from
    from		'Packed' directory name (may contain ~)
/**
  Convert a directory name to a format which can be compared as strings

 IMPLEMENTATION
  Make that last char of to is '/' if from not empty and
  from doesn't end in FN_DEVCHAR
  Uses cleanup_dirname and changes ~/.. to home_dir/..
  @param to     result buffer, FN_REFLEN chars in length; may be == from
  @param from   'packed' directory name, in whatever format
  @returns      size of the normalized name

  Changes a UNIX filename to system filename (replaces / with \ on windows)
  @details
  - Ensures that last char is FN_LIBCHAR, unless it is FN_DEVCHAR
  - Uses cleanup_dirname

  RETURN
   Length of new directory name (= length of to)
  It does *not* expand ~/ (although, see cleanup_dirname).  Nor does it do
  any case folding.  All case-insensitive normalization should be done by
  the caller.
*/

uint unpack_dirname(my_string to, const char *from)
uint normalize_dirname(char *to, const char *from)
{
  uint length,h_length;
  char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion;
  DBUG_ENTER("unpack_dirname");
  uint length;
  char buff[FN_REFLEN];
  DBUG_ENTER("normalize_dirname");

  (void) intern_filename(buff,from);		/* Change to intern name */
  /*
    Despite the name, this actually converts the name to the system's
    format (TODO: rip out the non-working VMS stuff and name this
    properly).
  */
  (void) intern_filename(buff, from);
  length= (uint) strlen(buff);			/* Fix that '/' is last */
  if (length &&
#ifdef FN_DEVCHAR
@@ -303,7 +305,36 @@ uint unpack_dirname(my_string to, const char *from)
    buff[length + 1]= '\0';
  }

  length=cleanup_dirname(buff,buff);
  length=cleanup_dirname(to, buff);

  DBUG_RETURN(length);
}


/**
  Fixes a directory name so that can be used by open()

  @param to     Result buffer, FN_REFLEN characters. May be == from
  @param from   'Packed' directory name (may contain ~)

  @details
  - Uses normalize_dirname()
  - Expands ~/... to home_dir/...
  - Resolves MySQL's fake "foo.sym" symbolic directory names (if USE_SYMDIR)
  - Changes a UNIX filename to system filename (replaces / with \ on windows)

  @returns
   Length of new directory name (= length of to)
*/

uint unpack_dirname(my_string to, const char *from)
{
  uint length,h_length;
  char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion;
  DBUG_ENTER("unpack_dirname");

  length= normalize_dirname(buff, from);

  if (buff[0] == FN_HOMELIB)
  {
    suffix=buff+1; tilde_expansion=expand_tilde(&suffix);