lex.reg.c
/*
 *
 * regStart == start a new region
 *
 */
regStart == start a new region
regStart == start a new region
static void _regStart() {
  char *s, *t;
  char tbuf[SZ_LINE];
  narg = 0;
  setargs = 0;
  s = xmalloc(strlen(regionstext)+1);
  nowhite(regionstext, s);
  if( *s == '+' ){
    regtype = TOK_IREG;
    strcpy(regname, s+1);
  } else if( *s == '-' ){
    regtype = TOK_EREG;
    strcpy(regname, s+1);
  } else if( *s == '!' ){
    regtype = TOK_NREG;
    strcpy(regname, s+1);
  } else {
    regtype = TOK_IREG;
    strcpy(regname, s);
  }
  _regTypeSet(regtype);
  if( !(t=strchr(regname, '(')) ){
    nsparen = 0;
  } else {
    *t = '\0';
    nsparen=1;
  }  
  culc(regname);
  nowhite(regname, s);
  strcpy(regname, s);
  if( !strncmp(regname, "ann", 3) ){
    strcpy(regname, "annulus");
    regid = TY_ANNULUS;
  } else if( !strncmp(regname, "box", 3) ){
    strcpy(regname, "box");
    regid = TY_BOX;
  } else if( !strncmp(regname, "cir", 3) ){
    strcpy(regname, "circle");
    regid = TY_CIRCLE;
  } else if( !strncmp(regname, "ell", 3) ){
    strcpy(regname, "ellipse");
    regid = TY_ELLIPSE;
  } else if( !strncmp(regname, "fie", 3) ){
    strcpy(regname, "field");
    regid = TY_FIELD;
  } else if( !strncmp(regname, "lin", 3) ){
    strcpy(regname, "line");
    regid = TY_LINE;
  } else if( !strncmp(regname, "pan", 3) ){
    strcpy(regname, "panda");
    regid = TY_PANDA;
  } else if( !strncmp(regname, "bpa", 3) ){
    strcpy(regname, "bpanda");
    regid = TY_BPANDA;
  } else if( !strncmp(regname, "cpa", 3) ){
    strcpy(regname, "cpanda");
    regid = TY_CPANDA;
  } else if( !strncmp(regname, "epa", 3) ){
    strcpy(regname, "epanda");
    regid = TY_EPANDA;
  } else if( !strncmp(regname, "pie", 3) ){
    strcpy(regname, "pie");
    regid = TY_PIE;
  } else if( !strncmp(regname, "qtp", 3) ){
    strcpy(regname, "qtpie");
    regid = TY_PIE;
  } else if( !strncmp(regname, "poi", 3) ){
    strcpy(regname, "point");
    regid = TY_POINT;
  } else if( !strncmp(regname, "pol", 3) ){
    strcpy(regname, "polygon");
    regid = TY_POLYGON;
  }
  if( xreg->reg_prefix ){
    _regCat(xreg->reg_prefix);
  }
  _regCat("im");
  seg[nseg-1]->regval = 0;
  seg[nseg-1]->s0 = strlen(seg[nseg-1]->s);
  _regCat(RegionsLexRegion1(xreg,regname));
  _regCat("(g,$RS,");
  switch(regtype){
  case TOK_IREG:
    snprintf(tbuf, SZ_LINE, "1,%d", TOK_IREG);
    _regCat(tbuf);
    break;
  case TOK_NREG:
    snprintf(tbuf, SZ_LINE, "0,%d", TOK_NREG);
    _regCat(tbuf);
    break;
  case TOK_EREG:
    snprintf(tbuf, SZ_LINE, "0,%d", TOK_EREG);
    _regCat(tbuf);
    break;
  }
  _regCat(",");
  floatprefix();
  _regCat("x");
  floatsuffix();
  _regCat(",");
  floatprefix();
  _regCat("y");
  floatsuffix();
  xfree(s);
}
static void _regStart ( ) { char * s , * t ; char tbuf [ SZ_LINE ] ; narg = 0 ; setargs = 0 ; s = xmalloc ( strlen ( regionstext ) + 1 ) ; nowhite ( regionstext , s ) ; if ( * s == ' ' ) { regtype = TOK_IREG ; strcpy ( regname , s + 1 ) ; } else if ( * s == ' ' ) { regtype = TOK_EREG ; strcpy ( regname , s + 1 ) ; } else if ( * s == ' ' ) { regtype = TOK_NREG ; strcpy ( regname , s + 1 ) ; } else { regtype = TOK_IREG ; strcpy ( regname , s ) ; } _regTypeSet ( regtype ) ; if ( ! ( t = strchr ( regname , ' ' ) ) ) { nsparen = 0 ; } else { * t = ' \0 ' ; nsparen = 1 ; } culc ( regname ) ; nowhite ( regname , s ) ; strcpy ( regname , s ) ; if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_ANNULUS ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_BOX ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_CIRCLE ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_ELLIPSE ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_FIELD ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_LINE ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_PANDA ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_BPANDA ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_CPANDA ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_EPANDA ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_PIE ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_PIE ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_POINT ; } else if ( ! strncmp ( regname , " " , 3 ) ) { strcpy ( regname , " " ) ; regid = TY_POLYGON ; } if ( xreg -> reg_prefix ) { _regCat ( xreg -> reg_prefix ) ; } _regCat ( " " ) ; seg [ nseg - 1 ] -> regval = 0 ; seg [ nseg - 1 ] -> s0 = strlen ( seg [ nseg - 1 ] -> s ) ; _regCat ( RegionsLexRegion1 ( xreg , regname ) ) ; _regCat ( " " ) ; switch ( regtype ) { case TOK_IREG : snprintf ( tbuf , SZ_LINE , " " , TOK_IREG ) ; _regCat ( tbuf ) ; break ; case TOK_NREG : snprintf ( tbuf , SZ_LINE , " " , TOK_NREG ) ; _regCat ( tbuf ) ; break ; case TOK_EREG : snprintf ( tbuf , SZ_LINE , " " , TOK_EREG ) ; _regCat ( tbuf ) ; break ; } _regCat ( " " ) ; floatprefix ( ) ; _regCat ( " " ) ; floatsuffix ( ) ; _regCat ( " " ) ; floatprefix ( ) ; _regCat ( " " ) ; floatsuffix ( ) ; xfree ( s ) ; }
regStart == start a new region
regStart == start a new region
/* initialize region */ /* look for include/exclude */ /* remove the paren from the regname string -- we will explicitly add it */ /* convert to lower case, remove white space */ /* convert abbrev to region */ /* image are filtered by image pixels */ /* no region value to start */ /* save size of current string so we can get back to the region string */ /* append region */ /* append standard args */ /* add include/exclude and whether we mark y lines for this region
     (we don't mark y on excludes as an optimization) */