RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Ralf S. Engelschall
Root: /v/rpm/cvs Email: rse@rpm5.org
Module: rpm Date: 01-Feb-2008 08:58:40
Branch: rpm-5_0 Handle: 2008020107583901
Modified files: (Branch: rpm-5_0)
rpm CHANGES
rpm/rpmio macro.c
Log:
Merge bugfix from RPM 5.1: ensure macro option parsing is done
correctly also under GLIBC by not allowing option/argument
permutations
Summary:
Revision Changes Path
1.2054.2.32 +1 -0 rpm/CHANGES
2.171.2.3 +33 -0 rpm/rpmio/macro.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.2054.2.31 -r1.2054.2.32 CHANGES
--- rpm/CHANGES 1 Feb 2008 01:25:56 -0000 1.2054.2.31
+++ rpm/CHANGES 1 Feb 2008 07:58:39 -0000 1.2054.2.32
@@ -1,4 +1,5 @@
5.0.1 -> 5.0.2:
+ - rse: ensure macro option parsing is done correctly also under GLIBC by not allowing option/argument permutations
- jbj: pedantic identification of Foo (not foo) syscalls in --fsmdebug spew.
- jbj: fix: --rollback PSM_INIT changes added fstates before initialize.
- rse: allow to compile without <langinfo.h> and its nl_langinfo(3)
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/macro.c
============================================================================
$ cvs diff -u -r2.171.2.2 -r2.171.2.3 macro.c
--- rpm/rpmio/macro.c 21 Jan 2008 17:32:03 -0000 2.171.2.2
+++ rpm/rpmio/macro.c 1 Feb 2008 07:58:40 -0000 2.171.2.3
@@ -995,6 +995,9 @@
int argc = 0;
const char **argv;
int c;
+#ifdef __GLIBC__
+ char *posixly_correct;
+#endif
/* Copy macro name as argv[0], save beginning of args. */
buf[0] = '\0';
@@ -1080,6 +1083,29 @@
opts = me->opts;
+#ifdef __GLIBC__
+ /*
+ * Ensure option parsing is done without allowing option/argument permutations
+ * to avoid accidentally picking up and complaining about unknown options.
+ *
+ * Required standard POSIX getopt(3) behavior:
+ * $ rpm --define '%foo() <%*>' --eval '%{foo bar %(echo -n "quux") baz}'
+ * <bar quux baz>
+ *
+ * Unexpected non-standard Linux GLIBC getopt(3) behavior:
+ * $ rpm --define '%foo() <%*>' --eval '%{foo bar %(echo -n "quux") baz}'
+ * foo: invalid option -- n
+ * error: Unknown option ? in foo()
+ * <%*>
+ *
+ * Fixed standard POSIX getopt(3) behavior also under Linux GLIBC:
+ * $ POSIXLY_CORRECT=1 rpm --define '%foo() <%*>' --eval '%{foo bar %(echo -n "quux") baz}'
+ * <bar quux baz>
+ */
+ posixly_correct = getenv("POSIXLY_CORRECT");
+ setenv("POSIXLY_CORRECT", "1", 1);
+#endif
+
/* Define option macros. */
/*@-nullstate@*/ /* FIX: argv[] can be NULL */
while((c = getopt(argc, (char **)argv, opts)) != -1)
@@ -1106,6 +1132,13 @@
be = b; /* reuse the space */
}
+#ifdef __GLIBC__
+ if (posixly_correct != NULL)
+ setenv("POSIXLY_CORRECT", posixly_correct, 1);
+ else
+ unsetenv("POSIXLY_CORRECT");
+#endif
+
/* Add arg count as macro. */
sprintf(aname, "%d", (argc - optind));
addMacro(mb->mc, "#", NULL, aname, mb->depth);
@@ .
Received on Fri Feb 1 08:58:40 2008