~ubuntu-branches/ubuntu/raring/boost-build/raring

« back to all changes in this revision

Viewing changes to util/string.jam

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-08-06 00:38:31 UTC
  • mfrom: (4.1.1 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080806003831-zr65893244swds0b
Tags: 2.0-m12-2
* debian/rules: Do not install /etc/user-config.jam.
* debian/site-config.jam: New.  Install into /etc instead of empty
  example.  Closes: #493323.

* debian/control: Update homepage.  Update description.  Closes:
  #493510.  Update Standards-Version to 3.8.0; no changes.

* debian/compat: New.  Set compat level to 7.
* debian/rules: Remove DH_COMPAT setting.
* debian/control: Change debhelper build-dep to version >= 7.

* debian/control: Remove docbook-to-man, bison from build-deps.

* debian/rules: Clean up upstream source by removing debian/conffiles.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (C) Copyright David Abrahams, 2002.
2
 
# (C) Copyright Rene Rivera, 2003.
3
 
#
4
 
# See accompanying license for terms and conditions of use.
5
 
#
 
1
# Copyright 2002 Dave Abrahams 
 
2
# Copyright 2002, 2003 Rene Rivera 
 
3
# Distributed under the Boost Software License, Version 1.0. 
 
4
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 
6
5
 
7
6
import regex ;
8
7
 
51
50
    return $(result) ;
52
51
}
53
52
 
 
53
# Apply a set of standard transformations to string to produce an
 
54
# abbreviation no more than 5 characters long
 
55
#
 
56
rule abbreviate ( string )
 
57
{
 
58
    local r = $(.abbreviated-$(string)) ;
 
59
    if $(r)
 
60
    {
 
61
        return $(r) ;
 
62
    }
 
63
    # Anything less than 4 characters gets no abbreviation
 
64
    else if ! [ MATCH (....) : $(string) ]
 
65
    {
 
66
        $(.abbreviated-$(string)) = $(string) ;
 
67
        return $(string) ;
 
68
    }
 
69
    else
 
70
    {
 
71
        # Separate the initial letter in case it's a vowel
 
72
        local s1 = [ MATCH ^(.)(.*) : $(string) ] ;
 
73
        
 
74
        # drop trailing "ing"
 
75
        local s2 = [ MATCH ^(.*)ing$ : $(s1[2]) ] ;
 
76
        s2 ?= $(s1[2]) ;
 
77
        
 
78
        # Reduce all doubled characters to one
 
79
        local last = "" ;
 
80
        for local c in [ chars $(s2) ]
 
81
        {
 
82
            if $(c) != $(last)
 
83
            {
 
84
                r += $(c) ;
 
85
                last = $(c) ;
 
86
            }
 
87
        }
 
88
        s2 = $(r:J="") ;
 
89
        
 
90
        # Chop all vowels out of the remainder
 
91
        s2 = [ regex.replace $(s2) [AEIOUaeiou] "" ] ;
 
92
 
 
93
        # Shorten remaining consonants to 4 characters
 
94
        s2 = [ MATCH ^(.?.?.?.?) : $(s2) ] ;
 
95
        
 
96
        # Glue the initial character back on to the front
 
97
        s2 = $(s1[1])$(s2) ;
 
98
        
 
99
        $(.abbreviated-$(string)) = $(s2) ;
 
100
        return $(s2) ;
 
101
    }
 
102
}
 
103
 
54
104
# Concatenates the given strings, inserting the given separator
55
105
# between each string.
56
106
#
102
152
    import assert ;
103
153
    assert.result a b c : chars abc ;
104
154
    
 
155
    assert.result rntm : abbreviate runtime ;
 
156
    assert.result ovrld : abbreviate overload ;
 
157
    assert.result dbg : abbreviate debugging ;
 
158
    assert.result async : abbreviate asynchronous ;
 
159
    assert.result pop : abbreviate pop ;
 
160
    assert.result aaa : abbreviate aaa ;
 
161
    assert.result qck : abbreviate quack ;
 
162
    assert.result sttc : abbreviate static ;
 
163
    
105
164
    # check boundary cases
106
165
    assert.result a : chars a ;
107
166
    assert.result : chars "" ;