File:  [CSRG BSD Unix] / 43BSD / contrib / icon / rt / cvpos.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#include "../h/rt.h"

/*
 * cvpos - convert position to strictly positive position
 *  given string or list length.
 */

cvpos(pos, len)
long pos;
register int len;
   {
   DclSave
   register int p;

   /*
    * Fail if the position isn't in the range of an int. (?)
    */
   if ((long)(p = pos) != pos)
      fail();
   /*
    * Fail if the position is off either end of the string.
    */
   if (p < -len || p > len + 1)
      fail();
   /*
    * If the position is greater than zero, just return it.  Otherwise,
    *  convert the zero/negative position.
    */
   if (pos > 0)
      return (p);
   return (len + p + 1);
   }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.