fix extra %endif catching
authorroot <devnull@localhost>
Wed, 21 Feb 1996 15:29:20 +0000 (15:29 +0000)
committerroot <devnull@localhost>
Wed, 21 Feb 1996 15:29:20 +0000 (15:29 +0000)
better errors

CVS patchset: 376
CVS date: 1996/02/21 15:29:20

build/spec.c

index 8f59250..7b45b99 100644 (file)
@@ -366,6 +366,7 @@ static int read_line(FILE *f, char *line)
        if (! fgets(line, LINE_BUF_SIZE, f)) {
            /* the end */
            if (read_level->next) {
+               error(RPMERR_UNMATCHEDIF, "Unclosed %%if");
                return RPMERR_UNMATCHEDIF;
            } else {
                return 0;
@@ -386,12 +387,14 @@ static int read_line(FILE *f, char *line)
        } else if (! strncmp("%else", line, 5)) {
            if (! read_level->next) {
                /* Got an else with no %if ! */
+               error(RPMERR_UNMATCHEDIF, "Got a %%else with no if");
                return RPMERR_UNMATCHEDIF;
            }
            read_level->reading =
                read_level->next->reading && ! read_level->reading;
        } else if (! strncmp("%endif", line, 6)) {
-           if (! read_level) {
+           if (! read_level->next) {
+               error(RPMERR_UNMATCHEDIF, "Got a %%endif with no if");
                return RPMERR_UNMATCHEDIF;
            }
            rl = read_level;
@@ -787,7 +790,6 @@ Spec parseSpec(FILE *f, char *specfile)
        } /* switch */
     }
     if (x < 0) {
-       error(RPMERR_READERROR, "Error reading specfile");
        return NULL;
     }