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

Function process_int_arg

strings/my_vsnprintf.c:248–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246*/
247
248static char *process_int_arg(char *to, char *end, size_t length,
249 longlong par, char arg_type, uint print_type)
250{
251 size_t res_length, to_length;
252 char *store_start= to, *store_end;
253 char buff[32];
254
255 if ((to_length= (size_t) (end-to)) < 16 || length)
256 store_start= buff;
257
258 if (arg_type == 'd' || arg_type == 'i')
259 store_end= longlong10_to_str(par, store_start, -10);
260 else if (arg_type == 'u')
261 store_end= longlong10_to_str(par, store_start, 10);
262 else if (arg_type == 'p')
263 {
264 store_start[0]= '0';
265 store_start[1]= 'x';
266 store_end= ll2str(par, store_start + 2, 16, 0);
267 }
268 else if (arg_type == 'o')
269 {
270 store_end= ll2str(par, store_start, 8, 0);
271 }
272 else
273 {
274 DBUG_ASSERT(arg_type == 'X' || arg_type =='x');
275 store_end= ll2str(par, store_start, 16, (arg_type == 'X'));
276 }
277
278 if ((res_length= (size_t) (store_end - store_start)) > to_length)
279 return to; /* num doesn't fit in output */
280 /* If %#d syntax was used, we have to pre-zero/pre-space the string */
281 if (store_start == buff)
282 {
283 length= MY_MIN(length, to_length);
284 if (res_length < length)
285 {
286 size_t diff= (length- res_length);
287 memset(to, (print_type & PREZERO_ARG) ? '0' : ' ', diff);
288 if (arg_type == 'p' && print_type & PREZERO_ARG)
289 {
290 if (diff > 1)
291 to[1]= 'x';
292 else
293 store_start[0]= 'x';
294 store_start[1]= '0';
295 }
296 to+= diff;
297 }
298 bmove(to, store_start, res_length);
299 }
300 to+= res_length;
301 return to;
302}
303
304
305/**

Callers 2

process_argsFunction · 0.85
my_vsnprintf_exFunction · 0.85

Calls 2

longlong10_to_strFunction · 0.85
ll2strFunction · 0.85

Tested by

no test coverage detected