diff options
author | Jonathan Perkin <jperkin@sun.com> | 2008-07-18 17:43:39 +0200 |
---|---|---|
committer | mysqldev <mysqldev@production.mysql.com> | 2008-07-18 17:43:39 +0200 |
commit | 3bbba8237e01fd0805b2d187af23b0b15d23f12f (patch) | |
tree | 0ab894d50bcc0bf6be49367812cd56f73743a3b4 | |
parent | a07bb6c47ac5c2a4a3dbd738d9efd39837be0092 (diff) | |
parent | aa5731dad97ec8ac95d2e4cdd43211460d546b29 (diff) | |
download | mariadb-git-3bbba8237e01fd0805b2d187af23b0b15d23f12f.tar.gz |
Merge fix for bug#38180 from mysql-5.0.66a-release
-rw-r--r-- | include/my_sys.h | 1 | ||||
-rw-r--r-- | mysys/default.c | 3 | ||||
-rw-r--r-- | mysys/mf_pack.c | 79 |
3 files changed, 57 insertions, 26 deletions
diff --git a/include/my_sys.h b/include/my_sys.h index 099310d9f4b..a2b705a0c59 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -682,6 +682,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); diff --git a/mysys/default.c b/mysys/default.c index b7eb963e395..b709b33e2f8 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -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 */ diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 9e8b6516f63..915c11ec51d 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -266,22 +266,64 @@ void symdirget(char *dir) #endif /* USE_SYMDIR */ -/* - Fixes a directroy name so that can be used by open() +/** + Convert a directory name to a format which can be compared as strings - SYNOPSIS - unpack_dirname() - to result-buffer, FN_REFLEN characters. may be == from - from 'Packed' directory name (may contain ~) + @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 - 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/.. + @details + - Ensures that last char is FN_LIBCHAR, unless it is FN_DEVCHAR + - Uses cleanup_dirname - Changes a UNIX filename to system filename (replaces / with \ on windows) + 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. +*/ - RETURN +uint normalize_dirname(char *to, const char *from) +{ + uint length; + char buff[FN_REFLEN]; + DBUG_ENTER("normalize_dirname"); + + /* + 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 + buff[length - 1] != FN_DEVCHAR && +#endif + buff[length - 1] != FN_LIBCHAR && buff[length - 1] != '/') + { + buff[length]= FN_LIBCHAR; + buff[length + 1]= '\0'; + } + + 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) */ @@ -291,19 +333,8 @@ uint unpack_dirname(my_string to, const char *from) char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion; DBUG_ENTER("unpack_dirname"); - (void) intern_filename(buff,from); /* Change to intern name */ - length= (uint) strlen(buff); /* Fix that '/' is last */ - if (length && -#ifdef FN_DEVCHAR - buff[length-1] != FN_DEVCHAR && -#endif - buff[length-1] != FN_LIBCHAR && buff[length-1] != '/') - { - buff[length]=FN_LIBCHAR; - buff[length+1]= '\0'; - } + length= normalize_dirname(buff, from); - length=cleanup_dirname(buff,buff); if (buff[0] == FN_HOMELIB) { suffix=buff+1; tilde_expansion=expand_tilde(&suffix); |