Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
389cec7d
Commit
389cec7d
authored
Jan 03, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Charset index is sotred in XML now
parent
ac0bb91f
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
612 additions
and
42 deletions
+612
-42
libmysql/Makefile.shared
libmysql/Makefile.shared
+1
-1
mysys/charset.c
mysys/charset.c
+154
-39
sql/share/Makefile.am
sql/share/Makefile.am
+2
-2
sql/share/charsets/Index.xml
sql/share/charsets/Index.xml
+455
-0
No files found.
libmysql/Makefile.shared
View file @
389cec7d
...
...
@@ -58,7 +58,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
mf_loadpath.lo my_pthread.lo my_thr_init.lo
\
thr_mutex.lo mulalloc.lo string.lo default.lo
\
my_compress.lo array.lo my_once.lo list.lo my_net.lo
\
charset.lo hash.lo mf_iocache.lo
\
charset.lo
xml.lo
hash.lo mf_iocache.lo
\
mf_iocache2.lo my_seek.lo
\
my_pread.lo mf_cache.lo my_vsnprintf.lo md5.lo sha1.lo
\
my_getopt.lo my_gethostbyname.lo my_port.lo
...
...
mysys/charset.c
View file @
389cec7d
...
...
@@ -19,7 +19,9 @@
#include <m_ctype.h>
#include <m_string.h>
#include <my_dir.h>
#include <my_xml.h>
#define MY_CHARSET_INDEX "Index.xml"
const
char
*
charsets_dir
=
NULL
;
static
int
charset_initialized
=
0
;
...
...
@@ -85,53 +87,166 @@ char *get_charsets_dir(char *buf)
}
static
my_bool
read_charset_index
(
myf
myflags
)
#define MAX_BUF 1024*16
static
void
mstr
(
char
*
str
,
const
char
*
src
,
uint
l1
,
uint
l2
)
{
struct
simpleconfig_buf_st
fb
;
char
buf
[
MAX_LINE
],
num_buf
[
MAX_LINE
]
;
strmov
(
get_charsets_dir
(
buf
),
"Index"
);
l1
=
l1
<
l2
?
l1
:
l2
;
memcpy
(
str
,
src
,
l1
)
;
str
[
l1
]
=
'\0'
;
}
if
((
fb
.
f
=
my_fopen
(
buf
,
O_RDONLY
,
myflags
))
==
NULL
)
return
TRUE
;
fb
.
buf
[
0
]
=
'\0'
;
fb
.
p
=
fb
.
buf
;
struct
my_cs_file_section_st
{
int
state
;
const
char
*
str
;
};
#define _CS_MISC 1
#define _CS_ID 2
#define _CS_NAME 3
#define _CS_FAMILY 4
#define _CS_ORDER 5
#define _CS_COLNAME 6
#define _CS_FLAG 7
#define _CS_CHARSET 8
#define _CS_COLLATION 9
static
struct
my_cs_file_section_st
sec
[]
=
{
{
_CS_MISC
,
"xml"
},
{
_CS_MISC
,
"xml.version"
},
{
_CS_MISC
,
"xml.encoding"
},
{
_CS_MISC
,
"charsets"
},
{
_CS_MISC
,
"charsets.max-id"
},
{
_CS_MISC
,
"charsets.description"
},
{
_CS_CHARSET
,
"charsets.charset"
},
{
_CS_NAME
,
"charsets.charset.name"
},
{
_CS_FAMILY
,
"charsets.charset.family"
},
{
_CS_MISC
,
"charsets.charset.alias"
},
{
_CS_COLLATION
,
"charsets.charset.collation"
},
{
_CS_COLNAME
,
"charsets.charset.collation.name"
},
{
_CS_ID
,
"charsets.charset.collation.id"
},
{
_CS_ORDER
,
"charsets.charset.collation.order"
},
{
_CS_FLAG
,
"charsets.charset.collation.flag"
},
{
0
,
NULL
}
};
static
struct
my_cs_file_section_st
*
cs_file_sec
(
const
char
*
attr
,
uint
len
)
{
struct
my_cs_file_section_st
*
s
;
for
(
s
=
sec
;
s
->
str
;
s
++
)
if
(
!
strncmp
(
attr
,
s
->
str
,
len
))
return
s
;
return
NULL
;
}
struct
my_cs_file_info
{
CHARSET_INFO
cs
;
myf
myflags
;
};
static
int
cs_enter
(
MY_XML_PARSER
*
st
,
const
char
*
attr
,
uint
len
)
{
struct
my_cs_file_info
*
i
=
(
struct
my_cs_file_info
*
)
st
->
user_data
;
struct
my_cs_file_section_st
*
s
=
cs_file_sec
(
attr
,
len
);
while
(
!
get_word
(
&
fb
,
buf
)
&&
!
get_word
(
&
fb
,
num_buf
))
if
(
s
&&
(
s
->
state
==
_CS_CHARSET
))
{
uint
csnum
;
uint
length
;
CHARSET_INFO
*
cs
;
bzero
(
&
i
->
cs
,
sizeof
(
i
->
cs
));
}
return
MY_XML_OK
;
}
if
(
!
(
csnum
=
atoi
(
num_buf
)))
{
/* corrupt Index file */
my_fclose
(
fb
.
f
,
myflags
);
return
TRUE
;
}
if
(
all_charsets
[
csnum
])
continue
;
if
(
!
(
cs
=
(
CHARSET_INFO
*
)
my_once_alloc
(
sizeof
(
cs
[
0
]),
myflags
)))
{
my_fclose
(
fb
.
f
,
myflags
);
return
TRUE
;
}
bzero
(
cs
,
sizeof
(
cs
[
0
]));
if
(
!
(
cs
->
name
=
(
char
*
)
my_once_alloc
(
length
=
(
uint
)
strlen
(
buf
)
+
1
,
myflags
)))
static
int
cs_leave
(
MY_XML_PARSER
*
st
,
const
char
*
attr
,
uint
len
)
{
struct
my_cs_file_info
*
i
=
(
struct
my_cs_file_info
*
)
st
->
user_data
;
struct
my_cs_file_section_st
*
s
=
cs_file_sec
(
attr
,
len
);
if
(
s
&&
(
s
->
state
==
_CS_COLLATION
)
&&
!
all_charsets
[
i
->
cs
.
number
])
{
if
(
!
(
all_charsets
[
i
->
cs
.
number
]
=
(
CHARSET_INFO
*
)
my_once_alloc
(
sizeof
(
CHARSET_INFO
),
i
->
myflags
)))
{
my_fclose
(
fb
.
f
,
myflags
);
return
TRUE
;
return
MY_XML_ERROR
;
}
memcpy
((
char
*
)
cs
->
name
,
buf
,
length
);
cs
->
number
=
csnum
;
all_charsets
[
csnum
]
=
cs
;
all_charsets
[
i
->
cs
.
number
][
0
]
=
i
->
cs
;
}
return
MY_XML_OK
;
}
static
int
cs_value
(
MY_XML_PARSER
*
st
,
const
char
*
attr
,
uint
len
)
{
struct
my_cs_file_info
*
i
=
(
struct
my_cs_file_info
*
)
st
->
user_data
;
struct
my_cs_file_section_st
*
s
;
int
state
=
(
s
=
cs_file_sec
(
st
->
attr
,
strlen
(
st
->
attr
)))
?
s
->
state
:
0
;
if
(
0
)
{
char
str
[
256
];
mstr
(
str
,
attr
,
len
,
sizeof
(
str
)
-
1
);
printf
(
"VALUE %d %s='%s'
\n
"
,
state
,
st
->
attr
,
str
);
}
switch
(
state
)
{
case
_CS_ID
:
i
->
cs
.
number
=
my_strntoul
(
my_charset_latin1
,
attr
,
len
,(
char
**
)
NULL
,
0
);
break
;
case
_CS_COLNAME
:
if
((
i
->
cs
.
name
=
(
char
*
)
my_once_alloc
(
len
+
1
,
i
->
myflags
)))
{
memcpy
((
char
*
)
i
->
cs
.
name
,
attr
,
len
);
((
char
*
)(
i
->
cs
.
name
))[
len
]
=
'\0'
;
}
break
;
}
my_fclose
(
fb
.
f
,
myflags
);
return
MY_XML_OK
;
}
static
my_bool
read_charset_index
(
myf
myflags
)
{
char
*
buf
;
int
fd
;
uint
len
;
MY_XML_PARSER
p
;
struct
my_cs_file_info
i
;
if
(
!
(
buf
=
(
char
*
)
my_malloc
(
MAX_BUF
,
myflags
)))
return
FALSE
;
strmov
(
get_charsets_dir
(
buf
),
MY_CHARSET_INDEX
);
if
((
fd
=
my_open
(
buf
,
O_RDONLY
,
myflags
))
<
0
)
{
my_free
(
buf
,
myflags
);
return
TRUE
;
}
len
=
read
(
fd
,
buf
,
MAX_BUF
);
my_xml_parser_create
(
&
p
);
my_close
(
fd
,
myflags
);
my_xml_set_enter_handler
(
&
p
,
cs_enter
);
my_xml_set_value_handler
(
&
p
,
cs_value
);
my_xml_set_leave_handler
(
&
p
,
cs_leave
);
my_xml_set_user_data
(
&
p
,(
void
*
)
&
i
);
if
(
MY_XML_OK
!=
my_xml_parse
(
&
p
,
buf
,
len
))
{
/*
printf("ERROR at line %d pos %d '%s'\n",
my_xml_error_lineno(&p)+1,
my_xml_error_pos(&p),
my_xml_error_string(&p));
*/
}
my_xml_parser_free
(
&
p
);
return
FALSE
;
}
...
...
@@ -472,7 +587,7 @@ CHARSET_INFO *get_charset(uint cs_number, myf flags)
if
(
!
cs
&&
(
flags
&
MY_WME
))
{
char
index_file
[
FN_REFLEN
],
cs_string
[
23
];
strmov
(
get_charsets_dir
(
index_file
),
"Index"
);
strmov
(
get_charsets_dir
(
index_file
),
MY_CHARSET_INDEX
);
cs_string
[
0
]
=
'#'
;
int10_to_str
(
cs_number
,
cs_string
+
1
,
10
);
my_error
(
EE_UNKNOWN_CHARSET
,
MYF
(
ME_BELL
),
cs_string
,
index_file
);
...
...
@@ -505,7 +620,7 @@ CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags)
if
(
!
cs
&&
(
flags
&
MY_WME
))
{
char
index_file
[
FN_REFLEN
];
strmov
(
get_charsets_dir
(
index_file
),
"Index"
);
strmov
(
get_charsets_dir
(
index_file
),
MY_CHARSET_INDEX
);
my_error
(
EE_UNKNOWN_CHARSET
,
MYF
(
ME_BELL
),
cs_name
,
index_file
);
}
...
...
sql/share/Makefile.am
View file @
389cec7d
...
...
@@ -7,7 +7,7 @@ dist-hook:
done
;
\
sleep
1
;
touch
$(srcdir)
/
*
/errmsg.sys
$(INSTALL_DATA)
$(srcdir)
/charsets/README
$(distdir)
/charsets
$(INSTALL_DATA)
$(srcdir)
/charsets/Index
$(distdir)
/charsets
$(INSTALL_DATA)
$(srcdir)
/charsets/Index
.xml
$(distdir)
/charsets
all
:
@AVAILABLE_LANGUAGES_ERRORS@
...
...
@@ -25,7 +25,7 @@ install-data-local:
done
$(mkinstalldirs)
$(DESTDIR)$(pkgdatadir)
/charsets
$(INSTALL_DATA)
$(srcdir)
/charsets/README
$(DESTDIR)$(pkgdatadir)
/charsets/README
$(INSTALL_DATA)
$(srcdir)
/charsets/Index
$(DESTDIR)$(pkgdatadir)
/charsets/Index
$(INSTALL_DATA)
$(srcdir)
/charsets/Index
.xml
$(DESTDIR)$(pkgdatadir)
/charsets/Index.xml
$(INSTALL_DATA)
$(srcdir)
/charsets/
*
.conf
$(DESTDIR)$(pkgdatadir)
/charsets
fix_errors
:
...
...
sql/share/charsets/Index.xml
0 → 100644
View file @
389cec7d
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment