diff --git a/scconfig/hooks.c b/scconfig/hooks.c index da79fcb6..53f97052 100644 --- a/scconfig/hooks.c +++ b/scconfig/hooks.c @@ -181,7 +181,7 @@ int hook_detect_target() /* for --debug mode, use -ansi -pedantic for all detection */ if (istrue(get("/local/xschem/debug"))) { - append("cc/cflags", " -g -O0"); + append("cc/cflags", " -g -O0 -Wconversion -Wno-sign-conversion"); if (require("cc/argstd/Wall", 0, 0) == 0) { append("cc/cflags", " "); append("cc/cflags", get("cc/argstd/Wall")); @@ -226,7 +226,7 @@ int hook_detect_target() require("libs/io/dup2/*", 0, 0); /* Stefan: query dup2() availability */ require("parsgen/flex/presents", 0, 1); require("parsgen/bison/presents", 0, 1); - require("libs/script/tk/*", 0, 1); /* this will also bring libs/script/tcl/* */ + require("libs/script/tk/*", 0, 1); /* this will also bring libs/script/tcl */ require("fstools/awk", 0, 1); require("libs/gui/xpm/*", 0, 1); require("libs/gui/cairo/*", 0, 0); diff --git a/src/actions.c b/src/actions.c index da2453d5..f8965dc1 100644 --- a/src/actions.c +++ b/src/actions.c @@ -696,17 +696,18 @@ void enable_layers(void) } } -int connect_by_kissing(void) +short connect_by_kissing(void) { xSymbol *symbol; int npin, i, j; double x0,y0, pinx0, piny0; short flip, rot; xRect *rct; - int k,ii, kissing, done_undo = 0; + short kissing, changed = 0; + int k, ii, done_undo = 0; Wireentry *wptr; Instpinentry *iptr; - int sqx, sqy, changed = 0; + int sqx, sqy; rebuild_selected_array(); k = xctx->lastsel; @@ -788,7 +789,7 @@ void attach_labels_to_inst(int interactive) /* offloaded from callback.c 201710 const char *symname_pin2 = "lab_pin.sym"; const char *symname_wire2 = "lab_wire.sym"; char *type=NULL; - int dir; + short dir; int k,ii, skip; int do_all_inst=0; const char *rot_txt; @@ -913,9 +914,9 @@ void attach_labels_to_inst(int interactive) /* offloaded from callback.c 201710 dir ^= flip; /* 20101129 20111030 */ if(rotated_text ==-1) { rot1=rot; - if(rot1==1 || rot1==2) { dir=!dir;rot1 = (rot1+2) %4;} + if(rot1==1 || rot1==2) { dir=!dir;rot1 = (short)((rot1+2) %4);} } else { - rot1=(rot+rotated_text)%4; /* 20111103 20171208 text_rotation */ + rot1=(short)((rot+rotated_text)%4); /* 20111103 20171208 text_rotation */ } if(!strcmp(tclgetvar("use_lab_wire"),"0")) { if(indirect) @@ -1399,7 +1400,7 @@ void go_back(int confirm) /* 20171006 add confirm */ so glob patterns containing Windows style path separators need special care.*/ void change_to_unix_fn(char* fn) { - int len, i, ii; + size_t len, i, ii; len = strlen(fn); ii = 0; for (i = 0; i < len; ++i) { @@ -1651,8 +1652,8 @@ void set_viewport_size(int w, int h, double lw) { xctx->xrect[0].x = 0; xctx->xrect[0].y = 0; - xctx->xrect[0].width = w; - xctx->xrect[0].height = h; + xctx->xrect[0].width = (unsigned short)w; + xctx->xrect[0].height = (unsigned short)h; xctx->areax2 = w+2*INT_WIDTH(lw); xctx->areay2 = h+2*INT_WIDTH(lw); xctx->areax1 = -2*INT_WIDTH(lw); @@ -1677,8 +1678,8 @@ void save_restore_zoom(int save) } else { xctx->xrect[0].x = 0; xctx->xrect[0].y = 0; - xctx->xrect[0].width = savew; - xctx->xrect[0].height = saveh; + xctx->xrect[0].width = (unsigned short)savew; + xctx->xrect[0].height = (unsigned short)saveh; xctx->areax2 = savew+2*INT_WIDTH(savelw); xctx->areay2 = saveh+2*INT_WIDTH(savelw); xctx->areax1 = -2*INT_WIDTH(savelw); @@ -1768,10 +1769,10 @@ void draw_stuff(void) #endif for(i = 0; i < n; i++) { - w=(float)(xctx->areaw*xctx->zoom/800) * rand() / (RAND_MAX+1.0); - h=(float)(xctx->areah*xctx->zoom/80) * rand() / (RAND_MAX+1.0); - x1=(float)(xctx->areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin; - y1=(float)(xctx->areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin; + w=(xctx->areaw*xctx->zoom/800) * rand() / (RAND_MAX+1.0); + h=(xctx->areah*xctx->zoom/80) * rand() / (RAND_MAX+1.0); + x1=(xctx->areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin; + y1=(xctx->areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin; x2=x1+w; y2=y1+h; ORDER(x1,y1,x2,y2); @@ -1785,10 +1786,10 @@ void draw_stuff(void) for(i = 0; i < n; i++) { - w=(float)(xctx->areaw*xctx->zoom/80) * rand() / (RAND_MAX+1.0); - h=(float)(xctx->areah*xctx->zoom/800) * rand() / (RAND_MAX+1.0); - x1=(float)(xctx->areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin; - y1=(float)(xctx->areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin; + w=(xctx->areaw*xctx->zoom/80) * rand() / (RAND_MAX+1.0); + h=(xctx->areah*xctx->zoom/800) * rand() / (RAND_MAX+1.0); + x1=(xctx->areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin; + y1=(xctx->areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin; x2=x1+w; y2=y1+h; ORDER(x1,y1,x2,y2); @@ -1802,10 +1803,10 @@ void draw_stuff(void) for(i = 0; i < n; i++) { - w=(float)xctx->zoom * rand() / (RAND_MAX+1.0); + w=xctx->zoom * rand() / (RAND_MAX+1.0); h=w; - x1=(float)(xctx->areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin; - y1=(float)(xctx->areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin; + x1=(xctx->areaw*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->xorigin; + y1=(xctx->areah*xctx->zoom) * rand() / (RAND_MAX+1.0)-xctx->yorigin; x2=x1+w; y2=y1+h; RECTORDER(x1,y1,x2,y2); diff --git a/src/callback.c b/src/callback.c index 4c75c7b3..5e1d343c 100644 --- a/src/callback.c +++ b/src/callback.c @@ -22,7 +22,7 @@ #include "xschem.h" -static int waves_selected(int event, int key, int state, int button) +static int waves_selected(int event, int state, int button) { int i; int is_inside = 0, skip = 0; @@ -88,7 +88,7 @@ static void abort_operation(void) constrained_move=0; xctx->last_command=0; xctx->manhattan_lines = 0; - dbg(1, "abort_operation(): Escape: ui_state=%ld\n", xctx->ui_state); + dbg(1, "abort_operation(): Escape: ui_state=%d\n", xctx->ui_state); if(xctx->ui_state & STARTMOVE) { move_objects(ABORT,0,0,0); @@ -862,7 +862,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, { if(debug_var>=2) if(event != MotionNotify) - fprintf(errfp, "callback(): reentrant call of callback(), semaphore=%d, ev=%d, ui_state=%ld\n", + fprintf(errfp, "callback(): reentrant call of callback(), semaphore=%d, ev=%d, ui_state=%d\n", xctx->semaphore, event, xctx->ui_state); } xctx->mousex=X_TO_XSCHEM(mx); @@ -903,10 +903,10 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, mx,my,button,aux,mx,my); { XRectangle xr[1]; - xr[0].x=mx; - xr[0].y=my; - xr[0].width=button; - xr[0].height=aux; + xr[0].x=(short)mx; + xr[0].y=(short)my; + xr[0].width=(unsigned short)button; + xr[0].height=(unsigned short)aux; /* redraw selection on expose, needed if no backing store available on the server 20171112 */ XSetClipRectangles(display, xctx->gc[SELLAYER], 0,0, xr, 1, Unsorted); rebuild_selected_array(); @@ -921,7 +921,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, break; case MotionNotify: - if( waves_selected(event, key, state, button)) { + if( waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -1324,7 +1324,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, if(key<='9' && key >='0' && state==ControlMask) /* choose layer */ { char n[30]; - xctx->rectcolor = key - '0'+4; + xctx->rectcolor = (int)key - '0'+4; my_snprintf(n, S(n), "%d", xctx->rectcolor); tclvareval("xschem set rectcolor ", n, NULL); @@ -1351,7 +1351,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key==XK_Right && !(state & ControlMask)) /* left */ { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -1362,7 +1362,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key==XK_Left && !(state & ControlMask)) /* right */ { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -1373,7 +1373,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key==XK_Down) /* down */ { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -1384,7 +1384,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key==XK_Up) /* up */ { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -1502,7 +1502,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, if(key=='a' && state == 0) /* make symbol */ { if(xctx->semaphore >= 2) break; - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -1733,7 +1733,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, xctx->enable_drill = 0; if(exists) { if(!tool) { - tool = atol(tclgetvar("sim(spicewave,default)")); + tool = atoi(tclgetvar("sim(spicewave,default)")); my_snprintf(str, S(str), "sim(spicewave,%d,name)", tool); my_strdup(1271, &tool_name, tclgetvar(str)); dbg(1,"callback(): tool_name=%s\n", tool_name); @@ -1860,7 +1860,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, if(key >= '0' && key <= '4' && state == 0) { /* toggle pin logic level */ if(xctx->semaphore >= 2) break; if(key == '4') logic_set(-1, 1); - else logic_set(key - '0', 1); + else logic_set((int)key - '0', 1); break; } if(key=='L' && state == (Mod1Mask | ShiftMask)) { /* add pin label*/ @@ -1935,7 +1935,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key=='m' && state==0 && !(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */ { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -2066,7 +2066,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, if(key=='b' && state==0) /* merge schematic */ { if(xctx->semaphore >= 2) break; - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -2133,7 +2133,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key=='f' && state == 0 ) /* full zoom */ { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -2153,8 +2153,8 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } break; case ButtonPress: /* end operation */ - dbg(1, "callback(): ButtonPress ui_state=%ld state=%d\n",xctx->ui_state,state); - if(waves_selected(event, key, state, button)) { + dbg(1, "callback(): ButtonPress ui_state=%d state=%d\n",xctx->ui_state,state); + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -2308,21 +2308,21 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } } else if(button==Button5 && state == 0 ) { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } view_unzoom(CADZOOMSTEP); } else if(button==Button4 && state == 0 ) { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } view_zoom(CADZOOMSTEP); } else if(button==Button4 && (state & ShiftMask) && !(state & Button2Mask)) { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -2331,7 +2331,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, redraw_w_a_l_r_p_rubbers(); } else if(button==Button5 && (state & ShiftMask) && !(state & Button2Mask)) { - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -2549,7 +2549,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } /* button==Button1 */ break; case ButtonRelease: - if(waves_selected(event, key, state, button)) { + if(waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } @@ -2561,7 +2561,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, redraw_w_a_l_r_p_rubbers(); break; } - dbg(1, "callback(): ButtonRelease ui_state=%ld state=%d\n",xctx->ui_state,state); + dbg(1, "callback(): ButtonRelease ui_state=%d state=%d\n",xctx->ui_state,state); if(xctx->semaphore >= 2) break; if(xctx->ui_state & STARTSELECT) { if(state & ControlMask) { @@ -2581,12 +2581,12 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } break; case -3: /* double click : edit prop */ - if( waves_selected(event, key, state, button)) { + if( waves_selected(event, state, button)) { waves_callback(event, mx, my, key, button, aux, state); break; } if(xctx->semaphore >= 2) break; - dbg(1, "callback(): DoubleClick ui_state=%ld state=%d\n",xctx->ui_state,state); + dbg(1, "callback(): DoubleClick ui_state=%d state=%d\n",xctx->ui_state,state); if(button==Button1) { if(xctx->ui_state == STARTWIRE) { xctx->ui_state &= ~STARTWIRE; diff --git a/src/draw.c b/src/draw.c index d6b96d02..be235cab 100644 --- a/src/draw.c +++ b/src/draw.c @@ -360,7 +360,7 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in a=0.0; continue; } - lines=character[cc][0]*4; + lines=(int)character[cc][0]*4; char_ptr_x1=character[cc]+1; char_ptr_y1=character[cc]+2; char_ptr_x2=character[cc]+3; @@ -776,8 +776,8 @@ static void drawgrid() xctx->biggridpoint[i].y1 = xctx->biggridpoint[i].y2 = (short)(y); i++; } else { - xctx->gridpoint[i].x=(int)(x); - xctx->gridpoint[i].y=(int)(y); + xctx->gridpoint[i].x=(short)(x); + xctx->gridpoint[i].y=(short)(y); i++; } } @@ -856,7 +856,7 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub if( clip(&x1,&y1,&x2,&y2) ) { if(dash) { - dash_arr[0] = dash_arr[1] = dash; + dash_arr[0] = dash_arr[1] = (char) dash; XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } @@ -879,7 +879,7 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub if( clip(&x1,&y1,&x2,&y2) ) { if(dash) { - dash_arr[0] = dash_arr[1] = dash; + dash_arr[0] = dash_arr[1] = (char) dash; XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); XSetLineAttributes (display, xctx->gc[c], INT_BUS_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } else { @@ -1012,8 +1012,8 @@ void drawtemparc(GC gc, int what, double x, double y, double r, double a, double xarc[i].y=(short)yy1; xarc[i].width= (unsigned short)(xx2 - xx1); xarc[i].height=(unsigned short)(yy2 - yy1); - xarc[i].angle1 = (int)(a*64); - xarc[i].angle2 = (int)(b*64); + xarc[i].angle1 = (short)(a*64); + xarc[i].angle2 = (short)(b*64); i++; } } @@ -1107,8 +1107,8 @@ void filledarc(int c, int what, double x, double y, double r, double a, double b xarc[i].y=(short)yy1; xarc[i].width =(unsigned short)(xx2 - xx1); xarc[i].height=(unsigned short)(yy2 - yy1); - xarc[i].angle1 = (int)(a*64); - xarc[i].angle2 = (int)(b*64); + xarc[i].angle1 = (short)(a*64); + xarc[i].angle2 = (short)(b*64); i++; } } @@ -1173,8 +1173,8 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b, xarc[i].y=(short)yy1; xarc[i].width =(unsigned short)(xx2 - xx1); xarc[i].height=(unsigned short)(yy2 - yy1); - xarc[i].angle1 = (int)(a*64); - xarc[i].angle2 = (int)(b*64); + xarc[i].angle1 = (short)(a*64); + xarc[i].angle2 = (short)(b*64); i++; } } @@ -1196,7 +1196,7 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b, { if(dash) { char dash_arr[2]; - dash_arr[0] = dash_arr[1] = dash; + dash_arr[0] = dash_arr[1] = (char)dash; XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } @@ -1278,8 +1278,8 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl { r[i].x=(short)x1; r[i].y=(short)y1; - r[i].width=(unsigned short)x2-r[i].x; - r[i].height=(unsigned short)y2-r[i].y; + r[i].width=(unsigned short)(x2-r[i].x); + r[i].height=(unsigned short)(y2-r[i].y); i++; } } @@ -1394,7 +1394,7 @@ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fil } if(dash) { char dash_arr[2]; - dash_arr[0] = dash_arr[1] = dash; + dash_arr[0] = dash_arr[1] = (char)dash; XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } @@ -1458,7 +1458,7 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double if( rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&x1,&y1,&x2,&y2) ) { if(dash) { - dash_arr[0] = dash_arr[1] = dash; + dash_arr[0] = dash_arr[1] = (char)dash; XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } @@ -1494,8 +1494,8 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double { r[i].x=(short)x1; r[i].y=(short)y1; - r[i].width=(unsigned short)x2-r[i].x; - r[i].height=(unsigned short)y2-r[i].y; + r[i].width=(unsigned short)(x2-r[i].x); + r[i].height=(unsigned short)(y2-r[i].y); i++; } } @@ -1544,8 +1544,8 @@ void drawtemprect(GC gc, int what, double rectx1,double recty1,double rectx2,dou { r[i].x=(short)x1; r[i].y=(short)y1; - r[i].width=(unsigned short)x2-r[i].x; - r[i].height=(unsigned short)y2-r[i].y; + r[i].width=(unsigned short)(x2-r[i].x); + r[i].height=(unsigned short)(y2-r[i].y); i++; } } @@ -2082,7 +2082,7 @@ static void draw_cursor(double active_cursorx, double other_cursorx, int cursor_ int tmp; char tmpstr[1024]; double txtsize = gr->txtsizex; - int flip = (other_cursorx > active_cursorx) ? 0 : 1; + short flip = (other_cursorx > active_cursorx) ? 0 : 1; int xoffs = flip ? 3 : -3; if(xx >= gr->x1 && xx <= gr->x2) { @@ -2624,7 +2624,7 @@ void draw_graph(int i, const int flags, Graph_ctx *gr) if(xx >= start && xx <= end) { if(first == -1) first = p; /* Build poly x array. Translate from graph coordinates to screen coords */ - point[poly_npoints].x = (int)S_X(xx); + point[poly_npoints].x = (short)S_X(xx); if(dataset == -1 || dataset == sweepvar_wrap) { if(measure_p == -1 && flags & 2 && cnt) { /* cursor1: show measurements on nodes in graph */ if(XSIGN(xx - xctx->graph_cursor1_x) != XSIGN(prev_x - xctx->graph_cursor1_x)) { diff --git a/src/editprop.c b/src/editprop.c index f618053d..3255baa2 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -453,7 +453,7 @@ void my_free(int id, void *ptr) * not fit(d[n-1]='\0') * return # of copied characters */ -int my_strncpy(char *d, const char *s, int n) +int my_strncpy(char *d, const char *s, size_t n) { int i = 0; n -= 1; @@ -544,7 +544,7 @@ static void edit_rect_property(int x) dash = get_tok_value(xctx->rect[c][n].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); - xctx->rect[c][n].dash = d >= 0? d : 0; + xctx->rect[c][n].dash = (short)(d >= 0? d : 0); } else xctx->rect[c][n].dash = 0; if( (oldprop && xctx->rect[c][n].prop_ptr && strcmp(oldprop, xctx->rect[c][n].prop_ptr)) || @@ -607,7 +607,7 @@ static void edit_line_property(void) dash = get_tok_value(xctx->line[c][n].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); - xctx->line[c][n].dash = d >= 0? d : 0; + xctx->line[c][n].dash = (short)(d >= 0? d : 0); } else xctx->line[c][n].dash = 0; if(xctx->line[c][n].y1 < xctx->line[c][n].y2) { @@ -732,7 +732,7 @@ static void edit_arc_property(void) dash = get_tok_value(xctx->arc[c][i].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); - xctx->arc[c][i].dash = d >= 0 ? d : 0; + xctx->arc[c][i].dash = (short)(d >= 0 ? d : 0); } else xctx->arc[c][i].dash = 0; @@ -800,7 +800,7 @@ static void edit_polygon_property(void) dash = get_tok_value(xctx->poly[c][i].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); - xctx->poly[c][i].dash = d >= 0 ? d : 0; + xctx->poly[c][i].dash = (short)(d >= 0 ? d : 0); } else xctx->poly[c][i].dash = 0; if(old_fill != xctx->poly[c][i].fill || old_dash != xctx->poly[c][i].dash) { @@ -890,7 +890,7 @@ static void edit_text_property(int x) customfont = set_text_custom_font(&xctx->text[sel]); #endif text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale, - xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, + xctx->text[sel].yscale, (short)rot, (short)flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0, &xx1,&yy1,&xx2,&yy2, &tmp, &dtmp); #if HAS_CAIRO==1 @@ -911,7 +911,7 @@ static void edit_text_property(int x) customfont = set_text_custom_font(&xctx->text[sel]); #endif text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale, - xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, + xctx->text[sel].yscale, (short)rot, (short)flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0, &xx1,&yy1,&xx2,&yy2, &tmp, &dtmp); #if HAS_CAIRO==1 @@ -978,7 +978,7 @@ static void edit_text_property(int x) customfont = set_text_custom_font(&xctx->text[sel]); #endif text_bbox(xctx->text[sel].txt_ptr, xctx->text[sel].xscale, - xctx->text[sel].yscale, rot, flip, xctx->text[sel].hcenter, + xctx->text[sel].yscale, (short)rot, (short)flip, xctx->text[sel].hcenter, xctx->text[sel].vcenter, xctx->text[sel].x0, xctx->text[sel].y0, &xx1,&yy1,&xx2,&yy2, &tmp, &dtmp); #if HAS_CAIRO==1 @@ -1109,7 +1109,7 @@ static void update_symbol(const char *result, int x) if(name && name[0] ) { dbg(1, "update_symbol(): prefix!='\\0', name=%s\n", name); /* 20110325 only modify prefix if prefix not NUL */ - if(prefix) name[0]=prefix; /* change prefix if changing symbol type; */ + if(prefix) name[0]=(char)prefix; /* change prefix if changing symbol type; */ dbg(1, "update_symbol(): name=%s, inst[*ii].prop_ptr=%s\n", name, xctx->inst[*ii].prop_ptr); my_strdup(89, &ptr,subst_token(xctx->inst[*ii].prop_ptr, "name", name) ); diff --git a/src/expandlabel.y b/src/expandlabel.y index b812910b..a6bb4aae 100644 --- a/src/expandlabel.y +++ b/src/expandlabel.y @@ -52,7 +52,7 @@ extern void my_realloc(int id, void *ptr,size_t size); 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, ...); +extern size_t my_snprintf(char *str, size_t size, const char *fmt, ...); extern int yyparse_error; @@ -83,7 +83,7 @@ static char *expandlabel_strdup(char *src) static char *expandlabel_strcat(char *s1, char *s2) /* concatenates s1 and s2, with c in between */ { - int l1=0,l2=0; + size_t l1=0,l2=0; char *res; if(s1) l1=strlen(s1); @@ -98,7 +98,7 @@ static char *expandlabel_strcat(char *s1, char *s2) static char *expandlabel_strcat_char(char *s1, char c, char *s2) /* concatenates s1 and s2, with c in between */ { - int l1=0,l2=0; + size_t l1=0,l2=0; char *res; if(s1) l1=strlen(s1); @@ -117,7 +117,8 @@ static char *expandlabel_strcat_char(char *s1, char c, char *s2) static char *expandlabel_strmult2(int n, char *s) /* if n==0 returns "\0" */ { - register int i, len; + register int i; + register size_t len; register char *pos,*prev; char *str, *ss; @@ -152,7 +153,8 @@ static char *expandlabel_strmult2(int n, char *s) static char *expandlabel_strmult(int n, char *s) /* if n==0 returns "\0" */ { - register int i, len; + register int i; + register size_t len; register char *pos; char *str; @@ -318,7 +320,7 @@ list: B_NAME { | list B_CAR list { dbg(3, "yyparse(): list B_CAR list\n"); - $$.str=expandlabel_strcat_char($1.str, $2, $3.str); + $$.str=expandlabel_strcat_char($1.str, (char)$2, $3.str); $$.m = $1.m + $3.m; my_free(744, &$1.str); my_free(745, &$3.str); @@ -329,7 +331,7 @@ list: B_NAME { } | B_NAME '[' B_NAME ']' { - int size = strlen($1) + strlen($3) + 3; + size_t size = strlen($1) + strlen($3) + 3; $$.str = my_malloc(81, size); $$.m=-1; my_snprintf($$.str, size, "%s[%s]", $1, $3); diff --git a/src/hilight.c b/src/hilight.c index 7fd086a0..766d86d8 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -88,8 +88,8 @@ static Hilight_hashentry *hilight_hash_lookup(const char *token, int value, int preventry=&xctx->hilight_table[index]; while(1) { if( !entry ) { /* empty slot */ - int lent = strlen(token) + 1; - int lenp = strlen(xctx->sch_path[xctx->currsch]) + 1; + size_t lent = strlen(token) + 1; + size_t lenp = strlen(xctx->sch_path[xctx->currsch]) + 1; if( what==XINSERT || what == XINSERT_NOREPLACE) { /* insert data */ s=sizeof( Hilight_hashentry ); entry= (Hilight_hashentry *)my_malloc(137, s ); @@ -254,7 +254,7 @@ void create_plot_cmd(void) if(tclresult()[0] == '1') exists = 1; xctx->enable_drill = 0; if(exists) { - viewer = atol(tclgetvar("sim(spicewave,default)")); + viewer = atoi(tclgetvar("sim(spicewave,default)")); my_snprintf(tcl_str, S(tcl_str), "sim(spicewave,%d,name)", viewer); my_strdup(1269, &viewer_name, tclgetvar(tcl_str)); dbg(1,"create_plot_cmd(): viewer_name=%s\n", viewer_name); @@ -562,7 +562,7 @@ int search(const char *tok, const char *val, int sub, int sel) int i,c, col = 7,tmp,bus=0; const char *str; char *type; - int has_token; + size_t has_token; const char *empty_string = ""; char *tmpname=NULL; int found = 0; diff --git a/src/parselabel.l b/src/parselabel.l index 56b3bf66..4b4ec382 100644 --- a/src/parselabel.l +++ b/src/parselabel.l @@ -104,7 +104,7 @@ const char *expandlabel(const char *s, int *m) yy_delete_buffer(buf); if(yyparse_error==1) { char *cmd = NULL; - int l; + size_t l; yyparse_error = -1; l = strlen(s)+120; cmd = my_malloc(526, l); diff --git a/src/paste.c b/src/paste.c index 1731499b..4ce2b0be 100644 --- a/src/paste.c +++ b/src/paste.c @@ -118,7 +118,7 @@ static void merge_box(FILE *fd) dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); - ptr[i].dash = d >= 0 ? d : 0; + ptr[i].dash = (short)(d >= 0 ? d : 0); } else { ptr[i].dash = 0; } @@ -160,7 +160,7 @@ static void merge_arc(FILE *fd) dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); - ptr[i].dash = d >= 0 ? d : 0; + ptr[i].dash = (short)(d >= 0 ? d : 0); } else { ptr[i].dash = 0; } @@ -217,7 +217,7 @@ static void merge_polygon(FILE *fd) dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); - ptr[i].dash = d >= 0 ? d : 0; + ptr[i].dash = (short)(d >= 0 ? d : 0); } else { ptr[i].dash = 0; } @@ -254,7 +254,7 @@ static void merge_line(FILE *fd) dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); - ptr[i].dash = d >= 0 ? d : 0; + ptr[i].dash = (short)(d >= 0 ? d : 0); } else { ptr[i].dash = 0; } @@ -263,10 +263,6 @@ static void merge_line(FILE *fd) set_modify(1); } - - - - static void merge_inst(int k,FILE *fd) { int i; diff --git a/src/psprint.c b/src/psprint.c index 6862d364..5b0d94eb 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -89,9 +89,9 @@ char *utf8[]={ static FILE *fd; typedef struct { - int red; - int green; - int blue; + unsigned int red; + unsigned int green; + unsigned int blue; } Ps_color; static Ps_color *ps_colors; @@ -673,7 +673,7 @@ static void fill_ps_colors() * } */ for(i=0;i> 16; diff --git a/src/save.c b/src/save.c index 6b881aca..a142fdb9 100644 --- a/src/save.c +++ b/src/save.c @@ -186,7 +186,8 @@ unsigned char *base64_decode(const char *data, const size_t input_length, size_t 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f }; unsigned char *decoded_data; - int i, j, sextet[4], triple, cnt, padding, actual_length; + int i, j, sextet[4], triple, cnt, padding; + size_t actual_length; actual_length = input_length; *output_length = input_length / 4 * 3 + 4; /* add 4 more just in case... */ @@ -206,9 +207,9 @@ unsigned char *base64_decode(const char *data, const size_t input_length, size_t sextet[cnt & 3] = data[i] == '=' ? 0 : b64_dec[(int)data[i]]; if((cnt & 3) == 3) { triple = (sextet[0] << 18) + (sextet[1] << 12) + (sextet[2] << 6) + (sextet[3]); - decoded_data[j++] = (triple >> 16) & 0xFF; - decoded_data[j++] = (triple >> 8) & 0xFF; - decoded_data[j++] = (triple) & 0xFF; + decoded_data[j++] = (unsigned char)((triple >> 16) & 0xFF); + decoded_data[j++] = (unsigned char)((triple >> 8) & 0xFF); + decoded_data[j++] = (unsigned char)((triple) & 0xFF); } cnt++; i++; @@ -871,9 +872,8 @@ static const char *random_string(const char *prefix) static const char *charset="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; static const int random_size=10; static char str[PATH_MAX]; /* safe even with multiple schematics, if immediately copied */ - int prefix_size; + size_t prefix_size, i; static unsigned short once=1; /* safe even with multiple schematics, set once and never changed */ - int i; int idx; if(once) { srand((unsigned short) time(NULL)); @@ -960,9 +960,10 @@ void updatebbox(int count, xRect *boundbox, xRect *tmp) void save_ascii_string(const char *ptr, FILE *fd, int newline) { - int c, len, strbuf_pos = 0; + int c; + size_t len, strbuf_pos = 0; static char *strbuf = NULL; /* safe even with multiple schematics */ - static int strbuf_size=0; /* safe even with multiple schematics */ + static size_t strbuf_size=0; /* safe even with multiple schematics */ if(ptr == NULL) { if( fd == NULL) { /* used to clear static data */ @@ -981,7 +982,7 @@ void save_ascii_string(const char *ptr, FILE *fd, int newline) while( (c = *ptr++) ) { if(strbuf_pos > strbuf_size - 6) my_realloc(525, &strbuf, (strbuf_size += CADCHUNKALLOC)); if( c=='\\' || c=='{' || c=='}') strbuf[strbuf_pos++] = '\\'; - strbuf[strbuf_pos++] = c; + strbuf[strbuf_pos++] = (char)c; } strbuf[strbuf_pos++] = '}'; if(newline) strbuf[strbuf_pos++] = '\n'; @@ -1199,7 +1200,7 @@ static void save_line(FILE *fd, int select_only) static void write_xschem_file(FILE *fd) { - int ty=0; + size_t ty=0; char *ptr; if(xctx->version_string && (ptr = strstr(xctx->version_string, "xschem")) && @@ -1415,7 +1416,7 @@ static void load_polygon(FILE *fd) dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); - ptr[i].dash = d >= 0 ? d : 0; + ptr[i].dash = (short)(d >= 0 ? d : 0); } else { ptr[i].dash = 0; } @@ -1455,7 +1456,7 @@ static void load_arc(FILE *fd) dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); - ptr[i].dash = d >= 0 ? d : 0; + ptr[i].dash = (short)(d >= 0 ? d : 0); } else { ptr[i].dash = 0; } @@ -1492,7 +1493,7 @@ static void load_box(FILE *fd) dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); - ptr[i].dash = d >= 0 ? d : 0; + ptr[i].dash = (short)(d >= 0 ? d : 0); } else { ptr[i].dash = 0; } @@ -1534,7 +1535,7 @@ static void load_line(FILE *fd) dash = get_tok_value(ptr[i].prop_ptr,"dash",0); if(strcmp(dash, "")) { int d = atoi(dash); - ptr[i].dash = d >= 0 ? d : 0; + ptr[i].dash = (short)(d >= 0 ? d : 0); } else { ptr[i].dash = 0; } @@ -1547,7 +1548,7 @@ static void read_xschem_file(FILE *fd) char name_embedded[PATH_MAX]; char tag[1]; int inst_cnt; - int ty=0; + size_t ty=0; dbg(2, "read_xschem_file(): start\n"); inst_cnt = endfile = 0; @@ -1701,7 +1702,7 @@ void load_ascii_string(char **ptr, FILE *fd) continue; } } - str[i]=c; + str[i]=(char)c; escape = 0; i++; } else if(c=='{') begin=1; @@ -2310,7 +2311,8 @@ static void align_sch_pins_with_sym(const char *name, int pos) static void add_pinlayer_boxes(int *lastr, xRect **bb, const char *symtype, char *prop_ptr, double i_x0, double i_y0) { - int i, save; + int i; + size_t save; const char *label; char *pin_label = NULL; @@ -2453,7 +2455,11 @@ int load_sym_def(const char *name, FILE *embed_fd) int incremented_level=0; int level = 0; int max_level, fscan_ret; +#ifdef __unix__ long filepos; +#else + __int3264 filepos; +#endif char sympath[PATH_MAX]; int i,c, k, poly_points; char *aux_ptr=NULL; @@ -2626,7 +2632,7 @@ int load_sym_def(const char *name, FILE *embed_fd) dash = get_tok_value(ll[c][i].prop_ptr,"dash", 0); if( strcmp(dash, "") ) { int d = atoi(dash); - ll[c][i].dash = d >= 0 ? d : 0; + ll[c][i].dash = (short)(d >= 0 ? d : 0); } else ll[c][i].dash = 0; ll[c][i].sel = 0; @@ -2669,7 +2675,7 @@ int load_sym_def(const char *name, FILE *embed_fd) dash = get_tok_value(pp[c][i].prop_ptr,"dash", 0); if( strcmp(dash, "") ) { int d = atoi(dash); - pp[c][i].dash = d >= 0 ? d : 0; + pp[c][i].dash = (short)(d >= 0 ? d : 0); } else pp[c][i].dash = 0; pp[c][i].sel = 0; @@ -2715,7 +2721,7 @@ int load_sym_def(const char *name, FILE *embed_fd) dash = get_tok_value(aa[c][i].prop_ptr,"dash", 0); if( strcmp(dash, "") ) { int d = atoi(dash); - aa[c][i].dash = d >= 0 ? d : 0; + aa[c][i].dash = (short)(d >= 0 ? d : 0); } else aa[c][i].dash = 0; aa[c][i].sel = 0; @@ -2754,7 +2760,7 @@ int load_sym_def(const char *name, FILE *embed_fd) dash = get_tok_value(bb[c][i].prop_ptr,"dash", 0); if( strcmp(dash, "") ) { int d = atoi(dash); - bb[c][i].dash = d >= 0 ? d : 0; + bb[c][i].dash = (short)(d >= 0 ? d : 0); } else bb[c][i].dash = 0; bb[c][i].sel = 0; @@ -2937,7 +2943,8 @@ int load_sym_def(const char *name, FILE *embed_fd) flip = lcc[level-1].flip; rot = lcc[level-1].rot; 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 = (short)((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; lcc[level].x0 += lcc[(level-1)].x0; @@ -3079,7 +3086,7 @@ void create_sch_from_sym(void) char *str=NULL; struct stat buf; char *sch = NULL; - int ln; + size_t ln; if(!stat(abs_sym_path(pinname[0], ""), &buf)) { indirect=1; diff --git a/src/scheduler.c b/src/scheduler.c index 52ea9c27..b93de587 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -53,7 +53,7 @@ static int get_instance(const char *s) dbg(1, "get_instance(): found=%d, i=%d\n", found, i); if(!found) { if(!isonlydigit(s)) return -1; - i=atol(s); + i=atoi(s); } if(i<0 || i>xctx->instances) { return -1; @@ -953,7 +953,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } else { change_to_unix_fn(s); - int slen = strlen(s); + size_t slen = strlen(s); if(s[slen - 1] == '/') s[slen - 1] = '\0'; my_strncpy(win_temp_dir, s, S(win_temp_dir)); dbg(2, "scheduler(): win_temp_dir is %s\n", win_temp_dir); @@ -1273,13 +1273,17 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg { cmd_found = 1; if(argc==7) - /* pos sym_name x y rot flip prop draw first */ - place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]),NULL, 3, 1, 1/*to_push_undo*/); + /* pos sym_name x y rot */ + place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), (short)atoi(argv[5]), + /* flip prop draw first ito_push_undo */ + (short)atoi(argv[6]),NULL, 3, 1, 1); else if(argc==8) - place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]), argv[7], 3, 1, 1/*to_push_undo*/); + place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), (short)atoi(argv[5]), + (short)atoi(argv[6]), argv[7], 3, 1, 1); else if(argc==9) { int x = !(atoi(argv[8])); - place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), atoi(argv[5]), atoi(argv[6]), argv[7], 0, x, 1/*to_push_undo*/); + place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), (short)atoi(argv[5]), + (short)atoi(argv[6]), argv[7], 0, x, 1); } } @@ -1522,7 +1526,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg y2=atof(argv[5]); ORDER(x1,y1,x2,y2); pos=-1; - if(argc==7) pos=atol(argv[6]); + if(argc==7) pos=atoi(argv[6]); storeobject(pos, x1,y1,x2,y2,LINE,xctx->rectcolor,0,NULL); save = xctx->draw_window; xctx->draw_window = 1; drawline(xctx->rectcolor,NOW, x1,y1,x2,y2, 0); @@ -2136,7 +2140,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg y2=atof(argv[5]); ORDER(x1,y1,x2,y2); pos=-1; - if(argc==7) pos=atol(argv[6]); + if(argc==7) pos=atoi(argv[6]); storeobject(pos, x1,y1,x2,y2,xRECT,xctx->rectcolor,0,NULL); save = xctx->draw_window; xctx->draw_window = 1; drawrect(xctx->rectcolor,NOW, x1,y1,x2,y2, 0); @@ -2240,7 +2244,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg if(name && name[0] ) { /* 20110325 only modify prefix if prefix not NUL */ - if(prefix) name[0]=prefix; /* change prefix if changing symbol type; */ + if(prefix) name[0]=(char)prefix; /* change prefix if changing symbol type; */ my_strdup(371, &ptr,subst_token(xctx->inst[inst].prop_ptr, "name", name) ); hash_all_names(inst); @@ -2364,12 +2368,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, (i >= 0) ? "1" : "0" , TCL_STATIC); } else if(!strcmp(argv[2],"wire") && argc==4) { - int n=atol(argv[3]); - if(nwires && n >= 0) select_wire(atol(argv[3]), SELECTED, 0); + int n=atoi(argv[3]); + if(nwires && n >= 0) select_wire(atoi(argv[3]), SELECTED, 0); } else if(!strcmp(argv[2],"text") && argc==4) { - int n=atol(argv[3]); - if(ntexts && n >= 0) select_text(atol(argv[3]), SELECTED, 0); + int n=atoi(argv[3]); + if(ntexts && n >= 0) select_text(atoi(argv[3]), SELECTED, 0); } drawtemparc(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0); drawtemprect(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); @@ -2428,7 +2432,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg if(tclresult()[0] == '1') exists = 1; xctx->enable_drill = 0; if(exists) { - viewer = atol(tclgetvar("sim(spicewave,default)")); + viewer = atoi(tclgetvar("sim(spicewave,default)")); my_snprintf(tcl_str, S(tcl_str), "sim(spicewave,%d,name)", viewer); my_strdup(1267, &viewer_name, tclgetvar(tcl_str)); dbg(1,"send_to_viewer: viewer_name=%s\n", viewer_name); @@ -2894,7 +2898,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg if(argc >= 8) prop = argv[7]; if(argc >= 9) sel = atoi(argv[8]); xctx->push_undo(); - storeobject(pos, x1,y1,x2,y2,WIRE,0,sel,prop); + storeobject(pos, x1,y1,x2,y2,WIRE,0,(short)sel,prop); xctx->prep_hi_structs=0; xctx->prep_net_structs=0; xctx->prep_hash_wires=0; diff --git a/src/select.c b/src/select.c index 6eb08d62..eb9f4f0a 100644 --- a/src/select.c +++ b/src/select.c @@ -344,7 +344,7 @@ void delete(int to_push_undo) customfont = set_text_custom_font(&xctx->text[i]); #endif text_bbox(xctx->text[i].txt_ptr, xctx->text[i].xscale, - xctx->text[i].yscale, select_rot, select_flip, xctx->text[i].hcenter, + xctx->text[i].yscale, (short) select_rot, (short) select_flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, &xx1,&yy1, &xx2,&yy2, &tmp, &dtmp); #if HAS_CAIRO==1 @@ -537,10 +537,10 @@ void bbox(int what,double x1,double y1, double x2, double y2) xctx->areaw = (xctx->areax2-xctx->areax1); xctx->areah = (xctx->areay2-xctx->areay1); - xctx->xrect[0].x = xctx->bbx1-INT_WIDTH(xctx->lw); - xctx->xrect[0].y = xctx->bby1-INT_WIDTH(xctx->lw); - xctx->xrect[0].width = xctx->bbx2-xctx->bbx1+2*INT_WIDTH(xctx->lw); - xctx->xrect[0].height = xctx->bby2-xctx->bby1+2*INT_WIDTH(xctx->lw); + xctx->xrect[0].x = (short)(xctx->bbx1-INT_WIDTH(xctx->lw)); + xctx->xrect[0].y = (short)(xctx->bby1-INT_WIDTH(xctx->lw)); + xctx->xrect[0].width = (unsigned short)(xctx->bbx2-xctx->bbx1+2*INT_WIDTH(xctx->lw)); + xctx->xrect[0].height = (unsigned short)(xctx->bby2-xctx->bby1+2*INT_WIDTH(xctx->lw)); if(has_x) { set_clip_mask(SET); dbg(2, "bbox(SET): setting clip area: %d %d %d %d\n", @@ -562,10 +562,10 @@ void bbox(int what,double x1,double y1, double x2, double y2) xctx->areaw = (xctx->areax2-xctx->areax1); xctx->areah = (xctx->areay2-xctx->areay1); - xctx->xrect[0].x = xctx->bbx1+INT_WIDTH(xctx->lw); - xctx->xrect[0].y = xctx->bby1+INT_WIDTH(xctx->lw); - xctx->xrect[0].width = xctx->bbx2-xctx->bbx1-2*INT_WIDTH(xctx->lw); - xctx->xrect[0].height = xctx->bby2-xctx->bby1-2*INT_WIDTH(xctx->lw); + xctx->xrect[0].x = (short)(xctx->bbx1+INT_WIDTH(xctx->lw)); + xctx->xrect[0].y = (short)(xctx->bby1+INT_WIDTH(xctx->lw)); + xctx->xrect[0].width = (unsigned short)(xctx->bbx2-xctx->bbx1-2*INT_WIDTH(xctx->lw)); + xctx->xrect[0].height = (unsigned short)(xctx->bby2-xctx->bby1-2*INT_WIDTH(xctx->lw)); if(has_x) { set_clip_mask(SET); dbg(2, "bbox(SET): setting clip area: %d %d %d %d\n", @@ -1022,7 +1022,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /*added u customfont = set_text_custom_font(&xctx->text[i]); #endif text_bbox(xctx->text[i].txt_ptr, - xctx->text[i].xscale, xctx->text[i].yscale, select_rot, select_flip, + xctx->text[i].xscale, xctx->text[i].yscale, (short)select_rot, (short)select_flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0, xctx->text[i].y0, &xx1,&yy1, &xx2,&yy2, &tmpint, &dtmp); @@ -1057,7 +1057,7 @@ void select_inside(double x1,double y1, double x2, double y2, int sel) /*added u if(xctx->poly[c][i].sel==SELECTED) xctx->poly[c][i].selected_point[k] = 1; if( POINTINSIDE(xctx->poly[c][i].x[k],xctx->poly[c][i].y[k], x1,y1,x2,y2)) { flag=1; - xctx->poly[c][i].selected_point[k] = sel; + xctx->poly[c][i].selected_point[k] = (short)sel; } if(xctx->poly[c][i].selected_point[k]) selected_points++; } diff --git a/src/spice_netlist.c b/src/spice_netlist.c index aa340444..a9719fda 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -98,7 +98,7 @@ static char *model_name(const char *m) char *m_lower = NULL; char *modelname = NULL; int n; - int l = strlen(m) + 1; + size_t l = strlen(m) + 1; my_strdup(255, &m_lower, m); strtolower(m_lower); my_realloc(256, &modelname, l); diff --git a/src/store.c b/src/store.c index c38cb8fe..acd1a593 100644 --- a/src/store.c +++ b/src/store.c @@ -194,7 +194,7 @@ void store_arc(int pos, double x, double y, double r, double a, double b, dash = get_tok_value(xctx->arc[rectc][n].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); - xctx->arc[rectc][n].dash = d >= 0 ? d : 0; + xctx->arc[rectc][n].dash = (char) (d >= 0 ? d : 0); } else xctx->arc[rectc][n].dash = 0; @@ -242,7 +242,7 @@ void store_poly(int pos, double *x, double *y, int points, unsigned int rectc, dash = get_tok_value(xctx->poly[rectc][n].prop_ptr,"dash",0); if( strcmp(dash, "") ) { int d = atoi(dash); - xctx->poly[rectc][n].dash = d >= 0 ? d : 0; + xctx->poly[rectc][n].dash = (char) (d >= 0 ? d : 0); } else xctx->poly[rectc][n].dash = 0; @@ -284,7 +284,7 @@ void storeobject(int pos, double x1,double y1,double x2,double y2, xctx->line[rectc][n].bus = 0; if(prop_ptr && (dash = get_tok_value(prop_ptr,"dash",0))[0]) { int d = atoi(dash); - xctx->line[rectc][n].dash = d >= 0 ? d : 0; + xctx->line[rectc][n].dash = (char) (d >= 0 ? d : 0); } else xctx->line[rectc][n].dash = 0; xctx->lines[rectc]++; @@ -313,7 +313,7 @@ void storeobject(int pos, double x1,double y1,double x2,double y2, xctx->rect[rectc][n].sel=sel; if(prop_ptr && (dash = get_tok_value(prop_ptr,"dash",0))[0]) { int d = atoi(dash); - xctx->rect[rectc][n].dash = d >= 0 ? d : 0; + xctx->rect[rectc][n].dash = (char) (d >= 0 ? d : 0); } else xctx->rect[rectc][n].dash = 0; set_rect_flags(&xctx->rect[rectc][n]); /* set cached .flags bitmask from on attributes */ diff --git a/src/svgdraw.c b/src/svgdraw.c index d675fb9b..32fb3644 100644 --- a/src/svgdraw.c +++ b/src/svgdraw.c @@ -583,7 +583,8 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot, static void fill_svg_colors() { char s[200]; /* overflow safe 20161122 */ - unsigned int i,c; + int i; + unsigned int c; /* if(debug_var>=1) { * tcleval( "puts $svg_colors"); * } diff --git a/src/token.c b/src/token.c index 3df26161..4d94769f 100644 --- a/src/token.c +++ b/src/token.c @@ -241,8 +241,8 @@ int set_different_token(char **s,const char *new, const char *old, int object, i { register int c, state=TOK_BEGIN, space; char *token=NULL, *value=NULL; - int sizetok=0, sizeval=0; - int token_pos=0, value_pos=0; + size_t sizetok=0, sizeval=0; + size_t token_pos=0, value_pos=0; int quote=0; int escape=0; int mod; @@ -269,9 +269,9 @@ int set_different_token(char **s,const char *new, const char *old, int object, i 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==TOK_TOKEN) token[token_pos++]=c; + if(state==TOK_TOKEN) token[token_pos++]=(char)c; else if(state==TOK_VALUE) { - value[value_pos++]=c; + value[value_pos++]=(char)c; } else if(state==TOK_ENDTOK || state==TOK_SEP) { if(token_pos) { @@ -292,7 +292,8 @@ int set_different_token(char **s,const char *new, const char *old, int object, i } state = TOK_BEGIN; - escape = quote = token_pos = value_pos = 0; + escape = quote = 0; + token_pos = value_pos = 0; /* parse old string and remove attributes that are not present in new */ while(old) { c=*old++; @@ -305,9 +306,9 @@ int set_different_token(char **s,const char *new, const char *old, int object, i 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==TOK_TOKEN) token[token_pos++]=c; + if(state==TOK_TOKEN) token[token_pos++]=(char)c; else if(state==TOK_VALUE) { - value[value_pos++]=c; + value[value_pos++]=(char)c; } else if(state==TOK_ENDTOK || state==TOK_SEP) { if(token_pos) { @@ -340,9 +341,9 @@ int set_different_token(char **s,const char *new, const char *old, int object, i const char *list_tokens(const char *s, int with_quotes) { static char *token=NULL; - int sizetok=0; + size_t sizetok=0; register int c, state=TOK_BEGIN, space; - register int token_pos=0; + register size_t token_pos=0; int quote=0; int escape=0; @@ -368,10 +369,10 @@ const char *list_tokens(const char *s, int with_quotes) } if(state==TOK_TOKEN) { if(c=='"') { - if((with_quotes & 1) || escape) token[token_pos++]=c; + if((with_quotes & 1) || escape) token[token_pos++]=(char)c; } - else if( !(c == '\\' && (with_quotes & 2)) ) token[token_pos++]=c; - else if(escape && c == '\\') token[token_pos++]=c; + else if( !(c == '\\' && (with_quotes & 2)) ) token[token_pos++]=(char)c; + else if(escape && c == '\\') token[token_pos++]=(char)c; } else if(state==TOK_VALUE) { /* do nothing */ } else if(state==TOK_ENDTOK || state==TOK_SEP) { @@ -456,9 +457,9 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes) result[0] = '\0'; return result; } - if( (with_quotes & 1) || escape || (c != '\\' && c != '"')) token[token_pos++]=c; + if( (with_quotes & 1) || escape || (c != '\\' && c != '"')) token[token_pos++]=(char)c; } else if(state == TOK_VALUE) { - if( (with_quotes & 1) || escape || (c != '\\' && c != '"')) result[value_pos++]=c; + if( (with_quotes & 1) || escape || (c != '\\' && c != '"')) result[value_pos++]=(char)c; } else if(state == TOK_ENDTOK || state == TOK_SEP) { if(token_pos) { token[token_pos] = '\0'; @@ -490,17 +491,17 @@ const char *get_tok_value(const char *s,const char *tok, int with_quotes) const char *get_sym_template(char *s,char *extra) { static char *result=NULL; - int sizeres=0; - int sizetok=0; - int sizeval=0; + size_t sizeres=0; + size_t sizetok=0; + size_t sizeval=0; char *value=NULL; char *token=NULL; register int c, state=TOK_BEGIN, space; - register int token_pos=0, value_pos=0, result_pos=0; + register size_t token_pos=0, value_pos=0, result_pos=0; int quote=0; int escape=0; int with_quotes=0; - int l; + size_t l; /* with_quotes: */ /* 0: eat non escaped quotes (") */ /* 1: return unescaped quotes as part of the token value if they are present */ @@ -527,16 +528,16 @@ const char *get_sym_template(char *s,char *extra) STR_ALLOC(&value, value_pos, &sizeval); STR_ALLOC(&token, token_pos, &sizetok); if(state==TOK_BEGIN) { - result[result_pos++] = c; + result[result_pos++] = (char)c; } else if(state==TOK_TOKEN) { - token[token_pos++]=c; + token[token_pos++]=(char)c; } else if(state==TOK_VALUE) { if(c=='"') { if(!escape) quote=!quote; - if((with_quotes & 1) || escape) value[value_pos++]=c; + if((with_quotes & 1) || escape) value[value_pos++]=(char)c; } else if( (c=='\\') && (with_quotes & 2) ) ; /* dont store backslash */ - else value[value_pos++]=c; + else value[value_pos++]=(char)c; escape = (c=='\\' && !escape); } else if(state==TOK_END) { @@ -545,7 +546,7 @@ const char *get_sym_template(char *s,char *extra) memcpy(result+result_pos, value, value_pos+1); result_pos+=value_pos; } - result[result_pos++] = c; + result[result_pos++] = (char)c; value_pos=0; token_pos=0; state=TOK_BEGIN; @@ -555,7 +556,7 @@ const char *get_sym_template(char *s,char *extra) if((!extra || !strstr(extra, token)) && strcmp(token,"name")) { memcpy(result+result_pos, token, token_pos+1); result_pos+=token_pos; - result[result_pos++] = c; + result[result_pos++] = (char)c; } token_pos=0; } @@ -579,7 +580,7 @@ static const char *find_bracket(const char *s) * return NULL if no matching token found */ static char *get_pin_attr_from_inst(int inst, int pin, const char *attr) { - int attr_size; + size_t attr_size; char *pinname = NULL, *pname = NULL, *pin_attr_value = NULL; char *pnumber = NULL; const char *str; @@ -589,7 +590,7 @@ static char *get_pin_attr_from_inst(int inst, int pin, const char *attr) pin_attr_value = NULL; str = get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][pin].prop_ptr,"name",0); if(str[0]) { - int tok_val_len; + size_t tok_val_len; tok_val_len = strlen(str); attr_size = strlen(attr); my_strdup(498, &pinname, str); @@ -624,8 +625,8 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names) const char *tmp2; int q,qq; static int last[1 << 8 * sizeof(char) ]; /* safe to keep with multiple schematics, reset on 1st invocation */ - int old_name_len; - int new_name_len; + size_t old_name_len; + size_t new_name_len; int n; char *old_name_base = NULL; Inst_hashentry *entry; @@ -731,8 +732,9 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200 char *template=NULL,*format=NULL,*s, *name=NULL, *token=NULL; const char *value; int pin_number; - int sizetok=0; - int token_pos=0, escape=0; + size_t sizetok=0; + size_t token_pos=0; + int escape=0; int no_of_pins=0; /* Inst_hashentry *ptr; */ @@ -781,7 +783,7 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200 STR_ALLOC(&token, token_pos, &sizetok); if(state==TOK_TOKEN) { - token[token_pos++]=c; /* 20171029 remove escaping backslashes */ + token[token_pos++]=(char)c; /* 20171029 remove escaping backslashes */ } else if(state==TOK_SEP) /* got a token */ { @@ -902,12 +904,12 @@ const char *subst_token(const char *s, const char *tok, const char *new_val) /* if new_val is NULL *remove* 'token (and =val if any)' from s */ { static char *result=NULL; - int size=0; + size_t size=0; register int c, state=TOK_BEGIN, space; - int sizetok=0; + size_t sizetok=0; char *token=NULL; - int token_pos=0, result_pos=0, result_save_pos = 0; - int quote=0, tmp; + size_t token_pos=0, result_pos=0, result_save_pos = 0, tmp; + int quote=0; int done_subst=0; int escape=0, matched_tok=0; char *new_val_copy = NULL; @@ -1028,16 +1030,16 @@ const char *subst_token(const char *s, const char *tok, const char *new_val) } /* state actions */ if(state == TOK_BEGIN) { - result[result_pos++] = c; + result[result_pos++] = (char)c; } else if(state == TOK_TOKEN) { - token[token_pos++] = c; - result[result_pos++] = c; + token[token_pos++] = (char)c; + result[result_pos++] = (char)c; } else if(state == TOK_ENDTOK) { - result[result_pos++] = c; + result[result_pos++] = (char)c; } else if(state == TOK_SEP) { - result[result_pos++] = c; + result[result_pos++] = (char)c; } else if(state==TOK_VALUE) { - if(!matched_tok) result[result_pos++] = c; /* skip value for matching token */ + if(!matched_tok) result[result_pos++] = (char)c; /* skip value for matching token */ } escape = (c=='\\' && !escape); if(c == '\0') break; @@ -1067,12 +1069,13 @@ const char *get_trailing_path(const char *str, int no_of_dir, int skip_ext) { static char s[PATH_MAX]; /* safe to keep even with multiple schematic windows */ size_t len; - int ext_pos, dir_pos, n_ext, n_dir, c, i; + size_t ext_pos, dir_pos; + int n_ext, n_dir, c, i; my_strncpy(s, str, S(s)); len = strlen(s); - for(ext_pos=len, dir_pos=len, n_ext=0, n_dir=0, i=len; i>=0; i--) { + for(ext_pos=len, dir_pos=len, n_ext=0, n_dir=0, i=(int)len; i>=0; i--) { c = s[i]; if(c=='.' && ++n_ext==1) ext_pos = i; if(c=='/' && ++n_dir==no_of_dir+1) dir_pos = i; @@ -1137,8 +1140,8 @@ void print_vhdl_element(FILE *fd, int inst) char *generic_value=NULL, *generic_type=NULL; char *template=NULL,*s, *value=NULL, *token=NULL; int no_of_pins=0, no_of_generics=0; - int sizetok=0, sizeval=0; - int token_pos=0, value_pos=0; + size_t sizetok=0, sizeval=0; + size_t token_pos=0, value_pos=0; int quote=0; int escape=0; xRect *pinptr; @@ -1192,10 +1195,10 @@ void print_vhdl_element(FILE *fd, int inst) else if( state==TOK_VALUE && space && !quote) state=TOK_END; STR_ALLOC(&value, value_pos, &sizeval); STR_ALLOC(&token, token_pos, &sizetok); - if(state==TOK_TOKEN) token[token_pos++]=c; + if(state==TOK_TOKEN) token[token_pos++]=(char)c; else if(state==TOK_VALUE) { if(c=='"' && !escape) quote=!quote; - else value[value_pos++]=c; + else value[value_pos++]=(char)c; } else if(state==TOK_ENDTOK || state==TOK_SEP) { if(token_pos) { @@ -1289,8 +1292,9 @@ void print_generic(FILE *fd, char *ent_or_comp, int symbol) char *template=NULL, *s, *value=NULL, *token=NULL; char *type=NULL, *generic_type=NULL, *generic_value=NULL; const char *str_tmp; - int i, sizetok=0, sizeval=0; - int token_pos=0, value_pos=0; + int i; + size_t sizetok=0, sizeval=0; + size_t token_pos=0, value_pos=0; int quote=0; int escape=0; int token_number=0; @@ -1328,11 +1332,11 @@ void print_generic(FILE *fd, char *ent_or_comp, int symbol) else if( state==TOK_VALUE && space && !quote) state=TOK_END; STR_ALLOC(&value, value_pos, &sizeval); STR_ALLOC(&token, token_pos, &sizetok); - if(state==TOK_TOKEN) token[token_pos++]=c; + if(state==TOK_TOKEN) token[token_pos++]=(char)c; else if(state==TOK_VALUE) { if(c=='"' && !escape) quote=!quote; - else value[value_pos++]=c; + else value[value_pos++]=(char)c; } else if(state==TOK_ENDTOK || state==TOK_SEP) { if(token_pos) { @@ -1398,8 +1402,8 @@ void print_verilog_param(FILE *fd, int symbol) { 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; + size_t sizetok=0, sizeval=0; + size_t token_pos=0, value_pos=0; int quote=0; int escape=0; int token_number=0; @@ -1433,11 +1437,11 @@ void print_verilog_param(FILE *fd, int symbol) STR_ALLOC(&value, value_pos, &sizeval); STR_ALLOC(&token, token_pos, &sizetok); - if(state==TOK_TOKEN) token[token_pos++]=c; + if(state==TOK_TOKEN) token[token_pos++]=(char)c; else if(state==TOK_VALUE) { if(c=='"' && !escape) quote=!quote; - else value[value_pos++]=c; + else value[value_pos++]=(char)c; } else if(state==TOK_ENDTOK || state==TOK_SEP) { if(token_pos) { @@ -1489,8 +1493,9 @@ void print_tedax_subckt(FILE *fd, int symbol) register int c, state=TOK_BEGIN, space; char *format=NULL,*s, *token=NULL; int pin_number; - int sizetok=0; - int token_pos=0, escape=0; + size_t sizetok=0; + size_t token_pos=0; + int escape=0; int no_of_pins=0; my_strdup(460, &format, get_tok_value(xctx->sym[symbol].prop_ptr,"format",2)); @@ -1524,7 +1529,7 @@ void print_tedax_subckt(FILE *fd, int symbol) STR_ALLOC(&token, token_pos, &sizetok); if(state==TOK_TOKEN) { - token[token_pos++]=c; + token[token_pos++]=(char)c; } else if(state==TOK_SEP) /* got a token */ { @@ -1597,8 +1602,9 @@ void print_spice_subckt(FILE *fd, int symbol) register int c, state=TOK_BEGIN, space; char *format=NULL,*s, *token=NULL; int pin_number; - int sizetok=0; - int token_pos=0, escape=0; + size_t sizetok=0; + size_t token_pos=0; + int escape=0; int no_of_pins=0; my_strdup(103, &format, get_tok_value(xctx->sym[symbol].prop_ptr,"format",2)); @@ -1632,7 +1638,7 @@ void print_spice_subckt(FILE *fd, int symbol) STR_ALLOC(&token, token_pos, &sizetok); if(state==TOK_TOKEN) { - token[token_pos++]=c; + token[token_pos++]=(char)c; } else if(state==TOK_SEP) /* got a token */ { @@ -1702,19 +1708,21 @@ void print_spice_subckt(FILE *fd, int symbol) int print_spice_element(FILE *fd, int inst) { - int i=0, multip, tmp; + int i=0, multip, itmp; + size_t tmp; const char *str_ptr=NULL; register int c, state=TOK_BEGIN, space; char *template=NULL,*format=NULL,*s, *name=NULL, *token=NULL; const char *lab, *value = NULL; char *translatedvalue = NULL; int pin_number; - int sizetok=0; - int token_pos=0, escape=0; + size_t sizetok=0; + size_t token_pos=0; + int escape=0; int no_of_pins=0; char *result = NULL; - int result_pos = 0; - int size = 0; + size_t result_pos = 0; + size_t size = 0; char *spiceprefixtag = NULL; size = CADCHUNKALLOC; @@ -1766,11 +1774,11 @@ int print_spice_element(FILE *fd, int inst) } STR_ALLOC(&token, token_pos, &sizetok); if(state==TOK_TOKEN) { - token[token_pos++]=c; + token[token_pos++]=(char)c; } else if (state==TOK_SEP) /* got a token */ { - int token_exists = 0; + size_t token_exists = 0; token[token_pos]='\0'; token_pos=0; @@ -1778,7 +1786,7 @@ int print_spice_element(FILE *fd, int inst) if (!tclgetboolvar("spiceprefix") && !strcmp(token, "@spiceprefix")) { value=NULL; } else { - int tok_val_len; + size_t tok_val_len; dbg(1, "print_spice_element(): token: |%s|\n", token); value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0); @@ -1815,7 +1823,7 @@ int print_spice_element(FILE *fd, int inst) /*if something else must be parsed, put an if here! */ if (!(strcmp(token+1,"name") && strcmp(token+1,"lab")) /* expand name/labels */ - && ((lab = expandlabel(value, &tmp)) != NULL)) { + && ((lab = expandlabel(value, &itmp)) != NULL)) { tmp = strlen(lab) +100 ; /* always make room for some extra chars * so 1-char writes to result do not need reallocs */ STR_ALLOC(&result, tmp + result_pos, &size); @@ -1969,7 +1977,7 @@ int print_spice_element(FILE *fd, int inst) * if(result && strstr(result, "eval(") == result) { * char *c = strrchr(result, ')'); * if(c) while(1) { /* shift following characters back 1 char */ - * *c = c[1]; + * *c = (char)c[1]; * c++; * if(!*c) break; * } @@ -2005,8 +2013,9 @@ void print_tedax_element(FILE *fd, int inst) char *saveptr1, *saveptr2; const char *tmp; int instance_based=0; - int sizetok=0; - int token_pos=0, escape=0; + size_t sizetok=0; + size_t token_pos=0; + int escape=0; int no_of_pins=0; int subcircuit = 0; /* Inst_hashentry *ptr; */ @@ -2151,7 +2160,7 @@ void print_tedax_element(FILE *fd, int inst) STR_ALLOC(&token, token_pos, &sizetok); if(state==TOK_TOKEN) { - token[token_pos++]=c; /* 20171029 remove escaping backslashes */ + token[token_pos++]=(char)c; /* 20171029 remove escaping backslashes */ } else if(state==TOK_SEP) /* got a token */ { @@ -2298,8 +2307,9 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level const char *lab; char *template=NULL,*format=NULL,*s=NULL, *name=NULL, *token=NULL; const char *value; - int sizetok=0; - int token_pos=0, escape=0; + size_t sizetok=0; + size_t token_pos=0; + int escape=0; int no_of_pins=0; /* Inst_hashentry *ptr; */ @@ -2350,7 +2360,7 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level STR_ALLOC(&token, token_pos, &sizetok); if(state==TOK_TOKEN) { - token[token_pos++]=c; + token[token_pos++]=(char)c; } else if(state==TOK_SEP) /* got a token */ { @@ -2488,8 +2498,8 @@ void print_verilog_element(FILE *fd, int inst) int tmp1 = 0; register int c, state=TOK_BEGIN, space; char *value=NULL, *token=NULL; - int sizetok=0, sizeval=0; - int token_pos=0, value_pos=0; + size_t sizetok=0, sizeval=0; + size_t token_pos=0, value_pos=0; int quote=0; if(get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"verilog_format",2)[0] != '\0') { @@ -2536,10 +2546,10 @@ void print_verilog_element(FILE *fd, int inst) STR_ALLOC(&value, value_pos, &sizeval); STR_ALLOC(&token, token_pos, &sizetok); - if(state==TOK_TOKEN) token[token_pos++]=c; + if(state==TOK_TOKEN) token[token_pos++]=(char)c; else if(state==TOK_VALUE) { - value[value_pos++]=c; + value[value_pos++]=(char)c; } else if(state==TOK_ENDTOK || state==TOK_SEP) { if(token_pos) { @@ -2708,8 +2718,9 @@ int isonlydigit(const char *s) char *find_nth(const char *str, const char *sep, int n) { static char *result=NULL; /* safe to keep even with multiple schematic windows */ - static int result_size = 0; /* safe to keep even with multiple schematic windows */ - int i, len; + static size_t result_size = 0; /* safe to keep even with multiple schematic windows */ + int i; + size_t len; char *ptr; int count = -1; @@ -2758,12 +2769,13 @@ const char *translate(int inst, const char* s) { static const char *empty=""; static char *result=NULL; /* safe to keep even with multiple schematics */ - int size=0, tmp; + size_t size=0; + size_t tmp; register int c, state=TOK_BEGIN, space; char *token=NULL; const char *tmp_sym_name; - int sizetok=0; - int result_pos=0, token_pos=0; + size_t sizetok=0; + size_t result_pos=0, token_pos=0; /* Inst_hashentry *ptr; */ struct stat time_buf; struct tm *tm; @@ -2815,7 +2827,7 @@ const char *translate(int inst, const char* s) STR_ALLOC(&result, result_pos, &size); STR_ALLOC(&token, token_pos, &sizetok); - if(state==TOK_TOKEN) token[token_pos++]=c; + if(state==TOK_TOKEN) token[token_pos++]=(char)c; else if(state==TOK_SEP) { token[token_pos]='\0'; @@ -3048,10 +3060,10 @@ const char *translate(int inst, const char* s) } token_pos = 0; if(c == '@' || c == '%') s--; - else result[result_pos++]=c; + else result[result_pos++]=(char)c; state=TOK_BEGIN; } - else if(state==TOK_BEGIN) result[result_pos++]=c; + else if(state==TOK_BEGIN) result[result_pos++]=(char)c; if(c=='\0') { result[result_pos]='\0'; @@ -3070,12 +3082,14 @@ const char *translate2(Lcc *lcc, int level, char* s) { static const char *empty=""; static char *result = NULL; - int i, size = 0, tmp, save_tok_size; + int i; + size_t save_tok_size, size = 0; + size_t tmp; register int c, state = TOK_BEGIN, space; char *token = NULL; const char *tmp_sym_name; - int sizetok = 0; - int result_pos = 0, token_pos = 0; + size_t sizetok = 0; + size_t result_pos = 0, token_pos = 0; char *value1 = NULL; char *value2 = NULL; char *value = NULL; @@ -3105,7 +3119,7 @@ const char *translate2(Lcc *lcc, int level, char* s) } STR_ALLOC(&result, result_pos, &size); STR_ALLOC(&token, token_pos, &sizetok); - if (state == TOK_TOKEN) token[token_pos++] = c; + if (state == TOK_TOKEN) token[token_pos++] = (char)c; else if (state == TOK_SEP) { token[token_pos] = '\0'; token_pos = 0; @@ -3161,10 +3175,10 @@ const char *translate2(Lcc *lcc, int level, char* s) } if (c == '@') s--; - else result[result_pos++] = c; + else result[result_pos++] = (char)c; state = TOK_BEGIN; } - else if (state == TOK_BEGIN) result[result_pos++] = c; + else if (state == TOK_BEGIN) result[result_pos++] = (char)c; if (c == '\0') { result[result_pos] = '\0'; break; diff --git a/src/xinit.c b/src/xinit.c index 8504ed32..5096fb4a 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -126,7 +126,7 @@ static int window_state (Display *disp, Window win, char *arg) {/*{{{*/ fputs("Invalid zero length property.\n", errfp); return EXIT_FAILURE; } - for( i = 0; p2[i]; i++) tmp2[i] = toupper( p2[i] ); + for( i = 0; p2[i]; i++) tmp2[i] = (char)toupper( p2[i] ); tmp2[i] = '\0'; my_snprintf(tmp_prop2, S(tmp_prop2), "_NET_WM_STATE_%s", tmp2); prop2 = XInternAtom(disp, tmp_prop2, False); @@ -137,7 +137,7 @@ static int window_state (Display *disp, Window win, char *arg) {/*{{{*/ fputs("Invalid zero length property.\n", errfp); return EXIT_FAILURE; } - for( i = 0; p1[i]; i++) tmp1[i] = toupper( p1[i] ); + for( i = 0; p1[i]; i++) tmp1[i] = (char)toupper( p1[i] ); tmp1[i] = '\0'; my_snprintf(tmp_prop1, S(tmp_prop1), "_NET_WM_STATE_%s", tmp1); prop1 = XInternAtom(disp, tmp_prop1, False); @@ -157,7 +157,9 @@ static int window_state (Display *disp, Window win, char *arg) {/*{{{*/ /* used to set icon */ void windowid(const char *winpath) { +#ifdef __unix__ int i; +#endif Display *display; Tk_Window mainwindow; @@ -200,9 +202,9 @@ void windowid(const char *winpath) static int err(Display *display, XErrorEvent *xev) { - char s[1024]; /* overflow safe 20161122 */ int l=250; #ifdef __unix__ + char s[1024]; /* overflow safe 20161122 */ XGetErrorText(display, xev->error_code, s,l); dbg(1, "err(): Err %d :%s maj=%d min=%d\n", xev->error_code, s, xev->request_code, xev->minor_code); @@ -212,13 +214,13 @@ static int err(Display *display, XErrorEvent *xev) static unsigned int find_best_color(char colorname[]) { +#ifdef __unix__ int i; double distance=10000000000.0, dist, r, g, b, red, green, blue; double deltar,deltag,deltab; unsigned int idx; - /* dbg(1, "find_best_color() start: %g\n", timer(1)); */ -#ifdef __unix__ + if( XAllocNamedColor(display, colormap, colorname, &xcolor_exact, &xcolor) ==0 ) { for(i=0;i<=255;i++) { @@ -245,7 +247,7 @@ static unsigned int find_best_color(char colorname[]) else { /*XLookupColor(display, colormap, colorname, &xcolor_exact, &xcolor); */ - idx = xcolor.pixel; + idx = (int)xcolor.pixel; } /* dbg(1, "find_best_color() return: %g\n", timer(1)); */ return idx; @@ -1590,11 +1592,12 @@ static void resetcairo(int create, int clear, int force_or_resize) void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h) { unsigned int width, height; - XWindowAttributes wattr; int status; #ifndef __unix__ HWND hwnd = Tk_GetHWND(xctx->window); RECT rct; + #else + XWindowAttributes wattr; #endif if(has_x) { @@ -1632,8 +1635,8 @@ void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h) dbg(1, "resetwin(): changing size\n\n"); xctx->xrect[0].x = 0; xctx->xrect[0].y = 0; - xctx->xrect[0].width = width; - xctx->xrect[0].height = height; + xctx->xrect[0].width = (unsigned short) width; + xctx->xrect[0].height = (unsigned short) height; if(clear_pixmap) { resetcairo(0, 1, 1); /* create, clear, force */ #ifdef __unix__ @@ -1679,10 +1682,12 @@ int Tcl_AppInit(Tcl_Interp *inter) int i; double l_width; struct stat buf; - const char *home_buff; int running_in_src_dir; int fs; +#ifdef __unix__ + const char* home_buff; +#endif /* get PWD and HOME */ if(!getcwd(pwd_dir, PATH_MAX)) { fprintf(errfp, "Tcl_AppInit(): getcwd() failed\n"); @@ -1691,13 +1696,13 @@ int Tcl_AppInit(Tcl_Interp *inter) if ((home_buff = getenv("HOME")) == NULL) { home_buff = getpwuid(getuid())->pw_dir; } + my_strncpy(home_dir, home_buff, S(home_dir)); #else change_to_unix_fn(pwd_dir); - home_buff = getenv("USERPROFILE"); + char *home_buff = getenv("USERPROFILE"); change_to_unix_fn(home_buff); + my_strncpy(home_dir, home_buff, S(home_dir)); #endif - my_strncpy(home_dir, home_buff, S(home_dir)); - /* set error and exit handlers */ XSetErrorHandler(err); if(!interp) interp=inter; @@ -1772,7 +1777,7 @@ int Tcl_AppInit(Tcl_Interp *inter) /*9*/ "xschem_library/rom8k" }; GetModuleFileNameA(NULL, install_dir, MAX_PATH); change_to_unix_fn(install_dir); - int dir_len=strlen(install_dir); + size_t dir_len=strlen(install_dir); if (dir_len>11) install_dir[dir_len-11] = '\0'; /* 11 = remove /xschem.exe */ /* debugging in Visual Studio will not have bin */ diff --git a/src/xschem.h b/src/xschem.h index 25af0c62..9b6229c7 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -351,7 +351,7 @@ extern char win_temp_dir[PATH_MAX]; * hold 'add' characters */ #define STR_ALLOC(dest_string, add, size) \ do { \ - register int __str_alloc_tmp__ = add; \ + register size_t __str_alloc_tmp__ = add; \ if( __str_alloc_tmp__ >= *size) { \ *size = __str_alloc_tmp__ + CADCHUNKALLOC; \ my_realloc(1212, dest_string, *size); \ @@ -758,7 +758,7 @@ typedef struct { double zoom; double mooz; double lw; - unsigned long ui_state ; /* this signals that we are doing a net place,panning etc. + unsigned int ui_state ; /* this signals that we are doing a net place,panning etc. * used to prevent nesting of some commands */ double mousex,mousey; /* mouse coord. */ double mousex_snap,mousey_snap; /* mouse coord. snapped to grid */ @@ -1191,7 +1191,7 @@ extern int place_symbol(int pos, const char *symbol_name, double x, double y, sh const char *inst_props, int draw_sym, int first_call, int to_push_undo); extern void place_net_label(int type); extern void attach_labels_to_inst(int interactive); -extern int connect_by_kissing(void); +extern short connect_by_kissing(void); extern void delete_files(void); extern int sym_vs_sch_pins(void); extern int match_symbol(const char name[]); @@ -1287,7 +1287,7 @@ extern size_t my_strdup(int id, char **dest, const char *src); extern void my_strndup(int id, char **dest, const char *src, size_t n); extern size_t my_strdup2(int id, char **dest, const char *src); extern char *my_strtok_r(char *str, const char *delim, const char *quote, char **saveptr); -extern int my_strncpy(char *d, const char *s, int n); +extern int my_strncpy(char *d, const char *s, size_t n); extern int my_strcasecmp(const char *s1, const char *s2); extern int my_strncasecmp(const char *s1, const char *s2, size_t n); extern char* strtolower(char* s);