MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / convert_dirname

Function convert_dirname

mysys/mf_dirname.c:104–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102#endif
103
104char *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 */

Callers 11

is_secure_file_pathFunction · 0.85
fix_pathsFunction · 0.85
append_file_to_dirFunction · 0.85
read_textsFunction · 0.85
dirname_partFunction · 0.85
get_charsets_dirFunction · 0.85
create_temp_fileFunction · 0.85
fn_formatFunction · 0.85
my_print_default_filesFunction · 0.85

Calls 2

fs_character_setFunction · 0.85
strmakeFunction · 0.85

Tested by

no test coverage detected