mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Output from 'dep status': PROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED cloud.google.com/go v0.23.0 v0.23.0 0fd7230 v0.23.0 1 github.com/briandowns/openweathermap ^0.11.0 0.11 1b87579 0.11 1 github.com/gdamore/encoding branch master branch master b23993c b23993c 1 github.com/gdamore/tcell ^1.0.0 v1.0.0 061d51a v1.0.0 2 github.com/go-test/deep ^1.0.1 v1.0.1 6592d9c v1.0.1 1 github.com/golang/protobuf v1.1.0 v1.1.0 b4deda0 v1.1.0 1 github.com/google/go-github branch master branch master 2ae5df7 2ae5df7 1 github.com/google/go-querystring branch master branch master 53e6ce1 53e6ce1 1 github.com/jessevdk/go-flags ^1.4.0 v1.4.0 c6ca198 v1.4.0 1 github.com/lucasb-eyer/go-colorful v1.0 v1.0 345fbb3 v1.0 1 github.com/mattn/go-runewidth v0.0.2 v0.0.2 9e777a8 v0.0.2 1 github.com/olebedev/config branch master branch master 9a10d05 9a10d05 1 github.com/radovskyb/watcher ^1.0.2 v1.0.2 6145e14 v1.0.2 1 github.com/rivo/tview branch master branch master 71ecf1f 71ecf1f 1 github.com/yfronto/newrelic branch master branch master f7fa0c6 f7fa0c6 1 golang.org/x/net branch master branch master 1e49130 1e49130 2 golang.org/x/oauth2 branch master branch master 1e0a3fa 1e0a3fa 5 golang.org/x/text v0.3.0 v0.3.0 f21a4df v0.3.0 5 google.golang.org/api branch master branch master 00e3bb8 00e3bb8 4 google.golang.org/appengine v1.0.0 v1.0.0 150dc57 v1.0.0 10 gopkg.in/yaml.v2 ^2.2.1 v2.2.1 5420a8b v2.2.1 1 See https://golang.github.io/dep/docs/daily-dep.html
174 lines
4.8 KiB
Go
174 lines
4.8 KiB
Go
package yaml
|
|
|
|
const (
|
|
// The size of the input raw buffer.
|
|
input_raw_buffer_size = 512
|
|
|
|
// The size of the input buffer.
|
|
// It should be possible to decode the whole raw buffer.
|
|
input_buffer_size = input_raw_buffer_size * 3
|
|
|
|
// The size of the output buffer.
|
|
output_buffer_size = 128
|
|
|
|
// The size of the output raw buffer.
|
|
// It should be possible to encode the whole output buffer.
|
|
output_raw_buffer_size = (output_buffer_size*2 + 2)
|
|
|
|
// The size of other stacks and queues.
|
|
initial_stack_size = 16
|
|
initial_queue_size = 16
|
|
initial_string_size = 16
|
|
)
|
|
|
|
// Check if the character at the specified position is an alphabetical
|
|
// character, a digit, '_', or '-'.
|
|
func is_alpha(b []byte, i int) bool {
|
|
return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-'
|
|
}
|
|
|
|
// Check if the character at the specified position is a digit.
|
|
func is_digit(b []byte, i int) bool {
|
|
return b[i] >= '0' && b[i] <= '9'
|
|
}
|
|
|
|
// Get the value of a digit.
|
|
func as_digit(b []byte, i int) int {
|
|
return int(b[i]) - '0'
|
|
}
|
|
|
|
// Check if the character at the specified position is a hex-digit.
|
|
func is_hex(b []byte, i int) bool {
|
|
return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f'
|
|
}
|
|
|
|
// Get the value of a hex-digit.
|
|
func as_hex(b []byte, i int) int {
|
|
bi := b[i]
|
|
if bi >= 'A' && bi <= 'F' {
|
|
return int(bi) - 'A' + 10
|
|
}
|
|
if bi >= 'a' && bi <= 'f' {
|
|
return int(bi) - 'a' + 10
|
|
}
|
|
return int(bi) - '0'
|
|
}
|
|
|
|
// Check if the character is ASCII.
|
|
func is_ascii(b []byte, i int) bool {
|
|
return b[i] <= 0x7F
|
|
}
|
|
|
|
// Check if the character at the start of the buffer can be printed unescaped.
|
|
func is_printable(b []byte, i int) bool {
|
|
return ((b[i] == 0x0A) || // . == #x0A
|
|
(b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E
|
|
(b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF
|
|
(b[i] > 0xC2 && b[i] < 0xED) ||
|
|
(b[i] == 0xED && b[i+1] < 0xA0) ||
|
|
(b[i] == 0xEE) ||
|
|
(b[i] == 0xEF && // #xE000 <= . <= #xFFFD
|
|
!(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF
|
|
!(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF))))
|
|
}
|
|
|
|
// Check if the character at the specified position is NUL.
|
|
func is_z(b []byte, i int) bool {
|
|
return b[i] == 0x00
|
|
}
|
|
|
|
// Check if the beginning of the buffer is a BOM.
|
|
func is_bom(b []byte, i int) bool {
|
|
return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF
|
|
}
|
|
|
|
// Check if the character at the specified position is space.
|
|
func is_space(b []byte, i int) bool {
|
|
return b[i] == ' '
|
|
}
|
|
|
|
// Check if the character at the specified position is tab.
|
|
func is_tab(b []byte, i int) bool {
|
|
return b[i] == '\t'
|
|
}
|
|
|
|
// Check if the character at the specified position is blank (space or tab).
|
|
func is_blank(b []byte, i int) bool {
|
|
//return is_space(b, i) || is_tab(b, i)
|
|
return b[i] == ' ' || b[i] == '\t'
|
|
}
|
|
|
|
// Check if the character at the specified position is a line break.
|
|
func is_break(b []byte, i int) bool {
|
|
return (b[i] == '\r' || // CR (#xD)
|
|
b[i] == '\n' || // LF (#xA)
|
|
b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
|
|
b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
|
|
b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029)
|
|
}
|
|
|
|
func is_crlf(b []byte, i int) bool {
|
|
return b[i] == '\r' && b[i+1] == '\n'
|
|
}
|
|
|
|
// Check if the character is a line break or NUL.
|
|
func is_breakz(b []byte, i int) bool {
|
|
//return is_break(b, i) || is_z(b, i)
|
|
return ( // is_break:
|
|
b[i] == '\r' || // CR (#xD)
|
|
b[i] == '\n' || // LF (#xA)
|
|
b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
|
|
b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
|
|
b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
|
|
// is_z:
|
|
b[i] == 0)
|
|
}
|
|
|
|
// Check if the character is a line break, space, or NUL.
|
|
func is_spacez(b []byte, i int) bool {
|
|
//return is_space(b, i) || is_breakz(b, i)
|
|
return ( // is_space:
|
|
b[i] == ' ' ||
|
|
// is_breakz:
|
|
b[i] == '\r' || // CR (#xD)
|
|
b[i] == '\n' || // LF (#xA)
|
|
b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
|
|
b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
|
|
b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
|
|
b[i] == 0)
|
|
}
|
|
|
|
// Check if the character is a line break, space, tab, or NUL.
|
|
func is_blankz(b []byte, i int) bool {
|
|
//return is_blank(b, i) || is_breakz(b, i)
|
|
return ( // is_blank:
|
|
b[i] == ' ' || b[i] == '\t' ||
|
|
// is_breakz:
|
|
b[i] == '\r' || // CR (#xD)
|
|
b[i] == '\n' || // LF (#xA)
|
|
b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
|
|
b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
|
|
b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
|
|
b[i] == 0)
|
|
}
|
|
|
|
// Determine the width of the character.
|
|
func width(b byte) int {
|
|
// Don't replace these by a switch without first
|
|
// confirming that it is being inlined.
|
|
if b&0x80 == 0x00 {
|
|
return 1
|
|
}
|
|
if b&0xE0 == 0xC0 {
|
|
return 2
|
|
}
|
|
if b&0xF0 == 0xE0 {
|
|
return 3
|
|
}
|
|
if b&0xF8 == 0xF0 {
|
|
return 4
|
|
}
|
|
return 0
|
|
|
|
}
|