Changeset 67210


Ignore:
Timestamp:
May 2, 2010, 8:45:12 PM (10 years ago)
Author:
raimue@…
Message:

Strip only one line break at the beginning and end of notes.
Allows use of empty lines as separators with notes-append.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portutil.tcl

    r67209 r67210  
    461461            foreach arg $args {
    462462                # Strip trailing empty lines
    463                 set txt [string trim $arg "\n"]
     463                if {[string index $arg 0] == "\n"} {
     464                    set arg [string range $arg 1 end]
     465                }
     466                if {[string index $arg end] == "\n"} {
     467                    set arg [string range $arg 0 end-1]
     468                }
    464469
    465470                # Determine indent level
    466471                set indent ""
    467                 for {set i 0} {$i < [string length $txt]} {incr i} {
    468                     set c [string index $txt $i]
     472                for {set i 0} {$i < [string length $arg]} {incr i} {
     473                    set c [string index $arg $i]
    469474                    if {$c != " " && $c != "\t"} {
    470475                        break
     
    473478                }
    474479                # Remove indent on first line
    475                 set txt [string replace $txt 0 [expr $i - 1]]
     480                set arg [string replace $arg 0 [expr $i - 1]]
    476481                # Remove indent on each other line
    477                 set txt [string map "\"\n$indent\" \"\n\"" $txt]
    478 
    479                 lappend fulllist $txt
     482                set arg [string map "\"\n$indent\" \"\n\"" $arg]
     483
     484                lappend fulllist $arg
    480485            }
    481486
Note: See TracChangeset for help on using the changeset viewer.