Actually catch errors from readLine()

CVS patchset: 2119
CVS date: 1998/05/20 17:05:26
This commit is contained in:
marc 1998-05-20 17:05:26 +00:00
parent c1b802dfda
commit f0d4eed0db
12 changed files with 78 additions and 23 deletions

View File

@ -1,5 +1,6 @@
2.5 -> 2.5.1:
- fail if sources are not regular files
- wasn't catching readLine() errors
2.4.109 -> 2.5:
- fixed return code bug in build code

View File

@ -323,7 +323,10 @@ static int processPackageFiles(Spec spec, Package pkg, int installSpecialDoc)
}
while (fgets(buf, sizeof(buf), f)) {
handleComments(buf);
expandMacros(&spec->macros, buf);
if (expandMacros(&spec->macros, buf)) {
rpmError(RPMERR_BADSPEC, "line: %s", buf);
return RPMERR_BADSPEC;
}
appendStringBuf(pkg->fileList, buf);
}
fclose(f);

View File

@ -186,7 +186,9 @@ static int handleDefine(struct MacroContext *mc, char *buf)
}
}
expandMacros(mc, expansion);
if (expandMacros(mc, expansion)) {
return 1;
}
addMacro(mc, name, expansion);
return 0;
@ -204,7 +206,6 @@ void initMacros(struct MacroContext *mc)
mc->firstFree = 0;
mc->macroTable = NULL;
expandMacroTable(mc);
}
void freeMacros(struct MacroContext *mc)

View File

@ -354,7 +354,10 @@ static StringBuf addFileToTagAux(Spec spec, char *file, StringBuf sb)
return NULL;
}
while (fgets(buf, sizeof(buf), f)) {
expandMacros(&spec->macros, buf);
if (expandMacros(&spec->macros, buf)) {
rpmError(RPMERR_BADSPEC, "line: %s", buf);
return NULL;
}
appendStringBuf(sb, buf);
}
fclose(f);

View File

@ -4,7 +4,7 @@
int parseBuildInstallClean(Spec spec, int parsePart)
{
int nextPart;
int nextPart, rc;
StringBuf *sbp = NULL;
char *name = NULL;
@ -31,15 +31,21 @@ int parseBuildInstallClean(Spec spec, int parsePart)
*sbp = newStringBuf();
/* There are no options to %build, %install, or %clean */
if (readLine(spec, STRIP_NOTHING) > 0) {
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
return PART_NONE;
}
if (rc) {
return rc;
}
while (! (nextPart = isPart(spec->line))) {
appendStringBuf(*sbp, spec->line);
if (readLine(spec, STRIP_NOTHING) > 0) {
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
return PART_NONE;
}
if (rc) {
return rc;
}
}
return nextPart;

View File

@ -23,23 +23,29 @@ static int dateToTimet(const char * datestr, time_t * secs);
int parseChangelog(Spec spec)
{
int nextPart, res;
int nextPart, res, rc;
StringBuf sb;
sb = newStringBuf();
/* There are no options to %changelog */
if (readLine(spec, STRIP_COMMENTS) > 0) {
if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
freeStringBuf(sb);
return PART_NONE;
}
if (rc) {
return rc;
}
while (! (nextPart = isPart(spec->line))) {
appendStringBuf(sb, spec->line);
if (readLine(spec, STRIP_COMMENTS) > 0) {
if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
nextPart = PART_NONE;
break;
}
if (rc) {
return rc;
}
}
res = addChangelog(spec->packages->header, sb);

View File

@ -92,15 +92,22 @@ int parseDescription(Spec spec)
sb = newStringBuf();
if (readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS) > 0) {
if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) {
nextPart = PART_NONE;
} else {
if (rc) {
return rc;
}
while (! (nextPart = isPart(spec->line))) {
appendLineStringBuf(sb, spec->line);
if (readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS) > 0) {
if ((rc =
readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) {
nextPart = PART_NONE;
break;
}
if (rc) {
return rc;
}
}
}

View File

@ -89,15 +89,21 @@ int parseFiles(Spec spec)
}
pkg->fileList = newStringBuf();
if (readLine(spec, STRIP_COMMENTS) > 0) {
if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
nextPart = PART_NONE;
} else {
if (rc) {
return rc;
}
while (! (nextPart = isPart(spec->line))) {
appendStringBuf(pkg->fileList, spec->line);
if (readLine(spec, STRIP_COMMENTS) > 0) {
if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
nextPart = PART_NONE;
break;
}
if (rc) {
return rc;
}
}
}

View File

@ -56,7 +56,7 @@ static int readIcon(Header h, char *file);
int parsePreamble(Spec spec, int initialPackage)
{
int nextPart;
int tag;
int tag, rc;
char *name, *mainName, *linep, *macro;
int flag;
Package pkg;
@ -91,9 +91,12 @@ int parsePreamble(Spec spec, int initialPackage)
headerAddEntry(pkg->header, RPMTAG_NAME, RPM_STRING_TYPE, fullName, 1);
}
if (readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS) > 0) {
if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) {
nextPart = PART_NONE;
} else {
if (rc) {
return rc;
}
while (! (nextPart = isPart(spec->line))) {
/* Skip blank lines */
linep = spec->line;
@ -111,10 +114,14 @@ int parsePreamble(Spec spec, int initialPackage)
return PART_BUILDARCHITECTURES;
}
}
if (readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS) > 0) {
if ((rc =
readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) {
nextPart = PART_NONE;
break;
}
if (rc) {
return rc;
}
}
}

View File

@ -44,7 +44,7 @@ static char *doUntar(Spec spec, int c, int quietly);
int parsePrep(Spec spec)
{
int nextPart, res;
int nextPart, res, rc;
StringBuf buf;
char **lines, **saveLines;
@ -56,9 +56,12 @@ int parsePrep(Spec spec)
spec->prep = newStringBuf();
/* There are no options to %prep */
if (readLine(spec, STRIP_NOTHING) > 0) {
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
return PART_NONE;
}
if (rc) {
return rc;
}
buf = newStringBuf();
@ -66,10 +69,13 @@ int parsePrep(Spec spec)
/* Need to expand the macros inline. That way we */
/* can give good line number information on error. */
appendStringBuf(buf, spec->line);
if (readLine(spec, STRIP_NOTHING) > 0) {
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
nextPart = PART_NONE;
break;
}
if (rc) {
return rc;
}
}
lines = splitString(getStringBuf(buf), strlen(getStringBuf(buf)), '\n');

View File

@ -192,15 +192,21 @@ int parseScript(Spec spec, int parsePart)
}
sb = newStringBuf();
if (readLine(spec, STRIP_NOTHING) > 0) {
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
nextPart = PART_NONE;
} else {
if (rc) {
return rc;
}
while (! (nextPart = isPart(spec->line))) {
appendStringBuf(sb, spec->line);
if (readLine(spec, STRIP_NOTHING) > 0) {
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
nextPart = PART_NONE;
break;
}
if (rc) {
return rc;
}
}
}
stripTrailingBlanksStringBuf(sb);

View File

@ -76,7 +76,10 @@ int readLine(Spec spec, int strip)
}
if (spec->readStack->reading) {
expandMacros(&spec->macros, spec->line);
if (expandMacros(&spec->macros, spec->line)) {
rpmError(RPMERR_BADSPEC, "line %d: %s", spec->lineNum, spec->line);
return RPMERR_BADSPEC;
}
}
rpmGetArchInfo(&arch, NULL);