diff options
author | monty@hundin.mysql.fi <> | 2001-10-08 04:58:07 +0300 |
---|---|---|
committer | monty@hundin.mysql.fi <> | 2001-10-08 04:58:07 +0300 |
commit | 88aff4bf851e8f0d67cc7cd860d445e0fb234717 (patch) | |
tree | f8a3cf3164d5a5550378074ac8d3bf4afe105683 /mysys/mf_dirname.c | |
parent | e80123501939a6e19dcc33efa837c15f5ca60641 (diff) | |
download | mariadb-git-88aff4bf851e8f0d67cc7cd860d445e0fb234717.tar.gz |
Updated manual about embedded version.
Speed up column-completion in 'mysql'
Don't use ISAM if HAVE_ISAM is not defined
A lot of fixes for the embedded version. All libraries are now included in libmysqld.a
Changed arguments to convert_dirname() to make it more general.
Renamed files in the 'merge' directory to all use a common prefix.
Don't compile both assembler and C functions on x86
Diffstat (limited to 'mysys/mf_dirname.c')
-rw-r--r-- | mysys/mf_dirname.c | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c index 399082a238b..fb5d77d8ab8 100644 --- a/mysys/mf_dirname.c +++ b/mysys/mf_dirname.c @@ -50,57 +50,69 @@ uint dirname_part(my_string to, const char *name) DBUG_PRINT("enter",("'%s'",name)); length=dirname_length(name); - (void) strmake(to,(char*) name,min(length,FN_REFLEN-2)); - convert_dirname(to); /* Convert chars */ + convert_dirname(to, name, name+length); DBUG_RETURN(length); } /* dirname */ - /* convert dirname to use under this system */ - /* If MSDOS converts '/' to '\' */ - /* If VMS converts '<' to '[' and '>' to ']' */ - /* Adds a '/' to end if there isn't one and the last isn't a dev_char */ - /* ARGSUSED */ + /* + Convert directory name to use under this system + If MSDOS converts '/' to '\' + If VMS converts '<' to '[' and '>' to ']' + Adds a FN_LIBCHAR to end if the result string if there isn't one + and the last isn't dev_char. + Copies data from 'from' until ASCII(0) for until from == from_end + If you want to use the whole 'from' string, just send NullS as the + last argument. + If the result string is larger than FN_REFLEN -1, then it's cut. + + Returns pointer to end \0 + */ #ifndef FN_DEVCHAR #define FN_DEVCHAR '\0' /* For easier code */ #endif -char *convert_dirname(my_string to) +char *convert_dirname(char *to, const char *from, const char *from_end) { - reg1 char *pos; -#ifdef FN_UPPER_CASE - caseup_str(to); -#endif -#ifdef FN_LOWER_CASE - casedn_str(to); -#endif -#if FN_LIBCHAR != '/' - { - pos=to-1; /* Change from '/' */ - while ((pos=strchr(pos+1,'/')) != 0) - *pos=FN_LIBCHAR; - } -#endif -#ifdef FN_C_BEFORE_DIR_2 + char *to_org=to; + + /* We use -2 here, becasue we need place for the last FN_LIBCHAR */ + if (!from_end || (from_end - from) > FN_REFLEN-2) + from_end=from+FN_REFLEN -2; + +#if FN_LIBCHAR != '/' || defined(FN_C_BEFORE_DIR_2) { - for (pos=to ; *pos ; pos++) + while (*from && *from != end) { - if (*pos == FN_C_BEFORE_DIR_2) - *pos=FN_C_BEFORE_DIR; - if (*pos == FN_C_AFTER_DIR_2) - *pos=FN_C_AFTER_DIR; + if (*from == '/') + *to++= FN_LIBCHAR; +#ifdef FN_C_BEFORE_DIR_2 + else if (*from == FN_C_BEFORE_DIR_2) + *to++= FN_C_BEFORE_DIR; + else if (*from == FN_C_AFTER_DIR_2) + *to++= FN_C_AFTER_DIR; +#endif + else + *to++= *from++; } } #else - { /* Append FN_LIBCHAR if not there */ - pos=strend(to); - if (pos != to && (pos[-1] != FN_LIBCHAR && pos[-1] != FN_DEVCHAR)) - { - *pos++=FN_LIBCHAR; - *pos=0; - } + /* This is ok even if to == from, becasue we need to cut the string */ + to= strmake(to, from, (uint) (from_end-from)); +#endif + + /* Add FN_LIBCHAR to the end of directory path */ + if (to != to_org && (to[-1] != FN_LIBCHAR && to[-1] != FN_DEVCHAR)) + { + *to++=FN_LIBCHAR; + *to=0; } +#ifdef FN_UPPER_CASE + caseup_str(to_org); +#endif +#ifdef FN_LOWER_CASE + casedn_str(to_org); #endif - return pos; /* Pointer to end of dir */ + return to; /* Pointer to end of dir */ } /* convert_dirname */ |