summaryrefslogtreecommitdiff
path: root/build/parseSpec.c
diff options
context:
space:
mode:
authorniemeyer <devnull@localhost>2004-04-08 20:27:53 +0000
committerniemeyer <devnull@localhost>2004-04-08 20:27:53 +0000
commit70905ee4c6f5e0e7ce3a0c9c5cd297fbe99d0483 (patch)
tree407f8591d3d5b64af33d5701d173260002a951a6 /build/parseSpec.c
parent66f860d94fa9b33f4abfcc41ea2267bd2660c613 (diff)
downloadlibrpm-tizen-70905ee4c6f5e0e7ce3a0c9c5cd297fbe99d0483.tar.gz
librpm-tizen-70905ee4c6f5e0e7ce3a0c9c5cd297fbe99d0483.tar.bz2
librpm-tizen-70905ee4c6f5e0e7ce3a0c9c5cd297fbe99d0483.zip
Implemented multiline macro support.
CVS patchset: 7231 CVS date: 2004/04/08 20:27:53
Diffstat (limited to 'build/parseSpec.c')
-rw-r--r--build/parseSpec.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/build/parseSpec.c b/build/parseSpec.c
index a7e4d5037..3ec24731e 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -145,15 +145,50 @@ static int copyNextLine(Spec spec, OFI_t *ofi, int strip)
}
/* Expand next line from file into line buffer */
if (!(spec->nextline && *spec->nextline)) {
- char *from, *to;
- to = last = spec->lbuf;
+ int pc = 0, bc = 0, nc = 0;
+ char *from, *to, *p;
+ to = spec->lbufPtr ? spec->lbufPtr : spec->lbuf;
from = ofi->readPtr;
ch = ' ';
while (*from && ch != '\n')
ch = *to++ = *from++;
+ spec->lbufPtr = to;
*to++ = '\0';
ofi->readPtr = from;
+ /* Check if we need another line before expanding the buffer. */
+ for (p = spec->lbuf; *p; p++) {
+ switch (*p) {
+ case '\\':
+ switch (*(p+1)) {
+ case '\n': p++, nc = 1; break;
+ case '\0': break;
+ default: p++; break;
+ }
+ break;
+ case '\n': nc = 0; break;
+ case '%':
+ switch (*(p+1)) {
+ case '{': p++, bc++; break;
+ case '(': p++, pc++; break;
+ case '%': p++; break;
+ }
+ break;
+ case '{': if (bc > 0) bc++; break;
+ case '}': if (bc > 0) bc--; break;
+ case '(': if (pc > 0) pc++; break;
+ case ')': if (pc > 0) pc--; break;
+ }
+ }
+
+ /* If it doesn't, ask for one more line. We need a better
+ * error code for this. */
+ if (pc || bc || nc ) {
+ spec->nextline = "";
+ return RPMERR_UNMATCHEDIF;
+ }
+ spec->lbufPtr = spec->lbuf;
+
/* Don't expand macros (eg. %define) in false branch of %if clause */
if (spec->readStack->reading &&
expandMacros(spec, spec->macros, spec->lbuf, sizeof(spec->lbuf))) {
@@ -265,8 +300,11 @@ retry:
#endif
/* Copy next file line into the spec line buffer */
- if ((rc = copyNextLine(spec, ofi, strip)) != 0)
+ if ((rc = copyNextLine(spec, ofi, strip)) != 0) {
+ if (rc == RPMERR_UNMATCHEDIF)
+ goto retry;
return rc;
+ }
s = spec->line;
SKIPSPACE(s);