line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
#include "yaml_private.h" |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
/* |
5
|
|
|
|
|
|
|
* Flush the buffer if needed. |
6
|
|
|
|
|
|
|
*/ |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#define FLUSH(emitter) \ |
9
|
|
|
|
|
|
|
((emitter->buffer.pointer+5 < emitter->buffer.end) \ |
10
|
|
|
|
|
|
|
|| yaml_emitter_flush(emitter)) |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
/* |
13
|
|
|
|
|
|
|
* Put a character to the output buffer. |
14
|
|
|
|
|
|
|
*/ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#define PUT(emitter,value) \ |
17
|
|
|
|
|
|
|
(FLUSH(emitter) \ |
18
|
|
|
|
|
|
|
&& (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \ |
19
|
|
|
|
|
|
|
emitter->column++, \ |
20
|
|
|
|
|
|
|
1)) |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
/* |
23
|
|
|
|
|
|
|
* Put a line break to the output buffer. |
24
|
|
|
|
|
|
|
*/ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#define PUT_BREAK(emitter) \ |
27
|
|
|
|
|
|
|
(FLUSH(emitter) \ |
28
|
|
|
|
|
|
|
&& ((emitter->line_break == YAML_CR_BREAK ? \ |
29
|
|
|
|
|
|
|
(*(emitter->buffer.pointer++) = (yaml_char_t) '\r') : \ |
30
|
|
|
|
|
|
|
emitter->line_break == YAML_LN_BREAK ? \ |
31
|
|
|
|
|
|
|
(*(emitter->buffer.pointer++) = (yaml_char_t) '\n') : \ |
32
|
|
|
|
|
|
|
emitter->line_break == YAML_CRLN_BREAK ? \ |
33
|
|
|
|
|
|
|
(*(emitter->buffer.pointer++) = (yaml_char_t) '\r', \ |
34
|
|
|
|
|
|
|
*(emitter->buffer.pointer++) = (yaml_char_t) '\n') : 0), \ |
35
|
|
|
|
|
|
|
emitter->column = 0, \ |
36
|
|
|
|
|
|
|
emitter->line ++, \ |
37
|
|
|
|
|
|
|
1)) |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
/* returning nothing */ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#define PUT_BREAK_void(emitter) \ |
42
|
|
|
|
|
|
|
(emitter->line_break == YAML_CR_BREAK ? \ |
43
|
|
|
|
|
|
|
(*(emitter->buffer.pointer++) = (yaml_char_t) '\r') : \ |
44
|
|
|
|
|
|
|
emitter->line_break == YAML_LN_BREAK ? \ |
45
|
|
|
|
|
|
|
(*(emitter->buffer.pointer++) = (yaml_char_t) '\n') : \ |
46
|
|
|
|
|
|
|
emitter->line_break == YAML_CRLN_BREAK ? \ |
47
|
|
|
|
|
|
|
(*(emitter->buffer.pointer++) = (yaml_char_t) '\r', \ |
48
|
|
|
|
|
|
|
*(emitter->buffer.pointer++) = (yaml_char_t) '\n') : 0, \ |
49
|
|
|
|
|
|
|
emitter->column = 0, \ |
50
|
|
|
|
|
|
|
emitter->line ++ \ |
51
|
|
|
|
|
|
|
) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
/* |
54
|
|
|
|
|
|
|
* Copy a character from a string into buffer. |
55
|
|
|
|
|
|
|
*/ |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#define WRITE(emitter,string) \ |
58
|
|
|
|
|
|
|
(FLUSH(emitter) \ |
59
|
|
|
|
|
|
|
&& (COPY(emitter->buffer,string), \ |
60
|
|
|
|
|
|
|
emitter->column ++, \ |
61
|
|
|
|
|
|
|
1)) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
/* |
64
|
|
|
|
|
|
|
* Copy a line break character from a string into buffer. |
65
|
|
|
|
|
|
|
*/ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#define WRITE_BREAK(emitter,string) \ |
68
|
|
|
|
|
|
|
(FLUSH(emitter) \ |
69
|
|
|
|
|
|
|
&& (CHECK(string,'\n') ? \ |
70
|
|
|
|
|
|
|
(PUT_BREAK_void(emitter), \ |
71
|
|
|
|
|
|
|
string.pointer ++, \ |
72
|
|
|
|
|
|
|
1) : \ |
73
|
|
|
|
|
|
|
(COPY(emitter->buffer,string), \ |
74
|
|
|
|
|
|
|
emitter->column = 0, \ |
75
|
|
|
|
|
|
|
emitter->line ++, \ |
76
|
|
|
|
|
|
|
1))) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
/* |
79
|
|
|
|
|
|
|
* API functions: see yaml.h |
80
|
|
|
|
|
|
|
*/ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
/* |
83
|
|
|
|
|
|
|
* Utility functions. |
84
|
|
|
|
|
|
|
*/ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
static int |
87
|
|
|
|
|
|
|
yaml_emitter_set_emitter_error(yaml_emitter_t *emitter, const char *problem); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
static int |
90
|
|
|
|
|
|
|
yaml_emitter_need_more_events(yaml_emitter_t *emitter); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
static int |
93
|
|
|
|
|
|
|
yaml_emitter_append_tag_directive(yaml_emitter_t *emitter, |
94
|
|
|
|
|
|
|
yaml_tag_directive_t value, int allow_duplicates); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
static int |
97
|
|
|
|
|
|
|
yaml_emitter_increase_indent(yaml_emitter_t *emitter, |
98
|
|
|
|
|
|
|
int flow, int indentless); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
/* |
101
|
|
|
|
|
|
|
* State functions. |
102
|
|
|
|
|
|
|
*/ |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
static int |
105
|
|
|
|
|
|
|
yaml_emitter_state_machine(yaml_emitter_t *emitter, yaml_event_t *event); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
static int |
108
|
|
|
|
|
|
|
yaml_emitter_emit_stream_start(yaml_emitter_t *emitter, |
109
|
|
|
|
|
|
|
yaml_event_t *event); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
static int |
112
|
|
|
|
|
|
|
yaml_emitter_emit_document_start(yaml_emitter_t *emitter, |
113
|
|
|
|
|
|
|
yaml_event_t *event, int first); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
static int |
116
|
|
|
|
|
|
|
yaml_emitter_emit_document_content(yaml_emitter_t *emitter, |
117
|
|
|
|
|
|
|
yaml_event_t *event); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
static int |
120
|
|
|
|
|
|
|
yaml_emitter_emit_document_end(yaml_emitter_t *emitter, |
121
|
|
|
|
|
|
|
yaml_event_t *event); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
static int |
124
|
|
|
|
|
|
|
yaml_emitter_emit_flow_sequence_item(yaml_emitter_t *emitter, |
125
|
|
|
|
|
|
|
yaml_event_t *event, int first); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
static int |
128
|
|
|
|
|
|
|
yaml_emitter_emit_flow_mapping_key(yaml_emitter_t *emitter, |
129
|
|
|
|
|
|
|
yaml_event_t *event, int first); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
static int |
132
|
|
|
|
|
|
|
yaml_emitter_emit_flow_mapping_value(yaml_emitter_t *emitter, |
133
|
|
|
|
|
|
|
yaml_event_t *event, int simple); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
static int |
136
|
|
|
|
|
|
|
yaml_emitter_emit_block_sequence_item(yaml_emitter_t *emitter, |
137
|
|
|
|
|
|
|
yaml_event_t *event, int first); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
static int |
140
|
|
|
|
|
|
|
yaml_emitter_emit_block_mapping_key(yaml_emitter_t *emitter, |
141
|
|
|
|
|
|
|
yaml_event_t *event, int first); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
static int |
144
|
|
|
|
|
|
|
yaml_emitter_emit_block_mapping_value(yaml_emitter_t *emitter, |
145
|
|
|
|
|
|
|
yaml_event_t *event, int simple); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
static int |
148
|
|
|
|
|
|
|
yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event, |
149
|
|
|
|
|
|
|
int root, int sequence, int mapping, int simple_key); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
static int |
152
|
|
|
|
|
|
|
yaml_emitter_emit_alias(yaml_emitter_t *emitter, yaml_event_t *event); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
static int |
155
|
|
|
|
|
|
|
yaml_emitter_emit_scalar(yaml_emitter_t *emitter, yaml_event_t *event); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
static int |
158
|
|
|
|
|
|
|
yaml_emitter_emit_sequence_start(yaml_emitter_t *emitter, yaml_event_t *event); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
static int |
161
|
|
|
|
|
|
|
yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
/* |
164
|
|
|
|
|
|
|
* Checkers. |
165
|
|
|
|
|
|
|
*/ |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
static int |
168
|
|
|
|
|
|
|
yaml_emitter_check_empty_document(yaml_emitter_t *emitter); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
static int |
171
|
|
|
|
|
|
|
yaml_emitter_check_empty_sequence(yaml_emitter_t *emitter); |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
static int |
174
|
|
|
|
|
|
|
yaml_emitter_check_empty_mapping(yaml_emitter_t *emitter); |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
static int |
177
|
|
|
|
|
|
|
yaml_emitter_check_simple_key(yaml_emitter_t *emitter); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
static int |
180
|
|
|
|
|
|
|
yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
/* |
183
|
|
|
|
|
|
|
* Processors. |
184
|
|
|
|
|
|
|
*/ |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
static int |
187
|
|
|
|
|
|
|
yaml_emitter_process_anchor(yaml_emitter_t *emitter); |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
static int |
190
|
|
|
|
|
|
|
yaml_emitter_process_tag(yaml_emitter_t *emitter); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
static int |
193
|
|
|
|
|
|
|
yaml_emitter_process_scalar(yaml_emitter_t *emitter); |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
/* |
196
|
|
|
|
|
|
|
* Analyzers. |
197
|
|
|
|
|
|
|
*/ |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
static int |
200
|
|
|
|
|
|
|
yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter, |
201
|
|
|
|
|
|
|
yaml_version_directive_t version_directive); |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
static int |
204
|
|
|
|
|
|
|
yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter, |
205
|
|
|
|
|
|
|
yaml_tag_directive_t tag_directive); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
static int |
208
|
|
|
|
|
|
|
yaml_emitter_analyze_anchor(yaml_emitter_t *emitter, |
209
|
|
|
|
|
|
|
yaml_char_t *anchor, int alias); |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
static int |
212
|
|
|
|
|
|
|
yaml_emitter_analyze_tag(yaml_emitter_t *emitter, |
213
|
|
|
|
|
|
|
yaml_char_t *tag); |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
static int |
216
|
|
|
|
|
|
|
yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, |
217
|
|
|
|
|
|
|
yaml_char_t *value, size_t length); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
static int |
220
|
|
|
|
|
|
|
yaml_emitter_analyze_event(yaml_emitter_t *emitter, |
221
|
|
|
|
|
|
|
yaml_event_t *event); |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
/* |
224
|
|
|
|
|
|
|
* Writers. |
225
|
|
|
|
|
|
|
*/ |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
static int |
228
|
|
|
|
|
|
|
yaml_emitter_write_bom(yaml_emitter_t *emitter); |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
static int |
231
|
|
|
|
|
|
|
yaml_emitter_write_indent(yaml_emitter_t *emitter); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
static int |
234
|
|
|
|
|
|
|
yaml_emitter_write_indicator(yaml_emitter_t *emitter, |
235
|
|
|
|
|
|
|
const char *indicator, int need_whitespace, |
236
|
|
|
|
|
|
|
int is_whitespace, int is_indention); |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
static int |
239
|
|
|
|
|
|
|
yaml_emitter_write_anchor(yaml_emitter_t *emitter, |
240
|
|
|
|
|
|
|
yaml_char_t *value, size_t length); |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
static int |
243
|
|
|
|
|
|
|
yaml_emitter_write_tag_handle(yaml_emitter_t *emitter, |
244
|
|
|
|
|
|
|
yaml_char_t *value, size_t length); |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
static int |
247
|
|
|
|
|
|
|
yaml_emitter_write_tag_content(yaml_emitter_t *emitter, |
248
|
|
|
|
|
|
|
yaml_char_t *value, size_t length, int need_whitespace); |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
static int |
251
|
|
|
|
|
|
|
yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter, |
252
|
|
|
|
|
|
|
yaml_char_t *value, size_t length, int allow_breaks); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
static int |
255
|
|
|
|
|
|
|
yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter, |
256
|
|
|
|
|
|
|
yaml_char_t *value, size_t length, int allow_breaks); |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
static int |
259
|
|
|
|
|
|
|
yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter, |
260
|
|
|
|
|
|
|
yaml_char_t *value, size_t length, int allow_breaks); |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
static int |
263
|
|
|
|
|
|
|
yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter, |
264
|
|
|
|
|
|
|
yaml_string_t string); |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
static int |
267
|
|
|
|
|
|
|
yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter, |
268
|
|
|
|
|
|
|
yaml_char_t *value, size_t length); |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
static int |
271
|
|
|
|
|
|
|
yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter, |
272
|
|
|
|
|
|
|
yaml_char_t *value, size_t length); |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
/* |
275
|
|
|
|
|
|
|
* Set an emitter error and return 0. |
276
|
|
|
|
|
|
|
*/ |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
static int |
279
|
0
|
|
|
|
|
|
yaml_emitter_set_emitter_error(yaml_emitter_t *emitter, const char *problem) |
280
|
|
|
|
|
|
|
{ |
281
|
0
|
|
|
|
|
|
emitter->error = YAML_EMITTER_ERROR; |
282
|
0
|
|
|
|
|
|
emitter->problem = problem; |
283
|
|
|
|
|
|
|
|
284
|
0
|
|
|
|
|
|
return 0; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
/* |
288
|
|
|
|
|
|
|
* Emit an event. |
289
|
|
|
|
|
|
|
*/ |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
YAML_DECLARE(int) |
292
|
920
|
|
|
|
|
|
yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event) |
293
|
|
|
|
|
|
|
{ |
294
|
920
|
100
|
|
|
|
|
if (!ENQUEUE(emitter, emitter->events, *event)) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
295
|
0
|
|
|
|
|
|
yaml_event_delete(event); |
296
|
0
|
|
|
|
|
|
return 0; |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
1840
|
100
|
|
|
|
|
while (!yaml_emitter_need_more_events(emitter)) { |
300
|
920
|
50
|
|
|
|
|
if (!yaml_emitter_analyze_event(emitter, emitter->events.head)) |
301
|
0
|
|
|
|
|
|
return 0; |
302
|
920
|
50
|
|
|
|
|
if (!yaml_emitter_state_machine(emitter, emitter->events.head)) |
303
|
0
|
|
|
|
|
|
return 0; |
304
|
920
|
|
|
|
|
|
yaml_event_delete(&DEQUEUE(emitter, emitter->events)); |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
920
|
|
|
|
|
|
return 1; |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
/* |
311
|
|
|
|
|
|
|
* Check if we need to accumulate more events before emitting. |
312
|
|
|
|
|
|
|
* |
313
|
|
|
|
|
|
|
* We accumulate extra |
314
|
|
|
|
|
|
|
* - 1 event for DOCUMENT-START |
315
|
|
|
|
|
|
|
* - 2 events for SEQUENCE-START |
316
|
|
|
|
|
|
|
* - 3 events for MAPPING-START |
317
|
|
|
|
|
|
|
*/ |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
static int |
320
|
1840
|
|
|
|
|
|
yaml_emitter_need_more_events(yaml_emitter_t *emitter) |
321
|
|
|
|
|
|
|
{ |
322
|
1840
|
|
|
|
|
|
int level = 0; |
323
|
1840
|
|
|
|
|
|
int accumulate = 0; |
324
|
|
|
|
|
|
|
yaml_event_t *event; |
325
|
|
|
|
|
|
|
|
326
|
1840
|
100
|
|
|
|
|
if (QUEUE_EMPTY(emitter, emitter->events)) |
327
|
582
|
|
|
|
|
|
return 1; |
328
|
|
|
|
|
|
|
|
329
|
1258
|
|
|
|
|
|
switch (emitter->events.head->type) { |
330
|
|
|
|
|
|
|
case YAML_DOCUMENT_START_EVENT: |
331
|
218
|
|
|
|
|
|
accumulate = 1; |
332
|
218
|
|
|
|
|
|
break; |
333
|
|
|
|
|
|
|
case YAML_SEQUENCE_START_EVENT: |
334
|
115
|
|
|
|
|
|
accumulate = 2; |
335
|
115
|
|
|
|
|
|
break; |
336
|
|
|
|
|
|
|
case YAML_MAPPING_START_EVENT: |
337
|
224
|
|
|
|
|
|
accumulate = 3; |
338
|
224
|
|
|
|
|
|
break; |
339
|
|
|
|
|
|
|
default: |
340
|
701
|
|
|
|
|
|
return 0; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
557
|
100
|
|
|
|
|
if (emitter->events.tail - emitter->events.head > accumulate) |
344
|
200
|
|
|
|
|
|
return 0; |
345
|
|
|
|
|
|
|
|
346
|
919
|
100
|
|
|
|
|
for (event = emitter->events.head; event != emitter->events.tail; event ++) { |
347
|
581
|
|
|
|
|
|
switch (event->type) { |
348
|
|
|
|
|
|
|
case YAML_STREAM_START_EVENT: |
349
|
|
|
|
|
|
|
case YAML_DOCUMENT_START_EVENT: |
350
|
|
|
|
|
|
|
case YAML_SEQUENCE_START_EVENT: |
351
|
|
|
|
|
|
|
case YAML_MAPPING_START_EVENT: |
352
|
386
|
|
|
|
|
|
level += 1; |
353
|
386
|
|
|
|
|
|
break; |
354
|
|
|
|
|
|
|
case YAML_STREAM_END_EVENT: |
355
|
|
|
|
|
|
|
case YAML_DOCUMENT_END_EVENT: |
356
|
|
|
|
|
|
|
case YAML_SEQUENCE_END_EVENT: |
357
|
|
|
|
|
|
|
case YAML_MAPPING_END_EVENT: |
358
|
19
|
|
|
|
|
|
level -= 1; |
359
|
19
|
|
|
|
|
|
break; |
360
|
|
|
|
|
|
|
default: |
361
|
176
|
|
|
|
|
|
break; |
362
|
|
|
|
|
|
|
} |
363
|
581
|
100
|
|
|
|
|
if (!level) |
364
|
19
|
|
|
|
|
|
return 0; |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
338
|
|
|
|
|
|
return 1; |
368
|
|
|
|
|
|
|
} |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
/* |
371
|
|
|
|
|
|
|
* Append a directive to the directives stack. |
372
|
|
|
|
|
|
|
*/ |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
static int |
375
|
218
|
|
|
|
|
|
yaml_emitter_append_tag_directive(yaml_emitter_t *emitter, |
376
|
|
|
|
|
|
|
yaml_tag_directive_t value, int allow_duplicates) |
377
|
|
|
|
|
|
|
{ |
378
|
|
|
|
|
|
|
yaml_tag_directive_t *tag_directive; |
379
|
218
|
|
|
|
|
|
yaml_tag_directive_t copy = { NULL, NULL }; |
380
|
|
|
|
|
|
|
|
381
|
327
|
100
|
|
|
|
|
for (tag_directive = emitter->tag_directives.start; |
382
|
109
|
|
|
|
|
|
tag_directive != emitter->tag_directives.top; tag_directive ++) { |
383
|
109
|
50
|
|
|
|
|
if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) { |
384
|
0
|
0
|
|
|
|
|
if (allow_duplicates) |
385
|
0
|
|
|
|
|
|
return 1; |
386
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
387
|
|
|
|
|
|
|
"duplicate %TAG directive"); |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
|
391
|
218
|
|
|
|
|
|
copy.handle = yaml_strdup(value.handle); |
392
|
218
|
|
|
|
|
|
copy.prefix = yaml_strdup(value.prefix); |
393
|
218
|
50
|
|
|
|
|
if (!copy.handle || !copy.prefix) { |
|
|
50
|
|
|
|
|
|
394
|
0
|
|
|
|
|
|
emitter->error = YAML_MEMORY_ERROR; |
395
|
0
|
|
|
|
|
|
goto error; |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
|
398
|
218
|
50
|
|
|
|
|
if (!PUSH(emitter, emitter->tag_directives, copy)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
399
|
0
|
|
|
|
|
|
goto error; |
400
|
|
|
|
|
|
|
|
401
|
218
|
|
|
|
|
|
return 1; |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
error: |
404
|
0
|
|
|
|
|
|
yaml_free(copy.handle); |
405
|
0
|
|
|
|
|
|
yaml_free(copy.prefix); |
406
|
218
|
|
|
|
|
|
return 0; |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
/* |
410
|
|
|
|
|
|
|
* Increase the indentation level. |
411
|
|
|
|
|
|
|
*/ |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
static int |
414
|
401
|
|
|
|
|
|
yaml_emitter_increase_indent(yaml_emitter_t *emitter, |
415
|
|
|
|
|
|
|
int flow, int indentless) |
416
|
|
|
|
|
|
|
{ |
417
|
401
|
50
|
|
|
|
|
if (!PUSH(emitter, emitter->indents, emitter->indent)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
418
|
0
|
|
|
|
|
|
return 0; |
419
|
|
|
|
|
|
|
|
420
|
401
|
100
|
|
|
|
|
if (emitter->indent < 0) { |
421
|
109
|
100
|
|
|
|
|
emitter->indent = flow ? emitter->best_indent : 0; |
422
|
|
|
|
|
|
|
} |
423
|
292
|
100
|
|
|
|
|
else if (!indentless) { |
424
|
289
|
|
|
|
|
|
emitter->indent += emitter->best_indent; |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
|
427
|
401
|
|
|
|
|
|
return 1; |
428
|
|
|
|
|
|
|
} |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
/* |
431
|
|
|
|
|
|
|
* State dispatcher. |
432
|
|
|
|
|
|
|
*/ |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
static int |
435
|
920
|
|
|
|
|
|
yaml_emitter_state_machine(yaml_emitter_t *emitter, yaml_event_t *event) |
436
|
|
|
|
|
|
|
{ |
437
|
920
|
|
|
|
|
|
switch (emitter->state) |
438
|
|
|
|
|
|
|
{ |
439
|
|
|
|
|
|
|
case YAML_EMIT_STREAM_START_STATE: |
440
|
87
|
|
|
|
|
|
return yaml_emitter_emit_stream_start(emitter, event); |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
case YAML_EMIT_FIRST_DOCUMENT_START_STATE: |
443
|
87
|
|
|
|
|
|
return yaml_emitter_emit_document_start(emitter, event, 1); |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
case YAML_EMIT_DOCUMENT_START_STATE: |
446
|
109
|
|
|
|
|
|
return yaml_emitter_emit_document_start(emitter, event, 0); |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
case YAML_EMIT_DOCUMENT_CONTENT_STATE: |
449
|
109
|
|
|
|
|
|
return yaml_emitter_emit_document_content(emitter, event); |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
case YAML_EMIT_DOCUMENT_END_STATE: |
452
|
109
|
|
|
|
|
|
return yaml_emitter_emit_document_end(emitter, event); |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
case YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE: |
455
|
10
|
|
|
|
|
|
return yaml_emitter_emit_flow_sequence_item(emitter, event, 1); |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
case YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE: |
458
|
0
|
|
|
|
|
|
return yaml_emitter_emit_flow_sequence_item(emitter, event, 0); |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
case YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE: |
461
|
9
|
|
|
|
|
|
return yaml_emitter_emit_flow_mapping_key(emitter, event, 1); |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
case YAML_EMIT_FLOW_MAPPING_KEY_STATE: |
464
|
0
|
|
|
|
|
|
return yaml_emitter_emit_flow_mapping_key(emitter, event, 0); |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
case YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE: |
467
|
0
|
|
|
|
|
|
return yaml_emitter_emit_flow_mapping_value(emitter, event, 1); |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
case YAML_EMIT_FLOW_MAPPING_VALUE_STATE: |
470
|
0
|
|
|
|
|
|
return yaml_emitter_emit_flow_mapping_value(emitter, event, 0); |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
case YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE: |
473
|
34
|
|
|
|
|
|
return yaml_emitter_emit_block_sequence_item(emitter, event, 1); |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
case YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE: |
476
|
91
|
|
|
|
|
|
return yaml_emitter_emit_block_sequence_item(emitter, event, 0); |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
case YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE: |
479
|
57
|
|
|
|
|
|
return yaml_emitter_emit_block_mapping_key(emitter, event, 1); |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
case YAML_EMIT_BLOCK_MAPPING_KEY_STATE: |
482
|
109
|
|
|
|
|
|
return yaml_emitter_emit_block_mapping_key(emitter, event, 0); |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
case YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE: |
485
|
109
|
|
|
|
|
|
return yaml_emitter_emit_block_mapping_value(emitter, event, 1); |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
case YAML_EMIT_BLOCK_MAPPING_VALUE_STATE: |
488
|
0
|
|
|
|
|
|
return yaml_emitter_emit_block_mapping_value(emitter, event, 0); |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
case YAML_EMIT_END_STATE: |
491
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
492
|
|
|
|
|
|
|
"expected nothing after STREAM-END"); |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
default: |
495
|
|
|
|
|
|
|
assert(1); /* Invalid state. */ |
496
|
|
|
|
|
|
|
} |
497
|
|
|
|
|
|
|
|
498
|
0
|
|
|
|
|
|
return 0; |
499
|
|
|
|
|
|
|
} |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
/* |
502
|
|
|
|
|
|
|
* Expect STREAM-START. |
503
|
|
|
|
|
|
|
*/ |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
static int |
506
|
87
|
|
|
|
|
|
yaml_emitter_emit_stream_start(yaml_emitter_t *emitter, |
507
|
|
|
|
|
|
|
yaml_event_t *event) |
508
|
|
|
|
|
|
|
{ |
509
|
87
|
50
|
|
|
|
|
if (event->type == YAML_STREAM_START_EVENT) |
510
|
|
|
|
|
|
|
{ |
511
|
87
|
50
|
|
|
|
|
if (!emitter->encoding) { |
512
|
87
|
|
|
|
|
|
emitter->encoding = event->data.stream_start.encoding; |
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
|
515
|
87
|
50
|
|
|
|
|
if (!emitter->encoding) { |
516
|
87
|
|
|
|
|
|
emitter->encoding = YAML_UTF8_ENCODING; |
517
|
|
|
|
|
|
|
} |
518
|
|
|
|
|
|
|
|
519
|
87
|
50
|
|
|
|
|
if (emitter->best_indent < 2 || emitter->best_indent > 9) { |
|
|
50
|
|
|
|
|
|
520
|
0
|
|
|
|
|
|
emitter->best_indent = 2; |
521
|
|
|
|
|
|
|
} |
522
|
|
|
|
|
|
|
|
523
|
87
|
50
|
|
|
|
|
if (emitter->best_width >= 0 |
524
|
87
|
50
|
|
|
|
|
&& emitter->best_width <= emitter->best_indent*2) { |
525
|
0
|
|
|
|
|
|
emitter->best_width = 80; |
526
|
|
|
|
|
|
|
} |
527
|
|
|
|
|
|
|
|
528
|
87
|
50
|
|
|
|
|
if (emitter->best_width < 0) { |
529
|
0
|
|
|
|
|
|
emitter->best_width = INT_MAX; |
530
|
|
|
|
|
|
|
} |
531
|
|
|
|
|
|
|
|
532
|
87
|
50
|
|
|
|
|
if (!emitter->line_break) { |
533
|
87
|
|
|
|
|
|
emitter->line_break = YAML_LN_BREAK; |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
|
536
|
87
|
|
|
|
|
|
emitter->indent = -1; |
537
|
|
|
|
|
|
|
|
538
|
87
|
|
|
|
|
|
emitter->line = 0; |
539
|
87
|
|
|
|
|
|
emitter->column = 0; |
540
|
87
|
|
|
|
|
|
emitter->whitespace = 1; |
541
|
87
|
|
|
|
|
|
emitter->indention = 1; |
542
|
|
|
|
|
|
|
|
543
|
87
|
50
|
|
|
|
|
if (emitter->encoding != YAML_UTF8_ENCODING) { |
544
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_bom(emitter)) |
545
|
0
|
|
|
|
|
|
return 0; |
546
|
|
|
|
|
|
|
} |
547
|
|
|
|
|
|
|
|
548
|
87
|
|
|
|
|
|
emitter->state = YAML_EMIT_FIRST_DOCUMENT_START_STATE; |
549
|
|
|
|
|
|
|
|
550
|
87
|
|
|
|
|
|
return 1; |
551
|
|
|
|
|
|
|
} |
552
|
|
|
|
|
|
|
|
553
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
554
|
|
|
|
|
|
|
"expected STREAM-START"); |
555
|
|
|
|
|
|
|
} |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
/* |
558
|
|
|
|
|
|
|
* Expect DOCUMENT-START or STREAM-END. |
559
|
|
|
|
|
|
|
*/ |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
static int |
562
|
196
|
|
|
|
|
|
yaml_emitter_emit_document_start(yaml_emitter_t *emitter, |
563
|
|
|
|
|
|
|
yaml_event_t *event, int first) |
564
|
|
|
|
|
|
|
{ |
565
|
196
|
100
|
|
|
|
|
if (event->type == YAML_DOCUMENT_START_EVENT) |
566
|
|
|
|
|
|
|
{ |
567
|
109
|
|
|
|
|
|
yaml_tag_directive_t default_tag_directives[] = { |
568
|
|
|
|
|
|
|
{(yaml_char_t *)"!", (yaml_char_t *)"!"}, |
569
|
|
|
|
|
|
|
{(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"}, |
570
|
|
|
|
|
|
|
{NULL, NULL} |
571
|
|
|
|
|
|
|
}; |
572
|
|
|
|
|
|
|
yaml_tag_directive_t *tag_directive; |
573
|
|
|
|
|
|
|
int implicit; |
574
|
|
|
|
|
|
|
|
575
|
109
|
50
|
|
|
|
|
if (event->data.document_start.version_directive) { |
576
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_analyze_version_directive(emitter, |
577
|
0
|
|
|
|
|
|
*event->data.document_start.version_directive)) |
578
|
0
|
|
|
|
|
|
return 0; |
579
|
|
|
|
|
|
|
} |
580
|
|
|
|
|
|
|
|
581
|
109
|
50
|
|
|
|
|
for (tag_directive = event->data.document_start.tag_directives.start; |
582
|
109
|
|
|
|
|
|
tag_directive != event->data.document_start.tag_directives.end; |
583
|
0
|
|
|
|
|
|
tag_directive ++) { |
584
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_analyze_tag_directive(emitter, *tag_directive)) |
585
|
0
|
|
|
|
|
|
return 0; |
586
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 0)) |
587
|
0
|
|
|
|
|
|
return 0; |
588
|
|
|
|
|
|
|
} |
589
|
|
|
|
|
|
|
|
590
|
327
|
100
|
|
|
|
|
for (tag_directive = default_tag_directives; |
591
|
218
|
|
|
|
|
|
tag_directive->handle; tag_directive ++) { |
592
|
218
|
50
|
|
|
|
|
if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 1)) |
593
|
0
|
|
|
|
|
|
return 0; |
594
|
|
|
|
|
|
|
} |
595
|
|
|
|
|
|
|
|
596
|
109
|
|
|
|
|
|
implicit = event->data.document_start.implicit; |
597
|
109
|
100
|
|
|
|
|
if (!first || emitter->canonical) { |
|
|
50
|
|
|
|
|
|
598
|
23
|
|
|
|
|
|
implicit = 0; |
599
|
|
|
|
|
|
|
} |
600
|
|
|
|
|
|
|
|
601
|
109
|
50
|
|
|
|
|
if ((event->data.document_start.version_directive || |
|
|
50
|
|
|
|
|
|
602
|
109
|
|
|
|
|
|
(event->data.document_start.tag_directives.start |
603
|
0
|
0
|
|
|
|
|
!= event->data.document_start.tag_directives.end)) && |
604
|
0
|
|
|
|
|
|
emitter->open_ended) |
605
|
|
|
|
|
|
|
{ |
606
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0)) |
607
|
0
|
|
|
|
|
|
return 0; |
608
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
609
|
0
|
|
|
|
|
|
return 0; |
610
|
|
|
|
|
|
|
} |
611
|
|
|
|
|
|
|
|
612
|
109
|
50
|
|
|
|
|
if (event->data.document_start.version_directive) { |
613
|
0
|
|
|
|
|
|
implicit = 0; |
614
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0)) |
615
|
0
|
|
|
|
|
|
return 0; |
616
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0)) |
617
|
0
|
|
|
|
|
|
return 0; |
618
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
619
|
0
|
|
|
|
|
|
return 0; |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
109
|
50
|
|
|
|
|
if (event->data.document_start.tag_directives.start |
623
|
109
|
|
|
|
|
|
!= event->data.document_start.tag_directives.end) { |
624
|
0
|
|
|
|
|
|
implicit = 0; |
625
|
0
|
0
|
|
|
|
|
for (tag_directive = event->data.document_start.tag_directives.start; |
626
|
0
|
|
|
|
|
|
tag_directive != event->data.document_start.tag_directives.end; |
627
|
0
|
|
|
|
|
|
tag_directive ++) { |
628
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "%TAG", 1, 0, 0)) |
629
|
0
|
|
|
|
|
|
return 0; |
630
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_tag_handle(emitter, tag_directive->handle, |
631
|
0
|
|
|
|
|
|
strlen((char *)tag_directive->handle))) |
632
|
0
|
|
|
|
|
|
return 0; |
633
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_tag_content(emitter, tag_directive->prefix, |
634
|
0
|
|
|
|
|
|
strlen((char *)tag_directive->prefix), 1)) |
635
|
0
|
|
|
|
|
|
return 0; |
636
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
637
|
0
|
|
|
|
|
|
return 0; |
638
|
|
|
|
|
|
|
} |
639
|
|
|
|
|
|
|
} |
640
|
|
|
|
|
|
|
|
641
|
109
|
50
|
|
|
|
|
if (yaml_emitter_check_empty_document(emitter)) { |
642
|
0
|
|
|
|
|
|
implicit = 0; |
643
|
|
|
|
|
|
|
} |
644
|
|
|
|
|
|
|
|
645
|
109
|
50
|
|
|
|
|
if (!implicit) { |
646
|
109
|
50
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
647
|
0
|
|
|
|
|
|
return 0; |
648
|
109
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "---", 1, 0, 0)) |
649
|
0
|
|
|
|
|
|
return 0; |
650
|
109
|
50
|
|
|
|
|
if (emitter->canonical) { |
651
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
652
|
0
|
|
|
|
|
|
return 0; |
653
|
|
|
|
|
|
|
} |
654
|
|
|
|
|
|
|
} |
655
|
|
|
|
|
|
|
|
656
|
109
|
|
|
|
|
|
emitter->state = YAML_EMIT_DOCUMENT_CONTENT_STATE; |
657
|
|
|
|
|
|
|
|
658
|
109
|
|
|
|
|
|
return 1; |
659
|
|
|
|
|
|
|
} |
660
|
|
|
|
|
|
|
|
661
|
87
|
50
|
|
|
|
|
else if (event->type == YAML_STREAM_END_EVENT) |
662
|
|
|
|
|
|
|
{ |
663
|
|
|
|
|
|
|
|
664
|
87
|
50
|
|
|
|
|
if (!yaml_emitter_flush(emitter)) |
665
|
0
|
|
|
|
|
|
return 0; |
666
|
|
|
|
|
|
|
|
667
|
87
|
|
|
|
|
|
emitter->state = YAML_EMIT_END_STATE; |
668
|
|
|
|
|
|
|
|
669
|
87
|
|
|
|
|
|
return 1; |
670
|
|
|
|
|
|
|
} |
671
|
|
|
|
|
|
|
|
672
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
673
|
|
|
|
|
|
|
"expected DOCUMENT-START or STREAM-END"); |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
/* |
677
|
|
|
|
|
|
|
* Expect the root node. |
678
|
|
|
|
|
|
|
*/ |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
static int |
681
|
109
|
|
|
|
|
|
yaml_emitter_emit_document_content(yaml_emitter_t *emitter, |
682
|
|
|
|
|
|
|
yaml_event_t *event) |
683
|
|
|
|
|
|
|
{ |
684
|
109
|
50
|
|
|
|
|
if (!PUSH(emitter, emitter->states, YAML_EMIT_DOCUMENT_END_STATE)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
685
|
0
|
|
|
|
|
|
return 0; |
686
|
|
|
|
|
|
|
|
687
|
109
|
|
|
|
|
|
return yaml_emitter_emit_node(emitter, event, 1, 0, 0, 0); |
688
|
|
|
|
|
|
|
} |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
/* |
691
|
|
|
|
|
|
|
* Expect DOCUMENT-END. |
692
|
|
|
|
|
|
|
*/ |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
static int |
695
|
109
|
|
|
|
|
|
yaml_emitter_emit_document_end(yaml_emitter_t *emitter, |
696
|
|
|
|
|
|
|
yaml_event_t *event) |
697
|
|
|
|
|
|
|
{ |
698
|
109
|
50
|
|
|
|
|
if (event->type == YAML_DOCUMENT_END_EVENT) |
699
|
|
|
|
|
|
|
{ |
700
|
109
|
50
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
701
|
0
|
|
|
|
|
|
return 0; |
702
|
109
|
50
|
|
|
|
|
if (!event->data.document_end.implicit) { |
703
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0)) |
704
|
0
|
|
|
|
|
|
return 0; |
705
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
706
|
0
|
|
|
|
|
|
return 0; |
707
|
|
|
|
|
|
|
} |
708
|
109
|
50
|
|
|
|
|
if (!yaml_emitter_flush(emitter)) |
709
|
0
|
|
|
|
|
|
return 0; |
710
|
|
|
|
|
|
|
|
711
|
109
|
|
|
|
|
|
emitter->state = YAML_EMIT_DOCUMENT_START_STATE; |
712
|
|
|
|
|
|
|
|
713
|
327
|
100
|
|
|
|
|
while (!STACK_EMPTY(emitter, emitter->tag_directives)) { |
714
|
218
|
|
|
|
|
|
yaml_tag_directive_t tag_directive = POP(emitter, |
715
|
|
|
|
|
|
|
emitter->tag_directives); |
716
|
218
|
|
|
|
|
|
yaml_free(tag_directive.handle); |
717
|
218
|
|
|
|
|
|
yaml_free(tag_directive.prefix); |
718
|
|
|
|
|
|
|
} |
719
|
|
|
|
|
|
|
|
720
|
109
|
|
|
|
|
|
return 1; |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
|
723
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
724
|
|
|
|
|
|
|
"expected DOCUMENT-END"); |
725
|
|
|
|
|
|
|
} |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
/* |
728
|
|
|
|
|
|
|
* |
729
|
|
|
|
|
|
|
* Expect a flow item node. |
730
|
|
|
|
|
|
|
*/ |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
static int |
733
|
10
|
|
|
|
|
|
yaml_emitter_emit_flow_sequence_item(yaml_emitter_t *emitter, |
734
|
|
|
|
|
|
|
yaml_event_t *event, int first) |
735
|
|
|
|
|
|
|
{ |
736
|
10
|
50
|
|
|
|
|
if (first) |
737
|
|
|
|
|
|
|
{ |
738
|
10
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "[", 1, 1, 0)) |
739
|
0
|
|
|
|
|
|
return 0; |
740
|
10
|
50
|
|
|
|
|
if (!yaml_emitter_increase_indent(emitter, 1, 0)) |
741
|
0
|
|
|
|
|
|
return 0; |
742
|
10
|
|
|
|
|
|
emitter->flow_level ++; |
743
|
|
|
|
|
|
|
} |
744
|
|
|
|
|
|
|
|
745
|
10
|
50
|
|
|
|
|
if (event->type == YAML_SEQUENCE_END_EVENT) |
746
|
|
|
|
|
|
|
{ |
747
|
10
|
|
|
|
|
|
emitter->flow_level --; |
748
|
10
|
|
|
|
|
|
emitter->indent = POP(emitter, emitter->indents); |
749
|
10
|
50
|
|
|
|
|
if (emitter->canonical && !first) { |
|
|
0
|
|
|
|
|
|
750
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0)) |
751
|
0
|
|
|
|
|
|
return 0; |
752
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
753
|
0
|
|
|
|
|
|
return 0; |
754
|
|
|
|
|
|
|
} |
755
|
10
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "]", 0, 0, 0)) |
756
|
0
|
|
|
|
|
|
return 0; |
757
|
10
|
|
|
|
|
|
emitter->state = POP(emitter, emitter->states); |
758
|
|
|
|
|
|
|
|
759
|
10
|
|
|
|
|
|
return 1; |
760
|
|
|
|
|
|
|
} |
761
|
|
|
|
|
|
|
|
762
|
0
|
0
|
|
|
|
|
if (!first) { |
763
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0)) |
764
|
0
|
|
|
|
|
|
return 0; |
765
|
|
|
|
|
|
|
} |
766
|
|
|
|
|
|
|
|
767
|
0
|
0
|
|
|
|
|
if (emitter->canonical || emitter->column > emitter->best_width) { |
|
|
0
|
|
|
|
|
|
768
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
769
|
0
|
|
|
|
|
|
return 0; |
770
|
|
|
|
|
|
|
} |
771
|
0
|
0
|
|
|
|
|
if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
772
|
0
|
|
|
|
|
|
return 0; |
773
|
|
|
|
|
|
|
|
774
|
0
|
|
|
|
|
|
return yaml_emitter_emit_node(emitter, event, 0, 1, 0, 0); |
775
|
|
|
|
|
|
|
} |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
/* |
778
|
|
|
|
|
|
|
* Expect a flow key node. |
779
|
|
|
|
|
|
|
*/ |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
static int |
782
|
9
|
|
|
|
|
|
yaml_emitter_emit_flow_mapping_key(yaml_emitter_t *emitter, |
783
|
|
|
|
|
|
|
yaml_event_t *event, int first) |
784
|
|
|
|
|
|
|
{ |
785
|
9
|
50
|
|
|
|
|
if (first) |
786
|
|
|
|
|
|
|
{ |
787
|
9
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "{", 1, 1, 0)) |
788
|
0
|
|
|
|
|
|
return 0; |
789
|
9
|
50
|
|
|
|
|
if (!yaml_emitter_increase_indent(emitter, 1, 0)) |
790
|
0
|
|
|
|
|
|
return 0; |
791
|
9
|
|
|
|
|
|
emitter->flow_level ++; |
792
|
|
|
|
|
|
|
} |
793
|
|
|
|
|
|
|
|
794
|
9
|
50
|
|
|
|
|
if (event->type == YAML_MAPPING_END_EVENT) |
795
|
|
|
|
|
|
|
{ |
796
|
9
|
|
|
|
|
|
emitter->flow_level --; |
797
|
9
|
|
|
|
|
|
emitter->indent = POP(emitter, emitter->indents); |
798
|
9
|
50
|
|
|
|
|
if (emitter->canonical && !first) { |
|
|
0
|
|
|
|
|
|
799
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0)) |
800
|
0
|
|
|
|
|
|
return 0; |
801
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
802
|
0
|
|
|
|
|
|
return 0; |
803
|
|
|
|
|
|
|
} |
804
|
9
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "}", 0, 0, 0)) |
805
|
0
|
|
|
|
|
|
return 0; |
806
|
9
|
|
|
|
|
|
emitter->state = POP(emitter, emitter->states); |
807
|
|
|
|
|
|
|
|
808
|
9
|
|
|
|
|
|
return 1; |
809
|
|
|
|
|
|
|
} |
810
|
|
|
|
|
|
|
|
811
|
0
|
0
|
|
|
|
|
if (!first) { |
812
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0)) |
813
|
0
|
|
|
|
|
|
return 0; |
814
|
|
|
|
|
|
|
} |
815
|
0
|
0
|
|
|
|
|
if (emitter->canonical || emitter->column > emitter->best_width) { |
|
|
0
|
|
|
|
|
|
816
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
817
|
0
|
|
|
|
|
|
return 0; |
818
|
|
|
|
|
|
|
} |
819
|
|
|
|
|
|
|
|
820
|
0
|
0
|
|
|
|
|
if (!emitter->canonical && yaml_emitter_check_simple_key(emitter)) |
|
|
0
|
|
|
|
|
|
821
|
|
|
|
|
|
|
{ |
822
|
0
|
0
|
|
|
|
|
if (!PUSH(emitter, emitter->states, |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
823
|
|
|
|
|
|
|
YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE)) |
824
|
0
|
|
|
|
|
|
return 0; |
825
|
|
|
|
|
|
|
|
826
|
0
|
|
|
|
|
|
return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 1); |
827
|
|
|
|
|
|
|
} |
828
|
|
|
|
|
|
|
else |
829
|
|
|
|
|
|
|
{ |
830
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 0)) |
831
|
0
|
|
|
|
|
|
return 0; |
832
|
0
|
0
|
|
|
|
|
if (!PUSH(emitter, emitter->states, |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
833
|
|
|
|
|
|
|
YAML_EMIT_FLOW_MAPPING_VALUE_STATE)) |
834
|
0
|
|
|
|
|
|
return 0; |
835
|
|
|
|
|
|
|
|
836
|
0
|
|
|
|
|
|
return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0); |
837
|
|
|
|
|
|
|
} |
838
|
|
|
|
|
|
|
} |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
/* |
841
|
|
|
|
|
|
|
* Expect a flow value node. |
842
|
|
|
|
|
|
|
*/ |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
static int |
845
|
0
|
|
|
|
|
|
yaml_emitter_emit_flow_mapping_value(yaml_emitter_t *emitter, |
846
|
|
|
|
|
|
|
yaml_event_t *event, int simple) |
847
|
|
|
|
|
|
|
{ |
848
|
0
|
0
|
|
|
|
|
if (simple) { |
849
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0)) |
850
|
0
|
|
|
|
|
|
return 0; |
851
|
|
|
|
|
|
|
} |
852
|
|
|
|
|
|
|
else { |
853
|
0
|
0
|
|
|
|
|
if (emitter->canonical || emitter->column > emitter->best_width) { |
|
|
0
|
|
|
|
|
|
854
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
855
|
0
|
|
|
|
|
|
return 0; |
856
|
|
|
|
|
|
|
} |
857
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 0)) |
858
|
0
|
|
|
|
|
|
return 0; |
859
|
|
|
|
|
|
|
} |
860
|
0
|
0
|
|
|
|
|
if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_MAPPING_KEY_STATE)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
861
|
0
|
|
|
|
|
|
return 0; |
862
|
0
|
|
|
|
|
|
return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0); |
863
|
|
|
|
|
|
|
} |
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
/* |
866
|
|
|
|
|
|
|
* Expect a block item node. |
867
|
|
|
|
|
|
|
*/ |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
static int |
870
|
125
|
|
|
|
|
|
yaml_emitter_emit_block_sequence_item(yaml_emitter_t *emitter, |
871
|
|
|
|
|
|
|
yaml_event_t *event, int first) |
872
|
|
|
|
|
|
|
{ |
873
|
125
|
100
|
|
|
|
|
if (first) |
874
|
|
|
|
|
|
|
{ |
875
|
37
|
100
|
|
|
|
|
if (!yaml_emitter_increase_indent(emitter, 0, |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
876
|
3
|
50
|
|
|
|
|
emitter->indentless_map && (emitter->mapping_context && !emitter->indention))) |
877
|
0
|
|
|
|
|
|
return 0; |
878
|
|
|
|
|
|
|
} |
879
|
|
|
|
|
|
|
|
880
|
125
|
100
|
|
|
|
|
if (event->type == YAML_SEQUENCE_END_EVENT) |
881
|
|
|
|
|
|
|
{ |
882
|
34
|
|
|
|
|
|
emitter->indent = POP(emitter, emitter->indents); |
883
|
34
|
|
|
|
|
|
emitter->state = POP(emitter, emitter->states); |
884
|
|
|
|
|
|
|
|
885
|
34
|
|
|
|
|
|
return 1; |
886
|
|
|
|
|
|
|
} |
887
|
|
|
|
|
|
|
|
888
|
91
|
50
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
889
|
0
|
|
|
|
|
|
return 0; |
890
|
91
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "-", 1, 0, 1)) |
891
|
0
|
|
|
|
|
|
return 0; |
892
|
91
|
50
|
|
|
|
|
if (!PUSH(emitter, emitter->states, |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
893
|
|
|
|
|
|
|
YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE)) |
894
|
0
|
|
|
|
|
|
return 0; |
895
|
|
|
|
|
|
|
|
896
|
91
|
|
|
|
|
|
return yaml_emitter_emit_node(emitter, event, 0, 1, 0, 0); |
897
|
|
|
|
|
|
|
} |
898
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
/* |
900
|
|
|
|
|
|
|
* Expect a block key node. |
901
|
|
|
|
|
|
|
*/ |
902
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
static int |
904
|
166
|
|
|
|
|
|
yaml_emitter_emit_block_mapping_key(yaml_emitter_t *emitter, |
905
|
|
|
|
|
|
|
yaml_event_t *event, int first) |
906
|
|
|
|
|
|
|
{ |
907
|
166
|
100
|
|
|
|
|
if (first) |
908
|
|
|
|
|
|
|
{ |
909
|
57
|
50
|
|
|
|
|
if (!yaml_emitter_increase_indent(emitter, 0, 0)) |
910
|
0
|
|
|
|
|
|
return 0; |
911
|
|
|
|
|
|
|
} |
912
|
|
|
|
|
|
|
|
913
|
166
|
100
|
|
|
|
|
if (event->type == YAML_MAPPING_END_EVENT) |
914
|
|
|
|
|
|
|
{ |
915
|
57
|
|
|
|
|
|
emitter->indent = POP(emitter, emitter->indents); |
916
|
57
|
|
|
|
|
|
emitter->state = POP(emitter, emitter->states); |
917
|
|
|
|
|
|
|
|
918
|
57
|
|
|
|
|
|
return 1; |
919
|
|
|
|
|
|
|
} |
920
|
|
|
|
|
|
|
|
921
|
109
|
50
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
922
|
0
|
|
|
|
|
|
return 0; |
923
|
|
|
|
|
|
|
|
924
|
109
|
50
|
|
|
|
|
if (yaml_emitter_check_simple_key(emitter)) |
925
|
|
|
|
|
|
|
{ |
926
|
109
|
50
|
|
|
|
|
if (!PUSH(emitter, emitter->states, |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
927
|
|
|
|
|
|
|
YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE)) |
928
|
0
|
|
|
|
|
|
return 0; |
929
|
|
|
|
|
|
|
|
930
|
109
|
|
|
|
|
|
return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 1); |
931
|
|
|
|
|
|
|
} |
932
|
|
|
|
|
|
|
else |
933
|
|
|
|
|
|
|
{ |
934
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 1)) |
935
|
0
|
|
|
|
|
|
return 0; |
936
|
0
|
0
|
|
|
|
|
if (!PUSH(emitter, emitter->states, |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
937
|
|
|
|
|
|
|
YAML_EMIT_BLOCK_MAPPING_VALUE_STATE)) |
938
|
0
|
|
|
|
|
|
return 0; |
939
|
|
|
|
|
|
|
|
940
|
0
|
|
|
|
|
|
return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0); |
941
|
|
|
|
|
|
|
} |
942
|
|
|
|
|
|
|
} |
943
|
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
/* |
945
|
|
|
|
|
|
|
* Expect a block value node. |
946
|
|
|
|
|
|
|
*/ |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
static int |
949
|
109
|
|
|
|
|
|
yaml_emitter_emit_block_mapping_value(yaml_emitter_t *emitter, |
950
|
|
|
|
|
|
|
yaml_event_t *event, int simple) |
951
|
|
|
|
|
|
|
{ |
952
|
109
|
50
|
|
|
|
|
if (simple) { |
953
|
109
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0)) |
954
|
0
|
|
|
|
|
|
return 0; |
955
|
|
|
|
|
|
|
} |
956
|
|
|
|
|
|
|
else { |
957
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
958
|
0
|
|
|
|
|
|
return 0; |
959
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 1)) |
960
|
0
|
|
|
|
|
|
return 0; |
961
|
|
|
|
|
|
|
} |
962
|
109
|
50
|
|
|
|
|
if (!PUSH(emitter, emitter->states, |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
963
|
|
|
|
|
|
|
YAML_EMIT_BLOCK_MAPPING_KEY_STATE)) |
964
|
0
|
|
|
|
|
|
return 0; |
965
|
|
|
|
|
|
|
|
966
|
109
|
|
|
|
|
|
return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0); |
967
|
|
|
|
|
|
|
} |
968
|
|
|
|
|
|
|
|
969
|
|
|
|
|
|
|
/* |
970
|
|
|
|
|
|
|
* Expect a node. |
971
|
|
|
|
|
|
|
*/ |
972
|
|
|
|
|
|
|
|
973
|
|
|
|
|
|
|
static int |
974
|
418
|
|
|
|
|
|
yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event, |
975
|
|
|
|
|
|
|
int root, int sequence, int mapping, int simple_key) |
976
|
|
|
|
|
|
|
{ |
977
|
418
|
|
|
|
|
|
emitter->root_context = root; |
978
|
418
|
|
|
|
|
|
emitter->sequence_context = sequence; |
979
|
418
|
|
|
|
|
|
emitter->mapping_context = mapping; |
980
|
418
|
|
|
|
|
|
emitter->simple_key_context = simple_key; |
981
|
|
|
|
|
|
|
|
982
|
418
|
|
|
|
|
|
switch (event->type) |
983
|
|
|
|
|
|
|
{ |
984
|
|
|
|
|
|
|
case YAML_ALIAS_EVENT: |
985
|
17
|
|
|
|
|
|
return yaml_emitter_emit_alias(emitter, event); |
986
|
|
|
|
|
|
|
|
987
|
|
|
|
|
|
|
case YAML_SCALAR_EVENT: |
988
|
291
|
|
|
|
|
|
return yaml_emitter_emit_scalar(emitter, event); |
989
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
case YAML_SEQUENCE_START_EVENT: |
991
|
44
|
|
|
|
|
|
return yaml_emitter_emit_sequence_start(emitter, event); |
992
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
case YAML_MAPPING_START_EVENT: |
994
|
66
|
|
|
|
|
|
return yaml_emitter_emit_mapping_start(emitter, event); |
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
default: |
997
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
998
|
|
|
|
|
|
|
"expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS"); |
999
|
|
|
|
|
|
|
} |
1000
|
|
|
|
|
|
|
} |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
/* |
1003
|
|
|
|
|
|
|
* Expect ALIAS. |
1004
|
|
|
|
|
|
|
*/ |
1005
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
static int |
1007
|
17
|
|
|
|
|
|
yaml_emitter_emit_alias(yaml_emitter_t *emitter, SHIM(yaml_event_t *event)) |
1008
|
|
|
|
|
|
|
{ |
1009
|
17
|
50
|
|
|
|
|
if (!yaml_emitter_process_anchor(emitter)) |
1010
|
0
|
|
|
|
|
|
return 0; |
1011
|
17
|
|
|
|
|
|
emitter->state = POP(emitter, emitter->states); |
1012
|
|
|
|
|
|
|
|
1013
|
17
|
|
|
|
|
|
return 1; |
1014
|
|
|
|
|
|
|
} |
1015
|
|
|
|
|
|
|
|
1016
|
|
|
|
|
|
|
/* |
1017
|
|
|
|
|
|
|
* Expect SCALAR. |
1018
|
|
|
|
|
|
|
*/ |
1019
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
static int |
1021
|
291
|
|
|
|
|
|
yaml_emitter_emit_scalar(yaml_emitter_t *emitter, yaml_event_t *event) |
1022
|
|
|
|
|
|
|
{ |
1023
|
291
|
50
|
|
|
|
|
if (!yaml_emitter_select_scalar_style(emitter, event)) |
1024
|
0
|
|
|
|
|
|
return 0; |
1025
|
291
|
50
|
|
|
|
|
if (!yaml_emitter_process_anchor(emitter)) |
1026
|
0
|
|
|
|
|
|
return 0; |
1027
|
291
|
50
|
|
|
|
|
if (!yaml_emitter_process_tag(emitter)) |
1028
|
0
|
|
|
|
|
|
return 0; |
1029
|
291
|
50
|
|
|
|
|
if (!yaml_emitter_increase_indent(emitter, 1, 0)) |
1030
|
0
|
|
|
|
|
|
return 0; |
1031
|
291
|
50
|
|
|
|
|
if (!yaml_emitter_process_scalar(emitter)) |
1032
|
0
|
|
|
|
|
|
return 0; |
1033
|
291
|
|
|
|
|
|
emitter->indent = POP(emitter, emitter->indents); |
1034
|
291
|
|
|
|
|
|
emitter->state = POP(emitter, emitter->states); |
1035
|
|
|
|
|
|
|
|
1036
|
291
|
|
|
|
|
|
return 1; |
1037
|
|
|
|
|
|
|
} |
1038
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
/* |
1040
|
|
|
|
|
|
|
* Expect SEQUENCE-START. |
1041
|
|
|
|
|
|
|
*/ |
1042
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
static int |
1044
|
44
|
|
|
|
|
|
yaml_emitter_emit_sequence_start(yaml_emitter_t *emitter, yaml_event_t *event) |
1045
|
|
|
|
|
|
|
{ |
1046
|
44
|
50
|
|
|
|
|
if (!yaml_emitter_process_anchor(emitter)) |
1047
|
0
|
|
|
|
|
|
return 0; |
1048
|
44
|
50
|
|
|
|
|
if (!yaml_emitter_process_tag(emitter)) |
1049
|
0
|
|
|
|
|
|
return 0; |
1050
|
|
|
|
|
|
|
|
1051
|
44
|
50
|
|
|
|
|
if (emitter->flow_level || emitter->canonical |
|
|
50
|
|
|
|
|
|
1052
|
44
|
50
|
|
|
|
|
|| event->data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE |
1053
|
44
|
100
|
|
|
|
|
|| yaml_emitter_check_empty_sequence(emitter)) { |
1054
|
10
|
|
|
|
|
|
emitter->state = YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE; |
1055
|
|
|
|
|
|
|
} |
1056
|
|
|
|
|
|
|
else { |
1057
|
34
|
|
|
|
|
|
emitter->state = YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE; |
1058
|
|
|
|
|
|
|
} |
1059
|
|
|
|
|
|
|
|
1060
|
44
|
|
|
|
|
|
return 1; |
1061
|
|
|
|
|
|
|
} |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
/* |
1064
|
|
|
|
|
|
|
* Expect MAPPING-START. |
1065
|
|
|
|
|
|
|
*/ |
1066
|
|
|
|
|
|
|
|
1067
|
|
|
|
|
|
|
static int |
1068
|
66
|
|
|
|
|
|
yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event) |
1069
|
|
|
|
|
|
|
{ |
1070
|
66
|
50
|
|
|
|
|
if (!yaml_emitter_process_anchor(emitter)) |
1071
|
0
|
|
|
|
|
|
return 0; |
1072
|
66
|
50
|
|
|
|
|
if (!yaml_emitter_process_tag(emitter)) |
1073
|
0
|
|
|
|
|
|
return 0; |
1074
|
|
|
|
|
|
|
|
1075
|
66
|
50
|
|
|
|
|
if (emitter->flow_level || emitter->canonical |
|
|
50
|
|
|
|
|
|
1076
|
66
|
50
|
|
|
|
|
|| event->data.mapping_start.style == YAML_FLOW_MAPPING_STYLE |
1077
|
66
|
100
|
|
|
|
|
|| yaml_emitter_check_empty_mapping(emitter)) { |
1078
|
9
|
|
|
|
|
|
emitter->state = YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE; |
1079
|
|
|
|
|
|
|
} |
1080
|
|
|
|
|
|
|
else { |
1081
|
57
|
|
|
|
|
|
emitter->state = YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE; |
1082
|
|
|
|
|
|
|
} |
1083
|
|
|
|
|
|
|
|
1084
|
66
|
|
|
|
|
|
return 1; |
1085
|
|
|
|
|
|
|
} |
1086
|
|
|
|
|
|
|
|
1087
|
|
|
|
|
|
|
/* |
1088
|
|
|
|
|
|
|
* Check if the document content is an empty scalar. |
1089
|
|
|
|
|
|
|
*/ |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
static int |
1092
|
109
|
|
|
|
|
|
yaml_emitter_check_empty_document(SHIM(yaml_emitter_t *emitter)) |
1093
|
|
|
|
|
|
|
{ |
1094
|
109
|
|
|
|
|
|
return 0; |
1095
|
|
|
|
|
|
|
} |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
/* |
1098
|
|
|
|
|
|
|
* Check if the next events represent an empty sequence. |
1099
|
|
|
|
|
|
|
*/ |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
static int |
1102
|
44
|
|
|
|
|
|
yaml_emitter_check_empty_sequence(yaml_emitter_t *emitter) |
1103
|
|
|
|
|
|
|
{ |
1104
|
44
|
50
|
|
|
|
|
if (emitter->events.tail - emitter->events.head < 2) |
1105
|
0
|
|
|
|
|
|
return 0; |
1106
|
|
|
|
|
|
|
|
1107
|
44
|
|
|
|
|
|
return (emitter->events.head[0].type == YAML_SEQUENCE_START_EVENT |
1108
|
44
|
50
|
|
|
|
|
&& emitter->events.head[1].type == YAML_SEQUENCE_END_EVENT); |
|
|
100
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
} |
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
/* |
1112
|
|
|
|
|
|
|
* Check if the next events represent an empty mapping. |
1113
|
|
|
|
|
|
|
*/ |
1114
|
|
|
|
|
|
|
|
1115
|
|
|
|
|
|
|
static int |
1116
|
66
|
|
|
|
|
|
yaml_emitter_check_empty_mapping(yaml_emitter_t *emitter) |
1117
|
|
|
|
|
|
|
{ |
1118
|
66
|
50
|
|
|
|
|
if (emitter->events.tail - emitter->events.head < 2) |
1119
|
0
|
|
|
|
|
|
return 0; |
1120
|
|
|
|
|
|
|
|
1121
|
66
|
|
|
|
|
|
return (emitter->events.head[0].type == YAML_MAPPING_START_EVENT |
1122
|
66
|
50
|
|
|
|
|
&& emitter->events.head[1].type == YAML_MAPPING_END_EVENT); |
|
|
100
|
|
|
|
|
|
1123
|
|
|
|
|
|
|
} |
1124
|
|
|
|
|
|
|
|
1125
|
|
|
|
|
|
|
/* |
1126
|
|
|
|
|
|
|
* Check if the next node can be expressed as a simple key. |
1127
|
|
|
|
|
|
|
*/ |
1128
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
static int |
1130
|
109
|
|
|
|
|
|
yaml_emitter_check_simple_key(yaml_emitter_t *emitter) |
1131
|
|
|
|
|
|
|
{ |
1132
|
109
|
|
|
|
|
|
yaml_event_t *event = emitter->events.head; |
1133
|
109
|
|
|
|
|
|
size_t length = 0; |
1134
|
|
|
|
|
|
|
|
1135
|
109
|
|
|
|
|
|
switch (event->type) |
1136
|
|
|
|
|
|
|
{ |
1137
|
|
|
|
|
|
|
case YAML_ALIAS_EVENT: |
1138
|
0
|
|
|
|
|
|
length += emitter->anchor_data.anchor_length; |
1139
|
0
|
|
|
|
|
|
break; |
1140
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
case YAML_SCALAR_EVENT: |
1142
|
109
|
50
|
|
|
|
|
if (emitter->scalar_data.multiline) |
1143
|
0
|
|
|
|
|
|
return 0; |
1144
|
218
|
|
|
|
|
|
length += emitter->anchor_data.anchor_length |
1145
|
109
|
|
|
|
|
|
+ emitter->tag_data.handle_length |
1146
|
109
|
|
|
|
|
|
+ emitter->tag_data.suffix_length |
1147
|
109
|
|
|
|
|
|
+ emitter->scalar_data.length; |
1148
|
109
|
|
|
|
|
|
break; |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
case YAML_SEQUENCE_START_EVENT: |
1151
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_check_empty_sequence(emitter)) |
1152
|
0
|
|
|
|
|
|
return 0; |
1153
|
0
|
|
|
|
|
|
length += emitter->anchor_data.anchor_length |
1154
|
0
|
|
|
|
|
|
+ emitter->tag_data.handle_length |
1155
|
0
|
|
|
|
|
|
+ emitter->tag_data.suffix_length; |
1156
|
0
|
|
|
|
|
|
break; |
1157
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
case YAML_MAPPING_START_EVENT: |
1159
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_check_empty_mapping(emitter)) |
1160
|
0
|
|
|
|
|
|
return 0; |
1161
|
0
|
|
|
|
|
|
length += emitter->anchor_data.anchor_length |
1162
|
0
|
|
|
|
|
|
+ emitter->tag_data.handle_length |
1163
|
0
|
|
|
|
|
|
+ emitter->tag_data.suffix_length; |
1164
|
0
|
|
|
|
|
|
break; |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
default: |
1167
|
0
|
|
|
|
|
|
return 0; |
1168
|
|
|
|
|
|
|
} |
1169
|
|
|
|
|
|
|
|
1170
|
109
|
50
|
|
|
|
|
if (length > 128) |
1171
|
0
|
|
|
|
|
|
return 0; |
1172
|
|
|
|
|
|
|
|
1173
|
109
|
|
|
|
|
|
return 1; |
1174
|
|
|
|
|
|
|
} |
1175
|
|
|
|
|
|
|
|
1176
|
|
|
|
|
|
|
/* |
1177
|
|
|
|
|
|
|
* Determine an acceptable scalar style. |
1178
|
|
|
|
|
|
|
*/ |
1179
|
|
|
|
|
|
|
|
1180
|
|
|
|
|
|
|
static int |
1181
|
291
|
|
|
|
|
|
yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event) |
1182
|
|
|
|
|
|
|
{ |
1183
|
291
|
|
|
|
|
|
yaml_scalar_style_t style = event->data.scalar.style; |
1184
|
291
|
100
|
|
|
|
|
int no_tag = (!emitter->tag_data.handle && !emitter->tag_data.suffix); |
|
|
50
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
|
1186
|
291
|
100
|
|
|
|
|
if (no_tag && !event->data.scalar.plain_implicit |
|
|
50
|
|
|
|
|
|
1187
|
0
|
0
|
|
|
|
|
&& !event->data.scalar.quoted_implicit) { |
1188
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
1189
|
|
|
|
|
|
|
"neither tag nor implicit flags are specified"); |
1190
|
|
|
|
|
|
|
} |
1191
|
|
|
|
|
|
|
|
1192
|
291
|
50
|
|
|
|
|
if (style == YAML_ANY_SCALAR_STYLE) |
1193
|
0
|
|
|
|
|
|
style = YAML_PLAIN_SCALAR_STYLE; |
1194
|
|
|
|
|
|
|
|
1195
|
291
|
50
|
|
|
|
|
if (emitter->canonical) |
1196
|
0
|
|
|
|
|
|
style = YAML_DOUBLE_QUOTED_SCALAR_STYLE; |
1197
|
|
|
|
|
|
|
|
1198
|
291
|
100
|
|
|
|
|
if (emitter->simple_key_context && emitter->scalar_data.multiline) |
|
|
50
|
|
|
|
|
|
1199
|
0
|
|
|
|
|
|
style = YAML_DOUBLE_QUOTED_SCALAR_STYLE; |
1200
|
|
|
|
|
|
|
|
1201
|
291
|
100
|
|
|
|
|
if (style == YAML_PLAIN_SCALAR_STYLE) |
1202
|
|
|
|
|
|
|
{ |
1203
|
262
|
50
|
|
|
|
|
if ((emitter->flow_level && !emitter->scalar_data.flow_plain_allowed) |
|
|
0
|
|
|
|
|
|
1204
|
262
|
50
|
|
|
|
|
|| (!emitter->flow_level && !emitter->scalar_data.block_plain_allowed)) |
|
|
100
|
|
|
|
|
|
1205
|
10
|
|
|
|
|
|
style = YAML_SINGLE_QUOTED_SCALAR_STYLE; |
1206
|
262
|
50
|
|
|
|
|
if (!emitter->scalar_data.length |
1207
|
0
|
0
|
|
|
|
|
&& (emitter->flow_level || emitter->simple_key_context)) |
|
|
0
|
|
|
|
|
|
1208
|
0
|
|
|
|
|
|
style = YAML_SINGLE_QUOTED_SCALAR_STYLE; |
1209
|
262
|
100
|
|
|
|
|
if (no_tag && !event->data.scalar.plain_implicit) |
|
|
50
|
|
|
|
|
|
1210
|
0
|
|
|
|
|
|
style = YAML_SINGLE_QUOTED_SCALAR_STYLE; |
1211
|
|
|
|
|
|
|
} |
1212
|
|
|
|
|
|
|
|
1213
|
291
|
100
|
|
|
|
|
if (style == YAML_SINGLE_QUOTED_SCALAR_STYLE) |
1214
|
|
|
|
|
|
|
{ |
1215
|
33
|
100
|
|
|
|
|
if (!emitter->scalar_data.single_quoted_allowed) |
1216
|
5
|
|
|
|
|
|
style = YAML_DOUBLE_QUOTED_SCALAR_STYLE; |
1217
|
|
|
|
|
|
|
} |
1218
|
|
|
|
|
|
|
|
1219
|
291
|
100
|
|
|
|
|
if (style == YAML_LITERAL_SCALAR_STYLE || style == YAML_FOLDED_SCALAR_STYLE) |
|
|
50
|
|
|
|
|
|
1220
|
|
|
|
|
|
|
{ |
1221
|
3
|
50
|
|
|
|
|
if (!emitter->scalar_data.block_allowed |
1222
|
3
|
50
|
|
|
|
|
|| emitter->flow_level || emitter->simple_key_context) |
|
|
50
|
|
|
|
|
|
1223
|
0
|
|
|
|
|
|
style = YAML_DOUBLE_QUOTED_SCALAR_STYLE; |
1224
|
|
|
|
|
|
|
} |
1225
|
|
|
|
|
|
|
|
1226
|
291
|
100
|
|
|
|
|
if (no_tag && !event->data.scalar.quoted_implicit |
|
|
50
|
|
|
|
|
|
1227
|
0
|
0
|
|
|
|
|
&& style != YAML_PLAIN_SCALAR_STYLE) |
1228
|
|
|
|
|
|
|
{ |
1229
|
0
|
|
|
|
|
|
emitter->tag_data.handle = (yaml_char_t *)"!"; |
1230
|
0
|
|
|
|
|
|
emitter->tag_data.handle_length = 1; |
1231
|
|
|
|
|
|
|
} |
1232
|
|
|
|
|
|
|
|
1233
|
291
|
|
|
|
|
|
emitter->scalar_data.style = style; |
1234
|
|
|
|
|
|
|
|
1235
|
291
|
|
|
|
|
|
return 1; |
1236
|
|
|
|
|
|
|
} |
1237
|
|
|
|
|
|
|
|
1238
|
|
|
|
|
|
|
/* |
1239
|
|
|
|
|
|
|
* Write an anchor. |
1240
|
|
|
|
|
|
|
*/ |
1241
|
|
|
|
|
|
|
|
1242
|
|
|
|
|
|
|
static int |
1243
|
418
|
|
|
|
|
|
yaml_emitter_process_anchor(yaml_emitter_t *emitter) |
1244
|
|
|
|
|
|
|
{ |
1245
|
418
|
100
|
|
|
|
|
if (!emitter->anchor_data.anchor) |
1246
|
385
|
|
|
|
|
|
return 1; |
1247
|
|
|
|
|
|
|
|
1248
|
33
|
100
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, |
|
|
50
|
|
|
|
|
|
1249
|
33
|
|
|
|
|
|
(emitter->anchor_data.alias ? "*" : "&"), 1, 0, 0)) |
1250
|
0
|
|
|
|
|
|
return 0; |
1251
|
|
|
|
|
|
|
|
1252
|
33
|
|
|
|
|
|
return yaml_emitter_write_anchor(emitter, |
1253
|
|
|
|
|
|
|
emitter->anchor_data.anchor, emitter->anchor_data.anchor_length); |
1254
|
|
|
|
|
|
|
} |
1255
|
|
|
|
|
|
|
|
1256
|
|
|
|
|
|
|
/* |
1257
|
|
|
|
|
|
|
* Write a tag. |
1258
|
|
|
|
|
|
|
*/ |
1259
|
|
|
|
|
|
|
|
1260
|
|
|
|
|
|
|
static int |
1261
|
401
|
|
|
|
|
|
yaml_emitter_process_tag(yaml_emitter_t *emitter) |
1262
|
|
|
|
|
|
|
{ |
1263
|
401
|
100
|
|
|
|
|
if (!emitter->tag_data.handle && !emitter->tag_data.suffix) |
|
|
50
|
|
|
|
|
|
1264
|
358
|
|
|
|
|
|
return 1; |
1265
|
|
|
|
|
|
|
|
1266
|
43
|
50
|
|
|
|
|
if (emitter->tag_data.handle) |
1267
|
|
|
|
|
|
|
{ |
1268
|
43
|
50
|
|
|
|
|
if (!yaml_emitter_write_tag_handle(emitter, emitter->tag_data.handle, |
1269
|
|
|
|
|
|
|
emitter->tag_data.handle_length)) |
1270
|
0
|
|
|
|
|
|
return 0; |
1271
|
43
|
50
|
|
|
|
|
if (emitter->tag_data.suffix) { |
1272
|
43
|
50
|
|
|
|
|
if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix, |
1273
|
|
|
|
|
|
|
emitter->tag_data.suffix_length, 0)) |
1274
|
0
|
|
|
|
|
|
return 0; |
1275
|
|
|
|
|
|
|
} |
1276
|
|
|
|
|
|
|
} |
1277
|
|
|
|
|
|
|
else |
1278
|
|
|
|
|
|
|
{ |
1279
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "!<", 1, 0, 0)) |
1280
|
0
|
|
|
|
|
|
return 0; |
1281
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix, |
1282
|
|
|
|
|
|
|
emitter->tag_data.suffix_length, 0)) |
1283
|
0
|
|
|
|
|
|
return 0; |
1284
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ">", 0, 0, 0)) |
1285
|
0
|
|
|
|
|
|
return 0; |
1286
|
|
|
|
|
|
|
} |
1287
|
|
|
|
|
|
|
|
1288
|
43
|
|
|
|
|
|
return 1; |
1289
|
|
|
|
|
|
|
} |
1290
|
|
|
|
|
|
|
|
1291
|
|
|
|
|
|
|
/* |
1292
|
|
|
|
|
|
|
* Write a scalar. |
1293
|
|
|
|
|
|
|
*/ |
1294
|
|
|
|
|
|
|
|
1295
|
|
|
|
|
|
|
static int |
1296
|
291
|
|
|
|
|
|
yaml_emitter_process_scalar(yaml_emitter_t *emitter) |
1297
|
|
|
|
|
|
|
{ |
1298
|
291
|
|
|
|
|
|
switch (emitter->scalar_data.style) |
1299
|
|
|
|
|
|
|
{ |
1300
|
|
|
|
|
|
|
case YAML_PLAIN_SCALAR_STYLE: |
1301
|
252
|
|
|
|
|
|
return yaml_emitter_write_plain_scalar(emitter, |
1302
|
|
|
|
|
|
|
emitter->scalar_data.value, emitter->scalar_data.length, |
1303
|
252
|
|
|
|
|
|
!emitter->simple_key_context); |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
case YAML_SINGLE_QUOTED_SCALAR_STYLE: |
1306
|
28
|
|
|
|
|
|
return yaml_emitter_write_single_quoted_scalar(emitter, |
1307
|
|
|
|
|
|
|
emitter->scalar_data.value, emitter->scalar_data.length, |
1308
|
28
|
|
|
|
|
|
!emitter->simple_key_context); |
1309
|
|
|
|
|
|
|
|
1310
|
|
|
|
|
|
|
case YAML_DOUBLE_QUOTED_SCALAR_STYLE: |
1311
|
8
|
|
|
|
|
|
return yaml_emitter_write_double_quoted_scalar(emitter, |
1312
|
|
|
|
|
|
|
emitter->scalar_data.value, emitter->scalar_data.length, |
1313
|
8
|
|
|
|
|
|
!emitter->simple_key_context); |
1314
|
|
|
|
|
|
|
|
1315
|
|
|
|
|
|
|
case YAML_LITERAL_SCALAR_STYLE: |
1316
|
3
|
|
|
|
|
|
return yaml_emitter_write_literal_scalar(emitter, |
1317
|
|
|
|
|
|
|
emitter->scalar_data.value, emitter->scalar_data.length); |
1318
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
case YAML_FOLDED_SCALAR_STYLE: |
1320
|
0
|
|
|
|
|
|
return yaml_emitter_write_folded_scalar(emitter, |
1321
|
|
|
|
|
|
|
emitter->scalar_data.value, emitter->scalar_data.length); |
1322
|
|
|
|
|
|
|
|
1323
|
|
|
|
|
|
|
default: |
1324
|
|
|
|
|
|
|
assert(1); /* Impossible. */ |
1325
|
|
|
|
|
|
|
} |
1326
|
|
|
|
|
|
|
|
1327
|
0
|
|
|
|
|
|
return 0; |
1328
|
|
|
|
|
|
|
} |
1329
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
/* |
1331
|
|
|
|
|
|
|
* Check if a %YAML directive is valid. |
1332
|
|
|
|
|
|
|
*/ |
1333
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
static int |
1335
|
0
|
|
|
|
|
|
yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter, |
1336
|
|
|
|
|
|
|
yaml_version_directive_t version_directive) |
1337
|
|
|
|
|
|
|
{ |
1338
|
0
|
0
|
|
|
|
|
if (version_directive.major != 1 || version_directive.minor != 1) { |
|
|
0
|
|
|
|
|
|
1339
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
1340
|
|
|
|
|
|
|
"incompatible %YAML directive"); |
1341
|
|
|
|
|
|
|
} |
1342
|
|
|
|
|
|
|
|
1343
|
0
|
|
|
|
|
|
return 1; |
1344
|
|
|
|
|
|
|
} |
1345
|
|
|
|
|
|
|
|
1346
|
|
|
|
|
|
|
/* |
1347
|
|
|
|
|
|
|
* Check if a %TAG directive is valid. |
1348
|
|
|
|
|
|
|
*/ |
1349
|
|
|
|
|
|
|
|
1350
|
|
|
|
|
|
|
static int |
1351
|
0
|
|
|
|
|
|
yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter, |
1352
|
|
|
|
|
|
|
yaml_tag_directive_t tag_directive) |
1353
|
|
|
|
|
|
|
{ |
1354
|
|
|
|
|
|
|
yaml_string_t handle; |
1355
|
|
|
|
|
|
|
yaml_string_t prefix; |
1356
|
|
|
|
|
|
|
size_t handle_length; |
1357
|
|
|
|
|
|
|
size_t prefix_length; |
1358
|
|
|
|
|
|
|
|
1359
|
0
|
|
|
|
|
|
handle_length = strlen((char *)tag_directive.handle); |
1360
|
0
|
|
|
|
|
|
prefix_length = strlen((char *)tag_directive.prefix); |
1361
|
0
|
|
|
|
|
|
STRING_ASSIGN(handle, tag_directive.handle, handle_length); |
1362
|
0
|
|
|
|
|
|
STRING_ASSIGN(prefix, tag_directive.prefix, prefix_length); |
1363
|
|
|
|
|
|
|
|
1364
|
0
|
0
|
|
|
|
|
if (handle.start == handle.end) { |
1365
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
1366
|
|
|
|
|
|
|
"tag handle must not be empty"); |
1367
|
|
|
|
|
|
|
} |
1368
|
|
|
|
|
|
|
|
1369
|
0
|
0
|
|
|
|
|
if (handle.start[0] != '!') { |
1370
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
1371
|
|
|
|
|
|
|
"tag handle must start with '!'"); |
1372
|
|
|
|
|
|
|
} |
1373
|
|
|
|
|
|
|
|
1374
|
0
|
0
|
|
|
|
|
if (handle.end[-1] != '!') { |
1375
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
1376
|
|
|
|
|
|
|
"tag handle must end with '!'"); |
1377
|
|
|
|
|
|
|
} |
1378
|
|
|
|
|
|
|
|
1379
|
0
|
|
|
|
|
|
handle.pointer ++; |
1380
|
|
|
|
|
|
|
|
1381
|
0
|
0
|
|
|
|
|
while (handle.pointer < handle.end-1) { |
1382
|
0
|
0
|
|
|
|
|
if (!IS_ALPHA(handle)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1383
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
1384
|
|
|
|
|
|
|
"tag handle must contain alphanumerical characters only"); |
1385
|
|
|
|
|
|
|
} |
1386
|
0
|
0
|
|
|
|
|
MOVE(handle); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1387
|
|
|
|
|
|
|
} |
1388
|
|
|
|
|
|
|
|
1389
|
0
|
0
|
|
|
|
|
if (prefix.start == prefix.end) { |
1390
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
1391
|
|
|
|
|
|
|
"tag prefix must not be empty"); |
1392
|
|
|
|
|
|
|
} |
1393
|
|
|
|
|
|
|
|
1394
|
0
|
|
|
|
|
|
return 1; |
1395
|
|
|
|
|
|
|
} |
1396
|
|
|
|
|
|
|
|
1397
|
|
|
|
|
|
|
/* |
1398
|
|
|
|
|
|
|
* Check if an anchor is valid. |
1399
|
|
|
|
|
|
|
*/ |
1400
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
static int |
1402
|
33
|
|
|
|
|
|
yaml_emitter_analyze_anchor(yaml_emitter_t *emitter, |
1403
|
|
|
|
|
|
|
yaml_char_t *anchor, int alias) |
1404
|
|
|
|
|
|
|
{ |
1405
|
|
|
|
|
|
|
size_t anchor_length; |
1406
|
|
|
|
|
|
|
yaml_string_t string; |
1407
|
|
|
|
|
|
|
|
1408
|
33
|
|
|
|
|
|
anchor_length = strlen((char *)anchor); |
1409
|
33
|
|
|
|
|
|
STRING_ASSIGN(string, anchor, anchor_length); |
1410
|
|
|
|
|
|
|
|
1411
|
33
|
50
|
|
|
|
|
if (string.start == string.end) { |
1412
|
0
|
0
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, alias ? |
1413
|
|
|
|
|
|
|
"alias value must not be empty" : |
1414
|
|
|
|
|
|
|
"anchor value must not be empty"); |
1415
|
|
|
|
|
|
|
} |
1416
|
|
|
|
|
|
|
|
1417
|
66
|
100
|
|
|
|
|
while (string.pointer != string.end) { |
1418
|
33
|
50
|
|
|
|
|
if (!IS_ALPHA(string)) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1419
|
0
|
0
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, alias ? |
1420
|
|
|
|
|
|
|
"alias value must contain alphanumerical characters only" : |
1421
|
|
|
|
|
|
|
"anchor value must contain alphanumerical characters only"); |
1422
|
|
|
|
|
|
|
} |
1423
|
33
|
50
|
|
|
|
|
MOVE(string); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1424
|
|
|
|
|
|
|
} |
1425
|
|
|
|
|
|
|
|
1426
|
33
|
|
|
|
|
|
emitter->anchor_data.anchor = string.start; |
1427
|
33
|
|
|
|
|
|
emitter->anchor_data.anchor_length = string.end - string.start; |
1428
|
33
|
|
|
|
|
|
emitter->anchor_data.alias = alias; |
1429
|
|
|
|
|
|
|
|
1430
|
33
|
|
|
|
|
|
return 1; |
1431
|
|
|
|
|
|
|
} |
1432
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
/* |
1434
|
|
|
|
|
|
|
* Check if a tag is valid. |
1435
|
|
|
|
|
|
|
*/ |
1436
|
|
|
|
|
|
|
|
1437
|
|
|
|
|
|
|
static int |
1438
|
43
|
|
|
|
|
|
yaml_emitter_analyze_tag(yaml_emitter_t *emitter, |
1439
|
|
|
|
|
|
|
yaml_char_t *tag) |
1440
|
|
|
|
|
|
|
{ |
1441
|
|
|
|
|
|
|
size_t tag_length; |
1442
|
|
|
|
|
|
|
yaml_string_t string; |
1443
|
|
|
|
|
|
|
yaml_tag_directive_t *tag_directive; |
1444
|
|
|
|
|
|
|
|
1445
|
43
|
|
|
|
|
|
tag_length = strlen((char *)tag); |
1446
|
43
|
|
|
|
|
|
STRING_ASSIGN(string, tag, tag_length); |
1447
|
|
|
|
|
|
|
|
1448
|
43
|
50
|
|
|
|
|
if (string.start == string.end) { |
1449
|
0
|
|
|
|
|
|
return yaml_emitter_set_emitter_error(emitter, |
1450
|
|
|
|
|
|
|
"tag value must not be empty"); |
1451
|
|
|
|
|
|
|
} |
1452
|
|
|
|
|
|
|
|
1453
|
86
|
50
|
|
|
|
|
for (tag_directive = emitter->tag_directives.start; |
1454
|
43
|
|
|
|
|
|
tag_directive != emitter->tag_directives.top; tag_directive ++) { |
1455
|
86
|
|
|
|
|
|
size_t prefix_length = strlen((char *)tag_directive->prefix); |
1456
|
86
|
50
|
|
|
|
|
if (prefix_length < (size_t)(string.end - string.start) |
1457
|
86
|
100
|
|
|
|
|
&& strncmp((char *)tag_directive->prefix, (char *)string.start, |
1458
|
|
|
|
|
|
|
prefix_length) == 0) |
1459
|
|
|
|
|
|
|
{ |
1460
|
43
|
|
|
|
|
|
emitter->tag_data.handle = tag_directive->handle; |
1461
|
43
|
|
|
|
|
|
emitter->tag_data.handle_length = |
1462
|
43
|
|
|
|
|
|
strlen((char *)tag_directive->handle); |
1463
|
43
|
|
|
|
|
|
emitter->tag_data.suffix = string.start + prefix_length; |
1464
|
43
|
|
|
|
|
|
emitter->tag_data.suffix_length = |
1465
|
43
|
|
|
|
|
|
(string.end - string.start) - prefix_length; |
1466
|
43
|
|
|
|
|
|
return 1; |
1467
|
|
|
|
|
|
|
} |
1468
|
|
|
|
|
|
|
} |
1469
|
|
|
|
|
|
|
|
1470
|
0
|
|
|
|
|
|
emitter->tag_data.suffix = string.start; |
1471
|
0
|
|
|
|
|
|
emitter->tag_data.suffix_length = string.end - string.start; |
1472
|
|
|
|
|
|
|
|
1473
|
43
|
|
|
|
|
|
return 1; |
1474
|
|
|
|
|
|
|
} |
1475
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
/* |
1477
|
|
|
|
|
|
|
* Check if a scalar is valid. |
1478
|
|
|
|
|
|
|
*/ |
1479
|
|
|
|
|
|
|
|
1480
|
|
|
|
|
|
|
static int |
1481
|
291
|
|
|
|
|
|
yaml_emitter_analyze_scalar(yaml_emitter_t *emitter, |
1482
|
|
|
|
|
|
|
yaml_char_t *value, size_t length) |
1483
|
|
|
|
|
|
|
{ |
1484
|
|
|
|
|
|
|
yaml_string_t string; |
1485
|
|
|
|
|
|
|
|
1486
|
291
|
|
|
|
|
|
int block_indicators = 0; |
1487
|
291
|
|
|
|
|
|
int flow_indicators = 0; |
1488
|
291
|
|
|
|
|
|
int line_breaks = 0; |
1489
|
291
|
|
|
|
|
|
int special_characters = 0; |
1490
|
|
|
|
|
|
|
|
1491
|
291
|
|
|
|
|
|
int leading_space = 0; |
1492
|
291
|
|
|
|
|
|
int leading_break = 0; |
1493
|
291
|
|
|
|
|
|
int trailing_space = 0; |
1494
|
291
|
|
|
|
|
|
int trailing_break = 0; |
1495
|
291
|
|
|
|
|
|
int break_space = 0; |
1496
|
291
|
|
|
|
|
|
int space_break = 0; |
1497
|
|
|
|
|
|
|
|
1498
|
291
|
|
|
|
|
|
int preceded_by_whitespace = 0; |
1499
|
291
|
|
|
|
|
|
int followed_by_whitespace = 0; |
1500
|
291
|
|
|
|
|
|
int previous_space = 0; |
1501
|
291
|
|
|
|
|
|
int previous_break = 0; |
1502
|
|
|
|
|
|
|
|
1503
|
291
|
|
|
|
|
|
STRING_ASSIGN(string, value, length); |
1504
|
|
|
|
|
|
|
|
1505
|
291
|
|
|
|
|
|
emitter->scalar_data.value = value; |
1506
|
291
|
|
|
|
|
|
emitter->scalar_data.length = length; |
1507
|
|
|
|
|
|
|
|
1508
|
291
|
100
|
|
|
|
|
if (string.start == string.end) |
1509
|
|
|
|
|
|
|
{ |
1510
|
5
|
|
|
|
|
|
emitter->scalar_data.multiline = 0; |
1511
|
5
|
|
|
|
|
|
emitter->scalar_data.flow_plain_allowed = 0; |
1512
|
5
|
|
|
|
|
|
emitter->scalar_data.block_plain_allowed = 1; |
1513
|
5
|
|
|
|
|
|
emitter->scalar_data.single_quoted_allowed = 1; |
1514
|
5
|
|
|
|
|
|
emitter->scalar_data.block_allowed = 0; |
1515
|
|
|
|
|
|
|
|
1516
|
5
|
|
|
|
|
|
return 1; |
1517
|
|
|
|
|
|
|
} |
1518
|
|
|
|
|
|
|
|
1519
|
286
|
50
|
|
|
|
|
if ((CHECK_AT(string, '-', 0) |
1520
|
0
|
0
|
|
|
|
|
&& CHECK_AT(string, '-', 1) |
1521
|
0
|
0
|
|
|
|
|
&& CHECK_AT(string, '-', 2)) |
1522
|
286
|
50
|
|
|
|
|
|| (CHECK_AT(string, '.', 0) |
1523
|
0
|
0
|
|
|
|
|
&& CHECK_AT(string, '.', 1) |
1524
|
0
|
0
|
|
|
|
|
&& CHECK_AT(string, '.', 2))) { |
1525
|
0
|
|
|
|
|
|
block_indicators = 1; |
1526
|
0
|
|
|
|
|
|
flow_indicators = 1; |
1527
|
|
|
|
|
|
|
} |
1528
|
|
|
|
|
|
|
|
1529
|
286
|
|
|
|
|
|
preceded_by_whitespace = 1; |
1530
|
286
|
100
|
|
|
|
|
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
|
1532
|
1675
|
100
|
|
|
|
|
while (string.pointer != string.end) |
1533
|
|
|
|
|
|
|
{ |
1534
|
1389
|
100
|
|
|
|
|
if (string.start == string.pointer) |
1535
|
|
|
|
|
|
|
{ |
1536
|
286
|
50
|
|
|
|
|
if (CHECK(string, '#') || CHECK(string, ',') |
|
|
50
|
|
|
|
|
|
1537
|
286
|
50
|
|
|
|
|
|| CHECK(string, '[') || CHECK(string, ']') |
|
|
50
|
|
|
|
|
|
1538
|
286
|
100
|
|
|
|
|
|| CHECK(string, '{') || CHECK(string, '}') |
|
|
50
|
|
|
|
|
|
1539
|
281
|
100
|
|
|
|
|
|| CHECK(string, '&') || CHECK(string, '*') |
|
|
100
|
|
|
|
|
|
1540
|
279
|
50
|
|
|
|
|
|| CHECK(string, '!') || CHECK(string, '|') |
|
|
100
|
|
|
|
|
|
1541
|
278
|
50
|
|
|
|
|
|| CHECK(string, '>') || CHECK(string, '\'') |
|
|
50
|
|
|
|
|
|
1542
|
278
|
50
|
|
|
|
|
|| CHECK(string, '"') || CHECK(string, '%') |
|
|
50
|
|
|
|
|
|
1543
|
278
|
50
|
|
|
|
|
|| CHECK(string, '@') || CHECK(string, '`')) { |
|
|
50
|
|
|
|
|
|
1544
|
8
|
|
|
|
|
|
flow_indicators = 1; |
1545
|
8
|
|
|
|
|
|
block_indicators = 1; |
1546
|
|
|
|
|
|
|
} |
1547
|
|
|
|
|
|
|
|
1548
|
286
|
100
|
|
|
|
|
if (CHECK(string, '?') || CHECK(string, ':')) { |
|
|
50
|
|
|
|
|
|
1549
|
1
|
|
|
|
|
|
flow_indicators = 1; |
1550
|
1
|
50
|
|
|
|
|
if (followed_by_whitespace) { |
1551
|
1
|
|
|
|
|
|
block_indicators = 1; |
1552
|
|
|
|
|
|
|
} |
1553
|
|
|
|
|
|
|
} |
1554
|
|
|
|
|
|
|
|
1555
|
286
|
50
|
|
|
|
|
if (CHECK(string, '-') && followed_by_whitespace) { |
|
|
0
|
|
|
|
|
|
1556
|
0
|
|
|
|
|
|
flow_indicators = 1; |
1557
|
286
|
|
|
|
|
|
block_indicators = 1; |
1558
|
|
|
|
|
|
|
} |
1559
|
|
|
|
|
|
|
} |
1560
|
|
|
|
|
|
|
else |
1561
|
|
|
|
|
|
|
{ |
1562
|
1103
|
50
|
|
|
|
|
if (CHECK(string, ',') || CHECK(string, '?') |
|
|
100
|
|
|
|
|
|
1563
|
1097
|
50
|
|
|
|
|
|| CHECK(string, '[') || CHECK(string, ']') |
|
|
50
|
|
|
|
|
|
1564
|
1097
|
50
|
|
|
|
|
|| CHECK(string, '{') || CHECK(string, '}')) { |
|
|
100
|
|
|
|
|
|
1565
|
11
|
|
|
|
|
|
flow_indicators = 1; |
1566
|
|
|
|
|
|
|
} |
1567
|
|
|
|
|
|
|
|
1568
|
1103
|
100
|
|
|
|
|
if (CHECK(string, ':')) { |
1569
|
11
|
|
|
|
|
|
flow_indicators = 1; |
1570
|
11
|
100
|
|
|
|
|
if (followed_by_whitespace) { |
1571
|
1
|
|
|
|
|
|
block_indicators = 1; |
1572
|
|
|
|
|
|
|
} |
1573
|
|
|
|
|
|
|
} |
1574
|
|
|
|
|
|
|
|
1575
|
1103
|
50
|
|
|
|
|
if (CHECK(string, '#') && preceded_by_whitespace) { |
|
|
0
|
|
|
|
|
|
1576
|
0
|
|
|
|
|
|
flow_indicators = 1; |
1577
|
0
|
|
|
|
|
|
block_indicators = 1; |
1578
|
|
|
|
|
|
|
} |
1579
|
|
|
|
|
|
|
} |
1580
|
|
|
|
|
|
|
|
1581
|
1389
|
100
|
|
|
|
|
if (!IS_PRINTABLE(string) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1582
|
1377
|
100
|
|
|
|
|
|| (!IS_ASCII(string) && !emitter->unicode)) { |
|
|
50
|
|
|
|
|
|
1583
|
12
|
|
|
|
|
|
special_characters = 1; |
1584
|
|
|
|
|
|
|
} |
1585
|
|
|
|
|
|
|
|
1586
|
1389
|
100
|
|
|
|
|
if (IS_BREAK(string)) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1587
|
19
|
|
|
|
|
|
line_breaks = 1; |
1588
|
|
|
|
|
|
|
} |
1589
|
|
|
|
|
|
|
|
1590
|
1389
|
100
|
|
|
|
|
if (IS_SPACE(string)) |
1591
|
|
|
|
|
|
|
{ |
1592
|
85
|
50
|
|
|
|
|
if (string.start == string.pointer) { |
1593
|
0
|
|
|
|
|
|
leading_space = 1; |
1594
|
|
|
|
|
|
|
} |
1595
|
85
|
50
|
|
|
|
|
if (string.pointer+WIDTH(string) == string.end) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1596
|
0
|
|
|
|
|
|
trailing_space = 1; |
1597
|
|
|
|
|
|
|
} |
1598
|
85
|
100
|
|
|
|
|
if (previous_break) { |
1599
|
7
|
|
|
|
|
|
break_space = 1; |
1600
|
|
|
|
|
|
|
} |
1601
|
85
|
|
|
|
|
|
previous_space = 1; |
1602
|
85
|
|
|
|
|
|
previous_break = 0; |
1603
|
|
|
|
|
|
|
} |
1604
|
1304
|
100
|
|
|
|
|
else if (IS_BREAK(string)) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1605
|
|
|
|
|
|
|
{ |
1606
|
19
|
50
|
|
|
|
|
if (string.start == string.pointer) { |
1607
|
0
|
|
|
|
|
|
leading_break = 1; |
1608
|
|
|
|
|
|
|
} |
1609
|
19
|
50
|
|
|
|
|
if (string.pointer+WIDTH(string) == string.end) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1610
|
4
|
|
|
|
|
|
trailing_break = 1; |
1611
|
|
|
|
|
|
|
} |
1612
|
19
|
50
|
|
|
|
|
if (previous_space) { |
1613
|
0
|
|
|
|
|
|
space_break = 1; |
1614
|
|
|
|
|
|
|
} |
1615
|
19
|
|
|
|
|
|
previous_space = 0; |
1616
|
19
|
|
|
|
|
|
previous_break = 1; |
1617
|
|
|
|
|
|
|
} |
1618
|
|
|
|
|
|
|
else |
1619
|
|
|
|
|
|
|
{ |
1620
|
1285
|
|
|
|
|
|
previous_space = 0; |
1621
|
1285
|
|
|
|
|
|
previous_break = 0; |
1622
|
|
|
|
|
|
|
} |
1623
|
|
|
|
|
|
|
|
1624
|
1389
|
100
|
|
|
|
|
preceded_by_whitespace = IS_BLANKZ(string); |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1625
|
1389
|
100
|
|
|
|
|
MOVE(string); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1626
|
1389
|
100
|
|
|
|
|
if (string.pointer != string.end) { |
1627
|
1103
|
100
|
|
|
|
|
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1628
|
|
|
|
|
|
|
} |
1629
|
|
|
|
|
|
|
} |
1630
|
|
|
|
|
|
|
|
1631
|
286
|
|
|
|
|
|
emitter->scalar_data.multiline = line_breaks; |
1632
|
|
|
|
|
|
|
|
1633
|
286
|
|
|
|
|
|
emitter->scalar_data.flow_plain_allowed = 1; |
1634
|
286
|
|
|
|
|
|
emitter->scalar_data.block_plain_allowed = 1; |
1635
|
286
|
|
|
|
|
|
emitter->scalar_data.single_quoted_allowed = 1; |
1636
|
286
|
|
|
|
|
|
emitter->scalar_data.block_allowed = 1; |
1637
|
|
|
|
|
|
|
|
1638
|
286
|
50
|
|
|
|
|
if (leading_space || leading_break || trailing_space || trailing_break) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1639
|
4
|
|
|
|
|
|
emitter->scalar_data.flow_plain_allowed = 0; |
1640
|
4
|
|
|
|
|
|
emitter->scalar_data.block_plain_allowed = 0; |
1641
|
|
|
|
|
|
|
} |
1642
|
|
|
|
|
|
|
|
1643
|
286
|
50
|
|
|
|
|
if (trailing_space) { |
1644
|
0
|
|
|
|
|
|
emitter->scalar_data.block_allowed = 0; |
1645
|
|
|
|
|
|
|
} |
1646
|
|
|
|
|
|
|
|
1647
|
286
|
100
|
|
|
|
|
if (break_space) { |
1648
|
2
|
|
|
|
|
|
emitter->scalar_data.flow_plain_allowed = 0; |
1649
|
2
|
|
|
|
|
|
emitter->scalar_data.block_plain_allowed = 0; |
1650
|
2
|
|
|
|
|
|
emitter->scalar_data.single_quoted_allowed = 0; |
1651
|
|
|
|
|
|
|
} |
1652
|
|
|
|
|
|
|
|
1653
|
286
|
50
|
|
|
|
|
if (space_break || special_characters) { |
|
|
100
|
|
|
|
|
|
1654
|
6
|
|
|
|
|
|
emitter->scalar_data.flow_plain_allowed = 0; |
1655
|
6
|
|
|
|
|
|
emitter->scalar_data.block_plain_allowed = 0; |
1656
|
6
|
|
|
|
|
|
emitter->scalar_data.single_quoted_allowed = 0; |
1657
|
6
|
|
|
|
|
|
emitter->scalar_data.block_allowed = 0; |
1658
|
|
|
|
|
|
|
} |
1659
|
|
|
|
|
|
|
|
1660
|
286
|
100
|
|
|
|
|
if (line_breaks) { |
1661
|
6
|
|
|
|
|
|
emitter->scalar_data.flow_plain_allowed = 0; |
1662
|
6
|
|
|
|
|
|
emitter->scalar_data.block_plain_allowed = 0; |
1663
|
|
|
|
|
|
|
} |
1664
|
|
|
|
|
|
|
|
1665
|
286
|
100
|
|
|
|
|
if (flow_indicators) { |
1666
|
17
|
|
|
|
|
|
emitter->scalar_data.flow_plain_allowed = 0; |
1667
|
|
|
|
|
|
|
} |
1668
|
|
|
|
|
|
|
|
1669
|
286
|
100
|
|
|
|
|
if (block_indicators) { |
1670
|
10
|
|
|
|
|
|
emitter->scalar_data.block_plain_allowed = 0; |
1671
|
|
|
|
|
|
|
} |
1672
|
|
|
|
|
|
|
|
1673
|
291
|
|
|
|
|
|
return 1; |
1674
|
|
|
|
|
|
|
} |
1675
|
|
|
|
|
|
|
|
1676
|
|
|
|
|
|
|
/* |
1677
|
|
|
|
|
|
|
* Check if the event data is valid. |
1678
|
|
|
|
|
|
|
*/ |
1679
|
|
|
|
|
|
|
|
1680
|
|
|
|
|
|
|
static int |
1681
|
920
|
|
|
|
|
|
yaml_emitter_analyze_event(yaml_emitter_t *emitter, |
1682
|
|
|
|
|
|
|
yaml_event_t *event) |
1683
|
|
|
|
|
|
|
{ |
1684
|
920
|
|
|
|
|
|
emitter->anchor_data.anchor = NULL; |
1685
|
920
|
|
|
|
|
|
emitter->anchor_data.anchor_length = 0; |
1686
|
920
|
|
|
|
|
|
emitter->tag_data.handle = NULL; |
1687
|
920
|
|
|
|
|
|
emitter->tag_data.handle_length = 0; |
1688
|
920
|
|
|
|
|
|
emitter->tag_data.suffix = NULL; |
1689
|
920
|
|
|
|
|
|
emitter->tag_data.suffix_length = 0; |
1690
|
920
|
|
|
|
|
|
emitter->scalar_data.value = NULL; |
1691
|
920
|
|
|
|
|
|
emitter->scalar_data.length = 0; |
1692
|
|
|
|
|
|
|
|
1693
|
920
|
|
|
|
|
|
switch (event->type) |
1694
|
|
|
|
|
|
|
{ |
1695
|
|
|
|
|
|
|
case YAML_ALIAS_EVENT: |
1696
|
17
|
50
|
|
|
|
|
if (!yaml_emitter_analyze_anchor(emitter, |
1697
|
|
|
|
|
|
|
event->data.alias.anchor, 1)) |
1698
|
0
|
|
|
|
|
|
return 0; |
1699
|
17
|
|
|
|
|
|
return 1; |
1700
|
|
|
|
|
|
|
|
1701
|
|
|
|
|
|
|
case YAML_SCALAR_EVENT: |
1702
|
291
|
50
|
|
|
|
|
if (event->data.scalar.anchor) { |
1703
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_analyze_anchor(emitter, |
1704
|
|
|
|
|
|
|
event->data.scalar.anchor, 0)) |
1705
|
0
|
|
|
|
|
|
return 0; |
1706
|
|
|
|
|
|
|
} |
1707
|
291
|
100
|
|
|
|
|
if (event->data.scalar.tag && (emitter->canonical || |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1708
|
272
|
|
|
|
|
|
(!event->data.scalar.plain_implicit |
1709
|
13
|
50
|
|
|
|
|
&& !event->data.scalar.quoted_implicit))) { |
1710
|
13
|
50
|
|
|
|
|
if (!yaml_emitter_analyze_tag(emitter, event->data.scalar.tag)) |
1711
|
0
|
|
|
|
|
|
return 0; |
1712
|
|
|
|
|
|
|
} |
1713
|
291
|
50
|
|
|
|
|
if (!yaml_emitter_analyze_scalar(emitter, |
1714
|
|
|
|
|
|
|
event->data.scalar.value, event->data.scalar.length)) |
1715
|
0
|
|
|
|
|
|
return 0; |
1716
|
291
|
|
|
|
|
|
return 1; |
1717
|
|
|
|
|
|
|
|
1718
|
|
|
|
|
|
|
case YAML_SEQUENCE_START_EVENT: |
1719
|
44
|
100
|
|
|
|
|
if (event->data.sequence_start.anchor) { |
1720
|
6
|
50
|
|
|
|
|
if (!yaml_emitter_analyze_anchor(emitter, |
1721
|
|
|
|
|
|
|
event->data.sequence_start.anchor, 0)) |
1722
|
0
|
|
|
|
|
|
return 0; |
1723
|
|
|
|
|
|
|
} |
1724
|
44
|
100
|
|
|
|
|
if (event->data.sequence_start.tag && (emitter->canonical || |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1725
|
3
|
|
|
|
|
|
!event->data.sequence_start.implicit)) { |
1726
|
3
|
50
|
|
|
|
|
if (!yaml_emitter_analyze_tag(emitter, |
1727
|
|
|
|
|
|
|
event->data.sequence_start.tag)) |
1728
|
0
|
|
|
|
|
|
return 0; |
1729
|
|
|
|
|
|
|
} |
1730
|
44
|
|
|
|
|
|
return 1; |
1731
|
|
|
|
|
|
|
|
1732
|
|
|
|
|
|
|
case YAML_MAPPING_START_EVENT: |
1733
|
66
|
100
|
|
|
|
|
if (event->data.mapping_start.anchor) { |
1734
|
10
|
50
|
|
|
|
|
if (!yaml_emitter_analyze_anchor(emitter, |
1735
|
|
|
|
|
|
|
event->data.mapping_start.anchor, 0)) |
1736
|
0
|
|
|
|
|
|
return 0; |
1737
|
|
|
|
|
|
|
} |
1738
|
66
|
100
|
|
|
|
|
if (event->data.mapping_start.tag && (emitter->canonical || |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1739
|
27
|
|
|
|
|
|
!event->data.mapping_start.implicit)) { |
1740
|
27
|
50
|
|
|
|
|
if (!yaml_emitter_analyze_tag(emitter, |
1741
|
|
|
|
|
|
|
event->data.mapping_start.tag)) |
1742
|
0
|
|
|
|
|
|
return 0; |
1743
|
|
|
|
|
|
|
} |
1744
|
66
|
|
|
|
|
|
return 1; |
1745
|
|
|
|
|
|
|
|
1746
|
|
|
|
|
|
|
default: |
1747
|
502
|
|
|
|
|
|
return 1; |
1748
|
|
|
|
|
|
|
} |
1749
|
|
|
|
|
|
|
} |
1750
|
|
|
|
|
|
|
|
1751
|
|
|
|
|
|
|
/* |
1752
|
|
|
|
|
|
|
* Write the BOM character. |
1753
|
|
|
|
|
|
|
*/ |
1754
|
|
|
|
|
|
|
|
1755
|
|
|
|
|
|
|
static int |
1756
|
0
|
|
|
|
|
|
yaml_emitter_write_bom(yaml_emitter_t *emitter) |
1757
|
|
|
|
|
|
|
{ |
1758
|
0
|
0
|
|
|
|
|
if (!FLUSH(emitter)) |
|
|
0
|
|
|
|
|
|
1759
|
0
|
|
|
|
|
|
return 0; |
1760
|
|
|
|
|
|
|
|
1761
|
0
|
|
|
|
|
|
*(emitter->buffer.pointer++) = (yaml_char_t) '\xEF'; |
1762
|
0
|
|
|
|
|
|
*(emitter->buffer.pointer++) = (yaml_char_t) '\xBB'; |
1763
|
0
|
|
|
|
|
|
*(emitter->buffer.pointer++) = (yaml_char_t) '\xBF'; |
1764
|
|
|
|
|
|
|
|
1765
|
0
|
|
|
|
|
|
return 1; |
1766
|
|
|
|
|
|
|
} |
1767
|
|
|
|
|
|
|
|
1768
|
|
|
|
|
|
|
static int |
1769
|
432
|
|
|
|
|
|
yaml_emitter_write_indent(yaml_emitter_t *emitter) |
1770
|
|
|
|
|
|
|
{ |
1771
|
432
|
|
|
|
|
|
int indent = (emitter->indent >= 0) ? emitter->indent : 0; |
1772
|
|
|
|
|
|
|
|
1773
|
432
|
100
|
|
|
|
|
if (!emitter->indention || emitter->column > indent |
|
|
50
|
|
|
|
|
|
1774
|
131
|
100
|
|
|
|
|
|| (emitter->column == indent && !emitter->whitespace)) { |
|
|
50
|
|
|
|
|
|
1775
|
301
|
50
|
|
|
|
|
if (!PUT_BREAK(emitter)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1776
|
0
|
|
|
|
|
|
return 0; |
1777
|
|
|
|
|
|
|
} |
1778
|
|
|
|
|
|
|
|
1779
|
589
|
100
|
|
|
|
|
while (emitter->column < indent) { |
1780
|
157
|
50
|
|
|
|
|
if (!PUT(emitter, ' ')) |
|
|
0
|
|
|
|
|
|
1781
|
0
|
|
|
|
|
|
return 0; |
1782
|
|
|
|
|
|
|
} |
1783
|
|
|
|
|
|
|
|
1784
|
432
|
|
|
|
|
|
emitter->whitespace = 1; |
1785
|
432
|
|
|
|
|
|
emitter->indention = 1; |
1786
|
|
|
|
|
|
|
|
1787
|
432
|
|
|
|
|
|
return 1; |
1788
|
|
|
|
|
|
|
} |
1789
|
|
|
|
|
|
|
|
1790
|
|
|
|
|
|
|
static int |
1791
|
457
|
|
|
|
|
|
yaml_emitter_write_indicator(yaml_emitter_t *emitter, |
1792
|
|
|
|
|
|
|
const char *indicator, int need_whitespace, |
1793
|
|
|
|
|
|
|
int is_whitespace, int is_indention) |
1794
|
|
|
|
|
|
|
{ |
1795
|
|
|
|
|
|
|
size_t indicator_length; |
1796
|
|
|
|
|
|
|
yaml_string_t string; |
1797
|
|
|
|
|
|
|
|
1798
|
457
|
|
|
|
|
|
indicator_length = strlen(indicator); |
1799
|
457
|
|
|
|
|
|
STRING_ASSIGN(string, (yaml_char_t *)indicator, indicator_length); |
1800
|
|
|
|
|
|
|
|
1801
|
457
|
100
|
|
|
|
|
if (need_whitespace && !emitter->whitespace) { |
|
|
100
|
|
|
|
|
|
1802
|
91
|
50
|
|
|
|
|
if (!PUT(emitter, ' ')) |
|
|
0
|
|
|
|
|
|
1803
|
0
|
|
|
|
|
|
return 0; |
1804
|
|
|
|
|
|
|
} |
1805
|
|
|
|
|
|
|
|
1806
|
1132
|
100
|
|
|
|
|
while (string.pointer != string.end) { |
1807
|
675
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1808
|
0
|
|
|
|
|
|
return 0; |
1809
|
|
|
|
|
|
|
} |
1810
|
|
|
|
|
|
|
|
1811
|
457
|
|
|
|
|
|
emitter->whitespace = is_whitespace; |
1812
|
457
|
100
|
|
|
|
|
emitter->indention = (emitter->indention && is_indention); |
|
|
100
|
|
|
|
|
|
1813
|
457
|
|
|
|
|
|
emitter->open_ended = 0; |
1814
|
|
|
|
|
|
|
|
1815
|
457
|
|
|
|
|
|
return 1; |
1816
|
|
|
|
|
|
|
} |
1817
|
|
|
|
|
|
|
|
1818
|
|
|
|
|
|
|
static int |
1819
|
33
|
|
|
|
|
|
yaml_emitter_write_anchor(yaml_emitter_t *emitter, |
1820
|
|
|
|
|
|
|
yaml_char_t *value, size_t length) |
1821
|
|
|
|
|
|
|
{ |
1822
|
|
|
|
|
|
|
yaml_string_t string; |
1823
|
33
|
|
|
|
|
|
STRING_ASSIGN(string, value, length); |
1824
|
|
|
|
|
|
|
|
1825
|
66
|
100
|
|
|
|
|
while (string.pointer != string.end) { |
1826
|
33
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1827
|
0
|
|
|
|
|
|
return 0; |
1828
|
|
|
|
|
|
|
} |
1829
|
|
|
|
|
|
|
|
1830
|
33
|
|
|
|
|
|
emitter->whitespace = 0; |
1831
|
33
|
|
|
|
|
|
emitter->indention = 0; |
1832
|
|
|
|
|
|
|
|
1833
|
33
|
|
|
|
|
|
return 1; |
1834
|
|
|
|
|
|
|
} |
1835
|
|
|
|
|
|
|
|
1836
|
|
|
|
|
|
|
static int |
1837
|
43
|
|
|
|
|
|
yaml_emitter_write_tag_handle(yaml_emitter_t *emitter, |
1838
|
|
|
|
|
|
|
yaml_char_t *value, size_t length) |
1839
|
|
|
|
|
|
|
{ |
1840
|
|
|
|
|
|
|
yaml_string_t string; |
1841
|
43
|
|
|
|
|
|
STRING_ASSIGN(string, value, length); |
1842
|
|
|
|
|
|
|
|
1843
|
43
|
50
|
|
|
|
|
if (!emitter->whitespace) { |
1844
|
43
|
50
|
|
|
|
|
if (!PUT(emitter, ' ')) |
|
|
0
|
|
|
|
|
|
1845
|
0
|
|
|
|
|
|
return 0; |
1846
|
|
|
|
|
|
|
} |
1847
|
|
|
|
|
|
|
|
1848
|
129
|
100
|
|
|
|
|
while (string.pointer != string.end) { |
1849
|
86
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1850
|
0
|
|
|
|
|
|
return 0; |
1851
|
|
|
|
|
|
|
} |
1852
|
|
|
|
|
|
|
|
1853
|
43
|
|
|
|
|
|
emitter->whitespace = 0; |
1854
|
43
|
|
|
|
|
|
emitter->indention = 0; |
1855
|
|
|
|
|
|
|
|
1856
|
43
|
|
|
|
|
|
return 1; |
1857
|
|
|
|
|
|
|
} |
1858
|
|
|
|
|
|
|
|
1859
|
|
|
|
|
|
|
static int |
1860
|
43
|
|
|
|
|
|
yaml_emitter_write_tag_content(yaml_emitter_t *emitter, |
1861
|
|
|
|
|
|
|
yaml_char_t *value, size_t length, |
1862
|
|
|
|
|
|
|
int need_whitespace) |
1863
|
|
|
|
|
|
|
{ |
1864
|
|
|
|
|
|
|
yaml_string_t string; |
1865
|
43
|
|
|
|
|
|
STRING_ASSIGN(string, value, length); |
1866
|
|
|
|
|
|
|
|
1867
|
43
|
50
|
|
|
|
|
if (need_whitespace && !emitter->whitespace) { |
|
|
0
|
|
|
|
|
|
1868
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, ' ')) |
|
|
0
|
|
|
|
|
|
1869
|
0
|
|
|
|
|
|
return 0; |
1870
|
|
|
|
|
|
|
} |
1871
|
|
|
|
|
|
|
|
1872
|
573
|
100
|
|
|
|
|
while (string.pointer != string.end) { |
1873
|
530
|
100
|
|
|
|
|
if (IS_ALPHA(string) |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1874
|
77
|
50
|
|
|
|
|
|| CHECK(string, ';') || CHECK(string, '/') |
|
|
100
|
|
|
|
|
|
1875
|
34
|
50
|
|
|
|
|
|| CHECK(string, '?') || CHECK(string, ':') |
|
|
50
|
|
|
|
|
|
1876
|
0
|
0
|
|
|
|
|
|| CHECK(string, '@') || CHECK(string, '&') |
|
|
0
|
|
|
|
|
|
1877
|
0
|
0
|
|
|
|
|
|| CHECK(string, '=') || CHECK(string, '+') |
|
|
0
|
|
|
|
|
|
1878
|
0
|
0
|
|
|
|
|
|| CHECK(string, '$') || CHECK(string, ',') |
|
|
0
|
|
|
|
|
|
1879
|
0
|
0
|
|
|
|
|
|| CHECK(string, '_') || CHECK(string, '.') |
|
|
0
|
|
|
|
|
|
1880
|
0
|
0
|
|
|
|
|
|| CHECK(string, '~') || CHECK(string, '*') |
|
|
0
|
|
|
|
|
|
1881
|
0
|
0
|
|
|
|
|
|| CHECK(string, '\'') || CHECK(string, '(') |
|
|
0
|
|
|
|
|
|
1882
|
0
|
0
|
|
|
|
|
|| CHECK(string, ')') || CHECK(string, '[') |
|
|
0
|
|
|
|
|
|
1883
|
0
|
0
|
|
|
|
|
|| CHECK(string, ']')) { |
1884
|
530
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1885
|
0
|
|
|
|
|
|
return 0; |
1886
|
|
|
|
|
|
|
} |
1887
|
|
|
|
|
|
|
else { |
1888
|
0
|
0
|
|
|
|
|
int width = WIDTH(string); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1889
|
|
|
|
|
|
|
unsigned int v; |
1890
|
0
|
0
|
|
|
|
|
while (width --) { |
1891
|
0
|
|
|
|
|
|
v = *(string.pointer++); |
1892
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, '%')) |
|
|
0
|
|
|
|
|
|
1893
|
0
|
|
|
|
|
|
return 0; |
1894
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, (v >> 4) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1895
|
|
|
|
|
|
|
+ ((v >> 4) < 10 ? '0' : 'A' - 10))) |
1896
|
0
|
|
|
|
|
|
return 0; |
1897
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, (v & 0x0F) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1898
|
|
|
|
|
|
|
+ ((v & 0x0F) < 10 ? '0' : 'A' - 10))) |
1899
|
0
|
|
|
|
|
|
return 0; |
1900
|
|
|
|
|
|
|
} |
1901
|
|
|
|
|
|
|
} |
1902
|
|
|
|
|
|
|
} |
1903
|
|
|
|
|
|
|
|
1904
|
43
|
|
|
|
|
|
emitter->whitespace = 0; |
1905
|
43
|
|
|
|
|
|
emitter->indention = 0; |
1906
|
|
|
|
|
|
|
|
1907
|
43
|
|
|
|
|
|
return 1; |
1908
|
|
|
|
|
|
|
} |
1909
|
|
|
|
|
|
|
|
1910
|
|
|
|
|
|
|
static int |
1911
|
252
|
|
|
|
|
|
yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter, |
1912
|
|
|
|
|
|
|
yaml_char_t *value, size_t length, int allow_breaks) |
1913
|
|
|
|
|
|
|
{ |
1914
|
|
|
|
|
|
|
yaml_string_t string; |
1915
|
252
|
|
|
|
|
|
int spaces = 0; |
1916
|
252
|
|
|
|
|
|
int breaks = 0; |
1917
|
|
|
|
|
|
|
|
1918
|
252
|
|
|
|
|
|
STRING_ASSIGN(string, value, length); |
1919
|
|
|
|
|
|
|
|
1920
|
252
|
100
|
|
|
|
|
if (!emitter->whitespace) { |
1921
|
143
|
50
|
|
|
|
|
if (!PUT(emitter, ' ')) |
|
|
0
|
|
|
|
|
|
1922
|
0
|
|
|
|
|
|
return 0; |
1923
|
|
|
|
|
|
|
} |
1924
|
|
|
|
|
|
|
|
1925
|
1301
|
100
|
|
|
|
|
while (string.pointer != string.end) |
1926
|
|
|
|
|
|
|
{ |
1927
|
1049
|
100
|
|
|
|
|
if (IS_SPACE(string)) { |
1928
|
42
|
100
|
|
|
|
|
if (allow_breaks && !spaces |
|
|
50
|
|
|
|
|
|
1929
|
41
|
50
|
|
|
|
|
&& emitter->column > emitter->best_width |
1930
|
0
|
0
|
|
|
|
|
&& !IS_SPACE_AT(string, 1)) { |
1931
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
1932
|
0
|
|
|
|
|
|
return 0; |
1933
|
0
|
0
|
|
|
|
|
MOVE(string); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1934
|
|
|
|
|
|
|
} |
1935
|
|
|
|
|
|
|
else { |
1936
|
42
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1937
|
0
|
|
|
|
|
|
return 0; |
1938
|
|
|
|
|
|
|
} |
1939
|
42
|
|
|
|
|
|
spaces = 1; |
1940
|
|
|
|
|
|
|
} |
1941
|
1007
|
50
|
|
|
|
|
else if (IS_BREAK(string)) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1942
|
0
|
0
|
|
|
|
|
if (!breaks && CHECK(string, '\n')) { |
|
|
0
|
|
|
|
|
|
1943
|
0
|
0
|
|
|
|
|
if (!PUT_BREAK(emitter)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1944
|
0
|
|
|
|
|
|
return 0; |
1945
|
|
|
|
|
|
|
} |
1946
|
0
|
0
|
|
|
|
|
if (!WRITE_BREAK(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1947
|
0
|
|
|
|
|
|
return 0; |
1948
|
0
|
|
|
|
|
|
emitter->indention = 1; |
1949
|
0
|
|
|
|
|
|
breaks = 1; |
1950
|
|
|
|
|
|
|
} |
1951
|
|
|
|
|
|
|
else { |
1952
|
1007
|
50
|
|
|
|
|
if (breaks) { |
1953
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
1954
|
0
|
|
|
|
|
|
return 0; |
1955
|
|
|
|
|
|
|
} |
1956
|
1007
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1957
|
0
|
|
|
|
|
|
return 0; |
1958
|
1007
|
|
|
|
|
|
emitter->indention = 0; |
1959
|
1007
|
|
|
|
|
|
spaces = 0; |
1960
|
1007
|
|
|
|
|
|
breaks = 0; |
1961
|
|
|
|
|
|
|
} |
1962
|
|
|
|
|
|
|
} |
1963
|
|
|
|
|
|
|
|
1964
|
252
|
|
|
|
|
|
emitter->whitespace = 0; |
1965
|
252
|
|
|
|
|
|
emitter->indention = 0; |
1966
|
|
|
|
|
|
|
/* |
1967
|
|
|
|
|
|
|
* < rz> ingy: i'm not sure why i set open_ended in yaml_emitter_write_plain_scalar |
1968
|
|
|
|
|
|
|
* |
1969
|
|
|
|
|
|
|
* Disabling this as it breaks YAML::XS tests with no perceived benefit. |
1970
|
|
|
|
|
|
|
* if (emitter->root_context) |
1971
|
|
|
|
|
|
|
* { |
1972
|
|
|
|
|
|
|
* emitter->open_ended = 1; |
1973
|
|
|
|
|
|
|
* } |
1974
|
|
|
|
|
|
|
*/ |
1975
|
|
|
|
|
|
|
|
1976
|
252
|
|
|
|
|
|
return 1; |
1977
|
|
|
|
|
|
|
} |
1978
|
|
|
|
|
|
|
|
1979
|
|
|
|
|
|
|
static int |
1980
|
28
|
|
|
|
|
|
yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter, |
1981
|
|
|
|
|
|
|
yaml_char_t *value, size_t length, int allow_breaks) |
1982
|
|
|
|
|
|
|
{ |
1983
|
|
|
|
|
|
|
yaml_string_t string; |
1984
|
28
|
|
|
|
|
|
int spaces = 0; |
1985
|
28
|
|
|
|
|
|
int breaks = 0; |
1986
|
|
|
|
|
|
|
|
1987
|
28
|
|
|
|
|
|
STRING_ASSIGN(string, value, length); |
1988
|
|
|
|
|
|
|
|
1989
|
28
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "'", 1, 0, 0)) |
1990
|
0
|
|
|
|
|
|
return 0; |
1991
|
|
|
|
|
|
|
|
1992
|
137
|
100
|
|
|
|
|
while (string.pointer != string.end) |
1993
|
|
|
|
|
|
|
{ |
1994
|
109
|
100
|
|
|
|
|
if (IS_SPACE(string)) { |
1995
|
8
|
50
|
|
|
|
|
if (allow_breaks && !spaces |
|
|
50
|
|
|
|
|
|
1996
|
8
|
50
|
|
|
|
|
&& emitter->column > emitter->best_width |
1997
|
0
|
0
|
|
|
|
|
&& string.pointer != string.start |
1998
|
0
|
0
|
|
|
|
|
&& string.pointer != string.end - 1 |
1999
|
0
|
0
|
|
|
|
|
&& !IS_SPACE_AT(string, 1)) { |
2000
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
2001
|
0
|
|
|
|
|
|
return 0; |
2002
|
0
|
0
|
|
|
|
|
MOVE(string); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2003
|
|
|
|
|
|
|
} |
2004
|
|
|
|
|
|
|
else { |
2005
|
8
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2006
|
0
|
|
|
|
|
|
return 0; |
2007
|
|
|
|
|
|
|
} |
2008
|
8
|
|
|
|
|
|
spaces = 1; |
2009
|
|
|
|
|
|
|
} |
2010
|
101
|
50
|
|
|
|
|
else if (IS_BREAK(string)) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2011
|
0
|
0
|
|
|
|
|
if (!breaks && CHECK(string, '\n')) { |
|
|
0
|
|
|
|
|
|
2012
|
0
|
0
|
|
|
|
|
if (!PUT_BREAK(emitter)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2013
|
0
|
|
|
|
|
|
return 0; |
2014
|
|
|
|
|
|
|
} |
2015
|
0
|
0
|
|
|
|
|
if (!WRITE_BREAK(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2016
|
0
|
|
|
|
|
|
return 0; |
2017
|
0
|
|
|
|
|
|
emitter->indention = 1; |
2018
|
0
|
|
|
|
|
|
breaks = 1; |
2019
|
|
|
|
|
|
|
} |
2020
|
|
|
|
|
|
|
else |
2021
|
|
|
|
|
|
|
{ |
2022
|
101
|
50
|
|
|
|
|
if (breaks) { |
2023
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
2024
|
0
|
|
|
|
|
|
return 0; |
2025
|
|
|
|
|
|
|
} |
2026
|
101
|
50
|
|
|
|
|
if (CHECK(string, '\'')) { |
2027
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, '\'')) |
|
|
0
|
|
|
|
|
|
2028
|
0
|
|
|
|
|
|
return 0; |
2029
|
|
|
|
|
|
|
} |
2030
|
101
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2031
|
0
|
|
|
|
|
|
return 0; |
2032
|
101
|
|
|
|
|
|
emitter->indention = 0; |
2033
|
101
|
|
|
|
|
|
spaces = 0; |
2034
|
101
|
|
|
|
|
|
breaks = 0; |
2035
|
|
|
|
|
|
|
} |
2036
|
|
|
|
|
|
|
} |
2037
|
|
|
|
|
|
|
|
2038
|
28
|
50
|
|
|
|
|
if (breaks) |
2039
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) return 0; |
2040
|
|
|
|
|
|
|
|
2041
|
28
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "'", 0, 0, 0)) |
2042
|
0
|
|
|
|
|
|
return 0; |
2043
|
|
|
|
|
|
|
|
2044
|
28
|
|
|
|
|
|
emitter->whitespace = 0; |
2045
|
28
|
|
|
|
|
|
emitter->indention = 0; |
2046
|
|
|
|
|
|
|
|
2047
|
28
|
|
|
|
|
|
return 1; |
2048
|
|
|
|
|
|
|
} |
2049
|
|
|
|
|
|
|
|
2050
|
|
|
|
|
|
|
static int |
2051
|
8
|
|
|
|
|
|
yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter, |
2052
|
|
|
|
|
|
|
yaml_char_t *value, size_t length, int allow_breaks) |
2053
|
|
|
|
|
|
|
{ |
2054
|
|
|
|
|
|
|
yaml_string_t string; |
2055
|
8
|
|
|
|
|
|
int spaces = 0; |
2056
|
|
|
|
|
|
|
|
2057
|
8
|
|
|
|
|
|
STRING_ASSIGN(string, value, length); |
2058
|
|
|
|
|
|
|
|
2059
|
8
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "\"", 1, 0, 0)) |
2060
|
0
|
|
|
|
|
|
return 0; |
2061
|
|
|
|
|
|
|
|
2062
|
70
|
100
|
|
|
|
|
while (string.pointer != string.end) |
2063
|
|
|
|
|
|
|
{ |
2064
|
62
|
100
|
|
|
|
|
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2065
|
50
|
50
|
|
|
|
|
|| IS_BOM(string) || IS_BREAK(string) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2066
|
44
|
50
|
|
|
|
|
|| CHECK(string, '"') || CHECK(string, '\\')) |
|
|
50
|
|
|
|
|
|
2067
|
18
|
|
|
|
|
|
{ |
2068
|
|
|
|
|
|
|
unsigned char octet; |
2069
|
|
|
|
|
|
|
unsigned int width; |
2070
|
|
|
|
|
|
|
unsigned int v; |
2071
|
|
|
|
|
|
|
int k; |
2072
|
|
|
|
|
|
|
|
2073
|
18
|
|
|
|
|
|
octet = string.pointer[0]; |
2074
|
18
|
100
|
|
|
|
|
width = (octet & 0x80) == 0x00 ? 1 : |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2075
|
4
|
|
|
|
|
|
(octet & 0xE0) == 0xC0 ? 2 : |
2076
|
0
|
|
|
|
|
|
(octet & 0xF0) == 0xE0 ? 3 : |
2077
|
0
|
|
|
|
|
|
(octet & 0xF8) == 0xF0 ? 4 : 0; |
2078
|
18
|
100
|
|
|
|
|
v = (octet & 0x80) == 0x00 ? octet & 0x7F : |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2079
|
4
|
|
|
|
|
|
(octet & 0xE0) == 0xC0 ? octet & 0x1F : |
2080
|
0
|
|
|
|
|
|
(octet & 0xF0) == 0xE0 ? octet & 0x0F : |
2081
|
0
|
|
|
|
|
|
(octet & 0xF8) == 0xF0 ? octet & 0x07 : 0; |
2082
|
22
|
100
|
|
|
|
|
for (k = 1; k < (int)width; k ++) { |
2083
|
4
|
|
|
|
|
|
octet = string.pointer[k]; |
2084
|
4
|
|
|
|
|
|
v = (v << 6) + (octet & 0x3F); |
2085
|
|
|
|
|
|
|
} |
2086
|
18
|
|
|
|
|
|
string.pointer += width; |
2087
|
|
|
|
|
|
|
|
2088
|
18
|
50
|
|
|
|
|
if (!PUT(emitter, '\\')) |
|
|
0
|
|
|
|
|
|
2089
|
0
|
|
|
|
|
|
return 0; |
2090
|
|
|
|
|
|
|
|
2091
|
18
|
|
|
|
|
|
switch (v) |
2092
|
|
|
|
|
|
|
{ |
2093
|
|
|
|
|
|
|
case 0x00: |
2094
|
5
|
50
|
|
|
|
|
if (!PUT(emitter, '0')) |
|
|
0
|
|
|
|
|
|
2095
|
0
|
|
|
|
|
|
return 0; |
2096
|
5
|
|
|
|
|
|
break; |
2097
|
|
|
|
|
|
|
|
2098
|
|
|
|
|
|
|
case 0x07: |
2099
|
1
|
50
|
|
|
|
|
if (!PUT(emitter, 'a')) |
|
|
0
|
|
|
|
|
|
2100
|
0
|
|
|
|
|
|
return 0; |
2101
|
1
|
|
|
|
|
|
break; |
2102
|
|
|
|
|
|
|
|
2103
|
|
|
|
|
|
|
case 0x08: |
2104
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, 'b')) |
|
|
0
|
|
|
|
|
|
2105
|
0
|
|
|
|
|
|
return 0; |
2106
|
0
|
|
|
|
|
|
break; |
2107
|
|
|
|
|
|
|
|
2108
|
|
|
|
|
|
|
case 0x09: |
2109
|
1
|
50
|
|
|
|
|
if (!PUT(emitter, 't')) |
|
|
0
|
|
|
|
|
|
2110
|
0
|
|
|
|
|
|
return 0; |
2111
|
1
|
|
|
|
|
|
break; |
2112
|
|
|
|
|
|
|
|
2113
|
|
|
|
|
|
|
case 0x0A: |
2114
|
6
|
50
|
|
|
|
|
if (!PUT(emitter, 'n')) |
|
|
0
|
|
|
|
|
|
2115
|
0
|
|
|
|
|
|
return 0; |
2116
|
6
|
|
|
|
|
|
break; |
2117
|
|
|
|
|
|
|
|
2118
|
|
|
|
|
|
|
case 0x0B: |
2119
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, 'v')) |
|
|
0
|
|
|
|
|
|
2120
|
0
|
|
|
|
|
|
return 0; |
2121
|
0
|
|
|
|
|
|
break; |
2122
|
|
|
|
|
|
|
|
2123
|
|
|
|
|
|
|
case 0x0C: |
2124
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, 'f')) |
|
|
0
|
|
|
|
|
|
2125
|
0
|
|
|
|
|
|
return 0; |
2126
|
0
|
|
|
|
|
|
break; |
2127
|
|
|
|
|
|
|
|
2128
|
|
|
|
|
|
|
case 0x0D: |
2129
|
1
|
50
|
|
|
|
|
if (!PUT(emitter, 'r')) |
|
|
0
|
|
|
|
|
|
2130
|
0
|
|
|
|
|
|
return 0; |
2131
|
1
|
|
|
|
|
|
break; |
2132
|
|
|
|
|
|
|
|
2133
|
|
|
|
|
|
|
case 0x1B: |
2134
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, 'e')) |
|
|
0
|
|
|
|
|
|
2135
|
0
|
|
|
|
|
|
return 0; |
2136
|
0
|
|
|
|
|
|
break; |
2137
|
|
|
|
|
|
|
|
2138
|
|
|
|
|
|
|
case 0x22: |
2139
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, '\"')) |
|
|
0
|
|
|
|
|
|
2140
|
0
|
|
|
|
|
|
return 0; |
2141
|
0
|
|
|
|
|
|
break; |
2142
|
|
|
|
|
|
|
|
2143
|
|
|
|
|
|
|
case 0x5C: |
2144
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, '\\')) |
|
|
0
|
|
|
|
|
|
2145
|
0
|
|
|
|
|
|
return 0; |
2146
|
0
|
|
|
|
|
|
break; |
2147
|
|
|
|
|
|
|
|
2148
|
|
|
|
|
|
|
case 0x85: |
2149
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, 'N')) |
|
|
0
|
|
|
|
|
|
2150
|
0
|
|
|
|
|
|
return 0; |
2151
|
0
|
|
|
|
|
|
break; |
2152
|
|
|
|
|
|
|
|
2153
|
|
|
|
|
|
|
case 0xA0: |
2154
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, '_')) |
|
|
0
|
|
|
|
|
|
2155
|
0
|
|
|
|
|
|
return 0; |
2156
|
0
|
|
|
|
|
|
break; |
2157
|
|
|
|
|
|
|
|
2158
|
|
|
|
|
|
|
case 0x2028: |
2159
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, 'L')) |
|
|
0
|
|
|
|
|
|
2160
|
0
|
|
|
|
|
|
return 0; |
2161
|
0
|
|
|
|
|
|
break; |
2162
|
|
|
|
|
|
|
|
2163
|
|
|
|
|
|
|
case 0x2029: |
2164
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, 'P')) |
|
|
0
|
|
|
|
|
|
2165
|
0
|
|
|
|
|
|
return 0; |
2166
|
0
|
|
|
|
|
|
break; |
2167
|
|
|
|
|
|
|
|
2168
|
|
|
|
|
|
|
default: |
2169
|
4
|
50
|
|
|
|
|
if (v <= 0xFF) { |
2170
|
4
|
50
|
|
|
|
|
if (!PUT(emitter, 'x')) |
|
|
0
|
|
|
|
|
|
2171
|
0
|
|
|
|
|
|
return 0; |
2172
|
4
|
|
|
|
|
|
width = 2; |
2173
|
|
|
|
|
|
|
} |
2174
|
0
|
0
|
|
|
|
|
else if (v <= 0xFFFF) { |
2175
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, 'u')) |
|
|
0
|
|
|
|
|
|
2176
|
0
|
|
|
|
|
|
return 0; |
2177
|
0
|
|
|
|
|
|
width = 4; |
2178
|
|
|
|
|
|
|
} |
2179
|
|
|
|
|
|
|
else { |
2180
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, 'U')) |
|
|
0
|
|
|
|
|
|
2181
|
0
|
|
|
|
|
|
return 0; |
2182
|
0
|
|
|
|
|
|
width = 8; |
2183
|
|
|
|
|
|
|
} |
2184
|
12
|
100
|
|
|
|
|
for (k = (width-1)*4; k >= 0; k -= 4) { |
2185
|
8
|
|
|
|
|
|
int digit = (v >> k) & 0x0F; |
2186
|
8
|
50
|
|
|
|
|
if (!PUT(emitter, digit + (digit < 10 ? '0' : 'A'-10))) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2187
|
0
|
|
|
|
|
|
return 0; |
2188
|
|
|
|
|
|
|
} |
2189
|
|
|
|
|
|
|
} |
2190
|
18
|
|
|
|
|
|
spaces = 0; |
2191
|
|
|
|
|
|
|
} |
2192
|
44
|
50
|
|
|
|
|
else if (IS_SPACE(string)) { |
2193
|
0
|
0
|
|
|
|
|
if (allow_breaks && !spaces |
|
|
0
|
|
|
|
|
|
2194
|
0
|
0
|
|
|
|
|
&& emitter->column > emitter->best_width |
2195
|
0
|
0
|
|
|
|
|
&& string.pointer != string.start |
2196
|
0
|
0
|
|
|
|
|
&& string.pointer != string.end - 1) { |
2197
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
2198
|
0
|
|
|
|
|
|
return 0; |
2199
|
0
|
0
|
|
|
|
|
if (IS_SPACE_AT(string, 1)) { |
2200
|
0
|
0
|
|
|
|
|
if (!PUT(emitter, '\\')) |
|
|
0
|
|
|
|
|
|
2201
|
0
|
|
|
|
|
|
return 0; |
2202
|
|
|
|
|
|
|
} |
2203
|
0
|
0
|
|
|
|
|
MOVE(string); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2204
|
|
|
|
|
|
|
} |
2205
|
|
|
|
|
|
|
else { |
2206
|
0
|
0
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2207
|
0
|
|
|
|
|
|
return 0; |
2208
|
|
|
|
|
|
|
} |
2209
|
0
|
|
|
|
|
|
spaces = 1; |
2210
|
|
|
|
|
|
|
} |
2211
|
|
|
|
|
|
|
else { |
2212
|
44
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2213
|
0
|
|
|
|
|
|
return 0; |
2214
|
44
|
|
|
|
|
|
spaces = 0; |
2215
|
|
|
|
|
|
|
} |
2216
|
|
|
|
|
|
|
} |
2217
|
|
|
|
|
|
|
|
2218
|
8
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "\"", 0, 0, 0)) |
2219
|
0
|
|
|
|
|
|
return 0; |
2220
|
|
|
|
|
|
|
|
2221
|
8
|
|
|
|
|
|
emitter->whitespace = 0; |
2222
|
8
|
|
|
|
|
|
emitter->indention = 0; |
2223
|
|
|
|
|
|
|
|
2224
|
8
|
|
|
|
|
|
return 1; |
2225
|
|
|
|
|
|
|
} |
2226
|
|
|
|
|
|
|
|
2227
|
|
|
|
|
|
|
static int |
2228
|
3
|
|
|
|
|
|
yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter, |
2229
|
|
|
|
|
|
|
yaml_string_t string) |
2230
|
|
|
|
|
|
|
{ |
2231
|
|
|
|
|
|
|
char indent_hint[2]; |
2232
|
3
|
|
|
|
|
|
const char *chomp_hint = NULL; |
2233
|
|
|
|
|
|
|
|
2234
|
3
|
50
|
|
|
|
|
if (IS_SPACE(string) || IS_BREAK(string)) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2235
|
0
|
|
|
|
|
|
indent_hint[0] = '0' + (char)emitter->best_indent; |
2236
|
0
|
|
|
|
|
|
indent_hint[1] = '\0'; |
2237
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, indent_hint, 0, 0, 0)) |
2238
|
0
|
|
|
|
|
|
return 0; |
2239
|
|
|
|
|
|
|
} |
2240
|
|
|
|
|
|
|
|
2241
|
3
|
|
|
|
|
|
emitter->open_ended = 0; |
2242
|
|
|
|
|
|
|
|
2243
|
3
|
|
|
|
|
|
string.pointer = string.end; |
2244
|
3
|
50
|
|
|
|
|
if (string.start == string.pointer) { |
2245
|
0
|
|
|
|
|
|
chomp_hint = "-"; |
2246
|
|
|
|
|
|
|
} |
2247
|
|
|
|
|
|
|
else { |
2248
|
|
|
|
|
|
|
do { |
2249
|
3
|
|
|
|
|
|
string.pointer --; |
2250
|
3
|
50
|
|
|
|
|
} while ((*string.pointer & 0xC0) == 0x80); |
2251
|
3
|
50
|
|
|
|
|
if (!IS_BREAK(string)) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2252
|
2
|
|
|
|
|
|
chomp_hint = "-"; |
2253
|
|
|
|
|
|
|
} |
2254
|
1
|
50
|
|
|
|
|
else if (string.start == string.pointer) { |
2255
|
0
|
|
|
|
|
|
chomp_hint = "+"; |
2256
|
0
|
|
|
|
|
|
emitter->open_ended = 1; |
2257
|
|
|
|
|
|
|
} |
2258
|
|
|
|
|
|
|
else { |
2259
|
|
|
|
|
|
|
do { |
2260
|
1
|
|
|
|
|
|
string.pointer --; |
2261
|
1
|
50
|
|
|
|
|
} while ((*string.pointer & 0xC0) == 0x80); |
2262
|
1
|
50
|
|
|
|
|
if (IS_BREAK(string)) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2263
|
0
|
|
|
|
|
|
chomp_hint = "+"; |
2264
|
0
|
|
|
|
|
|
emitter->open_ended = 1; |
2265
|
|
|
|
|
|
|
} |
2266
|
|
|
|
|
|
|
} |
2267
|
|
|
|
|
|
|
} |
2268
|
|
|
|
|
|
|
|
2269
|
3
|
100
|
|
|
|
|
if (chomp_hint) { |
2270
|
2
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, chomp_hint, 0, 0, 0)) |
2271
|
0
|
|
|
|
|
|
return 0; |
2272
|
|
|
|
|
|
|
} |
2273
|
|
|
|
|
|
|
|
2274
|
3
|
|
|
|
|
|
return 1; |
2275
|
|
|
|
|
|
|
} |
2276
|
|
|
|
|
|
|
|
2277
|
|
|
|
|
|
|
static int |
2278
|
3
|
|
|
|
|
|
yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter, |
2279
|
|
|
|
|
|
|
yaml_char_t *value, size_t length) |
2280
|
|
|
|
|
|
|
{ |
2281
|
|
|
|
|
|
|
yaml_string_t string; |
2282
|
3
|
|
|
|
|
|
int breaks = 1; |
2283
|
|
|
|
|
|
|
|
2284
|
3
|
|
|
|
|
|
STRING_ASSIGN(string, value, length); |
2285
|
|
|
|
|
|
|
|
2286
|
3
|
50
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, "|", 1, 0, 0)) |
2287
|
0
|
|
|
|
|
|
return 0; |
2288
|
3
|
50
|
|
|
|
|
if (!yaml_emitter_write_block_scalar_hints(emitter, string)) |
2289
|
0
|
|
|
|
|
|
return 0; |
2290
|
3
|
50
|
|
|
|
|
if (!PUT_BREAK(emitter)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2291
|
0
|
|
|
|
|
|
return 0; |
2292
|
3
|
|
|
|
|
|
emitter->indention = 1; |
2293
|
3
|
|
|
|
|
|
emitter->whitespace = 1; |
2294
|
|
|
|
|
|
|
|
2295
|
172
|
100
|
|
|
|
|
while (string.pointer != string.end) |
2296
|
|
|
|
|
|
|
{ |
2297
|
169
|
50
|
|
|
|
|
if (IS_BREAK(string)) |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2298
|
|
|
|
|
|
|
{ |
2299
|
12
|
50
|
|
|
|
|
if (!WRITE_BREAK(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2300
|
0
|
|
|
|
|
|
return 0; |
2301
|
12
|
|
|
|
|
|
emitter->indention = 1; |
2302
|
12
|
|
|
|
|
|
breaks = 1; |
2303
|
|
|
|
|
|
|
} |
2304
|
|
|
|
|
|
|
else |
2305
|
|
|
|
|
|
|
{ |
2306
|
157
|
100
|
|
|
|
|
if (breaks) { |
2307
|
14
|
50
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
2308
|
0
|
|
|
|
|
|
return 0; |
2309
|
|
|
|
|
|
|
} |
2310
|
157
|
50
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2311
|
0
|
|
|
|
|
|
return 0; |
2312
|
157
|
|
|
|
|
|
emitter->indention = 0; |
2313
|
157
|
|
|
|
|
|
breaks = 0; |
2314
|
|
|
|
|
|
|
} |
2315
|
|
|
|
|
|
|
} |
2316
|
|
|
|
|
|
|
|
2317
|
3
|
|
|
|
|
|
return 1; |
2318
|
|
|
|
|
|
|
} |
2319
|
|
|
|
|
|
|
|
2320
|
|
|
|
|
|
|
static int |
2321
|
0
|
|
|
|
|
|
yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter, |
2322
|
|
|
|
|
|
|
yaml_char_t *value, size_t length) |
2323
|
|
|
|
|
|
|
{ |
2324
|
|
|
|
|
|
|
yaml_string_t string; |
2325
|
0
|
|
|
|
|
|
int breaks = 1; |
2326
|
0
|
|
|
|
|
|
int leading_spaces = 1; |
2327
|
|
|
|
|
|
|
|
2328
|
0
|
|
|
|
|
|
STRING_ASSIGN(string, value, length); |
2329
|
|
|
|
|
|
|
|
2330
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indicator(emitter, ">", 1, 0, 0)) |
2331
|
0
|
|
|
|
|
|
return 0; |
2332
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_block_scalar_hints(emitter, string)) |
2333
|
0
|
|
|
|
|
|
return 0; |
2334
|
0
|
0
|
|
|
|
|
if (!PUT_BREAK(emitter)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2335
|
0
|
|
|
|
|
|
return 0; |
2336
|
0
|
|
|
|
|
|
emitter->indention = 1; |
2337
|
0
|
|
|
|
|
|
emitter->whitespace = 1; |
2338
|
|
|
|
|
|
|
|
2339
|
0
|
0
|
|
|
|
|
while (string.pointer != string.end) |
2340
|
|
|
|
|
|
|
{ |
2341
|
0
|
0
|
|
|
|
|
if (IS_BREAK(string)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2342
|
|
|
|
|
|
|
{ |
2343
|
0
|
0
|
|
|
|
|
if (!breaks && !leading_spaces && CHECK(string, '\n')) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2344
|
0
|
|
|
|
|
|
int k = 0; |
2345
|
0
|
0
|
|
|
|
|
while (IS_BREAK_AT(string, k)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2346
|
0
|
0
|
|
|
|
|
k += WIDTH_AT(string, k); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2347
|
|
|
|
|
|
|
} |
2348
|
0
|
0
|
|
|
|
|
if (!IS_BLANKZ_AT(string, k)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2349
|
0
|
0
|
|
|
|
|
if (!PUT_BREAK(emitter)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2350
|
0
|
|
|
|
|
|
return 0; |
2351
|
|
|
|
|
|
|
} |
2352
|
|
|
|
|
|
|
} |
2353
|
0
|
0
|
|
|
|
|
if (!WRITE_BREAK(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2354
|
0
|
|
|
|
|
|
return 0; |
2355
|
0
|
|
|
|
|
|
emitter->indention = 1; |
2356
|
0
|
|
|
|
|
|
breaks = 1; |
2357
|
|
|
|
|
|
|
} |
2358
|
|
|
|
|
|
|
else |
2359
|
|
|
|
|
|
|
{ |
2360
|
0
|
0
|
|
|
|
|
if (breaks) { |
2361
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
2362
|
0
|
|
|
|
|
|
return 0; |
2363
|
0
|
0
|
|
|
|
|
leading_spaces = IS_BLANK(string); |
|
|
0
|
|
|
|
|
|
2364
|
|
|
|
|
|
|
} |
2365
|
0
|
0
|
|
|
|
|
if (!breaks && IS_SPACE(string) && !IS_SPACE_AT(string, 1) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2366
|
0
|
0
|
|
|
|
|
&& emitter->column > emitter->best_width) { |
2367
|
0
|
0
|
|
|
|
|
if (!yaml_emitter_write_indent(emitter)) |
2368
|
0
|
|
|
|
|
|
return 0; |
2369
|
0
|
0
|
|
|
|
|
MOVE(string); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2370
|
|
|
|
|
|
|
} |
2371
|
|
|
|
|
|
|
else { |
2372
|
0
|
0
|
|
|
|
|
if (!WRITE(emitter, string)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2373
|
0
|
|
|
|
|
|
return 0; |
2374
|
|
|
|
|
|
|
} |
2375
|
0
|
|
|
|
|
|
emitter->indention = 0; |
2376
|
0
|
|
|
|
|
|
breaks = 0; |
2377
|
|
|
|
|
|
|
} |
2378
|
|
|
|
|
|
|
} |
2379
|
|
|
|
|
|
|
|
2380
|
0
|
|
|
|
|
|
return 1; |
2381
|
|
|
|
|
|
|
} |