Kirill Simonov avatar Kirill Simonov committed e3ddc4e

Fixed non-ANSI initializations (fixes #115).

Comments (0)

Files changed (6)

     struct {
         yaml_error_type_t error;
     } context;
-    yaml_node_pair_t pair = { key, value };
+
+    yaml_node_pair_t pair;
 
     assert(document);       /* Non-NULL document is required. */
     assert(mapping > 0
     assert(value > 0 && document->nodes.start + value <= document->nodes.top);
                             /* Valid value id is required. */
 
+    pair.key = key;
+    pair.value = value;
+
     if (!PUSH(&context,
                 document->nodes.start[mapping-1].data.mapping.pairs, pair))
         return 0;
 yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter,
         yaml_tag_directive_t tag_directive)
 {
-    yaml_string_t handle = STRING(tag_directive.handle,
-            strlen((char *)tag_directive.handle));
-    yaml_string_t prefix = STRING(tag_directive.prefix,
-            strlen((char *)tag_directive.prefix));
+    yaml_string_t handle;
+    yaml_string_t prefix;
+    size_t handle_length;
+    size_t prefix_length;
+
+    handle_length = strlen((char *)tag_directive.handle);
+    prefix_length = strlen((char *)tag_directive.prefix);
+    STRING_ASSIGN(handle, tag_directive.handle, handle_length);
+    STRING_ASSIGN(prefix, tag_directive.prefix, prefix_length);
 
     if (handle.start == handle.end) {
         return yaml_emitter_set_emitter_error(emitter,
 yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
         yaml_char_t *anchor, int alias)
 {
-    yaml_string_t string = STRING(anchor, strlen((char *)anchor));
+    size_t anchor_length;
+    yaml_string_t string;
+    
+    anchor_length = strlen((char *)anchor);
+    STRING_ASSIGN(string, anchor, anchor_length);
 
     if (string.start == string.end) {
         return yaml_emitter_set_emitter_error(emitter, alias ?
 yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
         yaml_char_t *tag)
 {
-    yaml_string_t string = STRING(tag, strlen((char *)tag));
+    size_t tag_length;
+    yaml_string_t string;
     yaml_tag_directive_t *tag_directive;
 
+    tag_length = strlen((char *)tag);
+    STRING_ASSIGN(string, tag, tag_length);
+
     if (string.start == string.end) {
         return yaml_emitter_set_emitter_error(emitter,
                 "tag value must not be empty");
 yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
         yaml_char_t *value, size_t length)
 {
-    yaml_string_t string = STRING(value, length);
+    yaml_string_t string;
 
     int block_indicators = 0;
     int flow_indicators = 0;
     int previous_space = 0;
     int previous_break = 0;
 
+    STRING_ASSIGN(string, value, length);
+
     emitter->scalar_data.value = value;
     emitter->scalar_data.length = length;
 
         char *indicator, int need_whitespace,
         int is_whitespace, int is_indention)
 {
-    yaml_string_t string = STRING((yaml_char_t *)indicator, strlen(indicator));
+    size_t indicator_length;
+    yaml_string_t string;
+
+    indicator_length = strlen(indicator);
+    STRING_ASSIGN(string, (yaml_char_t *)indicator, indicator_length);
 
     if (need_whitespace && !emitter->whitespace) {
         if (!PUT(emitter, ' ')) return 0;
 yaml_emitter_write_anchor(yaml_emitter_t *emitter,
         yaml_char_t *value, size_t length)
 {
-    yaml_string_t string = STRING(value, length);
+    yaml_string_t string;
+    STRING_ASSIGN(string, value, length);
 
     while (string.pointer != string.end) {
         if (!WRITE(emitter, string)) return 0;
 yaml_emitter_write_tag_handle(yaml_emitter_t *emitter,
         yaml_char_t *value, size_t length)
 {
-    yaml_string_t string = STRING(value, length);
+    yaml_string_t string;
+    STRING_ASSIGN(string, value, length);
 
     if (!emitter->whitespace) {
         if (!PUT(emitter, ' ')) return 0;
         yaml_char_t *value, size_t length,
         int need_whitespace)
 {
-    yaml_string_t string = STRING(value, length);
+    yaml_string_t string;
+    STRING_ASSIGN(string, value, length);
 
     if (need_whitespace && !emitter->whitespace) {
         if (!PUT(emitter, ' ')) return 0;
 yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
         yaml_char_t *value, size_t length, int allow_breaks)
 {
-    yaml_string_t string = STRING(value, length);
+    yaml_string_t string;
     int spaces = 0;
     int breaks = 0;
 
+    STRING_ASSIGN(string, value, length);
+
     if (!emitter->whitespace) {
         if (!PUT(emitter, ' ')) return 0;
     }
 yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
         yaml_char_t *value, size_t length, int allow_breaks)
 {
-    yaml_string_t string = STRING(value, length);
+    yaml_string_t string;
     int spaces = 0;
     int breaks = 0;
 
+    STRING_ASSIGN(string, value, length);
+
     if (!yaml_emitter_write_indicator(emitter, "'", 1, 0, 0))
         return 0;
 
 yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
         yaml_char_t *value, size_t length, int allow_breaks)
 {
-    yaml_string_t string = STRING(value, length);
+    yaml_string_t string;
     int spaces = 0;
 
+    STRING_ASSIGN(string, value, length);
+
     if (!yaml_emitter_write_indicator(emitter, "\"", 1, 0, 0))
         return 0;
 
 yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter,
         yaml_char_t *value, size_t length)
 {
-    yaml_string_t string = STRING(value, length);
+    yaml_string_t string;
     int breaks = 1;
 
+    STRING_ASSIGN(string, value, length);
+
     if (!yaml_emitter_write_indicator(emitter, "|", 1, 0, 0))
         return 0;
     if (!yaml_emitter_write_block_scalar_hints(emitter, string))
 yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
         yaml_char_t *value, size_t length)
 {
-    yaml_string_t string = STRING(value, length);
+    yaml_string_t string;
     int breaks = 1;
     int leading_spaces = 1;
 
+    STRING_ASSIGN(string, value, length);
+
     if (!yaml_emitter_write_indicator(emitter, ">", 1, 0, 0))
         return 0;
     if (!yaml_emitter_write_block_scalar_hints(emitter, string))
 yaml_parser_register_anchor(yaml_parser_t *parser,
         int index, yaml_char_t *anchor)
 {
-    yaml_alias_data_t data = { anchor, index, { 0, 0, 0 } };
+    yaml_alias_data_t data;
     yaml_alias_data_t *alias_data;
 
     if (!anchor) return 1;
 
+    data.anchor = anchor;
+    data.index = index;
     data.mark = parser->document->nodes.start[index-1].start_mark;
 
     for (alias_data = parser->aliases.start;
         }
 
         else if (token->type == YAML_TAG_DIRECTIVE_TOKEN) {
-            yaml_tag_directive_t value = {
-                token->data.tag_directive.handle,
-                token->data.tag_directive.prefix
-            };
+            yaml_tag_directive_t value;
+            value.handle = token->data.tag_directive.handle;
+            value.prefix = token->data.tag_directive.prefix;
+
             if (!yaml_parser_append_tag_directive(parser, value, 0,
                         token->start_mark))
                 goto error;
 
     if (parser->simple_key_allowed)
     {
-        yaml_simple_key_t simple_key = { 1, required,
-            parser->tokens_parsed + parser->tokens.tail - parser->tokens.head,
-            { 0, 0, 0 } };
+        yaml_simple_key_t simple_key;
+        simple_key.possible = 1;
+        simple_key.required = required;
+        simple_key.token_number = 
+            parser->tokens_parsed + parser->tokens.tail - parser->tokens.head;
         simple_key.mark = parser->mark;
 
         if (!yaml_parser_remove_simple_key(parser)) return 0;

src/yaml_private.h

 
 #define STRING(string,length)   { (string), (string)+(length), (string) }
 
+#define STRING_ASSIGN(value,string,length)                                      \
+    ((value).start = (string),                                                  \
+     (value).end = (string)+(length),                                           \
+     (value).pointer = (string))
+
 #define STRING_INIT(context,string,size)                                        \
     (((string).start = yaml_malloc(size)) ?                                     \
         ((string).pointer = (string).start,                                     \
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.