1 /* min(MINT) -- Do decimal input from standard input and store result in
4 Copyright (C) 1991, 1994 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 Library General Public License as published by
10 the Free Software Foundation; either version 2 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 Library General Public
16 License for more details.
18 You should have received a copy of the GNU Library General Public License
19 along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 MA 02111-1307, USA. */
30 digit_value_in_base (c, base)
59 size_t alloc_size, str_size;
65 str = (char *) (*_mp_allocate_func) (alloc_size);
68 /* Skip whitespace. */
80 if (digit_value_in_base (c, 10) < 0)
81 return; /* error if no digits */
86 if (str_size >= alloc_size)
88 size_t old_alloc_size = alloc_size;
89 alloc_size = alloc_size * 3 / 2;
90 str = (char *) (*_mp_reallocate_func) (str, old_alloc_size, alloc_size);
92 dig = digit_value_in_base (c, 10);
95 str[str_size++] = dig;
101 dest_size = str_size / __mp_bases[10].chars_per_limb + 1;
102 if (dest->_mp_alloc < dest_size)
103 _mp_realloc (dest, dest_size);
105 dest_size = mpn_set_str (dest->_mp_d, (unsigned char *) str, str_size, 10);
106 dest->_mp_size = negative ? -dest_size : dest_size;
108 (*_mp_free_func) (str, alloc_size);