summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1999-07-19 18:39:48 +0000
committerjbj <devnull@localhost>1999-07-19 18:39:48 +0000
commitc4e615007f983bb065f86a58b15ba792eeba51d3 (patch)
tree3305dd5f85429e5c3a660283197026f8ce7557ec
parent673bd51d8bd8e3d2f24bdb4906af37975a8628a5 (diff)
downloadrpm-c4e615007f983bb065f86a58b15ba792eeba51d3.tar.gz
rpm-c4e615007f983bb065f86a58b15ba792eeba51d3.tar.bz2
rpm-c4e615007f983bb065f86a58b15ba792eeba51d3.zip
permit multiline macro expansions.
CVS patchset: 3180 CVS date: 1999/07/19 18:39:48
-rw-r--r--CHANGES1
-rw-r--r--build/parseSpec.c90
-rw-r--r--build/rpmspec.h12
-rw-r--r--build/spec.c4
-rw-r--r--po/rpm.pot38
5 files changed, 83 insertions, 62 deletions
diff --git a/CHANGES b/CHANGES
index e6fa25932..c485a7ee8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -8,6 +8,7 @@
- add python bindings to rpm-devel (linux only).
- make query (rpm -qvl) behave like (POSIX?) ls for older files (#4050).
- fix: %if parsing skipped 3 chars too many.
+ - permit multiline macro expansions.
3.0.1 -> 3.0.2
- eliminate armv4 entries from rpmrc (Andrew E. Mileski).
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 73e542614..72464d6bc 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -92,7 +92,7 @@ void handleComments(char *s)
static void forceIncludeFile(Spec spec, const char * fileName)
{
- struct OpenFileInfo * ofi;
+ OFI_t * ofi;
ofi = newOpenFileInfo();
ofi->fileName = strdup(fileName);
@@ -100,21 +100,61 @@ static void forceIncludeFile(Spec spec, const char * fileName)
spec->fileStack = ofi;
}
+static int copyNextLine(Spec spec, OFI_t *ofi, int strip)
+{
+ char *last;
+ char ch;
+
+ /* Expand next line from file into line buffer */
+ if (!(spec->nextline && *spec->nextline)) {
+ char *from, *to;
+ to = last = spec->nextline = spec->lbuf;
+ from = ofi->readPtr;
+ while ((ch = *from) && ch != '\n')
+ *to++ = *from++;
+ *to++ = '\0';
+ ofi->readPtr = from;
+
+ if (expandMacros(spec, spec->macros, spec->lbuf, sizeof(spec->lbuf))) {
+ rpmError(RPMERR_BADSPEC, _("line %d: %s"), spec->lineNum, spec->lbuf);
+ return RPMERR_BADSPEC;
+ }
+ }
+
+ /* Find next line in expanded line buffer */
+ spec->line = spec->nextline;
+ while ((ch = *spec->nextline) && ch != '\n') {
+ spec->nextline++;
+ if (!isspace(ch))
+ last = spec->nextline;
+ }
+ if (ch == '\n')
+ *spec->nextline++ = '\0';
+
+ if (strip & STRIP_COMMENTS)
+ handleComments(spec->line);
+
+ if (strip & STRIP_TRAILINGSPACE)
+ *last = '\0';
+
+ return 0;
+}
+
/* returns 0 - success */
/* 1 - EOF */
/* <0 - error */
int readLine(Spec spec, int strip)
{
- char *from, *to, *last, *s, *arch, *os;
+ char *s, *arch, *os;
int match;
- char ch;
struct ReadLevelEntry *rl;
- struct OpenFileInfo *ofi = spec->fileStack;
+ OFI_t *ofi = spec->fileStack;
+ int rc;
- /* Make sure the current file is open */
retry:
- if (!ofi->file) {
+ /* Make sure the current file is open */
+ if (ofi->file == NULL) {
if (!(ofi->file = fopen(ofi->fileName, "r"))) {
rpmError(RPMERR_BADSPEC, _("Unable to open: %s\n"),
ofi->fileName);
@@ -124,7 +164,7 @@ retry:
}
/* Make sure we have something in the read buffer */
- if (!ofi->readPtr || ! *(ofi->readPtr)) {
+ if (!(ofi->readPtr && *(ofi->readPtr))) {
if (!fgets(ofi->readBuf, BUFSIZ, ofi->file)) {
/* EOF */
if (spec->readStack->next) {
@@ -158,42 +198,18 @@ retry:
}
sl->sl_lines[sl->sl_nlines++] = strdup(ofi->readBuf);
}
- /*rpmMessage(RPMMESS_DEBUG, "LINE: %s", spec->readBuf);*/
- }
-
- /* Copy a single line to the line buffer */
- from = ofi->readPtr;
- to = last = spec->line;
- ch = ' ';
- while (*from && ch != '\n') {
- ch = *to++ = *from++;
- if (!isspace(ch)) {
- last = to;
- }
}
- *to = '\0';
- ofi->readPtr = from;
- if (strip & STRIP_COMMENTS) {
- handleComments(spec->line);
- }
-
- if (strip & STRIP_TRAILINGSPACE) {
- *last = '\0';
- }
-
- if (spec->readStack->reading) {
- if (expandMacros(spec, spec->macros, spec->line, sizeof(spec->line))) {
- rpmError(RPMERR_BADSPEC, _("line %d: %s"), spec->lineNum, spec->line);
- return RPMERR_BADSPEC;
- }
- }
-
rpmGetArchInfo(&arch, NULL);
rpmGetOsInfo(&os, NULL);
+ /* Copy next file line into the spec line buffer */
+ if ((rc = copyNextLine(spec, ofi, strip)) != 0)
+ return rc;
+
s = spec->line;
SKIPSPACE(s);
+
match = -1;
if (! strncmp("%ifarch", s, 7)) {
s += 7;
@@ -281,7 +297,7 @@ retry:
void closeSpec(Spec spec)
{
- struct OpenFileInfo *ofi;
+ OFI_t *ofi;
while (spec->fileStack) {
ofi = spec->fileStack;
diff --git a/build/rpmspec.h b/build/rpmspec.h
index fb7e4a811..208c3a897 100644
--- a/build/rpmspec.h
+++ b/build/rpmspec.h
@@ -37,19 +37,19 @@ struct Source {
/*@owned@*/ struct Source *next;
};
-struct ReadLevelEntry {
+typedef struct ReadLevelEntry {
int reading;
/*@dependent@*/ struct ReadLevelEntry *next;
-};
+} RLE_t;
-struct OpenFileInfo {
+typedef struct OpenFileInfo {
/*@only@*/ char *fileName;
/*@dependent@*/ FILE *file;
int lineNum;
char readBuf[BUFSIZ];
/*@dependent@*/ char *readPtr;
/*@owned@*/ struct OpenFileInfo *next;
-};
+} OFI_t;
struct spectag {
int t_tag;
@@ -80,7 +80,9 @@ struct SpecStruct {
struct spectags *st;
/*@owned@*/ struct OpenFileInfo *fileStack;
- char line[BUFSIZ];
+ char lbuf[BUFSIZ];
+ char *line;
+ char *nextline;
int lineNum;
/*@only@*/ struct ReadLevelEntry *readStack;
diff --git a/build/spec.c b/build/spec.c
index 76c803eb2..fa77546ea 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -404,7 +404,9 @@ Spec newSpec(void)
spec->st = newSt();
spec->fileStack = NULL;
- spec->line[0] = '\0';
+ spec->lbuf[0] = '\0';
+ spec->line = spec->lbuf;
+ spec->nextline = NULL;
spec->lineNum = 0;
spec->readStack = malloc(sizeof(struct ReadLevelEntry));
spec->readStack->next = NULL;
diff --git a/po/rpm.pot b/po/rpm.pot
index c348d397d..cbb3766aa 100644
--- a/po/rpm.pot
+++ b/po/rpm.pot
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-07-19 12:17-0400\n"
+"POT-Creation-Date: 1999-07-19 14:32-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1610,29 +1610,29 @@ msgstr ""
msgid "no description in %%changelog"
msgstr ""
-#: ../build/parseDescription.c:36
+#: ../build/parseDescription.c:35
msgid "line %d: Error parsing %%description: %s"
msgstr ""
-#: ../build/parseDescription.c:49 ../build/parseFiles.c:42
+#: ../build/parseDescription.c:48 ../build/parseFiles.c:42
#: ../build/parseScript.c:170
#, c-format
msgid "line %d: Bad option %s: %s"
msgstr ""
-#: ../build/parseDescription.c:63 ../build/parseFiles.c:56
+#: ../build/parseDescription.c:62 ../build/parseFiles.c:56
#: ../build/parseScript.c:184
#, c-format
msgid "line %d: Too many names: %s"
msgstr ""
-#: ../build/parseDescription.c:73 ../build/parseFiles.c:66
+#: ../build/parseDescription.c:72 ../build/parseFiles.c:66
#: ../build/parseScript.c:194
#, c-format
msgid "line %d: Package does not exist: %s"
msgstr ""
-#: ../build/parseDescription.c:85
+#: ../build/parseDescription.c:84
#, c-format
msgid "line %d: Second description"
msgstr ""
@@ -1863,47 +1863,47 @@ msgstr ""
#: ../build/parseSpec.c:119
#, c-format
-msgid "Unable to open: %s\n"
+msgid "line %d: %s"
msgstr ""
-#: ../build/parseSpec.c:131
-msgid "Unclosed %%if"
+#: ../build/parseSpec.c:159
+#, c-format
+msgid "Unable to open: %s\n"
msgstr ""
-#: ../build/parseSpec.c:187
-#, c-format
-msgid "line %d: %s"
+#: ../build/parseSpec.c:171
+msgid "Unclosed %%if"
msgstr ""
-#: ../build/parseSpec.c:214
+#: ../build/parseSpec.c:230
#, c-format
msgid "%s:%d: parseExpressionBoolean returns %d"
msgstr ""
#. Got an else with no %if !
-#: ../build/parseSpec.c:222
+#: ../build/parseSpec.c:238
msgid "%s:%d: Got a %%else with no if"
msgstr ""
#. Got an end with no %if !
-#: ../build/parseSpec.c:233
+#: ../build/parseSpec.c:249
msgid "%s:%d: Got a %%endif with no if"
msgstr ""
-#: ../build/parseSpec.c:247 ../build/parseSpec.c:256
+#: ../build/parseSpec.c:263 ../build/parseSpec.c:272
msgid "malformed %%include statement"
msgstr ""
-#: ../build/parseSpec.c:337
+#: ../build/parseSpec.c:353
#, c-format
msgid "Timecheck value must be an integer: %s"
msgstr ""
-#: ../build/parseSpec.c:420
+#: ../build/parseSpec.c:436
msgid "No buildable architectures"
msgstr ""
-#: ../build/parseSpec.c:465
+#: ../build/parseSpec.c:481
msgid "Package has no %%description: %s"
msgstr ""