File Annotation
Not logged in
52f2254007 2007-10-04       aku: ## -*- tcl -*-
52f2254007 2007-10-04       aku: # # ## ### ##### ######## ############# #####################
52f2254007 2007-10-04       aku: ## Copyright (c) 2007 Andreas Kupries.
52f2254007 2007-10-04       aku: #
52f2254007 2007-10-04       aku: # This software is licensed as described in the file LICENSE, which
52f2254007 2007-10-04       aku: # you should have received as part of this distribution.
52f2254007 2007-10-04       aku: #
52f2254007 2007-10-04       aku: # This software consists of voluntary contributions made by many
52f2254007 2007-10-04       aku: # individuals.  For exact contribution history, see the revision
52f2254007 2007-10-04       aku: # history and logs, available at http://fossil-scm.hwaci.com/fossil
52f2254007 2007-10-04       aku: # # ## ### ##### ######## ############# #####################
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku: ## Utilities for various things: text formatting, max, ...
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku: # # ## ### ##### ######## ############# #####################
52f2254007 2007-10-04       aku: ## Requirements
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku: package require Tcl 8.4 ; # Required runtime
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku: # # ## ### ##### ######## ############# #####################
52f2254007 2007-10-04       aku: ##
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku: namespace eval ::vc::tools::misc {
52f2254007 2007-10-04       aku:     # # ## ### ##### ######## #############
52f2254007 2007-10-04       aku:     ## Public API, Methods
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku:     # Choose singular vs plural forms of a word based on a number.
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku:     proc sp {n singular {plural {}}} {
52f2254007 2007-10-04       aku: 	if {$n == 1} {return $singular}
52f2254007 2007-10-04       aku: 	if {$plural eq ""} {set plural ${singular}s}
52f2254007 2007-10-04       aku: 	return $plural
52f2254007 2007-10-04       aku:     }
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku:     # As above, with the number automatically put in front of the
52f2254007 2007-10-04       aku:     # string.
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku:     proc nsp {n singular {plural {}}} {
52f2254007 2007-10-04       aku: 	return "$n [sp $n $singular $plural]"
52f2254007 2007-10-04       aku:     }
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku:     # Find maximum in a list.
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku:     proc max {list} {
52f2254007 2007-10-04       aku: 	set max -1
52f2254007 2007-10-04       aku: 	foreach e $list {
52f2254007 2007-10-04       aku: 	    if {$e < $max} continue
52f2254007 2007-10-04       aku: 	    set max $e
52f2254007 2007-10-04       aku: 	}
52f2254007 2007-10-04       aku: 	return $max
52f2254007 2007-10-04       aku:     }
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku:     # # ## ### ##### ######## #############
52f2254007 2007-10-04       aku: }
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku: namespace eval ::vc::tools::misc {
52f2254007 2007-10-04       aku:     namespace export sp nsp max
52f2254007 2007-10-04       aku: }
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku: # -----------------------------------------------------------------------------
52f2254007 2007-10-04       aku: # Ready
52f2254007 2007-10-04       aku: 
52f2254007 2007-10-04       aku: package provide vc::tools::misc 1.0
52f2254007 2007-10-04       aku: return