- Enable braces expansion in rpmGlob()
- Resolves: 1246743
This commit is contained in:
parent
632722fbed
commit
ee316a0bf8
123
rpm-4.12.90-braces-expansion.patch
Normal file
123
rpm-4.12.90-braces-expansion.patch
Normal file
@ -0,0 +1,123 @@
|
||||
From d14ecfe587efbe80e5534161dbd3a4f7158b4e2b Mon Sep 17 00:00:00 2001
|
||||
From: Lubos Kardos <lkardos@redhat.com>
|
||||
Date: Mon, 27 Jul 2015 11:22:19 +0200
|
||||
Subject: [PATCH] Enable {} expansion in rpmGlob() (rhbz:1246743)
|
||||
|
||||
---
|
||||
rpmio/rpmglob.c | 42 ++++++++++++++++++++++++++++++++----------
|
||||
1 file changed, 32 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/rpmio/rpmglob.c b/rpmio/rpmglob.c
|
||||
index 4fc106d..597ac5c 100644
|
||||
--- a/rpmio/rpmglob.c
|
||||
+++ b/rpmio/rpmglob.c
|
||||
@@ -150,7 +150,7 @@ static inline const char *next_brace_sub(const char *begin)
|
||||
return cp;
|
||||
}
|
||||
|
||||
-static int __glob_pattern_p(const char *pattern, int quote);
|
||||
+static int __glob_pattern_p(const char *pattern, int flags);
|
||||
|
||||
/* Do glob searching for PATTERN, placing results in PGLOB.
|
||||
The bits defined above may be set in FLAGS.
|
||||
@@ -419,7 +419,7 @@ glob(const char *pattern, int flags,
|
||||
return GLOB_NOMATCH;
|
||||
}
|
||||
|
||||
- if (__glob_pattern_p(dirname, !(flags & GLOB_NOESCAPE))) {
|
||||
+ if (__glob_pattern_p(dirname, flags)) {
|
||||
/* The directory name contains metacharacters, so we
|
||||
have to glob for the directory, and then glob for
|
||||
the pattern in each directory found. */
|
||||
@@ -646,10 +646,11 @@ static int prefix_array(const char *dirname, char **array, size_t n)
|
||||
|
||||
/* Return nonzero if PATTERN contains any metacharacters.
|
||||
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
|
||||
-static int __glob_pattern_p(const char *pattern, int quote)
|
||||
+static int __glob_pattern_p(const char *pattern, int flags)
|
||||
{
|
||||
register const char *p;
|
||||
- int open = 0;
|
||||
+ int openBrackets = 0;
|
||||
+ int openBraces = 0;
|
||||
|
||||
for (p = pattern; *p != '\0'; ++p)
|
||||
switch (*p) {
|
||||
@@ -658,18 +659,29 @@ static int __glob_pattern_p(const char *pattern, int quote)
|
||||
return 1;
|
||||
|
||||
case '\\':
|
||||
- if (quote && p[1] != '\0')
|
||||
+ if (!(flags & GLOB_NOESCAPE) && p[1] != '\0')
|
||||
++p;
|
||||
break;
|
||||
|
||||
case '[':
|
||||
- open = 1;
|
||||
+ openBrackets = 1;
|
||||
break;
|
||||
|
||||
case ']':
|
||||
- if (open)
|
||||
+ if (openBrackets)
|
||||
return 1;
|
||||
break;
|
||||
+
|
||||
+ case '{':
|
||||
+ if (flags & GLOB_BRACE)
|
||||
+ openBraces = 1;
|
||||
+ break;
|
||||
+
|
||||
+ case '}':
|
||||
+ if (openBraces)
|
||||
+ return 1;
|
||||
+ break;
|
||||
+
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -694,7 +706,7 @@ glob_in_dir(const char *pattern, const char *directory, int flags,
|
||||
int meta;
|
||||
int save;
|
||||
|
||||
- meta = __glob_pattern_p(pattern, !(flags & GLOB_NOESCAPE));
|
||||
+ meta = __glob_pattern_p(pattern, flags);
|
||||
if (meta == 0) {
|
||||
if (flags & (GLOB_NOCHECK | GLOB_NOMAGIC))
|
||||
/* We need not do any tests. The PATTERN contains no meta
|
||||
@@ -844,6 +856,8 @@ int rpmGlob(const char * patterns, int * argcPtr, ARGV_t * argvPtr)
|
||||
int i, j;
|
||||
int rc;
|
||||
|
||||
+ gflags |= GLOB_BRACE;
|
||||
+
|
||||
if (home != NULL && strlen(home) > 0)
|
||||
gflags |= GLOB_TILDE;
|
||||
|
||||
@@ -874,7 +888,9 @@ int rpmGlob(const char * patterns, int * argcPtr, ARGV_t * argvPtr)
|
||||
int dir_only = (plen > 0 && path[plen-1] == '/');
|
||||
glob_t gl;
|
||||
|
||||
- if (!local || (!rpmIsGlob(av[j], 0) && strchr(path, '~') == NULL)) {
|
||||
+ if (!local || (!rpmIsGlob(av[j], GLOB_NOESCAPE | flags) &&
|
||||
+ strchr(path, '~') == NULL)) {
|
||||
+
|
||||
argvAdd(&argv, av[j]);
|
||||
continue;
|
||||
}
|
||||
@@ -966,5 +982,11 @@ exit:
|
||||
|
||||
int rpmIsGlob(const char * pattern, int quote)
|
||||
{
|
||||
- return __glob_pattern_p(pattern, quote);
|
||||
+ int flags = 0;
|
||||
+ if (!quote) {
|
||||
+ flags |= GLOB_NOESCAPE;
|
||||
+ }
|
||||
+ flags |= GLOB_BRACE;
|
||||
+
|
||||
+ return __glob_pattern_p(pattern, flags);
|
||||
}
|
||||
--
|
||||
1.9.3
|
||||
|
6
rpm.spec
6
rpm.spec
@ -27,7 +27,7 @@
|
||||
Summary: The RPM package management system
|
||||
Name: rpm
|
||||
Version: %{rpmver}
|
||||
Release: %{?snapver:0.%{snapver}.}1%{?dist}
|
||||
Release: %{?snapver:0.%{snapver}.}2%{?dist}
|
||||
Group: System Environment/Base
|
||||
Url: http://www.rpm.org/
|
||||
Source0: http://rpm.org/releases/rpm-4.12.x/%{name}-%{srcver}.tar.bz2
|
||||
@ -50,6 +50,7 @@ Patch4: rpm-4.8.1-use-gpg2.patch
|
||||
Patch5: rpm-4.12.0-rpm2cpio-hack.patch
|
||||
|
||||
# Patches already upstream:
|
||||
Patch100: rpm-4.12.90-braces-expansion.patch
|
||||
|
||||
# These are not yet upstream
|
||||
Patch302: rpm-4.7.1-geode-i686.patch
|
||||
@ -534,6 +535,9 @@ exit 0
|
||||
%doc doc/librpm/html/*
|
||||
|
||||
%changelog
|
||||
* Mon Jul 27 2015 Lubos Kardos <lkardos@redhat.com> - 4.12.90-2
|
||||
- Enable braces expansion in rpmGlob() (#1246743)
|
||||
|
||||
* Fri Jul 24 2015 Florian Festi <ffesti@rpm.org> - 4.12.90-1
|
||||
- Update to upstream alpha release
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user