diff --git a/src/ioc/dbStatic/dbLexRoutines.c b/src/ioc/dbStatic/dbLexRoutines.c index 75453dcac..162df824b 100644 --- a/src/ioc/dbStatic/dbLexRoutines.c +++ b/src/ioc/dbStatic/dbLexRoutines.c @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* $Revision-Id$ */ @@ -36,7 +36,7 @@ #include "dbStaticLib.h" #include "dbStaticPvt.h" - + /*global declarations*/ epicsShareDef char *makeDbdDepends=0; @@ -107,7 +107,7 @@ typedef struct tempListNode { static ELLLIST tempList = ELLLIST_INIT; static void *freeListPvt = NULL; static int duplicate = FALSE; - + static void yyerrorAbort(char *str) { yyerror(str); @@ -142,7 +142,7 @@ static void *getLastTemp(void) ptempListNode = (tempListNode *)ellLast(&tempList); return(ptempListNode->item); } - + static char *dbOpenFile(DBBASE *pdbbase,const char *filename,FILE **fp) { ELLLIST *ppathList = (ELLLIST *)pdbbase->pathPvt; @@ -160,7 +160,7 @@ static char *dbOpenFile(DBBASE *pdbbase,const char *filename,FILE **fp) } pdbPathNode = (dbPathNode *)ellFirst(ppathList); while (pdbPathNode) { - fullfilename = dbMalloc(strlen(pdbPathNode->directory) + + fullfilename = dbMalloc(strlen(pdbPathNode->directory) + strlen(filename) + 2); strcpy(fullfilename, pdbPathNode->directory); strcat(fullfilename, "/"); @@ -181,7 +181,7 @@ static void freeInputFileList(void) inputFile *pinputFileNow; while((pinputFileNow=(inputFile *)ellFirst(&inputFileList))) { - if(fclose(pinputFileNow->fp)) + if(fclose(pinputFileNow->fp)) errPrintf(0,__FILE__, __LINE__, "Closing file %s",pinputFileNow->filename); free((void *)pinputFileNow->filename); @@ -189,7 +189,7 @@ static void freeInputFileList(void) free((void *)pinputFileNow); } } - + static long dbReadCOM(DBBASE **ppdbbase,const char *filename, FILE *fp, const char *path,const char *substitutions) { @@ -197,7 +197,7 @@ static long dbReadCOM(DBBASE **ppdbbase,const char *filename, FILE *fp, inputFile *pinputFile = NULL; char *penv; char **macPairs; - + if(*ppdbbase == 0) *ppdbbase = dbAllocBase(); pdbbase = *ppdbbase; if(path && strlen(path)>0) { @@ -302,12 +302,12 @@ long dbReadDatabase(DBBASE **ppdbbase,const char *filename, long dbReadDatabaseFP(DBBASE **ppdbbase,FILE *fp, const char *path,const char *substitutions) {return (dbReadCOM(ppdbbase,0,fp,path,substitutions));} - + static int db_yyinput(char *buf, int max_size) { size_t l,n; char *fgetsRtn; - + if(yyAbort) return(0); if(*my_buffer_ptr==0) { while(TRUE) { /*until we get some input*/ @@ -327,7 +327,7 @@ static int db_yyinput(char *buf, int max_size) fgetsRtn = fgets(my_buffer,MY_BUFFER_SIZE,pinputFileNow->fp); } if(fgetsRtn) break; - if(fclose(pinputFileNow->fp)) + if(fclose(pinputFileNow->fp)) errPrintf(0,__FILE__, __LINE__, "Closing file %s",pinputFileNow->filename); free((void *)pinputFileNow->filename); @@ -395,7 +395,7 @@ static void dbIncludeNew(char *filename) ellAdd(&inputFileList,&pinputFile->node); pinputFileNow = pinputFile; } - + static void dbMenuHead(char *name) { dbMenu *pdbMenu; @@ -455,7 +455,7 @@ static void dbMenuBody(void) pgphentry->userPvt = pnewMenu; } } - + static void dbRecordtypeHead(char *name) { dbRecordType *pdbRecordType; @@ -478,7 +478,7 @@ static void dbRecordtypeFieldHead(char *name,char *type) { dbFldDes *pdbFldDes; int i; - + if(duplicate) return; pdbFldDes = dbCalloc(1,sizeof(dbFldDes)); allocTemp(pdbFldDes); @@ -492,11 +492,11 @@ static void dbRecordtypeFieldHead(char *name,char *type) } yyerrorAbort("Illegal Field Type"); } - + static void dbRecordtypeFieldItem(char *name,char *value) { dbFldDes *pdbFldDes; - + if(duplicate) return; pdbFldDes = (dbFldDes *)getLastTemp(); if(strcmp(name,"asl")==0) { @@ -590,23 +590,23 @@ static void dbRecordtypeFieldItem(char *name,char *value) return; } } - + static void dbRecordtypeCdef(char *text) { dbText *pdbCdef; tempListNode *ptempListNode; dbRecordType *pdbRecordType; - + if (!pdbbase->loadCdefs || duplicate) return; ptempListNode = (tempListNode *)ellFirst(&tempList); pdbRecordType = ptempListNode->item; - + pdbCdef = dbCalloc(1,sizeof(dbText)); if (text[0] == ' ') text++; /* strip leading space if present */ pdbCdef->text = epicsStrDup(text); ellAdd(&pdbRecordType->cdefList, &pdbCdef->node); return; } - + static void dbRecordtypeBody(void) { dbRecordType *pdbRecordType; @@ -753,7 +753,7 @@ static void dbDriver(char *name) pgphentry = gphAdd(pdbbase->pgpHash,pdrvSup->name,&pdbbase->drvList); if(!pgphentry) { yyerrorAbort("gphAdd failed"); - } + } pgphentry->userPvt = pdrvSup; ellAdd(&pdbbase->drvList,&pdrvSup->node); } @@ -772,7 +772,7 @@ static void dbRegistrar(char *name) pgphentry = gphAdd(pdbbase->pgpHash,ptext->text,&pdbbase->registrarList); if(!pgphentry) { yyerrorAbort("gphAdd failed"); - } + } pgphentry->userPvt = ptext; ellAdd(&pdbbase->registrarList,&ptext->node); } @@ -811,7 +811,7 @@ static void dbVariable(char *name, char *type) pgphentry = gphAdd(pdbbase->pgpHash,pvar->name,&pdbbase->variableList); if(!pgphentry) { yyerrorAbort("gphAdd failed"); - } + } pgphentry->userPvt = pvar; ellAdd(&pdbbase->variableList,&pvar->node); } @@ -870,11 +870,11 @@ static void dbBreakBody(void) pnewbrkTable->paBrkInt = paBrkInt = dbCalloc(number, sizeof(brkInt)); for (i=0; iuserPvt = pnewbrkTable; } - + static void dbRecordHead(char *recordType, char *name, int visible) { char *badch; @@ -995,7 +995,7 @@ static void dbRecordField(char *name,char *value) pdbentry = ptempListNode->item; status = dbFindField(pdbentry,name); if(status) { - epicsPrintf("Record \"%s\" does not have a field \"%s\"\n", + epicsPrintf("Record \"%s\" does not have a field \"%s\"\n", dbGetRecordName(pdbentry), name); yyerror(NULL); return; diff --git a/src/ioc/dbtemplate/msi.c b/src/ioc/dbtemplate/msi.c index 3884b9bc5..5a5baab68 100644 --- a/src/ioc/dbtemplate/msi.c +++ b/src/ioc/dbtemplate/msi.c @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS Base is distributed subject to a Software License Agreement found -* in the file LICENSE that is included with this distribution. +* in the file LICENSE that is included with this distribution. \*************************************************************************/ /* msi - macro substitutions and include */ @@ -54,7 +54,7 @@ static void makeSubstitutions(inputData *inputPvt, MAC_HANDLE *macPvt, char *tem /*Global variables */ static int opt_V = 0; - + int main(int argc,char **argv) { inputData *inputPvt; @@ -141,7 +141,7 @@ int main(int argc,char **argv) free(substitutionName); return opt_V & 2; } - + void usageExit(void) { fprintf(stderr,"usage: msi [options] [template]\n"); @@ -192,7 +192,7 @@ static void makeSubstitutions(inputData *inputPvt, MAC_HANDLE *macPvt, char *tem char *p; char *command = 0; - p = input; + p = input; /*skip whitespace at beginning of line*/ while(*p && (isspace((int) *p))) ++p; /*Look for i or s */ @@ -203,7 +203,7 @@ static void makeSubstitutions(inputData *inputPvt, MAC_HANDLE *macPvt, char *tem char *copy; int cmdind=-1; int i; - + for(i=0; i< NELEMENTS(cmdNames); i++) { if(strstr(command,cmdNames[i])) { cmdind = i; @@ -259,7 +259,7 @@ endif: } } } - + typedef struct inputFile{ ELLNODE node; char *filename; @@ -304,7 +304,7 @@ static void inputDestruct(inputData *pinputData) } free(pinputData); } - + static void inputAddPath(inputData *pinputData, char *path) { ELLLIST *ppathList = &pinputData->pathList; @@ -443,7 +443,7 @@ static void inputCloseFile(inputData *pinputData) pinputFile = (inputFile *)ellFirst(&pinputData->inputFileList); if(!pinputFile) return; ellDelete(&pinputData->inputFileList,&pinputFile->node); - if(fclose(pinputFile->fp)) + if(fclose(pinputFile->fp)) fprintf(stderr,"msi: Can't close input file '%s'\n",pinputFile->filename); free(pinputFile->filename); free(pinputFile); @@ -457,7 +457,7 @@ static void inputCloseAllFiles(inputData *pinputData) inputCloseFile(pinputData); } } - + /*start of code that handles substitution file*/ typedef enum { tokenLBrace,tokenRBrace,tokenSeparater,tokenString,tokenEOF @@ -518,7 +518,7 @@ void freePattern(subInfo *psubInfo) } psubInfo->isPattern = 0; } - + static void substituteDestruct(subInfo *psubInfo) { freeSubFile(psubInfo); @@ -624,7 +624,7 @@ static int substituteGetNextSet(subInfo *psubInfo,char **filename) subGetNextToken(psubFile); return(1); } - + static char *substituteGetGlobalReplacements(subInfo *psubInfo) { subFile *psubFile = psubInfo->psubFile; @@ -727,7 +727,7 @@ static char *substituteGetReplacements(subInfo *psubInfo) } } } - + static char *subGetNextLine(subFile *psubFile) { char *pline; @@ -754,7 +754,7 @@ static void subFileErrPrint(subFile *psubFile,char * message) psubFile->lineNum,psubFile->inputBuffer); } - + static tokenType subGetNextToken(subFile *psubFile) { char *p; @@ -809,7 +809,7 @@ static tokenType subGetNextToken(subFile *psubFile) } /*Now take anything up to next non String token and not space*/ pto = &psubFile->string[0]; - while(!isspace((int) *p) && (strspn(p,"\",{}")==0)) *pto++ = *p++; + while(!isspace((int) *p) && (strspn(p,"\",{}")==0)) *pto++ = *p++; *pto = 0; psubFile->pnextChar = p; psubFile->token = tokenString; diff --git a/src/libCom/iocsh/iocsh.cpp b/src/libCom/iocsh/iocsh.cpp index c918d270c..1e1caa202 100644 --- a/src/libCom/iocsh/iocsh.cpp +++ b/src/libCom/iocsh/iocsh.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* iocsh.cpp */ /* Author: Marty Kraimer Date: 27APR2000 */ @@ -201,7 +201,7 @@ void epicsShareAPI iocshRegisterVariable (const iocshVarDef *piocshVarDef) /* * Free storage created by iocshRegister/iocshRegisterVariable */ -void epicsShareAPI iocshFree(void) +void epicsShareAPI iocshFree(void) { struct iocshCommand *pc; struct iocshVariable *pv; @@ -498,7 +498,7 @@ iocshBody (const char *pathname, const char *commandLine, const char* macros) struct iocshCommand *found; void *readlineContext = NULL; int wasOkToBlock; - + /* * See if command interpreter is interactive */ @@ -585,7 +585,7 @@ iocshBody (const char *pathname, const char *commandLine, const char* macros) * Expand macros */ free(line); - if ((line = macEnvExpand(raw, macros)) == NULL) + if ((line = macEnvExpand(raw)) == NULL) continue; /* @@ -831,11 +831,11 @@ iocshBody (const char *pathname, const char *commandLine, const char* macros) * External access to the command interpreter */ int epicsShareAPI -iocsh (const char *pathname) +iocsh (const char *pathname, const char* macros) { if (pathname) epicsEnvSet("IOCSH_STARTUP_SCRIPT", pathname); - return iocshBody(pathname, NULL, NULL); + return iocshBody(pathname, NULL, macros); } int epicsShareAPI diff --git a/src/libCom/iocsh/iocsh.h b/src/libCom/iocsh/iocsh.h index 9000f2a4d..c86cc81af 100644 --- a/src/libCom/iocsh/iocsh.h +++ b/src/libCom/iocsh/iocsh.h @@ -5,7 +5,7 @@ * Operator of Los Alamos National Laboratory. * EPICS BASE Versions 3.13.7 * and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* iocsh.h ioc: call registered function*/ /* Author: Marty Kraimer Date: 27APR2000 */ @@ -68,7 +68,7 @@ epicsShareFunc void epicsShareAPI iocshRegisterVariable ( /* This should only be called when iocsh is no longer needed*/ epicsShareFunc void epicsShareAPI iocshFree(void); -epicsShareFunc int epicsShareAPI iocsh(const char *pathname); +epicsShareFunc int epicsShareAPI iocsh(const char *pathname, const char* macros); epicsShareFunc int epicsShareAPI iocshCmd(const char *cmd, const char* macros); /* 'weak' link to pdbbase */ diff --git a/src/libCom/macLib/macEnv.c b/src/libCom/macLib/macEnv.c index 596133056..fc362d953 100644 --- a/src/libCom/macLib/macEnv.c +++ b/src/libCom/macLib/macEnv.c @@ -2,7 +2,7 @@ * Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* $Revision-Id$ * @@ -23,8 +23,8 @@ macEnvExpand(const char *str, const char* macros) { MAC_HANDLE *handle; static char *pairs[] = { "", "environ", NULL, NULL }; - char** defines; - long destCapacity = 128; + char** defines; + long destCapacity = 128; char *dest = NULL; int n; @@ -33,17 +33,14 @@ macEnvExpand(const char *str, const char* macros) return NULL; } - if (macros) - { - if (macParseDefns(handle, macros, &defines) < 0) - { - cantProceed("macEnvExpand: invalid macro string"); - } - else - { - macInstallMacros(handle, defines); - } - } + if (macros) { + if (macParseDefns(handle, macros, &defines) < 0) { + cantProceed("macEnvExpand: invalid macro string"); + } + else { + macInstallMacros(handle, defines); + } + } do { destCapacity *= 2; diff --git a/src/libCom/macLib/macLib.h b/src/libCom/macLib/macLib.h index bbfd44aef..c4fc451db 100644 --- a/src/libCom/macLib/macLib.h +++ b/src/libCom/macLib/macLib.h @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* $Revision-Id$ * @@ -149,7 +149,7 @@ epicsShareAPI macInstallMacros( epicsShareFunc char * /* expanded string; NULL if any undefined macros */ epicsShareAPI macEnvExpand( const char *str, /* string to be expanded */ - const char *macros /* macro definitions in "a=xxx, b=yyy" */ + const char *macros /* macro definitions in "a=xxx, b=yyy" */ ); #ifdef __cplusplus diff --git a/src/libCom/test/macEnvExpandTest.c b/src/libCom/test/macEnvExpandTest.c index f3e9d924a..e37af38f7 100644 --- a/src/libCom/test/macEnvExpandTest.c +++ b/src/libCom/test/macEnvExpandTest.c @@ -152,7 +152,7 @@ MAIN(macEnvExpandTest) check("${FOO,FOO=$(FOO)}", NULL); check("${FOO=$(FOO)}", NULL); check("${FOO=$(BAR),BAR=$(FOO)}", NULL); - + errlogFlush(); eltc(1); return testDone();