Update upstream source from tag 'upstream/2.4.0'
Update to upstream version '2.4.0'
with Debian dir d77de48afd34538df52af976a595677d46516a73
Anthony Fok
3 years ago
78 | 78 |
parser.encoding = encoding
|
79 | 79 |
}
|
80 | 80 |
|
|
81 |
var disableLineWrapping = false
|
|
82 |
|
81 | 83 |
// Create a new emitter object.
|
82 | 84 |
func yaml_emitter_initialize(emitter *yaml_emitter_t) {
|
83 | 85 |
*emitter = yaml_emitter_t{
|
|
85 | 87 |
raw_buffer: make([]byte, 0, output_raw_buffer_size),
|
86 | 88 |
states: make([]yaml_emitter_state_t, 0, initial_stack_size),
|
87 | 89 |
events: make([]yaml_event_t, 0, initial_queue_size),
|
88 | |
best_width: -1,
|
|
90 |
}
|
|
91 |
if disableLineWrapping {
|
|
92 |
emitter.best_width = -1
|
89 | 93 |
}
|
90 | 94 |
}
|
91 | 95 |
|
396 | 396 |
map[string]interface{}{"a": jsonNumberT("bogus")},
|
397 | 397 |
"a: bogus\n",
|
398 | 398 |
},
|
399 | |
// Ensure that strings do not wrap
|
400 | |
{
|
401 | |
map[string]string{"a": "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 "},
|
402 | |
"a: 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 '\n",
|
403 | |
},
|
|
399 |
}
|
|
400 |
|
|
401 |
func (s *S) TestLineWrapping(c *C) {
|
|
402 |
var v = map[string]string{
|
|
403 |
"a": "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 ",
|
|
404 |
}
|
|
405 |
data, err := yaml.Marshal(v)
|
|
406 |
c.Assert(err, IsNil)
|
|
407 |
c.Assert(string(data), Equals,
|
|
408 |
"a: 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 abcdefghijklmnopqrstuvwxyz\n" +
|
|
409 |
" ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 '\n")
|
|
410 |
|
|
411 |
// The API does not allow this process to be reversed as it's intended
|
|
412 |
// for migration only. v3 drops this method and instead offers more
|
|
413 |
// control on a per encoding basis.
|
|
414 |
yaml.FutureLineWrap()
|
|
415 |
|
|
416 |
data, err = yaml.Marshal(v)
|
|
417 |
c.Assert(err, IsNil)
|
|
418 |
c.Assert(string(data), Equals,
|
|
419 |
"a: 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 '\n")
|
404 | 420 |
}
|
405 | 421 |
|
406 | 422 |
func (s *S) TestMarshal(c *C) {
|
0 | |
module "gopkg.in/yaml.v2"
|
|
0 |
module gopkg.in/yaml.v2
|
1 | 1 |
|
2 | |
require (
|
3 | |
"gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405
|
4 | |
)
|
|
2 |
go 1.15
|
|
3 |
|
|
4 |
require gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
|
174 | 174 |
// Zero valued structs will be omitted if all their public
|
175 | 175 |
// fields are zero, unless they implement an IsZero
|
176 | 176 |
// method (see the IsZeroer interface type), in which
|
177 | |
// case the field will be included if that method returns true.
|
|
177 |
// case the field will be excluded if IsZero returns true.
|
178 | 178 |
//
|
179 | 179 |
// flow Marshal using a flow style (useful for structs,
|
180 | 180 |
// sequences and maps).
|
|
463 | 463 |
}
|
464 | 464 |
return false
|
465 | 465 |
}
|
|
466 |
|
|
467 |
// FutureLineWrap globally disables line wrapping when encoding long strings.
|
|
468 |
// This is a temporary and thus deprecated method introduced to faciliate
|
|
469 |
// migration towards v3, which offers more control of line lengths on
|
|
470 |
// individual encodings, and has a default matching the behavior introduced
|
|
471 |
// by this function.
|
|
472 |
//
|
|
473 |
// The default formatting of v2 was erroneously changed in v2.3.0 and reverted
|
|
474 |
// in v2.4.0, at which point this function was introduced to help migration.
|
|
475 |
func FutureLineWrap() {
|
|
476 |
disableLineWrapping = true
|
|
477 |
}
|