lex.reg.c
/*
 *
 * _regAccel -- apply acceleration to a segment
 *
 */
- apply acceleration to a segment
- apply acceleration to a segment
static int _regAccel(int n) {
  int i;
  char tbuf[SZ_LINE];
  char *s;
  double dinc;
  switch(regid){
    case TY_ANNULUS:
      break;
    case TY_BOX:
      narg -= 2;
      break;
    case TY_CIRCLE:
      narg -= 1;
      break;
    case TY_ELLIPSE:
      narg -= 2;
      break;
    case TY_PIE:
      break;
    default:
      _regerror("annulus, box, circle, ellipse, pie accelerators only - ");
      break;
  }
  snprintf(tbuf, SZ_LINE, IFMT1, n);
  _regCat(tbuf);
  if( seg[nseg-1]->s0 ){
    if( (s = xstrdup(&seg[nseg-1]->s[seg[nseg-1]->s0])) ){
      seg[nseg-1]->s[seg[nseg-1]->s0] = '\0';
      _regCat("n");
      _regCat(s);
      snprintf(tbuf, SZ_LINE, "%d ", n);
      __regCat(tbuf, &(seg[nseg-1]->regions), &(seg[nseg-1]->nr));
      __regCat(tbuf, &(seg[nseg-1]->shapes), &(seg[nseg-1]->ns));
      setargs = 1;
      free (s);
    }
    if( seg[nseg-1]->radang ){
      xfree(seg[nseg-1]->radang);
      seg[nseg-1]->radang = NULL;
      seg[nseg-1]->ralen = 0;
    }
    switch(regid){
      case TY_ANNULUS:
      case TY_BOX:
      case TY_CIRCLE:
      case TY_ELLIPSE:
        dinc = (lastd2 - lastd1)/n;
        for(i=1; i<=n; i++){
          snprintf(tbuf, SZ_LINE, DFMT2, lastd1+((i-1)*dinc), lastd1+(i*dinc));
          __regCat(tbuf, &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
          __regCat(",NA,NA", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
	  __regCat("\n", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
        }
        break;
      case TY_PIE:
        dinc = (lastd2 - lastd1)/n;
        for(i=1; i<=n; i++){
          snprintf(tbuf, SZ_LINE, DFMT2, lastd1+((i-1)*dinc), lastd1+(i*dinc));
          __regCat("NA,NA", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
          __regCat(tbuf, &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
	  __regCat("\n", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
        }
        break;
      default:
        _regerror("annulus, box, circle, ellipse, pie accelerators only - ");
        break;
    }
    _regTypeSet(TOK_ACCEL);
  } else {
    _regerror("misplaced accelerator");
  }
  return(n);
}
static int _regAccel ( int n ) { int i ; char tbuf [ SZ_LINE ] ; char * s ; double dinc ; switch ( regid ) { case TY_ANNULUS : break ; case TY_BOX : narg -= 2 ; break ; case TY_CIRCLE : narg -= 1 ; break ; case TY_ELLIPSE : narg -= 2 ; break ; case TY_PIE : break ; default : _regerror ( " " ) ; break ; } snprintf ( tbuf , SZ_LINE , IFMT1 , n ) ; _regCat ( tbuf ) ; if ( seg [ nseg - 1 ] -> s0 ) { if ( ( s = xstrdup ( & seg [ nseg - 1 ] -> s [ seg [ nseg - 1 ] -> s0 ] ) ) ) { seg [ nseg - 1 ] -> s [ seg [ nseg - 1 ] -> s0 ] = ' \0 ' ; _regCat ( " " ) ; _regCat ( s ) ; snprintf ( tbuf , SZ_LINE , " " , n ) ; __regCat ( tbuf , & ( seg [ nseg - 1 ] -> regions ) , & ( seg [ nseg - 1 ] -> nr ) ) ; __regCat ( tbuf , & ( seg [ nseg - 1 ] -> shapes ) , & ( seg [ nseg - 1 ] -> ns ) ) ; setargs = 1 ; free ( s ) ; } if ( seg [ nseg - 1 ] -> radang ) { xfree ( seg [ nseg - 1 ] -> radang ) ; seg [ nseg - 1 ] -> radang = NULL ; seg [ nseg - 1 ] -> ralen = 0 ; } switch ( regid ) { case TY_ANNULUS : case TY_BOX : case TY_CIRCLE : case TY_ELLIPSE : dinc = ( lastd2 - lastd1 ) / n ; for ( i = 1 ; i <= n ; i ++ ) { snprintf ( tbuf , SZ_LINE , DFMT2 , lastd1 + ( ( i - 1 ) * dinc ) , lastd1 + ( i * dinc ) ) ; __regCat ( tbuf , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; __regCat ( " " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; __regCat ( " \n " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; } break ; case TY_PIE : dinc = ( lastd2 - lastd1 ) / n ; for ( i = 1 ; i <= n ; i ++ ) { snprintf ( tbuf , SZ_LINE , DFMT2 , lastd1 + ( ( i - 1 ) * dinc ) , lastd1 + ( i * dinc ) ) ; __regCat ( " " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; __regCat ( tbuf , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; __regCat ( " \n " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; } break ; default : _regerror ( " " ) ; break ; } _regTypeSet ( TOK_ACCEL ) ; } else { _regerror ( " " ) ; } return ( n ) ; }
_regAccel -- apply acceleration to a segment
_regAccel -- apply acceleration to a segment
/* check region type */ /* add the argument */ /* change the name of the routine we will call */