3 # Changes to 'tommath.h' to make it conform with Tcl's linking
6 # Copyright (c) 2005 Kevin B. Kenny. All rights reserved.
8 # See the file "license.terms" for information on usage and redistribution
9 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 #----------------------------------------------------------------------
12 set f [open [lindex $argv 0] r]
19 foreach line [split $data \n] {
20 if {!$eat_semi && !$eat_endif} {
21 switch -regexp -- $line {
25 puts "\#include \"tclInt.h\""
26 puts "\#include \"tclTomMathDecls.h\""
27 puts "\#ifndef MODULE_SCOPE"
28 puts "\#define MODULE_SCOPE extern"
31 {typedef\s+unsigned long\s+mp_digit;} {
32 # change the second 'typedef unsigned long mp
34 puts "\#ifndef MP_DIGIT_DECLARED"
35 if {$def_count == 2} {
36 puts [string map {long int} $line]
40 puts "\#define MP_DIGIT_DECLARED"
43 {typedef.*mp_digit;} {
44 puts "\#ifndef MP_DIGIT_DECLARED"
46 puts "\#define MP_DIGIT_DECLARED"
50 puts "\#ifndef MP_INT_DECLARED"
51 puts "\#define MP_INT_DECLARED"
52 puts "typedef struct mp_int mp_int;"
54 puts "struct mp_int \{"
65 {^extern (int|const)} {
66 puts "\#if defined(BUILD_tcl) || !defined(_WIN32)"
67 puts [regsub {^extern} $line "MODULE_SCOPE"]
69 set after_semi "\#endif"
71 {define heap macros} {
73 puts "\#if 0 /* these are macros in tclTomMathDecls.h */"
77 puts "[string map {__x86_64__ NEVER} $line]\
78 /* 128-bit ints fail in too many places */"
91 if {[regexp {; *$} $line]} {
97 if {[regexp {^\#endif} $line]} {