Ruby  1.9.3p448(2013-06-27revision41675)
newline.c
Go to the documentation of this file.
1 /* autogenerated. */
2 /* src="transcode-tblgen.rb", len=28123, checksum=30477 */
3 /* src="newline.trans", len=3162, checksum=42485 */
4 
5 #include "transcode_data.h"
6 
7 
8 
9 static const unsigned char
11 #define universal_newline_offsets 0
12 0, 255,
13  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
24  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
25  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
26  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
27  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
28  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29 
30 #define crlf_newline_offsets 258
31 0, 255,
32  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
33  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
35  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
37  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
38  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
39  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
40  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
41  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
43  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48 
49 };
50 static const unsigned int
52 #define universal_newline_infos WORDINDEX2INFO(0)
53  FUNso,
54 
55 #define universal_newline WORDINDEX2INFO(1)
58 
59 #define crlf_newline_infos WORDINDEX2INFO(3)
60  NOMAP, o2(0x0d,0x0a),
61 
62 #define crlf_newline WORDINDEX2INFO(5)
65 
66 #define cr_newline_infos WORDINDEX2INFO(7)
67  NOMAP, o1(0x0d),
68 
69 #define cr_newline WORDINDEX2INFO(9)
72 
73 };
74 #define TRANSCODE_TABLE_INFO newline_byte_array, 516, newline_word_array, 11, ((int)sizeof(unsigned int))
75 
76 
77 #define STATE (sp[0])
78 #define NORMAL 0
79 #define JUST_AFTER_CR 1
80 
81 /* no way to access this information, yet. */
82 #define NEWLINES_MET (sp[1])
83 #define MET_LF 0x01
84 #define MET_CRLF 0x02
85 #define MET_CR 0x04
86 
87 static int
89 {
90  unsigned char *sp = statep;
91  STATE = NORMAL;
92  NEWLINES_MET = 0;
93  return 0;
94 }
95 
96 static ssize_t
97 fun_so_universal_newline(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
98 {
99  unsigned char *sp = statep;
100  int len;
101  if (s[0] == '\n') {
102  if (STATE == NORMAL) {
103  NEWLINES_MET |= MET_LF;
104  }
105  else { /* JUST_AFTER_CR */
107  }
108  o[0] = '\n';
109  len = 1;
110  STATE = NORMAL;
111  }
112  else {
113  len = 0;
114  if (STATE == JUST_AFTER_CR) {
115  o[0] = '\n';
116  len = 1;
117  NEWLINES_MET |= MET_CR;
118  }
119  if (s[0] == '\r') {
121  }
122  else {
123  o[len++] = s[0];
124  STATE = NORMAL;
125  }
126  }
127 
128  return len;
129 }
130 
131 static ssize_t
132 universal_newline_finish(void *statep, unsigned char *o, size_t osize)
133 {
134  unsigned char *sp = statep;
135  int len = 0;
136  if (STATE == JUST_AFTER_CR) {
137  o[0] = '\n';
138  len = 1;
139  NEWLINES_MET |= MET_CR;
140  }
141  STATE = NORMAL;
142  return len;
143 }
144 
145 static const rb_transcoder
147  "", "universal_newline", universal_newline,
149  1, /* input_unit_length */
150  1, /* max_input */
151  2, /* max_output */
152  asciicompat_converter, /* asciicompat_type */
153  2, universal_newline_init, universal_newline_init, /* state_size, state_init, state_fini */
156 };
157 
158 static const rb_transcoder
160  "", "crlf_newline", crlf_newline,
162  1, /* input_unit_length */
163  1, /* max_input */
164  2, /* max_output */
165  asciicompat_converter, /* asciicompat_type */
166  0, NULL, NULL, /* state_size, state_init, state_fini */
167  NULL, NULL, NULL, NULL
168 };
169 
170 static const rb_transcoder
172  "", "cr_newline", cr_newline,
174  1, /* input_unit_length */
175  1, /* max_input */
176  1, /* max_output */
177  asciicompat_converter, /* asciicompat_type */
178  0, NULL, NULL, /* state_size, state_init, state_fini */
179  NULL, NULL, NULL, NULL
180 };
181 
182 void
184 {
188 }
189 
#define o2(b1, b2)
#define NOMAP
#define universal_newline
#define NORMAL
Definition: newline.c:78
static int universal_newline_init(void *statep)
Definition: newline.c:88
static ssize_t universal_newline_finish(void *statep, unsigned char *o, size_t osize)
Definition: newline.c:132
#define universal_newline_infos
#define JUST_AFTER_CR
Definition: newline.c:79
static const rb_transcoder rb_universal_newline
Definition: newline.c:146
#define cr_newline_infos
#define crlf_newline_infos
static const rb_transcoder rb_crlf_newline
Definition: newline.c:159
void Init_newline(void)
Definition: newline.c:183
#define crlf_newline_offsets
static const rb_transcoder rb_cr_newline
Definition: newline.c:171
void rb_register_transcoder(const rb_transcoder *tr)
Definition: transcode.c:205
#define FUNso
static const unsigned int newline_word_array[11]
Definition: newline.c:51
static ssize_t fun_so_universal_newline(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
Definition: newline.c:97
#define NULL
#define MET_CRLF
Definition: newline.c:84
#define NEWLINES_MET
Definition: newline.c:82
register unsigned int len
Definition: name2ctype.h:22210
#define TRANSCODE_TABLE_INFO
Definition: newline.c:74
#define o1(b1)
#define crlf_newline
#define cr_newline
#define universal_newline_offsets
#define MET_CR
Definition: newline.c:85
static const unsigned char newline_byte_array[516]
Definition: newline.c:10
#define STATE
Definition: newline.c:77
#define MET_LF
Definition: newline.c:83