"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/gopkg.in/yaml.v2/scannerc.go" between
kubernetes-1.15.9.tar.gz and kubernetes-1.15.10.tar.gz

About: Kubernetes is a platform for automating deployment, scaling, and operations of application containers across clusters of hosts (written in "Go"). 1.15.x series.

scannerc.go  (kubernetes-1.15.9):scannerc.go  (kubernetes-1.15.10)
skipping to change at line 629 skipping to change at line 629
fmt.Println(pargs...) fmt.Println(pargs...)
pargs = append([]interface{}{"---"}, args...) pargs = append([]interface{}{"---"}, args...)
return func() { fmt.Println(pargs...) } return func() { fmt.Println(pargs...) }
} }
// Ensure that the tokens queue contains at least one token which can be // Ensure that the tokens queue contains at least one token which can be
// returned to the Parser. // returned to the Parser.
func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool {
// While we need more tokens to fetch, do it. // While we need more tokens to fetch, do it.
for { for {
// Check if we really need to fetch more tokens. if parser.tokens_head != len(parser.tokens) {
need_more_tokens := false // If queue is non-empty, check if any potential simple k
ey may
if parser.tokens_head == len(parser.tokens) { // occupy the head position.
// Queue is empty. head_tok_idx, ok := parser.simple_keys_by_tok[parser.toke
need_more_tokens = true ns_parsed]
} else { if !ok {
// Check if any potential simple key may occupy the head break
position. } else if valid, ok := yaml_simple_key_is_valid(parser, &
if !yaml_parser_stale_simple_keys(parser) { parser.simple_keys[head_tok_idx]); !ok {
return false return false
} } else if !valid {
break
for i := range parser.simple_keys {
simple_key := &parser.simple_keys[i]
if simple_key.possible && simple_key.token_number
== parser.tokens_parsed {
need_more_tokens = true
break
}
} }
} }
// We are finished.
if !need_more_tokens {
break
}
// Fetch the next token. // Fetch the next token.
if !yaml_parser_fetch_next_token(parser) { if !yaml_parser_fetch_next_token(parser) {
return false return false
} }
} }
parser.token_available = true parser.token_available = true
return true return true
} }
skipping to change at line 681 skipping to change at line 668
// Check if we just started scanning. Fetch STREAM-START then. // Check if we just started scanning. Fetch STREAM-START then.
if !parser.stream_start_produced { if !parser.stream_start_produced {
return yaml_parser_fetch_stream_start(parser) return yaml_parser_fetch_stream_start(parser)
} }
// Eat whitespaces and comments until we reach the next token. // Eat whitespaces and comments until we reach the next token.
if !yaml_parser_scan_to_next_token(parser) { if !yaml_parser_scan_to_next_token(parser) {
return false return false
} }
// Remove obsolete potential simple keys.
if !yaml_parser_stale_simple_keys(parser) {
return false
}
// Check the indentation level against the current column. // Check the indentation level against the current column.
if !yaml_parser_unroll_indent(parser, parser.mark.column) { if !yaml_parser_unroll_indent(parser, parser.mark.column) {
return false return false
} }
// Ensure that the buffer contains at least 4 characters. 4 is the lengt h // Ensure that the buffer contains at least 4 characters. 4 is the lengt h
// of the longest indicators ('--- ' and '... '). // of the longest indicators ('--- ' and '... ').
if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {
return false return false
} }
skipping to change at line 840 skipping to change at line 822
!is_blankz(parser.buffer, parser.buffer_pos+1)) { !is_blankz(parser.buffer, parser.buffer_pos+1)) {
return yaml_parser_fetch_plain_scalar(parser) return yaml_parser_fetch_plain_scalar(parser)
} }
// If we don't determine the token type so far, it is an error. // If we don't determine the token type so far, it is an error.
return yaml_parser_set_scanner_error(parser, return yaml_parser_set_scanner_error(parser,
"while scanning for the next token", parser.mark, "while scanning for the next token", parser.mark,
"found character that cannot start any token") "found character that cannot start any token")
} }
// Check the list of potential simple keys and remove the positions that func yaml_simple_key_is_valid(parser *yaml_parser_t, simple_key *yaml_simple_key
// cannot contain simple keys anymore. _t) (valid, ok bool) {
func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { if !simple_key.possible {
// Check for a potential simple key for each flow level. return false, true
for i := range parser.simple_keys { }
simple_key := &parser.simple_keys[i]
// The 1.2 specification says:
// The specification requires that a simple key //
// // "If the ? indicator is omitted, parsing needs to see past the
// - is limited to a single line, // implicit key to recognize it as such. To limit the amount of
// - is shorter than 1024 characters. // lookahead required, the “:” indicator must appear at most 1024
if simple_key.possible && (simple_key.mark.line < parser.mark.lin // Unicode characters beyond the start of the key. In addition, the k
e || simple_key.mark.index+1024 < parser.mark.index) { ey
// is restricted to a single line."
// Check if the potential simple key to be removed is req //
uired. if simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024
if simple_key.required { < parser.mark.index {
return yaml_parser_set_scanner_error(parser, // Check if the potential simple key to be removed is required.
"while scanning a simple key", simple_key if simple_key.required {
.mark, return false, yaml_parser_set_scanner_error(parser,
"could not find expected ':'") "while scanning a simple key", simple_key.mark,
} "could not find expected ':'")
simple_key.possible = false
} }
simple_key.possible = false
return false, true
} }
return true return true, true
} }
// Check if a simple key may start at the current position and add it if // Check if a simple key may start at the current position and add it if
// needed. // needed.
func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { func yaml_parser_save_simple_key(parser *yaml_parser_t) bool {
// A simple key is required at the current position if the scanner is in // A simple key is required at the current position if the scanner is in
// the block context and the current column coincides with the indentatio n // the block context and the current column coincides with the indentatio n
// level. // level.
required := parser.flow_level == 0 && parser.indent == parser.mark.column required := parser.flow_level == 0 && parser.indent == parser.mark.column
// //
// If the current position may start a simple key, save it. // If the current position may start a simple key, save it.
// //
if parser.simple_key_allowed { if parser.simple_key_allowed {
simple_key := yaml_simple_key_t{ simple_key := yaml_simple_key_t{
possible: true, possible: true,
required: required, required: required,
token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head),
mark: parser.mark,
} }
simple_key.mark = parser.mark
if !yaml_parser_remove_simple_key(parser) { if !yaml_parser_remove_simple_key(parser) {
return false return false
} }
parser.simple_keys[len(parser.simple_keys)-1] = simple_key parser.simple_keys[len(parser.simple_keys)-1] = simple_key
parser.simple_keys_by_tok[simple_key.token_number] = len(parser.s imple_keys) - 1
} }
return true return true
} }
// Remove a potential simple key at the current flow level. // Remove a potential simple key at the current flow level.
func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool {
i := len(parser.simple_keys) - 1 i := len(parser.simple_keys) - 1
if parser.simple_keys[i].possible { if parser.simple_keys[i].possible {
// If the key is required, it is an error. // If the key is required, it is an error.
if parser.simple_keys[i].required { if parser.simple_keys[i].required {
return yaml_parser_set_scanner_error(parser, return yaml_parser_set_scanner_error(parser,
"while scanning a simple key", parser.simple_keys [i].mark, "while scanning a simple key", parser.simple_keys [i].mark,
"could not find expected ':'") "could not find expected ':'")
} }
// Remove the key from the stack.
parser.simple_keys[i].possible = false
delete(parser.simple_keys_by_tok, parser.simple_keys[i].token_num
ber)
} }
// Remove the key from the stack.
parser.simple_keys[i].possible = false
return true return true
} }
// max_flow_level limits the flow_level // max_flow_level limits the flow_level
const max_flow_level = 10000 const max_flow_level = 10000
// Increase the flow level and resize the simple key list if needed. // Increase the flow level and resize the simple key list if needed.
func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool {
// Reset the simple key on the next level. // Reset the simple key on the next level.
parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{
possible: false,
required: false,
token_number: parser.tokens_parsed + (len(parser.tokens) - parser
.tokens_head),
mark: parser.mark,
})
// Increase the flow level. // Increase the flow level.
parser.flow_level++ parser.flow_level++
if parser.flow_level > max_flow_level { if parser.flow_level > max_flow_level {
return yaml_parser_set_scanner_error(parser, return yaml_parser_set_scanner_error(parser,
"while increasing flow level", parser.simple_keys[len(par ser.simple_keys)-1].mark, "while increasing flow level", parser.simple_keys[len(par ser.simple_keys)-1].mark,
fmt.Sprintf("exceeded max depth of %d", max_flow_level)) fmt.Sprintf("exceeded max depth of %d", max_flow_level))
} }
return true return true
} }
// Decrease the flow level. // Decrease the flow level.
func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool {
if parser.flow_level > 0 { if parser.flow_level > 0 {
parser.flow_level-- parser.flow_level--
parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)- last := len(parser.simple_keys) - 1
1] delete(parser.simple_keys_by_tok, parser.simple_keys[last].token_
number)
parser.simple_keys = parser.simple_keys[:last]
} }
return true return true
} }
// max_indents limits the indents stack size // max_indents limits the indents stack size
const max_indents = 10000 const max_indents = 10000
// Push the current indentation level to the stack and set the new level // Push the current indentation level to the stack and set the new level
// the current column is greater than the indentation level. In this case, // the current column is greater than the indentation level. In this case,
// append or insert the specified token into the token queue. // append or insert the specified token into the token queue.
skipping to change at line 1008 skipping to change at line 1000
// Initialize the scanner and produce the STREAM-START token. // Initialize the scanner and produce the STREAM-START token.
func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool {
// Set the initial indentation. // Set the initial indentation.
parser.indent = -1 parser.indent = -1
// Initialize the simple key stack. // Initialize the simple key stack.
parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{})
parser.simple_keys_by_tok = make(map[int]int)
// A simple key is allowed at the beginning of the stream. // A simple key is allowed at the beginning of the stream.
parser.simple_key_allowed = true parser.simple_key_allowed = true
// We have started. // We have started.
parser.stream_start_produced = true parser.stream_start_produced = true
// Create the STREAM-START token and append it to the queue. // Create the STREAM-START token and append it to the queue.
token := yaml_token_t{ token := yaml_token_t{
typ: yaml_STREAM_START_TOKEN, typ: yaml_STREAM_START_TOKEN,
start_mark: parser.mark, start_mark: parser.mark,
skipping to change at line 1289 skipping to change at line 1283
yaml_insert_token(parser, -1, &token) yaml_insert_token(parser, -1, &token)
return true return true
} }
// Produce the VALUE token. // Produce the VALUE token.
func yaml_parser_fetch_value(parser *yaml_parser_t) bool { func yaml_parser_fetch_value(parser *yaml_parser_t) bool {
simple_key := &parser.simple_keys[len(parser.simple_keys)-1] simple_key := &parser.simple_keys[len(parser.simple_keys)-1]
// Have we found a simple key? // Have we found a simple key?
if simple_key.possible { if valid, ok := yaml_simple_key_is_valid(parser, simple_key); !ok {
return false
} else if valid {
// Create the KEY token and insert it into the queue. // Create the KEY token and insert it into the queue.
token := yaml_token_t{ token := yaml_token_t{
typ: yaml_KEY_TOKEN, typ: yaml_KEY_TOKEN,
start_mark: simple_key.mark, start_mark: simple_key.mark,
end_mark: simple_key.mark, end_mark: simple_key.mark,
} }
yaml_insert_token(parser, simple_key.token_number-parser.tokens_p arsed, &token) yaml_insert_token(parser, simple_key.token_number-parser.tokens_p arsed, &token)
// In the block context, we may need to add the BLOCK-MAPPING-STA RT token. // In the block context, we may need to add the BLOCK-MAPPING-STA RT token.
if !yaml_parser_roll_indent(parser, simple_key.mark.column, if !yaml_parser_roll_indent(parser, simple_key.mark.column,
simple_key.token_number, simple_key.token_number,
yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) { yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) {
return false return false
} }
// Remove the simple key. // Remove the simple key.
simple_key.possible = false simple_key.possible = false
delete(parser.simple_keys_by_tok, simple_key.token_number)
// A simple key cannot follow another simple key. // A simple key cannot follow another simple key.
parser.simple_key_allowed = false parser.simple_key_allowed = false
} else { } else {
// The ':' indicator follows a complex key. // The ':' indicator follows a complex key.
// In the block context, extra checks are required. // In the block context, extra checks are required.
if parser.flow_level == 0 { if parser.flow_level == 0 {
 End of changes. 17 change blocks. 
60 lines changed or deleted 62 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)