- preserve empty lines in spec prep section (#573339)

This commit is contained in:
Panu Matilainen 2010-03-16 09:23:27 +00:00
parent be98b0d6ed
commit e3441ce16a
2 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,96 @@
commit 35052b96232810cbf0d91a4f1d1d3ff25a142fd0
Author: Panu Matilainen <pmatilai@redhat.com>
Date: Mon Mar 15 11:54:55 2010 +0200
Add an enhanced argvSplitString() function for splitting strings to argv's
- Returns the newly created argv instead of useless "this always returns 0"
- By default make a "real" split, including empty strings
- Flags argument allows controlling behavior, for now only flag is to
preserve argvSplit() behavior but leaves room for future enhancements
such as quoted splitting etc
commit 12802c36c9a3b7260d9f788afc826b1cc5ee05e2
Author: Panu Matilainen <pmatilai@redhat.com>
Date: Mon Mar 15 12:00:55 2010 +0200
Avoid eating empty lines in spec %prep section (RhBug:573339)
- In spec %prep context empty lines don't usually matter but they can
be significant in eg here-documents.
- Fixes regression from commit 94ff22b129aeb31c38848231e40f87aa4a5613a1
diff --git a/rpmio/argv.c b/rpmio/argv.c
index d633462..f21da1c 100644
--- a/rpmio/argv.c
+++ b/rpmio/argv.c
@@ -168,7 +168,7 @@ int argvAppend(ARGV_t * argvp, ARGV_const_t av)
return 0;
}
-int argvSplit(ARGV_t * argvp, const char * str, const char * seps)
+ARGV_t argvSplitString(const char * str, const char * seps, argvFlags flags)
{
char *dest = xmalloc(strlen(str) + 1);
ARGV_t argv;
@@ -189,14 +189,22 @@ int argvSplit(ARGV_t * argvp, const char * str, const char * seps)
argv = xmalloc( (argc + 1) * sizeof(*argv));
for (c = 0, s = dest; s < t; s+= strlen(s) + 1) {
- if (*s == '\0')
+ if (*s == '\0' && (flags & ARGV_SKIPEMPTY))
continue;
argv[c] = xstrdup(s);
c++;
}
argv[c] = NULL;
- *argvp = argv;
free(dest);
+ return argv;
+}
+
+/* Backwards compatibility */
+int argvSplit(ARGV_t * argvp, const char * str, const char * seps)
+{
+ if (argvp) {
+ *argvp = argvSplitString(str, seps, ARGV_SKIPEMPTY);
+ }
return 0;
}
diff --git a/rpmio/argv.h b/rpmio/argv.h
index 6a6fc7f..86ec137 100644
--- a/rpmio/argv.h
+++ b/rpmio/argv.h
@@ -138,6 +138,20 @@ int argvAddNum(ARGV_t * argvp, int val);
*/
int argvAppend(ARGV_t * argvp, ARGV_const_t av);
+typedef enum argvFlags_e {
+ ARGV_NONE = 0,
+ ARGV_SKIPEMPTY = (1 << 0), /* omit empty strings from result */
+} argvFlags;
+
+/** \ingroup rpmargv
+ * Split a string into an argv array.
+ * @param str string arg to split
+ * @param seps seperator characters
+ * @param flags flags to control behavior
+ * @return argv array
+ */
+ARGV_t argvSplitString(const char * str, const char * seps, argvFlags flags);
+
/** \ingroup rpmargv
* Split a string into an argv array.
* @retval *argvp argv array
diff --git a/build/parsePrep.c b/build/parsePrep.c
index 8e10c00..394c162 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -522,7 +522,7 @@ int parsePrep(rpmSpec spec)
}
}
- argvSplit(&saveLines, getStringBuf(sb), "\n");
+ saveLines = argvSplitString(getStringBuf(sb), "\n", ARGV_NONE);
for (lines = saveLines; *lines; lines++) {
res = 0;
if (rstreqn(*lines, "%setup", sizeof("%setup")-1)) {

View File

@ -45,6 +45,7 @@ Patch202: rpm-4.8.0-pythondeps-parallel.patch
Patch203: rpm-4.8.0-python-bytecompile.patch
Patch204: rpm-4.8.0-lazy-statfs.patch
Patch205: rpm-4.8.0-erasure-dsi.patch
Patch206: rpm-4.8.0-prep-keep-empty.patch
# These are not yet upstream
Patch301: rpm-4.6.0-niagara.patch
@ -196,6 +197,7 @@ packages on a system.
%patch203 -p1 -b .python-bytecompile
%patch204 -p1 -b .lazy-statfs
%patch205 -p1 -b .erasure-dsi
%patch206 -p1 -b .prep-keep-empty
%patch301 -p1 -b .niagara
%patch302 -p1 -b .geode
@ -415,6 +417,7 @@ exit 0
* Tue Mar 16 2010 Panu Matilainen <pmatilai@redhat.com> - 4.8.0-11
- support single PPD providing driver for devices (#568351)
- merge the psdriver patch pile into one
- preserve empty lines in spec prep section (#573339)
* Mon Feb 15 2010 Panu Matilainen <pmatilai@redhat.com> - 4.8.0-10
- drop bogus dependency on lzma, xz is used to handle the lzma format too