From 84f08a153a9f7c6e87cc74147bb0d1cd58ed717f Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Mon, 14 Dec 1998 14:46:26 +0000 Subject: [PATCH] fix imcompatibilities with subtool --- Makefile | 17 +++++++++++------ Makefile.Host | 11 +++++++++++ Makefile.Unix | 4 ++-- msi.c | 53 ++++++++++++++++++++++++++++++++++----------------- substitute | 7 +++++-- 5 files changed, 65 insertions(+), 27 deletions(-) create mode 100644 Makefile.Host diff --git a/Makefile b/Makefile index d3a001c71..39cb7cad1 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,15 @@ # # $Id$ # - -EPICS=../../.. - -include $(EPICS)/config/CONFIG_EXTENSIONS - -include $(EPICS)/config/RULES_ARCHS +TOP = ../.. +ifneq ($(wildcard $(TOP)/config)x,x) + # New Makefile.Host config file location + include $(TOP)/config/CONFIG_EXTENSIONS + include $(TOP)/config/RULES_ARCHS +else + # Old Makefile.Unix config file location + EPICS=../../.. + include $(EPICS)/config/CONFIG_EXTENSIONS + include $(EPICS)/config/RULES_ARCHS +endif diff --git a/Makefile.Host b/Makefile.Host new file mode 100644 index 000000000..65fea75e8 --- /dev/null +++ b/Makefile.Host @@ -0,0 +1,11 @@ +TOP = ../../.. +include $(TOP)/config/CONFIG_EXTENSIONS + + +PROD_LIBS += Com + +SRCS.c= ../msi.c +PROD = msi + +include $(TOP)/config/RULES.Host + diff --git a/Makefile.Unix b/Makefile.Unix index e9ccd1dff..f33d079ce 100644 --- a/Makefile.Unix +++ b/Makefile.Unix @@ -2,8 +2,8 @@ EPICS = ../../../.. include Target.include include $(EPICS)/config/CONFIG_EXTENSIONS -DEPLIBS = $(EPICS_BASE_LIB)/libCom.a $(EPICS_EXTENSIONS_LIB)/libpprsyd.a -USR_LDLIBS = -lpprsyd -lCom +DEPLIBS = $(EPICS_BASE_LIB)/libCom.a +USR_LDLIBS = -lCom USR_INCLUDES = -I$(EPICS_EXTENSIONS_INCLUDE) USR_CFLAGS = -L$(EPICS_EXTENSIONS_LIB) diff --git a/msi.c b/msi.c index 4b1a6aab8..744544a52 100644 --- a/msi.c +++ b/msi.c @@ -47,8 +47,10 @@ static void substituteOpen(void *substitutePvt,char *substitutionName); static char *substituteGetReplacements(void *substitutePvt); #define USAGEEXIT \ {\ - fprintf(stderr,"usage: msi -V -Idir ... -Msub ... -Ssubfile template \n");\ - exit(1);\ + fprintf(stderr,"usage: msi -V -Ipath ... -Msub ... -Ssubfile template \n");\ + fprintf(stderr," Specifying path will replace the default '.'\n");\ + fprintf(stderr," stdin is used if template is not given\n");\ + exit(1);\ } int main(int argc,char **argv) @@ -219,7 +221,6 @@ typedef struct inputData { char inputBuffer[MAX_BUFFER_SIZE]; }inputData; - static char *inputOpenFile(inputData *pinputData,char *filename); static void inputCloseFile(inputData *pinputData); static void inputCloseAllFiles(inputData *pinputData); @@ -256,20 +257,32 @@ static void inputAddPath(void *pvt, char *path) const char *pcolon; const char *pdir; int len; + int emptyName; pdir = path; - while(pdir) { - if(*pdir == ':') { - pdir++; - continue; - } + /*an empty name at beginning, middle, or end means current directory*/ + while(pdir && *pdir) { + emptyName = ((*pdir == ':') ? TRUE : FALSE); + if(emptyName) ++pdir; ppathNode = (pathNode *)calloc(1,sizeof(pathNode)); ellAdd(ppathList,&ppathNode->node); - pcolon = strchr(pdir,':'); - len = (pcolon ? (pcolon - pdir) : strlen(pdir)); - ppathNode->directory = (char *)calloc(1,len+1); - strncpy(ppathNode->directory,pdir,len); - pdir = (pcolon ? (pcolon+1) : 0); + if(!emptyName) { + pcolon = strchr(pdir,':'); + len = (pcolon ? (pcolon - pdir) : strlen(pdir)); + if(len>0) { + ppathNode->directory = (char *)calloc(len+1,sizeof(char)); + strncpy(ppathNode->directory,pdir,len); + pdir = pcolon; + /*unless at end skip past first colon*/ + if(pdir && *(pdir+1)!=0) ++pdir; + } else { /*must have been trailing : */ + emptyName=TRUE; + } + } + if(emptyName) { + ppathNode->directory = (char *)calloc(2,sizeof(char)); + strcpy(ppathNode->directory,"."); + } } return; } @@ -406,6 +419,7 @@ typedef enum { }tokenType; typedef struct subFile { + char *substitutionName; FILE *fp; int lineNum; char inputBuffer[MAX_BUFFER_SIZE]; @@ -473,6 +487,7 @@ static void substituteOpen(void *pvt,char *substitutionName) fprintf(stderr,"Could not open %s\n",substitutionName); exit(1); } + psubFile->substitutionName = substitutionName; psubFile->fp = fp; psubFile->lineNum = 0; psubFile->inputBuffer[0] = 0; @@ -517,9 +532,10 @@ static char *substituteGetReplacements(void *pvt) pNext = &psubInfo->macroReplacements[0]; psubInfo->macroReplacements[0] = 0; - if(psubFile->token!=tokenLBrace) - while(subGetNextToken(psubFile)==tokenSeparater); - if(psubFile->token==tokenEOF) return(0); + while(psubFile->token!=tokenLBrace) { + if(psubFile->token==tokenEOF) return(0); + subGetNextToken(psubFile); + } if(psubFile->token!=tokenLBrace) { subFileErrPrint(psubFile,"Expecting {"); exit(1); @@ -588,7 +604,8 @@ static char *subGetNextLine(subFile *psubFile) static void subFileErrPrint(subFile *psubFile,char * message) { - fprintf(stderr,"substitution file line %d: %s", + fprintf(stderr,"substitution file %s line %d: %s", + psubFile->substitutionName, psubFile->lineNum,psubFile->inputBuffer); fprintf(stderr,"%s\n",message); } @@ -604,7 +621,9 @@ static tokenType subGetNextToken(subFile *psubFile) if(*p==0 || *p=='\n') { p = subGetNextLine(psubFile); if(!p) return(tokenEOF); + else return(tokenSeparater); } + while(isspace(*p)) p++; if(*p=='{') { psubFile->token = tokenLBrace; psubFile->pnextChar = ++p; diff --git a/substitute b/substitute index c249b940e..22c98bb0e 100644 --- a/substitute +++ b/substitute @@ -1,2 +1,5 @@ -{a=xxx,b="yyy"} -{a=zzz , b=ttt} +{a=111,b="222"} +{ a = aaa , b=bbb} +{a= aaa +b= bbb +}