1 /* min(MINT) -- Do decimal input from standard input and store result in
4 Copyright 1991, 1994, 1996, 2000, 2001 Free Software Foundation, Inc.
6 This file is part of the GNU MP Library.
8 The GNU MP Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
13 The GNU MP Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
27 extern const unsigned char __gmp_digit_value_tab[];
28 #define digit_value_tab __gmp_digit_value_tab
34 size_t alloc_size, str_size;
38 const unsigned char *digit_value;
40 digit_value = digit_value_tab;
43 str = (char *) (*__gmp_allocate_func) (alloc_size);
46 /* Skip whitespace. */
58 if (c == EOF || digit_value[c] >= 10)
59 return; /* error if no digits */
67 if (str_size >= alloc_size)
69 size_t old_alloc_size = alloc_size;
70 alloc_size = alloc_size * 3 / 2;
71 str = (char *) (*__gmp_reallocate_func) (str, old_alloc_size, alloc_size);
73 str[str_size++] = dig;
80 dest_size = str_size / mp_bases[10].chars_per_limb + 1;
81 if (dest->_mp_alloc < dest_size)
82 _mp_realloc (dest, dest_size);
84 dest_size = mpn_set_str (dest->_mp_d, (unsigned char *) str, str_size, 10);
85 dest->_mp_size = negative ? -dest_size : dest_size;
87 (*__gmp_free_func) (str, alloc_size);