00001
00002
00003
00004
00005 #include "transcode_data.h"
00006
00007
00008
00009 static const unsigned char
00010 escape_byte_array[1055] = {
00011 #define from__to_amp_escape_offsets 0
00012 0, 255,
00013 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00014 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00015 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00016 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00017 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00018 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00019 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00020 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00021 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00022 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00023 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00024 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00025 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00026 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00027 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00028 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00029
00030 #define str1_amp makeSTR1(258)
00031 makeSTR1LEN(5), 0x26, 0x61, 0x6D, 0x70, 0x3B,
00032
00033 #define from__to_xml_text_escape_offsets 264
00034 0, 255,
00035 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00036 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00037 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00038 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0,
00039 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00040 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00041 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00042 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00043 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00044 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00045 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00046 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00047 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00048 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00049 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00050 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00051
00052 #define str1_lt makeSTR1(522)
00053 makeSTR1LEN(4), 0x26, 0x6C, 0x74, 0x3B,
00054
00055 #define str1_gt makeSTR1(527)
00056 makeSTR1LEN(4), 0x26, 0x67, 0x74, 0x3B,
00057
00058 #define from__to_xml_attr_content_escape_offsets 532
00059 0, 255,
00060 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00061 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00062 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00063 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 4, 0,
00064 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00065 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00066 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00067 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00068 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00069 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00070 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00071 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00072 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00073 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00074 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00075 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00076
00077 #define str1_quot makeSTR1(790)
00078 makeSTR1LEN(6), 0x26, 0x71, 0x75, 0x6F, 0x74, 0x3B,
00079
00080 #define escape_xml_attr_quote_offsets 797
00081 0, 255,
00082 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00083 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00084 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00085 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00086 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00087 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00088 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00089 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00090 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00091 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00092 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00093 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00094 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00095 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00096 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00097 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00098
00099 };
00100 static const unsigned int
00101 escape_word_array[20] = {
00102 #define from__to_amp_escape_infos WORDINDEX2INFO(0)
00103 NOMAP, str1_amp,
00104
00105 #define from__to_amp_escape WORDINDEX2INFO(2)
00106 from__to_amp_escape_offsets,
00107 from__to_amp_escape_infos,
00108
00109 #define from__to_xml_text_escape_infos WORDINDEX2INFO(4)
00110 NOMAP, str1_amp, str1_lt, str1_gt,
00111
00112 #define from__to_xml_text_escape WORDINDEX2INFO(8)
00113 from__to_xml_text_escape_offsets,
00114 from__to_xml_text_escape_infos,
00115
00116 #define from__to_xml_attr_content_escape_infos WORDINDEX2INFO(10)
00117 NOMAP, str1_quot, str1_amp, str1_lt,
00118 str1_gt,
00119
00120 #define from__to_xml_attr_content_escape WORDINDEX2INFO(15)
00121 from__to_xml_attr_content_escape_offsets,
00122 from__to_xml_attr_content_escape_infos,
00123
00124 #define escape_xml_attr_quote_infos WORDINDEX2INFO(17)
00125 FUNso,
00126
00127 #define escape_xml_attr_quote WORDINDEX2INFO(18)
00128 escape_xml_attr_quote_offsets,
00129 escape_xml_attr_quote_infos,
00130
00131 };
00132 #define TRANSCODE_TABLE_INFO escape_byte_array, 1055, escape_word_array, 20, ((int)sizeof(unsigned int))
00133 static const rb_transcoder
00134 rb_from__to_amp_escape = {
00135 "", "amp_escape", from__to_amp_escape,
00136 TRANSCODE_TABLE_INFO,
00137 1,
00138 1,
00139 5,
00140 asciicompat_converter,
00141 0, NULL, NULL,
00142 NULL, NULL, NULL, NULL,
00143 NULL, NULL, NULL
00144 };
00145 static const rb_transcoder
00146 rb_from__to_xml_text_escape = {
00147 "", "xml_text_escape", from__to_xml_text_escape,
00148 TRANSCODE_TABLE_INFO,
00149 1,
00150 1,
00151 5,
00152 asciicompat_converter,
00153 0, NULL, NULL,
00154 NULL, NULL, NULL, NULL,
00155 NULL, NULL, NULL
00156 };
00157 static const rb_transcoder
00158 rb_from__to_xml_attr_content_escape = {
00159 "", "xml_attr_content_escape", from__to_xml_attr_content_escape,
00160 TRANSCODE_TABLE_INFO,
00161 1,
00162 1,
00163 6,
00164 asciicompat_converter,
00165 0, NULL, NULL,
00166 NULL, NULL, NULL, NULL,
00167 NULL, NULL, NULL
00168 };
00169
00170
00171 #define END 0
00172 #define NORMAL 1
00173
00174 static int
00175 escape_xml_attr_quote_init(void *statep)
00176 {
00177 unsigned char *sp = statep;
00178 *sp = END;
00179 return 0;
00180 }
00181
00182 static ssize_t
00183 fun_so_escape_xml_attr_quote(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
00184 {
00185 unsigned char *sp = statep;
00186 int n = 0;
00187 if (*sp == END) {
00188 *sp = NORMAL;
00189 o[n++] = '"';
00190 }
00191 o[n++] = s[0];
00192 return n;
00193 }
00194
00195 static ssize_t
00196 escape_xml_attr_quote_finish(void *statep, unsigned char *o, size_t osize)
00197 {
00198 unsigned char *sp = statep;
00199 int n = 0;
00200
00201 if (*sp == END) {
00202 o[n++] = '"';
00203 }
00204
00205 o[n++] = '"';
00206 *sp = END;
00207
00208 return n;
00209 }
00210
00211 static const rb_transcoder
00212 rb_escape_xml_attr_quote = {
00213 "", "xml_attr_quote", escape_xml_attr_quote,
00214 TRANSCODE_TABLE_INFO,
00215 1,
00216 1,
00217 7,
00218 asciicompat_encoder,
00219 1, escape_xml_attr_quote_init, escape_xml_attr_quote_init,
00220 NULL, NULL, NULL, fun_so_escape_xml_attr_quote,
00221 escape_xml_attr_quote_finish
00222 };
00223
00224 void
00225 Init_escape(void)
00226 {
00227 rb_register_transcoder(&rb_from__to_amp_escape);
00228 rb_register_transcoder(&rb_from__to_xml_text_escape);
00229 rb_register_transcoder(&rb_from__to_xml_attr_content_escape);
00230
00231 rb_register_transcoder(&rb_escape_xml_attr_quote);
00232 }
00233
00234
00235