strtol_error err = LONGINT_INVALID;
- /* Skip initial spaces and '+'. */
- for (;;)
- {
- char c = *s;
- if (c == ' ')
- s++;
- else if (c == '+')
- {
- s++;
- break;
- }
- else
- break;
- }
-
/* Initial scan for invalid digits. */
const char *p = s;
for (;;)
err = LONGINT_OK; /* we've seen at least one valid digit */
}
- for (;err == LONGINT_OK;)
+ while (err == LONGINT_OK)
{
unsigned int c = *s++;
if (c == 0)
static bool
print_factors (const char *input)
{
+ /* Skip initial spaces and '+'. */
+ char const *str = input;
+ while (*str == ' ')
+ str++;
+ str += *str == '+';
+
uintmax_t t1, t0;
/* Try converting the number to one or two words. If it fails, use GMP or
print an error message. The 2nd condition checks that the most
significant bit of the two-word number is clear, in a typesize neutral
way. */
- strtol_error err = strto2uintmax (&t1, &t0, input);
+ strtol_error err = strto2uintmax (&t1, &t0, str);
switch (err)
{
mpz_t t;
struct mp_factors factors;
- mpz_init_set_str (t, input, 10);
+ mpz_init_set_str (t, str, 10);
gmp_printf ("%Zd:", t);
mp_factor (t, &factors);
'115792089237316195423570985008687907853'
. '269984665640564039457584007913129639936',
{OUT => '2 'x255 . '2'}],
+ ['bug-gmp-plus_2_sup_128_plus_1',
+ '+170141183460469231731687303715884105729',
+ {OUT => '3 56713727820156410577229101238628035243'}],
);