Experimental Physics and Industrial Control System
I just found that our version of msi segfaults when given too many
substitutions as input. I thought I might upgrade msi to see if this is
already fixed and, voila, it is. This, however, prompted me to track down
what local changes we made to msi over the years. So here are some patches
which I think are improvements worthy to be included in the next release
(all changes are to file msi.c):
(1) This one is from 2000-16-03. It allows empty patterns and empty
substitutions:
@@ -142,16 +142,18 @@
long status;
status = macParseDefns(macPvt,pval,&pairs);
- if(!status) {
+ if(status==-1) {
fprintf(stderr,"Error macParseDefns error\n");
usageExit();
}
- status = macInstallMacros(macPvt,pairs);
- if(!status) {
- fprintf(stderr,"Error macInstallMacros error\n");
- usageExit();
+ if(status) {
+ status = macInstallMacros(macPvt,pairs);
+ if(!status) {
+ fprintf(stderr,"Error macInstallMacros error\n");
+ usageExit();
+ }
+ free((void *)pairs);
}
- free((void *)pairs);
}
typedef enum {cmdInclude,cmdSubstitute} cmdType;
(2) This is from 2001-09-03. It fixes the problem that msi silently
terminates if it encounters code like 'file xyz {}'.
@@ -576,7 +578,7 @@
*filename = psubInfo->filename;
while(psubFile->token==tokenSeparater) subGetNextToken(psubFile);
if(psubFile->token==tokenLBrace) return(1);
- if(psubFile->token==tokenRBrace) return(0);
+ if(psubFile->token==tokenRBrace) return(1);
if(psubFile->token!=tokenString
|| strcmp(psubFile->string,"pattern")!=0) {
subFileErrPrint(psubFile,"Expecting pattern");
(3) Use a do-{}-while loop instead of duplicating the loop body.
@@ -674,12 +676,10 @@
{
char *pline;
- pline = fgets(psubFile->inputBuffer,MAX_BUFFER_SIZE,psubFile->fp);
- ++psubFile->lineNum;
- while(pline && psubFile->inputBuffer[0]=='#') {
- pline = fgets(psubFile->inputBuffer,MAX_BUFFER_SIZE,psubFile->fp);
+ do {
+ pline = fgets(psubFile->inputBuffer,MAX_BUFFER_SIZE,psubFile->fp);
++psubFile->lineNum;
- }
+ } while(pline && psubFile->inputBuffer[0]=='#');
if(!pline) {
psubFile->token = tokenEOF;
psubFile->inputBuffer[0] = 0;
------------
I have attached a patch file containing these three changes relative to msi
release 1.5.
BTW, is the msi repo still CVS? If yes, what about moving it to a public
server and switch to some more convenient VCS?
Cheers
Ben
Helmholtz-Zentrum Berlin fÃr Materialien und Energie GmbH
Hahn-Meitner-Platz 1, 14109 Berlin
Vorsitzende des Aufsichtsrates: Prof. Dr. Dr. h.c. mult. Joachim Treusch
Stellvertretende Vorsitzende: Dr. Beatrix Vierkorn-Rudolph GeschÃftsfÃhrer: Prof. Dr. Anke Rita Kaysser-Pyzalla, Prof. Dr. Dr. h.c. Wolfgang Eberhardt, Dr. Ulrich Breuer
Sitz der Gesellschaft: Berlin Handelsregister: AG Charlottenburg, 89 HRB 5583
Disclaimer automatically attached by the E-Mail Security Appliance
mail0.bessy.de 08/17/10 at Helmholtz-Zentrum Berlin GmbH.
--- /opt/repositories/controls/darcs/epics/extensions/msi/vendor/msi.c 2010-08-17 12:41:52.000000000 +0200
+++ msi.c 2010-08-17 13:45:11.000000000 +0200
@@ -142,16 +142,18 @@
long status;
status = macParseDefns(macPvt,pval,&pairs);
- if(!status) {
+ if(status==-1) {
fprintf(stderr,"Error macParseDefns error\n");
usageExit();
}
- status = macInstallMacros(macPvt,pairs);
- if(!status) {
- fprintf(stderr,"Error macInstallMacros error\n");
- usageExit();
+ if(status) {
+ status = macInstallMacros(macPvt,pairs);
+ if(!status) {
+ fprintf(stderr,"Error macInstallMacros error\n");
+ usageExit();
+ }
+ free((void *)pairs);
}
- free((void *)pairs);
}
typedef enum {cmdInclude,cmdSubstitute} cmdType;
@@ -576,7 +578,7 @@
*filename = psubInfo->filename;
while(psubFile->token==tokenSeparater) subGetNextToken(psubFile);
if(psubFile->token==tokenLBrace) return(1);
- if(psubFile->token==tokenRBrace) return(0);
+ if(psubFile->token==tokenRBrace) return(1);
if(psubFile->token!=tokenString
|| strcmp(psubFile->string,"pattern")!=0) {
subFileErrPrint(psubFile,"Expecting pattern");
@@ -674,12 +676,10 @@
{
char *pline;
- pline = fgets(psubFile->inputBuffer,MAX_BUFFER_SIZE,psubFile->fp);
- ++psubFile->lineNum;
- while(pline && psubFile->inputBuffer[0]=='#') {
- pline = fgets(psubFile->inputBuffer,MAX_BUFFER_SIZE,psubFile->fp);
+ do {
+ pline = fgets(psubFile->inputBuffer,MAX_BUFFER_SIZE,psubFile->fp);
++psubFile->lineNum;
- }
+ } while(pline && psubFile->inputBuffer[0]=='#');
if(!pline) {
psubFile->token = tokenEOF;
psubFile->inputBuffer[0] = 0;
- Navigate by Date:
- Prev:
Re: DataBase question Tim Mooney
- Next:
Asyn and I/O intr scanning Hinko Kocevar
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: DataBase question Tim Mooney
- Next:
Asyn and I/O intr scanning Hinko Kocevar
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024