emitter.c

filter: Statementstmt 58.3% 662 / 1134 Branchbran 32.7% 668 / 2040 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 41.9% 1330 / 3174 SCAR 0
CC
0
Cov
0%
CRAP 0
« api.c ↑ Summary parser.c »
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 928 yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event)
293 {
294 928 ▶ if (!ENQUEUE(emitter, emitter->events, *event)) {
Branch: 3 branches
BranchTrueFalseTotal
if (!ENQUEUE(emitter, emitter->events, *event)) { 7 921 928
if (!ENQUEUE(emitter, emitter->events, *event)) { 7 0 7
if (!ENQUEUE(emitter, emitter->events, *event)) { 0 928 928
295 0 yaml_event_delete(event);
296 0 return 0;
297 }
298  
299 1856 ▶ while (!yaml_emitter_need_more_events(emitter)) {
Branch: 1 branch
BranchTrueFalseTotal
while (!yaml_emitter_need_more_events(emitter)) { 928 928 1856
300 928 ▶ if (!yaml_emitter_analyze_event(emitter, emitter->events.head))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_event(emitter, emitter->events.head)) 0 928 928
301 0 return 0;
302 928 ▶ if (!yaml_emitter_state_machine(emitter, emitter->events.head))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_state_machine(emitter, emitter->events.head)) 0 928 928
303 0 return 0;
304 928 yaml_event_delete(&DEQUEUE(emitter, emitter->events));
305 }
306  
307 928 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 1856 yaml_emitter_need_more_events(yaml_emitter_t *emitter)
321 {
322 1856 int level = 0;
323 1856 int accumulate = 0;
324 yaml_event_t *event;
325  
326 1856 ▶ if (QUEUE_EMPTY(emitter, emitter->events))
Branch: 1 branch
BranchTrueFalseTotal
if (QUEUE_EMPTY(emitter, emitter->events)) 586 1270 1856
327 586 return 1;
328  
329 1270 switch (emitter->events.head->type) {
330 220 case YAML_DOCUMENT_START_EVENT:
331 220 accumulate = 1;
332 220 break;
333 115 case YAML_SEQUENCE_START_EVENT:
334 115 accumulate = 2;
335 115 break;
336 228 case YAML_MAPPING_START_EVENT:
337 228 accumulate = 3;
338 228 break;
339 707 default:
340 707 return 0;
341 }
342  
343 563 ▶ if (emitter->events.tail - emitter->events.head > accumulate)
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->events.tail - emitter->events.head > accumulate) 202 361 563
344 202 return 0;
345  
346 930 ▶ for (event = emitter->events.head; event != emitter->events.tail; event ++) {
Branch: 1 branch
BranchTrueFalseTotal
for (event = emitter->events.head; event != emitter->events.tail; event ++) { 588 342 930
347 588 switch (event->type) {
348 390 case YAML_STREAM_START_EVENT:
349 case YAML_DOCUMENT_START_EVENT:
350 case YAML_SEQUENCE_START_EVENT:
351 case YAML_MAPPING_START_EVENT:
352 390 level += 1;
353 390 break;
354 19 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 179 default:
361 179 break;
362 }
363 588 ▶ if (!level)
Branch: 1 branch
BranchTrueFalseTotal
if (!level) 19 569 588
364 19 return 0;
365 }
366  
367 342 return 1;
368 }
369  
370 /*
371 * Append a directive to the directives stack.
372 */
373  
374 static int
375 220 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 220 yaml_tag_directive_t copy = { NULL, NULL };
380  
381 220 for (tag_directive = emitter->tag_directives.start;
382 330 ▶ tag_directive != emitter->tag_directives.top; tag_directive ++) {
Branch: 1 branch
BranchTrueFalseTotal
tag_directive != emitter->tag_directives.top; tag_directive ++) { 110 220 330
383 110 ▶ if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) { 0 110 110
384 0 ▶ if (allow_duplicates)
Branch: 1 branch
BranchTrueFalseTotal
if (allow_duplicates) 0 0 0
385 0 return 1;
386 0 return yaml_emitter_set_emitter_error(emitter,
387 "duplicate %TAG directive");
388 }
389 }
390  
391 220 copy.handle = yaml_strdup(value.handle);
392 220 copy.prefix = yaml_strdup(value.prefix);
393 220 ▶ if (!copy.handle || !copy.prefix) {
Branch: 2 branches
BranchTrueFalseTotal
if (!copy.handle || !copy.prefix) { 220 0 220
if (!copy.handle || !copy.prefix) { 0 220 220
394 0 emitter->error = YAML_MEMORY_ERROR;
395 0 goto error;
396 }
397  
398 220 ▶ if (!PUSH(emitter, emitter->tag_directives, copy))
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->tag_directives, copy)) 0 220 220
if (!PUSH(emitter, emitter->tag_directives, copy)) 0 0 0
if (!PUSH(emitter, emitter->tag_directives, copy)) 0 220 220
399 0 goto error;
400  
401 220 return 1;
402  
403 0 error:
404 0 yaml_free(copy.handle);
405 0 yaml_free(copy.prefix);
406 0 return 0;
407 }
408  
409 /*
410 * Increase the indentation level.
411 */
412  
413 static int
414 404 yaml_emitter_increase_indent(yaml_emitter_t *emitter,
415 int flow, int indentless)
416 {
417 404 ▶ if (!PUSH(emitter, emitter->indents, emitter->indent))
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->indents, emitter->indent)) 0 404 404
if (!PUSH(emitter, emitter->indents, emitter->indent)) 0 0 0
if (!PUSH(emitter, emitter->indents, emitter->indent)) 0 404 404
418 0 return 0;
419  
420 404 ▶ if (emitter->indent < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->indent < 0) { 110 294 404
421 110 ▶ emitter->indent = flow ? emitter->best_indent : 0;
Branch: 1 branch
BranchTrueFalseTotal
emitter->indent = flow ? emitter->best_indent : 0; 46 64 110
422 }
423 294 ▶ else if (!indentless) {
Branch: 1 branch
BranchTrueFalseTotal
else if (!indentless) { 291 3 294
424 291 emitter->indent += emitter->best_indent;
425 }
426  
427 404 return 1;
428 }
429  
430 /*
431 * State dispatcher.
432 */
433  
434 static int
435 928 yaml_emitter_state_machine(yaml_emitter_t *emitter, yaml_event_t *event)
436 {
437 928 switch (emitter->state)
438 {
439 88 case YAML_EMIT_STREAM_START_STATE:
440 88 return yaml_emitter_emit_stream_start(emitter, event);
441  
442 88 case YAML_EMIT_FIRST_DOCUMENT_START_STATE:
443 88 return yaml_emitter_emit_document_start(emitter, event, 1);
444  
445 110 case YAML_EMIT_DOCUMENT_START_STATE:
446 110 return yaml_emitter_emit_document_start(emitter, event, 0);
447  
448 110 case YAML_EMIT_DOCUMENT_CONTENT_STATE:
449 110 return yaml_emitter_emit_document_content(emitter, event);
450  
451 110 case YAML_EMIT_DOCUMENT_END_STATE:
452 110 return yaml_emitter_emit_document_end(emitter, event);
453  
454 10 case YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE:
455 10 return yaml_emitter_emit_flow_sequence_item(emitter, event, 1);
456  
457 0 case YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE:
458 0 return yaml_emitter_emit_flow_sequence_item(emitter, event, 0);
459  
460 9 case YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE:
461 9 return yaml_emitter_emit_flow_mapping_key(emitter, event, 1);
462  
463 0 case YAML_EMIT_FLOW_MAPPING_KEY_STATE:
464 0 return yaml_emitter_emit_flow_mapping_key(emitter, event, 0);
465  
466 0 case YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE:
467 0 return yaml_emitter_emit_flow_mapping_value(emitter, event, 1);
468  
469 0 case YAML_EMIT_FLOW_MAPPING_VALUE_STATE:
470 0 return yaml_emitter_emit_flow_mapping_value(emitter, event, 0);
471  
472 34 case YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE:
473 34 return yaml_emitter_emit_block_sequence_item(emitter, event, 1);
474  
475 91 case YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE:
476 91 return yaml_emitter_emit_block_sequence_item(emitter, event, 0);
477  
478 58 case YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE:
479 58 return yaml_emitter_emit_block_mapping_key(emitter, event, 1);
480  
481 110 case YAML_EMIT_BLOCK_MAPPING_KEY_STATE:
482 110 return yaml_emitter_emit_block_mapping_key(emitter, event, 0);
483  
484 110 case YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE:
485 110 return yaml_emitter_emit_block_mapping_value(emitter, event, 1);
486  
487 0 case YAML_EMIT_BLOCK_MAPPING_VALUE_STATE:
488 0 return yaml_emitter_emit_block_mapping_value(emitter, event, 0);
489  
490 0 case YAML_EMIT_END_STATE:
491 0 return yaml_emitter_set_emitter_error(emitter,
492 "expected nothing after STREAM-END");
493  
494 0 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 88 yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
507 yaml_event_t *event)
508 {
509 88 ▶ if (event->type == YAML_STREAM_START_EVENT)
Branch: 1 branch
BranchTrueFalseTotal
if (event->type == YAML_STREAM_START_EVENT) 88 0 88
510 {
511 88 ▶ if (!emitter->encoding) {
Branch: 1 branch
BranchTrueFalseTotal
if (!emitter->encoding) { 88 0 88
512 88 emitter->encoding = event->data.stream_start.encoding;
513 }
514  
515 88 ▶ if (!emitter->encoding) {
Branch: 1 branch
BranchTrueFalseTotal
if (!emitter->encoding) { 88 0 88
516 88 emitter->encoding = YAML_UTF8_ENCODING;
517 }
518  
519 88 ▶ if (emitter->best_indent < 2 || emitter->best_indent > 9) {
Branch: 2 branches
BranchTrueFalseTotal
if (emitter->best_indent < 2 || emitter->best_indent > 9) { 88 0 88
if (emitter->best_indent < 2 || emitter->best_indent > 9) { 0 88 88
520 0 emitter->best_indent = 2;
521 }
522  
523 88 ▶ if (emitter->best_width >= 0
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->best_width >= 0 88 0 88
524 88 ▶ && emitter->best_width <= emitter->best_indent*2) {
Branch: 1 branch
BranchTrueFalseTotal
&& emitter->best_width <= emitter->best_indent*2) { 0 88 88
525 0 emitter->best_width = 80;
526 }
527  
528 88 ▶ if (emitter->best_width < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->best_width < 0) { 0 88 88
529 0 emitter->best_width = INT_MAX;
530 }
531  
532 88 ▶ if (!emitter->line_break) {
Branch: 1 branch
BranchTrueFalseTotal
if (!emitter->line_break) { 88 0 88
533 88 emitter->line_break = YAML_LN_BREAK;
534 }
535  
536 88 emitter->indent = -1;
537  
538 88 emitter->line = 0;
539 88 emitter->column = 0;
540 88 emitter->whitespace = 1;
541 88 emitter->indention = 1;
542  
543 88 ▶ if (emitter->encoding != YAML_UTF8_ENCODING) {
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->encoding != YAML_UTF8_ENCODING) { 0 88 88
544 0 ▶ if (!yaml_emitter_write_bom(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_bom(emitter)) 0 0 0
545 0 return 0;
546 }
547  
548 88 emitter->state = YAML_EMIT_FIRST_DOCUMENT_START_STATE;
549  
550 88 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 198 yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
563 yaml_event_t *event, int first)
564 {
565 198 ▶ if (event->type == YAML_DOCUMENT_START_EVENT)
Branch: 1 branch
BranchTrueFalseTotal
if (event->type == YAML_DOCUMENT_START_EVENT) 110 88 198
566 {
567 110 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 110 ▶ if (event->data.document_start.version_directive) {
Branch: 1 branch
BranchTrueFalseTotal
if (event->data.document_start.version_directive) { 0 110 110
576 0 ▶ if (!yaml_emitter_analyze_version_directive(emitter,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_version_directive(emitter, 0 0 0
577 0 *event->data.document_start.version_directive))
578 0 return 0;
579 }
580  
581 110 for (tag_directive = event->data.document_start.tag_directives.start;
582 110 ▶ tag_directive != event->data.document_start.tag_directives.end;
Branch: 1 branch
BranchTrueFalseTotal
tag_directive != event->data.document_start.tag_directives.end; 0 110 110
583 0 tag_directive ++) {
584 0 ▶ if (!yaml_emitter_analyze_tag_directive(emitter, *tag_directive))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_tag_directive(emitter, *tag_directive)) 0 0 0
585 0 return 0;
586 0 ▶ if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 0)) 0 0 0
587 0 return 0;
588 }
589  
590 110 for (tag_directive = default_tag_directives;
591 330 ▶ tag_directive->handle; tag_directive ++) {
Branch: 1 branch
BranchTrueFalseTotal
tag_directive->handle; tag_directive ++) { 220 110 330
592 220 ▶ if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 1))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 1)) 0 220 220
593 0 return 0;
594 }
595  
596 110 implicit = event->data.document_start.implicit;
597 110 ▶ if (!first || emitter->canonical) {
Branch: 2 branches
BranchTrueFalseTotal
if (!first || emitter->canonical) { 87 23 110
if (!first || emitter->canonical) { 0 87 87
598 23 implicit = 0;
599 }
600  
601 110 ▶ if ((event->data.document_start.version_directive ||
Branch: 1 branch
BranchTrueFalseTotal
if ((event->data.document_start.version_directive || 110 0 110
602 110 (event->data.document_start.tag_directives.start
603 110 ▶ != event->data.document_start.tag_directives.end)) &&
Branch: 1 branch
BranchTrueFalseTotal
!= event->data.document_start.tag_directives.end)) && 0 110 110
604 0 ▶ emitter->open_ended)
Branch: 1 branch
BranchTrueFalseTotal
emitter->open_ended) 0 0 0
605 {
606 0 ▶ if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0)) 0 0 0
607 0 return 0;
608 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
609 0 return 0;
610 }
611  
612 110 ▶ if (event->data.document_start.version_directive) {
Branch: 1 branch
BranchTrueFalseTotal
if (event->data.document_start.version_directive) { 0 110 110
613 0 implicit = 0;
614 0 ▶ if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0)) 0 0 0
615 0 return 0;
616 0 ▶ if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0)) 0 0 0
617 0 return 0;
618 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
619 0 return 0;
620 }
621  
622 110 if (event->data.document_start.tag_directives.start
623 110 ▶ != event->data.document_start.tag_directives.end) {
Branch: 1 branch
BranchTrueFalseTotal
!= event->data.document_start.tag_directives.end) { 0 110 110
624 0 implicit = 0;
625 0 for (tag_directive = event->data.document_start.tag_directives.start;
626 0 ▶ tag_directive != event->data.document_start.tag_directives.end;
Branch: 1 branch
BranchTrueFalseTotal
tag_directive != event->data.document_start.tag_directives.end; 0 0 0
627 0 tag_directive ++) {
628 0 ▶ if (!yaml_emitter_write_indicator(emitter, "%TAG", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "%TAG", 1, 0, 0)) 0 0 0
629 0 return 0;
630 0 ▶ if (!yaml_emitter_write_tag_handle(emitter, tag_directive->handle,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_tag_handle(emitter, tag_directive->handle, 0 0 0
631 0 strlen((char *)tag_directive->handle)))
632 0 return 0;
633 0 ▶ if (!yaml_emitter_write_tag_content(emitter, tag_directive->prefix,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_tag_content(emitter, tag_directive->prefix, 0 0 0
634 0 strlen((char *)tag_directive->prefix), 1))
635 0 return 0;
636 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
637 0 return 0;
638 }
639 }
640  
641 110 ▶ if (yaml_emitter_check_empty_document(emitter)) {
Branch: 1 branch
BranchTrueFalseTotal
if (yaml_emitter_check_empty_document(emitter)) { 0 110 110
642 0 implicit = 0;
643 }
644  
645 110 ▶ if (!implicit) {
Branch: 1 branch
BranchTrueFalseTotal
if (!implicit) { 110 0 110
646 110 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 110 110
647 0 return 0;
648 110 ▶ if (!yaml_emitter_write_indicator(emitter, "---", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "---", 1, 0, 0)) 0 110 110
649 0 return 0;
650 110 ▶ if (emitter->canonical) {
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->canonical) { 0 110 110
651 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
652 0 return 0;
653 }
654 }
655  
656 110 emitter->state = YAML_EMIT_DOCUMENT_CONTENT_STATE;
657  
658 110 return 1;
659 }
660  
661 88 ▶ else if (event->type == YAML_STREAM_END_EVENT)
Branch: 1 branch
BranchTrueFalseTotal
else if (event->type == YAML_STREAM_END_EVENT) 88 0 88
662 {
663  
664 88 ▶ if (!yaml_emitter_flush(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_flush(emitter)) 0 88 88
665 0 return 0;
666  
667 88 emitter->state = YAML_EMIT_END_STATE;
668  
669 88 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 110 yaml_emitter_emit_document_content(yaml_emitter_t *emitter,
682 yaml_event_t *event)
683 {
684 110 ▶ if (!PUSH(emitter, emitter->states, YAML_EMIT_DOCUMENT_END_STATE))
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->states, YAML_EMIT_DOCUMENT_END_STATE)) 0 110 110
if (!PUSH(emitter, emitter->states, YAML_EMIT_DOCUMENT_END_STATE)) 0 0 0
if (!PUSH(emitter, emitter->states, YAML_EMIT_DOCUMENT_END_STATE)) 0 110 110
685 0 return 0;
686  
687 110 return yaml_emitter_emit_node(emitter, event, 1, 0, 0, 0);
688 }
689  
690 /*
691 * Expect DOCUMENT-END.
692 */
693  
694 static int
695 110 yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
696 yaml_event_t *event)
697 {
698 110 ▶ if (event->type == YAML_DOCUMENT_END_EVENT)
Branch: 1 branch
BranchTrueFalseTotal
if (event->type == YAML_DOCUMENT_END_EVENT) 110 0 110
699 {
700 110 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 110 110
701 0 return 0;
702 110 ▶ if (!event->data.document_end.implicit) {
Branch: 1 branch
BranchTrueFalseTotal
if (!event->data.document_end.implicit) { 0 110 110
703 0 ▶ if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0)) 0 0 0
704 0 return 0;
705 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
706 0 return 0;
707 }
708 110 ▶ if (!yaml_emitter_flush(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_flush(emitter)) 0 110 110
709 0 return 0;
710  
711 110 emitter->state = YAML_EMIT_DOCUMENT_START_STATE;
712  
713 330 ▶ while (!STACK_EMPTY(emitter, emitter->tag_directives)) {
Branch: 1 branch
BranchTrueFalseTotal
while (!STACK_EMPTY(emitter, emitter->tag_directives)) { 220 110 330
714 220 yaml_tag_directive_t tag_directive = POP(emitter,
715 emitter->tag_directives);
716 220 yaml_free(tag_directive.handle);
717 220 yaml_free(tag_directive.prefix);
718 }
719  
720 110 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 ▶ if (first)
Branch: 1 branch
BranchTrueFalseTotal
if (first) 10 0 10
737 {
738 10 ▶ if (!yaml_emitter_write_indicator(emitter, "[", 1, 1, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "[", 1, 1, 0)) 0 10 10
739 0 return 0;
740 10 ▶ if (!yaml_emitter_increase_indent(emitter, 1, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_increase_indent(emitter, 1, 0)) 0 10 10
741 0 return 0;
742 10 emitter->flow_level ++;
743 }
744  
745 10 ▶ if (event->type == YAML_SEQUENCE_END_EVENT)
Branch: 1 branch
BranchTrueFalseTotal
if (event->type == YAML_SEQUENCE_END_EVENT) 10 0 10
746 {
747 10 emitter->flow_level --;
748 10 emitter->indent = POP(emitter, emitter->indents);
749 10 ▶ if (emitter->canonical && !first) {
Branch: 2 branches
BranchTrueFalseTotal
if (emitter->canonical && !first) { 0 10 10
if (emitter->canonical && !first) { 0 0 0
750 0 ▶ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0)) 0 0 0
751 0 return 0;
752 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
753 0 return 0;
754 }
755 10 ▶ if (!yaml_emitter_write_indicator(emitter, "]", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "]", 0, 0, 0)) 0 10 10
756 0 return 0;
757 10 emitter->state = POP(emitter, emitter->states);
758  
759 10 return 1;
760 }
761  
762 0 ▶ if (!first) {
Branch: 1 branch
BranchTrueFalseTotal
if (!first) { 0 0 0
763 0 ▶ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0)) 0 0 0
764 0 return 0;
765 }
766  
767 0 ▶ if (emitter->canonical || emitter->column > emitter->best_width) {
Branch: 2 branches
BranchTrueFalseTotal
if (emitter->canonical || emitter->column > emitter->best_width) { 0 0 0
if (emitter->canonical || emitter->column > emitter->best_width) { 0 0 0
768 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
769 0 return 0;
770 }
771 0 ▶ if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE))
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE)) 0 0 0
if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE)) 0 0 0
if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE)) 0 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 ▶ if (first)
Branch: 1 branch
BranchTrueFalseTotal
if (first) 9 0 9
786 {
787 9 ▶ if (!yaml_emitter_write_indicator(emitter, "{", 1, 1, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "{", 1, 1, 0)) 0 9 9
788 0 return 0;
789 9 ▶ if (!yaml_emitter_increase_indent(emitter, 1, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_increase_indent(emitter, 1, 0)) 0 9 9
790 0 return 0;
791 9 emitter->flow_level ++;
792 }
793  
794 9 ▶ if (event->type == YAML_MAPPING_END_EVENT)
Branch: 1 branch
BranchTrueFalseTotal
if (event->type == YAML_MAPPING_END_EVENT) 9 0 9
795 {
796 9 emitter->flow_level --;
797 9 emitter->indent = POP(emitter, emitter->indents);
798 9 ▶ if (emitter->canonical && !first) {
Branch: 2 branches
BranchTrueFalseTotal
if (emitter->canonical && !first) { 0 9 9
if (emitter->canonical && !first) { 0 0 0
799 0 ▶ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0)) 0 0 0
800 0 return 0;
801 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
802 0 return 0;
803 }
804 9 ▶ if (!yaml_emitter_write_indicator(emitter, "}", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "}", 0, 0, 0)) 0 9 9
805 0 return 0;
806 9 emitter->state = POP(emitter, emitter->states);
807  
808 9 return 1;
809 }
810  
811 0 ▶ if (!first) {
Branch: 1 branch
BranchTrueFalseTotal
if (!first) { 0 0 0
812 0 ▶ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0)) 0 0 0
813 0 return 0;
814 }
815 0 ▶ if (emitter->canonical || emitter->column > emitter->best_width) {
Branch: 2 branches
BranchTrueFalseTotal
if (emitter->canonical || emitter->column > emitter->best_width) { 0 0 0
if (emitter->canonical || emitter->column > emitter->best_width) { 0 0 0
816 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
817 0 return 0;
818 }
819  
820 0 ▶ if (!emitter->canonical && yaml_emitter_check_simple_key(emitter))
Branch: 2 branches
BranchTrueFalseTotal
if (!emitter->canonical && yaml_emitter_check_simple_key(emitter)) 0 0 0
if (!emitter->canonical && yaml_emitter_check_simple_key(emitter)) 0 0 0
821 {
822 0 ▶ if (!PUSH(emitter, emitter->states,
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->states, 0 0 0
if (!PUSH(emitter, emitter->states, 0 0 0
if (!PUSH(emitter, emitter->states, 0 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 ▶ if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 0)) 0 0 0
831 0 return 0;
832 0 ▶ if (!PUSH(emitter, emitter->states,
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->states, 0 0 0
if (!PUSH(emitter, emitter->states, 0 0 0
if (!PUSH(emitter, emitter->states, 0 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 ▶ if (simple) {
Branch: 1 branch
BranchTrueFalseTotal
if (simple) { 0 0 0
849 0 ▶ if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0)) 0 0 0
850 0 return 0;
851 }
852 else {
853 0 ▶ if (emitter->canonical || emitter->column > emitter->best_width) {
Branch: 2 branches
BranchTrueFalseTotal
if (emitter->canonical || emitter->column > emitter->best_width) { 0 0 0
if (emitter->canonical || emitter->column > emitter->best_width) { 0 0 0
854 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
855 0 return 0;
856 }
857 0 ▶ if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 0)) 0 0 0
858 0 return 0;
859 }
860 0 ▶ if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_MAPPING_KEY_STATE))
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_MAPPING_KEY_STATE)) 0 0 0
if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_MAPPING_KEY_STATE)) 0 0 0
if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_MAPPING_KEY_STATE)) 0 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 ▶ if (first)
Branch: 1 branch
BranchTrueFalseTotal
if (first) 34 91 125
874 {
875 34 ▶ if (!yaml_emitter_increase_indent(emitter, 0,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_increase_indent(emitter, 0, 0 34 34
876 34 ▶ emitter->indentless_map && (emitter->mapping_context && !emitter->indention)))
Branch: 3 branches
BranchTrueFalseTotal
emitter->indentless_map && (emitter->mapping_context && !emitter->indention))) 7 27 34
emitter->indentless_map && (emitter->mapping_context && !emitter->indention))) 3 4 7
emitter->indentless_map && (emitter->mapping_context && !emitter->indention))) 3 0 3
877 0 return 0;
878 }
879  
880 125 ▶ if (event->type == YAML_SEQUENCE_END_EVENT)
Branch: 1 branch
BranchTrueFalseTotal
if (event->type == YAML_SEQUENCE_END_EVENT) 34 91 125
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 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 91 91
889 0 return 0;
890 91 ▶ if (!yaml_emitter_write_indicator(emitter, "-", 1, 0, 1))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "-", 1, 0, 1)) 0 91 91
891 0 return 0;
892 91 ▶ if (!PUSH(emitter, emitter->states,
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->states, 0 91 91
if (!PUSH(emitter, emitter->states, 0 0 0
if (!PUSH(emitter, emitter->states, 0 91 91
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 168 yaml_emitter_emit_block_mapping_key(yaml_emitter_t *emitter,
905 yaml_event_t *event, int first)
906 {
907 168 ▶ if (first)
Branch: 1 branch
BranchTrueFalseTotal
if (first) 58 110 168
908 {
909 58 ▶ if (!yaml_emitter_increase_indent(emitter, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_increase_indent(emitter, 0, 0)) 0 58 58
910 0 return 0;
911 }
912  
913 168 ▶ if (event->type == YAML_MAPPING_END_EVENT)
Branch: 1 branch
BranchTrueFalseTotal
if (event->type == YAML_MAPPING_END_EVENT) 58 110 168
914 {
915 58 emitter->indent = POP(emitter, emitter->indents);
916 58 emitter->state = POP(emitter, emitter->states);
917  
918 58 return 1;
919 }
920  
921 110 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 110 110
922 0 return 0;
923  
924 110 ▶ if (yaml_emitter_check_simple_key(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (yaml_emitter_check_simple_key(emitter)) 110 0 110
925 {
926 110 ▶ if (!PUSH(emitter, emitter->states,
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->states, 0 110 110
if (!PUSH(emitter, emitter->states, 0 0 0
if (!PUSH(emitter, emitter->states, 0 110 110
927 YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE))
928 0 return 0;
929  
930 110 return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 1);
931 }
932 else
933 {
934 0 ▶ if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 1))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 1)) 0 0 0
935 0 return 0;
936 0 ▶ if (!PUSH(emitter, emitter->states,
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->states, 0 0 0
if (!PUSH(emitter, emitter->states, 0 0 0
if (!PUSH(emitter, emitter->states, 0 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 110 yaml_emitter_emit_block_mapping_value(yaml_emitter_t *emitter,
950 yaml_event_t *event, int simple)
951 {
952 110 ▶ if (simple) {
Branch: 1 branch
BranchTrueFalseTotal
if (simple) { 110 0 110
953 110 ▶ if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0)) 0 110 110
954 0 return 0;
955 }
956 else {
957 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
958 0 return 0;
959 0 ▶ if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 1))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 1)) 0 0 0
960 0 return 0;
961 }
962 110 ▶ if (!PUSH(emitter, emitter->states,
Branch: 3 branches
BranchTrueFalseTotal
if (!PUSH(emitter, emitter->states, 0 110 110
if (!PUSH(emitter, emitter->states, 0 0 0
if (!PUSH(emitter, emitter->states, 0 110 110
963 YAML_EMIT_BLOCK_MAPPING_KEY_STATE))
964 0 return 0;
965  
966 110 return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
967 }
968  
969 /*
970 * Expect a node.
971 */
972  
973 static int
974 421 yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
975 int root, int sequence, int mapping, int simple_key)
976 {
977 421 emitter->root_context = root;
978 421 emitter->sequence_context = sequence;
979 421 emitter->mapping_context = mapping;
980 421 emitter->simple_key_context = simple_key;
981  
982 421 switch (event->type)
983 {
984 17 case YAML_ALIAS_EVENT:
985 17 return yaml_emitter_emit_alias(emitter, event);
986  
987 293 case YAML_SCALAR_EVENT:
988 293 return yaml_emitter_emit_scalar(emitter, event);
989  
990 44 case YAML_SEQUENCE_START_EVENT:
991 44 return yaml_emitter_emit_sequence_start(emitter, event);
992  
993 67 case YAML_MAPPING_START_EVENT:
994 67 return yaml_emitter_emit_mapping_start(emitter, event);
995  
996 0 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 ▶ if (!yaml_emitter_process_anchor(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_process_anchor(emitter)) 0 17 17
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 293 yaml_emitter_emit_scalar(yaml_emitter_t *emitter, yaml_event_t *event)
1022 {
1023 293 ▶ if (!yaml_emitter_select_scalar_style(emitter, event))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_select_scalar_style(emitter, event)) 0 293 293
1024 0 return 0;
1025 293 ▶ if (!yaml_emitter_process_anchor(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_process_anchor(emitter)) 0 293 293
1026 0 return 0;
1027 293 ▶ if (!yaml_emitter_process_tag(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_process_tag(emitter)) 0 293 293
1028 0 return 0;
1029 293 ▶ if (!yaml_emitter_increase_indent(emitter, 1, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_increase_indent(emitter, 1, 0)) 0 293 293
1030 0 return 0;
1031 293 ▶ if (!yaml_emitter_process_scalar(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_process_scalar(emitter)) 0 293 293
1032 0 return 0;
1033 293 emitter->indent = POP(emitter, emitter->indents);
1034 293 emitter->state = POP(emitter, emitter->states);
1035  
1036 293 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 ▶ if (!yaml_emitter_process_anchor(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_process_anchor(emitter)) 0 44 44
1047 0 return 0;
1048 44 ▶ if (!yaml_emitter_process_tag(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_process_tag(emitter)) 0 44 44
1049 0 return 0;
1050  
1051 44 ▶ if (emitter->flow_level || emitter->canonical
Branch: 2 branches
BranchTrueFalseTotal
if (emitter->flow_level || emitter->canonical 44 0 44
if (emitter->flow_level || emitter->canonical 44 0 44
1052 44 ▶ || event->data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE
Branch: 1 branch
BranchTrueFalseTotal
|| event->data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE 44 0 44
1053 44 ▶ || yaml_emitter_check_empty_sequence(emitter)) {
Branch: 1 branch
BranchTrueFalseTotal
|| yaml_emitter_check_empty_sequence(emitter)) { 10 34 44
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 67 yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event)
1069 {
1070 67 ▶ if (!yaml_emitter_process_anchor(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_process_anchor(emitter)) 0 67 67
1071 0 return 0;
1072 67 ▶ if (!yaml_emitter_process_tag(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_process_tag(emitter)) 0 67 67
1073 0 return 0;
1074  
1075 67 ▶ if (emitter->flow_level || emitter->canonical
Branch: 2 branches
BranchTrueFalseTotal
if (emitter->flow_level || emitter->canonical 67 0 67
if (emitter->flow_level || emitter->canonical 67 0 67
1076 67 ▶ || event->data.mapping_start.style == YAML_FLOW_MAPPING_STYLE
Branch: 1 branch
BranchTrueFalseTotal
|| event->data.mapping_start.style == YAML_FLOW_MAPPING_STYLE 67 0 67
1077 67 ▶ || yaml_emitter_check_empty_mapping(emitter)) {
Branch: 1 branch
BranchTrueFalseTotal
|| yaml_emitter_check_empty_mapping(emitter)) { 9 58 67
1078 9 emitter->state = YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE;
1079 }
1080 else {
1081 58 emitter->state = YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE;
1082 }
1083  
1084 67 return 1;
1085 }
1086  
1087 /*
1088 * Check if the document content is an empty scalar.
1089 */
1090  
1091 static int
1092 110 yaml_emitter_check_empty_document(SHIM(yaml_emitter_t *emitter))
1093 {
1094 110 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 ▶ if (emitter->events.tail - emitter->events.head < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->events.tail - emitter->events.head < 2) 0 44 44
1105 0 return 0;
1106  
1107 44 return (emitter->events.head[0].type == YAML_SEQUENCE_START_EVENT
1108 44 ▶ && emitter->events.head[1].type == YAML_SEQUENCE_END_EVENT);
Branch: 2 branches
BranchTrueFalseTotal
&& emitter->events.head[1].type == YAML_SEQUENCE_END_EVENT); 44 0 44
&& emitter->events.head[1].type == YAML_SEQUENCE_END_EVENT); 10 34 44
1109 }
1110  
1111 /*
1112 * Check if the next events represent an empty mapping.
1113 */
1114  
1115 static int
1116 67 yaml_emitter_check_empty_mapping(yaml_emitter_t *emitter)
1117 {
1118 67 ▶ if (emitter->events.tail - emitter->events.head < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->events.tail - emitter->events.head < 2) 0 67 67
1119 0 return 0;
1120  
1121 67 return (emitter->events.head[0].type == YAML_MAPPING_START_EVENT
1122 67 ▶ && emitter->events.head[1].type == YAML_MAPPING_END_EVENT);
Branch: 2 branches
BranchTrueFalseTotal
&& emitter->events.head[1].type == YAML_MAPPING_END_EVENT); 67 0 67
&& emitter->events.head[1].type == YAML_MAPPING_END_EVENT); 9 58 67
1123 }
1124  
1125 /*
1126 * Check if the next node can be expressed as a simple key.
1127 */
1128  
1129 static int
1130 110 yaml_emitter_check_simple_key(yaml_emitter_t *emitter)
1131 {
1132 110 yaml_event_t *event = emitter->events.head;
1133 110 size_t length = 0;
1134  
1135 110 switch (event->type)
1136 {
1137 0 case YAML_ALIAS_EVENT:
1138 0 length += emitter->anchor_data.anchor_length;
1139 0 break;
1140  
1141 110 case YAML_SCALAR_EVENT:
1142 110 ▶ if (emitter->scalar_data.multiline)
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->scalar_data.multiline) 0 110 110
1143 0 return 0;
1144 110 length += emitter->anchor_data.anchor_length
1145 110 + emitter->tag_data.handle_length
1146 110 + emitter->tag_data.suffix_length
1147 110 + emitter->scalar_data.length;
1148 110 break;
1149  
1150 0 case YAML_SEQUENCE_START_EVENT:
1151 0 ▶ if (!yaml_emitter_check_empty_sequence(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_check_empty_sequence(emitter)) 0 0 0
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 0 case YAML_MAPPING_START_EVENT:
1159 0 ▶ if (!yaml_emitter_check_empty_mapping(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_check_empty_mapping(emitter)) 0 0 0
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 0 default:
1167 0 return 0;
1168 }
1169  
1170 110 ▶ if (length > 128)
Branch: 1 branch
BranchTrueFalseTotal
if (length > 128) 0 110 110
1171 0 return 0;
1172  
1173 110 return 1;
1174 }
1175  
1176 /*
1177 * Determine an acceptable scalar style.
1178 */
1179  
1180 static int
1181 293 yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event)
1182 {
1183 293 yaml_scalar_style_t style = event->data.scalar.style;
1184 293 ▶ int no_tag = (!emitter->tag_data.handle && !emitter->tag_data.suffix);
Branch: 2 branches
BranchTrueFalseTotal
int no_tag = (!emitter->tag_data.handle && !emitter->tag_data.suffix); 280 13 293
int no_tag = (!emitter->tag_data.handle && !emitter->tag_data.suffix); 280 0 280
1185  
1186 293 ▶ if (no_tag && !event->data.scalar.plain_implicit
Branch: 2 branches
BranchTrueFalseTotal
if (no_tag && !event->data.scalar.plain_implicit 280 13 293
if (no_tag && !event->data.scalar.plain_implicit 0 280 280
1187 0 ▶ && !event->data.scalar.quoted_implicit) {
Branch: 1 branch
BranchTrueFalseTotal
&& !event->data.scalar.quoted_implicit) { 0 0 0
1188 0 return yaml_emitter_set_emitter_error(emitter,
1189 "neither tag nor implicit flags are specified");
1190 }
1191  
1192 293 ▶ if (style == YAML_ANY_SCALAR_STYLE)
Branch: 1 branch
BranchTrueFalseTotal
if (style == YAML_ANY_SCALAR_STYLE) 0 293 293
1193 0 style = YAML_PLAIN_SCALAR_STYLE;
1194  
1195 293 ▶ if (emitter->canonical)
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->canonical) 0 293 293
1196 0 style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
1197  
1198 293 ▶ if (emitter->simple_key_context && emitter->scalar_data.multiline)
Branch: 2 branches
BranchTrueFalseTotal
if (emitter->simple_key_context && emitter->scalar_data.multiline) 110 183 293
if (emitter->simple_key_context && emitter->scalar_data.multiline) 0 110 110
1199 0 style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
1200  
1201 293 ▶ if (style == YAML_PLAIN_SCALAR_STYLE)
Branch: 1 branch
BranchTrueFalseTotal
if (style == YAML_PLAIN_SCALAR_STYLE) 264 29 293
1202 {
1203 264 ▶ if ((emitter->flow_level && !emitter->scalar_data.flow_plain_allowed)
Branch: 2 branches
BranchTrueFalseTotal
if ((emitter->flow_level && !emitter->scalar_data.flow_plain_allowed) 0 264 264
if ((emitter->flow_level && !emitter->scalar_data.flow_plain_allowed) 0 0 0
1204 264 ▶ || (!emitter->flow_level && !emitter->scalar_data.block_plain_allowed))
Branch: 2 branches
BranchTrueFalseTotal
|| (!emitter->flow_level && !emitter->scalar_data.block_plain_allowed)) 264 0 264
|| (!emitter->flow_level && !emitter->scalar_data.block_plain_allowed)) 10 254 264
1205 10 style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
1206 264 ▶ if (!emitter->scalar_data.length
Branch: 1 branch
BranchTrueFalseTotal
if (!emitter->scalar_data.length 0 264 264
1207 0 ▶ && (emitter->flow_level || emitter->simple_key_context))
Branch: 2 branches
BranchTrueFalseTotal
&& (emitter->flow_level || emitter->simple_key_context)) 0 0 0
&& (emitter->flow_level || emitter->simple_key_context)) 0 0 0
1208 0 style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
1209 264 ▶ if (no_tag && !event->data.scalar.plain_implicit)
Branch: 2 branches
BranchTrueFalseTotal
if (no_tag && !event->data.scalar.plain_implicit) 256 8 264
if (no_tag && !event->data.scalar.plain_implicit) 0 256 256
1210 0 style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
1211 }
1212  
1213 293 ▶ if (style == YAML_SINGLE_QUOTED_SCALAR_STYLE)
Branch: 1 branch
BranchTrueFalseTotal
if (style == YAML_SINGLE_QUOTED_SCALAR_STYLE) 33 260 293
1214 {
1215 33 ▶ if (!emitter->scalar_data.single_quoted_allowed)
Branch: 1 branch
BranchTrueFalseTotal
if (!emitter->scalar_data.single_quoted_allowed) 5 28 33
1216 5 style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
1217 }
1218  
1219 293 ▶ if (style == YAML_LITERAL_SCALAR_STYLE || style == YAML_FOLDED_SCALAR_STYLE)
Branch: 2 branches
BranchTrueFalseTotal
if (style == YAML_LITERAL_SCALAR_STYLE || style == YAML_FOLDED_SCALAR_STYLE) 290 3 293
if (style == YAML_LITERAL_SCALAR_STYLE || style == YAML_FOLDED_SCALAR_STYLE) 0 290 290
1220 {
1221 3 ▶ if (!emitter->scalar_data.block_allowed
Branch: 1 branch
BranchTrueFalseTotal
if (!emitter->scalar_data.block_allowed 3 0 3
1222 3 ▶ || emitter->flow_level || emitter->simple_key_context)
Branch: 2 branches
BranchTrueFalseTotal
|| emitter->flow_level || emitter->simple_key_context) 3 0 3
|| emitter->flow_level || emitter->simple_key_context) 0 3 3
1223 0 style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
1224 }
1225  
1226 293 ▶ if (no_tag && !event->data.scalar.quoted_implicit
Branch: 2 branches
BranchTrueFalseTotal
if (no_tag && !event->data.scalar.quoted_implicit 280 13 293
if (no_tag && !event->data.scalar.quoted_implicit 0 280 280
1227 0 ▶ && style != YAML_PLAIN_SCALAR_STYLE)
Branch: 1 branch
BranchTrueFalseTotal
&& style != YAML_PLAIN_SCALAR_STYLE) 0 0 0
1228 {
1229 0 emitter->tag_data.handle = (yaml_char_t *)"!";
1230 0 emitter->tag_data.handle_length = 1;
1231 }
1232  
1233 293 emitter->scalar_data.style = style;
1234  
1235 293 return 1;
1236 }
1237  
1238 /*
1239 * Write an anchor.
1240 */
1241  
1242 static int
1243 421 yaml_emitter_process_anchor(yaml_emitter_t *emitter)
1244 {
1245 421 ▶ if (!emitter->anchor_data.anchor)
Branch: 1 branch
BranchTrueFalseTotal
if (!emitter->anchor_data.anchor) 388 33 421
1246 388 return 1;
1247  
1248 33 ▶ if (!yaml_emitter_write_indicator(emitter,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, 0 33 33
1249 33 ▶ (emitter->anchor_data.alias ? "*" : "&"), 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
(emitter->anchor_data.alias ? "*" : "&"), 1, 0, 0)) 17 16 33
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 404 yaml_emitter_process_tag(yaml_emitter_t *emitter)
1262 {
1263 404 ▶ if (!emitter->tag_data.handle && !emitter->tag_data.suffix)
Branch: 2 branches
BranchTrueFalseTotal
if (!emitter->tag_data.handle && !emitter->tag_data.suffix) 361 43 404
if (!emitter->tag_data.handle && !emitter->tag_data.suffix) 361 0 361
1264 361 return 1;
1265  
1266 43 ▶ if (emitter->tag_data.handle)
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->tag_data.handle) 43 0 43
1267 {
1268 43 ▶ if (!yaml_emitter_write_tag_handle(emitter, emitter->tag_data.handle,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_tag_handle(emitter, emitter->tag_data.handle, 0 43 43
1269 emitter->tag_data.handle_length))
1270 0 return 0;
1271 43 ▶ if (emitter->tag_data.suffix) {
Branch: 1 branch
BranchTrueFalseTotal
if (emitter->tag_data.suffix) { 43 0 43
1272 43 ▶ if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix, 0 43 43
1273 emitter->tag_data.suffix_length, 0))
1274 0 return 0;
1275 }
1276 }
1277 else
1278 {
1279 0 ▶ if (!yaml_emitter_write_indicator(emitter, "!<", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "!<", 1, 0, 0)) 0 0 0
1280 0 return 0;
1281 0 ▶ if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix, 0 0 0
1282 emitter->tag_data.suffix_length, 0))
1283 0 return 0;
1284 0 ▶ if (!yaml_emitter_write_indicator(emitter, ">", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ">", 0, 0, 0)) 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 293 yaml_emitter_process_scalar(yaml_emitter_t *emitter)
1297 {
1298 293 switch (emitter->scalar_data.style)
1299 {
1300 254 case YAML_PLAIN_SCALAR_STYLE:
1301 254 return yaml_emitter_write_plain_scalar(emitter,
1302 emitter->scalar_data.value, emitter->scalar_data.length,
1303 254 !emitter->simple_key_context);
1304  
1305 28 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 8 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 3 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 0 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 0 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 ▶ if (version_directive.major != 1 || version_directive.minor != 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (version_directive.major != 1 || version_directive.minor != 1) { 0 0 0
if (version_directive.major != 1 || version_directive.minor != 1) { 0 0 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 ▶ if (handle.start == handle.end) {
Branch: 1 branch
BranchTrueFalseTotal
if (handle.start == handle.end) { 0 0 0
1365 0 return yaml_emitter_set_emitter_error(emitter,
1366 "tag handle must not be empty");
1367 }
1368  
1369 0 ▶ if (handle.start[0] != '!') {
Branch: 1 branch
BranchTrueFalseTotal
if (handle.start[0] != '!') { 0 0 0
1370 0 return yaml_emitter_set_emitter_error(emitter,
1371 "tag handle must start with '!'");
1372 }
1373  
1374 0 ▶ if (handle.end[-1] != '!') {
Branch: 1 branch
BranchTrueFalseTotal
if (handle.end[-1] != '!') { 0 0 0
1375 0 return yaml_emitter_set_emitter_error(emitter,
1376 "tag handle must end with '!'");
1377 }
1378  
1379 0 handle.pointer ++;
1380  
1381 0 ▶ while (handle.pointer < handle.end-1) {
Branch: 1 branch
BranchTrueFalseTotal
while (handle.pointer < handle.end-1) { 0 0 0
1382 0 ▶ if (!IS_ALPHA(handle)) {
Branch: 8 branches
BranchTrueFalseTotal
if (!IS_ALPHA(handle)) { 0 0 0
if (!IS_ALPHA(handle)) { 0 0 0
if (!IS_ALPHA(handle)) { 0 0 0
if (!IS_ALPHA(handle)) { 0 0 0
if (!IS_ALPHA(handle)) { 0 0 0
if (!IS_ALPHA(handle)) { 0 0 0
if (!IS_ALPHA(handle)) { 0 0 0
if (!IS_ALPHA(handle)) { 0 0 0
1383 0 return yaml_emitter_set_emitter_error(emitter,
1384 "tag handle must contain alphanumerical characters only");
1385 }
1386 0 ▶ MOVE(handle);
Branch: 4 branches
BranchTrueFalseTotal
MOVE(handle); 0 0 0
MOVE(handle); 0 0 0
MOVE(handle); 0 0 0
MOVE(handle); 0 0 0
1387 }
1388  
1389 0 ▶ if (prefix.start == prefix.end) {
Branch: 1 branch
BranchTrueFalseTotal
if (prefix.start == prefix.end) { 0 0 0
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 ▶ if (string.start == string.end) {
Branch: 1 branch
BranchTrueFalseTotal
if (string.start == string.end) { 0 33 33
1412 0 ▶ return yaml_emitter_set_emitter_error(emitter, alias ?
Branch: 1 branch
BranchTrueFalseTotal
return yaml_emitter_set_emitter_error(emitter, alias ? 0 0 0
1413 "alias value must not be empty" :
1414 "anchor value must not be empty");
1415 }
1416  
1417 66 ▶ while (string.pointer != string.end) {
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) { 33 33 66
1418 33 ▶ if (!IS_ALPHA(string)) {
Branch: 8 branches
BranchTrueFalseTotal
if (!IS_ALPHA(string)) { 33 0 33
if (!IS_ALPHA(string)) { 0 33 33
if (!IS_ALPHA(string)) { 0 0 0
if (!IS_ALPHA(string)) { 0 0 0
if (!IS_ALPHA(string)) { 0 0 0
if (!IS_ALPHA(string)) { 0 0 0
if (!IS_ALPHA(string)) { 0 0 0
if (!IS_ALPHA(string)) { 0 0 0
1419 0 ▶ return yaml_emitter_set_emitter_error(emitter, alias ?
Branch: 1 branch
BranchTrueFalseTotal
return yaml_emitter_set_emitter_error(emitter, alias ? 0 0 0
1420 "alias value must contain alphanumerical characters only" :
1421 "anchor value must contain alphanumerical characters only");
1422 }
1423 33 ▶ MOVE(string);
Branch: 4 branches
BranchTrueFalseTotal
MOVE(string); 0 33 33
MOVE(string); 0 0 0
MOVE(string); 0 0 0
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 ▶ if (string.start == string.end) {
Branch: 1 branch
BranchTrueFalseTotal
if (string.start == string.end) { 0 43 43
1449 0 return yaml_emitter_set_emitter_error(emitter,
1450 "tag value must not be empty");
1451 }
1452  
1453 43 for (tag_directive = emitter->tag_directives.start;
1454 86 ▶ tag_directive != emitter->tag_directives.top; tag_directive ++) {
Branch: 1 branch
BranchTrueFalseTotal
tag_directive != emitter->tag_directives.top; tag_directive ++) { 86 0 86
1455 86 size_t prefix_length = strlen((char *)tag_directive->prefix);
1456 86 ▶ if (prefix_length < (size_t)(string.end - string.start)
Branch: 1 branch
BranchTrueFalseTotal
if (prefix_length < (size_t)(string.end - string.start) 86 0 86
1457 86 ▶ && strncmp((char *)tag_directive->prefix, (char *)string.start,
Branch: 1 branch
BranchTrueFalseTotal
&& strncmp((char *)tag_directive->prefix, (char *)string.start, 43 43 86
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 0 return 1;
1474 }
1475  
1476 /*
1477 * Check if a scalar is valid.
1478 */
1479  
1480 static int
1481 293 yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
1482 yaml_char_t *value, size_t length)
1483 {
1484 yaml_string_t string;
1485  
1486 293 int block_indicators = 0;
1487 293 int flow_indicators = 0;
1488 293 int line_breaks = 0;
1489 293 int special_characters = 0;
1490  
1491 293 int leading_space = 0;
1492 293 int leading_break = 0;
1493 293 int trailing_space = 0;
1494 293 int trailing_break = 0;
1495 293 int break_space = 0;
1496 293 int space_break = 0;
1497  
1498 293 int preceded_by_whitespace = 0;
1499 293 int followed_by_whitespace = 0;
1500 293 int previous_space = 0;
1501 293 int previous_break = 0;
1502  
1503 293 STRING_ASSIGN(string, value, length);
1504  
1505 293 emitter->scalar_data.value = value;
1506 293 emitter->scalar_data.length = length;
1507  
1508 293 ▶ if (string.start == string.end)
Branch: 1 branch
BranchTrueFalseTotal
if (string.start == string.end) 5 288 293
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 288 ▶ if ((CHECK_AT(string, '-', 0)
Branch: 1 branch
BranchTrueFalseTotal
if ((CHECK_AT(string, '-', 0) 0 288 288
1520 0 ▶ && CHECK_AT(string, '-', 1)
Branch: 1 branch
BranchTrueFalseTotal
&& CHECK_AT(string, '-', 1) 0 0 0
1521 0 ▶ && CHECK_AT(string, '-', 2))
Branch: 1 branch
BranchTrueFalseTotal
&& CHECK_AT(string, '-', 2)) 0 0 0
1522 288 ▶ || (CHECK_AT(string, '.', 0)
Branch: 1 branch
BranchTrueFalseTotal
|| (CHECK_AT(string, '.', 0) 0 288 288
1523 0 ▶ && CHECK_AT(string, '.', 1)
Branch: 1 branch
BranchTrueFalseTotal
&& CHECK_AT(string, '.', 1) 0 0 0
1524 0 ▶ && CHECK_AT(string, '.', 2))) {
Branch: 1 branch
BranchTrueFalseTotal
&& CHECK_AT(string, '.', 2))) { 0 0 0
1525 0 block_indicators = 1;
1526 0 flow_indicators = 1;
1527 }
1528  
1529 288 preceded_by_whitespace = 1;
1530 288 ▶ followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
Branch: 65 branches
BranchTrueFalseTotal
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 21 267 288
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 18 3 21
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 18 18
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 284 4 288
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 21 263 284
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 18 3 21
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 18 18
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 283 1 284
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 21 262 283
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 18 3 21
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 18 18
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 283 0 283
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 21 262 283
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 18 3 21
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 18 18
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 280 3 283
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 21 259 280
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 18 3 21
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 18 18
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 1 279 280
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 1 0 1
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 1 1
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 1 0 1
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 21 259 280
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 18 3 21
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 18 18
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 280 280
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 21 259 280
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 18 3 21
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 18 18
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 280 280
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 21 259 280
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 18 3 21
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 18 18
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 68 212 280
1531  
1532 1683 ▶ while (string.pointer != string.end)
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) 1395 288 1683
1533 {
1534 1395 ▶ if (string.start == string.pointer)
Branch: 1 branch
BranchTrueFalseTotal
if (string.start == string.pointer) 288 1107 1395
1535 {
1536 288 ▶ if (CHECK(string, '#') || CHECK(string, ',')
Branch: 2 branches
BranchTrueFalseTotal
if (CHECK(string, '#') || CHECK(string, ',') 288 0 288
if (CHECK(string, '#') || CHECK(string, ',') 288 0 288
1537 288 ▶ || CHECK(string, '[') || CHECK(string, ']')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '[') || CHECK(string, ']') 288 0 288
|| CHECK(string, '[') || CHECK(string, ']') 288 0 288
1538 288 ▶ || CHECK(string, '{') || CHECK(string, '}')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '{') || CHECK(string, '}') 283 5 288
|| CHECK(string, '{') || CHECK(string, '}') 283 0 283
1539 283 ▶ || CHECK(string, '&') || CHECK(string, '*')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '&') || CHECK(string, '*') 282 1 283
|| CHECK(string, '&') || CHECK(string, '*') 281 1 282
1540 281 ▶ || CHECK(string, '!') || CHECK(string, '|')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '!') || CHECK(string, '|') 281 0 281
|| CHECK(string, '!') || CHECK(string, '|') 280 1 281
1541 280 ▶ || CHECK(string, '>') || CHECK(string, '\'')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '>') || CHECK(string, '\'') 280 0 280
|| CHECK(string, '>') || CHECK(string, '\'') 280 0 280
1542 280 ▶ || CHECK(string, '"') || CHECK(string, '%')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '"') || CHECK(string, '%') 280 0 280
|| CHECK(string, '"') || CHECK(string, '%') 280 0 280
1543 280 ▶ || CHECK(string, '@') || CHECK(string, '`')) {
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '@') || CHECK(string, '`')) { 280 0 280
|| CHECK(string, '@') || CHECK(string, '`')) { 0 280 280
1544 8 flow_indicators = 1;
1545 8 block_indicators = 1;
1546 }
1547  
1548 288 ▶ if (CHECK(string, '?') || CHECK(string, ':')) {
Branch: 2 branches
BranchTrueFalseTotal
if (CHECK(string, '?') || CHECK(string, ':')) { 287 1 288
if (CHECK(string, '?') || CHECK(string, ':')) { 0 287 287
1549 1 flow_indicators = 1;
1550 1 ▶ if (followed_by_whitespace) {
Branch: 1 branch
BranchTrueFalseTotal
if (followed_by_whitespace) { 1 0 1
1551 1 block_indicators = 1;
1552 }
1553 }
1554  
1555 288 ▶ if (CHECK(string, '-') && followed_by_whitespace) {
Branch: 2 branches
BranchTrueFalseTotal
if (CHECK(string, '-') && followed_by_whitespace) { 0 288 288
if (CHECK(string, '-') && followed_by_whitespace) { 0 0 0
1556 0 flow_indicators = 1;
1557 0 block_indicators = 1;
1558 }
1559 }
1560 else
1561 {
1562 1107 ▶ if (CHECK(string, ',') || CHECK(string, '?')
Branch: 2 branches
BranchTrueFalseTotal
if (CHECK(string, ',') || CHECK(string, '?') 1107 0 1107
if (CHECK(string, ',') || CHECK(string, '?') 1101 6 1107
1563 1101 ▶ || CHECK(string, '[') || CHECK(string, ']')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '[') || CHECK(string, ']') 1101 0 1101
|| CHECK(string, '[') || CHECK(string, ']') 1101 0 1101
1564 1101 ▶ || CHECK(string, '{') || CHECK(string, '}')) {
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '{') || CHECK(string, '}')) { 1101 0 1101
|| CHECK(string, '{') || CHECK(string, '}')) { 5 1096 1101
1565 11 flow_indicators = 1;
1566 }
1567  
1568 1107 ▶ if (CHECK(string, ':')) {
Branch: 1 branch
BranchTrueFalseTotal
if (CHECK(string, ':')) { 11 1096 1107
1569 11 flow_indicators = 1;
1570 11 ▶ if (followed_by_whitespace) {
Branch: 1 branch
BranchTrueFalseTotal
if (followed_by_whitespace) { 1 10 11
1571 1 block_indicators = 1;
1572 }
1573 }
1574  
1575 1107 ▶ if (CHECK(string, '#') && preceded_by_whitespace) {
Branch: 2 branches
BranchTrueFalseTotal
if (CHECK(string, '#') && preceded_by_whitespace) { 0 1107 1107
if (CHECK(string, '#') && preceded_by_whitespace) { 0 0 0
1576 0 flow_indicators = 1;
1577 0 block_indicators = 1;
1578 }
1579 }
1580  
1581 1395 ▶ if (!IS_PRINTABLE(string)
Branch: 16 branches
BranchTrueFalseTotal
if (!IS_PRINTABLE(string) 1377 18 1395
if (!IS_PRINTABLE(string) 1369 8 1377
if (!IS_PRINTABLE(string) 73 1296 1369
if (!IS_PRINTABLE(string) 5 76 81
if (!IS_PRINTABLE(string) 4 1 5
if (!IS_PRINTABLE(string) 68 12 80
if (!IS_PRINTABLE(string) 0 68 68
if (!IS_PRINTABLE(string) 0 12 12
if (!IS_PRINTABLE(string) 0 0 0
if (!IS_PRINTABLE(string) 12 0 12
if (!IS_PRINTABLE(string) 0 12 12
if (!IS_PRINTABLE(string) 0 0 0
if (!IS_PRINTABLE(string) 0 0 0
if (!IS_PRINTABLE(string) 0 0 0
if (!IS_PRINTABLE(string) 0 0 0
if (!IS_PRINTABLE(string) 0 0 0
1582 1383 ▶ || (!IS_ASCII(string) && !emitter->unicode)) {
Branch: 2 branches
BranchTrueFalseTotal
|| (!IS_ASCII(string) && !emitter->unicode)) { 69 1314 1383
|| (!IS_ASCII(string) && !emitter->unicode)) { 0 69 69
1583 12 special_characters = 1;
1584 }
1585  
1586 1395 ▶ if (IS_BREAK(string)) {
Branch: 10 branches
BranchTrueFalseTotal
if (IS_BREAK(string)) { 1394 1 1395
if (IS_BREAK(string)) { 1376 18 1394
if (IS_BREAK(string)) { 5 1371 1376
if (IS_BREAK(string)) { 5 0 5
if (IS_BREAK(string)) { 0 1376 1376
if (IS_BREAK(string)) { 0 0 0
if (IS_BREAK(string)) { 0 0 0
if (IS_BREAK(string)) { 0 1376 1376
if (IS_BREAK(string)) { 0 0 0
if (IS_BREAK(string)) { 0 0 0
1587 19 line_breaks = 1;
1588 }
1589  
1590 1395 ▶ if (IS_SPACE(string))
Branch: 1 branch
BranchTrueFalseTotal
if (IS_SPACE(string)) 85 1310 1395
1591 {
1592 85 ▶ if (string.start == string.pointer) {
Branch: 1 branch
BranchTrueFalseTotal
if (string.start == string.pointer) { 0 85 85
1593 0 leading_space = 1;
1594 }
1595 85 ▶ if (string.pointer+WIDTH(string) == string.end) {
Branch: 5 branches
BranchTrueFalseTotal
if (string.pointer+WIDTH(string) == string.end) { 0 85 85
if (string.pointer+WIDTH(string) == string.end) { 0 0 0
if (string.pointer+WIDTH(string) == string.end) { 0 0 0
if (string.pointer+WIDTH(string) == string.end) { 0 0 0
if (string.pointer+WIDTH(string) == string.end) { 0 85 85
1596 0 trailing_space = 1;
1597 }
1598 85 ▶ if (previous_break) {
Branch: 1 branch
BranchTrueFalseTotal
if (previous_break) { 7 78 85
1599 7 break_space = 1;
1600 }
1601 85 previous_space = 1;
1602 85 previous_break = 0;
1603 }
1604 1310 ▶ else if (IS_BREAK(string))
Branch: 10 branches
BranchTrueFalseTotal
else if (IS_BREAK(string)) 1309 1 1310
else if (IS_BREAK(string)) 1291 18 1309
else if (IS_BREAK(string)) 5 1286 1291
else if (IS_BREAK(string)) 5 0 5
else if (IS_BREAK(string)) 0 1291 1291
else if (IS_BREAK(string)) 0 0 0
else if (IS_BREAK(string)) 0 0 0
else if (IS_BREAK(string)) 0 1291 1291
else if (IS_BREAK(string)) 0 0 0
else if (IS_BREAK(string)) 0 0 0
1605 {
1606 19 ▶ if (string.start == string.pointer) {
Branch: 1 branch
BranchTrueFalseTotal
if (string.start == string.pointer) { 0 19 19
1607 0 leading_break = 1;
1608 }
1609 19 ▶ if (string.pointer+WIDTH(string) == string.end) {
Branch: 5 branches
BranchTrueFalseTotal
if (string.pointer+WIDTH(string) == string.end) { 0 19 19
if (string.pointer+WIDTH(string) == string.end) { 0 0 0
if (string.pointer+WIDTH(string) == string.end) { 0 0 0
if (string.pointer+WIDTH(string) == string.end) { 0 0 0
if (string.pointer+WIDTH(string) == string.end) { 4 15 19
1610 4 trailing_break = 1;
1611 }
1612 19 ▶ if (previous_space) {
Branch: 1 branch
BranchTrueFalseTotal
if (previous_space) { 0 19 19
1613 0 space_break = 1;
1614 }
1615 19 previous_space = 0;
1616 19 previous_break = 1;
1617 }
1618 else
1619 {
1620 1291 previous_space = 0;
1621 1291 previous_break = 0;
1622 }
1623  
1624 1395 ▶ preceded_by_whitespace = IS_BLANKZ(string);
Branch: 13 branches
BranchTrueFalseTotal
preceded_by_whitespace = IS_BLANKZ(string); 1310 85 1395
preceded_by_whitespace = IS_BLANKZ(string); 1309 1 1310
preceded_by_whitespace = IS_BLANKZ(string); 1308 1 1309
preceded_by_whitespace = IS_BLANKZ(string); 1290 18 1308
preceded_by_whitespace = IS_BLANKZ(string); 5 1285 1290
preceded_by_whitespace = IS_BLANKZ(string); 5 0 5
preceded_by_whitespace = IS_BLANKZ(string); 0 1290 1290
preceded_by_whitespace = IS_BLANKZ(string); 0 0 0
preceded_by_whitespace = IS_BLANKZ(string); 0 0 0
preceded_by_whitespace = IS_BLANKZ(string); 0 1290 1290
preceded_by_whitespace = IS_BLANKZ(string); 0 0 0
preceded_by_whitespace = IS_BLANKZ(string); 0 0 0
preceded_by_whitespace = IS_BLANKZ(string); 5 1285 1290
1625 1395 ▶ MOVE(string);
Branch: 4 branches
BranchTrueFalseTotal
MOVE(string); 73 1322 1395
MOVE(string); 57 16 73
MOVE(string); 0 57 57
MOVE(string); 0 0 0
1626 1395 ▶ if (string.pointer != string.end) {
Branch: 1 branch
BranchTrueFalseTotal
if (string.pointer != string.end) { 1107 288 1395
1627 1107 ▶ followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
Branch: 65 branches
BranchTrueFalseTotal
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 52 1055 1107
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 39 13 52
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 39 39
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 1026 81 1107
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 50 976 1026
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 37 13 50
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 37 37
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 1026 0 1026
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 50 976 1026
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 37 13 50
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 37 37
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 1025 1 1026
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 50 975 1025
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 37 13 50
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 37 37
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 1010 15 1025
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 50 960 1010
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 37 13 50
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 37 37
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 4 1006 1010
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 4 4
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 4 0 4
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 50 960 1010
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 37 13 50
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 37 37
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 1010 1010
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 50 960 1010
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 37 13 50
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 37 37
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 1010 1010
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 50 960 1010
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 37 13 50
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 37 37
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 0 0 0
followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string)); 225 785 1010
1628 }
1629 }
1630  
1631 288 emitter->scalar_data.multiline = line_breaks;
1632  
1633 288 emitter->scalar_data.flow_plain_allowed = 1;
1634 288 emitter->scalar_data.block_plain_allowed = 1;
1635 288 emitter->scalar_data.single_quoted_allowed = 1;
1636 288 emitter->scalar_data.block_allowed = 1;
1637  
1638 288 ▶ if (leading_space || leading_break || trailing_space || trailing_break) {
Branch: 4 branches
BranchTrueFalseTotal
if (leading_space || leading_break || trailing_space || trailing_break) { 288 0 288
if (leading_space || leading_break || trailing_space || trailing_break) { 288 0 288
if (leading_space || leading_break || trailing_space || trailing_break) { 288 0 288
if (leading_space || leading_break || trailing_space || trailing_break) { 4 284 288
1639 4 emitter->scalar_data.flow_plain_allowed = 0;
1640 4 emitter->scalar_data.block_plain_allowed = 0;
1641 }
1642  
1643 288 ▶ if (trailing_space) {
Branch: 1 branch
BranchTrueFalseTotal
if (trailing_space) { 0 288 288
1644 0 emitter->scalar_data.block_allowed = 0;
1645 }
1646  
1647 288 ▶ if (break_space) {
Branch: 1 branch
BranchTrueFalseTotal
if (break_space) { 2 286 288
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 288 ▶ if (space_break || special_characters) {
Branch: 2 branches
BranchTrueFalseTotal
if (space_break || special_characters) { 288 0 288
if (space_break || special_characters) { 6 282 288
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 288 ▶ if (line_breaks) {
Branch: 1 branch
BranchTrueFalseTotal
if (line_breaks) { 6 282 288
1661 6 emitter->scalar_data.flow_plain_allowed = 0;
1662 6 emitter->scalar_data.block_plain_allowed = 0;
1663 }
1664  
1665 288 ▶ if (flow_indicators) {
Branch: 1 branch
BranchTrueFalseTotal
if (flow_indicators) { 17 271 288
1666 17 emitter->scalar_data.flow_plain_allowed = 0;
1667 }
1668  
1669 288 ▶ if (block_indicators) {
Branch: 1 branch
BranchTrueFalseTotal
if (block_indicators) { 10 278 288
1670 10 emitter->scalar_data.block_plain_allowed = 0;
1671 }
1672  
1673 288 return 1;
1674 }
1675  
1676 /*
1677 * Check if the event data is valid.
1678 */
1679  
1680 static int
1681 928 yaml_emitter_analyze_event(yaml_emitter_t *emitter,
1682 yaml_event_t *event)
1683 {
1684 928 emitter->anchor_data.anchor = NULL;
1685 928 emitter->anchor_data.anchor_length = 0;
1686 928 emitter->tag_data.handle = NULL;
1687 928 emitter->tag_data.handle_length = 0;
1688 928 emitter->tag_data.suffix = NULL;
1689 928 emitter->tag_data.suffix_length = 0;
1690 928 emitter->scalar_data.value = NULL;
1691 928 emitter->scalar_data.length = 0;
1692  
1693 928 switch (event->type)
1694 {
1695 17 case YAML_ALIAS_EVENT:
1696 17 ▶ if (!yaml_emitter_analyze_anchor(emitter,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_anchor(emitter, 0 17 17
1697 event->data.alias.anchor, 1))
1698 0 return 0;
1699 17 return 1;
1700  
1701 293 case YAML_SCALAR_EVENT:
1702 293 ▶ if (event->data.scalar.anchor) {
Branch: 1 branch
BranchTrueFalseTotal
if (event->data.scalar.anchor) { 0 293 293
1703 0 ▶ if (!yaml_emitter_analyze_anchor(emitter,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_anchor(emitter, 0 0 0
1704 event->data.scalar.anchor, 0))
1705 0 return 0;
1706 }
1707 293 ▶ if (event->data.scalar.tag && (emitter->canonical ||
Branch: 2 branches
BranchTrueFalseTotal
if (event->data.scalar.tag && (emitter->canonical || 274 19 293
if (event->data.scalar.tag && (emitter->canonical || 274 0 274
1708 274 ▶ (!event->data.scalar.plain_implicit
Branch: 1 branch
BranchTrueFalseTotal
(!event->data.scalar.plain_implicit 13 261 274
1709 13 ▶ && !event->data.scalar.quoted_implicit))) {
Branch: 1 branch
BranchTrueFalseTotal
&& !event->data.scalar.quoted_implicit))) { 13 0 13
1710 13 ▶ if (!yaml_emitter_analyze_tag(emitter, event->data.scalar.tag))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_tag(emitter, event->data.scalar.tag)) 0 13 13
1711 0 return 0;
1712 }
1713 293 ▶ if (!yaml_emitter_analyze_scalar(emitter,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_scalar(emitter, 0 293 293
1714 event->data.scalar.value, event->data.scalar.length))
1715 0 return 0;
1716 293 return 1;
1717  
1718 44 case YAML_SEQUENCE_START_EVENT:
1719 44 ▶ if (event->data.sequence_start.anchor) {
Branch: 1 branch
BranchTrueFalseTotal
if (event->data.sequence_start.anchor) { 6 38 44
1720 6 ▶ if (!yaml_emitter_analyze_anchor(emitter,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_anchor(emitter, 0 6 6
1721 event->data.sequence_start.anchor, 0))
1722 0 return 0;
1723 }
1724 44 ▶ if (event->data.sequence_start.tag && (emitter->canonical ||
Branch: 2 branches
BranchTrueFalseTotal
if (event->data.sequence_start.tag && (emitter->canonical || 3 41 44
if (event->data.sequence_start.tag && (emitter->canonical || 3 0 3
1725 3 ▶ !event->data.sequence_start.implicit)) {
Branch: 1 branch
BranchTrueFalseTotal
!event->data.sequence_start.implicit)) { 3 0 3
1726 3 ▶ if (!yaml_emitter_analyze_tag(emitter,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_tag(emitter, 0 3 3
1727 event->data.sequence_start.tag))
1728 0 return 0;
1729 }
1730 44 return 1;
1731  
1732 67 case YAML_MAPPING_START_EVENT:
1733 67 ▶ if (event->data.mapping_start.anchor) {
Branch: 1 branch
BranchTrueFalseTotal
if (event->data.mapping_start.anchor) { 10 57 67
1734 10 ▶ if (!yaml_emitter_analyze_anchor(emitter,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_anchor(emitter, 0 10 10
1735 event->data.mapping_start.anchor, 0))
1736 0 return 0;
1737 }
1738 67 ▶ if (event->data.mapping_start.tag && (emitter->canonical ||
Branch: 2 branches
BranchTrueFalseTotal
if (event->data.mapping_start.tag && (emitter->canonical || 27 40 67
if (event->data.mapping_start.tag && (emitter->canonical || 27 0 27
1739 27 ▶ !event->data.mapping_start.implicit)) {
Branch: 1 branch
BranchTrueFalseTotal
!event->data.mapping_start.implicit)) { 27 0 27
1740 27 ▶ if (!yaml_emitter_analyze_tag(emitter,
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_analyze_tag(emitter, 0 27 27
1741 event->data.mapping_start.tag))
1742 0 return 0;
1743 }
1744 67 return 1;
1745  
1746 507 default:
1747 507 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 ▶ if (!FLUSH(emitter))
Branch: 2 branches
BranchTrueFalseTotal
if (!FLUSH(emitter)) 0 0 0
if (!FLUSH(emitter)) 0 0 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 435 yaml_emitter_write_indent(yaml_emitter_t *emitter)
1770 {
1771 435 int indent = (emitter->indent >= 0) ? emitter->indent : 0;
1772  
1773 435 ▶ if (!emitter->indention || emitter->column > indent
Branch: 2 branches
BranchTrueFalseTotal
if (!emitter->indention || emitter->column > indent 132 303 435
if (!emitter->indention || emitter->column > indent 132 0 132
1774 132 ▶ || (emitter->column == indent && !emitter->whitespace)) {
Branch: 2 branches
BranchTrueFalseTotal
|| (emitter->column == indent && !emitter->whitespace)) { 111 21 132
|| (emitter->column == indent && !emitter->whitespace)) { 0 111 111
1775 303 ▶ if (!PUT_BREAK(emitter))
Branch: 5 branches
BranchTrueFalseTotal
if (!PUT_BREAK(emitter)) 0 303 303
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 303 303
if (!PUT_BREAK(emitter)) 303 0 303
if (!PUT_BREAK(emitter)) 0 0 0
1776 0 return 0;
1777 }
1778  
1779 592 ▶ while (emitter->column < indent) {
Branch: 1 branch
BranchTrueFalseTotal
while (emitter->column < indent) { 157 435 592
1780 157 ▶ if (!PUT(emitter, ' '))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, ' ')) 0 157 157
if (!PUT(emitter, ' ')) 0 0 0
1781 0 return 0;
1782 }
1783  
1784 435 emitter->whitespace = 1;
1785 435 emitter->indention = 1;
1786  
1787 435 return 1;
1788 }
1789  
1790 static int
1791 459 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 459 indicator_length = strlen(indicator);
1799 459 STRING_ASSIGN(string, (yaml_char_t *)indicator, indicator_length);
1800  
1801 459 ▶ if (need_whitespace && !emitter->whitespace) {
Branch: 2 branches
BranchTrueFalseTotal
if (need_whitespace && !emitter->whitespace) { 292 167 459
if (need_whitespace && !emitter->whitespace) { 91 201 292
1802 91 ▶ if (!PUT(emitter, ' '))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, ' ')) 0 91 91
if (!PUT(emitter, ' ')) 0 0 0
1803 0 return 0;
1804 }
1805  
1806 1138 ▶ while (string.pointer != string.end) {
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) { 679 459 1138
1807 679 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 679 679
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 679 0 679
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
1808 0 return 0;
1809 }
1810  
1811 459 emitter->whitespace = is_whitespace;
1812 459 ▶ emitter->indention = (emitter->indention && is_indention);
Branch: 2 branches
BranchTrueFalseTotal
emitter->indention = (emitter->indention && is_indention); 233 226 459
emitter->indention = (emitter->indention && is_indention); 91 142 233
1813 459 emitter->open_ended = 0;
1814  
1815 459 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 ▶ while (string.pointer != string.end) {
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) { 33 33 66
1826 33 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 33 33
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 33 0 33
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 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 ▶ if (!emitter->whitespace) {
Branch: 1 branch
BranchTrueFalseTotal
if (!emitter->whitespace) { 43 0 43
1844 43 ▶ if (!PUT(emitter, ' '))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, ' ')) 0 43 43
if (!PUT(emitter, ' ')) 0 0 0
1845 0 return 0;
1846 }
1847  
1848 129 ▶ while (string.pointer != string.end) {
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) { 86 43 129
1849 86 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 86 86
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 86 0 86
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 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 ▶ if (need_whitespace && !emitter->whitespace) {
Branch: 2 branches
BranchTrueFalseTotal
if (need_whitespace && !emitter->whitespace) { 0 43 43
if (need_whitespace && !emitter->whitespace) { 0 0 0
1868 0 ▶ if (!PUT(emitter, ' '))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, ' ')) 0 0 0
if (!PUT(emitter, ' ')) 0 0 0
1869 0 return 0;
1870 }
1871  
1872 573 ▶ while (string.pointer != string.end) {
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) { 530 43 573
1873 530 ▶ if (IS_ALPHA(string)
Branch: 8 branches
BranchTrueFalseTotal
if (IS_ALPHA(string) 487 43 530
if (IS_ALPHA(string) 487 0 487
if (IS_ALPHA(string) 453 77 530
if (IS_ALPHA(string) 426 27 453
if (IS_ALPHA(string) 426 77 503
if (IS_ALPHA(string) 0 426 426
if (IS_ALPHA(string) 77 0 77
if (IS_ALPHA(string) 77 0 77
1874 77 ▶ || CHECK(string, ';') || CHECK(string, '/')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, ';') || CHECK(string, '/') 77 0 77
|| CHECK(string, ';') || CHECK(string, '/') 34 43 77
1875 34 ▶ || CHECK(string, '?') || CHECK(string, ':')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '?') || CHECK(string, ':') 34 0 34
|| CHECK(string, '?') || CHECK(string, ':') 0 34 34
1876 0 ▶ || CHECK(string, '@') || CHECK(string, '&')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '@') || CHECK(string, '&') 0 0 0
|| CHECK(string, '@') || CHECK(string, '&') 0 0 0
1877 0 ▶ || CHECK(string, '=') || CHECK(string, '+')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '=') || CHECK(string, '+') 0 0 0
|| CHECK(string, '=') || CHECK(string, '+') 0 0 0
1878 0 ▶ || CHECK(string, '$') || CHECK(string, ',')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '$') || CHECK(string, ',') 0 0 0
|| CHECK(string, '$') || CHECK(string, ',') 0 0 0
1879 0 ▶ || CHECK(string, '_') || CHECK(string, '.')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '_') || CHECK(string, '.') 0 0 0
|| CHECK(string, '_') || CHECK(string, '.') 0 0 0
1880 0 ▶ || CHECK(string, '~') || CHECK(string, '*')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '~') || CHECK(string, '*') 0 0 0
|| CHECK(string, '~') || CHECK(string, '*') 0 0 0
1881 0 ▶ || CHECK(string, '\'') || CHECK(string, '(')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '\'') || CHECK(string, '(') 0 0 0
|| CHECK(string, '\'') || CHECK(string, '(') 0 0 0
1882 0 ▶ || CHECK(string, ')') || CHECK(string, '[')
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, ')') || CHECK(string, '[') 0 0 0
|| CHECK(string, ')') || CHECK(string, '[') 0 0 0
1883 0 ▶ || CHECK(string, ']')) {
Branch: 1 branch
BranchTrueFalseTotal
|| CHECK(string, ']')) { 0 0 0
1884 530 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 530 530
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 530 0 530
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
1885 0 return 0;
1886 }
1887 else {
1888 0 ▶ int width = WIDTH(string);
Branch: 4 branches
BranchTrueFalseTotal
int width = WIDTH(string); 0 0 0
int width = WIDTH(string); 0 0 0
int width = WIDTH(string); 0 0 0
int width = WIDTH(string); 0 0 0
1889 unsigned int v;
1890 0 ▶ while (width --) {
Branch: 1 branch
BranchTrueFalseTotal
while (width --) { 0 0 0
1891 0 v = *(string.pointer++);
1892 0 ▶ if (!PUT(emitter, '%'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, '%')) 0 0 0
if (!PUT(emitter, '%')) 0 0 0
1893 0 return 0;
1894 0 ▶ if (!PUT(emitter, (v >> 4)
Branch: 3 branches
BranchTrueFalseTotal
if (!PUT(emitter, (v >> 4) 0 0 0
if (!PUT(emitter, (v >> 4) 0 0 0
if (!PUT(emitter, (v >> 4) 0 0 0
1895 + ((v >> 4) < 10 ? '0' : 'A' - 10)))
1896 0 return 0;
1897 0 ▶ if (!PUT(emitter, (v & 0x0F)
Branch: 3 branches
BranchTrueFalseTotal
if (!PUT(emitter, (v & 0x0F) 0 0 0
if (!PUT(emitter, (v & 0x0F) 0 0 0
if (!PUT(emitter, (v & 0x0F) 0 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 254 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 254 int spaces = 0;
1916 254 int breaks = 0;
1917  
1918 254 STRING_ASSIGN(string, value, length);
1919  
1920 254 ▶ if (!emitter->whitespace) {
Branch: 1 branch
BranchTrueFalseTotal
if (!emitter->whitespace) { 144 110 254
1921 144 ▶ if (!PUT(emitter, ' '))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, ' ')) 0 144 144
if (!PUT(emitter, ' ')) 0 0 0
1922 0 return 0;
1923 }
1924  
1925 1309 ▶ while (string.pointer != string.end)
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) 1055 254 1309
1926 {
1927 1055 ▶ if (IS_SPACE(string)) {
Branch: 1 branch
BranchTrueFalseTotal
if (IS_SPACE(string)) { 42 1013 1055
1928 42 ▶ if (allow_breaks && !spaces
Branch: 2 branches
BranchTrueFalseTotal
if (allow_breaks && !spaces 41 1 42
if (allow_breaks && !spaces 41 0 41
1929 41 ▶ && emitter->column > emitter->best_width
Branch: 1 branch
BranchTrueFalseTotal
&& emitter->column > emitter->best_width 0 41 41
1930 0 ▶ && !IS_SPACE_AT(string, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
&& !IS_SPACE_AT(string, 1)) { 0 0 0
1931 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
1932 0 return 0;
1933 0 ▶ MOVE(string);
Branch: 4 branches
BranchTrueFalseTotal
MOVE(string); 0 0 0
MOVE(string); 0 0 0
MOVE(string); 0 0 0
MOVE(string); 0 0 0
1934 }
1935 else {
1936 42 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 42 42
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 42 0 42
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
1937 0 return 0;
1938 }
1939 42 spaces = 1;
1940 }
1941 1013 ▶ else if (IS_BREAK(string)) {
Branch: 10 branches
BranchTrueFalseTotal
else if (IS_BREAK(string)) { 1013 0 1013
else if (IS_BREAK(string)) { 1013 0 1013
else if (IS_BREAK(string)) { 1 1012 1013
else if (IS_BREAK(string)) { 1 0 1
else if (IS_BREAK(string)) { 0 1013 1013
else if (IS_BREAK(string)) { 0 0 0
else if (IS_BREAK(string)) { 0 0 0
else if (IS_BREAK(string)) { 0 1013 1013
else if (IS_BREAK(string)) { 0 0 0
else if (IS_BREAK(string)) { 0 0 0
1942 0 ▶ if (!breaks && CHECK(string, '\n')) {
Branch: 2 branches
BranchTrueFalseTotal
if (!breaks && CHECK(string, '\n')) { 0 0 0
if (!breaks && CHECK(string, '\n')) { 0 0 0
1943 0 ▶ if (!PUT_BREAK(emitter))
Branch: 5 branches
BranchTrueFalseTotal
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
1944 0 return 0;
1945 }
1946 0 ▶ if (!WRITE_BREAK(emitter, string))
Branch: 10 branches
BranchTrueFalseTotal
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
1947 0 return 0;
1948 0 emitter->indention = 1;
1949 0 breaks = 1;
1950 }
1951 else {
1952 1013 ▶ if (breaks) {
Branch: 1 branch
BranchTrueFalseTotal
if (breaks) { 0 1013 1013
1953 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
1954 0 return 0;
1955 }
1956 1013 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 1013 1013
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 944 69 1013
if (!WRITE(emitter, string)) 12 57 69
if (!WRITE(emitter, string)) 57 0 57
if (!WRITE(emitter, string)) 0 0 0
1957 0 return 0;
1958 1013 emitter->indention = 0;
1959 1013 spaces = 0;
1960 1013 breaks = 0;
1961 }
1962 }
1963  
1964 254 emitter->whitespace = 0;
1965 254 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 254 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 ▶ if (!yaml_emitter_write_indicator(emitter, "'", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "'", 1, 0, 0)) 0 28 28
1990 0 return 0;
1991  
1992 137 ▶ while (string.pointer != string.end)
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) 109 28 137
1993 {
1994 109 ▶ if (IS_SPACE(string)) {
Branch: 1 branch
BranchTrueFalseTotal
if (IS_SPACE(string)) { 8 101 109
1995 8 ▶ if (allow_breaks && !spaces
Branch: 2 branches
BranchTrueFalseTotal
if (allow_breaks && !spaces 8 0 8
if (allow_breaks && !spaces 8 0 8
1996 8 ▶ && emitter->column > emitter->best_width
Branch: 1 branch
BranchTrueFalseTotal
&& emitter->column > emitter->best_width 0 8 8
1997 0 ▶ && string.pointer != string.start
Branch: 1 branch
BranchTrueFalseTotal
&& string.pointer != string.start 0 0 0
1998 0 ▶ && string.pointer != string.end - 1
Branch: 1 branch
BranchTrueFalseTotal
&& string.pointer != string.end - 1 0 0 0
1999 0 ▶ && !IS_SPACE_AT(string, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
&& !IS_SPACE_AT(string, 1)) { 0 0 0
2000 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
2001 0 return 0;
2002 0 ▶ MOVE(string);
Branch: 4 branches
BranchTrueFalseTotal
MOVE(string); 0 0 0
MOVE(string); 0 0 0
MOVE(string); 0 0 0
MOVE(string); 0 0 0
2003 }
2004 else {
2005 8 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 8 8
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 8 0 8
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
2006 0 return 0;
2007 }
2008 8 spaces = 1;
2009 }
2010 101 ▶ else if (IS_BREAK(string)) {
Branch: 10 branches
BranchTrueFalseTotal
else if (IS_BREAK(string)) { 101 0 101
else if (IS_BREAK(string)) { 101 0 101
else if (IS_BREAK(string)) { 0 101 101
else if (IS_BREAK(string)) { 0 0 0
else if (IS_BREAK(string)) { 0 101 101
else if (IS_BREAK(string)) { 0 0 0
else if (IS_BREAK(string)) { 0 0 0
else if (IS_BREAK(string)) { 0 101 101
else if (IS_BREAK(string)) { 0 0 0
else if (IS_BREAK(string)) { 0 0 0
2011 0 ▶ if (!breaks && CHECK(string, '\n')) {
Branch: 2 branches
BranchTrueFalseTotal
if (!breaks && CHECK(string, '\n')) { 0 0 0
if (!breaks && CHECK(string, '\n')) { 0 0 0
2012 0 ▶ if (!PUT_BREAK(emitter))
Branch: 5 branches
BranchTrueFalseTotal
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
2013 0 return 0;
2014 }
2015 0 ▶ if (!WRITE_BREAK(emitter, string))
Branch: 10 branches
BranchTrueFalseTotal
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
2016 0 return 0;
2017 0 emitter->indention = 1;
2018 0 breaks = 1;
2019 }
2020 else
2021 {
2022 101 ▶ if (breaks) {
Branch: 1 branch
BranchTrueFalseTotal
if (breaks) { 0 101 101
2023 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
2024 0 return 0;
2025 }
2026 101 ▶ if (CHECK(string, '\'')) {
Branch: 1 branch
BranchTrueFalseTotal
if (CHECK(string, '\'')) { 0 101 101
2027 0 ▶ if (!PUT(emitter, '\''))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, '\'')) 0 0 0
if (!PUT(emitter, '\'')) 0 0 0
2028 0 return 0;
2029 }
2030 101 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 101 101
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 101 0 101
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 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 ▶ if (breaks)
Branch: 1 branch
BranchTrueFalseTotal
if (breaks) 0 28 28
2039 0 ▶ if (!yaml_emitter_write_indent(emitter)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) return 0; 0 0 0
2040  
2041 28 ▶ if (!yaml_emitter_write_indicator(emitter, "'", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "'", 0, 0, 0)) 0 28 28
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 ▶ if (!yaml_emitter_write_indicator(emitter, "\"", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "\"", 1, 0, 0)) 0 8 8
2060 0 return 0;
2061  
2062 70 ▶ while (string.pointer != string.end)
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) 62 8 70
2063 {
2064 62 ▶ if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string))
Branch: 18 branches
BranchTrueFalseTotal
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 56 6 62
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 48 8 56
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 4 44 48
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 4 8 12
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 4 0 4
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 12 12
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 0 0
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 12 12
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 0 0
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 12 0 12
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 12 12
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 0 0
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 0 0
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 0 0
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 0 0
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 0 0
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 50 50
if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string)) 0 0 0
2065 50 ▶ || IS_BOM(string) || IS_BREAK(string)
Branch: 13 branches
BranchTrueFalseTotal
|| IS_BOM(string) || IS_BREAK(string) 0 50 50
|| IS_BOM(string) || IS_BREAK(string) 0 0 0
|| IS_BOM(string) || IS_BREAK(string) 0 0 0
|| IS_BOM(string) || IS_BREAK(string) 50 0 50
|| IS_BOM(string) || IS_BREAK(string) 44 6 50
|| IS_BOM(string) || IS_BREAK(string) 0 44 44
|| IS_BOM(string) || IS_BREAK(string) 0 0 0
|| IS_BOM(string) || IS_BREAK(string) 0 44 44
|| IS_BOM(string) || IS_BREAK(string) 0 0 0
|| IS_BOM(string) || IS_BREAK(string) 0 0 0
|| IS_BOM(string) || IS_BREAK(string) 0 44 44
|| IS_BOM(string) || IS_BREAK(string) 0 0 0
|| IS_BOM(string) || IS_BREAK(string) 0 0 0
2066 44 ▶ || CHECK(string, '"') || CHECK(string, '\\'))
Branch: 2 branches
BranchTrueFalseTotal
|| CHECK(string, '"') || CHECK(string, '\\')) 44 0 44
|| CHECK(string, '"') || CHECK(string, '\\')) 0 44 44
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 22 ▶ width = (octet & 0x80) == 0x00 ? 1 :
Branch: 1 branch
BranchTrueFalseTotal
width = (octet & 0x80) == 0x00 ? 1 : 4 14 18
2075 4 ▶ (octet & 0xE0) == 0xC0 ? 2 :
Branch: 1 branch
BranchTrueFalseTotal
(octet & 0xE0) == 0xC0 ? 2 : 0 4 4
2076 0 ▶ (octet & 0xF0) == 0xE0 ? 3 :
Branch: 1 branch
BranchTrueFalseTotal
(octet & 0xF0) == 0xE0 ? 3 : 0 0 0
2077 0 ▶ (octet & 0xF8) == 0xF0 ? 4 : 0;
Branch: 1 branch
BranchTrueFalseTotal
(octet & 0xF8) == 0xF0 ? 4 : 0; 0 0 0
2078 22 ▶ v = (octet & 0x80) == 0x00 ? octet & 0x7F :
Branch: 1 branch
BranchTrueFalseTotal
v = (octet & 0x80) == 0x00 ? octet & 0x7F : 14 4 18
2079 4 ▶ (octet & 0xE0) == 0xC0 ? octet & 0x1F :
Branch: 1 branch
BranchTrueFalseTotal
(octet & 0xE0) == 0xC0 ? octet & 0x1F : 4 0 4
2080 0 ▶ (octet & 0xF0) == 0xE0 ? octet & 0x0F :
Branch: 1 branch
BranchTrueFalseTotal
(octet & 0xF0) == 0xE0 ? octet & 0x0F : 0 0 0
2081 0 ▶ (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
Branch: 1 branch
BranchTrueFalseTotal
(octet & 0xF8) == 0xF0 ? octet & 0x07 : 0; 0 0 0
2082 22 ▶ for (k = 1; k < (int)width; k ++) {
Branch: 1 branch
BranchTrueFalseTotal
for (k = 1; k < (int)width; k ++) { 4 18 22
2083 4 octet = string.pointer[k];
2084 4 v = (v << 6) + (octet & 0x3F);
2085 }
2086 18 string.pointer += width;
2087  
2088 18 ▶ if (!PUT(emitter, '\\'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, '\\')) 0 18 18
if (!PUT(emitter, '\\')) 0 0 0
2089 0 return 0;
2090  
2091 18 switch (v)
2092 {
2093 5 case 0x00:
2094 5 ▶ if (!PUT(emitter, '0'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, '0')) 0 5 5
if (!PUT(emitter, '0')) 0 0 0
2095 0 return 0;
2096 5 break;
2097  
2098 1 case 0x07:
2099 1 ▶ if (!PUT(emitter, 'a'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'a')) 0 1 1
if (!PUT(emitter, 'a')) 0 0 0
2100 0 return 0;
2101 1 break;
2102  
2103 0 case 0x08:
2104 0 ▶ if (!PUT(emitter, 'b'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'b')) 0 0 0
if (!PUT(emitter, 'b')) 0 0 0
2105 0 return 0;
2106 0 break;
2107  
2108 1 case 0x09:
2109 1 ▶ if (!PUT(emitter, 't'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 't')) 0 1 1
if (!PUT(emitter, 't')) 0 0 0
2110 0 return 0;
2111 1 break;
2112  
2113 6 case 0x0A:
2114 6 ▶ if (!PUT(emitter, 'n'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'n')) 0 6 6
if (!PUT(emitter, 'n')) 0 0 0
2115 0 return 0;
2116 6 break;
2117  
2118 0 case 0x0B:
2119 0 ▶ if (!PUT(emitter, 'v'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'v')) 0 0 0
if (!PUT(emitter, 'v')) 0 0 0
2120 0 return 0;
2121 0 break;
2122  
2123 0 case 0x0C:
2124 0 ▶ if (!PUT(emitter, 'f'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'f')) 0 0 0
if (!PUT(emitter, 'f')) 0 0 0
2125 0 return 0;
2126 0 break;
2127  
2128 1 case 0x0D:
2129 1 ▶ if (!PUT(emitter, 'r'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'r')) 0 1 1
if (!PUT(emitter, 'r')) 0 0 0
2130 0 return 0;
2131 1 break;
2132  
2133 0 case 0x1B:
2134 0 ▶ if (!PUT(emitter, 'e'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'e')) 0 0 0
if (!PUT(emitter, 'e')) 0 0 0
2135 0 return 0;
2136 0 break;
2137  
2138 0 case 0x22:
2139 0 ▶ if (!PUT(emitter, '\"'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, '\"')) 0 0 0
if (!PUT(emitter, '\"')) 0 0 0
2140 0 return 0;
2141 0 break;
2142  
2143 0 case 0x5C:
2144 0 ▶ if (!PUT(emitter, '\\'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, '\\')) 0 0 0
if (!PUT(emitter, '\\')) 0 0 0
2145 0 return 0;
2146 0 break;
2147  
2148 0 case 0x85:
2149 0 ▶ if (!PUT(emitter, 'N'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'N')) 0 0 0
if (!PUT(emitter, 'N')) 0 0 0
2150 0 return 0;
2151 0 break;
2152  
2153 0 case 0xA0:
2154 0 ▶ if (!PUT(emitter, '_'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, '_')) 0 0 0
if (!PUT(emitter, '_')) 0 0 0
2155 0 return 0;
2156 0 break;
2157  
2158 0 case 0x2028:
2159 0 ▶ if (!PUT(emitter, 'L'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'L')) 0 0 0
if (!PUT(emitter, 'L')) 0 0 0
2160 0 return 0;
2161 0 break;
2162  
2163 0 case 0x2029:
2164 0 ▶ if (!PUT(emitter, 'P'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'P')) 0 0 0
if (!PUT(emitter, 'P')) 0 0 0
2165 0 return 0;
2166 0 break;
2167  
2168 4 default:
2169 4 ▶ if (v <= 0xFF) {
Branch: 1 branch
BranchTrueFalseTotal
if (v <= 0xFF) { 4 0 4
2170 4 ▶ if (!PUT(emitter, 'x'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'x')) 0 4 4
if (!PUT(emitter, 'x')) 0 0 0
2171 0 return 0;
2172 4 width = 2;
2173 }
2174 0 ▶ else if (v <= 0xFFFF) {
Branch: 1 branch
BranchTrueFalseTotal
else if (v <= 0xFFFF) { 0 0 0
2175 0 ▶ if (!PUT(emitter, 'u'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'u')) 0 0 0
if (!PUT(emitter, 'u')) 0 0 0
2176 0 return 0;
2177 0 width = 4;
2178 }
2179 else {
2180 0 ▶ if (!PUT(emitter, 'U'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, 'U')) 0 0 0
if (!PUT(emitter, 'U')) 0 0 0
2181 0 return 0;
2182 0 width = 8;
2183 }
2184 12 ▶ for (k = (width-1)*4; k >= 0; k -= 4) {
Branch: 1 branch
BranchTrueFalseTotal
for (k = (width-1)*4; k >= 0; k -= 4) { 8 4 12
2185 8 int digit = (v >> k) & 0x0F;
2186 8 ▶ if (!PUT(emitter, digit + (digit < 10 ? '0' : 'A'-10)))
Branch: 3 branches
BranchTrueFalseTotal
if (!PUT(emitter, digit + (digit < 10 ? '0' : 'A'-10))) 0 8 8
if (!PUT(emitter, digit + (digit < 10 ? '0' : 'A'-10))) 0 0 0
if (!PUT(emitter, digit + (digit < 10 ? '0' : 'A'-10))) 8 0 8
2187 0 return 0;
2188 }
2189 }
2190 18 spaces = 0;
2191 }
2192 44 ▶ else if (IS_SPACE(string)) {
Branch: 1 branch
BranchTrueFalseTotal
else if (IS_SPACE(string)) { 0 44 44
2193 0 ▶ if (allow_breaks && !spaces
Branch: 2 branches
BranchTrueFalseTotal
if (allow_breaks && !spaces 0 0 0
if (allow_breaks && !spaces 0 0 0
2194 0 ▶ && emitter->column > emitter->best_width
Branch: 1 branch
BranchTrueFalseTotal
&& emitter->column > emitter->best_width 0 0 0
2195 0 ▶ && string.pointer != string.start
Branch: 1 branch
BranchTrueFalseTotal
&& string.pointer != string.start 0 0 0
2196 0 ▶ && string.pointer != string.end - 1) {
Branch: 1 branch
BranchTrueFalseTotal
&& string.pointer != string.end - 1) { 0 0 0
2197 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
2198 0 return 0;
2199 0 ▶ if (IS_SPACE_AT(string, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (IS_SPACE_AT(string, 1)) { 0 0 0
2200 0 ▶ if (!PUT(emitter, '\\'))
Branch: 2 branches
BranchTrueFalseTotal
if (!PUT(emitter, '\\')) 0 0 0
if (!PUT(emitter, '\\')) 0 0 0
2201 0 return 0;
2202 }
2203 0 ▶ MOVE(string);
Branch: 4 branches
BranchTrueFalseTotal
MOVE(string); 0 0 0
MOVE(string); 0 0 0
MOVE(string); 0 0 0
MOVE(string); 0 0 0
2204 }
2205 else {
2206 0 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
2207 0 return 0;
2208 }
2209 0 spaces = 1;
2210 }
2211 else {
2212 44 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 44 44
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 44 0 44
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
2213 0 return 0;
2214 44 spaces = 0;
2215 }
2216 }
2217  
2218 8 ▶ if (!yaml_emitter_write_indicator(emitter, "\"", 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "\"", 0, 0, 0)) 0 8 8
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 ▶ if (IS_SPACE(string) || IS_BREAK(string)) {
Branch: 11 branches
BranchTrueFalseTotal
if (IS_SPACE(string) || IS_BREAK(string)) { 3 0 3
if (IS_SPACE(string) || IS_BREAK(string)) { 3 0 3
if (IS_SPACE(string) || IS_BREAK(string)) { 3 0 3
if (IS_SPACE(string) || IS_BREAK(string)) { 0 3 3
if (IS_SPACE(string) || IS_BREAK(string)) { 0 0 0
if (IS_SPACE(string) || IS_BREAK(string)) { 0 3 3
if (IS_SPACE(string) || IS_BREAK(string)) { 0 0 0
if (IS_SPACE(string) || IS_BREAK(string)) { 0 0 0
if (IS_SPACE(string) || IS_BREAK(string)) { 0 3 3
if (IS_SPACE(string) || IS_BREAK(string)) { 0 0 0
if (IS_SPACE(string) || IS_BREAK(string)) { 0 0 0
2235 0 indent_hint[0] = '0' + (char)emitter->best_indent;
2236 0 indent_hint[1] = '\0';
2237 0 ▶ if (!yaml_emitter_write_indicator(emitter, indent_hint, 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, indent_hint, 0, 0, 0)) 0 0 0
2238 0 return 0;
2239 }
2240  
2241 3 emitter->open_ended = 0;
2242  
2243 3 string.pointer = string.end;
2244 3 ▶ if (string.start == string.pointer) {
Branch: 1 branch
BranchTrueFalseTotal
if (string.start == string.pointer) { 0 3 3
2245 0 chomp_hint = "-";
2246 }
2247 else {
2248 do {
2249 3 string.pointer --;
2250 3 ▶ } while ((*string.pointer & 0xC0) == 0x80);
Branch: 1 branch
BranchTrueFalseTotal
} while ((*string.pointer & 0xC0) == 0x80); 0 3 3
2251 3 ▶ if (!IS_BREAK(string)) {
Branch: 10 branches
BranchTrueFalseTotal
if (!IS_BREAK(string)) { 3 0 3
if (!IS_BREAK(string)) { 2 1 3
if (!IS_BREAK(string)) { 0 2 2
if (!IS_BREAK(string)) { 0 0 0
if (!IS_BREAK(string)) { 0 2 2
if (!IS_BREAK(string)) { 0 0 0
if (!IS_BREAK(string)) { 0 0 0
if (!IS_BREAK(string)) { 0 2 2
if (!IS_BREAK(string)) { 0 0 0
if (!IS_BREAK(string)) { 0 0 0
2252 2 chomp_hint = "-";
2253 }
2254 1 ▶ else if (string.start == string.pointer) {
Branch: 1 branch
BranchTrueFalseTotal
else if (string.start == string.pointer) { 0 1 1
2255 0 chomp_hint = "+";
2256 0 emitter->open_ended = 1;
2257 }
2258 else {
2259 do {
2260 1 string.pointer --;
2261 1 ▶ } while ((*string.pointer & 0xC0) == 0x80);
Branch: 1 branch
BranchTrueFalseTotal
} while ((*string.pointer & 0xC0) == 0x80); 0 1 1
2262 1 ▶ if (IS_BREAK(string)) {
Branch: 10 branches
BranchTrueFalseTotal
if (IS_BREAK(string)) { 1 0 1
if (IS_BREAK(string)) { 1 0 1
if (IS_BREAK(string)) { 0 1 1
if (IS_BREAK(string)) { 0 0 0
if (IS_BREAK(string)) { 0 1 1
if (IS_BREAK(string)) { 0 0 0
if (IS_BREAK(string)) { 0 0 0
if (IS_BREAK(string)) { 0 1 1
if (IS_BREAK(string)) { 0 0 0
if (IS_BREAK(string)) { 0 0 0
2263 0 chomp_hint = "+";
2264 0 emitter->open_ended = 1;
2265 }
2266 }
2267 }
2268  
2269 3 ▶ if (chomp_hint) {
Branch: 1 branch
BranchTrueFalseTotal
if (chomp_hint) { 2 1 3
2270 2 ▶ if (!yaml_emitter_write_indicator(emitter, chomp_hint, 0, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, chomp_hint, 0, 0, 0)) 0 2 2
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 ▶ if (!yaml_emitter_write_indicator(emitter, "|", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, "|", 1, 0, 0)) 0 3 3
2287 0 return 0;
2288 3 ▶ if (!yaml_emitter_write_block_scalar_hints(emitter, string))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_block_scalar_hints(emitter, string)) 0 3 3
2289 0 return 0;
2290 3 ▶ if (!PUT_BREAK(emitter))
Branch: 5 branches
BranchTrueFalseTotal
if (!PUT_BREAK(emitter)) 0 3 3
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 3 3
if (!PUT_BREAK(emitter)) 3 0 3
if (!PUT_BREAK(emitter)) 0 0 0
2291 0 return 0;
2292 3 emitter->indention = 1;
2293 3 emitter->whitespace = 1;
2294  
2295 172 ▶ while (string.pointer != string.end)
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) 169 3 172
2296 {
2297 169 ▶ if (IS_BREAK(string))
Branch: 10 branches
BranchTrueFalseTotal
if (IS_BREAK(string)) 169 0 169
if (IS_BREAK(string)) 157 12 169
if (IS_BREAK(string)) 0 157 157
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 157 157
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 157 157
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
2298 {
2299 12 ▶ if (!WRITE_BREAK(emitter, string))
Branch: 10 branches
BranchTrueFalseTotal
if (!WRITE_BREAK(emitter, string)) 0 12 12
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 12 0 12
if (!WRITE_BREAK(emitter, string)) 0 12 12
if (!WRITE_BREAK(emitter, string)) 12 0 12
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
2300 0 return 0;
2301 12 emitter->indention = 1;
2302 12 breaks = 1;
2303 }
2304 else
2305 {
2306 157 ▶ if (breaks) {
Branch: 1 branch
BranchTrueFalseTotal
if (breaks) { 14 143 157
2307 14 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 14 14
2308 0 return 0;
2309 }
2310 157 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 157 157
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 157 0 157
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 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 ▶ if (!yaml_emitter_write_indicator(emitter, ">", 1, 0, 0))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indicator(emitter, ">", 1, 0, 0)) 0 0 0
2331 0 return 0;
2332 0 ▶ if (!yaml_emitter_write_block_scalar_hints(emitter, string))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_block_scalar_hints(emitter, string)) 0 0 0
2333 0 return 0;
2334 0 ▶ if (!PUT_BREAK(emitter))
Branch: 5 branches
BranchTrueFalseTotal
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
2335 0 return 0;
2336 0 emitter->indention = 1;
2337 0 emitter->whitespace = 1;
2338  
2339 0 ▶ while (string.pointer != string.end)
Branch: 1 branch
BranchTrueFalseTotal
while (string.pointer != string.end) 0 0 0
2340 {
2341 0 ▶ if (IS_BREAK(string))
Branch: 10 branches
BranchTrueFalseTotal
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
if (IS_BREAK(string)) 0 0 0
2342 {
2343 0 ▶ if (!breaks && !leading_spaces && CHECK(string, '\n')) {
Branch: 3 branches
BranchTrueFalseTotal
if (!breaks && !leading_spaces && CHECK(string, '\n')) { 0 0 0
if (!breaks && !leading_spaces && CHECK(string, '\n')) { 0 0 0
if (!breaks && !leading_spaces && CHECK(string, '\n')) { 0 0 0
2344 0 int k = 0;
2345 0 ▶ while (IS_BREAK_AT(string, k)) {
Branch: 10 branches
BranchTrueFalseTotal
while (IS_BREAK_AT(string, k)) { 0 0 0
while (IS_BREAK_AT(string, k)) { 0 0 0
while (IS_BREAK_AT(string, k)) { 0 0 0
while (IS_BREAK_AT(string, k)) { 0 0 0
while (IS_BREAK_AT(string, k)) { 0 0 0
while (IS_BREAK_AT(string, k)) { 0 0 0
while (IS_BREAK_AT(string, k)) { 0 0 0
while (IS_BREAK_AT(string, k)) { 0 0 0
while (IS_BREAK_AT(string, k)) { 0 0 0
while (IS_BREAK_AT(string, k)) { 0 0 0
2346 0 ▶ k += WIDTH_AT(string, k);
Branch: 4 branches
BranchTrueFalseTotal
k += WIDTH_AT(string, k); 0 0 0
k += WIDTH_AT(string, k); 0 0 0
k += WIDTH_AT(string, k); 0 0 0
k += WIDTH_AT(string, k); 0 0 0
2347 }
2348 0 ▶ if (!IS_BLANKZ_AT(string, k)) {
Branch: 13 branches
BranchTrueFalseTotal
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
if (!IS_BLANKZ_AT(string, k)) { 0 0 0
2349 0 ▶ if (!PUT_BREAK(emitter))
Branch: 5 branches
BranchTrueFalseTotal
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
if (!PUT_BREAK(emitter)) 0 0 0
2350 0 return 0;
2351 }
2352 }
2353 0 ▶ if (!WRITE_BREAK(emitter, string))
Branch: 10 branches
BranchTrueFalseTotal
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
if (!WRITE_BREAK(emitter, string)) 0 0 0
2354 0 return 0;
2355 0 emitter->indention = 1;
2356 0 breaks = 1;
2357 }
2358 else
2359 {
2360 0 ▶ if (breaks) {
Branch: 1 branch
BranchTrueFalseTotal
if (breaks) { 0 0 0
2361 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
2362 0 return 0;
2363 0 ▶ leading_spaces = IS_BLANK(string);
Branch: 2 branches
BranchTrueFalseTotal
leading_spaces = IS_BLANK(string); 0 0 0
leading_spaces = IS_BLANK(string); 0 0 0
2364 }
2365 0 ▶ if (!breaks && IS_SPACE(string) && !IS_SPACE_AT(string, 1)
Branch: 3 branches
BranchTrueFalseTotal
if (!breaks && IS_SPACE(string) && !IS_SPACE_AT(string, 1) 0 0 0
if (!breaks && IS_SPACE(string) && !IS_SPACE_AT(string, 1) 0 0 0
if (!breaks && IS_SPACE(string) && !IS_SPACE_AT(string, 1) 0 0 0
2366 0 ▶ && emitter->column > emitter->best_width) {
Branch: 1 branch
BranchTrueFalseTotal
&& emitter->column > emitter->best_width) { 0 0 0
2367 0 ▶ if (!yaml_emitter_write_indent(emitter))
Branch: 1 branch
BranchTrueFalseTotal
if (!yaml_emitter_write_indent(emitter)) 0 0 0
2368 0 return 0;
2369 0 ▶ MOVE(string);
Branch: 4 branches
BranchTrueFalseTotal
MOVE(string); 0 0 0
MOVE(string); 0 0 0
MOVE(string); 0 0 0
MOVE(string); 0 0 0
2370 }
2371 else {
2372 0 ▶ if (!WRITE(emitter, string))
Branch: 6 branches
BranchTrueFalseTotal
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 0 0 0
if (!WRITE(emitter, string)) 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 }
« api.c ↑ Summary parser.c »