summaryrefslogtreecommitdiffstats
path: root/tools/spencer2testregexp.tcl
blob: 9e892ad3ad67e60047d61ce4b69b09cd774f184c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# spencer2testregexp.tcl --
#
# This file generates a test suite for the testregexp command based on
# Henry Spencer's test suite.  This script must be run in tcl 8.1 or
# higher and takes an output filename as its parameter.
#
# Copyright (c) 1996 by Sun Microsystems, Inc.
#
# SCCS: @(#) spencer2testregexp.tcl 1.4 98/01/22 14:48:14
# 

source ../tools/regexpTestLib.tcl

#
# remove flags that have no meaning
#
proc removeFlags {flags} {
    regsub -all {\[|[A-Z]|[0-9]} $flags "" newFlags 
    return $newFlags
}

#
# code for mapping char is not yet written, skip = and >
# NOTBOL flag is already tested and can't be tested from the command line, skip ^
# L is locale dependant, skip L
#
proc findSkipFlag {flags} {
    if {[regexp {\+} $flags] == 1} {
	return 1
    }
    return 0
}

proc prepareCmd {flags re str vars noBraces} {
    if {$noBraces > 0} {
	set cmd "testregexp $flags $re $str $vars"
    } else {
	set cmd "testregexp [list $flags] [list $re] [list $str] $vars"
    }
    return $cmd
}

# main

if {$argc != 2} {
    puts "name of input and outfile reuqired"
    return
}

set inFileName [lindex $argv 0]
set outFileName [lindex $argv 1]

writeOutputFile [readInputFile] testregexp