[63628] trunk/base/src/port1.0/portutil.tcl

raimue at macports.org raimue at macports.org
Wed Feb 10 12:38:14 PST 2010


Revision: 63628
          http://trac.macports.org/changeset/63628
Author:   raimue at macports.org
Date:     2010-02-10 12:38:12 -0800 (Wed, 10 Feb 2010)
Log Message:
-----------
Remove indentation from notes

With this, notes can have any indentation level in the Portfile. For example,
the following notes will be printed the same:

notes {
Foo
Bar
}

notes {
    Foo
    Bar
}

Modified Paths:
--------------
    trunk/base/src/port1.0/portutil.tcl

Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	2010-02-10 17:55:16 UTC (rev 63627)
+++ trunk/base/src/port1.0/portutil.tcl	2010-02-10 20:38:12 UTC (rev 63628)
@@ -449,7 +449,23 @@
 proc notes {args} {
     global PortInfo portnotes
 
-    set PortInfo(notes) [string trim [join $args]]
+    # Strip trailing empty lines
+    set notes [string trim [join $args] "\n"]
+    # Determine indent level
+    set indent ""
+    for {set i 0} {$i < [string length $notes]} {incr i} {
+        set c [string index $notes $i]
+        if {$c != " " && $c != "\t"} {
+            break
+        }
+        append indent $c
+    }
+    # Remove indent on first line
+    set notes [string replace $notes 0 [expr $i - 1]]
+    # Remove indent on each other line
+    set notes [string map "\"\n$indent\" \"\n\"" $notes]
+
+    set PortInfo(notes) $notes
     set portnotes $PortInfo(notes)
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100210/df0b38b6/attachment-0001.html>


More information about the macports-changes mailing list