|
|
1.1 ! root 1: #include "../h/rt.h" ! 2: ! 3: /* ! 4: * cvpos - convert position to strictly positive position ! 5: * given string or list length. ! 6: */ ! 7: ! 8: cvpos(pos, len) ! 9: long pos; ! 10: register int len; ! 11: { ! 12: DclSave ! 13: register int p; ! 14: ! 15: /* ! 16: * Fail if the position isn't in the range of an int. (?) ! 17: */ ! 18: if ((long)(p = pos) != pos) ! 19: fail(); ! 20: /* ! 21: * Fail if the position is off either end of the string. ! 22: */ ! 23: if (p < -len || p > len + 1) ! 24: fail(); ! 25: /* ! 26: * If the position is greater than zero, just return it. Otherwise, ! 27: * convert the zero/negative position. ! 28: */ ! 29: if (pos > 0) ! 30: return (p); ! 31: return (len + p + 1); ! 32: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.