| 102 | #endif |
| 103 | |
| 104 | char *convert_dirname(char *to, const char *from, const char *from_end) |
| 105 | { |
| 106 | char *to_org=to; |
| 107 | #ifdef BACKSLASH_MBTAIL |
| 108 | CHARSET_INFO *fs= fs_character_set(); |
| 109 | #endif |
| 110 | DBUG_ENTER("convert_dirname"); |
| 111 | |
| 112 | /* We use -2 here, becasue we need place for the last FN_LIBCHAR */ |
| 113 | if (!from_end || (from_end - from) > FN_REFLEN-2) |
| 114 | from_end=from+FN_REFLEN -2; |
| 115 | |
| 116 | #if FN_LIBCHAR != '/' |
| 117 | { |
| 118 | for (; from != from_end && *from ; from++) |
| 119 | { |
| 120 | if (*from == '/') |
| 121 | *to++= FN_LIBCHAR; |
| 122 | else |
| 123 | { |
| 124 | #ifdef BACKSLASH_MBTAIL |
| 125 | uint l; |
| 126 | if (use_mb(fs) && (l= my_ismbchar(fs, from, from + 3))) |
| 127 | { |
| 128 | memmove(to, from, l); |
| 129 | to+= l; |
| 130 | from+= l - 1; |
| 131 | to_org= to; /* Don't look inside mbchar */ |
| 132 | } |
| 133 | else |
| 134 | #endif |
| 135 | { |
| 136 | *to++= *from; |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | *to=0; |
| 141 | } |
| 142 | #else |
| 143 | /* This is ok even if to == from, becasue we need to cut the string */ |
| 144 | to= strmake(to, from, (size_t) (from_end-from)); |
| 145 | #endif |
| 146 | |
| 147 | /* Add FN_LIBCHAR to the end of directory path */ |
| 148 | if (to != to_org && (to[-1] != FN_LIBCHAR && to[-1] != FN_DEVCHAR)) |
| 149 | { |
| 150 | *to++=FN_LIBCHAR; |
| 151 | *to=0; |
| 152 | } |
| 153 | DBUG_RETURN(to); /* Pointer to end of dir */ |
| 154 | } /* convert_dirname */ |
no test coverage detected