MCPcopy Create free account
hub / github.com/GJDuck/e9patch / atoi_convert

Function atoi_convert

examples/stdlib.c:2822–2922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2820}
2821
2822static __int128 atoi_convert(const char * __restrict__ nptr,
2823 char ** __restrict__ endptr, int base, __int128 min, __int128 max)
2824{
2825 char *dummy_endptr;
2826 if (endptr == NULL)
2827 endptr = &dummy_endptr;
2828 if (base != 0 && (base < 2 || base > 36))
2829 {
2830 *endptr = (char *)nptr;
2831 errno = EINVAL;
2832 return 0;
2833 }
2834 char *startptr = (char *)nptr;
2835 while (isspace(*nptr))
2836 nptr++;
2837 bool neg = false;
2838 switch (*nptr)
2839 {
2840 case '-':
2841 neg = true;
2842 // Fallthrough:
2843 case '+':
2844 nptr++;
2845 break;
2846 default:
2847 break;
2848 }
2849 switch (*nptr)
2850 {
2851 case '0':
2852 switch (base)
2853 {
2854 case 16:
2855 nptr++;
2856 if (*nptr == 'x' || *nptr == 'X')
2857 nptr++;
2858 break;
2859 case 8:
2860 nptr++;
2861 break;
2862 case 0:
2863 nptr++;
2864 if (*nptr == 'x' || *nptr == 'X')
2865 {
2866 nptr++;
2867 base = 16;
2868 }
2869 else if (atoi_digit(*nptr, 8) >= 0)
2870 base = 8;
2871 else
2872 {
2873 *endptr = (char *)nptr;
2874 return 0;
2875 }
2876 break;
2877 }
2878 break;
2879 case '\0':

Callers 7

strtoullFunction · 0.85
strtoulFunction · 0.85
strtollFunction · 0.85
strtolFunction · 0.85
atoiFunction · 0.85
atolFunction · 0.85
atollFunction · 0.85

Calls 2

isspaceFunction · 0.85
atoi_digitFunction · 0.85

Tested by

no test coverage detected