permit multiline macro expansions.

CVS patchset: 3180
CVS date: 1999/07/19 18:39:48
This commit is contained in:
jbj 1999-07-19 18:39:48 +00:00
parent 673bd51d8b
commit c4e615007f
5 changed files with 86 additions and 65 deletions

View File

@ -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).

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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"
msgstr ""
#: ../build/parseSpec.c:131
msgid "Unclosed %%if"
msgstr ""
#: ../build/parseSpec.c:187
#, c-format
msgid "line %d: %s"
msgstr ""
#: ../build/parseSpec.c:214
#: ../build/parseSpec.c:159
#, c-format
msgid "Unable to open: %s\n"
msgstr ""
#: ../build/parseSpec.c:171
msgid "Unclosed %%if"
msgstr ""
#: ../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 ""