/**************************************************************************/
/*                                                                        */
/*                                 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: a_ixch.c,v 1.2 1997/09/25 16:51:58 ae59 Exp $ */
/*
$Log: a_ixch.c,v $
 * Revision 1.2  1997/09/25  16:51:58  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:20:45  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : a_ixch.c                              */
/*                                                              */
/*      Entries         : a_btyp a_ixch(i,l,u)                  */
/*                        a_intg i,l,u;                         */
/*                                                              */
/*      Arguments       : i = index                             */
/*                        l = lower bound of index range        */
/*                        u = upper bound of index range        */
/*                                                              */
/*      Description     : Index check                           */
/*                                                              */
/*      Function value  : Offset of index i from lower bound l. */
/*                                                              */
/*      Note            : -1 returned in case of error          */
/*                                                              */
/*      Date            : 1992-07-21                            */
/*      1992-07-21 : cast to a_btyp of -1 =b=                   */
/*      1990-11-15 : E_TPUSH+E_TPOPP                            */
/*      1990-07-23 : redundant E_TMSG in e_trap removed         */
/*                   Unused variable res removed.               */
/*                   Function returns -1 in case of error.      */
/****************************************************************/

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

#ifdef LINT_ARGS
local a_btyp a_ixch(a_intg i,a_intg l,a_intg u)
#else
local a_btyp a_ixch(i,l,u)

a_intg i;
a_intg l;
a_intg u;
#endif
        {
        a_btyp res;

        E_TPUSH("a_ixch")

        if (l<=i && i<=u)
           res = (a_btyp)(i-l);
        else
           {
           e_trap(INDEX_RANGE,6,E_TINT+E_TEXT(4),&i,
                                E_TINT+E_TEXT(5),&l,
                                E_TINT+E_TEXT(6),&u);
           res = (a_btyp) -1;
           }

        E_TPOPP("a_ixch")
        return(res);
        }

