summaryrefslogtreecommitdiff
blob: 2b6c2ab405af6f767ad4b4ec3c367f10dadce4aa (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
https://www.sqlite.org/cvstrac/tktview?tn=4016

--- Makefile.in
+++ Makefile.in
@@ -683,8 +683,7 @@
 	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/status.c
 
 sqlite3.h:	$(TOP)/src/sqlite.h.in 
-	sed -e s/--VERS--/$(RELEASE)/ $(TOP)/src/sqlite.h.in | \
-	sed -e s/--VERSION-NUMBER--/$(VERSION_NUMBER)/ >sqlite3.h
+	cat $(TOP)/src/sqlite.h.in | tclsh $(TOP)/tool/mksqlite3h.tcl `cat ${TOP}/VERSION` > sqlite3.h
 
 table.lo:	$(TOP)/src/table.c $(HDR)
 	$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/table.c
--- main.mk
+++ main.mk
@@ -389,9 +389,7 @@
 	awk -f $(TOP)/addopcodes.awk parse.h.temp >parse.h
 
 sqlite3.h:	$(TOP)/src/sqlite.h.in 
-	sed -e s/--VERS--/`cat ${TOP}/VERSION`/ \
-	    -e s/--VERSION-NUMBER--/`cat ${TOP}/VERSION | sed 's/[^0-9]/ /g' | $(NAWK) '{printf "%d%03d%03d",$$1,$$2,$$3}'`/ \
-                 $(TOP)/src/sqlite.h.in >sqlite3.h
+	cat $(TOP)/src/sqlite.h.in | tclsh $(TOP)/tool/mksqlite3h.tcl `cat ${TOP}/VERSION` > sqlite3.h
 
 keywordhash.h:	$(TOP)/tool/mkkeywordhash.c
 	$(BCC) -o mkkeywordhash $(OPTS) $(TOP)/tool/mkkeywordhash.c
--- tool/mksqlite3c.tcl
+++ tool/mksqlite3c.tcl
@@ -305,36 +305,3 @@
 
 close $out
 
-# This block overwrites the copy of sqlite3.h in the current directory.
-#
-# It copies tsrc/sqlite3.h to ./sqlite3.h, adding SQLITE_API in front of the
-# API functions and global variables as it goes. 
-#
-set fd_in [open tsrc/sqlite3.h r]
-set fd_out [open sqlite3.h w]
-while {![eof $fd_in]} {
-  set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)}
-  set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \**sqlite3_[_a-zA-Z0-9]+\(}
-
-  set line [gets $fd_in]
-  if {[regexp {define SQLITE_EXTERN extern} $line]} {
-    puts $fd_out $line
-    puts $fd_out [gets $fd_in]
-    puts $fd_out ""
-    puts $fd_out "#ifndef SQLITE_API"
-    puts $fd_out "# define SQLITE_API"
-    puts $fd_out "#endif"
-    set line ""
-  }
-
-  if {([regexp $varpattern $line] && ![regexp {^ *typedef} $line])
-   || ([regexp $declpattern $line])
-  } {
-    set line "SQLITE_API $line"
-  }
-  puts $fd_out $line
-}
-close $fd_out
-close $fd_in
-
-
--- tool/mksqlite3h.tcl
+++ tool/mksqlite3h.tcl
@@ -0,0 +1,47 @@
+#!/usr/bin/tclsh
+#
+# This script performs processing on src/sqlite.h.in. It:
+#
+#   1) Adds SQLITE_EXTERN in front of the declaration of global variables,
+#   2) Adds SQLITE_API in front of the declaration of API functions,
+#   3) Replaces the string --VERS-- with the current library version, 
+#      formatted as a string (e.g. "3.6.17"), and
+#   4) Replaces the string --VERSION-NUMBER-- with current library version,
+#      formatted as an integer (e.g. "3006017").
+#
+# This script reads from stdin, and outputs to stdout. The current library
+# version number should be passed as the only argument. Example invocation:
+#
+#   cat sqlite.h.in | mksqlite3h.tcl 3.6.17 > sqlite3.h
+#
+
+set zVersion [lindex $argv 0]
+set nVersion [eval format "%d%03d%03d" [split $zVersion .]]
+
+while {![eof stdin]} {
+  set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)}
+  set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \**sqlite3_[_a-zA-Z0-9]+\(}
+
+  set line [gets stdin]
+
+  regsub -- --VERS--           $line $zVersion line
+  regsub -- --VERSION-NUMBER-- $line $nVersion line
+
+  if {[regexp {define SQLITE_EXTERN extern} $line]} {
+    puts $line
+    puts [gets stdin]
+    puts ""
+    puts "#ifndef SQLITE_API"
+    puts "# define SQLITE_API"
+    puts "#endif"
+    set line ""
+  }
+
+  if {([regexp $varpattern $line] && ![regexp {^ *typedef} $line])
+   || ([regexp $declpattern $line])
+  } {
+    set line "SQLITE_API $line"
+  }
+  puts $line
+}
+