From d5f050a9a2f654b96a9fc60b5d83ffd86128126a Mon Sep 17 00:00:00 2001
From: Andrew Johnson
Date: Thu, 31 May 2012 16:39:05 -0500
Subject: [PATCH] Support ';'-separated path lists on Windows
Also renamed the '-c' option to '-g' (global scope)
Updated documentation to match.
---
src/dbtools/msi.c | 30 ++++++++++++++++--------------
src/dbtools/msi.html | 22 +++++++++++++++-------
2 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/src/dbtools/msi.c b/src/dbtools/msi.c
index bdde98ff6..b2733199b 100644
--- a/src/dbtools/msi.c
+++ b/src/dbtools/msi.c
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
#define MAX_BUFFER_SIZE 4096
@@ -62,7 +63,7 @@ int main(int argc,char **argv)
char *substitutionName=0;
char *templateName=0;
int i;
- int optScoped=1;
+ int localScope = 1;
inputConstruct(&inputPvt);
macCreateHandle(&macPvt,0);
@@ -86,8 +87,8 @@ int main(int argc,char **argv)
macSuppressWarning(macPvt,0);
dontWarnUndef = 0;
narg = 1; /* no argument for this option */
- } else if(strncmp(argv[1],"-c",2)==0) {
- optScoped = 0;
+ } else if(strncmp(argv[1],"-g",2)==0) {
+ localScope = 0;
narg = 1; /* no argument for this option */
} else {
usageExit();
@@ -123,10 +124,10 @@ int main(int argc,char **argv)
usageExit();
}
while((pval = substituteGetReplacements(substitutePvt))){
- if (optScoped) macPushScope(macPvt);
+ if (localScope) macPushScope(macPvt);
addMacroReplacements(macPvt,pval);
makeSubstitutions(inputPvt,macPvt,filename);
- if (optScoped) macPopScope(macPvt);
+ if (localScope) macPopScope(macPvt);
}
}
} while (isGlobal || isFile);
@@ -144,13 +145,13 @@ void usageExit(void)
fprintf(stderr,"usage: msi [options] [template]\n");
fprintf(stderr,"stdin is used if neither template nor substitution file is given\n");
fprintf(stderr,"options:\n");
- fprintf(stderr," -V don't suppress warnings\n");
- fprintf(stderr," -o save output to \n");
- fprintf(stderr," -I add to include file search path\n");
- fprintf(stderr," -M add to (global) macro definitions\n");
- fprintf(stderr," ( is of the form VAR=VALUE,...)\n");
- fprintf(stderr," -S expand a substitution file\n");
- fprintf(stderr," -c macro definitions are scoped (in substitution files)\n");
+ fprintf(stderr," -V Verbose warnings\n");
+ fprintf(stderr," -g All macros have global scope\n");
+ fprintf(stderr," -o Save output to \n");
+ fprintf(stderr," -I Add to include file search path\n");
+ fprintf(stderr," -M Add to (global) macro definitions\n");
+ fprintf(stderr," ( takes the form VAR=VALUE,...)\n");
+ fprintf(stderr," -S Expand the substitutions in FILE\n");
exit(1);
}
@@ -310,16 +311,17 @@ static void inputAddPath(inputData *pinputData, char *path)
const char *pdir;
int len;
int emptyName;
+ const char sep = *OSI_PATH_LIST_SEPARATOR;
pdir = path;
/*an empty name at beginning, middle, or end means current directory*/
while(pdir && *pdir) {
- emptyName = ((*pdir == ':') ? 1 : 0);
+ emptyName = ((*pdir == sep) ? 1 : 0);
if(emptyName) ++pdir;
ppathNode = (pathNode *)calloc(1,sizeof(pathNode));
ellAdd(ppathList,&ppathNode->node);
if(!emptyName) {
- pcolon = strchr(pdir,':');
+ pcolon = strchr(pdir,sep);
len = (pcolon ? (pcolon - pdir) : strlen(pdir));
if(len>0) {
ppathNode->directory = (char *)calloc(len+1,sizeof(char));
diff --git a/src/dbtools/msi.html b/src/dbtools/msi.html
index 0be7bef5f..b7e4e9e9e 100644
--- a/src/dbtools/msi.html
+++ b/src/dbtools/msi.html
@@ -24,7 +24,7 @@ accepted by the EPICS IOC's dbLoadTemplate command.
Command Syntax:
-msi -V -ooutfile -Idir -Msubs -Ssubfile template
+msi -V -g -ooutfile -Idir -Msubs -Ssubfile template
All parameters are optional. The -o, -I, -M, and -S switches may be
separated from their associated value string by spaces if desired. Output will
@@ -34,18 +34,26 @@ be written to stdout unless the -o option is given.
- -V
- - If this parameter is specified then any undefined macro discovered in
- the template file which does not have an associated default value is
- considered an error. An error message is generated and when msi terminates
- it will do so with an exit status of 2.
+ - Verbose warnings; if this parameter is specified then any undefined
+ macro discovered in the template file which does not have an associated
+ default value is considered an error. An error message is generated, and
+ when msi terminates it will do so with an exit status of 2.
+
+ - -g
+ - When this flag is given all macros defined in a substitution file will
+ have global scope and thus their values will persist until a new value is
+ given for this macro. This flag is provided for backwards compatibility as
+ this was the behavior of previous versions of msi, but it does not follow
+ common scoping rules and is discouraged.
- -o file
- Output will be written to the specifed file rather than to the standard
output.
- -I dir
- - This parameter, which may be repeated, specifies a search path for
- include commands. For example:
+
- This parameter, which may be repeated or contain a colon-separated (or
+ semi-colon separated on Windows) list of directory paths, specifies a search
+ path for include commands. For example:
msi -I /home/mrk/examples:. -I.. template