1/* Copyright (c) 2002, 2013, Oracle and/or its affiliates.
2 Copyright (c) 2009, 2014, SkySQL Ab.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
17/*
18 Shared, independent copyright: (C) 2001 Jan Pazdziora.
19
20 Development of this software was supported by Neocortex, s.r.o.
21 MySQL AB expresses its gratitude to Jan for for giving us this software.
22
23 Bug reports and suggestions are always welcome.
24
25 This file implements the collating sequence for Windows-1250
26 character set. It merely extends the binary sorting of US-ASCII
27 by adding characters with diacritical marks into proper places.
28 In addition, it sorts 'ch' between 'h' and 'i', and the sorting
29 is case sensitive, with uppercase being sorted first, in the
30 second pass.
31*/
32
33/*
34 * This comment is parsed by configure to create ctype.c,
35 * so don't change it unless you know what you are doing.
36 *
37 * .configure. strxfrm_multiply_win1250ch=2
38 */
39
40#define REAL_MYSQL
41#ifdef REAL_MYSQL
42
43#include "strings_def.h"
44#include <m_ctype.h>
45
46#else
47
48#include <stdio.h>
49#define uchar unsigned char
50
51#endif
52
53#ifdef HAVE_CHARSET_cp1250
54
55
56static const uint16 tab_cp1250_uni[256]={
57 0,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,
580x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F,
590x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017,
600x0018,0x0019,0x001A,0x001B,0x001C,0x001D,0x001E,0x001F,
610x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027,
620x0028,0x0029,0x002A,0x002B,0x002C,0x002D,0x002E,0x002F,
630x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037,
640x0038,0x0039,0x003A,0x003B,0x003C,0x003D,0x003E,0x003F,
650x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,
660x0048,0x0049,0x004A,0x004B,0x004C,0x004D,0x004E,0x004F,
670x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057,
680x0058,0x0059,0x005A,0x005B,0x005C,0x005D,0x005E,0x005F,
690x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067,
700x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F,
710x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
720x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
730x20AC, 0,0x201A, 0,0x201E,0x2026,0x2020,0x2021,
74 0,0x2030,0x0160,0x2039,0x015A,0x0164,0x017D,0x0179,
75 0,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014,
76 0,0x2122,0x0161,0x203A,0x015B,0x0165,0x017E,0x017A,
770x00A0,0x02C7,0x02D8,0x0141,0x00A4,0x0104,0x00A6,0x00A7,
780x00A8,0x00A9,0x015E,0x00AB,0x00AC,0x00AD,0x00AE,0x017B,
790x00B0,0x00B1,0x02DB,0x0142,0x00B4,0x00B5,0x00B6,0x00B7,
800x00B8,0x0105,0x015F,0x00BB,0x013D,0x02DD,0x013E,0x017C,
810x0154,0x00C1,0x00C2,0x0102,0x00C4,0x0139,0x0106,0x00C7,
820x010C,0x00C9,0x0118,0x00CB,0x011A,0x00CD,0x00CE,0x010E,
830x0110,0x0143,0x0147,0x00D3,0x00D4,0x0150,0x00D6,0x00D7,
840x0158,0x016E,0x00DA,0x0170,0x00DC,0x00DD,0x0162,0x00DF,
850x0155,0x00E1,0x00E2,0x0103,0x00E4,0x013A,0x0107,0x00E7,
860x010D,0x00E9,0x0119,0x00EB,0x011B,0x00ED,0x00EE,0x010F,
870x0111,0x0144,0x0148,0x00F3,0x00F4,0x0151,0x00F6,0x00F7,
880x0159,0x016F,0x00FA,0x0171,0x00FC,0x00FD,0x0163,0x02D9
89};
90
91
92/* 0000-00FD , 254 chars */
93static const uchar tab_uni_cp1250_plane00[]={
940x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
950x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
960x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
970x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
980x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
990x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
1000x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
1010x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
1020x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1030x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1040xA0,0x00,0x00,0x00,0xA4,0x00,0xA6,0xA7,0xA8,0xA9,0x00,0xAB,0xAC,0xAD,0xAE,0x00,
1050xB0,0xB1,0x00,0x00,0xB4,0xB5,0xB6,0xB7,0xB8,0x00,0x00,0xBB,0x00,0x00,0x00,0x00,
1060x00,0xC1,0xC2,0x00,0xC4,0x00,0x00,0xC7,0x00,0xC9,0x00,0xCB,0x00,0xCD,0xCE,0x00,
1070x00,0x00,0x00,0xD3,0xD4,0x00,0xD6,0xD7,0x00,0x00,0xDA,0x00,0xDC,0xDD,0x00,0xDF,
1080x00,0xE1,0xE2,0x00,0xE4,0x00,0x00,0xE7,0x00,0xE9,0x00,0xEB,0x00,0xED,0xEE,0x00,
1090x00,0x00,0x00,0xF3,0xF4,0x00,0xF6,0xF7,0x00,0x00,0xFA,0x00,0xFC,0xFD};
110
111/* 0102-017E , 125 chars */
112static const uchar tab_uni_cp1250_plane01[]={
1130xC3,0xE3,0xA5,0xB9,0xC6,0xE6,0x00,0x00,0x00,0x00,0xC8,0xE8,0xCF,0xEF,0xD0,0xF0,
1140x00,0x00,0x00,0x00,0x00,0x00,0xCA,0xEA,0xCC,0xEC,0x00,0x00,0x00,0x00,0x00,0x00,
1150x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1160x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC5,0xE5,0x00,0x00,0xBC,0xBE,0x00,0x00,0xA3,
1170xB3,0xD1,0xF1,0x00,0x00,0xD2,0xF2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD5,0xF5,
1180x00,0x00,0xC0,0xE0,0x00,0x00,0xD8,0xF8,0x8C,0x9C,0x00,0x00,0xAA,0xBA,0x8A,0x9A,
1190xDE,0xFE,0x8D,0x9D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD9,0xF9,0xDB,0xFB,
1200x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8F,0x9F,0xAF,0xBF,0x8E,0x9E};
121
122/* 2013-20AC , 154 chars */
123static const uchar tab_uni_cp1250_plane20[]={
1240x96,0x97,0x00,0x00,0x00,0x91,0x92,0x82,0x00,0x93,0x94,0x84,0x00,0x86,0x87,0x95,
1250x00,0x00,0x00,0x85,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x89,0x00,0x00,
1260x00,0x00,0x00,0x00,0x00,0x00,0x8B,0x9B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1270x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1280x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1290x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1300x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1310x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1320x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1330x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80};
134
135/* 02C7-02DD , 23 chars */
136static const uchar tab_uni_cp1250_plane02[]={
1370xA1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1380x00,0xA2,0xFF,0x00,0xB2,0x00,0xBD};
139
140/* 2122-2122 , 1 chars */
141static const uchar tab_uni_cp1250_plane21[]={
1420x99};
143
144
145static MY_UNI_IDX idx_uni_cp1250[]={
146 {0x0000,0x00FD,tab_uni_cp1250_plane00},
147 {0x0102,0x017E,tab_uni_cp1250_plane01},
148 {0x2013,0x20AC,tab_uni_cp1250_plane20},
149 {0x02C7,0x02DD,tab_uni_cp1250_plane02},
150 {0x2122,0x2122,tab_uni_cp1250_plane21},
151 {0,0,NULL}
152};
153
154
155static const uchar ctype_win1250ch[] = {
1560x00,
1570x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
1580x20, 0x28, 0x28, 0x28, 0x28, 0x28, 0x20, 0x20,
1590x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
1600x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
1610x48, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
1620x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
1630x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84,
1640x84, 0x84, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
1650x10, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x01,
1660x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
1670x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
1680x01, 0x01, 0x01, 0x10, 0x10, 0x10, 0x10, 0x10,
1690x10, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x02,
1700x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1710x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1720x02, 0x02, 0x02, 0x10, 0x10, 0x10, 0x10, 0x20,
1730x20, 0x20, 0x10, 0x20, 0x10, 0x10, 0x10, 0x10,
1740x20, 0x10, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01,
1750x20, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
1760x20, 0x10, 0x02, 0x10, 0x02, 0x02, 0x02, 0x02,
1770x48, 0x10, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01,
1780x10, 0x10, 0x01, 0x10, 0x10, 0x10, 0x10, 0x01,
1790x10, 0x10, 0x10, 0x02, 0x10, 0x10, 0x10, 0x10,
1800x10, 0x02, 0x02, 0x10, 0x01, 0x10, 0x02, 0x02,
1810x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
1820x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
1830x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10,
1840x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02,
1850x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1860x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1870x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x10,
1880x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x10
189};
190
191static const uchar to_lower_win1250ch[] = {
1920x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1930x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1940x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1950x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
1960x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
1970x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
1980x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
1990x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
2000x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
2010x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
2020x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
2030x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
2040x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
2050x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
2060x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
2070x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
2080x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
2090x88, 0x89, 0x9a, 0x8b, 0x9c, 0x9d, 0x9e, 0x9f,
2100x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
2110x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
2120xa0, 0xa1, 0xa2, 0xb3, 0xa4, 0xb9, 0xa6, 0xdf,
2130xa8, 0xa9, 0xba, 0xab, 0xac, 0xad, 0xae, 0xbf,
2140xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
2150xb8, 0xb9, 0xba, 0xbb, 0xbe, 0xbd, 0xbe, 0xbf,
2160xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
2170xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
2180xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7,
2190xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xdf,
2200xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
2210xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
2220xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2230xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
224};
225
226static const uchar to_upper_win1250ch[] = {
2270x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2280x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2290x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2300x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
2310x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
2320x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
2330x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2340x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
2350x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
2360x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
2370x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
2380x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
2390x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
2400x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
2410x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
2420x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
2430x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
2440x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
2450x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
2460x98, 0x99, 0x8a, 0x9b, 0x8c, 0x8d, 0x8e, 0x8f,
2470xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
2480xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
2490xb0, 0xb1, 0xb2, 0xa3, 0xb4, 0xb5, 0xb6, 0xb7,
2500xb8, 0xa5, 0xaa, 0xbb, 0xbc, 0xbd, 0xbc, 0xaf,
2510xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
2520xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
2530xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
2540xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xa7,
2550xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
2560xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
2570xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7,
2580xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xff
259};
260
261
262
263static const uchar sort_order_win1250ch[] = {
2640, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
26516, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
26632, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
26748, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
26864, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
26980, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
27096, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
271112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
272128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
273144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
274160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
275176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
276192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
277208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
278224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
279240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
280};
281
282static const uchar _sort_order_win1250ch1[] = {
2830x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
2840x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
2850x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
2860x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
287/* space ord 32 0x20 */
2880x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
2890x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91,
290/* 0 ord 48 0x30 */
2910x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
2920x9a, 0x9b,
293 /* colon ord 58 0x3a */
294 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1,
2950xa2,
296 /* A ord 65 0x41 */
297 0xa4, 0xa5,
298 /* C ord 67 0x43 */
299 0xff, 0xa8, 0xa9, 0xaa, 0xab,
3000xac, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
3010xb5, 0xb6,
302 /* R ord 82 0x52 */
303 0xb7,
304 /* S ord 83 0x53 */
305 0xb9, 0xbc, 0xbd, 0xbe, 0xbf,
3060xc0, 0xc1, 0xc2,
307 /* [ ord 91 0x5b */
308 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
3090xc9,
310 /* a ord 97 0x61 */
311 0xa4, 0xa5, 0xff, 0xa8, 0xa9, 0xaa, 0xab,
3120xac, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
3130xb5, 0xb6, 0xb7, 0xb9, 0xbc, 0xbd, 0xbe, 0xbf,
3140xc0, 0xc1, 0xc2,
315 /* { ord 123 0x7b */
316 0xca, 0xcb, 0xcc, 0xcd, 0x81,
3170x81, 0x81, 0xce, 0x81, 0xcf, 0xd0, 0xd1, 0xd2,
3180x81, 0xd3,
319 /* Scaron ord 138 0x8a */
320 0xba, 0xd4, 0xb9, 0xbc, 0xc3, 0xc2,
3210x81, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb,
3220x81, 0xdc, 0xba, 0xdd, 0xb9, 0xbc, 0xc3, 0xc2,
323/* nobreakspace ord 160 0xa0 */
3240x82, 0xde, 0xdf, 0xb1, 0xe0, 0xa4, 0xe1, 0xe2,
3250xe3, 0xe4, 0xb9, 0xe5, 0xe6, 0xe7, 0xe8, 0xc2,
3260xe9, 0xea, 0xeb, 0xb1, 0xed, 0xee, 0x81, 0xef,
327/* cedilla ord 183 0xb8 */
3280xf0, 0xa4, 0xb9, 0xf1, 0xb1, 0xf2, 0xb1, 0xc2,
3290xb7, 0xa4, 0xa4, 0xa4, 0xa4, 0xb1, 0xa6, 0xa6,
3300xa7, 0xa9, 0xa9, 0xa9, 0xa9, 0xae, 0xae, 0xa8,
331/* Eth ord 208 0xd0 */
3320xa8, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4, 0xb4, 0xf3,
3330xb8, 0xbd, 0xbd, 0xbd, 0xbd, 0xc1, 0xbc, 0xbb,
334/* racute ord 224 0xe0 */
3350xb7, 0xa4, 0xa4, 0xa4, 0xa4, 0xb1, 0xa6, 0xa6,
3360xa7, 0xa9, 0xa9, 0xa9, 0xa9, 0xae, 0xae, 0xa8,
337/* eth ord 240 0xf0 */
3380xa8, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4, 0xb4, 0xf4,
3390xb8, 0xbd, 0xbd, 0xbd, 0xbd, 0xc1, 0xbc, 0xf5
340};
341
342static uchar _sort_order_win1250ch2[] = {
3430x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
3440x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
3450x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
3460x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21,
347/* space ord 32 0x20 */
3480x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
3490x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
350/* 0 ord 48 0x30 */
3510x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
3520x01, 0x01,
353 /* colon ord 58 0x3a */
354 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
3550x01,
356 /* A ord 65 0x41 */
357 0x01, 0x01,
358 /* C ord 67 0x43 */
359 0xff, 0x01, 0x01, 0x01, 0x01,
3600x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
3610x01, 0x01,
362 /* R ord 82 0x52 */
363 0x01,
364 /* S ord 83 0x53 */
365 0x01, 0x01, 0x01, 0x01, 0x01,
3660x01, 0x01, 0x01,
367 /* [ ord 91 0x5b */
368 0x01, 0x01, 0x01, 0x01, 0x01,
3690x01,
370 /* a ord 97 0x61 */
371 0x02, 0x02, 0xff, 0x02, 0x02, 0x02, 0x02,
3720x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
3730x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
3740x02, 0x02, 0x02,
375 /* { ord 123 0x7b */
376 0x01, 0x01, 0x01, 0x01, 0x22,
3770x23, 0x24, 0x01, 0x25, 0x01, 0x01, 0x01, 0x01,
3780x26, 0x01,
379 /* Scaron ord 138 0x8a */
380 0x01, 0x01, 0x03, 0x03, 0x01, 0x05,
3810x27, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
3820x28, 0x01, 0x02, 0x01, 0x04, 0x04, 0x02, 0x06,
383/* nobreakspace ord 160 0xa0 */
3840x02, 0x01, 0x01, 0x07, 0x01, 0x11, 0x01, 0x01,
3850x01, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x03,
3860x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x29, 0x01,
387/* cedilla ord 184 0xb8 */
3880x01, 0x12, 0x06, 0x01, 0x05, 0x01, 0x06, 0x04,
3890x03, 0x03, 0x05, 0x07, 0x09, 0x03, 0x03, 0x05,
3900x01, 0x03, 0x09, 0x07, 0x05, 0x03, 0x05, 0x03,
391/* Eth ord 208 0xd0 */
3920x05, 0x03, 0x05, 0x03, 0x05, 0x09, 0x07, 0x01,
3930x01, 0x05, 0x03, 0x09, 0x07, 0x03, 0x05, 0x01,
394/* racute ord 224 0xe0 */
3950x04, 0x04, 0x06, 0x08, 0x0a, 0x04, 0x04, 0x06,
3960x02, 0x04, 0x0a, 0x08, 0x06, 0x04, 0x06, 0x04,
397/* eth ord 240 0xf0 */
3980x06, 0x04, 0x06, 0x04, 0x06, 0x0a, 0x08, 0x01,
3990x02, 0x06, 0x04, 0x0a, 0x08, 0x04, 0x06, 0x01
400};
401
402struct wordvalue {
403 const uchar *word;
404 uchar pass1;
405 uchar pass2;
406};
407static const struct wordvalue doubles[] = {
408 { (uchar*) "ch", 0xad, 0x03 },
409 { (uchar*) "c", 0xa6, 0x02 },
410 { (uchar*) "Ch", 0xad, 0x02 },
411 { (uchar*) "CH", 0xad, 0x01 },
412 { (uchar*) "C", 0xa6, 0x01 },
413};
414
415#define NEXT_CMP_VALUE(src, p, pass, value, len) \
416 while (1) { \
417 if (IS_END(p, src, len)) { \
418 if (pass == 0 && len > 0) { p= src; pass++; } \
419 else { value = 0; break; } \
420 } \
421 value = ((pass == 0) ? _sort_order_win1250ch1[*p] \
422 : _sort_order_win1250ch2[*p]); \
423 if (value == 0xff) { \
424 int i; \
425 for (i = 0; i < (int) sizeof(doubles); i++) { \
426 const uchar *patt = doubles[i].word; \
427 const uchar *q = (const uchar *) p; \
428 while (*patt \
429 && !(IS_END(q, src, len)) \
430 && (*patt == *q)) { \
431 patt++; q++; \
432 } \
433 if (!(*patt)) { \
434 value = (int)((pass == 0) \
435 ? doubles[i].pass1 \
436 : doubles[i].pass2); \
437 p = (const uchar *) q - 1; \
438 break; \
439 } \
440 } \
441 } \
442 p++; \
443 break; \
444 }
445
446#define IS_END(p, src, len) (((char *)p - (char *)src) >= (len))
447
448static int my_strnncoll_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
449 const uchar *s1, size_t len1,
450 const uchar *s2, size_t len2,
451 my_bool s2_is_prefix)
452{
453 int v1, v2;
454 const uchar *p1, * p2;
455 int pass1 = 0, pass2 = 0;
456 int diff;
457
458 if (s2_is_prefix && len1 > len2)
459 len1=len2;
460
461 p1 = s1; p2 = s2;
462
463 do
464 {
465 NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1);
466 NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2);
467 if ((diff = v1 - v2))
468 return diff;
469 } while (v1);
470 return 0;
471}
472
473
474/*
475 TODO: Has to be fixed as strnncollsp in ctype-simple
476*/
477
478static
479int my_strnncollsp_win1250ch(CHARSET_INFO * cs,
480 const uchar *s, size_t slen,
481 const uchar *t, size_t tlen)
482{
483 for ( ; slen && s[slen-1] == ' ' ; slen--);
484 for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
485 return my_strnncoll_win1250ch(cs,s,slen,t,tlen,0);
486}
487
488
489static size_t
490my_strnxfrm_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
491 uchar *dest, size_t len,
492 uint nweights_arg __attribute__((unused)),
493 const uchar *src, size_t srclen, uint flags)
494{
495 int value;
496 const uchar *p;
497 int pass = 0;
498 size_t totlen = 0;
499 p = src;
500
501 if (!(flags & 0x0F)) /* All levels by default */
502 flags|= 0x0F;
503
504 while (totlen < len)
505 {
506 NEXT_CMP_VALUE(src, p, pass, value, (int)srclen);
507 if (!value)
508 break;
509 if ((1 << pass) & flags)
510 dest[totlen++] = value;
511 }
512 if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && len > totlen)
513 {
514 memset(dest + totlen, 0x00, len - totlen);
515 totlen= len;
516 }
517 return totlen;
518}
519
520#undef IS_END
521
522#ifdef REAL_MYSQL
523
524static const uchar like_range_prefix_min_win1250ch[]=
525{
526 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
527 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
528 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
529 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
530 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
531 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
532 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
533 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
534 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
535 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
536 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
537 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
538 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
539 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
540 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
541 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
542 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
543 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
544 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
545 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
546 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
547 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
548 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
549 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
550 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
551 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
552 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
553 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
554 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
555 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
556 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
557 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
558};
559
560/*
561 The letter "C" is a special case:
562 "CH" is sorted between "H" and "I".
563 prefix_max for "C" is "I": prefix_max[0x43] == 0x49
564 prefix_max for "c" is "i": prefix_max[0x63] == 0x69
565 For all other characters: prefix_max[i] == i
566*/
567
568static uchar like_range_prefix_max_win1250ch[]=
569{
570 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
571 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
572 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
573 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
574 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
575 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
576 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
577 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
578 0x40, 0x41, 0x42, 0x49, 0x44, 0x45, 0x46, 0x47,
579 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
580 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
581 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
582 0x60, 0x61, 0x62, 0x69, 0x64, 0x65, 0x66, 0x67,
583 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
584 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
585 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
586 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
587 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
588 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
589 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
590 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
591 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
592 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
593 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
594 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
595 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
596 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
597 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
598 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
599 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
600 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
601 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
602};
603
604#define min_sort_char '\x20'
605#define max_sort_char '\xff'
606
607/*
608** Calculate min_str and max_str that ranges a LIKE string.
609** Arguments:
610** ptr Pointer to LIKE string.
611** ptr_length Length of LIKE string.
612** escape Escape character in LIKE. (Normally '\').
613** All escape characters should be removed from min_str and max_str
614** res_length Length of min_str and max_str.
615** min_str Smallest case sensitive string that ranges LIKE.
616** Should be space padded to res_length.
617** max_str Largest case sensitive string that ranges LIKE.
618** Normally padded with the biggest character sort value.
619**
620** The function should return 0 if ok and 1 if the LIKE string can't be
621** optimized !
622*/
623
624static my_bool
625my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
626 const char *ptr, size_t ptr_length,
627 pbool escape, pbool w_one, pbool w_many,
628 size_t res_length,
629 char *min_str, char *max_str,
630 size_t *min_length, size_t *max_length)
631{
632
633 int only_min_found= 1;
634 const char *end = ptr + ptr_length;
635 char *min_org = min_str;
636 char *min_end = min_str + res_length;
637
638 /* return 1; */
639
640 for (; ptr != end && min_str != min_end ; ptr++)
641 {
642 if (*ptr == escape && ptr+1 != end)
643 ptr++; /* Skip escape */
644 else if (*ptr == w_one || *ptr == w_many) /* '_' or '%' in SQL */
645 break;
646 *min_str= like_range_prefix_min_win1250ch[(uint) (uchar) (*ptr)];
647 if (*min_str != min_sort_char)
648 only_min_found= 0;
649 min_str++;
650 *max_str++= like_range_prefix_max_win1250ch[(uint) (uchar) (*ptr)];
651 }
652
653 if (cs->state & MY_CS_BINSORT)
654 *min_length= (size_t) (min_str - min_org);
655 else
656 {
657 /* 'a\0\0... is the smallest possible string */
658 *min_length= res_length;
659 }
660 /* a\ff\ff... is the biggest possible string */
661 *max_length= res_length;
662
663 while (min_str != min_end)
664 {
665 *min_str++ = min_sort_char;
666 *max_str++ = max_sort_char;
667 }
668 return (only_min_found);
669}
670
671
672static MY_COLLATION_HANDLER my_collation_czech_ci_handler =
673{
674 NULL, /* init */
675 my_strnncoll_win1250ch,
676 my_strnncollsp_win1250ch,
677 my_strnxfrm_win1250ch,
678 my_strnxfrmlen_simple,
679 my_like_range_win1250ch,
680 my_wildcmp_8bit,
681 my_strcasecmp_8bit,
682 my_instr_simple,
683 my_hash_sort_simple,
684 my_propagate_simple
685};
686
687
688struct charset_info_st my_charset_cp1250_czech_ci =
689{
690 34,0,0, /* number */
691 MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT|
692 MY_CS_STRNXFRM_BAD_NWEIGHTS|MY_CS_NON1TO1, /* state */
693 "cp1250", /* cs name */
694 "cp1250_czech_cs", /* name */
695 "", /* comment */
696 NULL, /* tailoring */
697 ctype_win1250ch,
698 to_lower_win1250ch,
699 to_upper_win1250ch,
700 sort_order_win1250ch,
701 NULL, /* uca */
702 tab_cp1250_uni, /* tab_to_uni */
703 idx_uni_cp1250, /* tab_from_uni */
704 &my_unicase_default, /* caseinfo */
705 NULL, /* state_map */
706 NULL, /* ident_map */
707 2, /* strxfrm_multiply */
708 1, /* caseup_multiply */
709 1, /* casedn_multiply */
710 1, /* mbminlen */
711 1, /* mbmaxlen */
712 0, /* min_sort_char */
713 0, /* max_sort_char */
714 ' ', /* pad char */
715 0, /* escape_with_backslash_is_dangerous */
716 2, /* levels_for_order */
717 &my_charset_8bit_handler,
718 &my_collation_czech_ci_handler
719};
720
721
722#endif /* REAL_MYSQL */
723
724#endif /* HAVE_CHARSET_cp1250 */
725