diff options
Diffstat (limited to 'mysys/mf_dirname.c')
-rw-r--r-- | mysys/mf_dirname.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c index d1672e55b65..1b428ded751 100644 --- a/mysys/mf_dirname.c +++ b/mysys/mf_dirname.c @@ -18,9 +18,9 @@ /* Functions definied in this file */ -uint dirname_length(const char *name) +size_t dirname_length(const char *name) { - register my_string pos,gpos; + register char *pos, *gpos; #ifdef BASKSLASH_MBTAIL CHARSET_INFO *fs= fs_character_set(); #endif @@ -47,21 +47,31 @@ uint dirname_length(const char *name) ) gpos=pos; } - return ((uint) (uint) (gpos+1-(char*) name)); + return (size_t) (gpos+1-(char*) name); } - /* Gives directory part of filename. Directory ends with '/' */ - /* Returns length of directory part */ +/* + Gives directory part of filename. Directory ends with '/' + + SYNOPSIS + dirname_part() + to Store directory name here + name Original name + to_length Store length of 'to' here + + RETURN + # Length of directory part in 'name' +*/ -uint dirname_part(my_string to, const char *name) +size_t dirname_part(char *to, const char *name, size_t *to_res_length) { - uint length; + size_t length; DBUG_ENTER("dirname_part"); DBUG_PRINT("enter",("'%s'",name)); length=dirname_length(name); - convert_dirname(to, name, name+length); + *to_res_length= (size_t) (convert_dirname(to, name, name+length) - to); DBUG_RETURN(length); } /* dirname */ @@ -74,7 +84,7 @@ uint dirname_part(my_string to, const char *name) to Store result here. Must be at least of size min(FN_REFLEN, strlen(from) + 1) to make room for adding FN_LIBCHAR at the end. - from Original filename + from Original filename. May be == to from_end Pointer at end of filename (normally end \0) IMPLEMENTATION @@ -102,6 +112,7 @@ char *convert_dirname(char *to, const char *from, const char *from_end) #ifdef BACKSLASH_MBTAIL CHARSET_INFO *fs= fs_character_set(); #endif + DBUG_ENTER("convert_dirname"); /* We use -2 here, becasue we need place for the last FN_LIBCHAR */ if (!from_end || (from_end - from) > FN_REFLEN-2) @@ -141,7 +152,7 @@ char *convert_dirname(char *to, const char *from, const char *from_end) } #else /* This is ok even if to == from, becasue we need to cut the string */ - to= strmake(to, from, (uint) (from_end-from)); + to= strmake(to, from, (size_t) (from_end-from)); #endif /* Add FN_LIBCHAR to the end of directory path */ @@ -150,5 +161,5 @@ char *convert_dirname(char *to, const char *from, const char *from_end) *to++=FN_LIBCHAR; *to=0; } - return to; /* Pointer to end of dir */ + DBUG_RETURN(to); /* Pointer to end of dir */ } /* convert_dirname */ |