diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2022-10-28 04:00:00 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2022-10-29 11:57:20 +0200 |
commit | 8df721df25864f89772c58a4486314855bf1a37e (patch) | |
tree | 7c89253922a8f09b964876b438056e2655cc9062 /src/graph/view2D | |
parent | 467b6fb9eeb12d064c1f6fa4d7f87638e49685ca (diff) | |
download | open-axiom-8df721df25864f89772c58a4486314855bf1a37e.tar.gz |
Fix some compiler warnings & buffer overflows
Diffstat (limited to 'src/graph/view2D')
-rw-r--r-- | src/graph/view2D/header2.h | 2 | ||||
-rw-r--r-- | src/graph/view2D/process2d.c | 6 | ||||
-rw-r--r-- | src/graph/view2D/write2d.c | 46 |
3 files changed, 26 insertions, 28 deletions
diff --git a/src/graph/view2D/header2.h b/src/graph/view2D/header2.h index c7d63985..bbd11a10 100644 --- a/src/graph/view2D/header2.h +++ b/src/graph/view2D/header2.h @@ -228,7 +228,7 @@ typedef struct _buttonStruct { typedef struct _controlPanelStruct { int numOfButtons; Window controlWindow,messageWindow,colormapWindow; - char message[40]; + char message[80]; struct _buttonStruct buttonQueue[maxButtons2D]; } controlPanelStruct; diff --git a/src/graph/view2D/process2d.c b/src/graph/view2D/process2d.c index 276948ef..52c326f6 100644 --- a/src/graph/view2D/process2d.c +++ b/src/graph/view2D/process2d.c @@ -493,7 +493,7 @@ processEvents(void) Window whichWindow; XWindowAttributes graphWindowAttrib; buttonStruct *controlButton; - mouseCoord mouseXY; + mouseCoord mouseXY = {0.0, 0.0}; int i, someInt, mouseW4, @@ -561,7 +561,7 @@ processEvents(void) switch(((XEvent *)event)->type) { case ClientMessage: - if (event->xclient.data.l[0] == wm_delete_window) { + if ((Atom)event->xclient.data.l[0] == wm_delete_window) { goodbye(-1); } else { @@ -799,7 +799,7 @@ processEvents(void) for (i=0; i<maxGraphs; i++) { if (graphStateArray[i].showing && graphStateArray[i].selected) { if (zoomXON) { - graphStateArray[i].scaleX *= (1 - mouseXY.y * 0.3); + graphStateArray[i].scaleX *= (1 - mouseXY.x * 0.3); if (graphStateArray[i].scaleX > maxScale) graphStateArray[i].scaleX = maxScale; else if (graphStateArray[i].scaleX < minScale) diff --git a/src/graph/view2D/write2d.c b/src/graph/view2D/write2d.c index 4431da08..395b821a 100644 --- a/src/graph/view2D/write2d.c +++ b/src/graph/view2D/write2d.c @@ -47,33 +47,31 @@ #include "Gfun.H1" -#define numBits (8*sizeof(int)) +#define numBits ((int)(8*sizeof(int))) int writeViewport(int thingsToWrite) { FILE *viewDataFile; - char viewDirName[80], - viewBitmapFilename[80],viewDataFilename[80],command[80]; + char buf[1024]; int i,j,k,ii; pointListStruct *aList; pointStruct *aPoint; XWindowAttributes vwInfo; XGetWindowAttributes(dsply,viewport->titleWindow,&vwInfo); - sprintf(viewDirName,"%s%s",filename,".VIEW"); - sprintf(command,"%s%s%s","rm -r ",viewDirName," > /dev/null 2>&1"); - system(command); - sprintf(command,"%s%s%s","mkdir ",viewDirName," > /dev/null 2>&1"); - if (system(command)) { - fprintf(stderr," Error: Cannot create %s\n",viewDirName); + sprintf(buf, "rm -f %s.VIEW", filename); + system(buf); + sprintf(buf, "mkdir %s.VIEW", filename); + if (system(buf)) { + fprintf(stderr," Error: Cannot create %s.VIEW\n", filename); return(-1); } else { /*** Create the data file ***/ - sprintf(viewDataFilename,"%s%s",viewDirName,"/data"); - if ((viewDataFile = fopen(viewDataFilename,"w")) == NULL) { - fprintf(stderr," Error: Cannot create %s\n",viewDataFilename); + sprintf(buf,"%s.VIEW/data", filename); + if ((viewDataFile = fopen(buf,"w")) == NULL) { + fprintf(stderr," Error: Cannot create %s\n", buf); perror("fopen"); return(-1); } else { @@ -101,9 +99,9 @@ writeViewport(int thingsToWrite) fclose(viewDataFile); for (i=0; i<maxGraphs; i++) { if (graphArray[i].key) { - sprintf(viewDataFilename,"%s%s%d",viewDirName,"/graph",i); - if ((viewDataFile = fopen(viewDataFilename,"w")) == NULL) { - fprintf(stderr," Error: Cannot create %s\n",viewDataFilename); + sprintf(buf,"%s.VIEW/graph%d", filename, i); + if ((viewDataFile = fopen(buf,"w")) == NULL) { + fprintf(stderr," Error: Cannot create %s\n", buf); perror("fopen"); return(-1); } else { @@ -143,37 +141,37 @@ writeViewport(int thingsToWrite) switch (ii) { case Pixmap: /*** Create the pixmap (bitmaps need leaf name) ***/ - sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.xpm"); + sprintf(buf,"%s.VIEW/image.xpm", filename); XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); - write_pixmap_file(dsply,scrn,viewBitmapFilename, + write_pixmap_file(dsply,scrn,buf, viewport->titleWindow,0,0,vwInfo.width, vwInfo.height+titleHeight); break; case Bitmap: /*** Create the bitmap (bitmaps need leaf name) ***/ - sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.bm"); + sprintf(buf,"%s.VIEW/image.bm", filename); XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); - XWriteBitmapFile(dsply,viewBitmapFilename, + XWriteBitmapFile(dsply,buf, viewport->titleWindow,vwInfo.width, vwInfo.height+vwInfo.border_width+20,-1,-1); break; case Image: /*** Create the pixmap (bitmaps need leaf name) ***/ - sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.xpm"); + sprintf(buf,"%s.VIEW/image.xpm", filename); XResizeWindow(dsply,viewport->titleWindow,300,300+titleHeight); XResizeWindow(dsply,viewport->viewWindow,300,300); XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); drawViewport(Xoption); writeTitle(); - write_pixmap_file(dsply,scrn,viewBitmapFilename, + write_pixmap_file(dsply,scrn,buf, viewport->titleWindow,0,0,vwInfo.width, vwInfo.height+titleHeight); /*** Create the bitmap (bitmaps need leaf name) ***/ mono = 1; drawViewport(Xoption); writeTitle(); - sprintf(viewBitmapFilename,"%s%s%s",viewDirName,"/","image.bm"); - XWriteBitmapFile(dsply,viewBitmapFilename, + sprintf(buf,"%s.VIEW/image.bm", filename); + XWriteBitmapFile(dsply,buf, viewport->titleWindow,vwInfo.width, vwInfo.height+vwInfo.border_width+20,-1,-1); mono = 0; @@ -181,7 +179,7 @@ writeViewport(int thingsToWrite) case Postscript: /*** Create postscript output for viewport (in axiom2D.ps) ***/ - sprintf(PSfilename,"%s%s",viewDirName,"/axiom2D.ps"); + sprintf(PSfilename,"%s.VIEW/axiom2D.ps", filename); if (PSInit(viewport->viewWindow,viewport->titleWindow) == psError) return (-1); drawViewport(PSoption); /* write new script file in /tmp */ |