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