diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-05-11 11:04:42 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-05-11 11:08:31 +0300 |
commit | b3f5959a473a1590b323f134e205b3f661147703 (patch) | |
tree | 380804f84e35b38142659d7a3ef8c1fc1c74c86e /build/parseSpec.c | |
parent | db782b4b62ea6edd3510f60a5875f2c884b08575 (diff) | |
download | librpm-tizen-b3f5959a473a1590b323f134e205b3f661147703.tar.gz librpm-tizen-b3f5959a473a1590b323f134e205b3f661147703.tar.bz2 librpm-tizen-b3f5959a473a1590b323f134e205b3f661147703.zip |
Simplify / sanitize pushing new files on spec file stack
- Replace the rather useless newOpenFileInfo() "constructor" with
a function to push a new filename on spec stack, creating the
OFI struct as we go. forceIncludeFile() becomes so simple its
no longer necessary at all.
Diffstat (limited to 'build/parseSpec.c')
-rw-r--r-- | build/parseSpec.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/build/parseSpec.c b/build/parseSpec.c index dbaaae362..93dbfe05e 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -109,31 +109,20 @@ void handleComments(char *s) *s = '\0'; } -static struct OpenFileInfo * newOpenFileInfo(void) +/* Push a file to spec's file stack, return the newly pushed entry */ +static OFI_t * pushOFI(rpmSpec spec, const char *fn) { - struct OpenFileInfo *ofi; + OFI_t *ofi = xcalloc(1, sizeof(*ofi)); - ofi = xmalloc(sizeof(*ofi)); ofi->fp = NULL; - ofi->fileName = NULL; + ofi->fileName = xstrdup(fn); ofi->lineNum = 0; ofi->readBuf[0] = '\0'; ofi->readPtr = NULL; - ofi->next = NULL; - - return ofi; -} - -/** - */ -static void forceIncludeFile(rpmSpec spec, const char * fileName) -{ - OFI_t * ofi; - - ofi = newOpenFileInfo(); - ofi->fileName = xstrdup(fileName); ofi->next = spec->fileStack; + spec->fileStack = ofi; + return spec->fileStack; } static int restoreFirstChar(rpmSpec spec) @@ -394,9 +383,7 @@ int readLine(rpmSpec spec, int strip) } *endFileName = '\0'; - forceIncludeFile(spec, fileName); - - ofi = spec->fileStack; + ofi = pushOFI(spec, fileName); goto retry; } @@ -569,8 +556,7 @@ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags, spec = newSpec(); spec->specFile = rpmGetPath(specFile, NULL); - spec->fileStack = newOpenFileInfo(); - spec->fileStack->fileName = xstrdup(spec->specFile); + pushOFI(spec, spec->specFile); /* If buildRoot not specified, use default %{buildroot} */ if (buildRoot) { spec->buildRoot = xstrdup(buildRoot); |