aboutsummaryrefslogtreecommitdiffstats
path: root/tools/build_numerics.sh
blob: cb225a7d917c3a217fd62f6ea5661b738785fd57 (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
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
###########################################################################
#                                                                         #
#  envbot - an IRC bot in bash                                            #
#  Copyright (C) 2007-2008  Arvid Norlander                               #
#                                                                         #
#  This program is free software: you can redistribute it and/or modify   #
#  it under the terms of the GNU General Public License as published by   #
#  the Free Software Foundation, either version 3 of the License, or      #
#  (at your option) any later version.                                    #
#                                                                         #
#  This program is distributed in the hope that it will be useful,        #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of         #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          #
#  GNU General Public License for more details.                           #
#                                                                         #
#  You should have received a copy of the GNU General Public License      #
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.  #
#                                                                         #
###########################################################################
#---------------------------------------------------------------------
## Generate list of numerics from the numerics.txt<br />
## Output to STDOUT.<br />
## Run this using make numerics in the main directory.
#---------------------------------------------------------------------

# Clean up env, just in case.
unset LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY
unset LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS
unset LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
export LC_ALL=C
export LANG=C

cat << EOF
#!/bin/bash
# -*- coding: utf-8 -*-
###########################################################################
#                                                                         #
#  envbot - an IRC bot in bash                                            #
#  Copyright (C) 2007-2008  Arvid Norlander                               #
#                                                                         #
#  This program is free software: you can redistribute it and/or modify   #
#  it under the terms of the GNU General Public License as published by   #
#  the Free Software Foundation, either version 3 of the License, or      #
#  (at your option) any later version.                                    #
#                                                                         #
#  This program is distributed in the hope that it will be useful,        #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of         #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          #
#  GNU General Public License for more details.                           #
#                                                                         #
#  You should have received a copy of the GNU General Public License      #
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.  #
#                                                                         #
###########################################################################

###########################################################################
#                                                                         #
# WARNING THIS FILE IS AUTOGENERATED. ANY CHANGES WILL BE OVERWRITTEN!    #
# See the source in tools/numerics.txt for comments about some numerics   #
# This file was generated with tools/build_numerics.sh                    #
#                                                                         #
###########################################################################
#---------------------------------------------------------------------
## Auto-generated list of numerics from tools/numerics.txt<br />
## This file contains a list of numerics that we currently use.
## It is therefore incomplete.<br />
## Because the list of variables in this file is so long, please see
## it's source for more details.
#---------------------------------------------------------------------

##########################
# Name -> number mapping #
##########################

EOF
# The numerics above are special case, otherwise bash strips leading 0.

# Yes a bash file with .txt..
source tools/numerics.txt || { echo 'Failed to source.' >&2; exit 1; }

for index in ${!numeric[*]}; do
	printf "numeric_%s='%03i'\n" "${numeric[$index]}" "$index"
done

# Same special case as above.
cat << EOF

##########################
# Number -> name mapping #
##########################

EOF
for index in ${!numeric[*]}; do
	echo "numerics[$index]='${numeric[$index]}'"
done

cat << EOF

# End of generated file.
EOF