newline.c

Go to the documentation of this file.
00001 /* autogenerated. */
00002 /* src="transcode-tblgen.rb", len=27499, checksum=52340 */
00003 /* src="newline.trans", len=3162, checksum=42485 */
00004 
00005 #include "transcode_data.h"
00006 
00007 
00008 
00009 static const unsigned char
00010 newline_byte_array[516] = {
00011 #define universal_newline_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,  0,  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 crlf_newline_offsets 258
00031 0, 255,
00032       0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  1,  0,  0,  0,  0,  0,
00033       0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
00034       0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
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,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
00038       0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  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 
00049 };
00050 static const unsigned int
00051 newline_word_array[11] = {
00052 #define universal_newline_infos WORDINDEX2INFO(0)
00053      FUNso,
00054 
00055 #define universal_newline WORDINDEX2INFO(1)
00056     universal_newline_offsets,
00057     universal_newline_infos,
00058 
00059 #define crlf_newline_infos WORDINDEX2INFO(3)
00060              NOMAP, o2(0x0d,0x0a),
00061 
00062 #define crlf_newline WORDINDEX2INFO(5)
00063     crlf_newline_offsets,
00064     crlf_newline_infos,
00065 
00066 #define cr_newline_infos WORDINDEX2INFO(7)
00067         NOMAP, o1(0x0d),
00068 
00069 #define cr_newline WORDINDEX2INFO(9)
00070     crlf_newline_offsets,
00071     cr_newline_infos,
00072 
00073 };
00074 #define TRANSCODE_TABLE_INFO newline_byte_array, 516, newline_word_array, 11, ((int)sizeof(unsigned int))
00075 
00076 
00077 #define STATE (sp[0])
00078 #define NORMAL 0
00079 #define JUST_AFTER_CR 1
00080 
00081 /* no way to access this information, yet. */
00082 #define NEWLINES_MET (sp[1])
00083 #define MET_LF          0x01
00084 #define MET_CRLF        0x02
00085 #define MET_CR          0x04
00086 
00087 static int
00088 universal_newline_init(void *statep)
00089 {
00090     unsigned char *sp = statep;
00091     STATE = NORMAL;
00092     NEWLINES_MET = 0;
00093     return 0;
00094 }
00095 
00096 static ssize_t
00097 fun_so_universal_newline(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
00098 {
00099     unsigned char *sp = statep;
00100     int len;
00101     if (s[0] == '\n') {
00102         if (STATE == NORMAL) {
00103             NEWLINES_MET |= MET_LF;
00104         }
00105         else { /* JUST_AFTER_CR */
00106             NEWLINES_MET |= MET_CRLF;
00107         }
00108         o[0] = '\n';
00109         len = 1;
00110         STATE = NORMAL;
00111     }
00112     else {
00113         len = 0;
00114         if (STATE == JUST_AFTER_CR) {
00115             o[0] = '\n';
00116             len = 1;
00117             NEWLINES_MET |= MET_CR;
00118         }
00119         if (s[0] == '\r') {
00120             STATE = JUST_AFTER_CR;
00121         }
00122         else {
00123             o[len++] = s[0];
00124             STATE = NORMAL;
00125         }
00126     }
00127 
00128     return len;
00129 }
00130 
00131 static ssize_t
00132 universal_newline_finish(void *statep, unsigned char *o, size_t osize)
00133 {
00134     unsigned char *sp = statep;
00135     int len = 0;
00136     if (STATE == JUST_AFTER_CR) {
00137         o[0] = '\n';
00138         len = 1;
00139         NEWLINES_MET |= MET_CR;
00140     }
00141     STATE = NORMAL;
00142     return len;
00143 }
00144 
00145 static const rb_transcoder
00146 rb_universal_newline = {
00147     "", "universal_newline", universal_newline,
00148     TRANSCODE_TABLE_INFO,
00149     1, /* input_unit_length */
00150     1, /* max_input */
00151     2, /* max_output */
00152     asciicompat_converter, /* asciicompat_type */
00153     2, universal_newline_init, universal_newline_init, /* state_size, state_init, state_fini */
00154     NULL, NULL, NULL, fun_so_universal_newline,
00155     universal_newline_finish
00156 };
00157 
00158 static const rb_transcoder
00159 rb_crlf_newline = {
00160     "", "crlf_newline", crlf_newline,
00161     TRANSCODE_TABLE_INFO,
00162     1, /* input_unit_length */
00163     1, /* max_input */
00164     2, /* max_output */
00165     asciicompat_converter, /* asciicompat_type */
00166     0, NULL, NULL, /* state_size, state_init, state_fini */
00167     NULL, NULL, NULL, NULL
00168 };
00169 
00170 static const rb_transcoder
00171 rb_cr_newline = {
00172     "", "cr_newline", cr_newline,
00173     TRANSCODE_TABLE_INFO,
00174     1, /* input_unit_length */
00175     1, /* max_input */
00176     1, /* max_output */
00177     asciicompat_converter, /* asciicompat_type */
00178     0, NULL, NULL, /* state_size, state_init, state_fini */
00179     NULL, NULL, NULL, NULL
00180 };
00181 
00182 void
00183 Init_newline(void)
00184 {
00185     rb_register_transcoder(&rb_universal_newline);
00186     rb_register_transcoder(&rb_crlf_newline);
00187     rb_register_transcoder(&rb_cr_newline);
00188 }
00189 
00190 

Generated on Wed Aug 10 09:16:52 2011 for Ruby by  doxygen 1.4.7