following shell-like macros are available:
%0 the name of the macro being invoked
- %* all arguments
+ %* all arguments (unlike shell, not including any processed flags)
%# the number of arguments
%{-f} if present at invocation, the flag f itself
%{-f*} if present at invocation, the argument to flag f
argc++;
}
+#if 0 /* XXX this is shell syntax, macros need !* to be "the rest" */
/* Add unexpanded args as macro */
addMacro(mb->mc, "*", NULL, b, mb->depth);
+#endif
#ifdef NOTYET
/* XXX if macros can be passed as args ... */
optv[0] = me->name;
optv[opte] = NULL;
- /* ... and finally copy the options */
+ /* ... and finally define option macros. */
optind = 0;
optc = 0;
optc++; /* XXX count optv[0] */
optc++;
}
+ /* Add macro for each arg. Concatenate args for !* */
+ b = be;
for (c = optind; c < argc; c++) {
sprintf(aname, "%d", (c - optind + 1));
addMacro(mb->mc, aname, NULL, argv[c], mb->depth);
+
+ if (be > b) *be++ = ' ';
+ strcpy(be, argv[c]);
+ be += strlen(be);
+ *be = '\0';
+
optv[optc] = argv[c];
optc++;
}
+
+ /* Add arg count as macro */
sprintf(aname, "%d", (argc - optind + 1));
addMacro(mb->mc, "#", NULL, aname, mb->depth);
+ /* Add unexpanded args as macro */
+ addMacro(mb->mc, "*", NULL, b, mb->depth);
+
return se;
}
#ifdef DEBUG_MACROS
-MacroContext mc = { NULL, 0, 0};
-char *macrofiles = "../macros";
+char *macrofiles = "../macros:./testmacros";
char *testfile = "./test";
int
FILE *fp;
int x;
- initMacros(&mc, macrofiles);
- dumpMacroTable(&mc, NULL);
+ initMacros(NULL, macrofiles);
+ dumpMacroTable(NULL, NULL);
if ((fp = fopen(testfile, "r")) != NULL) {
while(fgets(buf, sizeof(buf), fp)) {
buf[strlen(buf)-1] = '\0';
- x = expandMacros(NULL, &mc, buf, sizeof(buf));
+ x = expandMacros(NULL, NULL, buf, sizeof(buf));
fprintf(stderr, "%d->%s\n", x, buf);
memset(buf, 0, sizeof(buf));
}
while(fgets(buf, sizeof(buf), stdin)) {
buf[strlen(buf)-1] = '\0';
- x = expandMacros(NULL, &mc, buf, sizeof(buf));
+ x = expandMacros(NULL, NULL, buf, sizeof(buf));
fprintf(stderr, "%d->%s\n <-\n", x, buf);
memset(buf, 0, sizeof(buf));
}
-# $Id: macros.in,v 1.23 1999/04/20 18:21:08 jbj Exp $
+# $Id: macros.in,v 1.24 1999/04/20 22:45:52 jbj Exp $
#==============================================================================
# Macro naming conventions (preliminary):
#
# The GNUconfigure macro does the following:
# update config.guess and config.sub.
# regenerate all autoconf/automake files
+# optionally change to a directory (make the directory if requested).
# run configure with correct prefix, platform, and CFLAGS.
+# optionally restore current directory.
#
-%GNUconfigure \
+%GNUconfigure(MC:) \
%{__libtoolize} --copy --force \
%{__aclocal} \
%{__autoheader} \
%{__automake} \
%{__autoconf} \
- CFLAGS="%{optflags}" ./configure %{_target_platform} --prefix=%{_prefix}
+ %{-C:_mydir="`pwd`"; %{-M; %{__mkdirp} %{-C*};} cd %{-C*}} \
+ CFLAGS="%{optflags}" %{-C:${_mydir}}%{!-C:.}/configure %{_target_platform} --prefix=%{_prefix} !*
+ %{-C:cd ${_mydir}; unset _mydir}
argc++;
}
+#if 0 /* XXX this is shell syntax, macros need !* to be "the rest" */
/* Add unexpanded args as macro */
addMacro(mb->mc, "*", NULL, b, mb->depth);
+#endif
#ifdef NOTYET
/* XXX if macros can be passed as args ... */
optv[0] = me->name;
optv[opte] = NULL;
- /* ... and finally copy the options */
+ /* ... and finally define option macros. */
optind = 0;
optc = 0;
optc++; /* XXX count optv[0] */
optc++;
}
+ /* Add macro for each arg. Concatenate args for !* */
+ b = be;
for (c = optind; c < argc; c++) {
sprintf(aname, "%d", (c - optind + 1));
addMacro(mb->mc, aname, NULL, argv[c], mb->depth);
+
+ if (be > b) *be++ = ' ';
+ strcpy(be, argv[c]);
+ be += strlen(be);
+ *be = '\0';
+
optv[optc] = argv[c];
optc++;
}
+
+ /* Add arg count as macro */
sprintf(aname, "%d", (argc - optind + 1));
addMacro(mb->mc, "#", NULL, aname, mb->depth);
+ /* Add unexpanded args as macro */
+ addMacro(mb->mc, "*", NULL, b, mb->depth);
+
return se;
}
#ifdef DEBUG_MACROS
-MacroContext mc = { NULL, 0, 0};
-char *macrofiles = "../macros";
+char *macrofiles = "../macros:./testmacros";
char *testfile = "./test";
int
FILE *fp;
int x;
- initMacros(&mc, macrofiles);
- dumpMacroTable(&mc, NULL);
+ initMacros(NULL, macrofiles);
+ dumpMacroTable(NULL, NULL);
if ((fp = fopen(testfile, "r")) != NULL) {
while(fgets(buf, sizeof(buf), fp)) {
buf[strlen(buf)-1] = '\0';
- x = expandMacros(NULL, &mc, buf, sizeof(buf));
+ x = expandMacros(NULL, NULL, buf, sizeof(buf));
fprintf(stderr, "%d->%s\n", x, buf);
memset(buf, 0, sizeof(buf));
}
while(fgets(buf, sizeof(buf), stdin)) {
buf[strlen(buf)-1] = '\0';
- x = expandMacros(NULL, &mc, buf, sizeof(buf));
+ x = expandMacros(NULL, NULL, buf, sizeof(buf));
fprintf(stderr, "%d->%s\n <-\n", x, buf);
memset(buf, 0, sizeof(buf));
}