strip trailing whitespace off %part args
authorroot <devnull@localhost>
Fri, 16 Feb 1996 05:55:17 +0000 (05:55 +0000)
committerroot <devnull@localhost>
Fri, 16 Feb 1996 05:55:17 +0000 (05:55 +0000)
add handling for specfiles that start with "%package subname"

CVS patchset: 297
CVS date: 1996/02/16 05:55:17

build/spec.c

index 23bd91e..3b119ee 100644 (file)
@@ -629,19 +629,35 @@ Spec parseSpec(FILE *f, char *specfile)
                } else {
                    lookupopts = LP_SUBNAME;
                }
-           }
-           if (tag == PREAMBLE_PART) {
-               lookupopts |= LP_CREATE | LP_FAIL_EXISTS;
+               /* Handle trailing whitespace */
+               s1 = s + strlen(s) - 1;
+               while (*s1 == ' ' || *s1 == '\n' || *s1 == '\t') {
+                  s1--;
+               }
+               s1++;
+               *s1 = '\0';
            }
 
-           /* XXX - should be able to drop the -n in non-%package parts */
-           if (! lookup_package(spec, &cur_package, s, lookupopts)) {
-               error(RPMERR_INTERNAL, "Package lookup failed!");
-               return NULL;
+           switch (tag) {
+             case PREP_PART:
+             case BUILD_PART:
+             case INSTALL_PART:
+             case CLEAN_PART:
+             case CHANGELOG_PART:
+               /* Do not switch parts for these */
+               break;
+             case PREAMBLE_PART:
+               lookupopts |= LP_CREATE | LP_FAIL_EXISTS;
+               /* Fall through */
+             default:
+               /* XXX - should be able to drop the -n in non-%package parts */
+               if (! lookup_package(spec, &cur_package, s, lookupopts)) {
+                   error(RPMERR_INTERNAL, "Package lookup failed: %s", s);
+                   return NULL;
+               }
+               message(MESS_DEBUG, "Switched to package: %s\n", s);
            }
 
-           message(MESS_DEBUG, "Switched to package: %s\n", s);
-
            if (cur_part == FILES_PART) {
                /* set files to 0 (current -1 means no %files, no package */
                cur_package->files = 0;
@@ -650,7 +666,8 @@ Spec parseSpec(FILE *f, char *specfile)
            continue;
         }
 
-       /* Check for implicit "base" package */
+       /* Check for implicit "base" package.                        */
+        /* That means that the specfile does not start with %package */
        if (! cur_package) {
            lookupopts = 0;
            if (cur_part == PREAMBLE_PART) {