Support ';'-separated path lists on Windows
Also renamed the '-c' option to '-g' (global scope) Updated documentation to match.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <macLib.h>
|
||||
#include <ellLib.h>
|
||||
#include <epicsString.h>
|
||||
#include <osiFileName.h>
|
||||
|
||||
#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<FILE> save output to <FILE>\n");
|
||||
fprintf(stderr," -I<DIR> add <DIR> to include file search path\n");
|
||||
fprintf(stderr," -M<SUBST> add <SUBST> to (global) macro definitions\n");
|
||||
fprintf(stderr," (<SUBST> is of the form VAR=VALUE,...)\n");
|
||||
fprintf(stderr," -S<FILE> 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<FILE> Save output to <FILE>\n");
|
||||
fprintf(stderr," -I<DIR> Add <DIR> to include file search path\n");
|
||||
fprintf(stderr," -M<SUBST> Add <SUBST> to (global) macro definitions\n");
|
||||
fprintf(stderr," (<SUBST> takes the form VAR=VALUE,...)\n");
|
||||
fprintf(stderr," -S<FILE> 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));
|
||||
|
||||
@@ -24,7 +24,7 @@ accepted by the EPICS IOC's dbLoadTemplate command.</p>
|
||||
|
||||
<h2>Command Syntax:</h2>
|
||||
|
||||
<pre>msi -V -o<i>outfile</i> -I<i>dir</i> -M<i>subs</i> -S<i>subfile</i> <i>template</i></pre>
|
||||
<pre>msi -V -g -o<i>outfile</i> -I<i>dir</i> -M<i>subs</i> -S<i>subfile</i> <i>template</i></pre>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<dl>
|
||||
<dt><tt>-V</tt></dt>
|
||||
<dd>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.</dd>
|
||||
<dd>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.</dd>
|
||||
|
||||
<dt><tt>-g</tt></dt>
|
||||
<dd>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.</dd>
|
||||
|
||||
<dt><tt>-o</tt> <i>file</i></dt>
|
||||
<dd>Output will be written to the specifed file rather than to the standard
|
||||
output.</dd>
|
||||
|
||||
<dt><tt>-I</tt> <i>dir</i></dt>
|
||||
<dd>This parameter, which may be repeated, specifies a search path for
|
||||
include commands. For example:
|
||||
<dd>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:
|
||||
|
||||
<blockquote>
|
||||
<pre>msi -I /home/mrk/examples:. -I.. template</pre>
|
||||
|
||||
Reference in New Issue
Block a user