/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: r_conv.c,v 1.2 1997/09/25 17:44:23 ae59 Exp $ */
/*
$Log: r_conv.c,v $
 * Revision 1.2  1997/09/25  17:44:23  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:23:52  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : r_conv.c                              */
/*                                                              */
/*      Entries         : void r_conv(str,s,rnd,next)           */
/*                        a_char *str;                          */
/*                        a_real *s;                            */
/*                        a_intg rnd;                           */
/*                        a_char **next;                        */
/*                                                              */
/*      Arguments       : str - input string                    */
/*                        s - resultant IEEE variable           */
/*                        rnd - rounding mode                   */
/*                              -1 = rounding downwards         */
/*                               0 = round to nearest           */
/*                               1 = round upwards              */
/*                        next - address of last character      */
/*                                                              */
/*      Description     : Convert a character string            */
/*                        to IEEE double format                 */
/*                                                              */
/*      Date            : 1991-02-20                            */
/*      1991-02-20 : b_chck() new arguments                     */
/*      1990-11-19 : E_TPUSH+E_TPOPP                            */
/*      1990-10-23 : new argument 'next' in b_chck/r_conv       */
/*      1990-08-06 : explicit compare                           */
/*      1990-07-30 : string replaced by a_char[]                */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
extern dotprecision b_cp__;
#endif

#ifdef LINT_ARGS
local void r_conv(a_char *str,a_real *s,a_intg rnd,a_char **next)
#else
local void r_conv(str,s,rnd,next)

a_char *str;
a_real *s;
a_intg rnd;
a_char **next;
#endif
        {
        a_intg dp,expo,length,size;
        a_bool sign;
        char *buffer;
        a_btyp rc;

        E_TPUSH("r_conv")

        buffer = (char *)b_cp__;
        size = BUFFERSIZE;

        switch (b_chck(str,&buffer,&size,&expo,&dp,&length,&sign,next))
           {
           case  1: e_trap(ALLOCATION,2,E_TMSG,56);
                    break;
           case  2:
           case  3:
           case  4: e_trap(I_O_ERROR,4,E_TMSG,58,E_TSTR+E_TEXT(10),str);
                    break;
           case  5: e_trap(NO_ERROR+E_EMSG+E_ECNT,2,E_TMSG,64);
           default: if ((rc = b_form((a_btyp *)buffer,&size,
                                     expo,dp,length,sign,rnd,s))!=0)
                       e_trap(rc,2,E_TSTR+E_TEXT(10),str);
           }

        if (size!=BUFFERSIZE)
           {
#ifdef HEAP_CHECK
b_freh((a_char *)&buffer,(a_char *)buffer,(a_char *)"r_conv");
#endif
           free(buffer);
           }


        E_TPOPP("r_conv")
        return;
        }
