]> andersk Git - libyaml.git/blobdiff - src/scanner.c
Add `const` qualifier for `yaml_parser_set_input_string` parameter `input`.
[libyaml.git] / src / scanner.c
index 90a8979f437893aab8f24a09de492df92d520db1..b190c7eea565e103c6af2903adf7060e032fba74 100644 (file)
         ? 1                                                                     \
         : yaml_parser_update_buffer(parser, (length)))
 
-/*
- * Check the octet at the specified position.
- */
-
-#define CHECK_AT(parser,octet,offset)                                           \
-    (parser->buffer.pointer[offset] == (yaml_char_t)(octet))
-
-/*
- * Check the current octet in the buffer.
- */
-
-#define CHECK(parser,octet) CHECK_AT(parser,(octet),0)
-
-/*
- * Check if the character at the specified position is an alphabetical
- * character, a digit, '_', or '-'.
- */
-
-#define IS_ALPHA_AT(parser,offset)                                              \
-     ((parser->buffer.pointer[offset] >= (yaml_char_t) '0' &&                   \
-       parser->buffer.pointer[offset] <= (yaml_char_t) '9') ||                  \
-      (parser->buffer.pointer[offset] >= (yaml_char_t) 'A' &&                   \
-       parser->buffer.pointer[offset] <= (yaml_char_t) 'Z') ||                  \
-      (parser->buffer.pointer[offset] >= (yaml_char_t) 'a' &&                   \
-       parser->buffer.pointer[offset] <= (yaml_char_t) 'z') ||                  \
-      parser->buffer.pointer[offset] == '_' ||                                  \
-      parser->buffer.pointer[offset] == '-')
-
-#define IS_ALPHA(parser)    IS_ALPHA_AT(parser,0)
-
-/*
- * Check if the character at the specified position is a digit.
- */
-
-#define IS_DIGIT_AT(parser,offset)                                              \
-     ((parser->buffer.pointer[offset] >= (yaml_char_t) '0' &&                   \
-       parser->buffer.pointer[offset] <= (yaml_char_t) '9'))
-
-#define IS_DIGIT(parser)    IS_DIGIT_AT(parser,0)
-
-/*
- * Get the value of a digit.
- */
-
-#define AS_DIGIT_AT(parser,offset)                                              \
-     (parser->buffer.pointer[offset] - (yaml_char_t) '0')
-
-#define AS_DIGIT(parser)    AS_DIGIT_AT(parser,0)
-
-/*
- * Check if the character at the specified position is a hex-digit.
- */
-
-#define IS_HEX_AT(parser,offset)                                                \
-     ((parser->buffer.pointer[offset] >= (yaml_char_t) '0' &&                   \
-       parser->buffer.pointer[offset] <= (yaml_char_t) '9') ||                  \
-      (parser->buffer.pointer[offset] >= (yaml_char_t) 'A' &&                   \
-       parser->buffer.pointer[offset] <= (yaml_char_t) 'F') ||                  \
-      (parser->buffer.pointer[offset] >= (yaml_char_t) 'a' &&                   \
-       parser->buffer.pointer[offset] <= (yaml_char_t) 'f'))
-
-#define IS_HEX(parser)    IS_HEX_AT(parser,0)
-
-/*
- * Get the value of a hex-digit.
- */
-
-#define AS_HEX_AT(parser,offset)                                                \
-      ((parser->buffer.pointer[offset] >= (yaml_char_t) 'A' &&                  \
-        parser->buffer.pointer[offset] <= (yaml_char_t) 'F') ?                  \
-       (parser->buffer.pointer[offset] - (yaml_char_t) 'A' + 10) :              \
-       (parser->buffer.pointer[offset] >= (yaml_char_t) 'a' &&                  \
-        parser->buffer.pointer[offset] <= (yaml_char_t) 'f') ?                  \
-       (parser->buffer.pointer[offset] - (yaml_char_t) 'a' + 10) :              \
-       (parser->buffer.pointer[offset] - (yaml_char_t) '0'))
-#define AS_HEX(parser)  AS_HEX_AT(parser,0)
-/*
- * Check if the character at the specified position is NUL.
- */
-
-#define IS_Z_AT(parser,offset)    CHECK_AT(parser,'\0',(offset))
-
-#define IS_Z(parser)    IS_Z_AT(parser,0)
-
-/*
- * Check if the character at the specified position is BOM.
- */
-
-#define IS_BOM_AT(parser,offset)                                                \
-     (CHECK_AT(parser,'\xEF',(offset))                                          \
-      && CHECK_AT(parser,'\xBB',(offset)+1)                                     \
-      && CHECK_AT(parser,'\xBF',(offset)+1))    /* BOM (#xFEFF) */
-
-#define IS_BOM(parser)  IS_BOM_AT(parser,0)
-
-/*
- * Check if the character at the specified position is space.
- */
-
-#define IS_SPACE_AT(parser,offset)  CHECK_AT(parser,' ',(offset))
-
-#define IS_SPACE(parser)    IS_SPACE_AT(parser,0)
-
-/*
- * Check if the character at the specified position is tab.
- */
-
-#define IS_TAB_AT(parser,offset)    CHECK_AT(parser,'\t',(offset))
-
-#define IS_TAB(parser)  IS_TAB_AT(parser,0)
-
-/*
- * Check if the character at the specified position is blank (space or tab).
- */
-
-#define IS_BLANK_AT(parser,offset)  \
-    (IS_SPACE_AT(parser,(offset)) || IS_TAB_AT(parser,(offset)))
-
-#define IS_BLANK(parser)    IS_BLANK_AT(parser,0)
-
-/*
- * Check if the character at the specified position is a line break.
- */
-
-#define IS_BREAK_AT(parser,offset)                                              \
-    (CHECK_AT(parser,'\r',(offset))                 /* CR (#xD)*/               \
-     || CHECK_AT(parser,'\n',(offset))              /* LF (#xA) */              \
-     || (CHECK_AT(parser,'\xC2',(offset))                                       \
-         && CHECK_AT(parser,'\x85',(offset)+1))     /* NEL (#x85) */            \
-     || (CHECK_AT(parser,'\xE2',(offset))                                       \
-         && CHECK_AT(parser,'\x80',(offset)+1)                                  \
-         && CHECK_AT(parser,'\xA8',(offset)+2))     /* LS (#x2028) */           \
-     || (CHECK_AT(parser,'\xE2',(offset))                                       \
-         && CHECK_AT(parser,'\x80',(offset)+1)                                  \
-         && CHECK_AT(parser,'\xA9',(offset)+2)))    /* PS (#x2029) */
-
-#define IS_BREAK(parser)    IS_BREAK_AT(parser,0)
-
-#define IS_CRLF_AT(parser,offset)                                               \
-     (CHECK_AT(parser,'\r',(offset)) && CHECK_AT(parser,'\n',(offset)+1))
-
-#define IS_CRLF(parser) IS_CRLF_AT(parser,0)
-
-/*
- * Check if the character is a line break or NUL.
- */
-
-#define IS_BREAKZ_AT(parser,offset)                                             \
-    (IS_BREAK_AT(parser,(offset)) || IS_Z_AT(parser,(offset)))
-
-#define IS_BREAKZ(parser)   IS_BREAKZ_AT(parser,0)
-
-/*
- * Check if the character is a line break, space, or NUL.
- */
-
-#define IS_SPACEZ_AT(parser,offset)                                             \
-    (IS_SPACE_AT(parser,(offset)) || IS_BREAKZ_AT(parser,(offset)))
-
-#define IS_SPACEZ(parser)   IS_SPACEZ_AT(parser,0)
-
-/*
- * Check if the character is a line break, space, tab, or NUL.
- */
-
-#define IS_BLANKZ_AT(parser,offset)                                             \
-    (IS_BLANK_AT(parser,(offset)) || IS_BREAKZ_AT(parser,(offset)))
-
-#define IS_BLANKZ(parser)   IS_BLANKZ_AT(parser,0)
-
-/*
- * Determine the width of the character.
- */
-
-#define WIDTH_AT(parser,offset)                                                 \
-     ((parser->buffer.pointer[offset] & 0x80) == 0x00 ? 1 :                     \
-      (parser->buffer.pointer[offset] & 0xE0) == 0xC0 ? 2 :                     \
-      (parser->buffer.pointer[offset] & 0xF0) == 0xE0 ? 3 :                     \
-      (parser->buffer.pointer[offset] & 0xF8) == 0xF0 ? 4 : 0)
-
-#define WIDTH(parser)   WIDTH_AT(parser,0)
-
 /*
  * Advance the buffer pointer.
  */
      (parser->mark.index ++,                                                    \
       parser->mark.column ++,                                                   \
       parser->unread --,                                                        \
-      parser->buffer.pointer += WIDTH(parser))
+      parser->buffer.pointer += WIDTH(parser->buffer))
 
 #define SKIP_LINE(parser)                                                       \
-     (IS_CRLF(parser) ?                                                         \
+     (IS_CRLF(parser->buffer) ?                                                 \
       (parser->mark.index += 2,                                                 \
        parser->mark.column = 0,                                                 \
        parser->mark.line ++,                                                    \
        parser->unread -= 2,                                                     \
        parser->buffer.pointer += 2) :                                           \
-      IS_BREAK(parser) ?                                                        \
+      IS_BREAK(parser->buffer) ?                                                \
       (parser->mark.index ++,                                                   \
        parser->mark.column = 0,                                                 \
        parser->mark.line ++,                                                    \
        parser->unread --,                                                       \
-       parser->buffer.pointer += WIDTH(parser)) : 0)
+       parser->buffer.pointer += WIDTH(parser->buffer)) : 0)
 
 /*
  * Copy a character to a string buffer and advance pointers.
 
 #define READ(parser,string)                                                     \
      (STRING_EXTEND(parser,string) ?                                            \
-         (((*parser->buffer.pointer & 0x80) == 0x00 ?                           \
-           (*((string).pointer++) = *(parser->buffer.pointer++)) :              \
-           (*parser->buffer.pointer & 0xE0) == 0xC0 ?                           \
-           (*((string).pointer++) = *(parser->buffer.pointer++),                \
-            *((string).pointer++) = *(parser->buffer.pointer++)) :              \
-           (*parser->buffer.pointer & 0xF0) == 0xE0 ?                           \
-           (*((string).pointer++) = *(parser->buffer.pointer++),                \
-            *((string).pointer++) = *(parser->buffer.pointer++),                \
-            *((string).pointer++) = *(parser->buffer.pointer++)) :              \
-           (*parser->buffer.pointer & 0xF8) == 0xF0 ?                           \
-           (*((string).pointer++) = *(parser->buffer.pointer++),                \
-            *((string).pointer++) = *(parser->buffer.pointer++),                \
-            *((string).pointer++) = *(parser->buffer.pointer++),                \
-            *((string).pointer++) = *(parser->buffer.pointer++)) : 0),          \
+         (COPY(string,parser->buffer),                                          \
           parser->mark.index ++,                                                \
           parser->mark.column ++,                                               \
           parser->unread --,                                                    \
 
 #define READ_LINE(parser,string)                                                \
     (STRING_EXTEND(parser,string) ?                                             \
-    (((CHECK_AT(parser,'\r',0) && CHECK_AT(parser,'\n',1)) ? /* CR LF -> LF */  \
+    (((CHECK_AT(parser->buffer,'\r',0)                                          \
+       && CHECK_AT(parser->buffer,'\n',1)) ?        /* CR LF -> LF */           \
      (*((string).pointer++) = (yaml_char_t) '\n',                               \
       parser->buffer.pointer += 2,                                              \
       parser->mark.index += 2,                                                  \
       parser->mark.column = 0,                                                  \
       parser->mark.line ++,                                                     \
       parser->unread -= 2) :                                                    \
-     (CHECK_AT(parser,'\r',0) || CHECK_AT(parser,'\n',0)) ? /* CR|LF -> LF */   \
+     (CHECK_AT(parser->buffer,'\r',0)                                           \
+      || CHECK_AT(parser->buffer,'\n',0)) ?         /* CR|LF -> LF */           \
      (*((string).pointer++) = (yaml_char_t) '\n',                               \
       parser->buffer.pointer ++,                                                \
       parser->mark.index ++,                                                    \
       parser->mark.column = 0,                                                  \
       parser->mark.line ++,                                                     \
       parser->unread --) :                                                      \
-     (CHECK_AT(parser,'\xC2',0) && CHECK_AT(parser,'\x85',1)) ? /* NEL -> LF */ \
+     (CHECK_AT(parser->buffer,'\xC2',0)                                         \
+      && CHECK_AT(parser->buffer,'\x85',1)) ?       /* NEL -> LF */             \
      (*((string).pointer++) = (yaml_char_t) '\n',                               \
       parser->buffer.pointer += 2,                                              \
       parser->mark.index ++,                                                    \
       parser->mark.column = 0,                                                  \
       parser->mark.line ++,                                                     \
       parser->unread --) :                                                      \
-     (CHECK_AT(parser,'\xE2',0) &&                                              \
-      CHECK_AT(parser,'\x80',1) &&                                              \
-      (CHECK_AT(parser,'\xA8',2) ||                                             \
-       CHECK_AT(parser,'\xA9',2))) ?                    /* LS|PS -> LS|PS */    \
+     (CHECK_AT(parser->buffer,'\xE2',0) &&                                      \
+      CHECK_AT(parser->buffer,'\x80',1) &&                                      \
+      (CHECK_AT(parser->buffer,'\xA8',2) ||                                     \
+       CHECK_AT(parser->buffer,'\xA9',2))) ?        /* LS|PS -> LS|PS */        \
      (*((string).pointer++) = *(parser->buffer.pointer++),                      \
       *((string).pointer++) = *(parser->buffer.pointer++),                      \
       *((string).pointer++) = *(parser->buffer.pointer++),                      \
       parser->unread --) : 0),                                                  \
     1) : 0)
 
-/*
- * Token initializers.
- */
-
-#define TOKEN_INIT(token,token_type,token_start_mark,token_end_mark)            \
-    (memset(&(token), 0, sizeof(yaml_token_t)),                                 \
-     (token).type = (token_type),                                               \
-     (token).start_mark = (token_start_mark),                                   \
-     (token).end_mark = (token_end_mark))
-
-#define STREAM_START_TOKEN_INIT(token,token_encoding,start_mark,end_mark)       \
-    (TOKEN_INIT((token),YAML_STREAM_START_TOKEN,(start_mark),(end_mark)),       \
-     (token).data.stream_start.encoding = (token_encoding))
-
-#define STREAM_END_TOKEN_INIT(token,start_mark,end_mark)                        \
-    (TOKEN_INIT((token),YAML_STREAM_END_TOKEN,(start_mark),(end_mark)))
-
-#define ALIAS_TOKEN_INIT(token,token_value,start_mark,end_mark)                 \
-    (TOKEN_INIT((token),YAML_ALIAS_TOKEN,(start_mark),(end_mark)),              \
-     (token).data.alias.value = (token_value))
-
-#define ANCHOR_TOKEN_INIT(token,token_value,start_mark,end_mark)                \
-    (TOKEN_INIT((token),YAML_ANCHOR_TOKEN,(start_mark),(end_mark)),             \
-     (token).data.anchor.value = (token_value))
-
-#define TAG_TOKEN_INIT(token,token_handle,token_suffix,start_mark,end_mark)     \
-    (TOKEN_INIT((token),YAML_TAG_TOKEN,(start_mark),(end_mark)),                \
-     (token).data.tag.handle = (token_handle),                                  \
-     (token).data.tag.suffix = (token_suffix))
-
-#define SCALAR_TOKEN_INIT(token,token_value,token_length,token_style,start_mark,end_mark)   \
-    (TOKEN_INIT((token),YAML_SCALAR_TOKEN,(start_mark),(end_mark)),             \
-     (token).data.scalar.value = (token_value),                                 \
-     (token).data.scalar.length = (token_length),                               \
-     (token).data.scalar.style = (token_style))
-
-#define VERSION_DIRECTIVE_TOKEN_INIT(token,token_major,token_minor,start_mark,end_mark)     \
-    (TOKEN_INIT((token),YAML_VERSION_DIRECTIVE_TOKEN,(start_mark),(end_mark)),  \
-     (token).data.version_directive.major = (token_major),                      \
-     (token).data.version_directive.minor = (token_minor))
-
-#define TAG_DIRECTIVE_TOKEN_INIT(token,token_handle,token_prefix,start_mark,end_mark)       \
-    (TOKEN_INIT((token),YAML_TAG_DIRECTIVE_TOKEN,(start_mark),(end_mark)),      \
-     (token).data.tag_directive.handle = (token_handle),                        \
-     (token).data.tag_directive.prefix = (token_prefix))
-
 /*
  * Public API declarations.
  */
@@ -984,11 +744,13 @@ yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
     assert(parser); /* Non-NULL parser object is expected. */
     assert(token);  /* Non-NULL token object is expected. */
 
+    /* Erase the token object. */
+
+    memset(token, 0, sizeof(yaml_token_t));
+
     /* No tokens after STREAM-END or error. */
 
     if (parser->stream_end_produced || parser->error) {
-        memset(token, 0, sizeof(yaml_token_t));
-
         return 1;
     }
 
@@ -1132,111 +894,113 @@ yaml_parser_fetch_next_token(yaml_parser_t *parser)
 
     /* Is it the end of the stream? */
 
-    if (IS_Z(parser))
+    if (IS_Z(parser->buffer))
         return yaml_parser_fetch_stream_end(parser);
 
     /* Is it a directive? */
 
-    if (parser->mark.column == 0 && CHECK(parser, '%'))
+    if (parser->mark.column == 0 && CHECK(parser->buffer, '%'))
         return yaml_parser_fetch_directive(parser);
 
     /* Is it the document start indicator? */
 
     if (parser->mark.column == 0
-            && CHECK_AT(parser, '-', 0)
-            && CHECK_AT(parser, '-', 1)
-            && CHECK_AT(parser, '-', 2)
-            && IS_BLANKZ_AT(parser, 3))
+            && CHECK_AT(parser->buffer, '-', 0)
+            && CHECK_AT(parser->buffer, '-', 1)
+            && CHECK_AT(parser->buffer, '-', 2)
+            && IS_BLANKZ_AT(parser->buffer, 3))
         return yaml_parser_fetch_document_indicator(parser,
                 YAML_DOCUMENT_START_TOKEN);
 
     /* Is it the document end indicator? */
 
     if (parser->mark.column == 0
-            && CHECK_AT(parser, '.', 0)
-            && CHECK_AT(parser, '.', 1)
-            && CHECK_AT(parser, '.', 2)
-            && IS_BLANKZ_AT(parser, 3))
+            && CHECK_AT(parser->buffer, '.', 0)
+            && CHECK_AT(parser->buffer, '.', 1)
+            && CHECK_AT(parser->buffer, '.', 2)
+            && IS_BLANKZ_AT(parser->buffer, 3))
         return yaml_parser_fetch_document_indicator(parser,
                 YAML_DOCUMENT_END_TOKEN);
 
     /* Is it the flow sequence start indicator? */
 
-    if (CHECK(parser, '['))
+    if (CHECK(parser->buffer, '['))
         return yaml_parser_fetch_flow_collection_start(parser,
                 YAML_FLOW_SEQUENCE_START_TOKEN);
 
     /* Is it the flow mapping start indicator? */
 
-    if (CHECK(parser, '{'))
+    if (CHECK(parser->buffer, '{'))
         return yaml_parser_fetch_flow_collection_start(parser,
                 YAML_FLOW_MAPPING_START_TOKEN);
 
     /* Is it the flow sequence end indicator? */
 
-    if (CHECK(parser, ']'))
+    if (CHECK(parser->buffer, ']'))
         return yaml_parser_fetch_flow_collection_end(parser,
                 YAML_FLOW_SEQUENCE_END_TOKEN);
 
     /* Is it the flow mapping end indicator? */
 
-    if (CHECK(parser, '}'))
+    if (CHECK(parser->buffer, '}'))
         return yaml_parser_fetch_flow_collection_end(parser,
                 YAML_FLOW_MAPPING_END_TOKEN);
 
     /* Is it the flow entry indicator? */
 
-    if (CHECK(parser, ','))
+    if (CHECK(parser->buffer, ','))
         return yaml_parser_fetch_flow_entry(parser);
 
     /* Is it the block entry indicator? */
 
-    if (CHECK(parser, '-') && IS_BLANKZ_AT(parser, 1))
+    if (CHECK(parser->buffer, '-') && IS_BLANKZ_AT(parser->buffer, 1))
         return yaml_parser_fetch_block_entry(parser);
 
     /* Is it the key indicator? */
 
-    if (CHECK(parser, '?') && (parser->flow_level || IS_BLANKZ_AT(parser, 1)))
+    if (CHECK(parser->buffer, '?')
+            && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
         return yaml_parser_fetch_key(parser);
 
     /* Is it the value indicator? */
 
-    if (CHECK(parser, ':') && (parser->flow_level || IS_BLANKZ_AT(parser, 1)))
+    if (CHECK(parser->buffer, ':')
+            && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
         return yaml_parser_fetch_value(parser);
 
     /* Is it an alias? */
 
-    if (CHECK(parser, '*'))
+    if (CHECK(parser->buffer, '*'))
         return yaml_parser_fetch_anchor(parser, YAML_ALIAS_TOKEN);
 
     /* Is it an anchor? */
 
-    if (CHECK(parser, '&'))
+    if (CHECK(parser->buffer, '&'))
         return yaml_parser_fetch_anchor(parser, YAML_ANCHOR_TOKEN);
 
     /* Is it a tag? */
 
-    if (CHECK(parser, '!'))
+    if (CHECK(parser->buffer, '!'))
         return yaml_parser_fetch_tag(parser);
 
     /* Is it a literal scalar? */
 
-    if (CHECK(parser, '|') && !parser->flow_level)
+    if (CHECK(parser->buffer, '|') && !parser->flow_level)
         return yaml_parser_fetch_block_scalar(parser, 1);
 
     /* Is it a folded scalar? */
 
-    if (CHECK(parser, '>') && !parser->flow_level)
+    if (CHECK(parser->buffer, '>') && !parser->flow_level)
         return yaml_parser_fetch_block_scalar(parser, 0);
 
     /* Is it a single-quoted scalar? */
 
-    if (CHECK(parser, '\''))
+    if (CHECK(parser->buffer, '\''))
         return yaml_parser_fetch_flow_scalar(parser, 1);
 
     /* Is it a double-quoted scalar? */
 
-    if (CHECK(parser, '"'))
+    if (CHECK(parser->buffer, '"'))
         return yaml_parser_fetch_flow_scalar(parser, 0);
 
     /*
@@ -1258,16 +1022,20 @@ yaml_parser_fetch_next_token(yaml_parser_t *parser)
      * The last rule is more restrictive than the specification requires.
      */
 
-    if (!(IS_BLANKZ(parser) || CHECK(parser, '-') || CHECK(parser, '?')
-                || CHECK(parser, ':') || CHECK(parser, ',') || CHECK(parser, '[')
-                || CHECK(parser, ']') || CHECK(parser, '{') || CHECK(parser, '}')
-                || CHECK(parser, '#') || CHECK(parser, '&') || CHECK(parser, '*')
-                || CHECK(parser, '!') || CHECK(parser, '|') || CHECK(parser, '>')
-                || CHECK(parser, '\'') || CHECK(parser, '"') || CHECK(parser, '%')
-                || CHECK(parser, '@') || CHECK(parser, '`')) ||
-            (CHECK(parser, '-') && !IS_BLANK_AT(parser, 1)) ||
+    if (!(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '-')
+                || CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':')
+                || CHECK(parser->buffer, ',') || CHECK(parser->buffer, '[')
+                || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
+                || CHECK(parser->buffer, '}') || CHECK(parser->buffer, '#')
+                || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '*')
+                || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '|')
+                || CHECK(parser->buffer, '>') || CHECK(parser->buffer, '\'')
+                || CHECK(parser->buffer, '"') || CHECK(parser->buffer, '%')
+                || CHECK(parser->buffer, '@') || CHECK(parser->buffer, '`')) ||
+            (CHECK(parser->buffer, '-') && !IS_BLANK_AT(parser->buffer, 1)) ||
             (!parser->flow_level &&
-             (CHECK(parser, '?') || CHECK(parser, ':')) && !IS_BLANKZ_AT(parser, 1)))
+             (CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':'))
+             && !IS_BLANKZ_AT(parser->buffer, 1)))
         return yaml_parser_fetch_plain_scalar(parser);
 
     /*
@@ -1556,6 +1324,13 @@ yaml_parser_fetch_stream_end(yaml_parser_t *parser)
 {
     yaml_token_t token;
 
+    /* Force new line. */
+
+    if (parser->mark.column != 0) {
+        parser->mark.column = 0;
+        parser->mark.line ++;
+    }
+
     /* Reset the indentation level. */
 
     if (!yaml_parser_unroll_indent(parser, -1))
@@ -2145,7 +1920,7 @@ yaml_parser_scan_to_next_token(yaml_parser_t *parser)
 
         if (!CACHE(parser, 1)) return 0;
 
-        if (parser->mark.column == 0 && IS_BOM(parser))
+        if (parser->mark.column == 0 && IS_BOM(parser->buffer))
             SKIP(parser);
 
         /*
@@ -2160,17 +1935,17 @@ yaml_parser_scan_to_next_token(yaml_parser_t *parser)
 
         if (!CACHE(parser, 1)) return 0;
 
-        while (CHECK(parser,' ') ||
+        while (CHECK(parser->buffer,' ') ||
                 ((parser->flow_level || !parser->simple_key_allowed) &&
-                 CHECK(parser, '\t'))) {
+                 CHECK(parser->buffer, '\t'))) {
             SKIP(parser);
             if (!CACHE(parser, 1)) return 0;
         }
 
         /* Eat a comment until a line break. */
 
-        if (CHECK(parser, '#')) {
-            while (!IS_BREAKZ(parser)) {
+        if (CHECK(parser->buffer, '#')) {
+            while (!IS_BREAKZ(parser->buffer)) {
                 SKIP(parser);
                 if (!CACHE(parser, 1)) return 0;
             }
@@ -2178,7 +1953,7 @@ yaml_parser_scan_to_next_token(yaml_parser_t *parser)
 
         /* If it is a line break, eat it. */
 
-        if (IS_BREAK(parser))
+        if (IS_BREAK(parser->buffer))
         {
             if (!CACHE(parser, 2)) return 0;
             SKIP_LINE(parser);
@@ -2278,13 +2053,13 @@ yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
 
     if (!CACHE(parser, 1)) goto error;
 
-    while (IS_BLANK(parser)) {
+    while (IS_BLANK(parser->buffer)) {
         SKIP(parser);
         if (!CACHE(parser, 1)) goto error;
     }
 
-    if (CHECK(parser, '#')) {
-        while (!IS_BREAKZ(parser)) {
+    if (CHECK(parser->buffer, '#')) {
+        while (!IS_BREAKZ(parser->buffer)) {
             SKIP(parser);
             if (!CACHE(parser, 1)) goto error;
         }
@@ -2292,7 +2067,7 @@ yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
 
     /* Check if we are at the end of the line. */
 
-    if (!IS_BREAKZ(parser)) {
+    if (!IS_BREAKZ(parser->buffer)) {
         yaml_parser_set_scanner_error(parser, "while scanning a directive",
                 start_mark, "did not found expected comment or line break");
         goto error;
@@ -2300,7 +2075,7 @@ yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
 
     /* Eat a line break. */
 
-    if (IS_BREAK(parser)) {
+    if (IS_BREAK(parser->buffer)) {
         if (!CACHE(parser, 2)) goto error;
         SKIP_LINE(parser);
     }
@@ -2338,7 +2113,7 @@ yaml_parser_scan_directive_name(yaml_parser_t *parser,
 
     if (!CACHE(parser, 1)) goto error;
 
-    while (IS_ALPHA(parser))
+    while (IS_ALPHA(parser->buffer))
     {
         if (!READ(parser, string)) goto error;
         if (!CACHE(parser, 1)) goto error;
@@ -2354,7 +2129,7 @@ yaml_parser_scan_directive_name(yaml_parser_t *parser,
 
     /* Check for an blank character after the name. */
 
-    if (!IS_BLANKZ(parser)) {
+    if (!IS_BLANKZ(parser->buffer)) {
         yaml_parser_set_scanner_error(parser, "while scanning a directive",
                 start_mark, "found unexpected non-alphabetical character");
         goto error;
@@ -2385,7 +2160,7 @@ yaml_parser_scan_version_directive_value(yaml_parser_t *parser,
 
     if (!CACHE(parser, 1)) return 0;
 
-    while (IS_BLANK(parser)) {
+    while (IS_BLANK(parser->buffer)) {
         SKIP(parser);
         if (!CACHE(parser, 1)) return 0;
     }
@@ -2397,7 +2172,7 @@ yaml_parser_scan_version_directive_value(yaml_parser_t *parser,
 
     /* Eat '.'. */
 
-    if (!CHECK(parser, '.')) {
+    if (!CHECK(parser->buffer, '.')) {
         return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
                 start_mark, "did not find expected digit or '.' character");
     }
@@ -2435,7 +2210,7 @@ yaml_parser_scan_version_directive_number(yaml_parser_t *parser,
 
     if (!CACHE(parser, 1)) return 0;
 
-    while (IS_DIGIT(parser))
+    while (IS_DIGIT(parser->buffer))
     {
         /* Check if the number is too long. */
 
@@ -2444,7 +2219,7 @@ yaml_parser_scan_version_directive_number(yaml_parser_t *parser,
                     start_mark, "found extremely long version number");
         }
 
-        value = value*10 + AS_DIGIT(parser);
+        value = value*10 + AS_DIGIT(parser->buffer);
 
         SKIP(parser);
 
@@ -2482,7 +2257,7 @@ yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
 
     if (!CACHE(parser, 1)) goto error;
 
-    while (IS_BLANK(parser)) {
+    while (IS_BLANK(parser->buffer)) {
         SKIP(parser);
         if (!CACHE(parser, 1)) goto error;
     }
@@ -2496,7 +2271,7 @@ yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
 
     if (!CACHE(parser, 1)) goto error;
 
-    if (!IS_BLANK(parser)) {
+    if (!IS_BLANK(parser->buffer)) {
         yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
                 start_mark, "did not find expected whitespace");
         goto error;
@@ -2504,7 +2279,7 @@ yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
 
     /* Eat whitespaces. */
 
-    while (IS_BLANK(parser)) {
+    while (IS_BLANK(parser->buffer)) {
         SKIP(parser);
         if (!CACHE(parser, 1)) goto error;
     }
@@ -2518,7 +2293,7 @@ yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
 
     if (!CACHE(parser, 1)) goto error;
 
-    if (!IS_BLANKZ(parser)) {
+    if (!IS_BLANKZ(parser->buffer)) {
         yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
                 start_mark, "did not find expected whitespace or line break");
         goto error;
@@ -2555,7 +2330,7 @@ yaml_parser_scan_anchor(yaml_parser_t *parser, yaml_token_t *token,
 
     if (!CACHE(parser, 1)) goto error;
 
-    while (IS_ALPHA(parser)) {
+    while (IS_ALPHA(parser->buffer)) {
         if (!READ(parser, string)) goto error;
         if (!CACHE(parser, 1)) goto error;
         length ++;
@@ -2570,9 +2345,11 @@ yaml_parser_scan_anchor(yaml_parser_t *parser, yaml_token_t *token,
      *      '?', ':', ',', ']', '}', '%', '@', '`'.
      */
 
-    if (!length || !(IS_BLANKZ(parser) || CHECK(parser, '?') || CHECK(parser, ':') ||
-                CHECK(parser, ',') || CHECK(parser, ']') || CHECK(parser, '}') ||
-                CHECK(parser, '%') || CHECK(parser, '@') || CHECK(parser, '`'))) {
+    if (!length || !(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '?')
+                || CHECK(parser->buffer, ':') || CHECK(parser->buffer, ',')
+                || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '}')
+                || CHECK(parser->buffer, '%') || CHECK(parser->buffer, '@')
+                || CHECK(parser->buffer, '`'))) {
         yaml_parser_set_scanner_error(parser, type == YAML_ANCHOR_TOKEN ?
                 "while scanning an anchor" : "while scanning an alias", start_mark,
                 "did not find expected alphabetic or numeric character");
@@ -2612,7 +2389,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
 
     if (!CACHE(parser, 2)) goto error;
 
-    if (CHECK_AT(parser, '<', 1))
+    if (CHECK_AT(parser->buffer, '<', 1))
     {
         /* Set the handle to '' */
 
@@ -2632,7 +2409,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
 
         /* Check for '>' and eat it. */
 
-        if (!CHECK(parser, '>')) {
+        if (!CHECK(parser->buffer, '>')) {
             yaml_parser_set_scanner_error(parser, "while scanning a tag",
                     start_mark, "did not find the expected '>'");
             goto error;
@@ -2690,7 +2467,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
 
     if (!CACHE(parser, 1)) goto error;
 
-    if (!IS_BLANKZ(parser)) {
+    if (!IS_BLANKZ(parser->buffer)) {
         yaml_parser_set_scanner_error(parser, "while scanning a tag",
                 start_mark, "did not found expected whitespace or line break");
         goto error;
@@ -2726,7 +2503,7 @@ yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
 
     if (!CACHE(parser, 1)) goto error;
 
-    if (!CHECK(parser, '!')) {
+    if (!CHECK(parser->buffer, '!')) {
         yaml_parser_set_scanner_error(parser, directive ?
                 "while scanning a tag directive" : "while scanning a tag",
                 start_mark, "did not find expected '!'");
@@ -2741,7 +2518,7 @@ yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
 
     if (!CACHE(parser, 1)) goto error;
 
-    while (IS_ALPHA(parser))
+    while (IS_ALPHA(parser->buffer))
     {
         if (!READ(parser, string)) goto error;
         if (!CACHE(parser, 1)) goto error;
@@ -2749,7 +2526,7 @@ yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
 
     /* Check if the trailing character is '!' and copy it. */
 
-    if (CHECK(parser, '!'))
+    if (CHECK(parser->buffer, '!'))
     {
         if (!READ(parser, string)) goto error;
     }
@@ -2822,17 +2599,21 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
      *      '%'.
      */
 
-    while (IS_ALPHA(parser) || CHECK(parser, ';') || CHECK(parser, '/') ||
-            CHECK(parser, '?') || CHECK(parser, ':') || CHECK(parser, '@') ||
-            CHECK(parser, '&') || CHECK(parser, '=') || CHECK(parser, '+') ||
-            CHECK(parser, '$') || CHECK(parser, ',') || CHECK(parser, '.') ||
-            CHECK(parser, '!') || CHECK(parser, '~') || CHECK(parser, '*') ||
-            CHECK(parser, '\'') || CHECK(parser, '(') || CHECK(parser, ')') ||
-            CHECK(parser, '[') || CHECK(parser, ']') || CHECK(parser, '%'))
+    while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';')
+            || CHECK(parser->buffer, '/') || CHECK(parser->buffer, '?')
+            || CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@')
+            || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=')
+            || CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$')
+            || CHECK(parser->buffer, ',') || CHECK(parser->buffer, '.')
+            || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~')
+            || CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'')
+            || CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')')
+            || CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']')
+            || CHECK(parser->buffer, '%'))
     {
         /* Check if it is a URI-escape sequence. */
 
-        if (CHECK(parser, '%')) {
+        if (CHECK(parser->buffer, '%')) {
             if (!yaml_parser_scan_uri_escapes(parser,
                         directive, start_mark, &string)) goto error;
         }
@@ -2885,7 +2666,9 @@ yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive,
 
         if (!CACHE(parser, 3)) return 0;
 
-        if (!(CHECK(parser, '%') && IS_HEX_AT(parser, 1) && IS_HEX_AT(parser, 2))) {
+        if (!(CHECK(parser->buffer, '%')
+                    && IS_HEX_AT(parser->buffer, 1)
+                    && IS_HEX_AT(parser->buffer, 2))) {
             return yaml_parser_set_scanner_error(parser, directive ?
                     "while parsing a %TAG directive" : "while parsing a tag",
                     start_mark, "did not find URI escaped octet");
@@ -2893,7 +2676,7 @@ yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive,
 
         /* Get the octet. */
 
-        octet = (AS_HEX_AT(parser, 1) << 4) + AS_HEX_AT(parser, 2);
+        octet = (AS_HEX_AT(parser->buffer, 1) << 4) + AS_HEX_AT(parser->buffer, 2);
 
         /* If it is the leading octet, determine the length of the UTF-8 sequence. */
 
@@ -2967,11 +2750,11 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
     /* Check for a chomping indicator. */
 
-    if (CHECK(parser, '+') || CHECK(parser, '-'))
+    if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-'))
     {
         /* Set the chomping method and eat the indicator. */
 
-        chomping = CHECK(parser, '+') ? +1 : -1;
+        chomping = CHECK(parser->buffer, '+') ? +1 : -1;
 
         SKIP(parser);
 
@@ -2979,11 +2762,11 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
         if (!CACHE(parser, 1)) goto error;
 
-        if (IS_DIGIT(parser))
+        if (IS_DIGIT(parser->buffer))
         {
             /* Check that the intendation is greater than 0. */
 
-            if (CHECK(parser, '0')) {
+            if (CHECK(parser->buffer, '0')) {
                 yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
                         start_mark, "found an intendation indicator equal to 0");
                 goto error;
@@ -2991,7 +2774,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
             /* Get the intendation level and eat the indicator. */
 
-            increment = AS_DIGIT(parser);
+            increment = AS_DIGIT(parser->buffer);
 
             SKIP(parser);
         }
@@ -2999,22 +2782,22 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
     /* Do the same as above, but in the opposite order. */
 
-    else if (IS_DIGIT(parser))
+    else if (IS_DIGIT(parser->buffer))
     {
-        if (CHECK(parser, '0')) {
+        if (CHECK(parser->buffer, '0')) {
             yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
                     start_mark, "found an intendation indicator equal to 0");
             goto error;
         }
 
-        increment = AS_DIGIT(parser);
+        increment = AS_DIGIT(parser->buffer);
 
         SKIP(parser);
 
         if (!CACHE(parser, 1)) goto error;
 
-        if (CHECK(parser, '+') || CHECK(parser, '-')) {
-            chomping = CHECK(parser, '+') ? +1 : -1;
+        if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-')) {
+            chomping = CHECK(parser->buffer, '+') ? +1 : -1;
 
             SKIP(parser);
         }
@@ -3024,13 +2807,13 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
     if (!CACHE(parser, 1)) goto error;
 
-    while (IS_BLANK(parser)) {
+    while (IS_BLANK(parser->buffer)) {
         SKIP(parser);
         if (!CACHE(parser, 1)) goto error;
     }
 
-    if (CHECK(parser, '#')) {
-        while (!IS_BREAKZ(parser)) {
+    if (CHECK(parser->buffer, '#')) {
+        while (!IS_BREAKZ(parser->buffer)) {
             SKIP(parser);
             if (!CACHE(parser, 1)) goto error;
         }
@@ -3038,7 +2821,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
     /* Check if we are at the end of the line. */
 
-    if (!IS_BREAKZ(parser)) {
+    if (!IS_BREAKZ(parser->buffer)) {
         yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
                 start_mark, "did not found expected comment or line break");
         goto error;
@@ -3046,7 +2829,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
     /* Eat a line break. */
 
-    if (IS_BREAK(parser)) {
+    if (IS_BREAK(parser->buffer)) {
         if (!CACHE(parser, 2)) goto error;
         SKIP_LINE(parser);
     }
@@ -3068,7 +2851,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
     if (!CACHE(parser, 1)) goto error;
 
-    while (parser->mark.column == indent && !IS_Z(parser))
+    while (parser->mark.column == indent && !IS_Z(parser->buffer))
     {
         /*
          * We are at the beginning of a non-empty line.
@@ -3076,7 +2859,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
         /* Is it a trailing whitespace? */
 
-        trailing_blank = IS_BLANK(parser);
+        trailing_blank = IS_BLANK(parser->buffer);
 
         /* Check if we need to fold the leading line break. */
 
@@ -3104,11 +2887,11 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
         /* Is it a leading whitespace? */
 
-        leading_blank = IS_BLANK(parser);
+        leading_blank = IS_BLANK(parser->buffer);
 
         /* Consume the current line. */
 
-        while (!IS_BREAKZ(parser)) {
+        while (!IS_BREAKZ(parser->buffer)) {
             if (!READ(parser, string)) goto error;
             if (!CACHE(parser, 1)) goto error;
         }
@@ -3175,7 +2958,8 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
 
         if (!CACHE(parser, 1)) return 0;
 
-        while ((!*indent || parser->mark.column < *indent) && IS_SPACE(parser)) {
+        while ((!*indent || parser->mark.column < *indent)
+                && IS_SPACE(parser->buffer)) {
             SKIP(parser);
             if (!CACHE(parser, 1)) return 0;
         }
@@ -3185,14 +2969,15 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
 
         /* Check for a tab character messing the intendation. */
 
-        if ((!*indent || parser->mark.column < *indent) && IS_TAB(parser)) {
+        if ((!*indent || parser->mark.column < *indent)
+                && IS_TAB(parser->buffer)) {
             return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
                     start_mark, "found a tab character where an intendation space is expected");
         }
 
         /* Have we found a non-empty line? */
 
-        if (!IS_BREAK(parser)) break;
+        if (!IS_BREAK(parser->buffer)) break;
 
         /* Consume the line break. */
 
@@ -3250,13 +3035,13 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
         if (!CACHE(parser, 4)) goto error;
 
         if (parser->mark.column == 0 &&
-            ((CHECK_AT(parser, '-', 0) &&
-              CHECK_AT(parser, '-', 1) &&
-              CHECK_AT(parser, '-', 2)) ||
-             (CHECK_AT(parser, '.', 0) &&
-              CHECK_AT(parser, '.', 1) &&
-              CHECK_AT(parser, '.', 2))) &&
-            IS_BLANKZ_AT(parser, 3))
+            ((CHECK_AT(parser->buffer, '-', 0) &&
+              CHECK_AT(parser->buffer, '-', 1) &&
+              CHECK_AT(parser->buffer, '-', 2)) ||
+             (CHECK_AT(parser->buffer, '.', 0) &&
+              CHECK_AT(parser->buffer, '.', 1) &&
+              CHECK_AT(parser->buffer, '.', 2))) &&
+            IS_BLANKZ_AT(parser->buffer, 3))
         {
             yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
                     start_mark, "found unexpected document indicator");
@@ -3265,7 +3050,7 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
         /* Check for EOF. */
 
-        if (IS_Z(parser)) {
+        if (IS_Z(parser->buffer)) {
             yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
                     start_mark, "found unexpected end of stream");
             goto error;
@@ -3277,11 +3062,12 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
         leading_blanks = 0;
 
-        while (!IS_BLANKZ(parser))
+        while (!IS_BLANKZ(parser->buffer))
         {
             /* Check for an escaped single quote. */
 
-            if (single && CHECK_AT(parser, '\'', 0) && CHECK_AT(parser, '\'', 1))
+            if (single && CHECK_AT(parser->buffer, '\'', 0)
+                    && CHECK_AT(parser->buffer, '\'', 1))
             {
                 if (!STRING_EXTEND(parser, string)) goto error;
                 *(string.pointer++) = '\'';
@@ -3291,14 +3077,15 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
             /* Check for the right quote. */
 
-            else if (CHECK(parser, single ? '\'' : '"'))
+            else if (CHECK(parser->buffer, single ? '\'' : '"'))
             {
                 break;
             }
 
             /* Check for an escaped line break. */
 
-            else if (!single && CHECK(parser, '\\') && IS_BREAK_AT(parser, 1))
+            else if (!single && CHECK(parser->buffer, '\\')
+                    && IS_BREAK_AT(parser->buffer, 1))
             {
                 if (!CACHE(parser, 3)) goto error;
                 SKIP(parser);
@@ -3309,7 +3096,7 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
             /* Check for an escape sequence. */
 
-            else if (!single && CHECK(parser, '\\'))
+            else if (!single && CHECK(parser->buffer, '\\'))
             {
                 int code_length = 0;
 
@@ -3427,12 +3214,12 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
                     if (!CACHE(parser, code_length)) goto error;
 
                     for (k = 0; k < code_length; k ++) {
-                        if (!IS_HEX_AT(parser, k)) {
+                        if (!IS_HEX_AT(parser->buffer, k)) {
                             yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
                                     start_mark, "did not find expected hexdecimal number");
                             goto error;
                         }
-                        value = (value << 4) + AS_HEX_AT(parser, k);
+                        value = (value << 4) + AS_HEX_AT(parser->buffer, k);
                     }
 
                     /* Check the value and write the character. */
@@ -3482,16 +3269,16 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
 
         /* Check if we are at the end of the scalar. */
 
-        if (CHECK(parser, single ? '\'' : '"'))
+        if (CHECK(parser->buffer, single ? '\'' : '"'))
             break;
 
         /* Consume blank characters. */
 
         if (!CACHE(parser, 1)) goto error;
 
-        while (IS_BLANK(parser) || IS_BREAK(parser))
+        while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
         {
-            if (IS_BLANK(parser))
+            if (IS_BLANK(parser->buffer))
             {
                 /* Consume a space or a tab character. */
 
@@ -3601,7 +3388,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
     if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
     if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error;
 
-    start_mark = parser->mark;
+    start_mark = end_mark = parser->mark;
 
     /* Consume the content of the plain scalar. */
 
@@ -3612,26 +3399,28 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
         if (!CACHE(parser, 4)) goto error;
 
         if (parser->mark.column == 0 &&
-            ((CHECK_AT(parser, '-', 0) &&
-              CHECK_AT(parser, '-', 1) &&
-              CHECK_AT(parser, '-', 2)) ||
-             (CHECK_AT(parser, '.', 0) &&
-              CHECK_AT(parser, '.', 1) &&
-              CHECK_AT(parser, '.', 2))) &&
-            IS_BLANKZ_AT(parser, 3)) break;
+            ((CHECK_AT(parser->buffer, '-', 0) &&
+              CHECK_AT(parser->buffer, '-', 1) &&
+              CHECK_AT(parser->buffer, '-', 2)) ||
+             (CHECK_AT(parser->buffer, '.', 0) &&
+              CHECK_AT(parser->buffer, '.', 1) &&
+              CHECK_AT(parser->buffer, '.', 2))) &&
+            IS_BLANKZ_AT(parser->buffer, 3)) break;
 
         /* Check for a comment. */
 
-        if (CHECK(parser, '#'))
+        if (CHECK(parser->buffer, '#'))
             break;
 
         /* Consume non-blank characters. */
 
-        while (!IS_BLANKZ(parser))
+        while (!IS_BLANKZ(parser->buffer))
         {
             /* Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". */
 
-            if (parser->flow_level && CHECK(parser, ':') && !IS_BLANKZ_AT(parser, 1)) {
+            if (parser->flow_level
+                    && CHECK(parser->buffer, ':')
+                    && !IS_BLANKZ_AT(parser->buffer, 1)) {
                 yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
                         start_mark, "found unexpected ':'");
                 goto error;
@@ -3639,12 +3428,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
 
             /* Check for indicators that may end a plain scalar. */
 
-            if ((CHECK(parser, ':') && IS_BLANKZ_AT(parser, 1)) ||
-                    (parser->flow_level &&
-                     (CHECK(parser, ',') || CHECK(parser, ':') ||
-                      CHECK(parser, '?') || CHECK(parser, '[') ||
-                      CHECK(parser, ']') || CHECK(parser, '{') ||
-                      CHECK(parser, '}'))))
+            if ((CHECK(parser->buffer, ':') && IS_BLANKZ_AT(parser->buffer, 1))
+                    || (parser->flow_level &&
+                        (CHECK(parser->buffer, ',') || CHECK(parser->buffer, ':')
+                         || CHECK(parser->buffer, '?') || CHECK(parser->buffer, '[')
+                         || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
+                         || CHECK(parser->buffer, '}'))))
                 break;
 
             /* Check if we need to join whitespaces and breaks. */
@@ -3693,20 +3482,21 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
 
         /* Is it the end? */
 
-        if (!(IS_BLANK(parser) || IS_BREAK(parser)))
+        if (!(IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer)))
             break;
 
         /* Consume blank characters. */
 
         if (!CACHE(parser, 1)) goto error;
 
-        while (IS_BLANK(parser) || IS_BREAK(parser))
+        while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
         {
-            if (IS_BLANK(parser))
+            if (IS_BLANK(parser->buffer))
             {
                 /* Check for tab character that abuse intendation. */
 
-                if (leading_blanks && parser->mark.column < indent && IS_TAB(parser)) {
+                if (leading_blanks && parser->mark.column < indent
+                        && IS_TAB(parser->buffer)) {
                     yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
                             start_mark, "found a tab character that violate intendation");
                     goto error;
This page took 0.092809 seconds and 4 git commands to generate.