lex.reg.c
/*
 *
 * _regArgSave -- save a radius or angle value to the temp string:
 * this is a special hack for regcnts
 *
 */
- save a radius or angle value to the temp string:
this is a special hack for regcnts
- save a radius or angle value to the temp string : this is a special hack for regcnts
static void _regArgSave(double dval) {
  char tbuf[SZ_LINE];
  if( narg < 3 ){
    return;
  }
  snprintf(tbuf, SZ_LINE, DFMT1, dval);
  if( narg == 3 ){ 
    *lastarg = '\0';
    lastd1 = 0.0;
    lastd2 = 0.0;
    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_CIRCLE:
    if( *lastarg ){
      __regCat(lastarg, &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
    }
    __regCat(tbuf, &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
    if( narg > 3 ){
      __regCat(",NA,NA\n", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
      strcpy(lastarg, tbuf);
    }
    lastd1 = lastd2;
    lastd2 = dval;
    break;
  case TY_BOX:
  case TY_ELLIPSE:
    if( (narg%2) == 1 ){
      if( *lastarg ){
        __regCat(lastarg, &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
      }
      __regCat(tbuf, &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
      if( narg > 3 ){
        __regCat(",NA,NA\n", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
        strcpy(lastarg, tbuf);
      }
      lastd1 = lastd2;
      lastd2 = dval;
    }
    break;
  case TY_PIE:
    if( narg == 3 ){
      __regCat("NA,NA", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
    } else if( *lastarg ){
      __regCat("NA,NA,", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
      __regCat(lastarg, &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
    }
    __regCat(tbuf, &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
    if( narg > 3 ){
      __regCat("\n", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
      strcpy(lastarg, tbuf);
    }
    lastd1 = lastd2;
    lastd2 = dval;
    break;
  case TY_POINT:
    if( narg == 3 ){ 
      __regCat("NA,NA,NA,NA\n", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
    } else if( (narg % 2) == 0 ){ 
      __regCat("NA,NA,NA,NA\n", &(seg[nseg-1]->radang), &(seg[nseg-1]->ralen));
    }
    break;
  default:
    return;
  }      
}
static void _regArgSave ( double dval ) { char tbuf [ SZ_LINE ] ; if ( narg < 3 ) { return ; } snprintf ( tbuf , SZ_LINE , DFMT1 , dval ) ; if ( narg == 3 ) { * lastarg = ' \0 ' ; lastd1 = 0.0 ; lastd2 = 0.0 ; 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_CIRCLE : if ( * lastarg ) { __regCat ( lastarg , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; } __regCat ( tbuf , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; if ( narg > 3 ) { __regCat ( " \n " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; strcpy ( lastarg , tbuf ) ; } lastd1 = lastd2 ; lastd2 = dval ; break ; case TY_BOX : case TY_ELLIPSE : if ( ( narg % 2 ) == 1 ) { if ( * lastarg ) { __regCat ( lastarg , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; } __regCat ( tbuf , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; if ( narg > 3 ) { __regCat ( " \n " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; strcpy ( lastarg , tbuf ) ; } lastd1 = lastd2 ; lastd2 = dval ; } break ; case TY_PIE : if ( narg == 3 ) { __regCat ( " " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; } else if ( * lastarg ) { __regCat ( " " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; __regCat ( lastarg , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; } __regCat ( tbuf , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; if ( narg > 3 ) { __regCat ( " \n " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; strcpy ( lastarg , tbuf ) ; } lastd1 = lastd2 ; lastd2 = dval ; break ; case TY_POINT : if ( narg == 3 ) { __regCat ( " \n " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; } else if ( ( narg % 2 ) == 0 ) { __regCat ( " \n " , & ( seg [ nseg - 1 ] -> radang ) , & ( seg [ nseg - 1 ] -> ralen ) ) ; } break ; default : return ; } }
_regArgSave -- save a radius or angle value to the temp string:
 this is a special hack for regcnts
_regArgSave -- save a radius or angle value to the temp string : this is a special hack for regcnts
/* we have to process this here if its is a varargs */ // so, for the 3rd arg, we add a line for initial x, y pair /* and for every even arg, add a line for the preceeding x,y pair */