diff options
author | Jindrich Novy <jnovy@redhat.com> | 2008-12-09 12:47:50 +0100 |
---|---|---|
committer | Jindrich Novy <jnovy@redhat.com> | 2008-12-09 12:47:50 +0100 |
commit | 2ba56c673bf1c168cccb827938c09f5ff2a3beda (patch) | |
tree | 1b5259a509ca297181201343ad2bbf8f664c80e3 | |
parent | 0643dd44e6e243870868b0fb8196adad1632dfbb (diff) | |
download | rpm-2ba56c673bf1c168cccb827938c09f5ff2a3beda.tar.gz rpm-2ba56c673bf1c168cccb827938c09f5ff2a3beda.tar.bz2 rpm-2ba56c673bf1c168cccb827938c09f5ff2a3beda.zip |
Move declarations of local variables for parsing functions
from global scope. Compilers aren't that stupid these days
-rw-r--r-- | build/parseDescription.c | 20 | ||||
-rw-r--r-- | build/parseFiles.c | 19 | ||||
-rw-r--r-- | build/parsePrep.c | 32 | ||||
-rw-r--r-- | build/parseScript.c | 26 |
4 files changed, 37 insertions, 60 deletions
diff --git a/build/parseDescription.c b/build/parseDescription.c index 66f6a0d2c..606687895 100644 --- a/build/parseDescription.c +++ b/build/parseDescription.c @@ -12,16 +12,6 @@ extern int noLang; -/* These have to be global scope to make up for *stupid* compilers */ - static const char *name = NULL; - static const char *lang = NULL; - - static struct poptOption optionsTable[] = { - { NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL}, - { NULL, 'l', POPT_ARG_STRING, &lang, 'l', NULL, NULL}, - { 0, 0, 0, 0, 0, NULL, NULL} - }; - int parseDescription(rpmSpec spec) { int nextPart = PART_ERROR; /* assume error */ @@ -31,11 +21,15 @@ int parseDescription(rpmSpec spec) int rc, argc; int arg; const char **argv = NULL; + const char *name = NULL; + const char *lang = RPMBUILD_DEFAULT_LANG; poptContext optCon = NULL; spectag t = NULL; - - name = NULL; - lang = RPMBUILD_DEFAULT_LANG; + struct poptOption optionsTable[] = { + { NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL}, + { NULL, 'l', POPT_ARG_STRING, &lang, 'l', NULL, NULL}, + { 0, 0, 0, 0, 0, NULL, NULL} + }; if ((rc = poptParseArgvString(spec->line, &argc, &argv))) { rpmlog(RPMLOG_ERR, _("line %d: Error parsing %%description: %s\n"), diff --git a/build/parseFiles.c b/build/parseFiles.c index b04366861..96e642936 100644 --- a/build/parseFiles.c +++ b/build/parseFiles.c @@ -10,15 +10,6 @@ #include <rpm/rpmfileutil.h> #include "debug.h" -/* These have to be global scope to make up for *stupid* compilers */ - static const char *name = NULL; - static const char *file = NULL; - static struct poptOption optionsTable[] = { - { NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL}, - { NULL, 'f', POPT_ARG_STRING, &file, 'f', NULL, NULL}, - { 0, 0, 0, 0, 0, NULL, NULL} - }; - int parseFiles(rpmSpec spec) { int nextPart, res = PART_ERROR; @@ -26,11 +17,15 @@ int parseFiles(rpmSpec spec) int rc, argc; int arg; const char ** argv = NULL; + const char *name = NULL; + const char *file = NULL; int flag = PART_SUBNAME; poptContext optCon = NULL; - - name = NULL; - file = NULL; + struct poptOption optionsTable[] = { + { NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL}, + { NULL, 'f', POPT_ARG_STRING, &file, 'f', NULL, NULL}, + { 0, 0, 0, 0, 0, NULL, NULL} + }; if ((rc = poptParseArgvString(spec->line, &argc, &argv))) { rpmlog(RPMLOG_ERR, _("line %d: Error parsing %%files: %s\n"), diff --git a/build/parsePrep.c b/build/parsePrep.c index 34906c8a6..fbb63db34 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -11,21 +11,6 @@ #include <rpm/rpmfileutil.h> #include "debug.h" -/* These have to be global to make up for stupid compilers */ - static int leaveDirs, skipDefaultAction; - static int createDir, quietly; -static const char * dirName = NULL; -static struct poptOption optionsTable[] = { - { NULL, 'a', POPT_ARG_STRING, NULL, 'a', NULL, NULL}, - { NULL, 'b', POPT_ARG_STRING, NULL, 'b', NULL, NULL}, - { NULL, 'c', 0, &createDir, 0, NULL, NULL}, - { NULL, 'D', 0, &leaveDirs, 0, NULL, NULL}, - { NULL, 'n', POPT_ARG_STRING, &dirName, 0, NULL, NULL}, - { NULL, 'T', 0, &skipDefaultAction, 0, NULL, NULL}, - { NULL, 'q', 0, &quietly, 0, NULL, NULL}, - { 0, 0, 0, 0, 0, NULL, NULL} - }; - /** * Check that file owner and group are known. * @param urlfn file url @@ -262,10 +247,19 @@ static int doSetupMacro(rpmSpec spec, const char *line) const char * optArg; int rc; uint32_t num; - - leaveDirs = skipDefaultAction = 0; - createDir = quietly = 0; - dirName = NULL; + int leaveDirs = 0, skipDefaultAction = 0; + int createDir = 0, quietly = 0; + const char * dirName = NULL; + struct poptOption optionsTable[] = { + { NULL, 'a', POPT_ARG_STRING, NULL, 'a', NULL, NULL}, + { NULL, 'b', POPT_ARG_STRING, NULL, 'b', NULL, NULL}, + { NULL, 'c', 0, &createDir, 0, NULL, NULL}, + { NULL, 'D', 0, &leaveDirs, 0, NULL, NULL}, + { NULL, 'n', POPT_ARG_STRING, &dirName, 0, NULL, NULL}, + { NULL, 'T', 0, &skipDefaultAction, 0, NULL, NULL}, + { NULL, 'q', 0, &quietly, 0, NULL, NULL}, + { 0, 0, 0, 0, 0, NULL, NULL} + }; if ((rc = poptParseArgvString(line, &argc, &argv))) { rpmlog(RPMLOG_ERR, _("Error parsing %%setup: %s\n"), diff --git a/build/parseScript.c b/build/parseScript.c index 713d998aa..1b530709a 100644 --- a/build/parseScript.c +++ b/build/parseScript.c @@ -48,17 +48,6 @@ static int addTriggerIndex(Package pkg, const char *file, return index; } -/* these have to be global because of stupid compilers */ - static const char *name = NULL; - static const char *prog = NULL; - static const char *file = NULL; - static struct poptOption optionsTable[] = { - { NULL, 'p', POPT_ARG_STRING, &prog, 'p', NULL, NULL}, - { NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL}, - { NULL, 'f', POPT_ARG_STRING, &file, 'f', NULL, NULL}, - { 0, 0, 0, 0, 0, NULL, NULL} - }; - /* %trigger is a strange combination of %pre and Requires: behavior */ /* We can handle it by parsing the args before "--" in parseScript. */ /* We then pass the remaining arguments to parseRCPOT, along with */ @@ -93,11 +82,16 @@ int parseScript(rpmSpec spec, int parsePart) int arg; const char **argv = NULL; poptContext optCon = NULL; - - name = NULL; - prog = "/bin/sh"; - file = NULL; - + const char *name = NULL; + const char *prog = "/bin/sh"; + const char *file = NULL; + struct poptOption optionsTable[] = { + { NULL, 'p', POPT_ARG_STRING, &prog, 'p', NULL, NULL}, + { NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL}, + { NULL, 'f', POPT_ARG_STRING, &file, 'f', NULL, NULL}, + { 0, 0, 0, 0, 0, NULL, NULL} + }; + switch (parsePart) { case PART_PRE: tag = RPMTAG_PREIN; |