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

Function ll2str

strings/longlong2str.c:50–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48*/
49
50char *ll2str(longlong val,char *dst,int radix, int upcase)
51{
52 char buffer[65];
53 register char *p;
54 long long_val;
55 char *dig_vec= upcase ? _dig_vec_upper : _dig_vec_lower;
56 ulonglong uval= (ulonglong) val;
57
58 if (radix < 0)
59 {
60 if (radix < -36 || radix > -2) return (char*) 0;
61 if (val < 0) {
62 *dst++ = '-';
63 /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
64 uval = (ulonglong)0 - uval;
65 }
66 radix = -radix;
67 }
68 else
69 {
70 if (radix > 36 || radix < 2) return (char*) 0;
71 }
72 if (uval == 0)
73 {
74 *dst++='0';
75 *dst='\0';
76 return dst;
77 }
78 p = &buffer[sizeof(buffer)-1];
79 *p = '\0';
80
81 while (uval > (ulonglong) LONG_MAX)
82 {
83 ulonglong quo= uval/(uint) radix;
84 uint rem= (uint) (uval- quo* (uint) radix);
85 *--p= dig_vec[rem];
86 uval= quo;
87 }
88 long_val= (long) uval;
89 while (long_val != 0)
90 {
91 long quo= long_val/radix;
92 *--p= dig_vec[(uchar) (long_val - quo*radix)];
93 long_val= quo;
94 }
95 while ((*dst++ = *p++) != 0) ;
96 return dst-1;
97}
98#endif
99
100#ifndef longlong10_to_str

Callers 1

process_int_argFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected