rpm-4.0.2.patch.bugfix 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ##
  2. ## rpm-4.0.2.patch.bugfix -- Annotated patch file
  3. ## Copyright (c) 2000-2001 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2001 Ralf S. Engelschall <rse.com>
  5. ##
  6. ## This file assembles changes to existing RPM source files between
  7. ## the original RedHat RPM and the OpenPKG RPM variant. It can be
  8. ## automatically applied to a vanilla RedHat RPM source tree with the
  9. ## 'patch' tool to upgrade those files. Each patch snippet is annotated
  10. ## with a short description.
  11. ##
  12. ## Created on: 23-Sep-2001
  13. ##
  14. +---------------------------------------------------------------------------
  15. | First, remove incorrectly introduced buffer assignment. Second, fix
  16. | second and subsequent "%{foo -x}" constructs. Without resetting
  17. | the option index only the first construct works. Third, bugfix
  18. | the handling of macros inside macro arguments as in "%{foo
  19. | bar%{quux}baz}". RPM correctly determined the pointer to the
  20. | terminating second(1) closing brace, but instead of passing
  21. | this pointer to the subroutine which handles the macro argument
  22. | construction, it passed the underlying character. This in turn
  23. | obviously leaded to an incorrect determination of the argument end
  24. | (it then though the first closing brace is the end). We fix this by
  25. | passing the pointer and not the underlying character.
  26. +---------------------------------------------------------------------------
  27. Index: rpmio/macro.c
  28. --- rpmio/macro.c 2001/01/19 01:47:25 1.1.1.2
  29. +++ rpmio/macro.c 2001/09/20 09:58:20 1.6
  30. @@ -746,7 +746,7 @@
  31. * @return address to continue parsing
  32. */
  33. /*@dependent@*/ static const char *
  34. -grabArgs(MacroBuf *mb, const MacroEntry *me, const char *se, char lastc)
  35. +grabArgs(MacroBuf *mb, const MacroEntry *me, const char *se, char *lastc)
  36. {
  37. char buf[BUFSIZ], *b, *be;
  38. char aname[16];
  39. @@ -764,7 +764,7 @@
  40. /* Copy args into buf until lastc */
  41. *be++ = ' ';
  42. - while ((c = *se++) != '\0' && c != lastc) {
  43. + while ((c = *se++) != '\0' && (se-1) != lastc) {
  44. if (!isblank(c)) {
  45. *be++ = c;
  46. continue;
  47. @@ -801,7 +801,7 @@
  48. /* Build argv array */
  49. argv = (const char **) alloca((argc + 1) * sizeof(char *));
  50. be[-1] = ' '; /* be - 1 == b + strlen(b) == buf + strlen(buf) */
  51. - buf[0] = '\0';
  52. + be[0] = '\0';
  53. b = buf;
  54. for (c = 0; c < argc; c++) {
  55. argv[c] = b;
  56. @@ -814,6 +814,15 @@
  57. opts = me->opts;
  58. /* Define option macros. */
  59. +#ifdef __GLIBC__
  60. + /* set to value of 0 instead of 1, because internally GNU libc
  61. + increases it to 1 implicitly, but additionally performs the
  62. + necessary full initialization. Without this the option parsing
  63. + will horribly break under Linux and various circumstances. */
  64. + optind = 0;
  65. +#else
  66. + optind = 1;
  67. +#endif
  68. while((c = getopt(argc, (char **)argv, opts)) != -1) {
  69. if (c == '?' || (o = strchr(opts, c)) == NULL) {
  70. rpmError(RPMERR_BADSPEC, _("Unknown option %c in %s(%s)\n"),
  71. @@ -991,7 +1000,7 @@
  72. int c;
  73. int rc = 0;
  74. int negate;
  75. - char grab;
  76. + char *grab;
  77. int chkexist;
  78. if (++mb->depth > max_macro_depth) {
  79. @@ -1024,7 +1033,7 @@
  80. if (mb->depth > 1) /* XXX full expansion for outermost level */
  81. t = mb->t; /* save expansion pointer for printExpand */
  82. negate = 0;
  83. - grab = '\0';
  84. + grab = NULL;
  85. chkexist = 0;
  86. switch ((c = *s)) {
  87. default: /* %name substitution */
  88. @@ -1058,7 +1067,8 @@
  89. fe = se;
  90. /* For "%name " macros ... */
  91. if ((c = *fe) && isblank(c))
  92. - grab = '\n';
  93. + if ((grab = strchr(fe, '\n')) == NULL)
  94. + grab = strchr(fe, '\0');
  95. break;
  96. case '(': /* %(...) shell escape */
  97. if ((se = matchchar(s, c, ')')) == NULL) {
  98. @@ -1104,7 +1114,7 @@
  99. ge = se - 1;
  100. break;
  101. case ' ':
  102. - grab = se[-1];
  103. + grab = se-1;
  104. break;
  105. default:
  106. break;