]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-unglobal.patch
- don't install and package some useless scripts
[packages/rpm.git] / rpm-unglobal.patch
1 --- rpm-4.5/rpmio/macro.c.org   2009-08-08 15:42:25.574860247 +0200
2 +++ rpm-4.5/rpmio/macro.c       2009-08-08 15:47:20.495455961 +0200
3 @@ -807,6 +807,43 @@
4      return se;
5  }
6  
7 +void delMacroAll(MacroContext mc, const char * n);
8 +
9 +/**
10 + * Parse (and execute) macro undefinition.
11 + * @param mc           macro context
12 + * @param se           macro name to undefine
13 + * @return             address to continue parsing
14 + */
15 +/*@dependent@*/ static const char *
16 +doUnglobal(MacroContext mc, /*@returned@*/ const char * se)
17 +       /*@globals rpmGlobalMacroContext @*/
18 +       /*@modifies mc, rpmGlobalMacroContext @*/
19 +{
20 +    const char *s = se;
21 +    char *buf = alloca(_macro_BUFSIZ);
22 +    char *n = buf, *ne = n;
23 +    int c;
24 +
25 +    COPYNAME(ne, s, c);
26 +
27 +    /* Move scan over body */
28 +    while (iseol(*s))
29 +       s++;
30 +    se = s;
31 +
32 +    /* Names must start with alphabetic or _ and be at least 3 chars */
33 +    if (!((c = *n) && (xisalpha(c) || c == '_') && (ne - n) > 2)) {
34 +       rpmlog(RPMLOG_ERR,
35 +               _("Macro %%%s has illegal name (%%unglobal)\n"), n);
36 +       return se;
37 +    }
38 +
39 +    delMacroAll(mc, n);
40 +
41 +    return se;
42 +}
43 +
44  #ifdef DYING
45  static void
46  dumpME(const char * msg, MacroEntry me)
47 @@ -1430,6 +1465,10 @@
48                 s = doUndefine(mb->mc, se);
49                 continue;
50         }
51 +       if (STREQ("unglobal", f, fn)) {
52 +               s = doUnglobal(mb->mc, se);
53 +               continue;
54 +       }
55  
56         if (STREQ("echo", f, fn) ||
57             STREQ("warn", f, fn) ||
58 @@ -1984,6 +2023,18 @@
59      }
60  }
61  
62 +void
63 +delMacroAll(MacroContext mc, const char * n)
64 +{
65 +       MacroEntry * mep;
66 +
67 +       if (mc == NULL) mc = rpmGlobalMacroContext;
68 +       /* If name exists, pop entry */
69 +       while ((mep = findEntry(mc, n, 0)) != NULL) {
70 +               delMacro(mc, n);
71 +       }
72 +}
73 +
74  /*@-mustmod@*/ /* LCL: mc is modified through mb->mc, mb is abstract */
75  int
76  rpmDefineMacro(MacroContext mc, const char * macro, int level)
This page took 0.029099 seconds and 3 git commands to generate.