From 0a3e457c96887eb59e1ba5caa35b5ea3a25e5bd7 Mon Sep 17 00:00:00 2001 From: cvs Date: Wed, 26 Jul 2000 08:00:29 +0000 Subject: [PATCH] - Fixed irregularly occuring core dump bug. --- SCinter.c | 69 +++++++++++++++++++------------------------------ SCinter.h | 1 - danu.dat | 2 +- drive.c | 14 +++++++++- matrix/Makefile | 34 ++++++++++++++++++++++++ sicsstatus.tcl | 4 +-- stest.tcl | 2 +- 7 files changed, 77 insertions(+), 49 deletions(-) create mode 100644 matrix/Makefile diff --git a/SCinter.c b/SCinter.c index 0fb57c4c..fcdcc5eb 100644 --- a/SCinter.c +++ b/SCinter.c @@ -75,22 +75,6 @@ return NULL; } - pInter->argv = NULL; - pInter->argv = (char **)malloc(MAXPAR*sizeof(char *)); - if(pInter->argv == NULL) - { - free(pInter); - return NULL; - } - for(i = 0; i < MAXPAR; i++) - { - pInter->argv[i] = (char *)malloc(MAXLEN*sizeof(char)); - if(pInter->argv[i] == NULL) - { - free(pInter); - return NULL; - } - } pInter->iDeleting = 0; return pInter; } @@ -210,11 +194,13 @@ extern char *SkipSpace(char *pPtr); { int iCount = 0; int iRet; - int i; + int i, argc; char pBueffel[1024]; CommandList *pCommand = NULL; char pBrk[] = {" \r\n\0"}; char *pPtr; + char **argv = NULL; + assert(self); assert(pCon); @@ -240,36 +226,27 @@ extern char *SkipSpace(char *pPtr); } /* convert to argc, argv */ - pPtr = SkipSpace(pText); - if(pPtr) - { - pPtr = stptok(pPtr,self->argv[0],255,pBrk); - } - while(pPtr != NULL) - { - iCount++; - pPtr = SkipSpace(pPtr); - if(!pPtr) - { - break; - } - pPtr = stptok(pPtr,self->argv[iCount],255,pBrk); - } - self->argv[iCount][0] = '\0'; - + argc = 0; + Text2Arg(pText,&argc,&argv); + /* the first one must be the target object. If not given an empty command string was given which will be silently ignored */ - if(iCount < 1) + if(argc < 1) { return 1; } + if(argv[0] == NULL) + { + SCWrite(pCon,"ERROR: failed to parse command",eError); + return -1; + } /* find it */ - pCommand = FindCommand(self,self->argv[0]); + pCommand = FindCommand(self,argv[0]); if(!pCommand) { sprintf(pBueffel,"ERROR: Object -> %s <- NOT found", - self->argv[0]); + argv[0]); SCWrite(pCon,pBueffel,eError); return -1; @@ -280,8 +257,19 @@ extern char *SkipSpace(char *pPtr); self->eOut = eStatus; Tcl_ResetResult((Tcl_Interp *)self->pTcl); MacroPush(pCon); - iRet = pCommand->OFunc(pCon, self, pCommand->pData, iCount, self->argv); + iRet = pCommand->OFunc(pCon, self, pCommand->pData, argc, argv); MacroPop(); + + /* delete argv */ + for(i = 0; i < argc; i++) + { + if(argv[i] != NULL) + { + free(argv[i]); + } + } + free(argv); + return iRet; } /*------------------------------------------------------------------------*/ @@ -393,11 +381,6 @@ extern char *SkipSpace(char *pPtr); Tcl_DeleteInterp(pTcl); } - for(i = 0; i < MAXPAR; i++) - { - free(self->argv[i]); - } - free(self->argv); free(self); } diff --git a/SCinter.h b/SCinter.h index 2a1ee0bb..b8be9d91 100644 --- a/SCinter.h +++ b/SCinter.h @@ -34,7 +34,6 @@ typedef struct __SINTER CommandList *pCList; OutCode eOut; void *pTcl; - char **argv; int iDeleting; }SicsInterp; diff --git a/danu.dat b/danu.dat index d338d9b0..f69c1c40 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 5829 + 7281 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach!|n \ No newline at end of file diff --git a/drive.c b/drive.c index c11d8083..92977887 100644 --- a/drive.c +++ b/drive.c @@ -253,6 +253,7 @@ pMotor pMot = NULL; float fPos; int iRet; + char pBueffel[132]; /* treat motors separatetly in order to correct for zero points @@ -282,7 +283,18 @@ if(pDes) { pInt = pDes->GetInterface(pDum,DRIVEID); - return pInt->GetValue(pDum,pCon); + if(!pInt) + { + sprintf(pBueffel, + "ERROR: internal error in findPosition for %s", + name); + SCWrite(pCon,pBueffel,eError); + return -999.99; + } + else + { + return pInt->GetValue(pDum,pCon); + } } } } diff --git a/matrix/Makefile b/matrix/Makefile new file mode 100644 index 00000000..84c91dd4 --- /dev/null +++ b/matrix/Makefile @@ -0,0 +1,34 @@ +#--------------------------------------------------------------------------- +# Makefile for the Matrix library +# +# Mark Koennecke, November 1996 +#-------------------------------------------------------------------------- +OBJ= matadd.o matcreat.o matdet.o matdump.o matdurbn.o materr.o \ + matinv.o matmul.o matsolve.o matsub.o matsubx.o mattoepz.o \ + mattran.o + +#---------- for Redhat linux +#CC= gcc +#CFLAGS= -I/usr/local/include -I. -I../ -DLINUX -g -c + +#------------ for DigitalUnix +CC=cc +CFLAGS= -I/data/koenneck/include -I. -I../ -std1 -g -c +#------------ for DigitalUnix with Fortify +#CFLAGS= -I/data/koenneck/include -DFORTIFY -I. -I../ -std1 -g -c + +#------------ for CYGNUS toolchain on Win32 +#CC=gcc +#CFLAGS= -I. -I../ -DCYGNUS -g -c + +.c.o: + $(CC) $(CFLAGS) $*.c + +matrix: $(OBJ) + - rm libmatrix.a + ar cr libmatrix.a $(OBJ) + ranlib libmatrix.a + +clean: + rm *.o + rm *.a diff --git a/sicsstatus.tcl b/sicsstatus.tcl index 4267fa8f..66f129d8 100644 --- a/sicsstatus.tcl +++ b/sicsstatus.tcl @@ -129,8 +129,8 @@ phone setAccess 2 adress UNKNOWN adress setAccess 2 # Counter counter -counter SetPreset 1000.000000 -counter SetMode Timer +counter SetPreset 1.000000 +counter SetMode Preset # Motor som som SoftZero 0.000000 som SoftLowerLim 0.000000 diff --git a/stest.tcl b/stest.tcl index ae23b638..a6269419 100644 --- a/stest.tcl +++ b/stest.tcl @@ -1,7 +1,7 @@ scan clear scan np 10 scan var A4 20. 2. -scan preset 0.5 +scan preset 10 for {set i 0 } { $i < 2000 } { incr i} { scan run }