Do not remove comments in scripts
authormarc <devnull@localhost>
Fri, 1 May 1998 01:54:27 +0000 (01:54 +0000)
committermarc <devnull@localhost>
Fri, 1 May 1998 01:54:27 +0000 (01:54 +0000)
CVS patchset: 2101
CVS date: 1998/05/01 01:54:27

CHANGES
build/files.c
build/macro.c
build/parseChangelog.c
build/parseDescription.c
build/parseFiles.c
build/parsePreamble.c
build/read.c
build/read.h

diff --git a/CHANGES b/CHANGES
index 3891a38..99613c5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -8,6 +8,7 @@
        - freePrefixes wasn't initialized in runScript()
        - fix typo in %triggerpostun generation
        - include icons in source packages
+       - do not remove comments in scripts
 
 2.4.108 -> 2.4.109:
         - remove icons with --rmsource
index 4b19f3a..f14611c 100644 (file)
@@ -321,6 +321,7 @@ static int processPackageFiles(Spec spec, Package pkg, int installSpecialDoc)
            return RPMERR_BADFILENAME;
        }
        while (fgets(buf, sizeof(buf), f)) {
+           handleComments(buf);
            expandMacros(&spec->macros, buf);
            appendStringBuf(pkg->fileList, buf);
        }
index eb02b61..5f6d667 100644 (file)
@@ -45,16 +45,6 @@ int expandMacros(struct MacroContext *mc, char *buf)
        return 0;
     }
 
-    /* Check if commented out */
-    first = buf;
-    while (*first && isspace(*first)) {
-       first++;
-    }
-    if (*first == '#') {
-       buf[0] = '\0';
-       return 0;
-    }
-    
     copyFrom = buf;
     copyTo = bufA;
 
index 7433790..ecd066f 100644 (file)
@@ -29,14 +29,14 @@ int parseChangelog(Spec spec)
     sb = newStringBuf();
     
     /* There are no options to %changelog */
-    if (readLine(spec, STRIP_NOTHING) > 0) {
+    if (readLine(spec, STRIP_COMMENTS) > 0) {
        freeStringBuf(sb);
        return PART_NONE;
     }
     
     while (! (nextPart = isPart(spec->line))) {
        appendStringBuf(sb, spec->line);
-       if (readLine(spec, STRIP_NOTHING) > 0) {
+       if (readLine(spec, STRIP_COMMENTS) > 0) {
            nextPart = PART_NONE;
            break;
        }
index 4743a8c..f1a2427 100644 (file)
@@ -92,12 +92,12 @@ int parseDescription(Spec spec)
     
     sb = newStringBuf();
 
-    if (readLine(spec, STRIP_TRAILINGSPACE) > 0) {
+    if (readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS) > 0) {
        nextPart = PART_NONE;
     } else {
        while (! (nextPart = isPart(spec->line))) {
            appendLineStringBuf(sb, spec->line);
-           if (readLine(spec, STRIP_TRAILINGSPACE) > 0) {
+           if (readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS) > 0) {
                nextPart = PART_NONE;
                break;
            }
index 6b41b91..3e67fb4 100644 (file)
@@ -89,12 +89,12 @@ int parseFiles(Spec spec)
     }
     pkg->fileList = newStringBuf();
     
-    if (readLine(spec, STRIP_NOTHING) > 0) {
+    if (readLine(spec, STRIP_COMMENTS) > 0) {
        nextPart = PART_NONE;
     } else {
        while (! (nextPart = isPart(spec->line))) {
            appendStringBuf(pkg->fileList, spec->line);
-           if (readLine(spec, STRIP_NOTHING) > 0) {
+           if (readLine(spec, STRIP_COMMENTS) > 0) {
                nextPart = PART_NONE;
                break;
            }
index 6b8b03a..2392886 100644 (file)
@@ -91,7 +91,7 @@ int parsePreamble(Spec spec, int initialPackage)
        headerAddEntry(pkg->header, RPMTAG_NAME, RPM_STRING_TYPE, fullName, 1);
     }
 
-    if (readLine(spec, STRIP_TRAILINGSPACE) > 0) {
+    if (readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS) > 0) {
        nextPart = PART_NONE;
     } else {
        while (! (nextPart = isPart(spec->line))) {
@@ -111,7 +111,7 @@ int parsePreamble(Spec spec, int initialPackage)
                    return PART_BUILDARCHITECTURES;
                }
            }
-           if (readLine(spec, STRIP_TRAILINGSPACE) > 0) {
+           if (readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS) > 0) {
                nextPart = PART_NONE;
                break;
            }
index 66e18f0..8c9c62e 100644 (file)
@@ -7,6 +7,7 @@
 #include "messages.h"
 #include "macro.h"
 #include "misc.h"
+#include "read.h"
 
 static int matchTok(char *token, char *line);
 
@@ -14,9 +15,17 @@ static int matchTok(char *token, char *line);
 /*         1 - EOF     */
 /*        <0 - error   */
 
+void handleComments(char *s)
+{
+    SKIPSPACE(s);
+    if (*s == '#') {
+       *s = '\0';
+    }
+}
+
 int readLine(Spec spec, int strip)
 {
-    char *from, *to, *last, *s, *arch, *os;
+    char *from, *to, *first, *last, *s, *arch, *os;
     int match;
     char ch;
     struct ReadLevelEntry *rl;
@@ -58,7 +67,11 @@ int readLine(Spec spec, int strip)
     *to = '\0';
     spec->readPtr = from;
     
-    if (strip) {
+    if (strip & STRIP_COMMENTS) {
+       handleComments(spec->line);
+    }
+    
+    if (strip & STRIP_TRAILINGSPACE) {
        *last = '\0';
     }
 
index 041125d..238cdd5 100644 (file)
@@ -3,8 +3,9 @@
 
 #include "spec.h"
 
-#define STRIP_NOTHING       0
-#define STRIP_TRAILINGSPACE 1
+#define STRIP_NOTHING             0
+#define STRIP_TRAILINGSPACE (1 << 0)
+#define STRIP_COMMENTS      (1 << 1)
 
 /* returns 0 - success */
 /*         1 - EOF     */
@@ -12,5 +13,6 @@
 
 int readLine(Spec spec, int strip);
 void closeSpec(Spec spec);
+void handleComments(char *s);
 
 #endif