/**************************************************************************/
/*                                                                        */
/*                                 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: i_cnst.c,v 1.2 1997/09/25 17:27:41 ae59 Exp $ */
/*
$Log: i_cnst.c,v $
 * Revision 1.2  1997/09/25  17:27:41  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:22:53  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : i_cnst.c                              */
/*                                                              */
/*      Entries         : a_intv i_cnst(str)                    */
/*                        a_char *str;                          */
/*                                                              */
/*      Arguments       : str - input string                    */
/*                                                              */
/*      Description     : Convert a character string            */
/*                        to IEEE double format rounded         */
/*                        to interval.                          */
/*                                                              */
/*      Date            : 1991-04-22                            */
/*      1991-04-22 : real assignment replaced by R_ASSIGN()     */
/*      1991-02-20 : b_chck() new arguments                     */
/*      1990-11-20 : E_TPUSH+E_TPOPP                            */
/*      1990-11-20 : arg. of type a_char *                      */
/*      1990-10-30 : return with argument                       */
/****************************************************************/

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

#ifdef LINT_ARGS
local a_intv i_cnst(a_char *str)
#else
local a_intv i_cnst(str)

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

        E_TPUSH("i_cnst")

        R_ASSIGN(s.INF,*r_zero);
        R_ASSIGN(s.SUP,*r_zero);

        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,66);
                    E_TPOPP("i_cnst")
                    return(s);
           case  2:
           case  3:
           case  4: e_trap(I_O_ERROR,4,E_TMSG,58,E_TSTR+E_TEXT(10),str);
                    E_TPOPP("i_cnst")
                    return(s);
           case  5: e_trap(NO_ERROR+E_EMSG+E_ECNT,2,E_TSTR+E_TEXT(10),str);
           default: ;
           }

        if ((rc = b_form((a_btyp *)buffer,&size,
                         expo,dp,length,sign,(a_intg)-1,&s.INF))!=0)
           e_trap(rc,2,E_TSTR+E_TEXT(10),str);

        else if ((rc = b_form((a_btyp *)buffer,&size,
                         expo,dp,length,sign,(a_intg)1,&s.SUP))!=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 *)"i_cnst");
#endif
           free(buffer);
           }

        E_TPOPP("i_cnst")
        return(s);
        }

