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

Function int_token

sql/sql_lex.cc:772–842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

770static const uint unsigned_longlong_len=20;
771
772static inline uint int_token(const char *str,uint length)
773{
774 if (length < long_len) // quick normal case
775 return NUM;
776 bool neg=0;
777
778 if (*str == '+') // Remove sign and pre-zeros
779 {
780 str++; length--;
781 }
782 else if (*str == '-')
783 {
784 str++; length--;
785 neg=1;
786 }
787 while (*str == '0' && length)
788 {
789 str++; length --;
790 }
791 if (length < long_len)
792 return NUM;
793
794 uint smaller,bigger;
795 const char *cmp;
796 if (neg)
797 {
798 if (length == long_len)
799 {
800 cmp= signed_long_str+1;
801 smaller=NUM; // If <= signed_long_str
802 bigger=LONG_NUM; // If >= signed_long_str
803 }
804 else if (length < signed_longlong_len)
805 return LONG_NUM;
806 else if (length > signed_longlong_len)
807 return DECIMAL_NUM;
808 else
809 {
810 cmp=signed_longlong_str+1;
811 smaller=LONG_NUM; // If <= signed_longlong_str
812 bigger=DECIMAL_NUM;
813 }
814 }
815 else
816 {
817 if (length == long_len)
818 {
819 cmp= long_str;
820 smaller=NUM;
821 bigger=LONG_NUM;
822 }
823 else if (length < longlong_len)
824 return LONG_NUM;
825 else if (length > longlong_len)
826 {
827 if (length > unsigned_longlong_len)
828 return DECIMAL_NUM;
829 cmp=unsigned_longlong_str;

Callers 1

lex_one_tokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected