blob: adad734b7b7f89acf67ce718eed11f97120a68ff (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# fixtommath.tcl --
#
# Changes to 'tommath.h' to make it conform with Tcl's linking
# conventions.
#
# Copyright (c) 2005 by Kevin B. Kenny. All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: fix_tommath_h.tcl,v 1.4 2005/12/13 22:43:18 kennykb Exp $
#
#----------------------------------------------------------------------
set f [open [lindex $argv 0] r]
set data [read $f]
close $f
set eat_endif 0
set eat_semi 0
foreach line [split $data \n] {
if { !$eat_semi && !$eat_endif } {
switch -regexp -- $line {
{#define BN_H_} {
puts $line
puts {}
puts "\#include <tclTomMathDecls.h>"
puts "\#ifndef MODULE_SCOPE"
puts "\#define MODULE_SCOPE extern"
puts "\#endif"
}
{typedef.*mp_digit;} {
puts "\#ifndef MP_DIGIT_DECLARED"
puts $line
puts "\#define MP_DIGIT_DECLARED"
puts "\#endif"
}
{typedef struct} {
puts "\#ifndef MP_INT_DECLARED"
puts "\#define MP_INT_DECLARED"
puts "typedef struct mp_int mp_int;"
puts "\#endif"
puts "struct mp_int \{"
}
\}\ mp_int\; {
puts "\};"
}
{^(char|int|void)} {
puts "/*"
puts $line
set eat_semi 1
set after_semi "*/"
}
{^extern (int|const)} {
puts "\#if defined(BUILD_tcl) || !defined(_WIN32)"
puts [regsub {^extern} $line "MODULE_SCOPE"]
set eat_semi 1
set after_semi "\#endif"
}
{define heap macros} {
puts $line
puts "\#if 0 /* these are macros in tclTomMathDecls.h */"
set eat_endif 1
}
default {
puts $line
}
}
} else {
puts $line
}
if {$eat_semi} {
if {[regexp {; *$} $line]} {
puts $after_semi
set eat_semi 0
}
}
if {$eat_endif} {
if {[regexp {^\#endif} $line]} {
puts "\#endif"
set eat_endif 0
}
}
}
|