Skip to content

Commit 5196160

Browse files
committed
Generate a static
1 parent d771ca4 commit 5196160

File tree

3 files changed

+34
-32
lines changed

3 files changed

+34
-32
lines changed

ext/mysql2/mysql_enc_name_to_ruby.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* C code produced by gperf version 3.0.3 */
1+
/* C code produced by gperf version 3.0.4 */
22
/* Command-line: gperf */
33
/* Computed positions: -k'1,3,$' */
44

@@ -40,9 +40,9 @@ inline
4040
#endif
4141
#endif
4242
static unsigned int
43-
mysql2_mysql_enc_name_to_rb_hash(str, len)
43+
mysql2_mysql_enc_name_to_rb_hash (str, len)
4444
register const char *str;
45-
register const unsigned int len;
45+
register unsigned int len;
4646
{
4747
static const unsigned char asso_values[] =
4848
{
@@ -78,14 +78,14 @@ mysql2_mysql_enc_name_to_rb_hash(str, len)
7878

7979
#ifdef __GNUC__
8080
__inline
81-
#ifdef __GNUC_STDC_INLINE__
81+
#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
8282
__attribute__ ((__gnu_inline__))
8383
#endif
8484
#endif
8585
const struct mysql2_mysql_enc_name_to_rb_map *
86-
mysql2_mysql_enc_name_to_rb(str, len)
86+
mysql2_mysql_enc_name_to_rb (str, len)
8787
register const char *str;
88-
register const unsigned int len;
88+
register unsigned int len;
8989
{
9090
enum
9191
{
@@ -154,9 +154,9 @@ mysql2_mysql_enc_name_to_rb(str, len)
154154

155155
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
156156
{
157-
register const unsigned int key = mysql2_mysql_enc_name_to_rb_hash(str, len);
157+
register int key = mysql2_mysql_enc_name_to_rb_hash (str, len);
158158

159-
if (key <= MAX_HASH_VALUE)
159+
if (key <= MAX_HASH_VALUE && key >= 0)
160160
{
161161
register const char *s = wordlist[key].name;
162162

ext/mysql2/mysql_enc_to_ruby.h

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const char *mysql2_mysql_enc_to_rb[] = {
1+
static const char *mysql2_mysql_enc_to_rb[] = {
22
"Big5",
33
"ISO-8859-2",
44
NULL,
@@ -54,13 +54,13 @@ const char *mysql2_mysql_enc_to_rb[] = {
5454
"macRoman",
5555
"UTF-16",
5656
"UTF-16",
57-
NULL,
57+
"",
5858
"Windows-1256",
5959
"Windows-1257",
6060
"Windows-1257",
6161
"UTF-32",
6262
"UTF-32",
63-
NULL,
63+
"",
6464
"ASCII-8BIT",
6565
NULL,
6666
"US-ASCII",
@@ -119,10 +119,10 @@ const char *mysql2_mysql_enc_to_rb[] = {
119119
"UTF-16",
120120
"UTF-16",
121121
"UTF-16",
122-
NULL,
123-
NULL,
124-
NULL,
125-
NULL,
122+
"UTF-16",
123+
"UTF-16",
124+
"UTF-16",
125+
"UTF-16",
126126
NULL,
127127
NULL,
128128
NULL,
@@ -146,18 +146,22 @@ const char *mysql2_mysql_enc_to_rb[] = {
146146
"UTF-16BE",
147147
"UTF-16BE",
148148
"UTF-16BE",
149+
"UTF-16BE",
150+
"UTF-16BE",
151+
"UTF-16BE",
152+
"UTF-16BE",
149153
NULL,
150154
NULL,
151155
NULL,
152156
NULL,
153157
NULL,
154158
NULL,
155159
NULL,
156-
NULL,
157-
NULL,
158-
NULL,
159-
NULL,
160-
NULL,
160+
"UTF-16BE",
161+
"UTF-32",
162+
"UTF-32",
163+
"UTF-32",
164+
"UTF-32",
161165
"UTF-32",
162166
"UTF-32",
163167
"UTF-32",
@@ -178,10 +182,6 @@ const char *mysql2_mysql_enc_to_rb[] = {
178182
"UTF-32",
179183
"UTF-32",
180184
"UTF-32",
181-
NULL,
182-
NULL,
183-
NULL,
184-
NULL,
185185
NULL,
186186
NULL,
187187
NULL,
@@ -210,18 +210,22 @@ const char *mysql2_mysql_enc_to_rb[] = {
210210
"UTF-8",
211211
"UTF-8",
212212
"UTF-8",
213+
"UTF-8",
214+
"UTF-8",
215+
"UTF-8",
216+
"UTF-8",
213217
NULL,
214218
NULL,
215219
NULL,
216220
NULL,
217221
NULL,
218222
NULL,
219223
NULL,
220-
NULL,
221-
NULL,
222-
NULL,
223-
NULL,
224-
NULL,
224+
"UTF-8",
225+
"UTF-8",
226+
"UTF-8",
227+
"UTF-8",
228+
"UTF-8",
225229
"UTF-8",
226230
"UTF-8",
227231
"UTF-8",
@@ -243,4 +247,3 @@ const char *mysql2_mysql_enc_to_rb[] = {
243247
"UTF-8",
244248
"UTF-8"
245249
};
246-

support/mysql_enc_to_ruby.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676

7777
# start printing output
7878

79-
puts "const char *mysql2_mysql_enc_to_rb[] = {"
79+
puts "static const char *mysql2_mysql_enc_to_rb[] = {"
8080
puts encodings_with_nil.join(",\n")
8181
puts "};"
82-
puts

0 commit comments

Comments
 (0)