version 1.1.1.2, 2000/09/09 14:13:17 |
version 1.1.1.3, 2003/08/25 16:06:37 |
|
|
/* min(MINT) -- Do decimal input from standard input and store result in |
/* min(MINT) -- Do decimal input from standard input and store result in |
MINT. |
MINT. |
|
|
Copyright (C) 1991, 1994, 1996, 2000 Free Software Foundation, Inc. |
Copyright 1991, 1994, 1996, 2000, 2001 Free Software Foundation, Inc. |
|
|
This file is part of the GNU MP Library. |
This file is part of the GNU MP Library. |
|
|
Line 27 MA 02111-1307, USA. */ |
|
Line 27 MA 02111-1307, USA. */ |
|
#include "gmp-impl.h" |
#include "gmp-impl.h" |
|
|
static int |
static int |
#if __STDC__ |
|
digit_value_in_base (int c, int base) |
digit_value_in_base (int c, int base) |
#else |
|
digit_value_in_base (c, base) |
|
int c; |
|
int base; |
|
#endif |
|
{ |
{ |
int digit; |
int digit; |
|
|
Line 52 digit_value_in_base (c, base) |
|
Line 46 digit_value_in_base (c, base) |
|
} |
} |
|
|
void |
void |
#if __STDC__ |
|
min (MINT *dest) |
min (MINT *dest) |
#else |
|
min (dest) |
|
MINT *dest; |
|
#endif |
|
{ |
{ |
char *str; |
char *str; |
size_t alloc_size, str_size; |
size_t alloc_size, str_size; |
|
|
mp_size_t dest_size; |
mp_size_t dest_size; |
|
|
alloc_size = 100; |
alloc_size = 100; |
str = (char *) (*_mp_allocate_func) (alloc_size); |
str = (char *) (*__gmp_allocate_func) (alloc_size); |
str_size = 0; |
str_size = 0; |
|
|
/* Skip whitespace. */ |
/* Skip whitespace. */ |
|
|
{ |
{ |
size_t old_alloc_size = alloc_size; |
size_t old_alloc_size = alloc_size; |
alloc_size = alloc_size * 3 / 2; |
alloc_size = alloc_size * 3 / 2; |
str = (char *) (*_mp_reallocate_func) (str, old_alloc_size, alloc_size); |
str = (char *) (*__gmp_reallocate_func) (str, old_alloc_size, alloc_size); |
} |
} |
dig = digit_value_in_base (c, 10); |
dig = digit_value_in_base (c, 10); |
if (dig < 0) |
if (dig < 0) |
|
|
dest_size = mpn_set_str (dest->_mp_d, (unsigned char *) str, str_size, 10); |
dest_size = mpn_set_str (dest->_mp_d, (unsigned char *) str, str_size, 10); |
dest->_mp_size = negative ? -dest_size : dest_size; |
dest->_mp_size = negative ? -dest_size : dest_size; |
|
|
(*_mp_free_func) (str, alloc_size); |
(*__gmp_free_func) (str, alloc_size); |
return; |
return; |
} |
} |