nolint:cyclop // No clean way to split this.
(q []byte)
| 196 | |
| 197 | //nolint:cyclop // No clean way to split this. |
| 198 | func skipLeadingComments(q []byte) []byte { |
| 199 | for len(q) > 0 { |
| 200 | switch q[0] { |
| 201 | case '\t', '\n', '\v', '\f', '\r', ' ': |
| 202 | q = q[1:] |
| 203 | case '-': |
| 204 | if len(q) < 2 || q[1] != '-' { |
| 205 | return q |
| 206 | } |
| 207 | |
| 208 | // skip `-- comment` |
| 209 | n := bytes.IndexByte(q, '\n') |
| 210 | if n < 0 { |
| 211 | return nil |
| 212 | } |
| 213 | q = q[n+1:] |
| 214 | case '/': |
| 215 | if len(q) < 2 || q[1] != '*' { |
| 216 | return q |
| 217 | } |
| 218 | |
| 219 | // skip `/* comment */` |
| 220 | for { |
| 221 | n := bytes.IndexByte(q, '*') |
| 222 | if n < 0 { |
| 223 | return nil |
| 224 | } |
| 225 | q = q[n+1:] |
| 226 | if len(q) == 0 { |
| 227 | return nil |
| 228 | } |
| 229 | if q[0] == '/' { |
| 230 | q = q[1:] |
| 231 | break |
| 232 | } |
| 233 | } |
| 234 | default: |
| 235 | return q |
| 236 | } |
| 237 | } |
| 238 | return nil |
| 239 | } |
| 240 | |
| 241 | // splits header string in sorted slice |
| 242 | func sortHeader(header string) string { |
no outgoing calls