rpm/rpm-4.8.0-prep-keep-empty.patch
2010-03-16 09:23:27 +00:00

97 lines
3.0 KiB
Diff

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)) {