Removed all static/global name conflicts, avoided global conflicts with flex/bison generated code so xschem (as a test bench) can be compiled as a single big file that includes all other sources

This commit is contained in:
Stefan Schippers 2020-11-03 12:10:55 +01:00
parent 34a1cb8950
commit 957b9888d1
23 changed files with 464 additions and 461 deletions

View File

@ -821,7 +821,7 @@ void attach_labels_to_inst() /* offloaded from callback.c 20171005 */
/* opin or iopin on left of symbol--> reverse orientation 20171205 */
if(rotated_text ==-1 && dir==1 && pinx0<0) dir=0;
ROTATION(0.0, 0.0, pinx0, piny0, pinx0, piny0);
ROTATION(rot, flip, 0.0, 0.0, pinx0, piny0, pinx0, piny0);
pinx0 += x0;
piny0 += y0;
@ -925,7 +925,7 @@ void place_net_label(int type)
place_symbol(-1, "devices/lab_wire.sym", mousex_snap, mousey_snap, 0, 0, NULL, 4, 1);
}
}
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
ui_state |= START_SYMPIN;
}
@ -1007,7 +1007,7 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, int rot,
if(cond) xctx->inst[n].flags|=2;
else xctx->inst[n].flags &=~2;
if(first_call && (draw_sym & 3) ) bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
if(first_call && (draw_sym & 3) ) bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
xctx->instances++; /* must be updated before calling symbol_bbox() */
@ -1574,7 +1574,7 @@ void zoom_box(int what)
static double x1,y1,x2,y2;
static double xx1,yy1,xx2,yy2;
if( (what & BEGIN) )
if( (what & START) )
{
x1=x2=mousex_snap;y1=y2=mousey_snap;
ui_state |= STARTZOOM;
@ -1603,7 +1603,7 @@ void zoom_box(int what)
/* 20171211 update selected objects while dragging */
rebuild_selected_array();
bbox(BEGIN,0.0, 0.0, 0.0, 0.0);
bbox(START,0.0, 0.0, 0.0, 0.0);
bbox(ADD, xx1, yy1, xx2, yy2);
bbox(SET,0.0, 0.0, 0.0, 0.0);
draw_selection(gc[SELLAYER], 0);
@ -1668,7 +1668,7 @@ void restore_selection(double x1, double y1, double x2, double y2)
RECTORDER(xx1,yy1,xx2,yy2);
rebuild_selected_array();
if(!lastselected) return;
bbox(BEGIN,0.0, 0.0, 0.0, 0.0);
bbox(START,0.0, 0.0, 0.0, 0.0);
bbox(ADD, xx1, yy1, xx2, yy2);
bbox(SET,0.0, 0.0, 0.0, 0.0);
draw_selection(gc[SELLAYER], 0);
@ -1726,7 +1726,7 @@ void new_wire(int what, double mx_snap, double my_snap)
update_conn_cues(1,1);
if(show_pin_net_names) {
prepare_netlist_structs(0);
bbox(BEGIN , 0.0 , 0.0 , 0.0 , 0.0);
bbox(START , 0.0 , 0.0 , 0.0 , 0.0);
find_inst_to_be_redrawn(xctx->wire[xctx->wires-1].node);
find_inst_hash_clear();
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
@ -2203,7 +2203,7 @@ int text_bbox(const char *str, double xscale, double yscale,
}
ROTATION(0.0,0.0, ww*xctx->zoom,hh*xctx->zoom,(*rx2),(*ry2));
ROTATION(rot, flip, 0.0,0.0, ww*xctx->zoom,hh*xctx->zoom,(*rx2),(*ry2));
*rx2+=*rx1;*ry2+=*ry1;
if (rot==0) {*ry1-=cairo_vert_correct; *ry2-=cairo_vert_correct;}
else if(rot==1) {*rx1+=cairo_vert_correct; *rx2+=cairo_vert_correct;}
@ -2262,7 +2262,7 @@ int text_bbox(const char * str,double xscale, double yscale,
else if(rot==3 && flip == 1) { *rx1-= h/2;}
}
ROTATION(0.0,0.0,w,h,(*rx2),(*ry2));
ROTATION(rot, flip, 0.0,0.0,w,h,(*rx2),(*ry2));
*rx2+=*rx1;*ry2+=*ry1;
RECTORDER((*rx1),(*ry1),(*rx2),(*ry2));
return 1;
@ -2370,7 +2370,7 @@ void pan2(int what, int mx, int my)
static int mx_save, my_save;
static int mmx_save, mmy_save;
static double xorig_save, yorig_save;
if(what & BEGIN) {
if(what & START) {
mmx_save = mx_save = mx;
mmy_save = my_save = my;
xorig_save = xctx->xorigin;
@ -2405,7 +2405,7 @@ void pan(int what)
ORDER(xx1,yy1,xx2,yy2);
drawtempline(gc[SELLAYER], NOW, xx1,yy1,xx2,yy2);
}
if(what & BEGIN)
if(what & START)
{
ui_state |= STARTPAN;
xpan=mousex_snap;ypan=mousey_snap;xpan2=xpan;ypan2=ypan;
@ -2429,8 +2429,8 @@ void select_rect(int what, int select)
if(what & RUBBER)
{
if(sem==0) {
fprintf(errfp, "ERROR: select_rect() RUBBER called before BEGIN\n");
tcleval("alert_ {ERROR: select_rect() RUBBER called before BEGIN} {}");
fprintf(errfp, "ERROR: select_rect() RUBBER called before START\n");
tcleval("alert_ {ERROR: select_rect() RUBBER called before START} {}");
}
xx1=xr;xx2=xr2;yy1=yr;yy2=yr2;
RECTORDER(xx1,yy1,xx2,yy2);
@ -2439,7 +2439,7 @@ void select_rect(int what, int select)
/* 20171026 update unselected objects while dragging */
rebuild_selected_array();
bbox(BEGIN,0.0, 0.0, 0.0, 0.0);
bbox(START,0.0, 0.0, 0.0, 0.0);
bbox(ADD, xx1, yy1, xx2, yy2);
bbox(SET,0.0, 0.0, 0.0, 0.0);
draw_selection(gc[SELLAYER], 0);
@ -2449,7 +2449,7 @@ void select_rect(int what, int select)
RECTORDER(xx1,yy1,xx2,yy2);
drawtemprect(gc[SELLAYER],NOW, xx1,yy1,xx2,yy2);
}
else if(what & BEGIN)
else if(what & START)
{
/*
* if(sem==1) {
@ -2478,7 +2478,7 @@ void select_rect(int what, int select)
select_inside(xr,yr,xr2,yr2, sel);
bbox(BEGIN,0.0, 0.0, 0.0, 0.0);
bbox(START,0.0, 0.0, 0.0, 0.0);
bbox(ADD, xr, yr, xr2, yr2);
bbox(SET,0.0, 0.0, 0.0, 0.0);
draw_selection(gc[SELLAYER], 0);

View File

@ -257,7 +257,7 @@ int callback(int event, int mx, int my, KeySym key,
static int onetime=0;
if(mx != mx_save || my != my_save) {
if( !(ui_state & STARTSELECT)) {
select_rect(BEGIN,1);
select_rect(START,1);
onetime=1;
}
if(abs(mx-mx_save) > 8 || abs(my-my_save) > 8 ) { /* set some reasonable threshold before unselecting */
@ -272,14 +272,14 @@ int callback(int event, int mx, int my, KeySym key,
if((state & Button1Mask) && (state & Mod1Mask) && !(state & ShiftMask) &&
!(ui_state & STARTPAN2) && !(ui_state & PLACE_SYMBOL)) { /* 20150927 unselect area */
if( !(ui_state & STARTSELECT)) {
select_rect(BEGIN,0);
select_rect(START,0);
}
}
else if((state&Button1Mask) && (state & ShiftMask) && !(ui_state & PLACE_SYMBOL) &&
!(ui_state & STARTPAN2) ) {
if(mx != mx_save || my != my_save) {
if( !(ui_state & STARTSELECT)) {
select_rect(BEGIN,1);
select_rect(START,1);
}
if(abs(mx-mx_save) > 8 || abs(my-my_save) > 8 ) { /* set some reasonable threshold before unselecting */
select_object(X_TO_XSCHEM(mx_save), Y_TO_XSCHEM(my_save), 0, 0); /* remove near object if dragging */
@ -308,7 +308,7 @@ int callback(int event, int mx, int my, KeySym key,
rebuild_selected_array();
if(lastselected==0) ui_state &=~SELECTION;
}
pan2(BEGIN, mx, my);
pan2(START, mx, my);
ui_state |= STARTPAN2;
}
break;
@ -577,7 +577,7 @@ int callback(int event, int mx, int my, KeySym key,
if(key=='z' && state == 0) /* zoom box */
{
dbg(1, "callback(): zoom_box call\n");
zoom_box(BEGIN);break;
zoom_box(START);break;
}
if(key=='Z' && state == ShiftMask) /* zoom in */
{
@ -590,7 +590,7 @@ int callback(int event, int mx, int my, KeySym key,
xRECT, PINLAYER, SELECTED, "name=XXX\ndir=inout");
need_rebuild_selected_array=1;
rebuild_selected_array();
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
ui_state |= START_SYMPIN;
break;
}
@ -607,7 +607,7 @@ int callback(int event, int mx, int my, KeySym key,
}
if(key=='p' && state == ControlMask) /* pan */
{
pan(BEGIN);break;
pan(START);break;
}
if(key=='P' && state == ShiftMask) /* pan, other way to. */
{
@ -891,7 +891,7 @@ int callback(int event, int mx, int my, KeySym key,
if(place_symbol(-1,NULL,mousex_snap, mousey_snap, 0, 0, NULL, 4, 1) ) {
mousey_snap = my_double_save;
mousex_snap = mx_double_save;
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
ui_state |= PLACE_SYMBOL;
}
break;
@ -938,7 +938,7 @@ int callback(int event, int mx, int my, KeySym key,
unhilight_net();
/* undraw_hilight_net(1); */
if(!big) {
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
bbox(ADD, boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
}
@ -975,7 +975,7 @@ int callback(int event, int mx, int my, KeySym key,
delete_hilight_net();
/* undraw_hilight_net(1); */
if(!big) {
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
bbox(ADD, boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
}
@ -1106,7 +1106,7 @@ int callback(int event, int mx, int my, KeySym key,
mx_save = mx; my_save = my;
mx_double_save=mousex_snap;
my_double_save=mousey_snap;
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
if(lastselected>1) move_objects(FLIP,0,0,0);
else move_objects(FLIP|ROTATELOCAL,0,0,0);
move_objects(END,0,0,0);
@ -1128,7 +1128,7 @@ int callback(int event, int mx, int my, KeySym key,
mx_save = mx; my_save = my;
mx_double_save=mousex_snap;
my_double_save=mousey_snap;
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
move_objects(FLIP|ROTATELOCAL,0,0,0);
move_objects(END,0,0,0);
}
@ -1143,7 +1143,7 @@ int callback(int event, int mx, int my, KeySym key,
mx_save = mx; my_save = my;
mx_double_save=mousex_snap;
my_double_save=mousey_snap;
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
if(lastselected>1) move_objects(ROTATE,0,0,0);
else move_objects(ROTATE|ROTATELOCAL,0,0,0);
move_objects(END,0,0,0);
@ -1160,7 +1160,7 @@ int callback(int event, int mx, int my, KeySym key,
mx_save = mx; my_save = my;
mx_double_save=mousex_snap;
my_double_save=mousey_snap;
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
move_objects(ROTATE|ROTATELOCAL,0,0,0);
move_objects(END,0,0,0);
}
@ -1171,7 +1171,7 @@ int callback(int event, int mx, int my, KeySym key,
mx_save = mx; my_save = my;
mx_double_save=mousex_snap;
my_double_save=mousey_snap;
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
break;
}
@ -1182,7 +1182,7 @@ int callback(int event, int mx, int my, KeySym key,
mx_save = mx; my_save = my;
mx_double_save=mousex_snap;
my_double_save=mousey_snap;
copy_objects(BEGIN);
copy_objects(START);
break;
}
if(key=='n' && state==ControlMask) /* New schematic */
@ -1445,7 +1445,7 @@ int callback(int event, int mx, int my, KeySym key,
if(lastselected==0) ui_state &=~SELECTION;
}
else if(button==Button2 && (state == 0)) {
pan2(BEGIN, mx, my);
pan2(START, mx, my);
ui_state |= STARTPAN2;
break;
}
@ -1538,7 +1538,7 @@ int callback(int event, int mx, int my, KeySym key,
break;
}
if(ui_state & MENUSTARTZOOM) {
zoom_box(BEGIN);
zoom_box(START);
ui_state &=~MENUSTARTZOOM;
break;
}
@ -1643,7 +1643,7 @@ int callback(int event, int mx, int my, KeySym key,
delete_hilight_net();
/* undraw_hilight_net(1); */
if(!big) {
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
bbox(ADD, boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
}

View File

@ -320,7 +320,7 @@ void break_wires_at_pins(void)
y0=(rct[r].y1+rct[r].y2)/2;
rot=xctx->inst[k].rot;
flip=xctx->inst[k].flip;
ROTATION(0.0,0.0,x0,y0,rx1,ry1);
ROTATION(rot, flip, 0.0,0.0,x0,y0,rx1,ry1);
x0=xctx->inst[k].x0+rx1;
y0=xctx->inst[k].y0+ry1;
get_square(x0, y0, &sqx, &sqy);

View File

@ -438,8 +438,8 @@ void draw_string(int layer, int what, const char *str, int rot, int flip, int hc
curr_y1 = ( char_ptr_y1[i] ) * yscale+yy;
curr_x2 = ( char_ptr_x2[i]+ zx1 ) * xscale ;
curr_y2 = ( char_ptr_y2[i] ) * yscale+yy;
ROTATION(x1,y1,curr_x1,curr_y1,rx1,ry1);
ROTATION(x1,y1,curr_x2,curr_y2,rx2,ry2);
ROTATION(rot, flip, x1,y1,curr_x1,curr_y1,rx1,ry1);
ROTATION(rot, flip, x1,y1,curr_x2,curr_y2,rx2,ry2);
ORDER(rx1,ry1,rx2,ry2);
drawline(layer, what, rx1, ry1, rx2, ry2, 0);
}
@ -523,8 +523,8 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot,
for(j=0;j< symptr->lines[layer];j++)
{
line = (symptr->line[layer])[j];
ROTATION(0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(0.0,0.0,line.x2,line.y2,x2,y2);
ROTATION(rot, flip, 0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2);
ORDER(x1,y1,x2,y2);
if(line.bus)
drawline(c,THICK, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
@ -539,7 +539,7 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot,
double *x = my_malloc(34, sizeof(double) * polygon.points);
double *y = my_malloc(35, sizeof(double) * polygon.points);
for(k=0;k<polygon.points;k++) {
ROTATION(0.0,0.0,polygon.x[k],polygon.y[k],x[k],y[k]);
ROTATION(rot, flip, 0.0,0.0,polygon.x[k],polygon.y[k],x[k],y[k]);
x[k]+= x0;
y[k] += y0;
}
@ -559,7 +559,7 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot,
}
angle = fmod(angle, 360.);
if(angle<0.) angle+=360.;
ROTATION(0.0,0.0,arc.x,arc.y,x1,y1);
ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1);
drawarc(c,what, x0+x1, y0+y1, arc.r, angle, arc.b, arc.fill, arc.dash);
}
} /* if(!hide) */
@ -569,8 +569,8 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot,
for(j=0;j< symptr->rects[layer];j++)
{
box = (symptr->rect[layer])[j];
ROTATION(0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(0.0,0.0,box.x2,box.y2,x2,y2);
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,box.x2,box.y2,x2,y2);
RECTORDER(x1,y1,x2,y2);
drawrect(c,what, x0+x1, y0+y1, x0+x2, y0+y2, box.dash);
filledrect(c,what, x0+x1, y0+y1, x0+x2, y0+y2);
@ -585,7 +585,7 @@ void draw_symbol(int what,int c, int n,int layer,int tmp_flip, int rot,
if(text.xscale*FONTWIDTH*xctx->mooz<1) continue;
if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue;
txtptr= translate(n, text.txt_ptr);
ROTATION(0.0,0.0,text.x0,text.y0,x1,y1);
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
textlayer = c;
if( !(c == PINLAYER && (xctx->inst[n].flags & 4))) {
@ -681,8 +681,8 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,int tmp_flip, int rot,
for(j=0;j< symptr->lines[layer];j++)
{
line = (symptr->line[layer])[j];
ROTATION(0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(0.0,0.0,line.x2,line.y2,x2,y2);
ROTATION(rot, flip, 0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2);
ORDER(x1,y1,x2,y2);
if(line.bus)
drawtempline(gc,THICK, x0+x1, y0+y1, x0+x2, y0+y2);
@ -699,7 +699,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,int tmp_flip, int rot,
double *x = my_malloc(36, sizeof(double) * polygon.points);
double *y = my_malloc(37, sizeof(double) * polygon.points);
for(k=0;k<polygon.points;k++) {
ROTATION(0.0,0.0,polygon.x[k],polygon.y[k],x[k],y[k]);
ROTATION(rot, flip, 0.0,0.0,polygon.x[k],polygon.y[k],x[k],y[k]);
x[k] += x0;
y[k] += y0;
}
@ -712,8 +712,8 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,int tmp_flip, int rot,
for(j=0;j< symptr->rects[layer];j++)
{
box = (symptr->rect[layer])[j];
ROTATION(0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(0.0,0.0,box.x2,box.y2,x2,y2);
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,box.x2,box.y2,x2,y2);
RECTORDER(x1,y1,x2,y2);
drawtemprect(gc,what, x0+x1, y0+y1, x0+x2, y0+y2);
}
@ -727,7 +727,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,int tmp_flip, int rot,
}
angle = fmod(angle, 360.);
if(angle<0.) angle+=360.;
ROTATION(0.0,0.0,arc.x,arc.y,x1,y1);
ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1);
drawtemparc(gc, what, x0+x1, y0+y1, arc.r, angle, arc.b);
}
@ -739,7 +739,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,int tmp_flip, int rot,
text = symptr->text[j];
if(text.xscale*FONTWIDTH*xctx->mooz<1) continue;
txtptr= translate(n, text.txt_ptr);
ROTATION(0.0,0.0,text.x0,text.y0,x1,y1);
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
#ifdef HAS_CAIRO
customfont = set_text_custom_font(&text);
#endif
@ -890,7 +890,7 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
}
}
else if(what & BEGIN) i=0;
else if(what & START) i=0;
else if((what & END) && i)
{
#ifdef __unix__
@ -970,7 +970,7 @@ void drawtempline(GC gc, int what, double linex1,double liney1,double linex2,dou
}
}
else if(what & BEGIN) i=0;
else if(what & START) i=0;
else if((what & END) && i)
{
#ifdef __unix__
@ -1035,7 +1035,7 @@ void drawtemparc(GC gc, int what, double x, double y, double r, double a, double
XDrawArc(display, window, gc, xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
}
}
else if(what & BEGIN) i=0;
else if(what & START) i=0;
else if((what & END) && i)
{
XDrawArcs(display, window, gc, xarc,i);
@ -1131,7 +1131,7 @@ void filledarc(int c, int what, double x, double y, double r, double a, double b
if(draw_pixmap) XFillArc(display, save_pixmap, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64);
}
}
else if(what & BEGIN) i=0;
else if(what & START) i=0;
else if((what & END) && i)
{
if(draw_window) XFillArcs(display, window, gc[c], xarc,i);
@ -1222,7 +1222,7 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b,
}
}
}
else if(what & BEGIN) i=0;
else if(what & START) i=0;
else if((what & END) && i)
{
if(draw_window) XDrawArcs(display, window, gc[c], xarc,i);
@ -1258,7 +1258,7 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl
(unsigned int)y2 - (unsigned int)y1);
}
}
else if(what & BEGIN) i=0;
else if(what & START) i=0;
else if(what & ADD)
{
if(i>=CADDRAWBUFFERSIZE)
@ -1464,7 +1464,7 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double
}
}
}
else if(what & BEGIN) i=0;
else if(what & START) i=0;
else if(what & ADD)
{
if(i>=CADDRAWBUFFERSIZE)
@ -1517,7 +1517,7 @@ void drawtemprect(GC gc, int what, double rectx1,double recty1,double rectx2,dou
(unsigned int)y2 - (unsigned int)y1);
}
}
else if(what & BEGIN) i=0;
else if(what & START) i=0;
else if(what & ADD)
{
if(i>=CADDRAWBUFFERSIZE)

View File

@ -434,7 +434,7 @@ void edit_rect_property(void)
xctx->rect[c][n].dash = 0;
if(old_dash != xctx->rect[c][n].dash) {
if(!drw) {
bbox(BEGIN,0.0,0.0,0.0,0.0);
bbox(START,0.0,0.0,0.0,0.0);
drw = 1;
}
bbox(ADD, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2);
@ -469,7 +469,7 @@ void edit_line_property(void)
int y1, y2;
push_undo();
set_modify(1);
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
for(i=0; i<lastselected; i++) {
if(selectedgroup[i].type != LINE) continue;
c = selectedgroup[i].col;
@ -522,7 +522,7 @@ void edit_wire_property(void)
{
push_undo();
set_modify(1);
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
for(i=0; i<lastselected; i++) {
int oldbus=0;
int k = selectedgroup[i].n;
@ -613,7 +613,7 @@ void edit_arc_property(void)
if(old_fill != xctx->arc[c][i].fill || old_dash != xctx->arc[c][i].dash) {
if(!drw) {
bbox(BEGIN,0.0,0.0,0.0,0.0);
bbox(START,0.0,0.0,0.0,0.0);
drw = 1;
}
arc_bbox(xctx->arc[c][i].x, xctx->arc[c][i].y, xctx->arc[c][i].r, 0, 360, &x1,&y1,&x2,&y2);
@ -678,7 +678,7 @@ void edit_polygon_property(void)
xctx->poly[c][i].dash = 0;
if(old_fill != xctx->poly[c][i].fill || old_dash != xctx->poly[c][i].dash) {
if(!drw) {
bbox(BEGIN,0.0,0.0,0.0,0.0);
bbox(START,0.0,0.0,0.0,0.0);
drw = 1;
}
for(k=0; k<xctx->poly[c][i].points; k++) {
@ -748,7 +748,7 @@ void edit_text_property(int x)
{
dbg(1, "edit_text_property(): rcode !=\"\"\n");
set_modify(1); push_undo();
bbox(BEGIN,0.0,0.0,0.0,0.0);
bbox(START,0.0,0.0,0.0,0.0);
for(k=0;k<lastselected;k++)
{
if(selectedgroup[k].type!=xTEXT) continue;
@ -949,7 +949,7 @@ void update_symbol(const char *result, int x)
only_different=atoi(tclgetvar("preserve_unchanged_attrs") );
copy_cell=atoi(tclgetvar("user_wants_copy_cell") );
bbox(BEGIN,0.0,0.0,0.0,0.0);
bbox(START,0.0,0.0,0.0,0.0);
if(show_pin_net_names) {
prepare_netlist_structs(0);
for(k = 0; k < (xctx->inst[i].ptr + xctx->sym)->rects[PINLAYER]; k++) {

View File

@ -28,13 +28,14 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef STRINGPTR
#define STRINGPTR
typedef struct /* used in expandlabel.y */
{
char *str; /* label name */
int m; /* label multiplicity, number of wires */
} Stringptr;
#endif
#define YYERROR_VERBOSE
#define SIGN(x) ( (x) < 0 ? -1: 1 )
@ -48,7 +49,7 @@ extern FILE *errfp;
extern void *my_malloc(int id, size_t size);
extern void my_free(int id, void *ptr);
extern void my_realloc(int id, void *ptr,size_t size);
extern void my_strdup(int id, char **dest, char *src);
extern size_t my_strdup(int id, char **dest, const char *src);
extern int debug_var;
extern void dbg(int level, char *fmt, ...);
extern int my_snprintf(char *str, int size, const char *fmt, ...);

View File

@ -127,8 +127,8 @@ void find_closest_net_or_symbol_pin(double mx,double my, double *x, double *y)
if(IS_LABEL_OR_PIN(type)) no_of_pin_rects=1;
for(j=0; j<no_of_pin_rects; j++) {
box = ((xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER])[j];
ROTATION(0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(0.0,0.0,box.x2,box.y2,x2,y2);
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,box.x2,box.y2,x2,y2);
x1 += x0;
y1 += y0;
x2 += x0;

View File

@ -26,7 +26,7 @@ static struct hilight_hashentry *hilight_table[HASHSIZE];
static int nelements=0;
static int *inst_color=NULL;
static unsigned int hash(const char *tok)
static unsigned int hi_hash(const char *tok)
{
unsigned int hash = 0;
char *str;
@ -186,7 +186,7 @@ struct hilight_hashentry *hilight_lookup(const char *token, int value, int remov
int depth=0;
if(token==NULL) return NULL;
hashcode=hash(token);
hashcode=hi_hash(token);
index=hashcode % HASHSIZE;
entry=hilight_table[index];
preventry=&hilight_table[index];
@ -927,7 +927,7 @@ void redraw_hilights(void)
if(!has_x) return;
if(!big) {
calc_drawing_bbox(&boundbox, 2);
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
bbox(ADD, boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
}

View File

@ -22,8 +22,8 @@
#include "xschem.h"
static double rx1, rx2, ry1, ry2;
static int rot = 0;
static int flip = 0;
static int move_rot = 0;
static int move_flip = 0;
static double x1=0.0, y_1=0.0, x2=0.0, y_2=0.0, deltax = 0.0, deltay = 0.0;
/* static int i,c,n,k; */
static int lastsel;
@ -203,17 +203,17 @@ void draw_selection(GC g, int interruptable)
{
case xTEXT:
if(rotatelocal) {
ROTATION(xctx->text[n].x0, xctx->text[n].y0, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->text[n].x0, xctx->text[n].y0, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
} else {
ROTATION(x1, y_1, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
}
#ifdef HAS_CAIRO
customfont = set_text_custom_font(&xctx->text[n]);
#endif
draw_temp_string(g,ADD, xctx->text[n].txt_ptr,
(xctx->text[n].rot +
( (flip && (xctx->text[n].rot & 1) ) ? rot+2 : rot) ) & 0x3,
xctx->text[n].flip^flip, xctx->text[n].hcenter, xctx->text[n].vcenter,
( (move_flip && (xctx->text[n].rot & 1) ) ? move_rot+2 : move_rot) ) & 0x3,
xctx->text[n].flip^move_flip, xctx->text[n].hcenter, xctx->text[n].vcenter,
rx1+deltax, ry1+deltay,
xctx->text[n].xscale, xctx->text[n].yscale);
#ifdef HAS_CAIRO
@ -223,11 +223,11 @@ void draw_selection(GC g, int interruptable)
break;
case xRECT:
if(rotatelocal) {
ROTATION(xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
} else {
ROTATION(x1, y_1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(x1, y_1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, x1, y_1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
}
if(xctx->rect[c][n].sel==SELECTED)
{
@ -295,10 +295,10 @@ void draw_selection(GC g, int interruptable)
for(k=0;k<xctx->poly[c][n].points; k++) {
if( xctx->poly[c][n].sel==SELECTED || xctx->poly[c][n].selected_point[k]) {
if(rotatelocal) {
ROTATION(xctx->poly[c][n].x[0], xctx->poly[c][n].y[0],
ROTATION(move_rot, move_flip, xctx->poly[c][n].x[0], xctx->poly[c][n].y[0],
xctx->poly[c][n].x[k], xctx->poly[c][n].y[k], rx1,ry1);
} else {
ROTATION(x1, y_1, xctx->poly[c][n].x[k], xctx->poly[c][n].y[k], rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->poly[c][n].x[k], xctx->poly[c][n].y[k], rx1,ry1);
}
x[k] = rx1 + deltax;
y[k] = ry1 + deltay;
@ -316,11 +316,11 @@ void draw_selection(GC g, int interruptable)
case WIRE:
if(rotatelocal) {
ROTATION(xctx->wire[n].x1, xctx->wire[n].y1, xctx->wire[n].x1, xctx->wire[n].y1, rx1,ry1);
ROTATION(xctx->wire[n].x1, xctx->wire[n].y1, xctx->wire[n].x2, xctx->wire[n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, xctx->wire[n].x1, xctx->wire[n].y1, xctx->wire[n].x1, xctx->wire[n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->wire[n].x1, xctx->wire[n].y1, xctx->wire[n].x2, xctx->wire[n].y2, rx2,ry2);
} else {
ROTATION(x1, y_1, xctx->wire[n].x1, xctx->wire[n].y1, rx1,ry1);
ROTATION(x1, y_1, xctx->wire[n].x2, xctx->wire[n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, x1, y_1, xctx->wire[n].x1, xctx->wire[n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->wire[n].x2, xctx->wire[n].y2, rx2,ry2);
}
ORDER(rx1,ry1,rx2,ry2);
@ -348,11 +348,11 @@ void draw_selection(GC g, int interruptable)
break;
case LINE:
if(rotatelocal) {
ROTATION(xctx->line[c][n].x1, xctx->line[c][n].y1, xctx->line[c][n].x1, xctx->line[c][n].y1, rx1,ry1);
ROTATION(xctx->line[c][n].x1, xctx->line[c][n].y1, xctx->line[c][n].x2, xctx->line[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, xctx->line[c][n].x1, xctx->line[c][n].y1, xctx->line[c][n].x1, xctx->line[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->line[c][n].x1, xctx->line[c][n].y1, xctx->line[c][n].x2, xctx->line[c][n].y2, rx2,ry2);
} else {
ROTATION(x1, y_1, xctx->line[c][n].x1, xctx->line[c][n].y1, rx1,ry1);
ROTATION(x1, y_1, xctx->line[c][n].x2, xctx->line[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, x1, y_1, xctx->line[c][n].x1, xctx->line[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->line[c][n].x2, xctx->line[c][n].y2, rx2,ry2);
}
ORDER(rx1,ry1,rx2,ry2);
if(xctx->line[c][n].sel==SELECTED)
@ -383,13 +383,13 @@ void draw_selection(GC g, int interruptable)
rx1 = xctx->arc[c][n].x;
ry1 = xctx->arc[c][n].y;
} else {
ROTATION(x1, y_1, xctx->arc[c][n].x, xctx->arc[c][n].y, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->arc[c][n].x, xctx->arc[c][n].y, rx1,ry1);
}
angle = xctx->arc[c][n].a;
if(flip) {
angle = 270.*rot+180.-xctx->arc[c][n].b-xctx->arc[c][n].a;
if(move_flip) {
angle = 270.*move_rot+180.-xctx->arc[c][n].b-xctx->arc[c][n].a;
} else {
angle = xctx->arc[c][n].a+rot*270.;
angle = xctx->arc[c][n].a+move_rot*270.;
}
angle = fmod(angle, 360.);
if(angle<0.) angle+=360.;
@ -410,13 +410,13 @@ void draw_selection(GC g, int interruptable)
break;
case ELEMENT:
if(rotatelocal) {
ROTATION(xctx->inst[n].x0, xctx->inst[n].y0, xctx->inst[n].x0, xctx->inst[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->inst[n].x0, xctx->inst[n].y0, xctx->inst[n].x0, xctx->inst[n].y0, rx1,ry1);
} else {
ROTATION(x1, y_1, xctx->inst[n].x0, xctx->inst[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->inst[n].x0, xctx->inst[n].y0, rx1,ry1);
}
for(k=0;k<cadlayers;k++)
draw_temp_symbol(ADD, g, n, k, flip,
( flip && (xctx->inst[n].rot & 1) ) ? rot+2 : rot,
draw_temp_symbol(ADD, g, n, k, move_flip,
( move_flip && (xctx->inst[n].rot & 1) ) ? move_rot+2 : move_rot,
rx1-xctx->inst[n].x0+deltax,ry1-xctx->inst[n].y0+deltay);
break;
}
@ -506,28 +506,28 @@ void copy_objects(int what)
/* int customfont; */
#endif
if(what & BEGIN)
if(what & START)
{
rotatelocal=0;
dbg(1, "copy_objects(): BEGIN copy\n");
dbg(1, "copy_objects(): START copy\n");
rebuild_selected_array();
save_selection(1);
deltax = deltay = 0.0;
lastsel = lastselected;
x1=mousex_snap;y_1=mousey_snap;
flip = 0;rot = 0;
move_flip = 0;move_rot = 0;
ui_state|=STARTCOPY;
}
if(what & ABORT) /* draw objects while moving */
{
char *str = NULL; /* 20161122 overflow safe */
draw_selection(gctiled,0);
rot=flip=deltax=deltay=0;
move_rot=move_flip=deltax=deltay=0;
ui_state&=~STARTCOPY;
my_strdup(225, &str, user_conf_dir);
my_strcat(226, &str, "/.selection.sch");
xunlink(str);
update_symbol_bboxes(rot, flip);
update_symbol_bboxes(move_rot, move_flip);
my_free(818, &str);
}
if(what & RUBBER) /* draw objects while moving */
@ -542,26 +542,26 @@ void copy_objects(int what)
}
if(what & ROTATE) {
draw_selection(gctiled,0);
rot= (rot+1) & 0x3;
update_symbol_bboxes(rot, flip);
move_rot= (move_rot+1) & 0x3;
update_symbol_bboxes(move_rot, move_flip);
}
if(what & FLIP)
{
draw_selection(gctiled,0);
flip = !flip;
update_symbol_bboxes(rot, flip);
move_flip = !move_flip;
update_symbol_bboxes(move_rot, move_flip);
}
if(what & END) /* copy selected objects */
{
int firstw, firsti;
int save_draw;
/* if the copy operation involved flip or rotations the original element bboxes were changed.
/* if the copy operation involved move_flip or rotations the original element bboxes were changed.
restore them now */
update_symbol_bboxes(0, 0);
save_draw = draw_window;
draw_window=1; /* temporarily re-enable draw to window together with pixmap */
draw_selection(gctiled,0);
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
newpropcnt=0;
set_modify(1); push_undo(); /* 20150327 push_undo */
firstw = firsti = 1;
@ -591,11 +591,11 @@ void copy_objects(int what)
}
*/
if(rotatelocal) {
ROTATION(xctx->wire[n].x1, xctx->wire[n].y1, xctx->wire[n].x1, xctx->wire[n].y1, rx1,ry1);
ROTATION(xctx->wire[n].x1, xctx->wire[n].y1, xctx->wire[n].x2, xctx->wire[n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, xctx->wire[n].x1, xctx->wire[n].y1, xctx->wire[n].x1, xctx->wire[n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->wire[n].x1, xctx->wire[n].y1, xctx->wire[n].x2, xctx->wire[n].y2, rx2,ry2);
} else {
ROTATION(x1, y_1, xctx->wire[n].x1, xctx->wire[n].y1, rx1,ry1);
ROTATION(x1, y_1, xctx->wire[n].x2, xctx->wire[n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, x1, y_1, xctx->wire[n].x1, xctx->wire[n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->wire[n].x2, xctx->wire[n].y2, rx2,ry2);
}
if( xctx->wire[n].sel & (SELECTED|SELECTED1) )
{
@ -638,11 +638,11 @@ void copy_objects(int what)
if(c!=k) break;
/* bbox(ADD, xctx->line[c][n].x1, xctx->line[c][n].y1, xctx->line[c][n].x2, xctx->line[c][n].y2) */
if(rotatelocal) {
ROTATION(xctx->line[c][n].x1, xctx->line[c][n].y1, xctx->line[c][n].x1, xctx->line[c][n].y1, rx1,ry1);
ROTATION(xctx->line[c][n].x1, xctx->line[c][n].y1, xctx->line[c][n].x2, xctx->line[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, xctx->line[c][n].x1, xctx->line[c][n].y1, xctx->line[c][n].x1, xctx->line[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->line[c][n].x1, xctx->line[c][n].y1, xctx->line[c][n].x2, xctx->line[c][n].y2, rx2,ry2);
} else {
ROTATION(x1, y_1, xctx->line[c][n].x1, xctx->line[c][n].y1, rx1,ry1);
ROTATION(x1, y_1, xctx->line[c][n].x2, xctx->line[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, x1, y_1, xctx->line[c][n].x1, xctx->line[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->line[c][n].x2, xctx->line[c][n].y2, rx2,ry2);
}
if( xctx->line[c][n].sel & (SELECTED|SELECTED1) )
{
@ -688,9 +688,9 @@ void copy_objects(int what)
*/
if( p->sel==SELECTED || p->selected_point[j]) {
if(rotatelocal) {
ROTATION(p->x[0], p->y[0], p->x[j], p->y[j], rx1,ry1);
ROTATION(move_rot, move_flip, p->x[0], p->y[0], p->x[j], p->y[j], rx1,ry1);
} else {
ROTATION(x1, y_1, p->x[j], p->y[j], rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, p->x[j], p->y[j], rx1,ry1);
}
x[j] = rx1+deltax;
y[j] = ry1+deltay;
@ -720,13 +720,13 @@ void copy_objects(int what)
rx1 = xctx->arc[c][n].x;
ry1 = xctx->arc[c][n].y;
} else {
ROTATION(x1, y_1, xctx->arc[c][n].x, xctx->arc[c][n].y, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->arc[c][n].x, xctx->arc[c][n].y, rx1,ry1);
}
angle = xctx->arc[c][n].a;
if(flip) {
angle = 270.*rot+180.-xctx->arc[c][n].b-xctx->arc[c][n].a;
if(move_flip) {
angle = 270.*move_rot+180.-xctx->arc[c][n].b-xctx->arc[c][n].a;
} else {
angle = xctx->arc[c][n].a+rot*270.;
angle = xctx->arc[c][n].a+move_rot*270.;
}
angle = fmod(angle, 360.);
if(angle<0.) angle+=360.;
@ -745,11 +745,11 @@ void copy_objects(int what)
if(c!=k) break;
/* bbox(ADD, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2); */
if(rotatelocal) {
ROTATION(xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
} else {
ROTATION(x1, y_1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(x1, y_1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, x1, y_1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
}
RECTORDER(rx1,ry1,rx2,ry2);
xctx->rect[c][n].sel=0;
@ -777,9 +777,9 @@ void copy_objects(int what)
bbox(ADD, rx1, ry1, rx2, ry2 );
*/
if(rotatelocal) {
ROTATION(xctx->text[n].x0, xctx->text[n].y0, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->text[n].x0, xctx->text[n].y0, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
} else {
ROTATION(x1, y_1, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
}
xctx->text[xctx->texts].txt_ptr=NULL;
my_strdup(229, &xctx->text[xctx->texts].txt_ptr,xctx->text[n].txt_ptr);
@ -789,8 +789,8 @@ void copy_objects(int what)
xctx->text[xctx->texts].x0=rx1+deltax;
xctx->text[xctx->texts].y0=ry1+deltay;
xctx->text[xctx->texts].rot=(xctx->text[n].rot +
( (flip && (xctx->text[n].rot & 1) ) ? rot+2 : rot) ) & 0x3;
xctx->text[xctx->texts].flip=flip^xctx->text[n].flip;
( (move_flip && (xctx->text[n].rot & 1) ) ? move_rot+2 : move_rot) ) & 0x3;
xctx->text[xctx->texts].flip=move_flip^xctx->text[n].flip;
xctx->text[xctx->texts].sel=SELECTED;
xctx->text[xctx->texts].prop_ptr=NULL;
xctx->text[xctx->texts].font=NULL;
@ -864,9 +864,9 @@ void copy_objects(int what)
}
check_inst_storage();
if(rotatelocal) {
ROTATION(xctx->inst[n].x0, xctx->inst[n].y0, xctx->inst[n].x0, xctx->inst[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->inst[n].x0, xctx->inst[n].y0, xctx->inst[n].x0, xctx->inst[n].y0, rx1,ry1);
} else {
ROTATION(x1, y_1, xctx->inst[n].x0, xctx->inst[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->inst[n].x0, xctx->inst[n].y0, rx1,ry1);
}
xctx->inst[xctx->instances] = xctx->inst[n];
xctx->inst[xctx->instances].prop_ptr=NULL;
@ -883,8 +883,8 @@ void copy_objects(int what)
xctx->inst[xctx->instances].y0 = ry1+deltay;
xctx->inst[xctx->instances].sel = SELECTED;
xctx->inst[xctx->instances].rot = (xctx->inst[xctx->instances].rot +
( (flip && (xctx->inst[xctx->instances].rot & 1) ) ? rot+2 : rot) ) & 0x3;
xctx->inst[xctx->instances].flip = (flip? !xctx->inst[n].flip:xctx->inst[n].flip);
( (move_flip && (xctx->inst[xctx->instances].rot & 1) ) ? move_rot+2 : move_rot) ) & 0x3;
xctx->inst[xctx->instances].flip = (move_flip? !xctx->inst[n].flip:xctx->inst[n].flip);
/* the newpropcnt argument is zero for the 1st call and used in */
/* new_prop_string() for cleaning some internal caches. */
if(!newpropcnt) hash_all_names(xctx->instances);
@ -943,7 +943,7 @@ void copy_objects(int what)
check_collapsing_objects();
update_conn_cues(1, 1);
ui_state &= ~STARTCOPY;
x1=y_1=x2=y_2=rot=flip=deltax=deltay=0;
x1=y_1=x2=y_2=move_rot=move_flip=deltax=deltay=0;
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
draw();
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);
@ -973,7 +973,7 @@ void move_objects(int what, int merge, double dx, double dy)
xLine ** const line = xctx->line;
xWire * const wire = xctx->wire;
if(what & BEGIN)
if(what & START)
{
rotatelocal=0;
deltax = deltay = 0.0;
@ -984,13 +984,13 @@ void move_objects(int what, int merge, double dx, double dy)
x1 = xctx->arc[c][n].x;
y_1 = xctx->arc[c][n].y;
} else {x1=mousex_snap;y_1=mousey_snap;}
flip = 0;rot = 0;
move_flip = 0;move_rot = 0;
ui_state|=STARTMOVE;
}
if(what & ABORT) /* draw objects while moving */
{
draw_selection(gctiled,0);
rot=flip=deltax=deltay=0;
move_rot=move_flip=deltax=deltay=0;
ui_state &= ~STARTMOVE;
ui_state &= ~PLACE_SYMBOL;
update_symbol_bboxes(0, 0);
@ -1007,14 +1007,14 @@ void move_objects(int what, int merge, double dx, double dy)
}
if(what & ROTATE) {
draw_selection(gctiled,0);
rot= (rot+1) & 0x3;
update_symbol_bboxes(rot, flip);
move_rot= (move_rot+1) & 0x3;
update_symbol_bboxes(move_rot, move_flip);
}
if(what & FLIP)
{
draw_selection(gctiled,0);
flip = !flip;
update_symbol_bboxes(rot, flip);
move_flip = !move_flip;
update_symbol_bboxes(move_rot, move_flip);
}
if(what & END) /* move selected objects */
{
@ -1023,7 +1023,7 @@ void move_objects(int what, int merge, double dx, double dy)
save_draw = draw_window;
draw_window=1; /* temporarily re-enable draw to window together with pixmap */
draw_selection(gctiled,0);
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
set_modify(1);
if( !(ui_state & (STARTMERGE | PLACE_SYMBOL)) ) {
dbg(1, "move_objects(): push undo state\n");
@ -1087,11 +1087,11 @@ void move_objects(int what, int merge, double dx, double dy)
bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 );
}
if(rotatelocal) {
ROTATION(wire[n].x1, wire[n].y1, wire[n].x1, wire[n].y1, rx1,ry1);
ROTATION(wire[n].x1, wire[n].y1, wire[n].x2, wire[n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, wire[n].x1, wire[n].y1, wire[n].x1, wire[n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, wire[n].x1, wire[n].y1, wire[n].x2, wire[n].y2, rx2,ry2);
} else {
ROTATION(x1, y_1, wire[n].x1, wire[n].y1, rx1,ry1);
ROTATION(x1, y_1, wire[n].x2, wire[n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, x1, y_1, wire[n].x1, wire[n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, wire[n].x2, wire[n].y2, rx2,ry2);
}
if( wire[n].sel & (SELECTED|SELECTED1) )
@ -1127,11 +1127,11 @@ void move_objects(int what, int merge, double dx, double dy)
if(c!=k) break;
bbox(ADD, line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2);
if(rotatelocal) {
ROTATION(line[c][n].x1, line[c][n].y1, line[c][n].x1, line[c][n].y1, rx1,ry1);
ROTATION(line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, line[c][n].x1, line[c][n].y1, line[c][n].x1, line[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, line[c][n].x1, line[c][n].y1, line[c][n].x2, line[c][n].y2, rx2,ry2);
} else {
ROTATION(x1, y_1, line[c][n].x1, line[c][n].y1, rx1,ry1);
ROTATION(x1, y_1, line[c][n].x2, line[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, x1, y_1, line[c][n].x1, line[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, line[c][n].x2, line[c][n].y2, rx2,ry2);
}
if( line[c][n].sel & (SELECTED|SELECTED1) )
@ -1181,9 +1181,9 @@ void move_objects(int what, int merge, double dx, double dy)
if( p->sel==SELECTED || p->selected_point[j]) {
if(rotatelocal) {
ROTATION(savex0, savey0, p->x[j], p->y[j], rx1,ry1);
ROTATION(move_rot, move_flip, savex0, savey0, p->x[j], p->y[j], rx1,ry1);
} else {
ROTATION(x1, y_1, p->x[j], p->y[j], rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, p->x[j], p->y[j], rx1,ry1);
}
p->x[j] = rx1+deltax;
@ -1212,13 +1212,13 @@ void move_objects(int what, int merge, double dx, double dy)
rx1 = xctx->arc[c][n].x;
ry1 = xctx->arc[c][n].y;
} else {
ROTATION(x1, y_1, xctx->arc[c][n].x, xctx->arc[c][n].y, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->arc[c][n].x, xctx->arc[c][n].y, rx1,ry1);
}
angle = xctx->arc[c][n].a;
if(flip) {
angle = 270.*rot+180.-xctx->arc[c][n].b-xctx->arc[c][n].a;
if(move_flip) {
angle = 270.*move_rot+180.-xctx->arc[c][n].b-xctx->arc[c][n].a;
} else {
angle = xctx->arc[c][n].a+rot*270.;
angle = xctx->arc[c][n].a+move_rot*270.;
}
angle = fmod(angle, 360.);
if(angle<0.) angle+=360.;
@ -1254,11 +1254,11 @@ void move_objects(int what, int merge, double dx, double dy)
if(c!=k) break;
bbox(ADD, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2);
if(rotatelocal) {
ROTATION(xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
} else {
ROTATION(x1, y_1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(x1, y_1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
ROTATION(move_rot, move_flip, x1, y_1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->rect[c][n].x2, xctx->rect[c][n].y2, rx2,ry2);
}
if( xctx->rect[c][n].sel == SELECTED) {
@ -1342,16 +1342,16 @@ void move_objects(int what, int merge, double dx, double dy)
bbox(ADD, rx1, ry1, rx2, ry2 );
if(rotatelocal) {
ROTATION(xctx->text[n].x0, xctx->text[n].y0, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, xctx->text[n].x0, xctx->text[n].y0, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
} else {
ROTATION(x1, y_1, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, xctx->text[n].x0, xctx->text[n].y0, rx1,ry1);
}
xctx->text[n].x0=rx1+deltax;
xctx->text[n].y0=ry1+deltay;
xctx->text[n].rot=(xctx->text[n].rot +
( (flip && (xctx->text[n].rot & 1) ) ? rot+2 : rot) ) & 0x3;
xctx->text[n].flip=flip^xctx->text[n].flip;
( (move_flip && (xctx->text[n].rot & 1) ) ? move_rot+2 : move_rot) ) & 0x3;
xctx->text[n].flip=move_flip^xctx->text[n].flip;
textlayer = xctx->text[n].layer;
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
@ -1394,15 +1394,15 @@ void move_objects(int what, int merge, double dx, double dy)
firsti = 0;
}
if(rotatelocal) {
ROTATION(inst[n].x0, inst[n].y0, inst[n].x0, inst[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, inst[n].x0, inst[n].y0, inst[n].x0, inst[n].y0, rx1,ry1);
} else {
ROTATION(x1, y_1, inst[n].x0, inst[n].y0, rx1,ry1);
ROTATION(move_rot, move_flip, x1, y_1, inst[n].x0, inst[n].y0, rx1,ry1);
}
inst[n].x0 = rx1+deltax;
inst[n].y0 = ry1+deltay;
inst[n].rot = (inst[n].rot +
( (flip && (inst[n].rot & 1) ) ? rot+2 : rot) ) & 0x3;
inst[n].flip = flip ^ inst[n].flip;
( (move_flip && (inst[n].rot & 1) ) ? move_rot+2 : move_rot) ) & 0x3;
inst[n].flip = move_flip ^ inst[n].flip;
}
break;
@ -1450,7 +1450,7 @@ void move_objects(int what, int merge, double dx, double dy)
update_conn_cues(1, 1);
ui_state &= ~STARTMOVE;
ui_state &= ~STARTMERGE;
x1=y_1=x2=y_2=rot=flip=deltax=deltay=0;
x1=y_1=x2=y_2=move_rot=move_flip=deltax=deltay=0;
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
dbg(2, "move_objects(): bbox= %d %d %d %d\n", areax1, areay1, areaw, areah);
draw();

View File

@ -297,7 +297,7 @@ void hash_inst_pin(int what, int i, int j)
}
rot=xctx->inst[i].rot;
flip=xctx->inst[i].flip;
ROTATION(0.0,0.0,x0,y0,rx1,ry1);
ROTATION(rot, flip, 0.0,0.0,x0,y0,rx1,ry1);
x0=xctx->inst[i].x0+rx1;
y0=xctx->inst[i].y0+ry1;
get_square(x0, y0, &sqx, &sqy);
@ -774,7 +774,7 @@ void prepare_netlist_structs(int for_netlist)
y0=(rct[0].y1+rct[0].y2)/2;
rot=inst[i].rot;
flip=inst[i].flip;
ROTATION(0.0,0.0,x0,y0,rx1,ry1);
ROTATION(rot, flip, 0.0,0.0,x0,y0,rx1,ry1);
x0=inst[i].x0+rx1;
y0=inst[i].y0+ry1;
get_square(x0, y0, &sqx, &sqy);
@ -837,7 +837,7 @@ void prepare_netlist_structs(int for_netlist)
y0=(rct[j-rects].y1+rct[j-rects].y2)/2;
rot=inst[i].rot;
flip=inst[i].flip;
ROTATION(0.0,0.0,x0,y0,rx1,ry1);
ROTATION(rot, flip, 0.0,0.0,x0,y0,rx1,ry1);
x0=inst[i].x0+rx1;
y0=inst[i].y0+ry1;
get_square(x0, y0, &sqx, &sqy);
@ -908,7 +908,7 @@ void prepare_netlist_structs(int for_netlist)
y0=(rct[j].y1+rct[j].y2)/2;
rot=inst[i].rot;
flip=inst[i].flip;
ROTATION(0.0,0.0,x0,y0,rx1,ry1);
ROTATION(rot, flip, 0.0,0.0,x0,y0,rx1,ry1);
x0=inst[i].x0+rx1;
y0=inst[i].y0+ry1;
get_square(x0, y0, &sqx, &sqy);

View File

@ -24,7 +24,7 @@
static struct node_hashentry *node_table[HASHSIZE];
static unsigned int hash(const char *tok)
static unsigned int nh_hash(const char *tok)
{
unsigned int hash = 0;
int c;
@ -250,7 +250,7 @@ struct node_hashentry *node_hash_lookup(const char *token, const char *dir,int w
else if(!strcmp(dir,"out") ) d.out=1;
else if(!strcmp(dir,"inout") ) d.inout=1;
d.port=port;
hashcode=hash(token);
hashcode=nh_hash(token);
index=hashcode % HASHSIZE;
entry=node_table[index];
preventry=&node_table[index];

View File

@ -36,19 +36,21 @@ int dbg_var = 0;
extern int netlist_type;
extern int has_x;
extern FILE *errfp;
extern void my_strdup(int id, char **dest, char *src);
extern size_t my_strdup(int id, char **dest, const char *src);
extern void my_free(int id, void *ptr);
extern char bus_replacement_char[];
extern void tcleval(const char str[]);
extern const char *tcleval(const char str[]);
extern void *my_malloc(int id, size_t size);
extern int my_snprintf(char *str, int size, const char *fmt, ...);
#ifndef STRINGPTR
#define STRINGPTR
typedef struct /* used in expandlabel.y */
{
char *str; /* label name */
int m; /* label multiplicity, number of wires */
} Stringptr;
#endif
/* commented 20170412, fixes problems with older bison/flex versions */
/* #define YYPARSE_PARAM */
#include "expandlabel.h" /* Bison header file */
@ -121,7 +123,7 @@ const char *expandlabel(const char *s, int *m)
Lexical analyzer
*/
%x label
%x net_label
%x next_to_alias
%x rest
@ -142,7 +144,7 @@ ID_EXT_PARENTHESIS [-~#+/=_a-zA-Z][-#@\\/:.=_+a-zA-Z0-9]*\([-#@\\/:.=_+a-zA-Z0-9
return B_LINE;
}
<next_to_alias>[\n +]+ { /* get all white space and return a single separator */
BEGIN(label);
BEGIN(net_label);
if(dbg_var >= 3) fprintf(errfp, "yylex(): next_to_alias, yytext = %s\n", yytext);
yylval.val=yytext[0];
return B_CAR;
@ -150,7 +152,7 @@ ID_EXT_PARENTHESIS [-~#+/=_a-zA-Z][-#@\\/:.=_+a-zA-Z0-9]*\([-#@\\/:.=_+a-zA-Z0-9
^[^*] {
if(dbg_var >= 3) fprintf(errfp, "yylex(): matched: ^[^*] |%s|, push back\n",yytext);
yyless(0); /* push entire token back to input */
BEGIN(label); /* we know that a label follows. */
BEGIN(net_label); /* we know that a label follows. */
/* so go and process it. */
}
^\*.* { /* a comment, return as LINE token */
@ -159,9 +161,9 @@ ID_EXT_PARENTHESIS [-~#+/=_a-zA-Z][-#@\\/:.=_+a-zA-Z0-9]*\([-#@\\/:.=_+a-zA-Z0-9
my_strdup(299, &yylval.ptr.str, yytext); /* freed after use in expandlabel.y */
return B_LINE;
}
<label>{
<net_label>{
[ \n]+ { /* this ends the <label> start condition */
[ \n]+ { /* this ends the <net_label> start condition */
BEGIN(rest);
yylval.val=yytext[0];
if(dbg_var >= 3) fprintf(errfp, "yylex(): B_CAR: %s\n",yytext);
@ -234,7 +236,7 @@ ID_EXT_PARENTHESIS [-~#+/=_a-zA-Z][-#@\\/:.=_+a-zA-Z0-9]*\([-#@\\/:.=_+a-zA-Z0-9
if(dbg_var >= 3) fprintf(errfp, "yylex(): returning character: %s\n", yytext);
return yytext[0];
}
} /* end <label> */
} /* end <net_label> */
<rest>{ /* treat rest of line as a single LINE token */
(.|\n)* {

View File

@ -395,7 +395,7 @@ void merge_file(int selection_load, const char ext[])
ui_state |= STARTMERGE;
dbg(1, "merge_file(): loaded file:wire=%d inst=%d ui_state=%ld\n",
xctx->wires , xctx->instances, ui_state);
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
mousex_snap = mx_double_save;
mousey_snap = my_double_save;
move_objects(RUBBER,0,0,0);

View File

@ -242,8 +242,8 @@ static void ps_draw_string(int gctext, const char *str,
curr_y1 = ( character[cc][i+2] ) * yscale+yy;
curr_x2 = ( character[cc][i+3]+ a ) * xscale + x1;
curr_y2 = ( character[cc][i+4] ) * yscale+yy;
ROTATION(x1,y1,curr_x1,curr_y1,rx1,ry1);
ROTATION(x1,y1,curr_x2,curr_y2,rx2,ry2);
ROTATION(rot, flip, x1,y1,curr_x1,curr_y1,rx1,ry1);
ROTATION(rot, flip, x1,y1,curr_x2,curr_y2,rx2,ry2);
ORDER(rx1,ry1,rx2,ry2);
ps_drawline(gctext, rx1, ry1, rx2, ry2, 0);
}
@ -328,8 +328,8 @@ static void ps_draw_symbol(int n,int layer,int tmp_flip, int rot,
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->lines[layer];j++)
{
line = ((xctx->inst[n].ptr+ xctx->sym)->line[layer])[j];
ROTATION(0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(0.0,0.0,line.x2,line.y2,x2,y2);
ROTATION(rot, flip, 0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2);
ORDER(x1,y1,x2,y2);
ps_drawline(layer, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
}
@ -341,7 +341,7 @@ static void ps_draw_symbol(int n,int layer,int tmp_flip, int rot,
double *x = my_malloc(309, sizeof(double) * polygon.points);
double *y = my_malloc(310, sizeof(double) * polygon.points);
for(k=0;k<polygon.points;k++) {
ROTATION(0.0,0.0,polygon.x[k],polygon.y[k],x[k],y[k]);
ROTATION(rot, flip, 0.0,0.0,polygon.x[k],polygon.y[k],x[k],y[k]);
x[k]+= x0;
y[k] += y0;
}
@ -362,14 +362,14 @@ static void ps_draw_symbol(int n,int layer,int tmp_flip, int rot,
}
angle = fmod(angle, 360.);
if(angle<0.) angle+=360.;
ROTATION(0.0,0.0,arc.x,arc.y,x1,y1);
ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1);
ps_drawarc(layer, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash);
}
if( (layer != PINLAYER || enable_layer[layer]) ) for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->rects[layer];j++)
{
box = ((xctx->inst[n].ptr+ xctx->sym)->rect[layer])[j];
ROTATION(0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(0.0,0.0,box.x2,box.y2,x2,y2);
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,box.x2,box.y2,x2,y2);
RECTORDER(x1,y1,x2,y2);
ps_filledrect(layer, x0+x1, y0+y1, x0+x2, y0+y2, box.dash);
}
@ -382,7 +382,7 @@ static void ps_draw_symbol(int n,int layer,int tmp_flip, int rot,
text = (xctx->inst[n].ptr+ xctx->sym)->text[j];
/* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */
txtptr= translate(n, text.txt_ptr);
ROTATION(0.0,0.0,text.x0,text.y0,x1,y1);
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
textlayer = layer;
if( !(layer == PINLAYER && (xctx->inst[n].flags & 4))) {
textlayer = (xctx->inst[n].ptr+ xctx->sym)->text[j].layer;

View File

@ -1667,8 +1667,8 @@ int load_sym_def(const char *name, FILE *embed_fd)
}
if (level>0) {
rot = lcc[level].rot; flip = lcc[level].flip;
ROTATION(0.0, 0.0, ll[c][i].x1, ll[c][i].y1, rx1, ry1);
ROTATION(0.0, 0.0, ll[c][i].x2, ll[c][i].y2, rx2, ry2);
ROTATION(rot, flip, 0.0, 0.0, ll[c][i].x1, ll[c][i].y1, rx1, ry1);
ROTATION(rot, flip, 0.0, 0.0, ll[c][i].x2, ll[c][i].y2, rx2, ry2);
ll[c][i].x1 = lcc[level].x0 + rx1; ll[c][i].y1 = lcc[level].y0 + ry1;
ll[c][i].x2 = lcc[level].x0 + rx2; ll[c][i].y2 = lcc[level].y0 + ry2;
}
@ -1712,7 +1712,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
}
if (level>0) {
rot = lcc[level].rot; flip = lcc[level].flip;
ROTATION(0.0, 0.0, pp[c][i].x[k], pp[c][i].y[k], rx1, ry1);
ROTATION(rot, flip, 0.0, 0.0, pp[c][i].x[k], pp[c][i].y[k], rx1, ry1);
pp[c][i].x[k] = lcc[level].x0 + rx1; pp[c][i].y[k] = lcc[level].y0 + ry1;
}
}
@ -1759,7 +1759,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
}
angle = fmod(angle, 360.);
if (angle < 0.) angle += 360.;
ROTATION(0.0, 0.0, aa[c][i].x, aa[c][i].y, rx1, ry1);
ROTATION(rot, flip, 0.0, 0.0, aa[c][i].x, aa[c][i].y, rx1, ry1);
aa[c][i].x = lcc[level].x0 + rx1; aa[c][i].y = lcc[level].y0 + ry1;
aa[c][i].a = angle;
}
@ -1793,8 +1793,8 @@ int load_sym_def(const char *name, FILE *embed_fd)
&bb[c][i].x2, &bb[c][i].y2);
if (level>0) {
rot = lcc[level].rot; flip = lcc[level].flip;
ROTATION(0.0, 0.0, bb[c][i].x1, bb[c][i].y1, rx1, ry1);
ROTATION(0.0, 0.0, bb[c][i].x2, bb[c][i].y2, rx2, ry2);
ROTATION(rot, flip, 0.0, 0.0, bb[c][i].x1, bb[c][i].y1, rx1, ry1);
ROTATION(rot, flip, 0.0, 0.0, bb[c][i].x2, bb[c][i].y2, rx2, ry2);
bb[c][i].x1 = lcc[level].x0 + rx1; bb[c][i].y1 = lcc[level].y0 + ry1;
bb[c][i].x2 = lcc[level].x0 + rx2; bb[c][i].y2 = lcc[level].y0 + ry2;
}
@ -1823,7 +1823,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
const char* tmp = translate2(lcc, level, tt[i].txt_ptr);
rot = lcc[level].rot; flip = lcc[level].flip;
if (tmp) my_strdup(651, &tt[i].txt_ptr, tmp);
ROTATION(0.0, 0.0, tt[i].x0, tt[i].y0, rx1, ry1);
ROTATION(rot, flip, 0.0, 0.0, tt[i].x0, tt[i].y0, rx1, ry1);
tt[i].x0 = lcc[level].x0 + rx1; tt[i].y0 = lcc[level].y0 + ry1;
tt[i].rot = (tt[i].rot + ((lcc[level].flip && (tt[i].rot & 1)) ? lcc[level].rot + 2 : lcc[level].rot)) & 0x3;
tt[i].flip = lcc[level].flip ^ tt[i].flip;
@ -1863,8 +1863,8 @@ int load_sym_def(const char *name, FILE *embed_fd)
}
if (level>0) {
rot = lcc[level].rot; flip = lcc[level].flip;
ROTATION(0.0, 0.0, ll[WIRELAYER][i].x1, ll[WIRELAYER][i].y1, rx1, ry1);
ROTATION(0.0, 0.0, ll[WIRELAYER][i].x2, ll[WIRELAYER][i].y2, rx2, ry2);
ROTATION(rot, flip, 0.0, 0.0, ll[WIRELAYER][i].x1, ll[WIRELAYER][i].y1, rx1, ry1);
ROTATION(rot, flip, 0.0, 0.0, ll[WIRELAYER][i].x2, ll[WIRELAYER][i].y2, rx2, ry2);
ll[WIRELAYER][i].x1 = lcc[level].x0 + rx1; ll[WIRELAYER][i].y1 = lcc[level].y0 + ry1;
ll[WIRELAYER][i].x2 = lcc[level].x0 + rx2; ll[WIRELAYER][i].y2 = lcc[level].y0 + ry2;
}
@ -1978,7 +1978,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
flip = lcc[level-1].flip;
rot = lcc[level-1].rot;
ROTATION(0.0, 0.0, lcc[level].x0, lcc[level].y0,lcc[level].x0, lcc[level].y0);
ROTATION(rot, flip, 0.0, 0.0, lcc[level].x0, lcc[level].y0,lcc[level].x0, lcc[level].y0);
lcc[level].rot = (lcc[(level-1)].flip ? map[lcc[level].rot] : lcc[level].rot) + lcc[(level-1)].rot;
lcc[level].rot &= 0x3;
lcc[level].flip = lcc[level].flip ^ lcc[level-1].flip;

View File

@ -204,7 +204,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
xRECT, PINLAYER, SELECTED, "name=XXX\ndir=inout");
need_rebuild_selected_array=1;
rebuild_selected_array();
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
ui_state |= START_SYMPIN;
Tcl_ResetResult(interp);
}
@ -320,7 +320,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(ret) {
mousey_snap = my_double_save;
mousex_snap = mx_double_save;
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
ui_state |= PLACE_SYMBOL;
}
semaphore--;
@ -331,7 +331,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
{
ui_state |= MENUSTARTTEXT;
/* place_text(0,mousex_snap, mousey_snap); */
/* move_objects(BEGIN,0,0,0); */
/* move_objects(START,0,0,0); */
Tcl_ResetResult(interp);
}
@ -361,17 +361,17 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"copy_objects"))
{
copy_objects(BEGIN);
copy_objects(START);
Tcl_ResetResult(interp);
}
else if(!strcmp(argv[1],"move_objects"))
{
if(argc==4) {
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
move_objects( END,0,atof(argv[2]), atof(argv[3]));
}
else move_objects(BEGIN,0,0,0);
else move_objects(START,0,0,0);
Tcl_ResetResult(interp);
}
@ -484,7 +484,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
draw();
bbox(END , 0.0 , 0.0 , 0.0 , 0.0);
} else if(!strcmp(argv[2], "begin")) {
bbox(BEGIN,0.0, 0.0, 0.0, 0.0);
bbox(START,0.0, 0.0, 0.0, 0.0);
}
}
Tcl_ResetResult(interp);
@ -515,7 +515,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
return TCL_ERROR;
} else {
if(!fast) {
bbox(BEGIN,0.0,0.0,0.0,0.0);
bbox(START,0.0,0.0,0.0,0.0);
symbol_bbox(inst, &xctx->inst[inst].x1, &xctx->inst[inst].y1, &xctx->inst[inst].x2, &xctx->inst[inst].y2);
bbox(ADD, xctx->inst[inst].x1, xctx->inst[inst].y1, xctx->inst[inst].x2, xctx->inst[inst].y2);
push_undo();
@ -567,7 +567,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
char *name=NULL;
char *ptr=NULL;
bbox(BEGIN,0.0,0.0,0.0,0.0);
bbox(START,0.0,0.0,0.0,0.0);
my_strncpy(symbol, argv[4], S(symbol));
push_undo();
set_modify(1);
@ -1431,7 +1431,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
delete_hilight_net();
/* undraw_hilight_net(1); */
if(!big) {
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
bbox(ADD, boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
}
@ -1471,7 +1471,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
{
if(! (ui_state & (STARTMOVE | STARTCOPY) ) ) {
rebuild_selected_array();
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
move_objects(FLIP|ROTATELOCAL,0,0,0);
move_objects(END,0,0,0);
}
@ -1487,7 +1487,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(! (ui_state & (STARTMOVE | STARTCOPY) ) ) {
rebuild_selected_array();
move_objects(BEGIN,0,0,0);
move_objects(START,0,0,0);
move_objects(ROTATE|ROTATELOCAL,0,0,0);
move_objects(END,0,0,0);
}

View File

@ -22,8 +22,8 @@
#include "xschem.h"
static int rot = 0;
static int flip = 0;
static int select_rot = 0;
static int select_flip = 0;
static double xx1,yy1,xx2,yy2;
@ -48,9 +48,9 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
rot = xctx->inst[i].rot;
x0=xctx->inst[i].x0;
y0=xctx->inst[i].y0;
ROTATION(0.0,0.0,(xctx->inst[i].ptr+ xctx->sym)->minx,
ROTATION(rot, flip, 0.0,0.0,(xctx->inst[i].ptr+ xctx->sym)->minx,
(xctx->inst[i].ptr+ xctx->sym)->miny,*x1,*y1);
ROTATION(0.0,0.0,(xctx->inst[i].ptr+ xctx->sym)->maxx,
ROTATION(rot, flip, 0.0,0.0,(xctx->inst[i].ptr+ xctx->sym)->maxx,
(xctx->inst[i].ptr+ xctx->sym)->maxy,*x2,*y2);
RECTORDER(*x1,*y1,*x2,*y2);
*x1+=x0;*y1+=y0;
@ -73,7 +73,7 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
tmp_txt = translate(i, text.txt_ptr);
dbg(2, "symbol_bbox(): translated text: %s\n", tmp_txt);
ROTATION(0.0,0.0,text.x0, text.y0,text_x0,text_y0);
ROTATION(rot, flip, 0.0,0.0,text.x0, text.y0,text_x0,text_y0);
#ifdef HAS_CAIRO
customfont=set_text_custom_font(&text);
#endif
@ -213,7 +213,7 @@ void delete(void)
dbg(3, "delete(): start\n");
j = 0;
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
rebuild_selected_array();
if(lastselected) push_undo();
@ -269,13 +269,13 @@ void delete(void)
{
if(xctx->text[i].sel == SELECTED)
{
rot = xctx->text[i].rot;
flip = xctx->text[i].flip;
select_rot = xctx->text[i].rot;
select_flip = xctx->text[i].flip;
#ifdef HAS_CAIRO
customfont = set_text_custom_font(&xctx->text[i]);
#endif
text_bbox(xctx->text[i].txt_ptr, xctx->text[i].xscale,
xctx->text[i].yscale, rot, flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].yscale, select_rot, select_flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
&xx1,&yy1, &xx2,&yy2);
#ifdef HAS_CAIRO
@ -378,7 +378,7 @@ void delete(void)
void delete_only_rect_line_arc_poly(void)
{
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
del_rect_line_arc_poly();
lastselected = 0;
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
@ -398,7 +398,7 @@ void bbox(int what,double x1,double y1, double x2, double y2)
/* fprintf(errfp, "bbox: what=%d\n", what); */
switch(what)
{
case BEGIN:
case START:
if(sem==1) {
fprintf(errfp, "ERROR: rentrant bbox() call\n");
tcleval("alert_ {ERROR: reentrant bbox() call} {}");
@ -417,8 +417,8 @@ void bbox(int what,double x1,double y1, double x2, double y2)
break;
case ADD:
if(sem==0) {
fprintf(errfp, "ERROR: bbox(ADD) call before bbox(BEGIN)\n");
tcleval("alert_ {ERROR: bbox(ADD) call before bbox(BEGIN)} {}");
fprintf(errfp, "ERROR: bbox(ADD) call before bbox(START)\n");
tcleval("alert_ {ERROR: bbox(ADD) call before bbox(START)} {}");
}
x1=X_TO_SCREEN(x1);
y1=Y_TO_SCREEN(y1);
@ -462,8 +462,8 @@ void bbox(int what,double x1,double y1, double x2, double y2)
break;
case SET:
if(sem==0) {
fprintf(errfp, "ERROR: bbox(SET) call before bbox(BEGIN)\n");
tcleval("alert_ {ERROR: bbox(SET) call before bbox(BEGIN)} {}");
fprintf(errfp, "ERROR: bbox(SET) call before bbox(START)\n");
tcleval("alert_ {ERROR: bbox(SET) call before bbox(START)} {}");
}
areax1 = bbx1-2*INT_WIDTH(xctx->lw);
areax2 = bbx2+2*INT_WIDTH(xctx->lw);
@ -966,13 +966,13 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /* 201509
}
for(i=0;i<xctx->texts;i++)
{
rot = xctx->text[i].rot;
flip = xctx->text[i].flip;
select_rot = xctx->text[i].rot;
select_flip = xctx->text[i].flip;
#ifdef HAS_CAIRO
customfont = set_text_custom_font(&xctx->text[i]);
#endif
text_bbox(xctx->text[i].txt_ptr,
xctx->text[i].xscale, xctx->text[i].yscale, rot, flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].xscale, xctx->text[i].yscale, select_rot, select_flip, xctx->text[i].hcenter, xctx->text[i].vcenter,
xctx->text[i].x0, xctx->text[i].y0,
&xx1,&yy1, &xx2,&yy2);
#ifdef HAS_CAIRO

View File

@ -173,9 +173,9 @@ void global_spice_netlist(int global) /* netlister driver */
{
/* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */
my_strdup(391, &subckt_name, get_cell(xctx->sym[i].name, 0));
if (hash_lookup(subckt_table, subckt_name, "", XLOOKUP)==NULL)
if (str_hash_lookup(subckt_table, subckt_name, "", XLOOKUP)==NULL)
{
hash_lookup(subckt_table, subckt_name, "", XINSERT);
str_hash_lookup(subckt_table, subckt_name, "", XINSERT);
if( split_files && strcmp(get_tok_value(xctx->sym[i].prop_ptr,"vhdl_netlist",0),"true")==0 )
vhdl_block_netlist(fd, i);
else if(split_files && strcmp(get_tok_value(xctx->sym[i].prop_ptr,"verilog_netlist",0),"true")==0 )
@ -407,10 +407,10 @@ void spice_netlist(FILE *fd, int spice_stop )
print_spice_element(fd, i) ; /* this is the element line */
/* hash device_model attribute if any */
m = get_tok_value(xctx->inst[i].prop_ptr, "device_model", 2);
if(m[0]) hash_lookup(model_table, model_name(m), m, XINSERT);
if(m[0]) str_hash_lookup(model_table, model_name(m), m, XINSERT);
else {
m = get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "device_model", 2);
if(m[0]) hash_lookup(model_table, model_name(m), m, XINSERT);
if(m[0]) str_hash_lookup(model_table, model_name(m), m, XINSERT);
}
my_free(951, &model_name_result);
}
@ -422,7 +422,7 @@ void spice_netlist(FILE *fd, int spice_stop )
}
/* calculate the hash function relative to string s */
static unsigned int hash(const char *tok)
static unsigned int str_hash(const char *tok)
{
unsigned int hash = 0;
int c;
@ -447,14 +447,14 @@ static unsigned int hash(const char *tok)
* return NULL if not found
* "whatever" "whatever" XDELETE delete entry if found,return NULL
*/
struct hashentry *hash_lookup(struct hashentry **table, const char *token, const char *value, int what)
struct hashentry *str_hash_lookup(struct hashentry **table, const char *token, const char *value, int what)
{
unsigned int hashcode, index;
struct hashentry *entry, *saveptr, **preventry;
int s ;
if(token==NULL) return NULL;
hashcode=hash(token);
hashcode=str_hash(token);
index=hashcode % HASHSIZE;
entry=table[index];
preventry=&table[index];
@ -496,7 +496,7 @@ struct hashentry *hash_lookup(struct hashentry **table, const char *token, const
}
}
static struct hashentry *free_hash_entry(struct hashentry *entry)
static struct hashentry *str_free_hash_entry(struct hashentry *entry)
{
struct hashentry *tmp;
while( entry ) {
@ -516,7 +516,7 @@ void free_hash(struct hashentry **table)
for(i=0;i<HASHSIZE;i++)
{
table[i] = free_hash_entry( table[i] );
table[i] = str_free_hash_entry( table[i] );
}
}
@ -541,7 +541,7 @@ struct int_hashentry *int_hash_lookup(struct int_hashentry **table, const char *
int s ;
if(token==NULL) return NULL;
hashcode=hash(token);
hashcode=str_hash(token);
index=hashcode % HASHSIZE;
entry=table[index];
preventry=&table[index];

View File

@ -38,7 +38,7 @@ static Svg_color *svg_colors;
static double svg_linew; /* current width of lines / rectangles */
static Svg_color svg_stroke;
static void restore_lw(void)
static void svg_restore_lw(void)
{
svg_linew = xctx->lw*0.7;
}
@ -253,8 +253,8 @@ static void svg_draw_string(int gctext, const char *str,
curr_y1 = ( character[cc][i+2] ) * yscale+yy;
curr_x2 = ( character[cc][i+3]+ a ) * xscale + x1;
curr_y2 = ( character[cc][i+4] ) * yscale+yy;
ROTATION(x1,y1,curr_x1,curr_y1,rx1,ry1);
ROTATION(x1,y1,curr_x2,curr_y2,rx2,ry2);
ROTATION(rot, flip, x1,y1,curr_x1,curr_y1,rx1,ry1);
ROTATION(rot, flip, x1,y1,curr_x2,curr_y2,rx2,ry2);
ORDER(rx1,ry1,rx2,ry2);
svg_drawline(gctext, rx1, ry1, rx2, ry2, 0);
}
@ -339,8 +339,8 @@ static void svg_draw_symbol(int n,int layer,int tmp_flip, int rot,
for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->lines[layer];j++)
{
line = ((xctx->inst[n].ptr+ xctx->sym)->line[layer])[j];
ROTATION(0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(0.0,0.0,line.x2,line.y2,x2,y2);
ROTATION(rot, flip, 0.0,0.0,line.x1,line.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2);
ORDER(x1,y1,x2,y2);
svg_drawline(layer, x0+x1, y0+y1, x0+x2, y0+y2, line.dash);
}
@ -353,7 +353,7 @@ static void svg_draw_symbol(int n,int layer,int tmp_flip, int rot,
double *x = my_malloc(417, sizeof(double) * polygon.points);
double *y = my_malloc(418, sizeof(double) * polygon.points);
for(k=0;k<polygon.points;k++) {
ROTATION(0.0,0.0,polygon.x[k],polygon.y[k],x[k],y[k]);
ROTATION(rot, flip, 0.0,0.0,polygon.x[k],polygon.y[k],x[k],y[k]);
x[k]+= x0;
y[k] += y0;
}
@ -373,15 +373,15 @@ static void svg_draw_symbol(int n,int layer,int tmp_flip, int rot,
}
angle = fmod(angle, 360.);
if(angle<0.) angle+=360.;
ROTATION(0.0,0.0,arc.x,arc.y,x1,y1);
ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1);
svg_drawarc(layer, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash);
}
if( (layer != PINLAYER || enable_layer[layer]) ) for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->rects[layer];j++)
{
box = ((xctx->inst[n].ptr+ xctx->sym)->rect[layer])[j];
ROTATION(0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(0.0,0.0,box.x2,box.y2,x2,y2);
ROTATION(rot, flip, 0.0,0.0,box.x1,box.y1,x1,y1);
ROTATION(rot, flip, 0.0,0.0,box.x2,box.y2,x2,y2);
RECTORDER(x1,y1,x2,y2);
svg_filledrect(layer, x0+x1, y0+y1, x0+x2, y0+y2, box.dash);
}
@ -394,7 +394,7 @@ static void svg_draw_symbol(int n,int layer,int tmp_flip, int rot,
text = (xctx->inst[n].ptr+ xctx->sym)->text[j];
/* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */
txtptr= translate(n, text.txt_ptr);
ROTATION(0.0,0.0,text.x0,text.y0,x1,y1);
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
textlayer = layer;
if( !(layer == PINLAYER && (xctx->inst[n].flags & 4))) {
textlayer = (xctx->inst[n].ptr+ xctx->sym)->text[j].layer;
@ -465,7 +465,7 @@ void svg_draw(void)
else return;
}
restore_lw();
svg_restore_lw();
svg_colors=my_calloc(419, cadlayers, sizeof(Svg_color));
if(svg_colors==NULL){

View File

@ -34,7 +34,7 @@ struct inst_hashentry {
static struct inst_hashentry *table[HASHSIZE];
enum status {XBEGIN, XTOKEN, XSEPARATOR, XVALUE, XEND, XENDTOK};
enum status {TOK_BEGIN, TOK_TOKEN, TOK_SEP, TOK_VALUE, TOK_END, TOK_ENDTOK};
/* calculate the hash function relative to string s */
static unsigned int hash(char *tok)
@ -190,7 +190,7 @@ void check_unique_names(int rename)
delete_hilight_net();
/* undraw_hilight_net(1); */
if(!big) {
bbox(BEGIN, 0.0 , 0.0 , 0.0 , 0.0);
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
bbox(ADD, boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
bbox(SET , 0.0 , 0.0 , 0.0 , 0.0);
}
@ -214,7 +214,7 @@ void check_unique_names(int rename)
hilight_nets=1;
if(rename == 1) {
if(first) {
bbox(BEGIN,0.0,0.0,0.0,0.0);
bbox(START,0.0,0.0,0.0,0.0);
set_modify(1); push_undo();
prepared_hash_instances=0;
prepared_netlist_structs=0;
@ -281,7 +281,7 @@ int match_symbol(const char *name) /* never returns -1, if symbol not found loa
/* return 1 if s modified 20081221 */
int set_different_token(char **s,const char *new, const char *old, int object, int n)
{
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
char *token=NULL, *value=NULL;
int sizetok=0, sizeval=0;
int token_pos=0, value_pos=0;
@ -304,23 +304,23 @@ int set_different_token(char **s,const char *new, const char *old, int object, i
c=*my_new++;
space=SPACE(c) ;
if(c=='"' && !escape) quote=!quote;
if( (state==XBEGIN || state==XENDTOK) && !space && c != '=') state=XTOKEN;
else if( state==XTOKEN && space) state=XENDTOK;
else if( (state==XTOKEN || state==XENDTOK) && c=='=') state=XSEPARATOR;
else if( state==XSEPARATOR && !space) state=XVALUE;
else if( state==XVALUE && space && !quote && !escape) state=XEND;
if( (state==TOK_BEGIN || state==TOK_ENDTOK) && !space && c != '=') state=TOK_TOKEN;
else if( state==TOK_TOKEN && space) state=TOK_ENDTOK;
else if( (state==TOK_TOKEN || state==TOK_ENDTOK) && c=='=') state=TOK_SEP;
else if( state==TOK_SEP && !space) state=TOK_VALUE;
else if( state==TOK_VALUE && space && !quote && !escape) state=TOK_END;
STR_ALLOC(&value, value_pos, &sizeval);
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) token[token_pos++]=c;
else if(state==XVALUE) {
if(state==TOK_TOKEN) token[token_pos++]=c;
else if(state==TOK_VALUE) {
value[value_pos++]=c;
}
else if(state==XENDTOK || state==XSEPARATOR) {
else if(state==TOK_ENDTOK || state==TOK_SEP) {
if(token_pos) {
token[token_pos]='\0';
token_pos=0;
}
} else if(state==XEND) {
} else if(state==TOK_END) {
value[value_pos]='\0';
value_pos=0;
if(strcmp(value, get_tok_value(old,token,1))) {
@ -338,31 +338,31 @@ int set_different_token(char **s,const char *new, const char *old, int object, i
mod=1;
my_strdup(433, s, subst_token(*s, token, value) );
}
state=XBEGIN;
state=TOK_BEGIN;
}
escape = (c=='\\' && !escape);
if(c=='\0') break;
}
state = XBEGIN;
state = TOK_BEGIN;
escape = quote = token_pos = value_pos = 0;
/* parse old string and remove attributes that are not present in new */
while(old) {
c=*old++;
space=SPACE(c) ;
if(c=='"' && !escape) quote=!quote;
if( (state==XBEGIN || state==XENDTOK) && !space && c != '=') state=XTOKEN;
else if( state==XTOKEN && space) state=XENDTOK;
else if( (state==XTOKEN || state==XENDTOK) && c=='=') state=XSEPARATOR;
else if( state==XSEPARATOR && !space) state=XVALUE;
else if( state==XVALUE && space && !quote && !escape) state=XEND;
if( (state==TOK_BEGIN || state==TOK_ENDTOK) && !space && c != '=') state=TOK_TOKEN;
else if( state==TOK_TOKEN && space) state=TOK_ENDTOK;
else if( (state==TOK_TOKEN || state==TOK_ENDTOK) && c=='=') state=TOK_SEP;
else if( state==TOK_SEP && !space) state=TOK_VALUE;
else if( state==TOK_VALUE && space && !quote && !escape) state=TOK_END;
STR_ALLOC(&value, value_pos, &sizeval);
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) token[token_pos++]=c;
else if(state==XVALUE) {
if(state==TOK_TOKEN) token[token_pos++]=c;
else if(state==TOK_VALUE) {
value[value_pos++]=c;
}
else if(state==XENDTOK || state==XSEPARATOR) {
else if(state==TOK_ENDTOK || state==TOK_SEP) {
if(token_pos) {
token[token_pos]='\0';
token_pos=0;
@ -382,10 +382,10 @@ int set_different_token(char **s,const char *new, const char *old, int object, i
mod=1;
my_strdup(443, s, subst_token(*s, token, NULL) );
}
} else if(state==XEND) {
} else if(state==TOK_END) {
value[value_pos]='\0';
value_pos=0;
state=XBEGIN;
state=TOK_BEGIN;
}
escape = (c=='\\' && !escape);
if(c=='\0') break;
@ -404,7 +404,7 @@ const char *list_tokens(const char *s, int with_quotes)
{
static char *token=NULL;
int sizetok=0;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
register int token_pos=0;
int quote=0;
int escape=0;
@ -419,29 +419,29 @@ const char *list_tokens(const char *s, int with_quotes)
while(1) {
c=*s++;
space=SPACE(c) ;
if( (state==XBEGIN || state==XENDTOK) && !space && c != '=') state=XTOKEN;
else if( state==XTOKEN && space && !quote && !escape) state=XENDTOK;
else if( (state==XTOKEN || state==XENDTOK) && c=='=') state=XSEPARATOR;
else if( state==XSEPARATOR && !space) state=XVALUE;
else if( state==XVALUE && space && !quote && !escape ) state=XEND;
if( (state==TOK_BEGIN || state==TOK_ENDTOK) && !space && c != '=') state=TOK_TOKEN;
else if( state==TOK_TOKEN && space && !quote && !escape) state=TOK_ENDTOK;
else if( (state==TOK_TOKEN || state==TOK_ENDTOK) && c=='=') state=TOK_SEP;
else if( state==TOK_SEP && !space) state=TOK_VALUE;
else if( state==TOK_VALUE && space && !quote && !escape ) state=TOK_END;
STR_ALLOC(&token, token_pos, &sizetok);
if(c=='"') {
if(!escape) quote=!quote;
}
if(state==XTOKEN) {
if(state==TOK_TOKEN) {
if(c=='"') {
if((with_quotes & 1) || escape) token[token_pos++]=c;
}
else if( !(c == '\\' && (with_quotes & 2)) ) token[token_pos++]=c;
else if(escape && c == '\\') token[token_pos++]=c;
} else if(state==XVALUE) {
} else if(state==TOK_VALUE) {
/* do nothing */
} else if(state==XENDTOK || state==XSEPARATOR) {
} else if(state==TOK_ENDTOK || state==TOK_SEP) {
if(token_pos) {
token[token_pos++]= ' ';
}
} else if(state==XEND) {
state=XBEGIN;
} else if(state==TOK_END) {
state=TOK_BEGIN;
}
escape = (c=='\\' && !escape);
if(c=='\0') {
@ -470,7 +470,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
int sizetok=0;
register int c, space;
register int token_pos=0, value_pos=0;
int quote=0, state=XBEGIN;
int quote=0, state=TOK_BEGIN;
int escape=0;
int cmp = 1;
@ -488,11 +488,11 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
while(1) {
c=*s++;
space=SPACE(c) ;
if( (state==XBEGIN || state==XENDTOK) && !space && c != '=') state=XTOKEN;
else if( state==XTOKEN && space && !quote && !escape) state=XENDTOK;
else if( (state==XTOKEN || state==XENDTOK) && c=='=') state=XSEPARATOR;
else if( state==XSEPARATOR && !space) state=XVALUE;
else if( state==XVALUE && space && !quote && !escape ) state=XEND;
if( (state==TOK_BEGIN || state==TOK_ENDTOK) && !space && c != '=') state=TOK_TOKEN;
else if( state==TOK_TOKEN && space && !quote && !escape) state=TOK_ENDTOK;
else if( (state==TOK_TOKEN || state==TOK_ENDTOK) && c=='=') state=TOK_SEP;
else if( state==TOK_SEP && !space) state=TOK_VALUE;
else if( state==TOK_VALUE && space && !quote && !escape ) state=TOK_END;
/* don't use STR_ALLOC() for efficiency reasons */
if(value_pos>=size) {
size+=CADCHUNKALLOC;
@ -505,7 +505,7 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
if(c=='"') {
if(!escape) quote=!quote;
}
if(state==XTOKEN) {
if(state==TOK_TOKEN) {
if(!cmp) { /* previous token matched search and was without value, return get_tok_size */
result[0] = '\0';
get_tok_value_size = 0;
@ -516,13 +516,13 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
}
else if( !(c == '\\' && (with_quotes & 2)) ) token[token_pos++]=c;
else if(escape && c == '\\') token[token_pos++]=c;
} else if(state==XVALUE) {
} else if(state==TOK_VALUE) {
if(c=='"') {
if((with_quotes & 1) || escape) result[value_pos++]=c;
}
else if( !quote || !((c == '\\') && (with_quotes & 2)) ) result[value_pos++]=c; /* skip unescaped backslashes */
else if( (c == '\\') && escape ) result[value_pos++]=c; /* 20170414 add escaped backslashes */
} else if(state==XENDTOK || state==XSEPARATOR) {
} else if(state==TOK_ENDTOK || state==TOK_SEP) {
if(token_pos) {
token[token_pos]='\0';
if( !(cmp = strcmp(token,tok)) ) {
@ -531,14 +531,14 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes)
dbg(2, "get_tok_value(): token=%s\n", token);
token_pos=0;
}
} else if(state==XEND) {
} else if(state==TOK_END) {
result[value_pos]='\0';
if( !cmp ) {
get_tok_value_size = value_pos; /* return also size so to avoid using strlen 20180926 */
return result;
}
value_pos=0;
state=XBEGIN;
state=TOK_BEGIN;
}
escape = (c=='\\' && !escape);
if(c=='\0') {
@ -559,7 +559,7 @@ const char *get_sym_template(char *s,char *extra)
int sizeval=0;
char *value=NULL;
char *token=NULL;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
register int token_pos=0, value_pos=0, result_pos=0;
int quote=0;
int escape=0;
@ -583,18 +583,18 @@ const char *get_sym_template(char *s,char *extra)
while(1) {
c=*s++;
space=SPACE(c) ;
if( (state==XBEGIN || state==XENDTOK) && !space && c != '=') state=XTOKEN;
else if( state==XTOKEN && space) state=XENDTOK;
else if( (state==XTOKEN || state==XENDTOK) && c=='=') state=XSEPARATOR;
else if( state==XSEPARATOR && !space) state=XVALUE;
else if( state==XVALUE && space && !quote) state=XEND;
if( (state==TOK_BEGIN || state==TOK_ENDTOK) && !space && c != '=') state=TOK_TOKEN;
else if( state==TOK_TOKEN && space) state=TOK_ENDTOK;
else if( (state==TOK_TOKEN || state==TOK_ENDTOK) && c=='=') state=TOK_SEP;
else if( state==TOK_SEP && !space) state=TOK_VALUE;
else if( state==TOK_VALUE && space && !quote) state=TOK_END;
STR_ALLOC(&value, value_pos, &sizeval);
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XBEGIN) {
if(state==TOK_BEGIN) {
result[result_pos++] = c;
} else if(state==XTOKEN) {
} else if(state==TOK_TOKEN) {
token[token_pos++]=c;
} else if(state==XVALUE) {
} else if(state==TOK_VALUE) {
if(c=='"') {
if(!escape) quote=!quote;
if((with_quotes & 1) || escape) value[value_pos++]=c;
@ -603,7 +603,7 @@ const char *get_sym_template(char *s,char *extra)
else value[value_pos++]=c;
escape = (c=='\\' && !escape);
} else if(state==XEND) {
} else if(state==TOK_END) {
value[value_pos]='\0';
if((!extra || !strstr(extra, token)) && strcmp(token,"name")) {
memcpy(result+result_pos, value, value_pos+1);
@ -612,8 +612,8 @@ const char *get_sym_template(char *s,char *extra)
result[result_pos++] = c;
value_pos=0;
token_pos=0;
state=XBEGIN;
} else if(state==XENDTOK || state==XSEPARATOR) {
state=TOK_BEGIN;
} else if(state==TOK_ENDTOK || state==TOK_SEP) {
if(token_pos) {
token[token_pos]='\0';
if((!extra || !strstr(extra, token)) && strcmp(token,"name")) {
@ -756,7 +756,7 @@ const char *subst_token(const char *s, const char *tok, const char *new_val)
{
static char *result=NULL;
int size=0;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
int sizetok=0;
char *token=NULL;
int token_pos=0, result_pos=0, result_save_pos = 0;
@ -787,27 +787,27 @@ const char *subst_token(const char *s, const char *tok, const char *new_val)
/* parsing state machine */
/* states: */
/* XBEGIN XTOKEN XENDTOK XSEPARATOR XVALUE */
/* TOK_BEGIN TOK_TOKEN TOK_ENDTOK TOK_SEP TOK_VALUE */
/* */
/* */
/* XBEGIN */
/* | XTOKEN */
/* | | XENDTOK */
/* | | | XSEPARATOR */
/* | | | | XVALUE */
/* | | | | | XBEGIN */
/* | | | | | | XTOKEN */
/* | | | | | | | XENDTOK */
/* | | | | | | | | XTOKEN */
/* TOK_BEGIN */
/* | TOK_TOKEN */
/* | | TOK_ENDTOK */
/* | | | TOK_SEP */
/* | | | | TOK_VALUE */
/* | | | | | TOK_BEGIN */
/* | | | | | | TOK_TOKEN */
/* | | | | | | | TOK_ENDTOK */
/* | | | | | | | | TOK_TOKEN */
/* | | | | | | | | | */
/* .......name...=.x1....format...type..=..subcircuit.... */
/* . : space */
if(state == XBEGIN && !space && c != '=' ) {
if(state == TOK_BEGIN && !space && c != '=' ) {
result_save_pos = result_pos;
token_pos = 0;
state = XTOKEN;
} else if(state == XENDTOK && (!space || c == '\0') && c != '=' ) {
state = TOK_TOKEN;
} else if(state == TOK_ENDTOK && (!space || c == '\0') && c != '=' ) {
if(!done_subst && matched_tok) {
if(new_val) { /* add new_val to matching token with no value */
if(new_val[0]) {
@ -829,24 +829,24 @@ const char *subst_token(const char *s, const char *tok, const char *new_val)
}
}
result_save_pos = result_pos;
if(c != '\0') state = XTOKEN; /* if end of string remain in XENDTOK state */
} else if( state == XTOKEN && space) {
if(c != '\0') state = TOK_TOKEN; /* if end of string remain in TOK_ENDTOK state */
} else if( state == TOK_TOKEN && space) {
token[token_pos] = '\0';
token_pos = 0;
matched_tok = !strcmp(token, tok) && !done_subst;
state=XENDTOK;
state=TOK_ENDTOK;
if(c == '\0') {
s--; /* go to next iteration and process '\0' as XENDTOK */
s--; /* go to next iteration and process '\0' as TOK_ENDTOK */
continue;
}
} else if(state == XTOKEN && c=='=') {
} else if(state == TOK_TOKEN && c=='=') {
token[token_pos] = '\0';
token_pos = 0;
matched_tok = !strcmp(token, tok) && !done_subst;
state=XSEPARATOR;
} else if(state == XENDTOK && c=='=') {
state=XSEPARATOR;
} else if( state == XSEPARATOR && !space) {
state=TOK_SEP;
} else if(state == TOK_ENDTOK && c=='=') {
state=TOK_SEP;
} else if( state == TOK_SEP && !space) {
if(!done_subst && matched_tok) {
if(new_val) { /* replace token value with new_val */
if(new_val[0]) {
@ -864,21 +864,21 @@ const char *subst_token(const char *s, const char *tok, const char *new_val)
done_subst = 1;
}
}
state=XVALUE;
} else if( state == XVALUE && space && !quote && !escape) {
state=XBEGIN;
state=TOK_VALUE;
} else if( state == TOK_VALUE && space && !quote && !escape) {
state=TOK_BEGIN;
}
/* state actions */
if(state == XBEGIN) {
if(state == TOK_BEGIN) {
result[result_pos++] = c;
} else if(state == XTOKEN) {
} else if(state == TOK_TOKEN) {
token[token_pos++] = c;
result[result_pos++] = c;
} else if(state == XENDTOK) {
} else if(state == TOK_ENDTOK) {
result[result_pos++] = c;
} else if(state == XSEPARATOR) {
} else if(state == TOK_SEP) {
result[result_pos++] = c;
} else if(state==XVALUE) {
} else if(state==TOK_VALUE) {
if(!matched_tok) result[result_pos++] = c; /* skip value for matching token */
}
escape = (c=='\\' && !escape);
@ -956,7 +956,7 @@ void print_vhdl_element(FILE *fd, int inst)
{
int i=0, mult, tmp, tmp1;
const char *str_ptr;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
const char *lab;
char *name=NULL;
char *generic_value=NULL, *generic_type=NULL;
@ -1009,24 +1009,24 @@ void print_vhdl_element(FILE *fd, int inst)
else
escape=0;
space=SPACE(c);
if( (state==XBEGIN || state==XENDTOK) && !space && c != '=') state=XTOKEN;
else if( state==XTOKEN && space) state=XENDTOK;
else if( (state==XTOKEN || state==XENDTOK) && c=='=') state=XSEPARATOR;
else if( state==XSEPARATOR && !space) state=XVALUE;
else if( state==XVALUE && space && !quote) state=XEND;
if( (state==TOK_BEGIN || state==TOK_ENDTOK) && !space && c != '=') state=TOK_TOKEN;
else if( state==TOK_TOKEN && space) state=TOK_ENDTOK;
else if( (state==TOK_TOKEN || state==TOK_ENDTOK) && c=='=') state=TOK_SEP;
else if( state==TOK_SEP && !space) state=TOK_VALUE;
else if( state==TOK_VALUE && space && !quote) state=TOK_END;
STR_ALLOC(&value, value_pos, &sizeval);
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) token[token_pos++]=c;
else if(state==XVALUE) {
if(state==TOK_TOKEN) token[token_pos++]=c;
else if(state==TOK_VALUE) {
if(c=='"' && !escape) quote=!quote;
else value[value_pos++]=c;
}
else if(state==XENDTOK || state==XSEPARATOR) {
else if(state==TOK_ENDTOK || state==TOK_SEP) {
if(token_pos) {
token[token_pos]='\0';
token_pos=0;
}
} else if(state==XEND) {
} else if(state==TOK_END) {
value[value_pos]='\0';
value_pos=0;
get_tok_value(template, token, 0);
@ -1047,7 +1047,7 @@ void print_vhdl_element(FILE *fd, int inst)
tmp1=1;
}
}
state=XBEGIN;
state=TOK_BEGIN;
}
if(c=='\0') /* end string */
{
@ -1112,7 +1112,7 @@ void print_vhdl_element(FILE *fd, int inst)
void print_generic(FILE *fd, char *ent_or_comp, int symbol)
{
int tmp;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
char *template=NULL, *s, *value=NULL, *token=NULL;
char *type=NULL, *generic_type=NULL, *generic_value=NULL;
const char *str_tmp;
@ -1148,25 +1148,25 @@ void print_generic(FILE *fd, char *ent_or_comp, int symbol)
else
escape=0;
space=SPACE(c);
if( (state==XBEGIN || state==XENDTOK) && !space && c != '=') state=XTOKEN;
else if( state==XTOKEN && space) state=XENDTOK;
else if( (state==XTOKEN || state==XENDTOK) && c=='=') state=XSEPARATOR;
else if( state==XSEPARATOR && !space) state=XVALUE;
else if( state==XVALUE && space && !quote) state=XEND;
if( (state==TOK_BEGIN || state==TOK_ENDTOK) && !space && c != '=') state=TOK_TOKEN;
else if( state==TOK_TOKEN && space) state=TOK_ENDTOK;
else if( (state==TOK_TOKEN || state==TOK_ENDTOK) && c=='=') state=TOK_SEP;
else if( state==TOK_SEP && !space) state=TOK_VALUE;
else if( state==TOK_VALUE && space && !quote) state=TOK_END;
STR_ALLOC(&value, value_pos, &sizeval);
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) token[token_pos++]=c;
else if(state==XVALUE)
if(state==TOK_TOKEN) token[token_pos++]=c;
else if(state==TOK_VALUE)
{
if(c=='"' && !escape) quote=!quote;
else value[value_pos++]=c;
}
else if(state==XENDTOK || state==XSEPARATOR) {
else if(state==TOK_ENDTOK || state==TOK_SEP) {
if(token_pos) {
token[token_pos]='\0';
token_pos=0;
}
} else if(state==XEND) /* got a token */
} else if(state==TOK_END) /* got a token */
{
token_number++;
value[value_pos]='\0';
@ -1188,7 +1188,7 @@ void print_generic(FILE *fd, char *ent_or_comp, int symbol)
tmp=1;
}
}
state=XBEGIN;
state=TOK_BEGIN;
}
if(c=='\0') /* end string */
{
@ -1223,7 +1223,7 @@ void print_generic(FILE *fd, char *ent_or_comp, int symbol)
void print_verilog_param(FILE *fd, int symbol)
{
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
char *template=NULL, *s, *value=NULL, *generic_type=NULL, *token=NULL;
int sizetok=0, sizeval=0;
int token_pos=0, value_pos=0;
@ -1252,26 +1252,26 @@ void print_verilog_param(FILE *fd, int symbol)
else
escape=0;
space=SPACE(c);
if( (state==XBEGIN || state==XENDTOK) && !space && c != '=') state=XTOKEN;
else if( state==XTOKEN && space) state=XENDTOK;
else if( (state==XTOKEN || state==XENDTOK) && c=='=') state=XSEPARATOR;
else if( state==XSEPARATOR && !space) state=XVALUE;
else if( state==XVALUE && space && !quote) state=XEND;
if( (state==TOK_BEGIN || state==TOK_ENDTOK) && !space && c != '=') state=TOK_TOKEN;
else if( state==TOK_TOKEN && space) state=TOK_ENDTOK;
else if( (state==TOK_TOKEN || state==TOK_ENDTOK) && c=='=') state=TOK_SEP;
else if( state==TOK_SEP && !space) state=TOK_VALUE;
else if( state==TOK_VALUE && space && !quote) state=TOK_END;
STR_ALLOC(&value, value_pos, &sizeval);
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) token[token_pos++]=c;
else if(state==XVALUE)
if(state==TOK_TOKEN) token[token_pos++]=c;
else if(state==TOK_VALUE)
{
if(c=='"' && !escape) quote=!quote;
else value[value_pos++]=c;
}
else if(state==XENDTOK || state==XSEPARATOR) {
else if(state==TOK_ENDTOK || state==TOK_SEP) {
if(token_pos) {
token[token_pos]='\0';
token_pos=0;
}
} else if(state==XEND) /* got a token */
} else if(state==TOK_END) /* got a token */
{
token_number++;
value[value_pos]='\0';
@ -1293,7 +1293,7 @@ void print_verilog_param(FILE *fd, int symbol)
}
}
}
state=XBEGIN;
state=TOK_BEGIN;
}
if(c=='\0') /* end string */
{
@ -1314,7 +1314,7 @@ void print_spice_subckt(FILE *fd, int symbol)
{
int i=0, mult;
const char *str_ptr=NULL;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
char *format=NULL,*s, *token=NULL;
int pin_number;
int sizetok=0;
@ -1340,21 +1340,21 @@ void print_spice_subckt(FILE *fd, int symbol)
else escape=0;
if(c=='\n' && escape ) c=*s++; /* 20171030 eat escaped newlines */
space=SPACE(c);
if( state==XBEGIN && (c=='@' || c=='$') && !escape) state=XTOKEN;
else if(state==XTOKEN && token_pos > 1 &&
if( state==TOK_BEGIN && (c=='@' || c=='$') && !escape) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '$' || c == '@') && !escape ) ||
( (!space && c != '$' && c != '@') && escape )
)
) {
state = XSEPARATOR;
state = TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) {
if(state==TOK_TOKEN) {
token[token_pos++]=c;
}
else if(state==XSEPARATOR) /* got a token */
else if(state==TOK_SEP) /* got a token */
{
token[token_pos]='\0';
token_pos=0;
@ -1402,10 +1402,10 @@ void print_spice_subckt(FILE *fd, int symbol)
}
if(c!='$' && c!='@' && c!='\0' ) fputc(c,fd);
if(c == '@' || c =='$') s--;
state=XBEGIN;
state=TOK_BEGIN;
}
/* 20151028 dont print escaping backslashes */
else if(state==XBEGIN && c!='\0') {
else if(state==TOK_BEGIN && c!='\0') {
/* do nothing */
}
if(c=='\0')
@ -1421,7 +1421,7 @@ void print_spice_element(FILE *fd, int inst)
{
int i=0, mult, tmp;
const char *str_ptr=NULL;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
char *template=NULL,*format=NULL,*s, *name=NULL, *token=NULL;
const char *lab, *value = NULL;
int pin_number;
@ -1469,21 +1469,21 @@ void print_spice_element(FILE *fd, int inst)
if (c=='\n' && escape) c=*s++; /* 20171030 eat escaped newlines */
space=SPACE(c);
if ( state==XBEGIN && (c=='@'|| c=='$') && !escape ) state=XTOKEN;
else if(state==XTOKEN && token_pos > 1 &&
if ( state==TOK_BEGIN && (c=='@'|| c=='$') && !escape ) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '$' || c == '@') && !escape ) ||
( (!space && c != '$' && c != '@') && escape )
)
) {
dbg(1, "print_spice_element: c=%c, space=%d, escape=%d roken_pos=%d\n", c, space, escape, token_pos);
state=XSEPARATOR;
state=TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) {
if(state==TOK_TOKEN) {
token[token_pos++]=c;
}
else if (state==XSEPARATOR) /* got a token */
else if (state==TOK_SEP) /* got a token */
{
token[token_pos]='\0';
token_pos=0;
@ -1632,9 +1632,9 @@ void print_spice_element(FILE *fd, int inst)
/* fputc(c,fd); */
}
if(c == '@' || c == '$' ) s--;
state=XBEGIN;
state=TOK_BEGIN;
}
else if(state==XBEGIN && c!='\0') {
else if(state==TOK_BEGIN && c!='\0') {
result_pos += my_snprintf(result + result_pos, 2, "%c", c); /* no realloc needed */
/* fputc(c,fd); */
}
@ -1678,7 +1678,7 @@ void print_tedax_element(FILE *fd, int inst)
{
int i=0, mult;
const char *str_ptr=NULL;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
char *template=NULL,*format=NULL,*s, *name=NULL, *token=NULL;
const char *value;
char *extra=NULL, *extra_pinnumber=NULL;
@ -1788,21 +1788,21 @@ void print_tedax_element(FILE *fd, int inst)
if(c=='\n' && escape ) c=*s++; /* 20171030 eat escaped newlines */
space=SPACE(c);
if( state==XBEGIN && (c=='$' || c=='@') && !escape) state=XTOKEN;
else if(state==XTOKEN && token_pos > 1 &&
if( state==TOK_BEGIN && (c=='$' || c=='@') && !escape) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '$' || c == '@') && !escape ) ||
( (!space && c != '$' && c != '@') && escape )
)
) {
state=XSEPARATOR;
state=TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) {
if(state==TOK_TOKEN) {
token[token_pos++]=c; /* 20171029 remove escaping backslashes */
}
else if(state==XSEPARATOR) /* got a token */
else if(state==TOK_SEP) /* got a token */
{
token[token_pos]='\0';
token_pos=0;
@ -1917,9 +1917,9 @@ void print_tedax_element(FILE *fd, int inst)
if(c!='$' && c!='@' && c!='\0') fputc(c,fd);
if(c == '@' || c == '$' ) s--;
state=XBEGIN;
state=TOK_BEGIN;
}
else if(state==XBEGIN && c!='\0') fputc(c,fd);
else if(state==TOK_BEGIN && c!='\0') fputc(c,fd);
if(c=='\0')
{
fputc('\n',fd);
@ -1960,7 +1960,7 @@ void print_verilog_element(FILE *fd, int inst)
char *template=NULL,*s;
int no_of_pins=0;
int tmp1 = 0;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
char *value=NULL, *token=NULL;
int sizetok=0, sizeval=0;
int token_pos=0, value_pos=0;
@ -2002,25 +2002,25 @@ void print_verilog_element(FILE *fd, int inst)
c=*s++;
}
space=SPACE(c);
if( (state==XBEGIN || state==XENDTOK) && !space && c != '=') state=XTOKEN;
else if( state==XTOKEN && space) state=XENDTOK;
else if( (state==XTOKEN || state==XENDTOK) && c=='=') state=XSEPARATOR;
else if( state==XSEPARATOR && !space) state=XVALUE;
else if( state==XVALUE && space && !quote) state=XEND;
if( (state==TOK_BEGIN || state==TOK_ENDTOK) && !space && c != '=') state=TOK_TOKEN;
else if( state==TOK_TOKEN && space) state=TOK_ENDTOK;
else if( (state==TOK_TOKEN || state==TOK_ENDTOK) && c=='=') state=TOK_SEP;
else if( state==TOK_SEP && !space) state=TOK_VALUE;
else if( state==TOK_VALUE && space && !quote) state=TOK_END;
STR_ALLOC(&value, value_pos, &sizeval);
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) token[token_pos++]=c;
else if(state==XVALUE)
if(state==TOK_TOKEN) token[token_pos++]=c;
else if(state==TOK_VALUE)
{
value[value_pos++]=c;
}
else if(state==XENDTOK || state==XSEPARATOR) {
else if(state==TOK_ENDTOK || state==TOK_SEP) {
if(token_pos) {
token[token_pos]='\0';
token_pos=0;
}
} else if(state==XEND)
} else if(state==TOK_END)
{
value[value_pos]='\0';
value_pos=0;
@ -2042,7 +2042,7 @@ void print_verilog_element(FILE *fd, int inst)
}
}
}
state=XBEGIN;
state=TOK_BEGIN;
}
if(c=='\0') /* end string */
{
@ -2142,7 +2142,7 @@ void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 *
{
int i=0, mult, tmp;
const char *str_ptr;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
const char *lab;
char *template=NULL,*format=NULL,*s, *name=NULL, *token=NULL;
const char *value;
@ -2185,21 +2185,21 @@ void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 *
if(c=='\n' && escape ) c=*s++; /* 20171030 eat escaped newlines */
space=SPACE(c);
if( state==XBEGIN && (c=='@' || c=='$') && !escape ) state=XTOKEN;
else if(state==XTOKEN && token_pos > 1 &&
if( state==TOK_BEGIN && (c=='@' || c=='$') && !escape ) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '$' || c == '@') && !escape ) ||
( (!space && c != '$' && c != '@') && escape )
)
) {
state=XSEPARATOR;
state=TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) {
if(state==TOK_TOKEN) {
token[token_pos++]=c; /* 20171029 remove escaping backslashes */
}
else if(state==XSEPARATOR) /* got a token */
else if(state==TOK_SEP) /* got a token */
{
token[token_pos]='\0';
token_pos=0;
@ -2292,9 +2292,9 @@ void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 *
if(c!='$' && c!='@' && c!='\0' ) fputc(c,fd);
if(c == '@' || c == '$') s--;
state=XBEGIN;
state=TOK_BEGIN;
}
else if(state==XBEGIN && c!='\0') fputc(c,fd);
else if(state==TOK_BEGIN && c!='\0') fputc(c,fd);
if(c=='\0')
{
@ -2314,7 +2314,7 @@ void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primiti
{
int i=0, mult, tmp;
const char *str_ptr;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
const char *lab;
char *template=NULL,*format=NULL,*s=NULL, *name=NULL, *token=NULL;
const char *value;
@ -2357,22 +2357,22 @@ void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primiti
else escape=0;
if(c=='\n' && escape ) c=*s++; /* 20171030 eat escaped newlines */
space=SPACE(c);
if( state==XBEGIN && (c=='@' || c=='$') && !escape ) state=XTOKEN;
else if(state==XTOKEN && token_pos > 1 &&
if( state==TOK_BEGIN && (c=='@' || c=='$') && !escape ) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '$' || c == '@') && !escape ) ||
( (!space && c != '$' && c != '@') && escape )
)
) {
state=XSEPARATOR;
state=TOK_SEP;
}
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) {
if(state==TOK_TOKEN) {
token[token_pos++]=c;
}
else if(state==XSEPARATOR) /* got a token */
else if(state==TOK_SEP) /* got a token */
{
token[token_pos]='\0';
token_pos=0;
@ -2466,9 +2466,9 @@ void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primiti
}
if(c!='$' && c!='@' && c!='\0') fputc(c,fd);
if(c == '@' || c == '$') s--;
state=XBEGIN;
state=TOK_BEGIN;
}
else if(state==XBEGIN && c!='\0') fputc(c,fd);
else if(state==TOK_BEGIN && c!='\0') fputc(c,fd);
if(c=='\0')
{
fputc('\n',fd);
@ -2530,7 +2530,7 @@ const char *translate(int inst, const char* s)
static char empty[]="";
static char *result=NULL;
int size=0, tmp;
register int c, state=XBEGIN, space;
register int c, state=TOK_BEGIN, space;
char *token=NULL;
const char *tmp_sym_name;
int sizetok=0;
@ -2564,19 +2564,19 @@ const char *translate(int inst, const char* s)
}
else escape=0;
space=SPACE(c);
if( state==XBEGIN && (c=='@' || c=='$' ) && !escape ) state=XTOKEN; /* 20161210 escape */
else if( state==XTOKEN && (
if( state==TOK_BEGIN && (c=='@' || c=='$' ) && !escape ) state=TOK_TOKEN; /* 20161210 escape */
else if( state==TOK_TOKEN && (
(space && !escape) ||
(c =='@' || c == '$') ||
(!space && escape)
)
&& token_pos > 1 ) state=XSEPARATOR;
&& token_pos > 1 ) state=TOK_SEP;
STR_ALLOC(&result, result_pos, &size);
STR_ALLOC(&token, token_pos, &sizetok);
if(state==XTOKEN) token[token_pos++]=c;
else if(state==XSEPARATOR)
if(state==TOK_TOKEN) token[token_pos++]=c;
else if(state==TOK_SEP)
{
token[token_pos]='\0';
dbg(2, "translate(): token=%s\n", token);
@ -2796,9 +2796,9 @@ const char *translate(int inst, const char* s)
if(c == '@' || c == '$') s--;
else result[result_pos++]=c;
state=XBEGIN;
state=TOK_BEGIN;
}
else if(state==XBEGIN) result[result_pos++]=c;
else if(state==TOK_BEGIN) result[result_pos++]=c;
if(c=='\0')
{
result[result_pos]='\0';
@ -2819,7 +2819,7 @@ const char *translate2(struct Lcc *lcc, int level, char* s)
static char empty[]="";
static char *result = NULL;
int i, size = 0, tmp, save_tok_size, save_value_size;
register int c, state = XBEGIN, space;
register int c, state = TOK_BEGIN, space;
char *token = NULL;
const char *tmp_sym_name;
int sizetok = 0;
@ -2847,14 +2847,14 @@ const char *translate2(struct Lcc *lcc, int level, char* s)
}
else escape = 0;
space = SPACE(c);
if (state == XBEGIN && c == '@' && !escape) state = XTOKEN;
else if (state == XTOKEN && ( (space && !escape) || c == '@' || (!space && escape)) && token_pos > 1) {
state = XSEPARATOR;
if (state == TOK_BEGIN && c == '@' && !escape) state = TOK_TOKEN;
else if (state == TOK_TOKEN && ( (space && !escape) || c == '@' || (!space && escape)) && token_pos > 1) {
state = TOK_SEP;
}
STR_ALLOC(&result, result_pos, &size);
STR_ALLOC(&token, token_pos, &sizetok);
if (state == XTOKEN) token[token_pos++] = c;
else if (state == XSEPARATOR) {
if (state == TOK_TOKEN) token[token_pos++] = c;
else if (state == TOK_SEP) {
token[token_pos] = '\0';
token_pos = 0;
@ -2909,9 +2909,9 @@ const char *translate2(struct Lcc *lcc, int level, char* s)
if (c == '@') s--;
else result[result_pos++] = c;
state = XBEGIN;
state = TOK_BEGIN;
}
else if (state == XBEGIN) result[result_pos++] = c;
else if (state == TOK_BEGIN) result[result_pos++] = c;
if (c == '\0') {
result[result_pos] = '\0';
break;

View File

@ -287,9 +287,9 @@ void global_verilog_netlist(int global) /* netlister driver */
if(strcmp(xctx->sym[i].type,"subcircuit")==0 && check_lib(xctx->sym[i].name)) {
/* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */
my_strdup(328, &subckt_name, get_cell(xctx->sym[i].name, 0));
if (hash_lookup(subckt_table, subckt_name, "", XLOOKUP)==NULL)
if (str_hash_lookup(subckt_table, subckt_name, "", XLOOKUP)==NULL)
{
hash_lookup(subckt_table, subckt_name, "", XINSERT);
str_hash_lookup(subckt_table, subckt_name, "", XINSERT);
if( split_files && strcmp(get_tok_value(xctx->sym[i].prop_ptr,"vhdl_netlist",0),"true")==0 )
vhdl_block_netlist(fd, i);
else if(split_files && strcmp(get_tok_value(xctx->sym[i].prop_ptr,"spice_netlist",0),"true")==0 )

View File

@ -255,8 +255,8 @@ void global_vhdl_netlist(int global) /* netlister driver */
{
/* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */
my_strdup(317, &subckt_name, get_cell(xctx->sym[j].name, 0));
if (hash_lookup(subckt_table, subckt_name, "", XLOOKUP)==NULL) {
hash_lookup(subckt_table, subckt_name, "", XINSERT);
if (str_hash_lookup(subckt_table, subckt_name, "", XLOOKUP)==NULL) {
str_hash_lookup(subckt_table, subckt_name, "", XINSERT);
/* component generics */
print_generic(fd,"component", j);
@ -340,9 +340,9 @@ void global_vhdl_netlist(int global) /* netlister driver */
{
/* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */
my_strdup(327, &subckt_name, get_cell(xctx->sym[i].name, 0));
if (hash_lookup(subckt_table, subckt_name, "", XLOOKUP)==NULL)
if (str_hash_lookup(subckt_table, subckt_name, "", XLOOKUP)==NULL)
{
hash_lookup(subckt_table, subckt_name, "", XINSERT);
str_hash_lookup(subckt_table, subckt_name, "", XINSERT);
if( split_files && strcmp(get_tok_value(xctx->sym[i].prop_ptr,"verilog_netlist",0),"true")==0 )
verilog_block_netlist(fd, i);
else if( split_files && strcmp(get_tok_value(xctx->sym[i].prop_ptr,"spice_netlist",0),"true")==0 )

View File

@ -225,7 +225,7 @@ extern char win_temp_dir[PATH_MAX];
/* parameters passed to action functions, see actions.c */
#define END 1 /* endop */
#define BEGIN 2 /* begin placing something */
#define START 2 /* begin placing something */
#define PLACE 4 /* place something */
#define ADD 8 /* add something */
#define RUBBER 16 /* used for drawing rubber objects while placing them */
@ -264,7 +264,7 @@ extern char win_temp_dir[PATH_MAX];
#define RECTINSIDE(xa,ya,xb,yb,x1,y1,x2,y2) \
(xa>=x1 && xa<=x2 && xb>=x1 && xb<=x2 && ya>=y1 && ya<=y2 && yb>=y1 && yb<=y2 )
#define ROTATION(x0, y0, x, y, rx, ry) \
#define ROTATION(rot, flip, x0, y0, x, y, rx, ry) \
{ \
double xxtmp = (flip ? 2 * x0 -x : x); \
if(rot==0) {rx = xxtmp; ry = y;} \
@ -961,7 +961,7 @@ extern void check_unique_names(int rename);
extern void clear_instance_hash();
extern void free_hash(struct hashentry **table);
extern struct hashentry *hash_lookup(struct hashentry **table, const char *token, const char *value, int what);
extern struct hashentry *str_hash_lookup(struct hashentry **table, const char *token, const char *value, int what);
extern void free_int_hash(struct int_hashentry **table);
extern struct int_hashentry *int_hash_lookup(struct int_hashentry **table, const char *token, const int value, int what);