diff options
author | jbj <devnull@localhost> | 2000-10-31 16:18:34 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2000-10-31 16:18:34 +0000 |
commit | ce1e8d26ec5c76550c59fa30b6e6787e21f866e0 (patch) | |
tree | 3a3eba857ddc88c3367cbebb80e7800945ab9bbc /rpmio/macro.c | |
parent | d69a6f7c1c4901dd48ca730937ce67886fbf2c61 (diff) | |
download | rpm-ce1e8d26ec5c76550c59fa30b6e6787e21f866e0.tar.gz rpm-ce1e8d26ec5c76550c59fa30b6e6787e21f866e0.tar.bz2 rpm-ce1e8d26ec5c76550c59fa30b6e6787e21f866e0.zip |
- add support for SHA1 as well as MD5 message digests.
lclint annotations.
CVS patchset: 4234
CVS date: 2000/10/31 16:18:34
Diffstat (limited to 'rpmio/macro.c')
-rw-r--r-- | rpmio/macro.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/rpmio/macro.c b/rpmio/macro.c index 9c37106cb..66f7672db 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -42,6 +42,8 @@ typedef FILE * FD_t; #define Fread fread #define Fclose fclose +#define fdGetFILE(_fd) (_fd) + #else #include <rpmio_internal.h> @@ -52,6 +54,10 @@ typedef FILE * FD_t; #include <rpmmacro.h> +/*@access FD_t@*/ /* XXX compared with NULL */ +/*@access MacroContext@*/ +/*@access MacroEntry@*/ + struct MacroContext rpmGlobalMacroContext; struct MacroContext rpmCLIMacroContext; @@ -59,14 +65,14 @@ struct MacroContext rpmCLIMacroContext; * Macro expansion state. */ typedef struct MacroBuf { - const char *s; /*!< Text to expand. */ - char *t; /*!< Expansion buffer. */ +/*@shared@*/ const char *s; /*!< Text to expand. */ +/*@shared@*/ char *t; /*!< Expansion buffer. */ size_t nb; /*!< No. bytes remaining in expansion buffer. */ int depth; /*!< Current expansion depth. */ int macro_trace; /*!< Pre-print macro to expand? */ int expand_trace; /*!< Post-print macro expansion? */ - void *spec; /*!< (future) %file expansion info. */ - MacroContext *mc; +/*@shared@*/ void *spec; /*!< (future) %file expansion info. */ +/*@dependent@*/ MacroContext *mc; } MacroBuf; #define SAVECHAR(_mb, _c) { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; } @@ -191,7 +197,7 @@ rpmDumpMacroTable(MacroContext * mc, FILE * fp) * @param namelen no. of byes * @return address of slot in macro table with name (or NULL) */ -static MacroEntry ** +/*@dependent@*/ static MacroEntry ** findEntry(MacroContext *mc, const char *name, size_t namelen) { MacroEntry keybuf, *key, **ret; @@ -222,7 +228,7 @@ findEntry(MacroContext *mc, const char *name, size_t namelen) /** * fgets(3) analogue that reads \ continuations. Last newline always trimmed. */ -static char * +/*@dependent@*/ static char * rdcl(char *buf, size_t size, FD_t fd, int escapes) { char *q = buf; @@ -232,7 +238,7 @@ rdcl(char *buf, size_t size, FD_t fd, int escapes) *q = '\0'; do { /* read next line */ - if (fgets(q, size, (FILE *)fdGetFp(fd)) == NULL) + if (fgets(q, size, fdGetFILE(fd)) == NULL) break; nb = strlen(q); nread += nb; @@ -255,7 +261,7 @@ rdcl(char *buf, size_t size, FD_t fd, int escapes) } /** - * Return text between pl and matching pr. + * Return text between pl and matching pr characters. * @param p start of text * @param pl left char, i.e. '[', '(', '{', etc. * @param pr right char, i.e. ']', ')', '}', etc. @@ -521,7 +527,7 @@ doShellEscape(MacroBuf *mb, const char *cmd, size_t clen) * @param expandbody should body be expanded? * @return address to continue parsing */ -static const char * +/*@dependent@*/ static const char * doDefine(MacroBuf *mb, const char *se, int level, int expandbody) { const char *s = se; @@ -605,7 +611,7 @@ doDefine(MacroBuf *mb, const char *se, int level, int expandbody) * @param se macro name to undefine * @return address to continue parsing */ -static const char * +/*@dependent@*/ static const char * doUndefine(MacroContext *mc, const char *se) { const char *s = se; @@ -736,7 +742,7 @@ freeArgs(MacroBuf *mb) * @param lastc stop parsing at lastc * @return address to continue parsing */ -static const char * +/*@dependent@*/ static const char * grabArgs(MacroBuf *mb, const MacroEntry *me, const char *se, char lastc) { char buf[BUFSIZ], *b, *be; @@ -792,6 +798,7 @@ grabArgs(MacroBuf *mb, const MacroEntry *me, const char *se, char lastc) /* Build argv array */ argv = (const char **) alloca((argc + 1) * sizeof(char *)); be[-1] = ' '; /* be - 1 == b + strlen(b) == buf + strlen(buf) */ + buf[0] = '\0'; b = buf; for (c = 0; c < argc; c++) { argv[c] = b; @@ -997,7 +1004,7 @@ expandMacro(MacroBuf *mb) if (*s != '%') break; s++; /* skip first % in %% */ - /* fall thru */ + /*@fallthrough@*/ default: SAVECHAR(mb, c); continue; @@ -1017,7 +1024,7 @@ expandMacro(MacroBuf *mb) while (strchr("!?", *s) != NULL) { switch(*s++) { case '!': - negate = (++negate % 2); + negate = ((negate + 1) % 2); break; case '?': chkexist++; @@ -1073,7 +1080,7 @@ expandMacro(MacroBuf *mb) while (strchr("!?", *f) != NULL) { switch(*f++) { case '!': - negate = (++negate % 2); + negate = ((negate + 1) % 2); break; case '?': chkexist++; @@ -1353,6 +1360,7 @@ rpmDefineMacro(MacroContext *mc, const char *macro, int level) { MacroBuf macrobuf, *mb = ¯obuf; + memset(mb, 0, sizeof(*mb)); /* XXX just enough to get by */ mb->mc = (mc ? mc : &rpmGlobalMacroContext); (void)doDefine(mb, macro, level, 0); @@ -1527,6 +1535,7 @@ rpmExpand(const char *arg, ...) if (arg == NULL) return xstrdup(""); + buf[0] = '\0'; p = buf; pe = stpcpy(p, arg); @@ -1653,6 +1662,7 @@ rpmGetPath(const char *path, ...) if (path == NULL) return xstrdup(""); + buf[0] = '\0'; t = buf; te = stpcpy(t, path); *te = '\0'; @@ -1674,9 +1684,12 @@ rpmGetPath(const char *path, ...) const char * rpmGenPath(const char * urlroot, const char * urlmdir, const char *urlfile) { - const char * xroot = rpmGetPath(urlroot, NULL), * root = xroot; - const char * xmdir = rpmGetPath(urlmdir, NULL), * mdir = xmdir; - const char * xfile = rpmGetPath(urlfile, NULL), * file = xfile; +/*@owned@*/ const char * xroot = rpmGetPath(urlroot, NULL); +/*@dependent@*/ const char * root = xroot; +/*@owned@*/ const char * xmdir = rpmGetPath(urlmdir, NULL); +/*@dependent@*/ const char * mdir = xmdir; +/*@owned@*/ const char * xfile = rpmGetPath(urlfile, NULL); +/*@dependent@*/ const char * file = xfile; const char * result; const char * url = NULL; int nurl = 0; |