Actually catch errors from readLine()
authormarc <devnull@localhost>
Wed, 20 May 1998 17:05:26 +0000 (17:05 +0000)
committermarc <devnull@localhost>
Wed, 20 May 1998 17:05:26 +0000 (17:05 +0000)
CVS patchset: 2119
CVS date: 1998/05/20 17:05:26

12 files changed:
CHANGES
build/files.c
build/macro.c
build/pack.c
build/parseBuildInstallClean.c
build/parseChangelog.c
build/parseDescription.c
build/parseFiles.c
build/parsePreamble.c
build/parsePrep.c
build/parseScript.c
build/read.c

diff --git a/CHANGES b/CHANGES
index a57154d..bda5fd8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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
index 31333e0..dcc68d0 100644 (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);
index 5f6d667..a1a3508 100644 (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)
index 8f632c6..ed16dde 100644 (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);
index c5f9aff..18643e8 100644 (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;
index ecd066f..a126597 100644 (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);
index f1a2427..e1bd486 100644 (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;
+           }
        }
     }
     
index 3e67fb4..f7938c2 100644 (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;
+           }
        }
     }
 
index 2392886..ff979d2 100644 (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;
+           }
        }
     }
 
index 305e52d..0308fed 100644 (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');
index 0f19567..cf83a92 100644 (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);
index 0f2906c..c469e09 100644 (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);