|
Panu Matilainen |
351ab4 |
diff -up rpm-4.13.90-git14002/rpmio/macro.c.noquote rpm-4.13.90-git14002/rpmio/macro.c
|
|
Panu Matilainen |
351ab4 |
--- rpm-4.13.90-git14002/rpmio/macro.c.noquote 2017-08-14 11:43:41.160400779 +0300
|
|
Panu Matilainen |
351ab4 |
+++ rpm-4.13.90-git14002/rpmio/macro.c 2017-08-14 11:43:58.924398809 +0300
|
|
Panu Matilainen |
351ab4 |
@@ -649,61 +649,6 @@ freeArgs(MacroBuf mb, int delete)
|
|
Panu Matilainen |
351ab4 |
mb->level--;
|
|
Panu Matilainen |
351ab4 |
}
|
|
Panu Matilainen |
351ab4 |
|
|
Panu Matilainen |
351ab4 |
-/* XXX: belongs to argv.c but figure a sensible API before making public */
|
|
Panu Matilainen |
351ab4 |
-static ARGV_t argvSplitShell(const char * str, const char * seps)
|
|
Panu Matilainen |
351ab4 |
-{
|
|
Panu Matilainen |
351ab4 |
- char *dest = NULL;
|
|
Panu Matilainen |
351ab4 |
- ARGV_t argv;
|
|
Panu Matilainen |
351ab4 |
- int argc = 1;
|
|
Panu Matilainen |
351ab4 |
- const char * s;
|
|
Panu Matilainen |
351ab4 |
- char * t;
|
|
Panu Matilainen |
351ab4 |
- int c;
|
|
Panu Matilainen |
351ab4 |
- int quote;
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
- if (str == NULL || seps == NULL)
|
|
Panu Matilainen |
351ab4 |
- return NULL;
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
- dest = xmalloc(strlen(str) + 1);
|
|
Panu Matilainen |
351ab4 |
- t = dest;
|
|
Panu Matilainen |
351ab4 |
- s = str;
|
|
Panu Matilainen |
351ab4 |
- argc = 1;
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
- while ((c = *s)) {
|
|
Panu Matilainen |
351ab4 |
- if (strchr(seps, c)) {
|
|
Panu Matilainen |
351ab4 |
- s++;
|
|
Panu Matilainen |
351ab4 |
- } else {
|
|
Panu Matilainen |
351ab4 |
- if (!strchr("\"\'",c)) {
|
|
Panu Matilainen |
351ab4 |
- /* read argument not in "" or ''*/
|
|
Panu Matilainen |
351ab4 |
- for (; (c = *s); s++, t++) {
|
|
Panu Matilainen |
351ab4 |
- if (strchr(seps, c) || strchr("\"\'",c))
|
|
Panu Matilainen |
351ab4 |
- break;
|
|
Panu Matilainen |
351ab4 |
- *t = c;
|
|
Panu Matilainen |
351ab4 |
- }
|
|
Panu Matilainen |
351ab4 |
- } else {
|
|
Panu Matilainen |
351ab4 |
- /* read argument in "" or '' */
|
|
Panu Matilainen |
351ab4 |
- quote = *s;
|
|
Panu Matilainen |
351ab4 |
- s++;
|
|
Panu Matilainen |
351ab4 |
- for (; (c = *s) && (c != quote); t++,s++)
|
|
Panu Matilainen |
351ab4 |
- *t = c;
|
|
Panu Matilainen |
351ab4 |
- s++;
|
|
Panu Matilainen |
351ab4 |
- }
|
|
Panu Matilainen |
351ab4 |
- *t = '\0';
|
|
Panu Matilainen |
351ab4 |
- t++;
|
|
Panu Matilainen |
351ab4 |
- argc++;
|
|
Panu Matilainen |
351ab4 |
- }
|
|
Panu Matilainen |
351ab4 |
- }
|
|
Panu Matilainen |
351ab4 |
- *t = '\0';
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
- argv = xmalloc((argc + 1) * sizeof(*argv));
|
|
Panu Matilainen |
351ab4 |
- for (c = 0, s = dest; s < t; s+= strlen(s) + 1) {
|
|
Panu Matilainen |
351ab4 |
- argv[c] = xstrdup(s);
|
|
Panu Matilainen |
351ab4 |
- c++;
|
|
Panu Matilainen |
351ab4 |
- }
|
|
Panu Matilainen |
351ab4 |
- argv[c] = NULL;
|
|
Panu Matilainen |
351ab4 |
- free(dest);
|
|
Panu Matilainen |
351ab4 |
- return argv;
|
|
Panu Matilainen |
351ab4 |
-}
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
/**
|
|
Panu Matilainen |
351ab4 |
* Parse arguments (to next new line) for parameterized macro.
|
|
Panu Matilainen |
351ab4 |
* @todo Use popt rather than getopt to parse args.
|
|
Panu Matilainen |
351ab4 |
@@ -740,7 +685,7 @@ grabArgs(MacroBuf mb, const rpmMacroEntr
|
|
Panu Matilainen |
351ab4 |
expandThis(mb, se, lastc-se, &s);
|
|
Panu Matilainen |
351ab4 |
mb->escape = oescape;
|
|
Panu Matilainen |
351ab4 |
|
|
Panu Matilainen |
351ab4 |
- av = argvSplitShell(s, " \t");
|
|
Panu Matilainen |
351ab4 |
+ av = argvSplitString(s, " \t", ARGV_SKIPEMPTY);
|
|
Panu Matilainen |
351ab4 |
argvAppend(&argv, av);
|
|
Panu Matilainen |
351ab4 |
argvFree(av);
|
|
Panu Matilainen |
351ab4 |
free(s);
|
|
Panu Matilainen |
351ab4 |
diff -up rpm-4.13.90-git14002/tests/rpmmacro.at.noquote rpm-4.13.90-git14002/tests/rpmmacro.at
|
|
Panu Matilainen |
351ab4 |
--- rpm-4.13.90-git14002/tests/rpmmacro.at.noquote 2017-08-14 11:39:38.512426695 +0300
|
|
Panu Matilainen |
351ab4 |
+++ rpm-4.13.90-git14002/tests/rpmmacro.at 2017-08-14 11:40:18.807422527 +0300
|
|
Panu Matilainen |
351ab4 |
@@ -268,69 +268,6 @@ runroot rpm \
|
|
Panu Matilainen |
351ab4 |
)
|
|
Panu Matilainen |
351ab4 |
AT_CLEANUP
|
|
Panu Matilainen |
351ab4 |
|
|
Panu Matilainen |
351ab4 |
-AT_SETUP([macro arguments in double quotes])
|
|
Panu Matilainen |
351ab4 |
-AT_KEYWORDS([macros arguments])
|
|
Panu Matilainen |
351ab4 |
-AT_CHECK([
|
|
Panu Matilainen |
351ab4 |
-runroot rpm --define "%foo() 1:%1 2:%2" --eval '%foo "argument 1" argument_2'
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" \
|
|
Panu Matilainen |
351ab4 |
- --eval '%foo "argument 1" argument_2 """"""'
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm \
|
|
Panu Matilainen |
351ab4 |
- --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" \
|
|
Panu Matilainen |
351ab4 |
- --eval '%foo "arg. number 1""arg. number 2" "arg number 3" "" normal'
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm \
|
|
Panu Matilainen |
351ab4 |
- --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" \
|
|
Panu Matilainen |
351ab4 |
- --eval '%foo "arg. number 1"normal"arg. number 2" '
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" \
|
|
Panu Matilainen |
351ab4 |
- --eval '%foo """jjj"""aa"" '
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" --eval '%foo xx"yy""zz""""bb" '
|
|
Panu Matilainen |
351ab4 |
-],
|
|
Panu Matilainen |
351ab4 |
-[0],
|
|
Panu Matilainen |
351ab4 |
-[1:argument 1 2:argument_2
|
|
Panu Matilainen |
351ab4 |
-1:argument 1 2:argument_2 3: 4: 5:
|
|
Panu Matilainen |
351ab4 |
-1:arg. number 1 2:arg. number 2 3:arg number 3 4: 5:normal
|
|
Panu Matilainen |
351ab4 |
-1:arg. number 1 2:normal 3:arg. number 2 4:%4 5:%5
|
|
Panu Matilainen |
351ab4 |
-1: 2:jjj 3: 4:aa 5:
|
|
Panu Matilainen |
351ab4 |
-1:xx 2:yy 3:zz 4: 5:bb
|
|
Panu Matilainen |
351ab4 |
-])
|
|
Panu Matilainen |
351ab4 |
-AT_CLEANUP
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-AT_SETUP([macro arguments in single + double quotes])
|
|
Panu Matilainen |
351ab4 |
-AT_KEYWORDS([macros arguments])
|
|
Panu Matilainen |
351ab4 |
-AT_CHECK([
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm \
|
|
Panu Matilainen |
351ab4 |
- --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" \
|
|
Panu Matilainen |
351ab4 |
- --eval "%foo 'arg. number 1''arg. number 2' 'arg number 3' '' normal"
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm \
|
|
Panu Matilainen |
351ab4 |
- --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" \
|
|
Panu Matilainen |
351ab4 |
- --eval "%foo 'arg. number 1'normal'arg. number 2'''normal "
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" \
|
|
Panu Matilainen |
351ab4 |
- --eval "%foo '''jjj'''aa'' "
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" \
|
|
Panu Matilainen |
351ab4 |
- --eval "%foo ''\"jjj\"''aa\"\" "
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" --eval "%foo xx'yy''zz''''bb' "
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
-runroot rpm --define "%foo() 1:%1 2:%2 3:%3 4:%4 5:%5" --eval "%foo xx'yy'\"zz\"\"\"'bb' "
|
|
Panu Matilainen |
351ab4 |
-],
|
|
Panu Matilainen |
351ab4 |
-[0],
|
|
Panu Matilainen |
351ab4 |
-[1:arg. number 1 2:arg. number 2 3:arg number 3 4: 5:normal
|
|
Panu Matilainen |
351ab4 |
-1:arg. number 1 2:normal 3:arg. number 2 4: 5:normal
|
|
Panu Matilainen |
351ab4 |
-1: 2:jjj 3: 4:aa 5:
|
|
Panu Matilainen |
351ab4 |
-1: 2:jjj 3: 4:aa 5:
|
|
Panu Matilainen |
351ab4 |
-1:xx 2:yy 3:zz 4: 5:bb
|
|
Panu Matilainen |
351ab4 |
-1:xx 2:yy 3:zz 4: 5:bb
|
|
Panu Matilainen |
351ab4 |
-])
|
|
Panu Matilainen |
351ab4 |
-AT_CLEANUP
|
|
Panu Matilainen |
351ab4 |
-
|
|
Panu Matilainen |
351ab4 |
AT_SETUP([%undefine from different scopes])
|
|
Panu Matilainen |
351ab4 |
AT_KEYWORDS([macros %undefine])
|
|
Panu Matilainen |
351ab4 |
AT_CHECK([
|