[BACK]Return to inp_str.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpf

Diff for /OpenXM_contrib/gmp/mpf/Attic/inp_str.c between version 1.1.1.1 and 1.1.1.3

version 1.1.1.1, 2000/01/10 15:35:22 version 1.1.1.3, 2003/08/25 16:06:35
Line 1 
Line 1 
 /* mpf_inp_str(dest_float, stream, base) -- Input a number in base  /* mpf_inp_str(dest_float, stream, base) -- Input a number in base
    BASE from stdio stream STREAM and store the result in DEST_FLOAT.     BASE from stdio stream STREAM and store the result in DEST_FLOAT.
   
 Copyright (C) 1996 Free Software Foundation, Inc.  Copyright 1996, 2000, 2001, 2002 Free Software Foundation, Inc.
   
 This file is part of the GNU MP Library.  This file is part of the GNU MP Library.
   
 The GNU MP Library is free software; you can redistribute it and/or modify  The GNU MP Library is free software; you can redistribute it and/or modify
 it under the terms of the GNU Library General Public License as published by  it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your  the Free Software Foundation; either version 2.1 of the License, or (at your
 option) any later version.  option) any later version.
   
 The GNU MP Library is distributed in the hope that it will be useful, but  The GNU MP Library is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 License for more details.  License for more details.
   
 You should have received a copy of the GNU Library General Public License  You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library; see the file COPYING.LIB.  If not, write to  along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */  MA 02111-1307, USA. */
Line 26  MA 02111-1307, USA. */
Line 26  MA 02111-1307, USA. */
 #include "gmp-impl.h"  #include "gmp-impl.h"
   
 size_t  size_t
 #if __STDC__  
 mpf_inp_str (mpf_ptr rop, FILE *stream, int base)  mpf_inp_str (mpf_ptr rop, FILE *stream, int base)
 #else  
 mpf_inp_str (rop, stream, base)  
      mpf_ptr rop;  
      FILE *stream;  
      int base;  
 #endif  
 {  {
   char *str;    char *str;
   size_t alloc_size, str_size;    size_t alloc_size, str_size;
Line 45  mpf_inp_str (rop, stream, base)
Line 38  mpf_inp_str (rop, stream, base)
     stream = stdin;      stream = stdin;
   
   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;
   nread = 0;    nread = 0;
   
Line 63  mpf_inp_str (rop, stream, base)
Line 56  mpf_inp_str (rop, stream, base)
         {          {
           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);
         }          }
       if (c == EOF || isspace (c))        if (c == EOF || isspace (c))
         break;          break;
Line 71  mpf_inp_str (rop, stream, base)
Line 64  mpf_inp_str (rop, stream, base)
       c = getc (stream);        c = getc (stream);
     }      }
   ungetc (c, stream);    ungetc (c, stream);
     nread--;
   
   if (str_size >= alloc_size)    if (str_size >= alloc_size)
     {      {
       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);
     }      }
   str[str_size] = 0;    str[str_size] = 0;
   
   retval = mpf_set_str (rop, str, base);    retval = mpf_set_str (rop, str, base);
     (*__gmp_free_func) (str, alloc_size);
   
   if (retval == -1)    if (retval == -1)
     return 0;                   /* error */      return 0;                   /* error */
   
   (*_mp_free_func) (str, alloc_size);  
   return str_size + nread;    return str_size + nread;
 }  }

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>