adding atoi_superscript and isdigit_superscript

This commit is contained in:
hugogogo
2026-05-06 20:02:44 +02:00
parent b64ede50af
commit f93c635234
10 changed files with 269 additions and 82 deletions

View File

@@ -3,27 +3,13 @@
long ft_atol(const char *str)
{
long long nbr;
int i;
int negatif;
long long result = ft_atoll(str);
i = 0;
negatif = 1;
nbr = 0;
// clamp to long range
if (result > LONG_MAX)
return LONG_MAX;
if (result < LONG_MIN)
return LONG_MIN;
// Skip leading whitespace
while ((str[i] == ' ') || (str[i] > 8 && str[i] < 14))
i++;
// Handle optional sign
if (str[i] == '-')
negatif = -1;
if (str[i] == '+' || str[i] == '-')
i++;
// parse integer
while (str[i] >= '0' && str[i] <= '9')
nbr = nbr * 10 + (str[i++] - '0');
return (nbr * negatif);
return (long)result;
}