mirror of
https://github.com/boostorg/build.git
synced 2026-02-15 13:02:11 +00:00
38 lines
1.1 KiB
Plaintext
38 lines
1.1 KiB
Plaintext
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
|
# distribute this software is granted provided this copyright notice appears in
|
|
# all copies. This software is provided "as is" without express or implied
|
|
# warranty, and with no claim as to its suitability for any purpose.
|
|
|
|
rule chars ( string )
|
|
{
|
|
local result ;
|
|
while $(string)
|
|
{
|
|
local s = [ SUBST $(string) (.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.*)
|
|
$9 $1 $2 $3 $4 $5 $6 $7 $8 ] ;
|
|
string = $(s[1]) ;
|
|
result += $(s[2-]) ;
|
|
}
|
|
|
|
# trim off empty strings
|
|
while $(result[1]) && ! $(result[-2])
|
|
{
|
|
result = $(result[1--2]) ;
|
|
}
|
|
|
|
return $(result) ;
|
|
}
|
|
|
|
rule __test__ ( )
|
|
{
|
|
import assert ;
|
|
assert.result a b c : chars abc ;
|
|
|
|
# check boundary cases
|
|
assert.result a : chars a ;
|
|
assert.result : chars "" ;
|
|
assert.result a b c d e f g h : chars abcdefgh ;
|
|
assert.result a b c d e f g h i : chars abcdefghi ;
|
|
assert.result a b c d e f g h i j : chars abcdefghij ;
|
|
assert.result a b c d e f g h i j k : chars abcdefghijk ;
|
|
} |