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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
b9e9c4ae
Commit
b9e9c4ae
authored
Jan 29, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf_to_src.c:
Getting closer strings/conf_to_src.c: Getting closer
parent
83a52d60
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
143 deletions
+91
-143
strings/conf_to_src.c
strings/conf_to_src.c
+91
-143
No files found.
strings/conf_to_src.c
View file @
b9e9c4ae
...
...
@@ -14,8 +14,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* can't use -lmysys because this prog is used to create -lstrings */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -32,93 +30,27 @@
#define TO_LOWER_TABLE_SIZE 256
#define TO_UPPER_TABLE_SIZE 256
#define SORT_ORDER_TABLE_SIZE 256
#define ROW_LEN 16
char
*
prog
;
char
buf
[
1024
],
*
p
,
*
endptr
;
#define MAX_BUF 16*1024
static
CHARSET_INFO
all_charsets
[
256
];
void
print_array
(
FILE
*
f
,
const
char
*
set
,
const
char
*
name
,
int
n
)
print_array
(
FILE
*
f
,
const
char
*
set
,
const
char
*
name
,
uchar
*
a
,
int
n
)
{
int
i
;
char
val
[
100
];
printf
(
"uchar %s_%s[] = {
\n
"
,
name
,
set
);
fprintf
(
f
,
"uchar %s_%s[] = {
\n
"
,
name
,
set
);
p
=
buf
;
*
buf
=
'\0'
;
for
(
i
=
0
;
i
<
n
;
++
i
)
{
/* get a word from f */
endptr
=
p
;
for
(;;)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
while
(
isspace
((
*
(
unsigned
char
*
)
endptr
)))
++
endptr
;
if
(
*
endptr
&&
*
endptr
!=
'#'
)
/* not comment */
break
;
if
((
fgets
(
buf
,
sizeof
(
buf
),
f
))
==
NULL
)
return
;
/* XXX: break silently */
endptr
=
buf
;
}
p
=
val
;
while
(
!
isspace
((
*
(
unsigned
char
*
)
endptr
)))
*
p
++
=
*
endptr
++
;
*
p
=
'\0'
;
p
=
endptr
;
/* write the value out */
if
(
i
==
0
||
i
%
ROW_LEN
==
n
%
ROW_LEN
)
printf
(
" "
);
printf
(
"%3d"
,
(
unsigned
char
)
strtol
(
val
,
(
char
**
)
NULL
,
16
));
if
(
i
<
n
-
1
)
printf
(
","
);
if
((
i
+
1
)
%
ROW_LEN
==
n
%
ROW_LEN
)
printf
(
"
\n
"
);
}
printf
(
"};
\n\n
"
);
}
void
print_arrays_for
(
char
*
set
)
{
FILE
*
f
;
sprintf
(
buf
,
"%s.conf"
,
set
);
if
((
f
=
fopen
(
buf
,
"r"
))
==
NULL
)
{
fprintf
(
stderr
,
"%s: can't read conf file for charset %s
\n
"
,
prog
,
set
);
exit
(
EXIT_FAILURE
);
fprintf
(
f
,
"0x%02X%s%s"
,
a
[
i
],
(
i
+
1
<
n
)
?
","
:
""
,
i
%
16
?
""
:
"
\n
"
);
}
printf
(
"\
/* The %s character set. Generated automatically by
\n
\
* the %s program
\n
\
*/
\n\n
"
,
set
,
prog
);
/* it would be nice if this used the code in mysys/charset.c, but... */
print_array
(
f
,
set
,
"ctype"
,
CTYPE_TABLE_SIZE
);
print_array
(
f
,
set
,
"to_lower"
,
TO_LOWER_TABLE_SIZE
);
print_array
(
f
,
set
,
"to_upper"
,
TO_UPPER_TABLE_SIZE
);
print_array
(
f
,
set
,
"sort_order"
,
SORT_ORDER_TABLE_SIZE
);
printf
(
"
\n
"
);
fclose
(
f
);
return
;
fprintf
(
f
,
"};
\n\n
"
);
}
#define MAX_BUF 16*1024
static
CHARSET_INFO
all_charsets
[
256
];
static
int
get_charset_number
(
const
char
*
charset_name
)
{
...
...
@@ -207,7 +139,7 @@ static int my_read_charset_file(const char *filename)
if
((
fd
=
open
(
filename
,
O_RDONLY
))
<
0
)
{
printf
(
"Can't open '%s'
\n
"
,
filename
);
fprintf
(
stderr
,
"Can't open '%s'
\n
"
,
filename
);
return
1
;
}
...
...
@@ -227,69 +159,69 @@ static int my_read_charset_file(const char *filename)
return
FALSE
;
}
void
dispcset
(
CHARSET_INFO
*
cs
)
void
dispcset
(
FILE
*
f
,
CHARSET_INFO
*
cs
)
{
printf
(
"{
\n
"
);
printf
(
" %d,
\n
"
,
cs
->
number
);
printf
(
" MY_CS_COMPILED,
\n
"
);
fprintf
(
f
,
"{
\n
"
);
fprintf
(
f
,
" %d,
\n
"
,
cs
->
number
);
fprintf
(
f
,
" MY_CS_COMPILED,
\n
"
);
if
(
cs
->
name
)
{
printf
(
"
\"
%s
\"
,
\n
"
,
cs
->
name
);
printf
(
"
\"
%s
\"
,
\n
"
,
cs
->
csname
);
printf
(
"
\"\"
,
\n
"
);
printf
(
" ctype_%s,
\n
"
,
cs
->
name
);
printf
(
" to_lower_%s,
\n
"
,
cs
->
name
);
printf
(
" to_upper_%s,
\n
"
,
cs
->
name
);
printf
(
" sort_order_%s,
\n
"
,
cs
->
name
);
printf
(
" to_uni_%s,
\n
"
,
cs
->
name
);
printf
(
" from_uni_%s,
\n
"
,
cs
->
name
);
fprintf
(
f
,
"
\"
%s
\"
,
\n
"
,
cs
->
name
);
fprintf
(
f
,
"
\"
%s
\"
,
\n
"
,
cs
->
csname
);
fprintf
(
f
,
"
\"\"
,
\n
"
);
fprintf
(
f
,
" ctype_%s,
\n
"
,
cs
->
name
);
fprintf
(
f
,
" to_lower_%s,
\n
"
,
cs
->
name
);
fprintf
(
f
,
" to_upper_%s,
\n
"
,
cs
->
name
);
fprintf
(
f
,
" sort_order_%s,
\n
"
,
cs
->
name
);
fprintf
(
f
,
" to_uni_%s,
\n
"
,
cs
->
name
);
fprintf
(
f
,
" from_uni_%s,
\n
"
,
cs
->
name
);
}
else
{
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
}
printf
(
" %d,
\n
"
,
cs
->
strxfrm_multiply
);
printf
(
" my_strnncoll_simple,
\n
"
);
printf
(
" my_strnxfrm_simple,
\n
"
);
printf
(
" my_like_range_simple,
\n
"
);
printf
(
" my_wild_cmp_8bit,
\n
"
);
printf
(
" %d,
\n
"
,
cs
->
mbmaxlen
);
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
printf
(
" NULL,
\n
"
);
printf
(
" my_mb_wc_8bit,
\n
"
);
printf
(
" my_wc_mb_8bit,
\n
"
);
printf
(
" my_caseup_str_8bit,
\n
"
);
printf
(
" my_casedn_str_8bit,
\n
"
);
printf
(
" my_caseup_8bit,
\n
"
);
printf
(
" my_casedn_8bit,
\n
"
);
printf
(
" my_tosort_8bit,
\n
"
);
printf
(
" my_strcasecmp_8bit,
\n
"
);
printf
(
" my_strncasecmp_8bit,
\n
"
);
printf
(
" my_hash_caseup_simple,
\n
"
);
printf
(
" my_hash_sort_simple,
\n
"
);
printf
(
" 0,
\n
"
);
printf
(
" my_snprintf_8bit,
\n
"
);
printf
(
" my_long10_to_str_8bit,
\n
"
);
printf
(
" my_longlong10_to_str_8bit,
\n
"
);
printf
(
" my_fill_8bit,
\n
"
);
printf
(
" my_strntol_8bit,
\n
"
);
printf
(
" my_strntoul_8bit,
\n
"
);
printf
(
" my_strntoll_8bit,
\n
"
);
printf
(
" my_strntoull_8bit,
\n
"
);
printf
(
" my_strntod_8bit,
\n
"
);
printf
(
" my_scan_8bit
\n
"
);
printf
(
"}
\n
"
);
fprintf
(
f
,
" %d,
\n
"
,
cs
->
strxfrm_multiply
);
fprintf
(
f
,
" my_strnncoll_simple,
\n
"
);
fprintf
(
f
,
" my_strnxfrm_simple,
\n
"
);
fprintf
(
f
,
" my_like_range_simple,
\n
"
);
fprintf
(
f
,
" my_wild_cmp_8bit,
\n
"
);
fprintf
(
f
,
" %d,
\n
"
,
cs
->
mbmaxlen
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" NULL,
\n
"
);
fprintf
(
f
,
" my_mb_wc_8bit,
\n
"
);
fprintf
(
f
,
" my_wc_mb_8bit,
\n
"
);
fprintf
(
f
,
" my_caseup_str_8bit,
\n
"
);
fprintf
(
f
,
" my_casedn_str_8bit,
\n
"
);
fprintf
(
f
,
" my_caseup_8bit,
\n
"
);
fprintf
(
f
,
" my_casedn_8bit,
\n
"
);
fprintf
(
f
,
" my_tosort_8bit,
\n
"
);
fprintf
(
f
,
" my_strcasecmp_8bit,
\n
"
);
fprintf
(
f
,
" my_strncasecmp_8bit,
\n
"
);
fprintf
(
f
,
" my_hash_caseup_simple,
\n
"
);
fprintf
(
f
,
" my_hash_sort_simple,
\n
"
);
fprintf
(
f
,
" 0,
\n
"
);
fprintf
(
f
,
" my_snprintf_8bit,
\n
"
);
fprintf
(
f
,
" my_long10_to_str_8bit,
\n
"
);
fprintf
(
f
,
" my_longlong10_to_str_8bit,
\n
"
);
fprintf
(
f
,
" my_fill_8bit,
\n
"
);
fprintf
(
f
,
" my_strntol_8bit,
\n
"
);
fprintf
(
f
,
" my_strntoul_8bit,
\n
"
);
fprintf
(
f
,
" my_strntoll_8bit,
\n
"
);
fprintf
(
f
,
" my_strntoull_8bit,
\n
"
);
fprintf
(
f
,
" my_strntod_8bit,
\n
"
);
fprintf
(
f
,
" my_scan_8bit
\n
"
);
fprintf
(
f
,
"}
\n
"
);
}
...
...
@@ -299,6 +231,7 @@ main(int argc, char **argv __attribute__((unused)))
CHARSET_INFO
ncs
;
CHARSET_INFO
*
cs
;
char
filename
[
256
];
FILE
*
f
=
stdout
;
if
(
argc
<
2
)
{
...
...
@@ -312,7 +245,6 @@ main(int argc, char **argv __attribute__((unused)))
sprintf
(
filename
,
"%s/%s"
,
argv
[
1
],
"Index.xml"
);
my_read_charset_file
(
filename
);
printf
(
"CHARSET_INFO compiled_charsets[] = {
\n
"
);
for
(
cs
=
all_charsets
;
cs
<
all_charsets
+
256
;
cs
++
)
{
if
(
cs
->
number
)
...
...
@@ -322,19 +254,35 @@ main(int argc, char **argv __attribute__((unused)))
sprintf
(
filename
,
"%s/%s.xml"
,
argv
[
1
],
cs
->
csname
);
my_read_charset_file
(
filename
);
}
}
}
if
(
simple_cs_is_full
)
for
(
cs
=
all_charsets
;
cs
<
all_charsets
+
256
;
cs
++
)
{
printf
(
"#ifdef HAVE_CHARSET_%s
\n
"
,
cs
->
csname
);
dispcset
(
cs
);
printf
(
",
\n
"
);
printf
(
"#endif
\n
"
);
if
(
simple_cs_is_full
(
cs
))
{
print_array
(
f
,
cs
->
name
,
"ctype"
,
cs
->
ctype
,
CTYPE_TABLE_SIZE
);
print_array
(
f
,
cs
->
name
,
"to_lower"
,
cs
->
to_lower
,
TO_LOWER_TABLE_SIZE
);
print_array
(
f
,
cs
->
name
,
"to_upper"
,
cs
->
to_upper
,
TO_UPPER_TABLE_SIZE
);
print_array
(
f
,
cs
->
name
,
"sort_order"
,
cs
->
sort_order
,
SORT_ORDER_TABLE_SIZE
);
fprintf
(
f
,
"
\n
"
);
}
}
fprintf
(
f
,
"CHARSET_INFO compiled_charsets[] = {
\n
"
);
for
(
cs
=
all_charsets
;
cs
<
all_charsets
+
256
;
cs
++
)
{
if
(
simple_cs_is_full
(
cs
))
{
fprintf
(
f
,
"#ifdef HAVE_CHARSET_%s
\n
"
,
cs
->
csname
);
dispcset
(
f
,
cs
);
fprintf
(
f
,
",
\n
"
);
fprintf
(
f
,
"#endif
\n
"
);
}
}
dispcset
(
&
ncs
);
printf
(
"};
\n
"
);
dispcset
(
f
,
&
ncs
);
fprintf
(
f
,
"};
\n
"
);
return
0
;
}
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