From 957b9888d129914af0fa4c91cfcca1d81a06cdd3 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Tue, 3 Nov 2020 12:10:55 +0100 Subject: [PATCH] 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 --- src/actions.c | 32 ++-- src/callback.c | 38 ++--- src/check.c | 2 +- src/draw.c | 48 +++--- src/editprop.c | 14 +- src/expandlabel.y | 7 +- src/findnet.c | 4 +- src/hilight.c | 6 +- src/move.c | 202 +++++++++++----------- src/netlist.c | 8 +- src/node_hash.c | 4 +- src/parselabel.l | 20 ++- src/paste.c | 2 +- src/psprint.c | 18 +- src/save.c | 20 +-- src/scheduler.c | 24 +-- src/select.c | 36 ++-- src/spice_netlist.c | 20 +-- src/svgdraw.c | 22 +-- src/token.c | 380 +++++++++++++++++++++--------------------- src/verilog_netlist.c | 4 +- src/vhdl_netlist.c | 8 +- src/xschem.h | 6 +- 23 files changed, 464 insertions(+), 461 deletions(-) diff --git a/src/actions.c b/src/actions.c index f772e2a9..26cc7204 100644 --- a/src/actions.c +++ b/src/actions.c @@ -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); diff --git a/src/callback.c b/src/callback.c index 67b271de..621e61bf 100644 --- a/src/callback.c +++ b/src/callback.c @@ -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); } diff --git a/src/check.c b/src/check.c index 3dd6238e..9a5af076 100644 --- a/src/check.c +++ b/src/check.c @@ -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); diff --git a/src/draw.c b/src/draw.c index 2d21dada..c27325c2 100644 --- a/src/draw.c +++ b/src/draw.c @@ -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;krects[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;krects[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) diff --git a/src/editprop.c b/src/editprop.c index 4ea3810f..771d627c 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -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; iarc[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; kpoly[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;kinst[i].ptr + xctx->sym)->rects[PINLAYER]; k++) { diff --git a/src/expandlabel.y b/src/expandlabel.y index 39aee915..e4aeb39b 100644 --- a/src/expandlabel.y +++ b/src/expandlabel.y @@ -28,13 +28,14 @@ #include #include - +#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, ...); diff --git a/src/findnet.c b/src/findnet.c index 7312d763..2972eb2b 100644 --- a/src/findnet.c +++ b/src/findnet.c @@ -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; jinst[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; diff --git a/src/hilight.c b/src/hilight.c index ccb5ae27..e3822f0a 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -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); } diff --git a/src/move.c b/src/move.c index 10f87216..9965d181 100644 --- a/src/move.c +++ b/src/move.c @@ -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;kpoly[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;kinst[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(); diff --git a/src/netlist.c b/src/netlist.c index 12025623..3638be2d 100644 --- a/src/netlist.c +++ b/src/netlist.c @@ -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); diff --git a/src/node_hash.c b/src/node_hash.c index f018473a..6a9aa5a0 100644 --- a/src/node_hash.c +++ b/src/node_hash.c @@ -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]; diff --git a/src/parselabel.l b/src/parselabel.l index 8ebeaae9..b52de9d8 100644 --- a/src/parselabel.l +++ b/src/parselabel.l @@ -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; } [\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; } -