podman
1package yaml2
3const (4// The size of the input raw buffer.5input_raw_buffer_size = 5126
7// The size of the input buffer.8// It should be possible to decode the whole raw buffer.9input_buffer_size = input_raw_buffer_size * 310
11// The size of the output buffer.12output_buffer_size = 12813
14// The size of the output raw buffer.15// It should be possible to encode the whole output buffer.16output_raw_buffer_size = (output_buffer_size*2 + 2)17
18// The size of other stacks and queues.19initial_stack_size = 1620initial_queue_size = 1621initial_string_size = 1622)
23
24// Check if the character at the specified position is an alphabetical
25// character, a digit, '_', or '-'.
26func is_alpha(b []byte, i int) bool {27return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-'28}
29
30// Check if the character at the specified position is a digit.
31func is_digit(b []byte, i int) bool {32return b[i] >= '0' && b[i] <= '9'33}
34
35// Get the value of a digit.
36func as_digit(b []byte, i int) int {37return int(b[i]) - '0'38}
39
40// Check if the character at the specified position is a hex-digit.
41func is_hex(b []byte, i int) bool {42return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f'43}
44
45// Get the value of a hex-digit.
46func as_hex(b []byte, i int) int {47bi := b[i]48if bi >= 'A' && bi <= 'F' {49return int(bi) - 'A' + 1050}51if bi >= 'a' && bi <= 'f' {52return int(bi) - 'a' + 1053}54return int(bi) - '0'55}
56
57// Check if the character is ASCII.
58func is_ascii(b []byte, i int) bool {59return b[i] <= 0x7F60}
61
62// Check if the character at the start of the buffer can be printed unescaped.
63func is_printable(b []byte, i int) bool {64return ((b[i] == 0x0A) || // . == #x0A65(b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E66(b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF67(b[i] > 0xC2 && b[i] < 0xED) ||68(b[i] == 0xED && b[i+1] < 0xA0) ||69(b[i] == 0xEE) ||70(b[i] == 0xEF && // #xE000 <= . <= #xFFFD71!(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF72!(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF))))73}
74
75// Check if the character at the specified position is NUL.
76func is_z(b []byte, i int) bool {77return b[i] == 0x0078}
79
80// Check if the beginning of the buffer is a BOM.
81func is_bom(b []byte, i int) bool {82return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF83}
84
85// Check if the character at the specified position is space.
86func is_space(b []byte, i int) bool {87return b[i] == ' '88}
89
90// Check if the character at the specified position is tab.
91func is_tab(b []byte, i int) bool {92return b[i] == '\t'93}
94
95// Check if the character at the specified position is blank (space or tab).
96func is_blank(b []byte, i int) bool {97//return is_space(b, i) || is_tab(b, i)98return b[i] == ' ' || b[i] == '\t'99}
100
101// Check if the character at the specified position is a line break.
102func is_break(b []byte, i int) bool {103return (b[i] == '\r' || // CR (#xD)104b[i] == '\n' || // LF (#xA)105b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)106b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)107b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029)108}
109
110func is_crlf(b []byte, i int) bool {111return b[i] == '\r' && b[i+1] == '\n'112}
113
114// Check if the character is a line break or NUL.
115func is_breakz(b []byte, i int) bool {116//return is_break(b, i) || is_z(b, i)117return ( // is_break:118b[i] == '\r' || // CR (#xD)119b[i] == '\n' || // LF (#xA)120b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)121b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)122b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)123// is_z:124b[i] == 0)125}
126
127// Check if the character is a line break, space, or NUL.
128func is_spacez(b []byte, i int) bool {129//return is_space(b, i) || is_breakz(b, i)130return ( // is_space:131b[i] == ' ' ||132// is_breakz:133b[i] == '\r' || // CR (#xD)134b[i] == '\n' || // LF (#xA)135b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)136b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)137b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)138b[i] == 0)139}
140
141// Check if the character is a line break, space, tab, or NUL.
142func is_blankz(b []byte, i int) bool {143//return is_blank(b, i) || is_breakz(b, i)144return ( // is_blank:145b[i] == ' ' || b[i] == '\t' ||146// is_breakz:147b[i] == '\r' || // CR (#xD)148b[i] == '\n' || // LF (#xA)149b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)150b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)151b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)152b[i] == 0)153}
154
155// Determine the width of the character.
156func width(b byte) int {157// Don't replace these by a switch without first158// confirming that it is being inlined.159if b&0x80 == 0x00 {160return 1161}162if b&0xE0 == 0xC0 {163return 2164}165if b&0xF0 == 0xE0 {166return 3167}168if b&0xF8 == 0xF0 {169return 4170}171return 0172
173}
174