📄 mkdeps.pl
字号:
or err "Can't create \"cesbi.h\" file for writing.\nSystem error message: $!.\n"; print CESBI_H "$comment_automatic\n\n"; print CESBI_H "#ifndef __CESBI_H__\n"; print CESBI_H "#define __CESBI_H__\n\n"; print CESBI_H "#include <newlib.h>\n"; print CESBI_H "#include <_ansi.h>\n"; print CESBI_H "#include \"../lib/encnames.h\"\n"; print CESBI_H "#include \"../lib/ucsconv.h\"\n\n"; print CESBI_H "/*\n"; print CESBI_H " * Enable CES converter if correspondent encoding is requested.\n"; print CESBI_H " * Defining ${macro_to_ucs_ces}XXX macro or ${macro_from_ucs_ces}XXX\n"; print CESBI_H " * macro is needed to enable \"XXX encoding -> UCS\" or \"UCS -> XXX encoding\"\n"; print CESBI_H " * part of UCS-based CES converter.\n"; print CESBI_H " */\n"; foreach my $ces (@ces) { my @encs = sort @{$cesenc{$ces}}; foreach my $encoding (@encs) { print CESBI_H $encoding eq $encs[0] ? "#if " : " || "; print CESBI_H "defined ($macro_from_enc\U$encoding)"; print CESBI_H " \\" if $encoding ne $encs[$#encs]; print CESBI_H "\n"; } print CESBI_H "# define $macro_to_ucs_ces\U$ces\n"; print CESBI_H "#endif\n"; foreach my $encoding (@encs) { print CESBI_H $encoding eq $encs[0] ? "#if " : " || "; print CESBI_H "defined ($macro_to_enc\U$encoding)"; print CESBI_H " \\" if $encoding ne $encs[$#encs]; print CESBI_H "\n"; } print CESBI_H "# define $macro_from_ucs_ces\U$ces\n"; print CESBI_H "#endif\n\n"; } print CESBI_H "/*\n"; print CESBI_H " * Some encodings require another encodings to be enabled.\n"; print CESBI_H " * These dependencies are handled in cesdeps.h header file.\n"; print CESBI_H " */\n"; print CESBI_H "#include \"cesdeps.h\"\n\n"; print CESBI_H "/*\n"; print CESBI_H " * NLS uses iconv's capabilities and require one of encodings\n"; print CESBI_H " * to be enabled for internal wchar_t representation.\n"; print CESBI_H " */\n"; print CESBI_H "#include \"../lib/iconvnls.h\"\n\n"; print CESBI_H "/*\n"; print CESBI_H " * Forward declarations of CES converter handlers.\n"; print CESBI_H " * These handlers are actually defined in correspondent CES converter files.\n"; print CESBI_H " */\n"; foreach my $ces (@ces) { print CESBI_H "#ifdef $macro_to_ucs_ces\U$ces\n"; print CESBI_H "extern _CONST iconv_to_ucs_ces_handlers_t\n"; print CESBI_H "$var_to_ucs_handlers$ces;\n"; print CESBI_H "#endif\n"; print CESBI_H "#ifdef $macro_from_ucs_ces\U$ces\n"; print CESBI_H "extern _CONST iconv_from_ucs_ces_handlers_t\n"; print CESBI_H "$var_from_ucs_handlers$ces;\n"; print CESBI_H "#endif\n\n"; } print CESBI_H "#endif /* !__CESBI_H__ */\n\n"; close CESBI_H or err "Error while closing cesbi.h file.";}# ==============================================================================## Generate encnames.h header file.## Parameters: array of supported encodings.## ==============================================================================sub generate_encnames_h(@){ print "Debug: create \"../lib/encnames.h\" file.\n" if $verbose; open (ENCNAMES_H, '>', "../lib/encnames.h") or err "Can't create \"../lib/encnames.h\" file for writing.\nSystem error message: $!.\n"; print ENCNAMES_H "$comment_automatic\n\n"; print ENCNAMES_H "#ifndef __ENCNAMES_H__\n"; print ENCNAMES_H "#define __ENCNAMES_H__\n\n"; print ENCNAMES_H "/*\n"; print ENCNAMES_H " * Encodings name macros.\n"; print ENCNAMES_H " */\n"; foreach my $enc (sort @_) { print ENCNAMES_H "#define $macro_enc_name\U$enc\E \"$enc\"\n"; } print ENCNAMES_H "\n#endif /* !__ENCNAMES_H__ */\n\n"; close ENCNAMES_H or err "Error while closing ../lib/encnames.h file.";}# ==============================================================================## Generate aliasesbi.c C source file.## Parameters: hash reference with keys = encodings and values = aliases string.## ==============================================================================sub generate_aliasesbi_c($){ print "Debug: create \"../lib/aliasesbi.c\" file.\n" if $verbose; open (ALIASESBI_C, '>', "../lib/aliasesbi.c") or err "Can't create \"../lib/aliasesbi.c\" file for writing.\nSystem error message: $!.\n"; print ALIASESBI_C "$comment_automatic\n\n"; print ALIASESBI_C "#include <_ansi.h>\n"; print ALIASESBI_C "#include \"encnames.h\"\n\n"; print ALIASESBI_C "_CONST char *\n"; print ALIASESBI_C "$var_aliases =\n"; print ALIASESBI_C "{\n"; foreach my $enc (sort keys %{$_[0]}) { print ALIASESBI_C "#if defined ($macro_from_enc\U$enc) \\\n"; print ALIASESBI_C " || defined ($macro_to_enc\U$enc)\n"; print ALIASESBI_C " $macro_enc_name\U$enc\E"; print ALIASESBI_C " \" ${$_[0]}{$enc}\\n\"" if defined ${$_[0]}{$enc}; print ALIASESBI_C "\n"; print ALIASESBI_C "#endif\n"; } print ALIASESBI_C " \"\"\n"; print ALIASESBI_C "};\n\n"; close ALIASESBI_C or err "Error while closing ../lib/aliasesbi.c file.";}# ==============================================================================## Generate encoding.aliases file.## Parameter 1: hash reference with keys = encodings and values = aliases string.## ==============================================================================sub generate_encoding_aliases($){ print "Debug: create \"../encoding.aliases\" file.\n" if $verbose; open (ALIASES, '>', "../encoding.aliases") or err "Can't create \"../encoding.aliases\" file for writing.\nSystem error message: $!.\n"; print ALIASES "#\n# This file was automatically generated. Don't edit.\n#\n\n"; foreach my $enc (sort keys %{$_[0]}) { print ALIASES "$enc"; print ALIASES " ${$_[0]}{$enc}" if defined ${$_[0]}{$enc}; print ALIASES "\n"; } print ALIASES "\n"; close ALIASES or err "Error while closing ./encoding.aliases file.";}# ==============================================================================## Generate cesdeps.h header file.## Parameter 1: hash reference with keys = CES converters and values = references# to arrays with list of CES converters which are needed by that CES converter# (defined by key).## ==============================================================================sub generate_cesdeps_h($){ my %cesdeps = %{$_[0]}; print "Debug: create \"cesdeps.h\" file.\n" if $verbose; open (CESDEPS_H, '>', "cesdeps.h") or err "Can't create \"cesdeps.h\" file for writing.\nSystem error message: $!.\n"; print CESDEPS_H "$comment_automatic\n\n"; print CESDEPS_H "#ifndef __CESDEPS_H__\n"; print CESDEPS_H "#define __CESDEPS_H__\n\n"; print CESDEPS_H "/*\n"; print CESDEPS_H " * Some CES converters use another CES converters and the following\n"; print CESDEPS_H " * is such dependencies description.\n"; print CESDEPS_H " */\n"; foreach my $ces (sort keys %cesdeps) { my @deps = sort @{$cesdeps{$ces}}; print CESDEPS_H "#ifdef $macro_to_ucs_ces\U$ces\n"; foreach my $dep (@deps) { print CESDEPS_H "# ifndef $macro_to_ucs_ces\U$dep\n"; print CESDEPS_H "# define $macro_to_ucs_ces\U$dep\n"; print CESDEPS_H "# endif\n"; } print CESDEPS_H "#endif\n"; print CESDEPS_H "#ifdef $macro_from_ucs_ces\U$ces\n"; foreach my $dep (@deps) { print CESDEPS_H "# ifndef $macro_from_ucs_ces\U$dep\n"; print CESDEPS_H "# define $macro_from_ucs_ces\U$dep\n"; print CESDEPS_H "# endif\n"; } print CESDEPS_H "#endif\n"; } print CESDEPS_H "\n#endif /* !__CESDEPS_H__ */\n\n"; close CESDEPS_H or err "Error while closing cesdeps.h file.";}# ==============================================================================## Generate ccsbi.h file.## Parameter 1 (input): hash reference with keys = CCS tables names and# values = array references with list of encodings which need this CCS table.## ==============================================================================sub generate_ccsbi_h($){ my %ccsenc = %{$_[0]}; my @ccs = sort keys %ccsenc; print "Debug: create \"../ccs/ccsbi.h\" file.\n" if $verbose; open (CCSBI_H, '>', "../ccs/ccsbi.h") or err "Can't create \"../ccs/ccsbi.h\" file for writing.\nSystem error message: $!.\n"; print CCSBI_H "$comment_automatic\n\n"; print CCSBI_H "#ifndef __CCSBI_H__\n"; print CCSBI_H "#define __CCSBI_H__\n\n"; print CCSBI_H "#include <newlib.h>\n"; print CCSBI_H "#include <_ansi.h>\n"; print CCSBI_H "#include \"ccs.h\"\n\n"; print CCSBI_H "/*\n"; print CCSBI_H " * Enable CCS tables if encoding needs them.\n"; print CCSBI_H " * Defining ${macro_to_ucs_ccs}XXX macro or ${macro_from_ucs_ccs}XXX\n"; print CCSBI_H " * macro is needed to enable \"XXX encoding -> UCS\" or \"UCS -> XXX encoding\"\n"; print CCSBI_H " * part of CCS table.\n"; print CCSBI_H " * CCS tables aren't linked if Newlib was configuted to use external CCS tables.\n"; print CCSBI_H " */\n"; print CCSBI_H "#ifndef _ICONV_ENABLE_EXTERNAL_CCS\n\n"; foreach my $ccs (@ccs) { my @encs = sort @{$ccsenc{$ccs}}; foreach my $encoding (@encs) { print CCSBI_H $encoding eq $encs[0] ? "#if " : " || "; print CCSBI_H "defined ($macro_from_enc\U$encoding)"; print CCSBI_H " \\" if $encoding ne $encs[$#encs]; print CCSBI_H "\n"; } print CCSBI_H "# define $macro_to_ucs_ccs\U$ccs\n"; print CCSBI_H "#endif\n"; foreach my $encoding (@encs) { print CCSBI_H $encoding eq $encs[0] ? "#if " : " || "; print CCSBI_H "defined ($macro_to_enc\U$encoding)"; print CCSBI_H " \\" if $encoding ne $encs[$#encs]; print CCSBI_H "\n"; } print CCSBI_H "# define $macro_from_ucs_ccs\U$ccs\n"; print CCSBI_H "#endif\n\n"; } print CCSBI_H "/*\n"; print CCSBI_H " * CCS table description structures forward declarations.\n"; print CCSBI_H " */\n"; foreach my $ccs (@ccs) { print CCSBI_H "#if defined ($macro_to_ucs_ccs\U$ccs) \\\n"; print CCSBI_H " || defined ($macro_from_ucs_ccs\U$ccs)\n"; print CCSBI_H "extern _CONST iconv_ccs_t\n"; print CCSBI_H "$var_ccs$ccs;\n"; print CCSBI_H "#endif\n"; } print CCSBI_H "\n#endif /* !_ICONV_ENABLE_EXTERNAL_CCS */\n\n"; print CCSBI_H "\n#endif /* __CCSBI_H__ */\n\n"; close CCSBI_H or err "Error while closing ../ccs/ccsbi.h file.";}# ==============================================================================## Generate cesbi.c file.## Parameter 1 (input): hash reference with keys = CES Converters names and# values = array references with list of supported encodings.## ==============================================================================sub generate_cesbi_c($){ my %cesenc = %{$_[0]}; my @ces = sort keys %cesenc; print "Debug: create \"cesbi.c\" file.\n" if $verbose; open (CESBI_C, '>', "cesbi.c") or err "Can't create \"cesbi.c\" file for writing.\nSystem error message: $!.\n"; print CESBI_C "$comment_automatic\n\n"; print CESBI_C "#include <_ansi.h>\n"; print CESBI_C "#include <newlib.h>\n"; print CESBI_C "#include \"../lib/ucsconv.h\"\n"; print CESBI_C "#include \"cesbi.h\"\n\n"; print CESBI_C "/*\n"; print CESBI_C " * Each CES converter provides the list of supported encodings.\n"; print CESBI_C " */\n"; foreach my $ces (@ces) { print CESBI_C "#if defined ($macro_to_ucs_ces\U$ces) \\\n"; print CESBI_C " || defined ($macro_from_ucs_ces\U$ces)\n"; print CESBI_C "static _CONST char *\n"; print CESBI_C "$var_ces_names${ces}\[] =\n"; print CESBI_C "{\n"; my @encodings = sort @{$cesenc{$ces}}; foreach my $encoding (@encodings) { print CESBI_C "# if defined ($macro_from_enc\U$encoding) \\\n"; print CESBI_C " || defined ($macro_to_enc\U$encoding)\n"; print CESBI_C " $macro_enc_name\U$encoding,\n"; print CESBI_C "#endif\n"; } print CESBI_C " NULL\n"; print CESBI_C "};\n"; print CESBI_C "#endif\n\n"; } print CESBI_C "/*\n"; print CESBI_C " * The following structure contains the list of \"to UCS\" linked-in CES converters.\n"; print CESBI_C " */\n"; print CESBI_C "_CONST iconv_to_ucs_ces_t\n"; print CESBI_C "_iconv_to_ucs_ces[] =\n"; print CESBI_C "{\n"; foreach my $ces (@ces) { print CESBI_C "#ifdef $macro_to_ucs_ces\U$ces\n"; print CESBI_C " {(_CONST char **)$var_ces_names$ces,\n"; print CESBI_C " &$var_to_ucs_handlers$ces},\n"; print CESBI_C "#endif\n"; } print CESBI_C " {(_CONST char **)NULL,\n"; print CESBI_C " (iconv_to_ucs_ces_handlers_t *)NULL}\n"; print CESBI_C "};\n\n"; print CESBI_C "/*\n"; print CESBI_C " * The following structure contains the list of \"from UCS\" linked-in CES converters.\n"; print CESBI_C " */\n"; print CESBI_C "_CONST iconv_from_ucs_ces_t\n"; print CESBI_C "_iconv_from_ucs_ces[] =\n"; print CESBI_C "{\n"; foreach my $ces (@ces) { print CESBI_C "#ifdef $macro_from_ucs_ces\U$ces\n"; print CESBI_C " {(_CONST char **)$var_ces_names$ces,\n"; print CESBI_C " &$var_from_ucs_handlers$ces},\n"; print CESBI_C "#endif\n"; } print CESBI_C " {(_CONST char **)NULL,\n"; print CESBI_C " (iconv_from_ucs_ces_handlers_t *)NULL}\n"; print CESBI_C "};\n"; close CESBI_C or err "Error while closing cesbi.c file.";}# ==============================================================================## Generate ccsbi.c file.## Parameter 1 (input): array reference with CCS tables names## ==============================================================================sub generate_ccsbi_c($){ my @ccs = @{$_[0]}; print "Debug: create \"../ccs/ccsbi.c\" file.\n" if $verbose; open (CESBI_C, '>', "../ccs/ccsbi.c") or err "Can't create \"../ccs/ccsbi.c\" file for writing.\nSystem error message: $!.\n"; print CESBI_C "$comment_automatic\n\n"; print CESBI_C "#include <_ansi.h>\n"; print CESBI_C "#include \"ccsbi.h\"\n\n"; print CESBI_C "/*\n"; print CESBI_C " * The following array contains the list of built-in CCS tables.\n"; print CESBI_C " */\n"; print CESBI_C "_CONST iconv_ccs_t *\n"; print CESBI_C "_iconv_ccs[] =\n"; print CESBI_C "{\n"; foreach my $ccs (@ccs) { print CESBI_C "#if defined ($macro_to_ucs_ccs\U$ccs) \\\n"; print CESBI_C " || defined ($macro_from_ucs_ccs\U$ccs)\n"; print CESBI_C " &$var_ccs$ccs,\n"; print CESBI_C "#endif\n"; } print CESBI_C " NULL\n"; print CESBI_C "};\n"; close CESBI_C or err "Error while closing ../ccs/ccsbi.c file.";}# ==============================================================================## Generate ccsnames.h file.## Parameter 1 (input): hash reference with keys = CCS tables names and# values = array references with list of encodings which need this CCS table.## ==============================================================================sub generate_ccsnames_h($){ my %ccsenc = %{$_[0]}; my @ccs = sort keys %ccsenc; print "Debug: create \"../ccs/ccsnames.h\" file.\n" if $verbose; open (CCSNAMES_H, '>', "../ccs/ccsnames.h") or err "Can't create \"../ccs/ccsnames.h\" file for writing.\nSystem error message: $!.\n"; print CCSNAMES_H "$comment_automatic\n\n"; print CCSNAMES_H "#ifndef __CCSNAMES_H__\n"; print CCSNAMES_H "#define __CCSNAMES_H__\n\n"; print CCSNAMES_H "#include \"../lib/encnames.h\"\n\n"; print CCSNAMES_H "/*\n"; print CCSNAMES_H " * CCS tables names macros.\n"; print CCSNAMES_H " */\n"; foreach my $ccs (@ccs) { my @encs = @{$ccsenc{$ccs}}; my $flag; foreach my $encoding (@encs) { print CCSNAMES_H "#define $macro_ccs_name\U$ccs "; if ($encoding eq $ccs) { $flag = 1; print CCSNAMES_H "$macro_enc_name\U$encoding\n"; last; } } print CCSNAMES_H "\"$ccs\"\n" if !$flag; } print CCSNAMES_H "\n#endif /* !__CCSNAMES_H__ */\n\n"; close CCSNAMES_H or err "Error while closing ../ccs/ccsnames.h file.";}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -