~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to visualization/nviz/scripts/unique.tcl

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Proc UNIQUE 
3
 
#
4
 
#   Usage:  unique NAME
5
 
#
6
 
#    returns a name which is guaranteed to be unique (when compared to other
7
 
#     names unique returns) with $name as its prefix. Basically
8
 
#     it appends 1-N to the end of the string.  This is good up to
9
 
#     the max int value at which point it will wrap around and potentially
10
 
#     fail.
11
 
#
12
 
#
13
 
#  EXTENSIONS:
14
 
#
15
 
#     None
16
 
#
17
 
#
18
 
#  RETURNS:
19
 
#     Normal return value
20
 
#     Result is a unique string
21
 
#
22
 
#
23
 
#  GLOBALS:
24
 
#     unique_a()
25
 
#     
26
 
#  PROCS:
27
 
#     unique
28
 
#     
29
 
 
30
 
 
31
 
 
32
 
set unique_a(start) 1
33
 
 
34
 
proc unique {name} {
35
 
    global unique_a
36
 
 
37
 
    switch [catch {set num [set unique_a($name)]}] {
38
 
        0 {                     ; # Found a match
39
 
            incr num
40
 
            set unique_a($name) $num
41
 
            return $name$num
42
 
          }
43
 
        1 {                     ; # no match  new name
44
 
            set num 1
45
 
            set unique_a($name) $num
46
 
            return $name$num
47
 
          }
48
 
    }
49
 
 
50
 
    return -code error "unknown error in unique"
51
 
}
52
 
 
53
 
 
54
 
 
55
 
 
56
 
 
57
 
 
58
 
 
59