1: #include "../h/rt.h"
   2: 
   3: /*
   4:  * tab(i) - set &pos to i, return substring of &subject spanned.
   5:  *  Reverses effects if resumed..
   6:  */
   7: 
   8: Xtab(nargs, oldsubj, arg1, arg0)
   9: int nargs;
  10: struct descrip oldsubj, arg1, arg0;
  11:    {
  12:    register int i, j;
  13:    int t, oldpos;
  14:    long l1;
  15: 
  16:    /*
  17:     * i must be an integer.
  18:     */
  19:    if (cvint(&arg1,&l1) == NULL)
  20:       runerr(101, &arg1);
  21: 
  22:    /*
  23:     * Convert j to an absolute position.
  24:     */
  25:    j = cvpos(l1, STRLEN(k_subject));
  26: 
  27:    /*
  28:     * Save old &subject and &pos.  Local variable i holds &pos
  29:     *  before the tab.
  30:     */
  31:    oldsubj = k_subject;
  32:    oldpos = i = k_pos;
  33: 
  34:    /*
  35:     * Set new &pos.
  36:     */
  37:    k_pos = j;
  38: 
  39:    /*
  40:     *  Make j the length of the substring &subject[i:j]
  41:     */
  42:    if (i > j) {
  43:       t = i;
  44:       i = j;
  45:       j = t - j;
  46:       }
  47:    else
  48:       j = j - i;
  49: 
  50:    /*
  51:     * Suspend the portion of &subject that was tabbed over.
  52:     */
  53:    STRLOC(arg0) = STRLOC(k_subject) + i - 1;
  54:    STRLEN(arg0) = j;
  55:    suspend();
  56: 
  57:    /*
  58:     * If tab is resumed, restore the old subject and position
  59:     *  and fail.
  60:     */
  61:    k_subject = oldsubj;
  62:    k_pos = oldpos;
  63:    fail();
  64:    }
  65: 
  66: Procblock(tab,2)

Defined functions

Xtab defined in line 8; never used
Last modified: 1984-11-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 604
Valid CSS Valid XHTML 1.0 Strict