Split setupArgs() function from grabArgs()
We will reuse setupArgs() in the future.
This commit is contained in:
parent
13df6fda91
commit
0cd8268ed2
|
@ -923,43 +923,21 @@ static int mbopt(int c, const char *oarg, int oint, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse arguments (to next new line) for parameterized macro.
|
* Setup arguments for parameterized macro.
|
||||||
* @todo Use popt rather than getopt to parse args.
|
|
||||||
* @param mb macro expansion state
|
* @param mb macro expansion state
|
||||||
* @param me macro entry slot
|
* @param me macro entry slot
|
||||||
* @param se arguments to parse
|
* @param se arguments to parse
|
||||||
* @param lastc stop parsing at lastc
|
* @param argv parsed arguments for the macro
|
||||||
* @return address to continue parsing
|
* Note that the call takes ownership of the argv
|
||||||
*/
|
*/
|
||||||
static const char *
|
static void
|
||||||
grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
|
setupArgs(MacroBuf mb, const rpmMacroEntry me, ARGV_t argv)
|
||||||
const char * lastc)
|
|
||||||
{
|
{
|
||||||
const char *cont = NULL;
|
|
||||||
char *args = NULL;
|
char *args = NULL;
|
||||||
ARGV_t argv = NULL;
|
int argc;
|
||||||
int argc = 0;
|
int ind;
|
||||||
int ind = 0;
|
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
/*
|
|
||||||
* Prepare list of call arguments, starting with macro name as argv[0].
|
|
||||||
* Make a copy of se up to lastc string that we can pass to argvSplit().
|
|
||||||
* Append the results to main argv.
|
|
||||||
*/
|
|
||||||
argvAdd(&argv, me->name);
|
|
||||||
if (lastc) {
|
|
||||||
char *s = NULL;
|
|
||||||
|
|
||||||
/* Expand possible macros in arguments */
|
|
||||||
expandThis(mb, se, lastc-se, &s);
|
|
||||||
splitQuoted(&argv, s, " \t");
|
|
||||||
free(s);
|
|
||||||
|
|
||||||
cont = (*lastc == '\0') || (*lastc == '\n' && *(lastc-1) != '\\') ?
|
|
||||||
lastc : lastc + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bump call depth on entry before first macro define */
|
/* Bump call depth on entry before first macro define */
|
||||||
mb->level++;
|
mb->level++;
|
||||||
|
|
||||||
|
@ -1012,6 +990,41 @@ grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
|
||||||
exit:
|
exit:
|
||||||
mb->me = me;
|
mb->me = me;
|
||||||
mb->args = argv;
|
mb->args = argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse arguments (to next new line) for parameterized macro.
|
||||||
|
* @todo Use popt rather than getopt to parse args.
|
||||||
|
* @param mb macro expansion state
|
||||||
|
* @param me macro entry slot
|
||||||
|
* @param se arguments to parse
|
||||||
|
* @param lastc stop parsing at lastc
|
||||||
|
* @return address to continue parsing
|
||||||
|
*/
|
||||||
|
static const char *
|
||||||
|
grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
|
||||||
|
const char * lastc)
|
||||||
|
{
|
||||||
|
const char *cont = NULL;
|
||||||
|
ARGV_t argv = NULL;
|
||||||
|
/*
|
||||||
|
* Prepare list of call arguments, starting with macro name as argv[0].
|
||||||
|
* Make a copy of se up to lastc string that we can pass to argvSplit().
|
||||||
|
* Append the results to main argv.
|
||||||
|
*/
|
||||||
|
argvAdd(&argv, me->name);
|
||||||
|
if (lastc) {
|
||||||
|
char *s = NULL;
|
||||||
|
|
||||||
|
/* Expand possible macros in arguments */
|
||||||
|
expandThis(mb, se, lastc-se, &s);
|
||||||
|
splitQuoted(&argv, s, " \t");
|
||||||
|
free(s);
|
||||||
|
|
||||||
|
cont = (*lastc == '\0') || (*lastc == '\n' && *(lastc-1) != '\\') ?
|
||||||
|
lastc : lastc + 1;
|
||||||
|
}
|
||||||
|
setupArgs(mb, me, argv);
|
||||||
return cont;
|
return cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue