From 331597b9f8a7942cbcb233a328301e4d5bf94fb0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 11 Jan 2019 23:28:47 +0200 Subject: Switch to Go modules and make other changes --- Gopkg.lock | 219 -- Gopkg.toml | 82 - go.mod | 19 + go.sum | 40 + interface/ui.go | 1 - lib/bfhtml/html.go | 2 +- matrix/matrix.go | 8 +- matrix/sync.go | 11 +- ui/commands.go | 3 +- ui/fuzzy-search-modal.go | 2 +- ui/messages/parser/parser.go | 112 +- ui/room-list.go | 2 +- ui/room-view.go | 6 +- vendor/github.com/davecgh/go-spew/LICENSE | 15 - vendor/github.com/davecgh/go-spew/spew/bypass.go | 145 -- .../github.com/davecgh/go-spew/spew/bypasssafe.go | 38 - vendor/github.com/davecgh/go-spew/spew/common.go | 341 --- vendor/github.com/davecgh/go-spew/spew/config.go | 306 --- vendor/github.com/davecgh/go-spew/spew/doc.go | 211 -- vendor/github.com/davecgh/go-spew/spew/dump.go | 509 ---- vendor/github.com/davecgh/go-spew/spew/format.go | 419 --- vendor/github.com/davecgh/go-spew/spew/spew.go | 148 -- .../github.com/disintegration/imaging/.travis.yml | 13 - vendor/github.com/disintegration/imaging/LICENSE | 21 - vendor/github.com/disintegration/imaging/README.md | 188 -- vendor/github.com/disintegration/imaging/adjust.go | 222 -- .../disintegration/imaging/convolution.go | 146 -- vendor/github.com/disintegration/imaging/doc.go | 7 - .../github.com/disintegration/imaging/effects.go | 173 -- .../github.com/disintegration/imaging/histogram.go | 51 - vendor/github.com/disintegration/imaging/io.go | 463 ---- vendor/github.com/disintegration/imaging/resize.go | 572 ----- .../github.com/disintegration/imaging/scanner.go | 250 -- vendor/github.com/disintegration/imaging/tools.go | 247 -- .../github.com/disintegration/imaging/transform.go | 271 -- vendor/github.com/disintegration/imaging/utils.go | 83 - vendor/github.com/gdamore/encoding/.appveyor.yml | 13 - vendor/github.com/gdamore/encoding/.travis.yml | 6 - vendor/github.com/gdamore/encoding/LICENSE | 202 -- vendor/github.com/gdamore/encoding/README.md | 19 - vendor/github.com/gdamore/encoding/ascii.go | 36 - vendor/github.com/gdamore/encoding/charmap.go | 192 -- vendor/github.com/gdamore/encoding/doc.go | 17 - vendor/github.com/gdamore/encoding/ebcdic.go | 273 -- vendor/github.com/gdamore/encoding/latin1.go | 33 - vendor/github.com/gdamore/encoding/latin5.go | 35 - vendor/github.com/gdamore/encoding/utf8.go | 35 - vendor/github.com/kyokomi/emoji/.gitignore | 2 - vendor/github.com/kyokomi/emoji/LICENSE | 21 - vendor/github.com/kyokomi/emoji/README.md | 53 - vendor/github.com/kyokomi/emoji/emoji.go | 153 -- vendor/github.com/kyokomi/emoji/emoji_codemap.go | 1517 ----------- vendor/github.com/kyokomi/emoji/wercker.yml | 25 - .../github.com/lucasb-eyer/go-colorful/.gitignore | 28 - .../github.com/lucasb-eyer/go-colorful/.travis.yml | 8 - vendor/github.com/lucasb-eyer/go-colorful/LICENSE | 7 - .../github.com/lucasb-eyer/go-colorful/README.md | 488 ---- .../lucasb-eyer/go-colorful/colorgens.go | 55 - .../github.com/lucasb-eyer/go-colorful/colors.go | 819 ------ .../lucasb-eyer/go-colorful/happy_palettegen.go | 25 - .../github.com/lucasb-eyer/go-colorful/hexcolor.go | 37 - .../lucasb-eyer/go-colorful/soft_palettegen.go | 185 -- .../lucasb-eyer/go-colorful/warm_palettegen.go | 25 - vendor/github.com/mattn/go-runewidth/.travis.yml | 8 - vendor/github.com/mattn/go-runewidth/LICENSE | 21 - vendor/github.com/mattn/go-runewidth/README.mkd | 27 - vendor/github.com/mattn/go-runewidth/runewidth.go | 1235 --------- .../github.com/mattn/go-runewidth/runewidth_js.go | 8 - .../mattn/go-runewidth/runewidth_posix.go | 77 - .../mattn/go-runewidth/runewidth_windows.go | 25 - vendor/github.com/nu7hatch/gouuid/.gitignore | 11 - vendor/github.com/nu7hatch/gouuid/COPYING | 19 - vendor/github.com/nu7hatch/gouuid/README.md | 21 - vendor/github.com/nu7hatch/gouuid/uuid.go | 173 -- vendor/github.com/pmezard/go-difflib/LICENSE | 27 - .../pmezard/go-difflib/difflib/difflib.go | 772 ------ vendor/github.com/renstrom/fuzzysearch/LICENSE | 21 - .../github.com/renstrom/fuzzysearch/fuzzy/fuzzy.go | 173 -- .../renstrom/fuzzysearch/fuzzy/levenshtein.go | 43 - .../shurcooL/sanitized_anchor_name/.travis.yml | 16 - .../shurcooL/sanitized_anchor_name/LICENSE | 21 - .../shurcooL/sanitized_anchor_name/README.md | 36 - .../shurcooL/sanitized_anchor_name/main.go | 29 - vendor/github.com/stretchr/testify/LICENSE | 22 - .../stretchr/testify/assert/assertion_format.go | 484 ---- .../testify/assert/assertion_format.go.tmpl | 5 - .../stretchr/testify/assert/assertion_forward.go | 956 ------- .../testify/assert/assertion_forward.go.tmpl | 5 - .../stretchr/testify/assert/assertions.go | 1394 ---------- vendor/github.com/stretchr/testify/assert/doc.go | 45 - .../github.com/stretchr/testify/assert/errors.go | 10 - .../stretchr/testify/assert/forward_assertions.go | 16 - .../stretchr/testify/assert/http_assertions.go | 143 -- vendor/github.com/zyedidia/clipboard/.travis.yml | 18 - vendor/github.com/zyedidia/clipboard/LICENSE | 31 - vendor/github.com/zyedidia/clipboard/README.md | 54 - vendor/github.com/zyedidia/clipboard/clipboard.go | 22 - .../zyedidia/clipboard/clipboard_darwin.go | 58 - .../zyedidia/clipboard/clipboard_unix.go | 105 - .../zyedidia/clipboard/clipboard_windows.go | 107 - vendor/golang.org/x/image/AUTHORS | 3 - vendor/golang.org/x/image/CONTRIBUTORS | 3 - vendor/golang.org/x/image/LICENSE | 27 - vendor/golang.org/x/image/PATENTS | 22 - vendor/golang.org/x/image/bmp/reader.go | 213 -- vendor/golang.org/x/image/bmp/writer.go | 262 -- vendor/golang.org/x/image/riff/riff.go | 193 -- vendor/golang.org/x/image/tiff/buffer.go | 69 - vendor/golang.org/x/image/tiff/compress.go | 58 - vendor/golang.org/x/image/tiff/consts.go | 133 - vendor/golang.org/x/image/tiff/lzw/reader.go | 272 -- vendor/golang.org/x/image/tiff/reader.go | 684 ----- vendor/golang.org/x/image/tiff/writer.go | 438 ---- vendor/golang.org/x/image/vp8/decode.go | 403 --- vendor/golang.org/x/image/vp8/filter.go | 273 -- vendor/golang.org/x/image/vp8/idct.go | 98 - vendor/golang.org/x/image/vp8/partition.go | 129 - vendor/golang.org/x/image/vp8/pred.go | 201 -- vendor/golang.org/x/image/vp8/predfunc.go | 553 ---- vendor/golang.org/x/image/vp8/quant.go | 98 - vendor/golang.org/x/image/vp8/reconstruct.go | 442 ---- vendor/golang.org/x/image/vp8/token.go | 381 --- vendor/golang.org/x/image/vp8l/decode.go | 603 ----- vendor/golang.org/x/image/vp8l/huffman.go | 245 -- vendor/golang.org/x/image/vp8l/transform.go | 299 --- vendor/golang.org/x/image/webp/decode.go | 270 -- vendor/golang.org/x/image/webp/doc.go | 9 - vendor/golang.org/x/net/AUTHORS | 3 - vendor/golang.org/x/net/CONTRIBUTORS | 3 - vendor/golang.org/x/net/LICENSE | 27 - vendor/golang.org/x/net/PATENTS | 22 - vendor/golang.org/x/net/html/atom/atom.go | 78 - vendor/golang.org/x/net/html/atom/gen.go | 712 ------ vendor/golang.org/x/net/html/atom/table.go | 783 ------ vendor/golang.org/x/net/html/const.go | 112 - vendor/golang.org/x/net/html/doc.go | 106 - vendor/golang.org/x/net/html/doctype.go | 156 -- vendor/golang.org/x/net/html/entity.go | 2253 ---------------- vendor/golang.org/x/net/html/escape.go | 258 -- vendor/golang.org/x/net/html/foreign.go | 226 -- vendor/golang.org/x/net/html/node.go | 220 -- vendor/golang.org/x/net/html/parse.go | 2311 ----------------- vendor/golang.org/x/net/html/render.go | 271 -- vendor/golang.org/x/net/html/token.go | 1219 --------- vendor/golang.org/x/text/AUTHORS | 3 - vendor/golang.org/x/text/CONTRIBUTORS | 3 - vendor/golang.org/x/text/LICENSE | 27 - vendor/golang.org/x/text/PATENTS | 22 - vendor/golang.org/x/text/encoding/encoding.go | 335 --- .../x/text/encoding/internal/identifier/gen.go | 137 - .../encoding/internal/identifier/identifier.go | 81 - .../x/text/encoding/internal/identifier/mib.go | 1621 ------------ vendor/golang.org/x/text/internal/gen/code.go | 369 --- vendor/golang.org/x/text/internal/gen/gen.go | 333 --- vendor/golang.org/x/text/transform/transform.go | 705 ----- vendor/golang.org/x/text/unicode/cldr/base.go | 105 - vendor/golang.org/x/text/unicode/cldr/cldr.go | 130 - vendor/golang.org/x/text/unicode/cldr/collate.go | 359 --- vendor/golang.org/x/text/unicode/cldr/decode.go | 171 -- vendor/golang.org/x/text/unicode/cldr/makexml.go | 400 --- vendor/golang.org/x/text/unicode/cldr/resolve.go | 602 ----- vendor/golang.org/x/text/unicode/cldr/slice.go | 144 -- vendor/golang.org/x/text/unicode/cldr/xml.go | 1494 ----------- vendor/gopkg.in/russross/blackfriday.v2/.gitignore | 8 - .../gopkg.in/russross/blackfriday.v2/.travis.yml | 17 - .../gopkg.in/russross/blackfriday.v2/LICENSE.txt | 29 - vendor/gopkg.in/russross/blackfriday.v2/README.md | 291 --- vendor/gopkg.in/russross/blackfriday.v2/block.go | 1590 ------------ vendor/gopkg.in/russross/blackfriday.v2/doc.go | 18 - vendor/gopkg.in/russross/blackfriday.v2/esc.go | 34 - vendor/gopkg.in/russross/blackfriday.v2/go.mod | 1 - vendor/gopkg.in/russross/blackfriday.v2/html.go | 949 ------- vendor/gopkg.in/russross/blackfriday.v2/inline.go | 1228 --------- .../gopkg.in/russross/blackfriday.v2/markdown.go | 950 ------- vendor/gopkg.in/russross/blackfriday.v2/node.go | 354 --- .../russross/blackfriday.v2/smartypants.go | 457 ---- vendor/gopkg.in/toast.v1/.gitignore | 3 - vendor/gopkg.in/toast.v1/LICENSE | 7 - vendor/gopkg.in/toast.v1/readme.md | 61 - .../gopkg.in/toast.v1/screenshot-action-centre.png | Bin 85126 -> 0 bytes vendor/gopkg.in/toast.v1/screenshot-cli.png | Bin 62466 -> 0 bytes vendor/gopkg.in/toast.v1/screenshot-toast.png | Bin 62644 -> 0 bytes vendor/gopkg.in/toast.v1/toast.go | 357 --- vendor/gopkg.in/yaml.v2/.travis.yml | 12 - vendor/gopkg.in/yaml.v2/LICENSE | 201 -- vendor/gopkg.in/yaml.v2/LICENSE.libyaml | 31 - vendor/gopkg.in/yaml.v2/NOTICE | 13 - vendor/gopkg.in/yaml.v2/README.md | 133 - vendor/gopkg.in/yaml.v2/apic.go | 739 ------ vendor/gopkg.in/yaml.v2/decode.go | 775 ------ vendor/gopkg.in/yaml.v2/emitterc.go | 1685 ------------ vendor/gopkg.in/yaml.v2/encode.go | 362 --- vendor/gopkg.in/yaml.v2/go.mod | 5 - vendor/gopkg.in/yaml.v2/parserc.go | 1095 -------- vendor/gopkg.in/yaml.v2/readerc.go | 412 --- vendor/gopkg.in/yaml.v2/resolve.go | 258 -- vendor/gopkg.in/yaml.v2/scannerc.go | 2696 -------------------- vendor/gopkg.in/yaml.v2/sorter.go | 113 - vendor/gopkg.in/yaml.v2/writerc.go | 26 - vendor/gopkg.in/yaml.v2/yaml.go | 466 ---- vendor/gopkg.in/yaml.v2/yamlh.go | 738 ------ vendor/gopkg.in/yaml.v2/yamlprivateh.go | 173 -- vendor/maunium.net/go/mautrix/.gitignore | 2 - vendor/maunium.net/go/mautrix/LICENSE | 201 -- vendor/maunium.net/go/mautrix/README.md | 4 - vendor/maunium.net/go/mautrix/client.go | 796 ------ vendor/maunium.net/go/mautrix/events.go | 438 ---- vendor/maunium.net/go/mautrix/filter.go | 90 - vendor/maunium.net/go/mautrix/format/htmlparser.go | 257 -- vendor/maunium.net/go/mautrix/format/markdown.go | 38 - vendor/maunium.net/go/mautrix/reply.go | 97 - vendor/maunium.net/go/mautrix/requests.go | 82 - vendor/maunium.net/go/mautrix/responses.go | 182 -- vendor/maunium.net/go/mautrix/room.go | 44 - vendor/maunium.net/go/mautrix/store.go | 65 - vendor/maunium.net/go/mautrix/sync.go | 159 -- vendor/maunium.net/go/mautrix/userids.go | 130 - vendor/maunium.net/go/tcell/.appveyor.yml | 13 - vendor/maunium.net/go/tcell/.gitignore | 1 - vendor/maunium.net/go/tcell/.travis.yml | 19 - vendor/maunium.net/go/tcell/AUTHORS | 5 - vendor/maunium.net/go/tcell/LICENSE | 202 -- vendor/maunium.net/go/tcell/README.adoc | 270 -- vendor/maunium.net/go/tcell/README.md | 254 -- vendor/maunium.net/go/tcell/attr.go | 34 - vendor/maunium.net/go/tcell/cell.go | 191 -- vendor/maunium.net/go/tcell/charset_stub.go | 21 - vendor/maunium.net/go/tcell/charset_unix.go | 49 - vendor/maunium.net/go/tcell/charset_windows.go | 21 - vendor/maunium.net/go/tcell/color.go | 1019 -------- vendor/maunium.net/go/tcell/colorfit.go | 52 - vendor/maunium.net/go/tcell/console_stub.go | 23 - vendor/maunium.net/go/tcell/console_win.go | 1036 -------- vendor/maunium.net/go/tcell/database.json | 1351 ---------- vendor/maunium.net/go/tcell/doc.go | 48 - vendor/maunium.net/go/tcell/encoding.go | 139 - vendor/maunium.net/go/tcell/errors.go | 73 - vendor/maunium.net/go/tcell/event.go | 53 - vendor/maunium.net/go/tcell/interrupt.go | 41 - vendor/maunium.net/go/tcell/key.go | 508 ---- vendor/maunium.net/go/tcell/mouse.go | 103 - vendor/maunium.net/go/tcell/paste.go | 42 - vendor/maunium.net/go/tcell/resize.go | 42 - vendor/maunium.net/go/tcell/runes.go | 111 - vendor/maunium.net/go/tcell/screen.go | 214 -- vendor/maunium.net/go/tcell/simulation.go | 510 ---- vendor/maunium.net/go/tcell/style.go | 138 - vendor/maunium.net/go/tcell/terminfo/.gitignore | 1 - vendor/maunium.net/go/tcell/terminfo/README.md | 8 - vendor/maunium.net/go/tcell/terminfo/TERMINALS.md | 7 - vendor/maunium.net/go/tcell/terminfo/dyninfo.go | 475 ---- vendor/maunium.net/go/tcell/terminfo/mkinfo.go | 922 ------- vendor/maunium.net/go/tcell/terminfo/models.txt | 57 - vendor/maunium.net/go/tcell/terminfo/term_adm3a.go | 24 - .../maunium.net/go/tcell/terminfo/term_aixterm.go | 80 - vendor/maunium.net/go/tcell/terminfo/term_ansi.go | 40 - vendor/maunium.net/go/tcell/terminfo/term_aterm.go | 109 - .../maunium.net/go/tcell/terminfo/term_beterm.go | 53 - .../maunium.net/go/tcell/terminfo/term_bsdos_pc.go | 41 - .../maunium.net/go/tcell/terminfo/term_cygwin.go | 62 - vendor/maunium.net/go/tcell/terminfo/term_d200.go | 96 - vendor/maunium.net/go/tcell/terminfo/term_d210.go | 94 - .../maunium.net/go/tcell/terminfo/term_dtterm.go | 66 - vendor/maunium.net/go/tcell/terminfo/term_eterm.go | 26 - vendor/maunium.net/go/tcell/terminfo/term_gnome.go | 156 -- .../go/tcell/terminfo/term_gnome_256color.go | 156 -- .../maunium.net/go/tcell/terminfo/term_hpterm.go | 49 - .../maunium.net/go/tcell/terminfo/term_hz1500.go | 25 - .../maunium.net/go/tcell/terminfo/term_konsole.go | 155 -- .../go/tcell/terminfo/term_konsole_256color.go | 155 -- vendor/maunium.net/go/tcell/terminfo/term_kterm.go | 66 - vendor/maunium.net/go/tcell/terminfo/term_linux.go | 68 - .../maunium.net/go/tcell/terminfo/term_pcansi.go | 38 - vendor/maunium.net/go/tcell/terminfo/term_rxvt.go | 109 - .../go/tcell/terminfo/term_rxvt_256color.go | 109 - .../go/tcell/terminfo/term_rxvt_unicode.go | 83 - .../tcell/terminfo/term_rxvt_unicode_256color.go | 83 - .../maunium.net/go/tcell/terminfo/term_screen.go | 66 - .../go/tcell/terminfo/term_screen_256color.go | 66 - vendor/maunium.net/go/tcell/terminfo/term_st.go | 157 -- .../go/tcell/terminfo/term_st_256color.go | 157 -- .../maunium.net/go/tcell/terminfo/term_st_meta.go | 155 -- .../go/tcell/terminfo/term_st_meta_256color.go | 155 -- .../go/tcell/terminfo/term_st_meta_truecolor.go | 158 -- .../go/tcell/terminfo/term_st_truecolor.go | 158 -- vendor/maunium.net/go/tcell/terminfo/term_sun.go | 46 - .../go/tcell/terminfo/term_sun_color.go | 50 - .../maunium.net/go/tcell/terminfo/term_termite.go | 152 -- .../maunium.net/go/tcell/terminfo/term_tvi910.go | 38 - .../maunium.net/go/tcell/terminfo/term_tvi912.go | 37 - .../maunium.net/go/tcell/terminfo/term_tvi921.go | 33 - .../maunium.net/go/tcell/terminfo/term_tvi925.go | 42 - .../maunium.net/go/tcell/terminfo/term_tvi950.go | 45 - .../maunium.net/go/tcell/terminfo/term_tvi970.go | 39 - vendor/maunium.net/go/tcell/terminfo/term_vt100.go | 47 - vendor/maunium.net/go/tcell/terminfo/term_vt102.go | 46 - vendor/maunium.net/go/tcell/terminfo/term_vt220.go | 57 - vendor/maunium.net/go/tcell/terminfo/term_vt320.go | 62 - vendor/maunium.net/go/tcell/terminfo/term_vt400.go | 45 - vendor/maunium.net/go/tcell/terminfo/term_vt420.go | 52 - vendor/maunium.net/go/tcell/terminfo/term_vt52.go | 28 - vendor/maunium.net/go/tcell/terminfo/term_wy50.go | 58 - vendor/maunium.net/go/tcell/terminfo/term_wy60.go | 62 - .../go/tcell/terminfo/term_wy99_ansi.go | 60 - .../go/tcell/terminfo/term_wy99a_ansi.go | 60 - vendor/maunium.net/go/tcell/terminfo/term_xfce.go | 155 -- .../maunium.net/go/tcell/terminfo/term_xnuppc.go | 33 - vendor/maunium.net/go/tcell/terminfo/term_xterm.go | 156 -- .../go/tcell/terminfo/term_xterm_256color.go | 155 -- .../go/tcell/terminfo/term_xterm_truecolor.go | 155 -- vendor/maunium.net/go/tcell/terminfo/terminfo.go | 881 ------- vendor/maunium.net/go/tcell/tscreen.go | 1524 ----------- vendor/maunium.net/go/tcell/tscreen_bsd.go | 119 - vendor/maunium.net/go/tcell/tscreen_darwin.go | 140 - vendor/maunium.net/go/tcell/tscreen_linux.go | 129 - vendor/maunium.net/go/tcell/tscreen_posix.go | 206 -- vendor/maunium.net/go/tcell/tscreen_stub.go | 32 - vendor/maunium.net/go/tcell/tscreen_windows.go | 40 - vendor/maunium.net/go/tview/CODE_OF_CONDUCT.md | 73 - vendor/maunium.net/go/tview/CONTRIBUTING.md | 31 - vendor/maunium.net/go/tview/LICENSE.txt | 21 - vendor/maunium.net/go/tview/README.md | 108 - vendor/maunium.net/go/tview/ansi.go | 237 -- vendor/maunium.net/go/tview/application.go | 573 ----- vendor/maunium.net/go/tview/borders.go | 45 - vendor/maunium.net/go/tview/box.go | 416 --- vendor/maunium.net/go/tview/button.go | 137 - vendor/maunium.net/go/tview/checkbox.go | 203 -- vendor/maunium.net/go/tview/doc.go | 174 -- vendor/maunium.net/go/tview/dropdown.go | 413 --- vendor/maunium.net/go/tview/flex.go | 186 -- vendor/maunium.net/go/tview/focusable.go | 8 - vendor/maunium.net/go/tview/form.go | 564 ---- vendor/maunium.net/go/tview/frame.go | 157 -- vendor/maunium.net/go/tview/grid.go | 624 ----- vendor/maunium.net/go/tview/inputfield.go | 445 ---- vendor/maunium.net/go/tview/list.go | 362 --- vendor/maunium.net/go/tview/modal.go | 146 -- vendor/maunium.net/go/tview/pages.go | 257 -- vendor/maunium.net/go/tview/primitive.go | 50 - vendor/maunium.net/go/tview/semigraphics.go | 296 --- vendor/maunium.net/go/tview/styles.go | 34 - vendor/maunium.net/go/tview/table.go | 1096 -------- vendor/maunium.net/go/tview/textview.go | 1018 -------- vendor/maunium.net/go/tview/treeview.go | 684 ----- vendor/maunium.net/go/tview/tview.gif | Bin 2226085 -> 0 bytes vendor/maunium.net/go/tview/util.go | 605 ----- 347 files changed, 189 insertions(+), 81573 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 vendor/github.com/davecgh/go-spew/LICENSE delete mode 100644 vendor/github.com/davecgh/go-spew/spew/bypass.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/bypasssafe.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/common.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/config.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/doc.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/dump.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/format.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/spew.go delete mode 100644 vendor/github.com/disintegration/imaging/.travis.yml delete mode 100644 vendor/github.com/disintegration/imaging/LICENSE delete mode 100644 vendor/github.com/disintegration/imaging/README.md delete mode 100644 vendor/github.com/disintegration/imaging/adjust.go delete mode 100644 vendor/github.com/disintegration/imaging/convolution.go delete mode 100644 vendor/github.com/disintegration/imaging/doc.go delete mode 100644 vendor/github.com/disintegration/imaging/effects.go delete mode 100644 vendor/github.com/disintegration/imaging/histogram.go delete mode 100644 vendor/github.com/disintegration/imaging/io.go delete mode 100644 vendor/github.com/disintegration/imaging/resize.go delete mode 100644 vendor/github.com/disintegration/imaging/scanner.go delete mode 100644 vendor/github.com/disintegration/imaging/tools.go delete mode 100644 vendor/github.com/disintegration/imaging/transform.go delete mode 100644 vendor/github.com/disintegration/imaging/utils.go delete mode 100644 vendor/github.com/gdamore/encoding/.appveyor.yml delete mode 100644 vendor/github.com/gdamore/encoding/.travis.yml delete mode 100644 vendor/github.com/gdamore/encoding/LICENSE delete mode 100644 vendor/github.com/gdamore/encoding/README.md delete mode 100644 vendor/github.com/gdamore/encoding/ascii.go delete mode 100644 vendor/github.com/gdamore/encoding/charmap.go delete mode 100644 vendor/github.com/gdamore/encoding/doc.go delete mode 100644 vendor/github.com/gdamore/encoding/ebcdic.go delete mode 100644 vendor/github.com/gdamore/encoding/latin1.go delete mode 100644 vendor/github.com/gdamore/encoding/latin5.go delete mode 100644 vendor/github.com/gdamore/encoding/utf8.go delete mode 100644 vendor/github.com/kyokomi/emoji/.gitignore delete mode 100644 vendor/github.com/kyokomi/emoji/LICENSE delete mode 100644 vendor/github.com/kyokomi/emoji/README.md delete mode 100644 vendor/github.com/kyokomi/emoji/emoji.go delete mode 100644 vendor/github.com/kyokomi/emoji/emoji_codemap.go delete mode 100644 vendor/github.com/kyokomi/emoji/wercker.yml delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/.gitignore delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/.travis.yml delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/LICENSE delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/README.md delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/colorgens.go delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/colors.go delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/hexcolor.go delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/soft_palettegen.go delete mode 100644 vendor/github.com/lucasb-eyer/go-colorful/warm_palettegen.go delete mode 100644 vendor/github.com/mattn/go-runewidth/.travis.yml delete mode 100644 vendor/github.com/mattn/go-runewidth/LICENSE delete mode 100644 vendor/github.com/mattn/go-runewidth/README.mkd delete mode 100644 vendor/github.com/mattn/go-runewidth/runewidth.go delete mode 100644 vendor/github.com/mattn/go-runewidth/runewidth_js.go delete mode 100644 vendor/github.com/mattn/go-runewidth/runewidth_posix.go delete mode 100644 vendor/github.com/mattn/go-runewidth/runewidth_windows.go delete mode 100644 vendor/github.com/nu7hatch/gouuid/.gitignore delete mode 100644 vendor/github.com/nu7hatch/gouuid/COPYING delete mode 100644 vendor/github.com/nu7hatch/gouuid/README.md delete mode 100644 vendor/github.com/nu7hatch/gouuid/uuid.go delete mode 100644 vendor/github.com/pmezard/go-difflib/LICENSE delete mode 100644 vendor/github.com/pmezard/go-difflib/difflib/difflib.go delete mode 100644 vendor/github.com/renstrom/fuzzysearch/LICENSE delete mode 100644 vendor/github.com/renstrom/fuzzysearch/fuzzy/fuzzy.go delete mode 100644 vendor/github.com/renstrom/fuzzysearch/fuzzy/levenshtein.go delete mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/.travis.yml delete mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/LICENSE delete mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/README.md delete mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/main.go delete mode 100644 vendor/github.com/stretchr/testify/LICENSE delete mode 100644 vendor/github.com/stretchr/testify/assert/assertion_format.go delete mode 100644 vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl delete mode 100644 vendor/github.com/stretchr/testify/assert/assertion_forward.go delete mode 100644 vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl delete mode 100644 vendor/github.com/stretchr/testify/assert/assertions.go delete mode 100644 vendor/github.com/stretchr/testify/assert/doc.go delete mode 100644 vendor/github.com/stretchr/testify/assert/errors.go delete mode 100644 vendor/github.com/stretchr/testify/assert/forward_assertions.go delete mode 100644 vendor/github.com/stretchr/testify/assert/http_assertions.go delete mode 100644 vendor/github.com/zyedidia/clipboard/.travis.yml delete mode 100644 vendor/github.com/zyedidia/clipboard/LICENSE delete mode 100644 vendor/github.com/zyedidia/clipboard/README.md delete mode 100644 vendor/github.com/zyedidia/clipboard/clipboard.go delete mode 100644 vendor/github.com/zyedidia/clipboard/clipboard_darwin.go delete mode 100644 vendor/github.com/zyedidia/clipboard/clipboard_unix.go delete mode 100644 vendor/github.com/zyedidia/clipboard/clipboard_windows.go delete mode 100644 vendor/golang.org/x/image/AUTHORS delete mode 100644 vendor/golang.org/x/image/CONTRIBUTORS delete mode 100644 vendor/golang.org/x/image/LICENSE delete mode 100644 vendor/golang.org/x/image/PATENTS delete mode 100644 vendor/golang.org/x/image/bmp/reader.go delete mode 100644 vendor/golang.org/x/image/bmp/writer.go delete mode 100644 vendor/golang.org/x/image/riff/riff.go delete mode 100644 vendor/golang.org/x/image/tiff/buffer.go delete mode 100644 vendor/golang.org/x/image/tiff/compress.go delete mode 100644 vendor/golang.org/x/image/tiff/consts.go delete mode 100644 vendor/golang.org/x/image/tiff/lzw/reader.go delete mode 100644 vendor/golang.org/x/image/tiff/reader.go delete mode 100644 vendor/golang.org/x/image/tiff/writer.go delete mode 100644 vendor/golang.org/x/image/vp8/decode.go delete mode 100644 vendor/golang.org/x/image/vp8/filter.go delete mode 100644 vendor/golang.org/x/image/vp8/idct.go delete mode 100644 vendor/golang.org/x/image/vp8/partition.go delete mode 100644 vendor/golang.org/x/image/vp8/pred.go delete mode 100644 vendor/golang.org/x/image/vp8/predfunc.go delete mode 100644 vendor/golang.org/x/image/vp8/quant.go delete mode 100644 vendor/golang.org/x/image/vp8/reconstruct.go delete mode 100644 vendor/golang.org/x/image/vp8/token.go delete mode 100644 vendor/golang.org/x/image/vp8l/decode.go delete mode 100644 vendor/golang.org/x/image/vp8l/huffman.go delete mode 100644 vendor/golang.org/x/image/vp8l/transform.go delete mode 100644 vendor/golang.org/x/image/webp/decode.go delete mode 100644 vendor/golang.org/x/image/webp/doc.go delete mode 100644 vendor/golang.org/x/net/AUTHORS delete mode 100644 vendor/golang.org/x/net/CONTRIBUTORS delete mode 100644 vendor/golang.org/x/net/LICENSE delete mode 100644 vendor/golang.org/x/net/PATENTS delete mode 100644 vendor/golang.org/x/net/html/atom/atom.go delete mode 100644 vendor/golang.org/x/net/html/atom/gen.go delete mode 100644 vendor/golang.org/x/net/html/atom/table.go delete mode 100644 vendor/golang.org/x/net/html/const.go delete mode 100644 vendor/golang.org/x/net/html/doc.go delete mode 100644 vendor/golang.org/x/net/html/doctype.go delete mode 100644 vendor/golang.org/x/net/html/entity.go delete mode 100644 vendor/golang.org/x/net/html/escape.go delete mode 100644 vendor/golang.org/x/net/html/foreign.go delete mode 100644 vendor/golang.org/x/net/html/node.go delete mode 100644 vendor/golang.org/x/net/html/parse.go delete mode 100644 vendor/golang.org/x/net/html/render.go delete mode 100644 vendor/golang.org/x/net/html/token.go delete mode 100644 vendor/golang.org/x/text/AUTHORS delete mode 100644 vendor/golang.org/x/text/CONTRIBUTORS delete mode 100644 vendor/golang.org/x/text/LICENSE delete mode 100644 vendor/golang.org/x/text/PATENTS delete mode 100644 vendor/golang.org/x/text/encoding/encoding.go delete mode 100644 vendor/golang.org/x/text/encoding/internal/identifier/gen.go delete mode 100644 vendor/golang.org/x/text/encoding/internal/identifier/identifier.go delete mode 100644 vendor/golang.org/x/text/encoding/internal/identifier/mib.go delete mode 100644 vendor/golang.org/x/text/internal/gen/code.go delete mode 100644 vendor/golang.org/x/text/internal/gen/gen.go delete mode 100644 vendor/golang.org/x/text/transform/transform.go delete mode 100644 vendor/golang.org/x/text/unicode/cldr/base.go delete mode 100644 vendor/golang.org/x/text/unicode/cldr/cldr.go delete mode 100644 vendor/golang.org/x/text/unicode/cldr/collate.go delete mode 100644 vendor/golang.org/x/text/unicode/cldr/decode.go delete mode 100644 vendor/golang.org/x/text/unicode/cldr/makexml.go delete mode 100644 vendor/golang.org/x/text/unicode/cldr/resolve.go delete mode 100644 vendor/golang.org/x/text/unicode/cldr/slice.go delete mode 100644 vendor/golang.org/x/text/unicode/cldr/xml.go delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/.gitignore delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/.travis.yml delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/LICENSE.txt delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/README.md delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/block.go delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/doc.go delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/esc.go delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/go.mod delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/html.go delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/inline.go delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/markdown.go delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/node.go delete mode 100644 vendor/gopkg.in/russross/blackfriday.v2/smartypants.go delete mode 100644 vendor/gopkg.in/toast.v1/.gitignore delete mode 100644 vendor/gopkg.in/toast.v1/LICENSE delete mode 100644 vendor/gopkg.in/toast.v1/readme.md delete mode 100644 vendor/gopkg.in/toast.v1/screenshot-action-centre.png delete mode 100644 vendor/gopkg.in/toast.v1/screenshot-cli.png delete mode 100644 vendor/gopkg.in/toast.v1/screenshot-toast.png delete mode 100644 vendor/gopkg.in/toast.v1/toast.go delete mode 100644 vendor/gopkg.in/yaml.v2/.travis.yml delete mode 100644 vendor/gopkg.in/yaml.v2/LICENSE delete mode 100644 vendor/gopkg.in/yaml.v2/LICENSE.libyaml delete mode 100644 vendor/gopkg.in/yaml.v2/NOTICE delete mode 100644 vendor/gopkg.in/yaml.v2/README.md delete mode 100644 vendor/gopkg.in/yaml.v2/apic.go delete mode 100644 vendor/gopkg.in/yaml.v2/decode.go delete mode 100644 vendor/gopkg.in/yaml.v2/emitterc.go delete mode 100644 vendor/gopkg.in/yaml.v2/encode.go delete mode 100644 vendor/gopkg.in/yaml.v2/go.mod delete mode 100644 vendor/gopkg.in/yaml.v2/parserc.go delete mode 100644 vendor/gopkg.in/yaml.v2/readerc.go delete mode 100644 vendor/gopkg.in/yaml.v2/resolve.go delete mode 100644 vendor/gopkg.in/yaml.v2/scannerc.go delete mode 100644 vendor/gopkg.in/yaml.v2/sorter.go delete mode 100644 vendor/gopkg.in/yaml.v2/writerc.go delete mode 100644 vendor/gopkg.in/yaml.v2/yaml.go delete mode 100644 vendor/gopkg.in/yaml.v2/yamlh.go delete mode 100644 vendor/gopkg.in/yaml.v2/yamlprivateh.go delete mode 100644 vendor/maunium.net/go/mautrix/.gitignore delete mode 100644 vendor/maunium.net/go/mautrix/LICENSE delete mode 100644 vendor/maunium.net/go/mautrix/README.md delete mode 100644 vendor/maunium.net/go/mautrix/client.go delete mode 100644 vendor/maunium.net/go/mautrix/events.go delete mode 100644 vendor/maunium.net/go/mautrix/filter.go delete mode 100644 vendor/maunium.net/go/mautrix/format/htmlparser.go delete mode 100644 vendor/maunium.net/go/mautrix/format/markdown.go delete mode 100644 vendor/maunium.net/go/mautrix/reply.go delete mode 100644 vendor/maunium.net/go/mautrix/requests.go delete mode 100644 vendor/maunium.net/go/mautrix/responses.go delete mode 100644 vendor/maunium.net/go/mautrix/room.go delete mode 100644 vendor/maunium.net/go/mautrix/store.go delete mode 100644 vendor/maunium.net/go/mautrix/sync.go delete mode 100644 vendor/maunium.net/go/mautrix/userids.go delete mode 100644 vendor/maunium.net/go/tcell/.appveyor.yml delete mode 100644 vendor/maunium.net/go/tcell/.gitignore delete mode 100644 vendor/maunium.net/go/tcell/.travis.yml delete mode 100644 vendor/maunium.net/go/tcell/AUTHORS delete mode 100644 vendor/maunium.net/go/tcell/LICENSE delete mode 100644 vendor/maunium.net/go/tcell/README.adoc delete mode 100644 vendor/maunium.net/go/tcell/README.md delete mode 100644 vendor/maunium.net/go/tcell/attr.go delete mode 100644 vendor/maunium.net/go/tcell/cell.go delete mode 100644 vendor/maunium.net/go/tcell/charset_stub.go delete mode 100644 vendor/maunium.net/go/tcell/charset_unix.go delete mode 100644 vendor/maunium.net/go/tcell/charset_windows.go delete mode 100644 vendor/maunium.net/go/tcell/color.go delete mode 100644 vendor/maunium.net/go/tcell/colorfit.go delete mode 100644 vendor/maunium.net/go/tcell/console_stub.go delete mode 100644 vendor/maunium.net/go/tcell/console_win.go delete mode 100644 vendor/maunium.net/go/tcell/database.json delete mode 100644 vendor/maunium.net/go/tcell/doc.go delete mode 100644 vendor/maunium.net/go/tcell/encoding.go delete mode 100644 vendor/maunium.net/go/tcell/errors.go delete mode 100644 vendor/maunium.net/go/tcell/event.go delete mode 100644 vendor/maunium.net/go/tcell/interrupt.go delete mode 100644 vendor/maunium.net/go/tcell/key.go delete mode 100644 vendor/maunium.net/go/tcell/mouse.go delete mode 100644 vendor/maunium.net/go/tcell/paste.go delete mode 100644 vendor/maunium.net/go/tcell/resize.go delete mode 100644 vendor/maunium.net/go/tcell/runes.go delete mode 100644 vendor/maunium.net/go/tcell/screen.go delete mode 100644 vendor/maunium.net/go/tcell/simulation.go delete mode 100644 vendor/maunium.net/go/tcell/style.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/.gitignore delete mode 100644 vendor/maunium.net/go/tcell/terminfo/README.md delete mode 100644 vendor/maunium.net/go/tcell/terminfo/TERMINALS.md delete mode 100644 vendor/maunium.net/go/tcell/terminfo/dyninfo.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/mkinfo.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/models.txt delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_adm3a.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_aixterm.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_ansi.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_aterm.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_beterm.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_bsdos_pc.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_cygwin.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_d200.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_d210.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_dtterm.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_eterm.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_gnome.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_gnome_256color.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_hpterm.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_hz1500.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_konsole.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_konsole_256color.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_kterm.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_linux.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_pcansi.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_rxvt.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_rxvt_256color.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_rxvt_unicode_256color.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_screen.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_screen_256color.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_st.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_st_256color.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_st_meta.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_st_meta_256color.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_st_meta_truecolor.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_st_truecolor.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_sun.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_sun_color.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_termite.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_tvi910.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_tvi912.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_tvi921.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_tvi925.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_tvi950.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_tvi970.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_vt100.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_vt102.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_vt220.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_vt320.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_vt400.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_vt420.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_vt52.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_wy50.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_wy60.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_wy99_ansi.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_wy99a_ansi.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_xfce.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_xnuppc.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_xterm.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_xterm_256color.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/term_xterm_truecolor.go delete mode 100644 vendor/maunium.net/go/tcell/terminfo/terminfo.go delete mode 100644 vendor/maunium.net/go/tcell/tscreen.go delete mode 100644 vendor/maunium.net/go/tcell/tscreen_bsd.go delete mode 100644 vendor/maunium.net/go/tcell/tscreen_darwin.go delete mode 100644 vendor/maunium.net/go/tcell/tscreen_linux.go delete mode 100644 vendor/maunium.net/go/tcell/tscreen_posix.go delete mode 100644 vendor/maunium.net/go/tcell/tscreen_stub.go delete mode 100644 vendor/maunium.net/go/tcell/tscreen_windows.go delete mode 100644 vendor/maunium.net/go/tview/CODE_OF_CONDUCT.md delete mode 100644 vendor/maunium.net/go/tview/CONTRIBUTING.md delete mode 100644 vendor/maunium.net/go/tview/LICENSE.txt delete mode 100644 vendor/maunium.net/go/tview/README.md delete mode 100644 vendor/maunium.net/go/tview/ansi.go delete mode 100644 vendor/maunium.net/go/tview/application.go delete mode 100644 vendor/maunium.net/go/tview/borders.go delete mode 100644 vendor/maunium.net/go/tview/box.go delete mode 100644 vendor/maunium.net/go/tview/button.go delete mode 100644 vendor/maunium.net/go/tview/checkbox.go delete mode 100644 vendor/maunium.net/go/tview/doc.go delete mode 100644 vendor/maunium.net/go/tview/dropdown.go delete mode 100644 vendor/maunium.net/go/tview/flex.go delete mode 100644 vendor/maunium.net/go/tview/focusable.go delete mode 100644 vendor/maunium.net/go/tview/form.go delete mode 100644 vendor/maunium.net/go/tview/frame.go delete mode 100644 vendor/maunium.net/go/tview/grid.go delete mode 100644 vendor/maunium.net/go/tview/inputfield.go delete mode 100644 vendor/maunium.net/go/tview/list.go delete mode 100644 vendor/maunium.net/go/tview/modal.go delete mode 100644 vendor/maunium.net/go/tview/pages.go delete mode 100644 vendor/maunium.net/go/tview/primitive.go delete mode 100644 vendor/maunium.net/go/tview/semigraphics.go delete mode 100644 vendor/maunium.net/go/tview/styles.go delete mode 100644 vendor/maunium.net/go/tview/table.go delete mode 100644 vendor/maunium.net/go/tview/textview.go delete mode 100644 vendor/maunium.net/go/tview/treeview.go delete mode 100644 vendor/maunium.net/go/tview/tview.gif delete mode 100644 vendor/maunium.net/go/tview/util.go diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index da3664e..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,219 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" - name = "github.com/davecgh/go-spew" - packages = ["spew"] - pruneopts = "UT" - revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" - version = "v1.1.1" - -[[projects]] - digest = "1:2694597a20d303502ad1b7f1cc688977c7dc34da732ccf4d27e98b552cceed5b" - name = "github.com/disintegration/imaging" - packages = ["."] - pruneopts = "UT" - revision = "0bd5694c78c9c3d9a3cd06a706a8f3c59296a9ac" - version = "v1.5.0" - -[[projects]] - branch = "master" - digest = "1:40d0056c1b1f503c366ba441df92a82b5a2654d6f3747b1689a611eb5c9ce0a2" - name = "github.com/gdamore/encoding" - packages = ["."] - pruneopts = "UT" - revision = "b23993cbb6353f0e6aa98d0ee318a34728f628b9" - -[[projects]] - digest = "1:f4bd9b6cfcbaafa94259861747781022d8f06ff3c88aafe49a815ac02609bc96" - name = "github.com/kyokomi/emoji" - packages = ["."] - pruneopts = "UT" - revision = "2e9a9507333f3ee28f3fab88c2c3aba34455d734" - version = "v1.5.1" - -[[projects]] - digest = "1:c65a16ac77d0b1aefc7009cabb6ac5ad05def02025f5be85f450c03f52cc6f86" - name = "github.com/lucasb-eyer/go-colorful" - packages = ["."] - pruneopts = "UT" - revision = "345fbb3dbcdb252d9985ee899a84963c0fa24c82" - version = "v1.0" - -[[projects]] - digest = "1:cdb899c199f907ac9fb50495ec71212c95cb5b0e0a8ee0800da0238036091033" - name = "github.com/mattn/go-runewidth" - packages = ["."] - pruneopts = "UT" - revision = "ce7b0b5c7b45a81508558cd1dba6bb1e4ddb51bb" - version = "v0.0.3" - -[[projects]] - branch = "master" - digest = "1:0e1e5f960c58fdc677212fcc70e55042a0084d367623e51afbdb568963832f5d" - name = "github.com/nu7hatch/gouuid" - packages = ["."] - pruneopts = "UT" - revision = "179d4d0c4d8d407a32af483c2354df1d2c91e6c3" - -[[projects]] - digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - pruneopts = "UT" - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - branch = "master" - digest = "1:3fd3d634f6815f19ac4b2c5e16d28ec9aa4584d0bba25d1ee6c424d813cca22a" - name = "github.com/renstrom/fuzzysearch" - packages = ["fuzzy"] - pruneopts = "UT" - revision = "b18e754edff4833912ef4dce9eaca885bd3f0de1" - -[[projects]] - branch = "master" - digest = "1:def689e73e9252f6f7fe66834a76751a41b767e03daab299e607e7226c58a855" - name = "github.com/shurcooL/sanitized_anchor_name" - packages = ["."] - pruneopts = "UT" - revision = "86672fcb3f950f35f2e675df2240550f2a50762f" - -[[projects]] - digest = "1:18752d0b95816a1b777505a97f71c7467a8445b8ffb55631a7bf779f6ba4fa83" - name = "github.com/stretchr/testify" - packages = ["assert"] - pruneopts = "UT" - revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" - version = "v1.2.2" - -[[projects]] - branch = "master" - digest = "1:22738a5261588086d75acb3c792f7c931d30fd32e351117e9e046331135f5297" - name = "github.com/zyedidia/clipboard" - packages = ["."] - pruneopts = "UT" - revision = "bd31d747117d04b4e25b61f73e1ea4faeea3c56a" - -[[projects]] - branch = "master" - digest = "1:441333ba1f7f3074035297647244e3d1ce3665e4e7c5054b3a8b138463f8ff58" - name = "golang.org/x/image" - packages = [ - "bmp", - "riff", - "tiff", - "tiff/lzw", - "vp8", - "vp8l", - "webp", - ] - pruneopts = "UT" - revision = "249dc8530c0efc2766606a940c1c50b434b2f1cd" - -[[projects]] - branch = "master" - digest = "1:1a1ecfa7b54ca3f7a0115ab5c578d7d6a5d8b605839c549e80260468c42f8be7" - name = "golang.org/x/net" - packages = [ - "html", - "html/atom", - ] - pruneopts = "UT" - revision = "88d92db4c548972d942ac2a3531a8a9a34c82ca6" - -[[projects]] - digest = "1:37672ad5821719e2df8509c2edd4ba5ae192463237c73c3a2d24ef8b2bc9e36f" - name = "golang.org/x/text" - packages = [ - "encoding", - "encoding/internal/identifier", - "internal/gen", - "transform", - "unicode/cldr", - ] - pruneopts = "UT" - revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" - version = "v0.3.0" - -[[projects]] - digest = "1:2ee0f15eb0fb04f918db7c2dcf39745f40d69f798ef171610a730e8a56aaa4fd" - name = "gopkg.in/russross/blackfriday.v2" - packages = ["."] - pruneopts = "UT" - revision = "d3b5b032dc8e8927d31a5071b56e14c89f045135" - version = "v2.0.1" - -[[projects]] - branch = "v1" - digest = "1:b71ccd8615521db4ea2f9381f55780a1312654f5d8431d2e58eca51c74110de2" - name = "gopkg.in/toast.v1" - packages = ["."] - pruneopts = "UT" - revision = "0a84660828b24d25b35525c9a1f1f51267f8da91" - -[[projects]] - digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202" - name = "gopkg.in/yaml.v2" - packages = ["."] - pruneopts = "UT" - revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" - version = "v2.2.1" - -[[projects]] - branch = "master" - digest = "1:1abef70ba640c92bf2763f1b1fbcb8c6e3ba1b58b2dcfeb933a09bfc51f7147b" - name = "maunium.net/go/mautrix" - packages = [ - ".", - "format", - ] - pruneopts = "UT" - revision = "ffb03045581b402abaa1fd51340207dfb807dc81" - -[[projects]] - branch = "master" - digest = "1:28d6d6123ce29c9b0b5d393af0085f1454a9d93d70b4c9893efe6cff025702b9" - name = "maunium.net/go/tcell" - packages = [ - ".", - "terminfo", - ] - pruneopts = "UT" - revision = "a62189e4543d731b94ae0d3b659d1853975ea657" - -[[projects]] - branch = "master" - digest = "1:b4c2e264221b6afa98aec4e0a097f3775cb014eebac8a6f49d33c53b237b77af" - name = "maunium.net/go/tview" - packages = ["."] - pruneopts = "UT" - revision = "dae31f32cda75339f5ec2a64411ef3ec1862ef5e" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/disintegration/imaging", - "github.com/kyokomi/emoji", - "github.com/lucasb-eyer/go-colorful", - "github.com/mattn/go-runewidth", - "github.com/renstrom/fuzzysearch/fuzzy", - "github.com/stretchr/testify/assert", - "github.com/zyedidia/clipboard", - "golang.org/x/image/bmp", - "golang.org/x/image/tiff", - "golang.org/x/image/webp", - "golang.org/x/net/html", - "gopkg.in/russross/blackfriday.v2", - "gopkg.in/toast.v1", - "gopkg.in/yaml.v2", - "maunium.net/go/mautrix", - "maunium.net/go/mautrix/format", - "maunium.net/go/tcell", - "maunium.net/go/tview", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 2fa3148..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,82 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - -[[constraint]] - name = "github.com/disintegration/imaging" - version = "1.4.1" - -[[constraint]] - name = "github.com/mattn/go-runewidth" - version = "0.0.2" - -[[constraint]] - name = "github.com/stretchr/testify" - version = "1.2.1" - -[[constraint]] - branch = "master" - name = "github.com/zyedidia/clipboard" - -[[constraint]] - branch = "master" - name = "golang.org/x/image" - -[[constraint]] - branch = "master" - name = "golang.org/x/net" - -[[constraint]] - name = "gopkg.in/russross/blackfriday.v2" - version = "2.0.0" - -[[constraint]] - branch = "v1" - name = "gopkg.in/toast.v1" - -[[constraint]] - name = "gopkg.in/yaml.v2" - version = "2.2.1" - -[[constraint]] - branch = "master" - name = "maunium.net/go/mautrix" - -[[constraint]] - branch = "master" - name = "maunium.net/go/tcell" - -[[constraint]] - branch = "master" - name = "maunium.net/go/tview" - -[[constraint]] - branch = "master" - name = "github.com/renstrom/fuzzysearch" - -[prune] - go-tests = true - unused-packages = true diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..036acdc --- /dev/null +++ b/go.mod @@ -0,0 +1,19 @@ +module maunium.net/go/gomuks + +require ( + github.com/disintegration/imaging v1.5.0 + github.com/kyokomi/emoji v2.0.0+incompatible + github.com/lithammer/fuzzysearch v1.0.2 + github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08 + github.com/mattn/go-runewidth v0.0.4 + github.com/russross/blackfriday/v2 v2.0.1 + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/zyedidia/clipboard v0.0.0-20180718195219-bd31d747117d + golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b + golang.org/x/net v0.0.0-20190110200230-915654e7eabc + gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect + gopkg.in/yaml.v2 v2.2.2 + maunium.net/go/mautrix v0.1.0-alpha.2 + maunium.net/go/tcell v0.0.0-20190111212645-703b3f6ecec9 + maunium.net/go/tview v0.0.0-20190111212720-d6aa1eac1b9a +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..a9806d4 --- /dev/null +++ b/go.sum @@ -0,0 +1,40 @@ +github.com/disintegration/imaging v1.5.0 h1:uYqUhwNmLU4K1FN44vhqS4TZJRAA4RhBINgbQlKyGi0= +github.com/disintegration/imaging v1.5.0/go.mod h1:9B/deIUIrliYkyMTuXJd6OUFLcrZ2tf+3Qlwnaf/CjU= +github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= +github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= +github.com/kyokomi/emoji v2.0.0+incompatible h1:ftqSD1PzBkSr3I4/0ZZ7Cluaxv6sNi8CkhYE56Son6A= +github.com/kyokomi/emoji v2.0.0+incompatible/go.mod h1:mZ6aGCD7yk8j6QY6KICwnZ2pxoszVseX1DNoGtU2tBA= +github.com/lithammer/fuzzysearch v1.0.2 h1:AjCE2iwc5y+8K+h2nXVc0Pmrpjvu+JVqMgiZ0oakXDM= +github.com/lithammer/fuzzysearch v1.0.2/go.mod h1:bvAJyokfCQ7Vknrd4Kgc+izmMrPj5CiBAu2t6rK1Kak= +github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08 h1:5MnxBC15uMxFv5FY/J/8vzyaBiArCOkMdFT9Jsw78iY= +github.com/lucasb-eyer/go-colorful v0.0.0-20181028223441-12d3b2882a08/go.mod h1:NXg0ArsFk0Y01623LgUqoqcouGDB+PwCCQlrwrG6xJ4= +github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= +github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/zyedidia/clipboard v0.0.0-20180718195219-bd31d747117d h1:Lhqt2eo+rgM8aswvM7nTtAMVm8ARPWzkE9n6eZDOccY= +github.com/zyedidia/clipboard v0.0.0-20180718195219-bd31d747117d/go.mod h1:WDk3p8GiZV9+xFWlSo8qreeoLhW6Ik692rqXk+cNeRY= +golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b h1:VHyIDlv3XkfCa5/a81uzaoDkHH4rr81Z62g+xlnO8uM= +golang.org/x/image v0.0.0-20181116024801-cd38e8056d9b/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190110200230-915654e7eabc h1:Yx9JGxI1SBhVLFjpAkWMaO1TF+xyqtHLjZpvQboJGiM= +golang.org/x/net v0.0.0-20190110200230-915654e7eabc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0/go.mod h1:OdE7CF6DbADk7lN8LIKRzRJTTZXIjtWgA5THM5lhBAw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +maunium.net/go/mautrix v0.1.0-alpha.2 h1:NsLc5tyrp5tyrKTvFSmqcLi+FISQ+FsuWC/ycL08PzI= +maunium.net/go/mautrix v0.1.0-alpha.2/go.mod h1:C8akEpHpmmO8gQhLvmInr3HujhUXyKvCoCAzFsxHjGE= +maunium.net/go/tcell v0.0.0-20190111210611-542340841245 h1:JIekRWZ4na6cZJa5VMwLFpuiGzmeX+5Xx+WRVOHQHuk= +maunium.net/go/tcell v0.0.0-20190111210611-542340841245/go.mod h1:U+akxk8CP6vAWV74r2NOqEMMHw6kPGWTyvjzCtemxtM= +maunium.net/go/tcell v0.0.0-20190111212645-703b3f6ecec9 h1:aSZPhcBmGu8MIddPxWNksfjbXHmlRL0yUddwB9CP4s0= +maunium.net/go/tcell v0.0.0-20190111212645-703b3f6ecec9/go.mod h1:U+akxk8CP6vAWV74r2NOqEMMHw6kPGWTyvjzCtemxtM= +maunium.net/go/tview v0.0.0-20190111211351-2f23a5129af0 h1:xHG0S9ExKp+6dkhasnK/fgO9mLHSSSqVoAymjyUtDdI= +maunium.net/go/tview v0.0.0-20190111211351-2f23a5129af0/go.mod h1:ypYT6Dn71E7sVv6NxCjNo2cBJWJa257VSHCGOssGbV0= +maunium.net/go/tview v0.0.0-20190111212720-d6aa1eac1b9a h1:f4JVX4GHJH/wMcL9VACMVXT0eaWhxx9a7OT/NLcxsw8= +maunium.net/go/tview v0.0.0-20190111212720-d6aa1eac1b9a/go.mod h1:CTOF8OnDeK31Wl25GXdbYzTDvvZoiazmKNZdwkVUmzE= diff --git a/interface/ui.go b/interface/ui.go index 39473f5..885bb0a 100644 --- a/interface/ui.go +++ b/interface/ui.go @@ -73,7 +73,6 @@ type RoomView interface { SetTyping(users []string) UpdateUserList() - NewMessage(id, sender string, msgtype mautrix.MessageType, text string, timestamp time.Time) Message NewTempMessage(msgtype mautrix.MessageType, text string) Message AddMessage(message Message, direction MessageDirection) AddServiceMessage(message string) diff --git a/lib/bfhtml/html.go b/lib/bfhtml/html.go index 14076ee..3faedf7 100644 --- a/lib/bfhtml/html.go +++ b/lib/bfhtml/html.go @@ -19,7 +19,7 @@ package bfhtml import ( "io" - bf "gopkg.in/russross/blackfriday.v2" + bf "github.com/russross/blackfriday/v2" ) type HTMLRenderer struct { diff --git a/matrix/matrix.go b/matrix/matrix.go index 54efd6e..b119fc9 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -34,7 +34,7 @@ import ( "crypto/tls" "encoding/json" - "gopkg.in/russross/blackfriday.v2" + "github.com/russross/blackfriday/v2" "maunium.net/go/gomuks/config" "maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/interface" @@ -194,6 +194,10 @@ func (c *Container) OnLogin() { debug.Print("Initializing syncer") c.syncer = NewGomuksSyncer(c.config) c.syncer.OnEventType(mautrix.EventMessage, c.HandleMessage) + c.syncer.OnEventType(mautrix.StateAliases, c.HandleMessage) + c.syncer.OnEventType(mautrix.StateCanonicalAlias, c.HandleMessage) + c.syncer.OnEventType(mautrix.StateTopic, c.HandleMessage) + c.syncer.OnEventType(mautrix.StateRoomName, c.HandleMessage) c.syncer.OnEventType(mautrix.StateMember, c.HandleMembership) c.syncer.OnEventType(mautrix.EphemeralEventReceipt, c.HandleReadReceipt) c.syncer.OnEventType(mautrix.EphemeralEventTyping, c.HandleTyping) @@ -290,7 +294,7 @@ func (c *Container) HandleMessage(source EventSource, evt *mautrix.Event) { c.ui.Render() } } else { - debug.Printf("Parsing event %v failed (ParseEvent() returned nil).", evt) + debug.Printf("Parsing event %s type %s %v from %s in %s failed (ParseEvent() returned nil).", evt.ID, evt.Type, evt.Content.Raw, evt.Sender, evt.RoomID) } } diff --git a/matrix/sync.go b/matrix/sync.go index 06c7f47..fc426bc 100644 --- a/matrix/sync.go +++ b/matrix/sync.go @@ -23,8 +23,8 @@ import ( "maunium.net/go/gomuks/debug" "time" - "maunium.net/go/mautrix" "maunium.net/go/gomuks/matrix/rooms" + "maunium.net/go/mautrix" ) type SyncerSession interface { @@ -167,7 +167,14 @@ func (s *GomuksSyncer) GetFilterJSON(userID string) json.RawMessage { }, }, Timeline: mautrix.FilterPart{ - Types: []string{"m.room.message", "m.room.member"}, + Types: []string{ + "m.room.message", + "m.room.member", + "m.room.name", + "m.room.topic", + "m.room.canonical_alias", + "m.room.aliases", + }, Limit: 50, }, Ephemeral: mautrix.FilterPart{ diff --git a/ui/commands.go b/ui/commands.go index 0feda29..50aedd2 100644 --- a/ui/commands.go +++ b/ui/commands.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" "maunium.net/go/mautrix" + "maunium.net/go/mautrix/format" "strings" "unicode" @@ -79,7 +80,7 @@ func cmdRainbow(cmd *Command) { color := rainbow.GetInterpolatedColorFor(float64(i) / float64(len(text))).Hex() fmt.Fprintf(&html, "%c", color, char) } - tempMessage := cmd.Room.NewTempMessage("m.text", html.String()) + tempMessage := cmd.Room.NewTempMessage("m.text", format.HTMLToText(html.String())) go cmd.MainView.sendTempMessage(cmd.Room, tempMessage, html.String()) cmd.UI.Render() } diff --git a/ui/fuzzy-search-modal.go b/ui/fuzzy-search-modal.go index 0ccd72d..b58a367 100644 --- a/ui/fuzzy-search-modal.go +++ b/ui/fuzzy-search-modal.go @@ -21,7 +21,7 @@ import ( "sort" "strconv" - "github.com/renstrom/fuzzysearch/fuzzy" + "github.com/lithammer/fuzzysearch/fuzzy" "maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/matrix/rooms" "maunium.net/go/gomuks/ui/widget" diff --git a/ui/messages/parser/parser.go b/ui/messages/parser/parser.go index ef6578f..05dd0e9 100644 --- a/ui/messages/parser/parser.go +++ b/ui/messages/parser/parser.go @@ -39,6 +39,8 @@ func ParseEvent(matrix ifc.MatrixContainer, room *rooms.Room, evt *mautrix.Event fallthrough case mautrix.EventMessage: return ParseMessage(matrix, room, evt) + case mautrix.StateTopic, mautrix.StateRoomName, mautrix.StateAliases, mautrix.StateCanonicalAlias: + return ParseStateEvent(matrix, room, evt) case mautrix.StateMember: return ParseMembershipEvent(room, evt) } @@ -53,6 +55,45 @@ func unixToTime(unix int64) time.Time { return timestamp } +func ParseStateEvent(matrix ifc.MatrixContainer, room *rooms.Room, evt *mautrix.Event) messages.UIMessage { + displayname := evt.Sender + member := room.GetMember(evt.Sender) + if member != nil { + displayname = member.Displayname + } + text := tstring.NewColorTString(displayname, widget.GetHashColor(evt.Sender)) + switch evt.Type { + case mautrix.StateTopic: + if len(evt.Content.Topic) == 0 { + text = text.AppendColor(" removed the topic.", tcell.ColorGreen) + } else { + text = text.AppendColor(" changed the topic to ", tcell.ColorGreen). + AppendStyle(evt.Content.Topic, tcell.StyleDefault.Underline(true)). + AppendColor(".", tcell.ColorGreen) + } + case mautrix.StateRoomName: + if len(evt.Content.Name) == 0 { + text = text.AppendColor(" removed the room name.", tcell.ColorGreen) + } else { + text = text.AppendColor(" changed the room name to ", tcell.ColorGreen). + AppendStyle(evt.Content.Name, tcell.StyleDefault.Underline(true)). + AppendColor(".", tcell.ColorGreen) + } + case mautrix.StateCanonicalAlias: + if len(evt.Content.Alias) == 0 { + text = text.AppendColor(" removed the main address of the room.", tcell.ColorGreen) + } else { + text = text.AppendColor(" changed the main address of the room to ", tcell.ColorGreen). + AppendStyle(evt.Content.Alias, tcell.StyleDefault.Underline(true)). + AppendColor(".", tcell.ColorGreen) + } + case mautrix.StateAliases: + text = ParseAliasEvent(evt, displayname) + } + ts := unixToTime(evt.Timestamp) + return messages.NewExpandedTextMessage(evt.ID, evt.Sender, displayname, mautrix.MessageType(evt.Type.Type), text, ts) +} + func ParseMessage(matrix ifc.MatrixContainer, room *rooms.Room, evt *mautrix.Event) messages.UIMessage { displayname := evt.Sender member := room.GetMember(evt.Sender) @@ -153,10 +194,12 @@ func getMembershipEventContent(room *rooms.Room, evt *mautrix.Event) (sender str sender, text = getMembershipChangeMessage(evt, membership, prevMembership, senderDisplayname, displayname, prevDisplayname) } else if displayname != prevDisplayname { sender = "---" - text = tstring.NewColorTString(fmt.Sprintf("%s changed their display name to %s.", prevDisplayname, displayname), tcell.ColorGreen) color := widget.GetHashColor(*evt.StateKey) - text.Colorize(0, len(prevDisplayname), color) - text.Colorize(len(prevDisplayname)+len(" changed their display name to "), len(displayname), color) + text = tstring.NewBlankTString(). + AppendColor(prevDisplayname, color). + AppendColor(" changed their display name to ", tcell.ColorGreen). + AppendColor(displayname, color). + AppendColor(".", tcell.ColorGreen) } return } @@ -170,3 +213,66 @@ func ParseMembershipEvent(room *rooms.Room, evt *mautrix.Event) messages.UIMessa ts := unixToTime(evt.Timestamp) return messages.NewExpandedTextMessage(evt.ID, evt.Sender, displayname, "m.room.member", text, ts) } + +func ParseAliasEvent(evt *mautrix.Event, displayname string) tstring.TString { + var prevAliases []string + if evt.Unsigned.PrevContent != nil { + prevAliases = evt.Unsigned.PrevContent.Aliases + } + aliases := evt.Content.Aliases + var added, removed []tstring.TString +Outer1: + for _, oldAlias := range prevAliases { + for _, newAlias := range aliases { + if oldAlias == newAlias { + continue Outer1 + } + } + removed = append(removed, tstring.NewStyleTString(oldAlias, tcell.StyleDefault.Foreground(widget.GetHashColor(oldAlias)).Underline(true))) + } +Outer2: + for _, newAlias := range aliases { + for _, oldAlias := range prevAliases { + if oldAlias == newAlias { + continue Outer2 + } + } + added = append(added, tstring.NewStyleTString(newAlias, tcell.StyleDefault.Foreground(widget.GetHashColor(newAlias)).Underline(true))) + } + var addedStr, removedStr tstring.TString + if len(added) == 1 { + addedStr = added[0] + } else if len(added) > 1 { + addedStr = tstring. + Join(added[:len(added)-1], ", "). + Append(" and "). + AppendTString(added[len(added)-1]) + } + if len(removed) == 1 { + removedStr = removed[0] + } else if len(removed) > 1 { + removedStr = tstring. + Join(removed[:len(removed)-1], ", "). + Append(" and "). + AppendTString(removed[len(removed)-1]) + } + text := tstring.NewBlankTString() + if len(addedStr) > 0 && len(removedStr) > 0 { + text = text.AppendColor(fmt.Sprintf("%s added ", displayname), tcell.ColorGreen). + AppendTString(addedStr). + AppendColor(" and removed ", tcell.ColorGreen). + AppendTString(removedStr). + AppendColor(" as addresses for this room.", tcell.ColorGreen) + } else if len(addedStr) > 0 { + text = text.AppendColor(fmt.Sprintf("%s added ", displayname), tcell.ColorGreen). + AppendTString(addedStr). + AppendColor(" as addresses for this room.", tcell.ColorGreen) + } else if len(removedStr) > 0 { + text = text.AppendColor(fmt.Sprintf("%s removed ", displayname), tcell.ColorGreen). + AppendTString(removedStr). + AppendColor(" as addresses for this room.", tcell.ColorGreen) + } else { + return nil + } + return text +} diff --git a/ui/room-list.go b/ui/room-list.go index 6b81e60..d82f870 100644 --- a/ui/room-list.go +++ b/ui/room-list.go @@ -456,7 +456,7 @@ func (list *RoomList) Draw(screen tcell.Screen) { for _, tag := range list.tags { trl := list.items[tag] tagDisplayName := list.GetTagDisplayName(tag) - if len(tagDisplayName) == 0 { + if trl == nil || len(tagDisplayName) == 0 { continue } diff --git a/ui/room-view.go b/ui/room-view.go index 6eda559..a978346 100644 --- a/ui/room-view.go +++ b/ui/room-view.go @@ -357,10 +357,6 @@ func (view *RoomView) newUIMessage(id, sender string, msgtype mautrix.MessageTyp return msg } -func (view *RoomView) NewMessage(id, sender string, msgtype mautrix.MessageType, text string, timestamp time.Time) ifc.Message { - return view.newUIMessage(id, sender, msgtype, text, timestamp) -} - func (view *RoomView) NewTempMessage(msgtype mautrix.MessageType, text string) ifc.Message { now := time.Now() id := strconv.FormatInt(now.UnixNano(), 10) @@ -375,7 +371,7 @@ func (view *RoomView) NewTempMessage(msgtype mautrix.MessageType, text string) i } func (view *RoomView) AddServiceMessage(text string) { - message := view.newUIMessage("", "*", "gomuks.service", text, time.Now()) + message := view.newUIMessage(view.parent.matrix.Client().TxnID(), "*", "gomuks.service", text, time.Now()) message.SetIsService(true) view.AddMessage(message, ifc.AppendMessage) } diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE deleted file mode 100644 index bc52e96..0000000 --- a/vendor/github.com/davecgh/go-spew/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -ISC License - -Copyright (c) 2012-2016 Dave Collins - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go deleted file mode 100644 index 7929947..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/bypass.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) 2015-2016 Dave Collins -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when the code is not running on Google App Engine, compiled by GopherJS, and -// "-tags safe" is not added to the go build command line. The "disableunsafe" -// tag is deprecated and thus should not be used. -// Go versions prior to 1.4 are disabled because they use a different layout -// for interfaces which make the implementation of unsafeReflectValue more complex. -// +build !js,!appengine,!safe,!disableunsafe,go1.4 - -package spew - -import ( - "reflect" - "unsafe" -) - -const ( - // UnsafeDisabled is a build-time constant which specifies whether or - // not access to the unsafe package is available. - UnsafeDisabled = false - - // ptrSize is the size of a pointer on the current arch. - ptrSize = unsafe.Sizeof((*byte)(nil)) -) - -type flag uintptr - -var ( - // flagRO indicates whether the value field of a reflect.Value - // is read-only. - flagRO flag - - // flagAddr indicates whether the address of the reflect.Value's - // value may be taken. - flagAddr flag -) - -// flagKindMask holds the bits that make up the kind -// part of the flags field. In all the supported versions, -// it is in the lower 5 bits. -const flagKindMask = flag(0x1f) - -// Different versions of Go have used different -// bit layouts for the flags type. This table -// records the known combinations. -var okFlags = []struct { - ro, addr flag -}{{ - // From Go 1.4 to 1.5 - ro: 1 << 5, - addr: 1 << 7, -}, { - // Up to Go tip. - ro: 1<<5 | 1<<6, - addr: 1 << 8, -}} - -var flagValOffset = func() uintptr { - field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") - if !ok { - panic("reflect.Value has no flag field") - } - return field.Offset -}() - -// flagField returns a pointer to the flag field of a reflect.Value. -func flagField(v *reflect.Value) *flag { - return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) -} - -// unsafeReflectValue converts the passed reflect.Value into a one that bypasses -// the typical safety restrictions preventing access to unaddressable and -// unexported data. It works by digging the raw pointer to the underlying -// value out of the protected value and generating a new unprotected (unsafe) -// reflect.Value to it. -// -// This allows us to check for implementations of the Stringer and error -// interfaces to be used for pretty printing ordinarily unaddressable and -// inaccessible values such as unexported struct fields. -func unsafeReflectValue(v reflect.Value) reflect.Value { - if !v.IsValid() || (v.CanInterface() && v.CanAddr()) { - return v - } - flagFieldPtr := flagField(&v) - *flagFieldPtr &^= flagRO - *flagFieldPtr |= flagAddr - return v -} - -// Sanity checks against future reflect package changes -// to the type or semantics of the Value.flag field. -func init() { - field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") - if !ok { - panic("reflect.Value has no flag field") - } - if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { - panic("reflect.Value flag field has changed kind") - } - type t0 int - var t struct { - A t0 - // t0 will have flagEmbedRO set. - t0 - // a will have flagStickyRO set - a t0 - } - vA := reflect.ValueOf(t).FieldByName("A") - va := reflect.ValueOf(t).FieldByName("a") - vt0 := reflect.ValueOf(t).FieldByName("t0") - - // Infer flagRO from the difference between the flags - // for the (otherwise identical) fields in t. - flagPublic := *flagField(&vA) - flagWithRO := *flagField(&va) | *flagField(&vt0) - flagRO = flagPublic ^ flagWithRO - - // Infer flagAddr from the difference between a value - // taken from a pointer and not. - vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A") - flagNoPtr := *flagField(&vA) - flagPtr := *flagField(&vPtrA) - flagAddr = flagNoPtr ^ flagPtr - - // Check that the inferred flags tally with one of the known versions. - for _, f := range okFlags { - if flagRO == f.ro && flagAddr == f.addr { - return - } - } - panic("reflect.Value read-only flag has changed semantics") -} diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go deleted file mode 100644 index 205c28d..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2015-2016 Dave Collins -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when the code is running on Google App Engine, compiled by GopherJS, or -// "-tags safe" is added to the go build command line. The "disableunsafe" -// tag is deprecated and thus should not be used. -// +build js appengine safe disableunsafe !go1.4 - -package spew - -import "reflect" - -const ( - // UnsafeDisabled is a build-time constant which specifies whether or - // not access to the unsafe package is available. - UnsafeDisabled = true -) - -// unsafeReflectValue typically converts the passed reflect.Value into a one -// that bypasses the typical safety restrictions preventing access to -// unaddressable and unexported data. However, doing this relies on access to -// the unsafe package. This is a stub version which simply returns the passed -// reflect.Value when the unsafe package is not available. -func unsafeReflectValue(v reflect.Value) reflect.Value { - return v -} diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go deleted file mode 100644 index 1be8ce9..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/common.go +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "bytes" - "fmt" - "io" - "reflect" - "sort" - "strconv" -) - -// Some constants in the form of bytes to avoid string overhead. This mirrors -// the technique used in the fmt package. -var ( - panicBytes = []byte("(PANIC=") - plusBytes = []byte("+") - iBytes = []byte("i") - trueBytes = []byte("true") - falseBytes = []byte("false") - interfaceBytes = []byte("(interface {})") - commaNewlineBytes = []byte(",\n") - newlineBytes = []byte("\n") - openBraceBytes = []byte("{") - openBraceNewlineBytes = []byte("{\n") - closeBraceBytes = []byte("}") - asteriskBytes = []byte("*") - colonBytes = []byte(":") - colonSpaceBytes = []byte(": ") - openParenBytes = []byte("(") - closeParenBytes = []byte(")") - spaceBytes = []byte(" ") - pointerChainBytes = []byte("->") - nilAngleBytes = []byte("") - maxNewlineBytes = []byte("\n") - maxShortBytes = []byte("") - circularBytes = []byte("") - circularShortBytes = []byte("") - invalidAngleBytes = []byte("") - openBracketBytes = []byte("[") - closeBracketBytes = []byte("]") - percentBytes = []byte("%") - precisionBytes = []byte(".") - openAngleBytes = []byte("<") - closeAngleBytes = []byte(">") - openMapBytes = []byte("map[") - closeMapBytes = []byte("]") - lenEqualsBytes = []byte("len=") - capEqualsBytes = []byte("cap=") -) - -// hexDigits is used to map a decimal value to a hex digit. -var hexDigits = "0123456789abcdef" - -// catchPanic handles any panics that might occur during the handleMethods -// calls. -func catchPanic(w io.Writer, v reflect.Value) { - if err := recover(); err != nil { - w.Write(panicBytes) - fmt.Fprintf(w, "%v", err) - w.Write(closeParenBytes) - } -} - -// handleMethods attempts to call the Error and String methods on the underlying -// type the passed reflect.Value represents and outputes the result to Writer w. -// -// It handles panics in any called methods by catching and displaying the error -// as the formatted value. -func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) { - // We need an interface to check if the type implements the error or - // Stringer interface. However, the reflect package won't give us an - // interface on certain things like unexported struct fields in order - // to enforce visibility rules. We use unsafe, when it's available, - // to bypass these restrictions since this package does not mutate the - // values. - if !v.CanInterface() { - if UnsafeDisabled { - return false - } - - v = unsafeReflectValue(v) - } - - // Choose whether or not to do error and Stringer interface lookups against - // the base type or a pointer to the base type depending on settings. - // Technically calling one of these methods with a pointer receiver can - // mutate the value, however, types which choose to satisify an error or - // Stringer interface with a pointer receiver should not be mutating their - // state inside these interface methods. - if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() { - v = unsafeReflectValue(v) - } - if v.CanAddr() { - v = v.Addr() - } - - // Is it an error or Stringer? - switch iface := v.Interface().(type) { - case error: - defer catchPanic(w, v) - if cs.ContinueOnMethod { - w.Write(openParenBytes) - w.Write([]byte(iface.Error())) - w.Write(closeParenBytes) - w.Write(spaceBytes) - return false - } - - w.Write([]byte(iface.Error())) - return true - - case fmt.Stringer: - defer catchPanic(w, v) - if cs.ContinueOnMethod { - w.Write(openParenBytes) - w.Write([]byte(iface.String())) - w.Write(closeParenBytes) - w.Write(spaceBytes) - return false - } - w.Write([]byte(iface.String())) - return true - } - return false -} - -// printBool outputs a boolean value as true or false to Writer w. -func printBool(w io.Writer, val bool) { - if val { - w.Write(trueBytes) - } else { - w.Write(falseBytes) - } -} - -// printInt outputs a signed integer value to Writer w. -func printInt(w io.Writer, val int64, base int) { - w.Write([]byte(strconv.FormatInt(val, base))) -} - -// printUint outputs an unsigned integer value to Writer w. -func printUint(w io.Writer, val uint64, base int) { - w.Write([]byte(strconv.FormatUint(val, base))) -} - -// printFloat outputs a floating point value using the specified precision, -// which is expected to be 32 or 64bit, to Writer w. -func printFloat(w io.Writer, val float64, precision int) { - w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision))) -} - -// printComplex outputs a complex value using the specified float precision -// for the real and imaginary parts to Writer w. -func printComplex(w io.Writer, c complex128, floatPrecision int) { - r := real(c) - w.Write(openParenBytes) - w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision))) - i := imag(c) - if i >= 0 { - w.Write(plusBytes) - } - w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision))) - w.Write(iBytes) - w.Write(closeParenBytes) -} - -// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x' -// prefix to Writer w. -func printHexPtr(w io.Writer, p uintptr) { - // Null pointer. - num := uint64(p) - if num == 0 { - w.Write(nilAngleBytes) - return - } - - // Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix - buf := make([]byte, 18) - - // It's simpler to construct the hex string right to left. - base := uint64(16) - i := len(buf) - 1 - for num >= base { - buf[i] = hexDigits[num%base] - num /= base - i-- - } - buf[i] = hexDigits[num] - - // Add '0x' prefix. - i-- - buf[i] = 'x' - i-- - buf[i] = '0' - - // Strip unused leading bytes. - buf = buf[i:] - w.Write(buf) -} - -// valuesSorter implements sort.Interface to allow a slice of reflect.Value -// elements to be sorted. -type valuesSorter struct { - values []reflect.Value - strings []string // either nil or same len and values - cs *ConfigState -} - -// newValuesSorter initializes a valuesSorter instance, which holds a set of -// surrogate keys on which the data should be sorted. It uses flags in -// ConfigState to decide if and how to populate those surrogate keys. -func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface { - vs := &valuesSorter{values: values, cs: cs} - if canSortSimply(vs.values[0].Kind()) { - return vs - } - if !cs.DisableMethods { - vs.strings = make([]string, len(values)) - for i := range vs.values { - b := bytes.Buffer{} - if !handleMethods(cs, &b, vs.values[i]) { - vs.strings = nil - break - } - vs.strings[i] = b.String() - } - } - if vs.strings == nil && cs.SpewKeys { - vs.strings = make([]string, len(values)) - for i := range vs.values { - vs.strings[i] = Sprintf("%#v", vs.values[i].Interface()) - } - } - return vs -} - -// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted -// directly, or whether it should be considered for sorting by surrogate keys -// (if the ConfigState allows it). -func canSortSimply(kind reflect.Kind) bool { - // This switch parallels valueSortLess, except for the default case. - switch kind { - case reflect.Bool: - return true - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - return true - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: - return true - case reflect.Float32, reflect.Float64: - return true - case reflect.String: - return true - case reflect.Uintptr: - return true - case reflect.Array: - return true - } - return false -} - -// Len returns the number of values in the slice. It is part of the -// sort.Interface implementation. -func (s *valuesSorter) Len() int { - return len(s.values) -} - -// Swap swaps the values at the passed indices. It is part of the -// sort.Interface implementation. -func (s *valuesSorter) Swap(i, j int) { - s.values[i], s.values[j] = s.values[j], s.values[i] - if s.strings != nil { - s.strings[i], s.strings[j] = s.strings[j], s.strings[i] - } -} - -// valueSortLess returns whether the first value should sort before the second -// value. It is used by valueSorter.Less as part of the sort.Interface -// implementation. -func valueSortLess(a, b reflect.Value) bool { - switch a.Kind() { - case reflect.Bool: - return !a.Bool() && b.Bool() - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - return a.Int() < b.Int() - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: - return a.Uint() < b.Uint() - case reflect.Float32, reflect.Float64: - return a.Float() < b.Float() - case reflect.String: - return a.String() < b.String() - case reflect.Uintptr: - return a.Uint() < b.Uint() - case reflect.Array: - // Compare the contents of both arrays. - l := a.Len() - for i := 0; i < l; i++ { - av := a.Index(i) - bv := b.Index(i) - if av.Interface() == bv.Interface() { - continue - } - return valueSortLess(av, bv) - } - } - return a.String() < b.String() -} - -// Less returns whether the value at index i should sort before the -// value at index j. It is part of the sort.Interface implementation. -func (s *valuesSorter) Less(i, j int) bool { - if s.strings == nil { - return valueSortLess(s.values[i], s.values[j]) - } - return s.strings[i] < s.strings[j] -} - -// sortValues is a sort function that handles both native types and any type that -// can be converted to error or Stringer. Other inputs are sorted according to -// their Value.String() value to ensure display stability. -func sortValues(values []reflect.Value, cs *ConfigState) { - if len(values) == 0 { - return - } - sort.Sort(newValuesSorter(values, cs)) -} diff --git a/vendor/github.com/davecgh/go-spew/spew/config.go b/vendor/github.com/davecgh/go-spew/spew/config.go deleted file mode 100644 index 2e3d22f..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/config.go +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "bytes" - "fmt" - "io" - "os" -) - -// ConfigState houses the configuration options used by spew to format and -// display values. There is a global instance, Config, that is used to control -// all top-level Formatter and Dump functionality. Each ConfigState instance -// provides methods equivalent to the top-level functions. -// -// The zero value for ConfigState provides no indentation. You would typically -// want to set it to a space or a tab. -// -// Alternatively, you can use NewDefaultConfig to get a ConfigState instance -// with default settings. See the documentation of NewDefaultConfig for default -// values. -type ConfigState struct { - // Indent specifies the string to use for each indentation level. The - // global config instance that all top-level functions use set this to a - // single space by default. If you would like more indentation, you might - // set this to a tab with "\t" or perhaps two spaces with " ". - Indent string - - // MaxDepth controls the maximum number of levels to descend into nested - // data structures. The default, 0, means there is no limit. - // - // NOTE: Circular data structures are properly detected, so it is not - // necessary to set this value unless you specifically want to limit deeply - // nested data structures. - MaxDepth int - - // DisableMethods specifies whether or not error and Stringer interfaces are - // invoked for types that implement them. - DisableMethods bool - - // DisablePointerMethods specifies whether or not to check for and invoke - // error and Stringer interfaces on types which only accept a pointer - // receiver when the current type is not a pointer. - // - // NOTE: This might be an unsafe action since calling one of these methods - // with a pointer receiver could technically mutate the value, however, - // in practice, types which choose to satisify an error or Stringer - // interface with a pointer receiver should not be mutating their state - // inside these interface methods. As a result, this option relies on - // access to the unsafe package, so it will not have any effect when - // running in environments without access to the unsafe package such as - // Google App Engine or with the "safe" build tag specified. - DisablePointerMethods bool - - // DisablePointerAddresses specifies whether to disable the printing of - // pointer addresses. This is useful when diffing data structures in tests. - DisablePointerAddresses bool - - // DisableCapacities specifies whether to disable the printing of capacities - // for arrays, slices, maps and channels. This is useful when diffing - // data structures in tests. - DisableCapacities bool - - // ContinueOnMethod specifies whether or not recursion should continue once - // a custom error or Stringer interface is invoked. The default, false, - // means it will print the results of invoking the custom error or Stringer - // interface and return immediately instead of continuing to recurse into - // the internals of the data type. - // - // NOTE: This flag does not have any effect if method invocation is disabled - // via the DisableMethods or DisablePointerMethods options. - ContinueOnMethod bool - - // SortKeys specifies map keys should be sorted before being printed. Use - // this to have a more deterministic, diffable output. Note that only - // native types (bool, int, uint, floats, uintptr and string) and types - // that support the error or Stringer interfaces (if methods are - // enabled) are supported, with other types sorted according to the - // reflect.Value.String() output which guarantees display stability. - SortKeys bool - - // SpewKeys specifies that, as a last resort attempt, map keys should - // be spewed to strings and sorted by those strings. This is only - // considered if SortKeys is true. - SpewKeys bool -} - -// Config is the active configuration of the top-level functions. -// The configuration can be changed by modifying the contents of spew.Config. -var Config = ConfigState{Indent: " "} - -// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the formatted string as a value that satisfies error. See NewFormatter -// for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) { - return fmt.Errorf(format, c.convertArgs(a)...) -} - -// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) { - return fmt.Fprint(w, c.convertArgs(a)...) -} - -// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { - return fmt.Fprintf(w, format, c.convertArgs(a)...) -} - -// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it -// passed with a Formatter interface returned by c.NewFormatter. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) { - return fmt.Fprintln(w, c.convertArgs(a)...) -} - -// Print is a wrapper for fmt.Print that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Print(c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Print(a ...interface{}) (n int, err error) { - return fmt.Print(c.convertArgs(a)...) -} - -// Printf is a wrapper for fmt.Printf that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) { - return fmt.Printf(format, c.convertArgs(a)...) -} - -// Println is a wrapper for fmt.Println that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Println(c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Println(a ...interface{}) (n int, err error) { - return fmt.Println(c.convertArgs(a)...) -} - -// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Sprint(a ...interface{}) string { - return fmt.Sprint(c.convertArgs(a)...) -} - -// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Sprintf(format string, a ...interface{}) string { - return fmt.Sprintf(format, c.convertArgs(a)...) -} - -// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it -// were passed with a Formatter interface returned by c.NewFormatter. It -// returns the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Sprintln(a ...interface{}) string { - return fmt.Sprintln(c.convertArgs(a)...) -} - -/* -NewFormatter returns a custom formatter that satisfies the fmt.Formatter -interface. As a result, it integrates cleanly with standard fmt package -printing functions. The formatter is useful for inline printing of smaller data -types similar to the standard %v format specifier. - -The custom formatter only responds to the %v (most compact), %+v (adds pointer -addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb -combinations. Any other verbs such as %x and %q will be sent to the the -standard fmt package for formatting. In addition, the custom formatter ignores -the width and precision arguments (however they will still work on the format -specifiers not handled by the custom formatter). - -Typically this function shouldn't be called directly. It is much easier to make -use of the custom formatter by calling one of the convenience functions such as -c.Printf, c.Println, or c.Printf. -*/ -func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter { - return newFormatter(c, v) -} - -// Fdump formats and displays the passed arguments to io.Writer w. It formats -// exactly the same as Dump. -func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) { - fdump(c, w, a...) -} - -/* -Dump displays the passed parameters to standard out with newlines, customizable -indentation, and additional debug information such as complete types and all -pointer addresses used to indirect to the final value. It provides the -following features over the built-in printing facilities provided by the fmt -package: - - * Pointers are dereferenced and followed - * Circular data structures are detected and handled properly - * Custom Stringer/error interfaces are optionally invoked, including - on unexported types - * Custom types which only implement the Stringer/error interfaces via - a pointer receiver are optionally invoked when passing non-pointer - variables - * Byte arrays and slices are dumped like the hexdump -C command which - includes offsets, byte values in hex, and ASCII output - -The configuration options are controlled by modifying the public members -of c. See ConfigState for options documentation. - -See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to -get the formatted result as a string. -*/ -func (c *ConfigState) Dump(a ...interface{}) { - fdump(c, os.Stdout, a...) -} - -// Sdump returns a string with the passed arguments formatted exactly the same -// as Dump. -func (c *ConfigState) Sdump(a ...interface{}) string { - var buf bytes.Buffer - fdump(c, &buf, a...) - return buf.String() -} - -// convertArgs accepts a slice of arguments and returns a slice of the same -// length with each argument converted to a spew Formatter interface using -// the ConfigState associated with s. -func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) { - formatters = make([]interface{}, len(args)) - for index, arg := range args { - formatters[index] = newFormatter(c, arg) - } - return formatters -} - -// NewDefaultConfig returns a ConfigState with the following default settings. -// -// Indent: " " -// MaxDepth: 0 -// DisableMethods: false -// DisablePointerMethods: false -// ContinueOnMethod: false -// SortKeys: false -func NewDefaultConfig() *ConfigState { - return &ConfigState{Indent: " "} -} diff --git a/vendor/github.com/davecgh/go-spew/spew/doc.go b/vendor/github.com/davecgh/go-spew/spew/doc.go deleted file mode 100644 index aacaac6..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/doc.go +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* -Package spew implements a deep pretty printer for Go data structures to aid in -debugging. - -A quick overview of the additional features spew provides over the built-in -printing facilities for Go data types are as follows: - - * Pointers are dereferenced and followed - * Circular data structures are detected and handled properly - * Custom Stringer/error interfaces are optionally invoked, including - on unexported types - * Custom types which only implement the Stringer/error interfaces via - a pointer receiver are optionally invoked when passing non-pointer - variables - * Byte arrays and slices are dumped like the hexdump -C command which - includes offsets, byte values in hex, and ASCII output (only when using - Dump style) - -There are two different approaches spew allows for dumping Go data structures: - - * Dump style which prints with newlines, customizable indentation, - and additional debug information such as types and all pointer addresses - used to indirect to the final value - * A custom Formatter interface that integrates cleanly with the standard fmt - package and replaces %v, %+v, %#v, and %#+v to provide inline printing - similar to the default %v while providing the additional functionality - outlined above and passing unsupported format verbs such as %x and %q - along to fmt - -Quick Start - -This section demonstrates how to quickly get started with spew. See the -sections below for further details on formatting and configuration options. - -To dump a variable with full newlines, indentation, type, and pointer -information use Dump, Fdump, or Sdump: - spew.Dump(myVar1, myVar2, ...) - spew.Fdump(someWriter, myVar1, myVar2, ...) - str := spew.Sdump(myVar1, myVar2, ...) - -Alternatively, if you would prefer to use format strings with a compacted inline -printing style, use the convenience wrappers Printf, Fprintf, etc with -%v (most compact), %+v (adds pointer addresses), %#v (adds types), or -%#+v (adds types and pointer addresses): - spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) - spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) - spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) - spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) - -Configuration Options - -Configuration of spew is handled by fields in the ConfigState type. For -convenience, all of the top-level functions use a global state available -via the spew.Config global. - -It is also possible to create a ConfigState instance that provides methods -equivalent to the top-level functions. This allows concurrent configuration -options. See the ConfigState documentation for more details. - -The following configuration options are available: - * Indent - String to use for each indentation level for Dump functions. - It is a single space by default. A popular alternative is "\t". - - * MaxDepth - Maximum number of levels to descend into nested data structures. - There is no limit by default. - - * DisableMethods - Disables invocation of error and Stringer interface methods. - Method invocation is enabled by default. - - * DisablePointerMethods - Disables invocation of error and Stringer interface methods on types - which only accept pointer receivers from non-pointer variables. - Pointer method invocation is enabled by default. - - * DisablePointerAddresses - DisablePointerAddresses specifies whether to disable the printing of - pointer addresses. This is useful when diffing data structures in tests. - - * DisableCapacities - DisableCapacities specifies whether to disable the printing of - capacities for arrays, slices, maps and channels. This is useful when - diffing data structures in tests. - - * ContinueOnMethod - Enables recursion into types after invoking error and Stringer interface - methods. Recursion after method invocation is disabled by default. - - * SortKeys - Specifies map keys should be sorted before being printed. Use - this to have a more deterministic, diffable output. Note that - only native types (bool, int, uint, floats, uintptr and string) - and types which implement error or Stringer interfaces are - supported with other types sorted according to the - reflect.Value.String() output which guarantees display - stability. Natural map order is used by default. - - * SpewKeys - Specifies that, as a last resort attempt, map keys should be - spewed to strings and sorted by those strings. This is only - considered if SortKeys is true. - -Dump Usage - -Simply call spew.Dump with a list of variables you want to dump: - - spew.Dump(myVar1, myVar2, ...) - -You may also call spew.Fdump if you would prefer to output to an arbitrary -io.Writer. For example, to dump to standard error: - - spew.Fdump(os.Stderr, myVar1, myVar2, ...) - -A third option is to call spew.Sdump to get the formatted output as a string: - - str := spew.Sdump(myVar1, myVar2, ...) - -Sample Dump Output - -See the Dump example for details on the setup of the types and variables being -shown here. - - (main.Foo) { - unexportedField: (*main.Bar)(0xf84002e210)({ - flag: (main.Flag) flagTwo, - data: (uintptr) - }), - ExportedField: (map[interface {}]interface {}) (len=1) { - (string) (len=3) "one": (bool) true - } - } - -Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C -command as shown. - ([]uint8) (len=32 cap=32) { - 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | - 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| - 00000020 31 32 |12| - } - -Custom Formatter - -Spew provides a custom formatter that implements the fmt.Formatter interface -so that it integrates cleanly with standard fmt package printing functions. The -formatter is useful for inline printing of smaller data types similar to the -standard %v format specifier. - -The custom formatter only responds to the %v (most compact), %+v (adds pointer -addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb -combinations. Any other verbs such as %x and %q will be sent to the the -standard fmt package for formatting. In addition, the custom formatter ignores -the width and precision arguments (however they will still work on the format -specifiers not handled by the custom formatter). - -Custom Formatter Usage - -The simplest way to make use of the spew custom formatter is to call one of the -convenience functions such as spew.Printf, spew.Println, or spew.Printf. The -functions have syntax you are most likely already familiar with: - - spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) - spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) - spew.Println(myVar, myVar2) - spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) - spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) - -See the Index for the full list convenience functions. - -Sample Formatter Output - -Double pointer to a uint8: - %v: <**>5 - %+v: <**>(0xf8400420d0->0xf8400420c8)5 - %#v: (**uint8)5 - %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5 - -Pointer to circular struct with a uint8 field and a pointer to itself: - %v: <*>{1 <*>} - %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)} - %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)} - %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)} - -See the Printf example for details on the setup of variables being shown -here. - -Errors - -Since it is possible for custom Stringer/error interfaces to panic, spew -detects them and handles them internally by printing the panic information -inline with the output. Since spew is intended to provide deep pretty printing -capabilities on structures, it intentionally does not return any errors. -*/ -package spew diff --git a/vendor/github.com/davecgh/go-spew/spew/dump.go b/vendor/github.com/davecgh/go-spew/spew/dump.go deleted file mode 100644 index f78d89f..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/dump.go +++ /dev/null @@ -1,509 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "bytes" - "encoding/hex" - "fmt" - "io" - "os" - "reflect" - "regexp" - "strconv" - "strings" -) - -var ( - // uint8Type is a reflect.Type representing a uint8. It is used to - // convert cgo types to uint8 slices for hexdumping. - uint8Type = reflect.TypeOf(uint8(0)) - - // cCharRE is a regular expression that matches a cgo char. - // It is used to detect character arrays to hexdump them. - cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`) - - // cUnsignedCharRE is a regular expression that matches a cgo unsigned - // char. It is used to detect unsigned character arrays to hexdump - // them. - cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`) - - // cUint8tCharRE is a regular expression that matches a cgo uint8_t. - // It is used to detect uint8_t arrays to hexdump them. - cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`) -) - -// dumpState contains information about the state of a dump operation. -type dumpState struct { - w io.Writer - depth int - pointers map[uintptr]int - ignoreNextType bool - ignoreNextIndent bool - cs *ConfigState -} - -// indent performs indentation according to the depth level and cs.Indent -// option. -func (d *dumpState) indent() { - if d.ignoreNextIndent { - d.ignoreNextIndent = false - return - } - d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) -} - -// unpackValue returns values inside of non-nil interfaces when possible. -// This is useful for data types like structs, arrays, slices, and maps which -// can contain varying types packed inside an interface. -func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { - if v.Kind() == reflect.Interface && !v.IsNil() { - v = v.Elem() - } - return v -} - -// dumpPtr handles formatting of pointers by indirecting them as necessary. -func (d *dumpState) dumpPtr(v reflect.Value) { - // Remove pointers at or below the current depth from map used to detect - // circular refs. - for k, depth := range d.pointers { - if depth >= d.depth { - delete(d.pointers, k) - } - } - - // Keep list of all dereferenced pointers to show later. - pointerChain := make([]uintptr, 0) - - // Figure out how many levels of indirection there are by dereferencing - // pointers and unpacking interfaces down the chain while detecting circular - // references. - nilFound := false - cycleFound := false - indirects := 0 - ve := v - for ve.Kind() == reflect.Ptr { - if ve.IsNil() { - nilFound = true - break - } - indirects++ - addr := ve.Pointer() - pointerChain = append(pointerChain, addr) - if pd, ok := d.pointers[addr]; ok && pd < d.depth { - cycleFound = true - indirects-- - break - } - d.pointers[addr] = d.depth - - ve = ve.Elem() - if ve.Kind() == reflect.Interface { - if ve.IsNil() { - nilFound = true - break - } - ve = ve.Elem() - } - } - - // Display type information. - d.w.Write(openParenBytes) - d.w.Write(bytes.Repeat(asteriskBytes, indirects)) - d.w.Write([]byte(ve.Type().String())) - d.w.Write(closeParenBytes) - - // Display pointer information. - if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 { - d.w.Write(openParenBytes) - for i, addr := range pointerChain { - if i > 0 { - d.w.Write(pointerChainBytes) - } - printHexPtr(d.w, addr) - } - d.w.Write(closeParenBytes) - } - - // Display dereferenced value. - d.w.Write(openParenBytes) - switch { - case nilFound: - d.w.Write(nilAngleBytes) - - case cycleFound: - d.w.Write(circularBytes) - - default: - d.ignoreNextType = true - d.dump(ve) - } - d.w.Write(closeParenBytes) -} - -// dumpSlice handles formatting of arrays and slices. Byte (uint8 under -// reflection) arrays and slices are dumped in hexdump -C fashion. -func (d *dumpState) dumpSlice(v reflect.Value) { - // Determine whether this type should be hex dumped or not. Also, - // for types which should be hexdumped, try to use the underlying data - // first, then fall back to trying to convert them to a uint8 slice. - var buf []uint8 - doConvert := false - doHexDump := false - numEntries := v.Len() - if numEntries > 0 { - vt := v.Index(0).Type() - vts := vt.String() - switch { - // C types that need to be converted. - case cCharRE.MatchString(vts): - fallthrough - case cUnsignedCharRE.MatchString(vts): - fallthrough - case cUint8tCharRE.MatchString(vts): - doConvert = true - - // Try to use existing uint8 slices and fall back to converting - // and copying if that fails. - case vt.Kind() == reflect.Uint8: - // We need an addressable interface to convert the type - // to a byte slice. However, the reflect package won't - // give us an interface on certain things like - // unexported struct fields in order to enforce - // visibility rules. We use unsafe, when available, to - // bypass these restrictions since this package does not - // mutate the values. - vs := v - if !vs.CanInterface() || !vs.CanAddr() { - vs = unsafeReflectValue(vs) - } - if !UnsafeDisabled { - vs = vs.Slice(0, numEntries) - - // Use the existing uint8 slice if it can be - // type asserted. - iface := vs.Interface() - if slice, ok := iface.([]uint8); ok { - buf = slice - doHexDump = true - break - } - } - - // The underlying data needs to be converted if it can't - // be type asserted to a uint8 slice. - doConvert = true - } - - // Copy and convert the underlying type if needed. - if doConvert && vt.ConvertibleTo(uint8Type) { - // Convert and copy each element into a uint8 byte - // slice. - buf = make([]uint8, numEntries) - for i := 0; i < numEntries; i++ { - vv := v.Index(i) - buf[i] = uint8(vv.Convert(uint8Type).Uint()) - } - doHexDump = true - } - } - - // Hexdump the entire slice as needed. - if doHexDump { - indent := strings.Repeat(d.cs.Indent, d.depth) - str := indent + hex.Dump(buf) - str = strings.Replace(str, "\n", "\n"+indent, -1) - str = strings.TrimRight(str, d.cs.Indent) - d.w.Write([]byte(str)) - return - } - - // Recursively call dump for each item. - for i := 0; i < numEntries; i++ { - d.dump(d.unpackValue(v.Index(i))) - if i < (numEntries - 1) { - d.w.Write(commaNewlineBytes) - } else { - d.w.Write(newlineBytes) - } - } -} - -// dump is the main workhorse for dumping a value. It uses the passed reflect -// value to figure out what kind of object we are dealing with and formats it -// appropriately. It is a recursive function, however circular data structures -// are detected and handled properly. -func (d *dumpState) dump(v reflect.Value) { - // Handle invalid reflect values immediately. - kind := v.Kind() - if kind == reflect.Invalid { - d.w.Write(invalidAngleBytes) - return - } - - // Handle pointers specially. - if kind == reflect.Ptr { - d.indent() - d.dumpPtr(v) - return - } - - // Print type information unless already handled elsewhere. - if !d.ignoreNextType { - d.indent() - d.w.Write(openParenBytes) - d.w.Write([]byte(v.Type().String())) - d.w.Write(closeParenBytes) - d.w.Write(spaceBytes) - } - d.ignoreNextType = false - - // Display length and capacity if the built-in len and cap functions - // work with the value's kind and the len/cap itself is non-zero. - valueLen, valueCap := 0, 0 - switch v.Kind() { - case reflect.Array, reflect.Slice, reflect.Chan: - valueLen, valueCap = v.Len(), v.Cap() - case reflect.Map, reflect.String: - valueLen = v.Len() - } - if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 { - d.w.Write(openParenBytes) - if valueLen != 0 { - d.w.Write(lenEqualsBytes) - printInt(d.w, int64(valueLen), 10) - } - if !d.cs.DisableCapacities && valueCap != 0 { - if valueLen != 0 { - d.w.Write(spaceBytes) - } - d.w.Write(capEqualsBytes) - printInt(d.w, int64(valueCap), 10) - } - d.w.Write(closeParenBytes) - d.w.Write(spaceBytes) - } - - // Call Stringer/error interfaces if they exist and the handle methods flag - // is enabled - if !d.cs.DisableMethods { - if (kind != reflect.Invalid) && (kind != reflect.Interface) { - if handled := handleMethods(d.cs, d.w, v); handled { - return - } - } - } - - switch kind { - case reflect.Invalid: - // Do nothing. We should never get here since invalid has already - // been handled above. - - case reflect.Bool: - printBool(d.w, v.Bool()) - - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - printInt(d.w, v.Int(), 10) - - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: - printUint(d.w, v.Uint(), 10) - - case reflect.Float32: - printFloat(d.w, v.Float(), 32) - - case reflect.Float64: - printFloat(d.w, v.Float(), 64) - - case reflect.Complex64: - printComplex(d.w, v.Complex(), 32) - - case reflect.Complex128: - printComplex(d.w, v.Complex(), 64) - - case reflect.Slice: - if v.IsNil() { - d.w.Write(nilAngleBytes) - break - } - fallthrough - - case reflect.Array: - d.w.Write(openBraceNewlineBytes) - d.depth++ - if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { - d.indent() - d.w.Write(maxNewlineBytes) - } else { - d.dumpSlice(v) - } - d.depth-- - d.indent() - d.w.Write(closeBraceBytes) - - case reflect.String: - d.w.Write([]byte(strconv.Quote(v.String()))) - - case reflect.Interface: - // The only time we should get here is for nil interfaces due to - // unpackValue calls. - if v.IsNil() { - d.w.Write(nilAngleBytes) - } - - case reflect.Ptr: - // Do nothing. We should never get here since pointers have already - // been handled above. - - case reflect.Map: - // nil maps should be indicated as different than empty maps - if v.IsNil() { - d.w.Write(nilAngleBytes) - break - } - - d.w.Write(openBraceNewlineBytes) - d.depth++ - if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { - d.indent() - d.w.Write(maxNewlineBytes) - } else { - numEntries := v.Len() - keys := v.MapKeys() - if d.cs.SortKeys { - sortValues(keys, d.cs) - } - for i, key := range keys { - d.dump(d.unpackValue(key)) - d.w.Write(colonSpaceBytes) - d.ignoreNextIndent = true - d.dump(d.unpackValue(v.MapIndex(key))) - if i < (numEntries - 1) { - d.w.Write(commaNewlineBytes) - } else { - d.w.Write(newlineBytes) - } - } - } - d.depth-- - d.indent() - d.w.Write(closeBraceBytes) - - case reflect.Struct: - d.w.Write(openBraceNewlineBytes) - d.depth++ - if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { - d.indent() - d.w.Write(maxNewlineBytes) - } else { - vt := v.Type() - numFields := v.NumField() - for i := 0; i < numFields; i++ { - d.indent() - vtf := vt.Field(i) - d.w.Write([]byte(vtf.Name)) - d.w.Write(colonSpaceBytes) - d.ignoreNextIndent = true - d.dump(d.unpackValue(v.Field(i))) - if i < (numFields - 1) { - d.w.Write(commaNewlineBytes) - } else { - d.w.Write(newlineBytes) - } - } - } - d.depth-- - d.indent() - d.w.Write(closeBraceBytes) - - case reflect.Uintptr: - printHexPtr(d.w, uintptr(v.Uint())) - - case reflect.UnsafePointer, reflect.Chan, reflect.Func: - printHexPtr(d.w, v.Pointer()) - - // There were not any other types at the time this code was written, but - // fall back to letting the default fmt package handle it in case any new - // types are added. - default: - if v.CanInterface() { - fmt.Fprintf(d.w, "%v", v.Interface()) - } else { - fmt.Fprintf(d.w, "%v", v.String()) - } - } -} - -// fdump is a helper function to consolidate the logic from the various public -// methods which take varying writers and config states. -func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { - for _, arg := range a { - if arg == nil { - w.Write(interfaceBytes) - w.Write(spaceBytes) - w.Write(nilAngleBytes) - w.Write(newlineBytes) - continue - } - - d := dumpState{w: w, cs: cs} - d.pointers = make(map[uintptr]int) - d.dump(reflect.ValueOf(arg)) - d.w.Write(newlineBytes) - } -} - -// Fdump formats and displays the passed arguments to io.Writer w. It formats -// exactly the same as Dump. -func Fdump(w io.Writer, a ...interface{}) { - fdump(&Config, w, a...) -} - -// Sdump returns a string with the passed arguments formatted exactly the same -// as Dump. -func Sdump(a ...interface{}) string { - var buf bytes.Buffer - fdump(&Config, &buf, a...) - return buf.String() -} - -/* -Dump displays the passed parameters to standard out with newlines, customizable -indentation, and additional debug information such as complete types and all -pointer addresses used to indirect to the final value. It provides the -following features over the built-in printing facilities provided by the fmt -package: - - * Pointers are dereferenced and followed - * Circular data structures are detected and handled properly - * Custom Stringer/error interfaces are optionally invoked, including - on unexported types - * Custom types which only implement the Stringer/error interfaces via - a pointer receiver are optionally invoked when passing non-pointer - variables - * Byte arrays and slices are dumped like the hexdump -C command which - includes offsets, byte values in hex, and ASCII output - -The configuration options are controlled by an exported package global, -spew.Config. See ConfigState for options documentation. - -See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to -get the formatted result as a string. -*/ -func Dump(a ...interface{}) { - fdump(&Config, os.Stdout, a...) -} diff --git a/vendor/github.com/davecgh/go-spew/spew/format.go b/vendor/github.com/davecgh/go-spew/spew/format.go deleted file mode 100644 index b04edb7..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/format.go +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "bytes" - "fmt" - "reflect" - "strconv" - "strings" -) - -// supportedFlags is a list of all the character flags supported by fmt package. -const supportedFlags = "0-+# " - -// formatState implements the fmt.Formatter interface and contains information -// about the state of a formatting operation. The NewFormatter function can -// be used to get a new Formatter which can be used directly as arguments -// in standard fmt package printing calls. -type formatState struct { - value interface{} - fs fmt.State - depth int - pointers map[uintptr]int - ignoreNextType bool - cs *ConfigState -} - -// buildDefaultFormat recreates the original format string without precision -// and width information to pass in to fmt.Sprintf in the case of an -// unrecognized type. Unless new types are added to the language, this -// function won't ever be called. -func (f *formatState) buildDefaultFormat() (format string) { - buf := bytes.NewBuffer(percentBytes) - - for _, flag := range supportedFlags { - if f.fs.Flag(int(flag)) { - buf.WriteRune(flag) - } - } - - buf.WriteRune('v') - - format = buf.String() - return format -} - -// constructOrigFormat recreates the original format string including precision -// and width information to pass along to the standard fmt package. This allows -// automatic deferral of all format strings this package doesn't support. -func (f *formatState) constructOrigFormat(verb rune) (format string) { - buf := bytes.NewBuffer(percentBytes) - - for _, flag := range supportedFlags { - if f.fs.Flag(int(flag)) { - buf.WriteRune(flag) - } - } - - if width, ok := f.fs.Width(); ok { - buf.WriteString(strconv.Itoa(width)) - } - - if precision, ok := f.fs.Precision(); ok { - buf.Write(precisionBytes) - buf.WriteString(strconv.Itoa(precision)) - } - - buf.WriteRune(verb) - - format = buf.String() - return format -} - -// unpackValue returns values inside of non-nil interfaces when possible and -// ensures that types for values which have been unpacked from an interface -// are displayed when the show types flag is also set. -// This is useful for data types like structs, arrays, slices, and maps which -// can contain varying types packed inside an interface. -func (f *formatState) unpackValue(v reflect.Value) reflect.Value { - if v.Kind() == reflect.Interface { - f.ignoreNextType = false - if !v.IsNil() { - v = v.Elem() - } - } - return v -} - -// formatPtr handles formatting of pointers by indirecting them as necessary. -func (f *formatState) formatPtr(v reflect.Value) { - // Display nil if top level pointer is nil. - showTypes := f.fs.Flag('#') - if v.IsNil() && (!showTypes || f.ignoreNextType) { - f.fs.Write(nilAngleBytes) - return - } - - // Remove pointers at or below the current depth from map used to detect - // circular refs. - for k, depth := range f.pointers { - if depth >= f.depth { - delete(f.pointers, k) - } - } - - // Keep list of all dereferenced pointers to possibly show later. - pointerChain := make([]uintptr, 0) - - // Figure out how many levels of indirection there are by derferencing - // pointers and unpacking interfaces down the chain while detecting circular - // references. - nilFound := false - cycleFound := false - indirects := 0 - ve := v - for ve.Kind() == reflect.Ptr { - if ve.IsNil() { - nilFound = true - break - } - indirects++ - addr := ve.Pointer() - pointerChain = append(pointerChain, addr) - if pd, ok := f.pointers[addr]; ok && pd < f.depth { - cycleFound = true - indirects-- - break - } - f.pointers[addr] = f.depth - - ve = ve.Elem() - if ve.Kind() == reflect.Interface { - if ve.IsNil() { - nilFound = true - break - } - ve = ve.Elem() - } - } - - // Display type or indirection level depending on flags. - if showTypes && !f.ignoreNextType { - f.fs.Write(openParenBytes) - f.fs.Write(bytes.Repeat(asteriskBytes, indirects)) - f.fs.Write([]byte(ve.Type().String())) - f.fs.Write(closeParenBytes) - } else { - if nilFound || cycleFound { - indirects += strings.Count(ve.Type().String(), "*") - } - f.fs.Write(openAngleBytes) - f.fs.Write([]byte(strings.Repeat("*", indirects))) - f.fs.Write(closeAngleBytes) - } - - // Display pointer information depending on flags. - if f.fs.Flag('+') && (len(pointerChain) > 0) { - f.fs.Write(openParenBytes) - for i, addr := range pointerChain { - if i > 0 { - f.fs.Write(pointerChainBytes) - } - printHexPtr(f.fs, addr) - } - f.fs.Write(closeParenBytes) - } - - // Display dereferenced value. - switch { - case nilFound: - f.fs.Write(nilAngleBytes) - - case cycleFound: - f.fs.Write(circularShortBytes) - - default: - f.ignoreNextType = true - f.format(ve) - } -} - -// format is the main workhorse for providing the Formatter interface. It -// uses the passed reflect value to figure out what kind of object we are -// dealing with and formats it appropriately. It is a recursive function, -// however circular data structures are detected and handled properly. -func (f *formatState) format(v reflect.Value) { - // Handle invalid reflect values immediately. - kind := v.Kind() - if kind == reflect.Invalid { - f.fs.Write(invalidAngleBytes) - return - } - - // Handle pointers specially. - if kind == reflect.Ptr { - f.formatPtr(v) - return - } - - // Print type information unless already handled elsewhere. - if !f.ignoreNextType && f.fs.Flag('#') { - f.fs.Write(openParenBytes) - f.fs.Write([]byte(v.Type().String())) - f.fs.Write(closeParenBytes) - } - f.ignoreNextType = false - - // Call Stringer/error interfaces if they exist and the handle methods - // flag is enabled. - if !f.cs.DisableMethods { - if (kind != reflect.Invalid) && (kind != reflect.Interface) { - if handled := handleMethods(f.cs, f.fs, v); handled { - return - } - } - } - - switch kind { - case reflect.Invalid: - // Do nothing. We should never get here since invalid has already - // been handled above. - - case reflect.Bool: - printBool(f.fs, v.Bool()) - - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - printInt(f.fs, v.Int(), 10) - - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: - printUint(f.fs, v.Uint(), 10) - - case reflect.Float32: - printFloat(f.fs, v.Float(), 32) - - case reflect.Float64: - printFloat(f.fs, v.Float(), 64) - - case reflect.Complex64: - printComplex(f.fs, v.Complex(), 32) - - case reflect.Complex128: - printComplex(f.fs, v.Complex(), 64) - - case reflect.Slice: - if v.IsNil() { - f.fs.Write(nilAngleBytes) - break - } - fallthrough - - case reflect.Array: - f.fs.Write(openBracketBytes) - f.depth++ - if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { - f.fs.Write(maxShortBytes) - } else { - numEntries := v.Len() - for i := 0; i < numEntries; i++ { - if i > 0 { - f.fs.Write(spaceBytes) - } - f.ignoreNextType = true - f.format(f.unpackValue(v.Index(i))) - } - } - f.depth-- - f.fs.Write(closeBracketBytes) - - case reflect.String: - f.fs.Write([]byte(v.String())) - - case reflect.Interface: - // The only time we should get here is for nil interfaces due to - // unpackValue calls. - if v.IsNil() { - f.fs.Write(nilAngleBytes) - } - - case reflect.Ptr: - // Do nothing. We should never get here since pointers have already - // been handled above. - - case reflect.Map: - // nil maps should be indicated as different than empty maps - if v.IsNil() { - f.fs.Write(nilAngleBytes) - break - } - - f.fs.Write(openMapBytes) - f.depth++ - if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { - f.fs.Write(maxShortBytes) - } else { - keys := v.MapKeys() - if f.cs.SortKeys { - sortValues(keys, f.cs) - } - for i, key := range keys { - if i > 0 { - f.fs.Write(spaceBytes) - } - f.ignoreNextType = true - f.format(f.unpackValue(key)) - f.fs.Write(colonBytes) - f.ignoreNextType = true - f.format(f.unpackValue(v.MapIndex(key))) - } - } - f.depth-- - f.fs.Write(closeMapBytes) - - case reflect.Struct: - numFields := v.NumField() - f.fs.Write(openBraceBytes) - f.depth++ - if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { - f.fs.Write(maxShortBytes) - } else { - vt := v.Type() - for i := 0; i < numFields; i++ { - if i > 0 { - f.fs.Write(spaceBytes) - } - vtf := vt.Field(i) - if f.fs.Flag('+') || f.fs.Flag('#') { - f.fs.Write([]byte(vtf.Name)) - f.fs.Write(colonBytes) - } - f.format(f.unpackValue(v.Field(i))) - } - } - f.depth-- - f.fs.Write(closeBraceBytes) - - case reflect.Uintptr: - printHexPtr(f.fs, uintptr(v.Uint())) - - case reflect.UnsafePointer, reflect.Chan, reflect.Func: - printHexPtr(f.fs, v.Pointer()) - - // There were not any other types at the time this code was written, but - // fall back to letting the default fmt package handle it if any get added. - default: - format := f.buildDefaultFormat() - if v.CanInterface() { - fmt.Fprintf(f.fs, format, v.Interface()) - } else { - fmt.Fprintf(f.fs, format, v.String()) - } - } -} - -// Format satisfies the fmt.Formatter interface. See NewFormatter for usage -// details. -func (f *formatState) Format(fs fmt.State, verb rune) { - f.fs = fs - - // Use standard formatting for verbs that are not v. - if verb != 'v' { - format := f.constructOrigFormat(verb) - fmt.Fprintf(fs, format, f.value) - return - } - - if f.value == nil { - if fs.Flag('#') { - fs.Write(interfaceBytes) - } - fs.Write(nilAngleBytes) - return - } - - f.format(reflect.ValueOf(f.value)) -} - -// newFormatter is a helper function to consolidate the logic from the various -// public methods which take varying config states. -func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { - fs := &formatState{value: v, cs: cs} - fs.pointers = make(map[uintptr]int) - return fs -} - -/* -NewFormatter returns a custom formatter that satisfies the fmt.Formatter -interface. As a result, it integrates cleanly with standard fmt package -printing functions. The formatter is useful for inline printing of smaller data -types similar to the standard %v format specifier. - -The custom formatter only responds to the %v (most compact), %+v (adds pointer -addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb -combinations. Any other verbs such as %x and %q will be sent to the the -standard fmt package for formatting. In addition, the custom formatter ignores -the width and precision arguments (however they will still work on the format -specifiers not handled by the custom formatter). - -Typically this function shouldn't be called directly. It is much easier to make -use of the custom formatter by calling one of the convenience functions such as -Printf, Println, or Fprintf. -*/ -func NewFormatter(v interface{}) fmt.Formatter { - return newFormatter(&Config, v) -} diff --git a/vendor/github.com/davecgh/go-spew/spew/spew.go b/vendor/github.com/davecgh/go-spew/spew/spew.go deleted file mode 100644 index 32c0e33..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/spew.go +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "fmt" - "io" -) - -// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the formatted string as a value that satisfies error. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b)) -func Errorf(format string, a ...interface{}) (err error) { - return fmt.Errorf(format, convertArgs(a)...) -} - -// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b)) -func Fprint(w io.Writer, a ...interface{}) (n int, err error) { - return fmt.Fprint(w, convertArgs(a)...) -} - -// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b)) -func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { - return fmt.Fprintf(w, format, convertArgs(a)...) -} - -// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it -// passed with a default Formatter interface returned by NewFormatter. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b)) -func Fprintln(w io.Writer, a ...interface{}) (n int, err error) { - return fmt.Fprintln(w, convertArgs(a)...) -} - -// Print is a wrapper for fmt.Print that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b)) -func Print(a ...interface{}) (n int, err error) { - return fmt.Print(convertArgs(a)...) -} - -// Printf is a wrapper for fmt.Printf that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b)) -func Printf(format string, a ...interface{}) (n int, err error) { - return fmt.Printf(format, convertArgs(a)...) -} - -// Println is a wrapper for fmt.Println that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b)) -func Println(a ...interface{}) (n int, err error) { - return fmt.Println(convertArgs(a)...) -} - -// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b)) -func Sprint(a ...interface{}) string { - return fmt.Sprint(convertArgs(a)...) -} - -// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b)) -func Sprintf(format string, a ...interface{}) string { - return fmt.Sprintf(format, convertArgs(a)...) -} - -// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it -// were passed with a default Formatter interface returned by NewFormatter. It -// returns the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b)) -func Sprintln(a ...interface{}) string { - return fmt.Sprintln(convertArgs(a)...) -} - -// convertArgs accepts a slice of arguments and returns a slice of the same -// length with each argument converted to a default spew Formatter interface. -func convertArgs(args []interface{}) (formatters []interface{}) { - formatters = make([]interface{}, len(args)) - for index, arg := range args { - formatters[index] = NewFormatter(arg) - } - return formatters -} diff --git a/vendor/github.com/disintegration/imaging/.travis.yml b/vendor/github.com/disintegration/imaging/.travis.yml deleted file mode 100644 index 89370ed..0000000 --- a/vendor/github.com/disintegration/imaging/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: go -go: - - "1.7.x" - - "1.8.x" - - "1.9.x" - - "1.10.x" - -before_install: - - go get github.com/mattn/goveralls - -script: - - go test -v -race -cover - - $GOPATH/bin/goveralls -service=travis-ci diff --git a/vendor/github.com/disintegration/imaging/LICENSE b/vendor/github.com/disintegration/imaging/LICENSE deleted file mode 100644 index c68f7ab..0000000 --- a/vendor/github.com/disintegration/imaging/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2012-2018 Grigory Dryapak - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/disintegration/imaging/README.md b/vendor/github.com/disintegration/imaging/README.md deleted file mode 100644 index c7ee30f..0000000 --- a/vendor/github.com/disintegration/imaging/README.md +++ /dev/null @@ -1,188 +0,0 @@ -# Imaging - -[![GoDoc](https://godoc.org/github.com/disintegration/imaging?status.svg)](https://godoc.org/github.com/disintegration/imaging) -[![Build Status](https://travis-ci.org/disintegration/imaging.svg?branch=master)](https://travis-ci.org/disintegration/imaging) -[![Coverage Status](https://coveralls.io/repos/github/disintegration/imaging/badge.svg?branch=master&service=github)](https://coveralls.io/github/disintegration/imaging?branch=master) -[![Go Report Card](https://goreportcard.com/badge/github.com/disintegration/imaging)](https://goreportcard.com/report/github.com/disintegration/imaging) - -Package imaging provides basic image processing functions (resize, rotate, crop, brightness/contrast adjustments, etc.). - -All the image processing functions provided by the package accept any image type that implements `image.Image` interface -as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha). - -## Installation - - go get -u github.com/disintegration/imaging - -## Documentation - -http://godoc.org/github.com/disintegration/imaging - -## Usage examples - -A few usage examples can be found below. See the documentation for the full list of supported functions. - -### Image resizing - -```go -// Resize srcImage to size = 128x128px using the Lanczos filter. -dstImage128 := imaging.Resize(srcImage, 128, 128, imaging.Lanczos) - -// Resize srcImage to width = 800px preserving the aspect ratio. -dstImage800 := imaging.Resize(srcImage, 800, 0, imaging.Lanczos) - -// Scale down srcImage to fit the 800x600px bounding box. -dstImageFit := imaging.Fit(srcImage, 800, 600, imaging.Lanczos) - -// Resize and crop the srcImage to fill the 100x100px area. -dstImageFill := imaging.Fill(srcImage, 100, 100, imaging.Center, imaging.Lanczos) -``` - -Imaging supports image resizing using various resampling filters. The most notable ones: -- `NearestNeighbor` - Fastest resampling filter, no antialiasing. -- `Box` - Simple and fast averaging filter appropriate for downscaling. When upscaling it's similar to NearestNeighbor. -- `Linear` - Bilinear filter, smooth and reasonably fast. -- `MitchellNetravali` - А smooth bicubic filter. -- `CatmullRom` - A sharp bicubic filter. -- `Gaussian` - Blurring filter that uses gaussian function, useful for noise removal. -- `Lanczos` - High-quality resampling filter for photographic images yielding sharp results, slower than cubic filters. - -The full list of supported filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine. Custom filters can be created using ResampleFilter struct. - -**Resampling filters comparison** - -Original image: - -![srcImage](testdata/branches.png) - -The same image resized from 600x400px to 150x100px using different resampling filters. -From faster (lower quality) to slower (higher quality): - -Filter | Resize result ---------------------------|--------------------------------------------- -`imaging.NearestNeighbor` | ![dstImage](testdata/out_resize_nearest.png) -`imaging.Linear` | ![dstImage](testdata/out_resize_linear.png) -`imaging.CatmullRom` | ![dstImage](testdata/out_resize_catrom.png) -`imaging.Lanczos` | ![dstImage](testdata/out_resize_lanczos.png) - - -### Gaussian Blur - -```go -dstImage := imaging.Blur(srcImage, 0.5) -``` - -Sigma parameter allows to control the strength of the blurring effect. - -Original image | Sigma = 0.5 | Sigma = 1.5 ------------------------------------|----------------------------------------|--------------------------------------- -![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_blur_0.5.png) | ![dstImage](testdata/out_blur_1.5.png) - -### Sharpening - -```go -dstImage := imaging.Sharpen(srcImage, 0.5) -``` - -`Sharpen` uses gaussian function internally. Sigma parameter allows to control the strength of the sharpening effect. - -Original image | Sigma = 0.5 | Sigma = 1.5 ------------------------------------|-------------------------------------------|------------------------------------------ -![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_sharpen_0.5.png) | ![dstImage](testdata/out_sharpen_1.5.png) - -### Gamma correction - -```go -dstImage := imaging.AdjustGamma(srcImage, 0.75) -``` - -Original image | Gamma = 0.75 | Gamma = 1.25 ------------------------------------|------------------------------------------|----------------------------------------- -![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_gamma_0.75.png) | ![dstImage](testdata/out_gamma_1.25.png) - -### Contrast adjustment - -```go -dstImage := imaging.AdjustContrast(srcImage, 20) -``` - -Original image | Contrast = 15 | Contrast = -15 ------------------------------------|--------------------------------------------|------------------------------------------- -![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_contrast_p15.png) | ![dstImage](testdata/out_contrast_m15.png) - -### Brightness adjustment - -```go -dstImage := imaging.AdjustBrightness(srcImage, 20) -``` - -Original image | Brightness = 10 | Brightness = -10 ------------------------------------|----------------------------------------------|--------------------------------------------- -![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_brightness_p10.png) | ![dstImage](testdata/out_brightness_m10.png) - -## Example code - -```go -package main - -import ( - "image" - "image/color" - "log" - - "github.com/disintegration/imaging" -) - -func main() { - // Open a test image. - src, err := imaging.Open("testdata/flowers.png") - if err != nil { - log.Fatalf("failed to open image: %v", err) - } - - // Crop the original image to 300x300px size using the center anchor. - src = imaging.CropAnchor(src, 300, 300, imaging.Center) - - // Resize the cropped image to width = 200px preserving the aspect ratio. - src = imaging.Resize(src, 200, 0, imaging.Lanczos) - - // Create a blurred version of the image. - img1 := imaging.Blur(src, 5) - - // Create a grayscale version of the image with higher contrast and sharpness. - img2 := imaging.Grayscale(src) - img2 = imaging.AdjustContrast(img2, 20) - img2 = imaging.Sharpen(img2, 2) - - // Create an inverted version of the image. - img3 := imaging.Invert(src) - - // Create an embossed version of the image using a convolution filter. - img4 := imaging.Convolve3x3( - src, - [9]float64{ - -1, -1, 0, - -1, 1, 1, - 0, 1, 1, - }, - nil, - ) - - // Create a new image and paste the four produced images into it. - dst := imaging.New(400, 400, color.NRGBA{0, 0, 0, 0}) - dst = imaging.Paste(dst, img1, image.Pt(0, 0)) - dst = imaging.Paste(dst, img2, image.Pt(0, 200)) - dst = imaging.Paste(dst, img3, image.Pt(200, 0)) - dst = imaging.Paste(dst, img4, image.Pt(200, 200)) - - // Save the resulting image as JPEG. - err = imaging.Save(dst, "testdata/out_example.jpg") - if err != nil { - log.Fatalf("failed to save image: %v", err) - } -} -``` - -Output: - -![dstImage](testdata/out_example.jpg) \ No newline at end of file diff --git a/vendor/github.com/disintegration/imaging/adjust.go b/vendor/github.com/disintegration/imaging/adjust.go deleted file mode 100644 index fb3a9ce..0000000 --- a/vendor/github.com/disintegration/imaging/adjust.go +++ /dev/null @@ -1,222 +0,0 @@ -package imaging - -import ( - "image" - "image/color" - "math" -) - -// Grayscale produces a grayscale version of the image. -func Grayscale(img image.Image) *image.NRGBA { - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) - parallel(0, src.h, func(ys <-chan int) { - for y := range ys { - i := y * dst.Stride - src.scan(0, y, src.w, y+1, dst.Pix[i:i+src.w*4]) - for x := 0; x < src.w; x++ { - r := dst.Pix[i+0] - g := dst.Pix[i+1] - b := dst.Pix[i+2] - f := 0.299*float64(r) + 0.587*float64(g) + 0.114*float64(b) - y := uint8(f + 0.5) - dst.Pix[i+0] = y - dst.Pix[i+1] = y - dst.Pix[i+2] = y - i += 4 - } - } - }) - return dst -} - -// Invert produces an inverted (negated) version of the image. -func Invert(img image.Image) *image.NRGBA { - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) - parallel(0, src.h, func(ys <-chan int) { - for y := range ys { - i := y * dst.Stride - src.scan(0, y, src.w, y+1, dst.Pix[i:i+src.w*4]) - for x := 0; x < src.w; x++ { - dst.Pix[i+0] = 255 - dst.Pix[i+0] - dst.Pix[i+1] = 255 - dst.Pix[i+1] - dst.Pix[i+2] = 255 - dst.Pix[i+2] - i += 4 - } - } - }) - return dst -} - -// AdjustContrast changes the contrast of the image using the percentage parameter and returns the adjusted image. -// The percentage must be in range (-100, 100). The percentage = 0 gives the original image. -// The percentage = -100 gives solid gray image. -// -// Examples: -// -// dstImage = imaging.AdjustContrast(srcImage, -10) // decrease image contrast by 10% -// dstImage = imaging.AdjustContrast(srcImage, 20) // increase image contrast by 20% -// -func AdjustContrast(img image.Image, percentage float64) *image.NRGBA { - percentage = math.Min(math.Max(percentage, -100.0), 100.0) - lut := make([]uint8, 256) - - v := (100.0 + percentage) / 100.0 - for i := 0; i < 256; i++ { - if 0 <= v && v <= 1 { - lut[i] = clamp((0.5 + (float64(i)/255.0-0.5)*v) * 255.0) - } else if 1 < v && v < 2 { - lut[i] = clamp((0.5 + (float64(i)/255.0-0.5)*(1/(2.0-v))) * 255.0) - } else { - lut[i] = uint8(float64(i)/255.0+0.5) * 255 - } - } - - return adjustLUT(img, lut) -} - -// AdjustBrightness changes the brightness of the image using the percentage parameter and returns the adjusted image. -// The percentage must be in range (-100, 100). The percentage = 0 gives the original image. -// The percentage = -100 gives solid black image. The percentage = 100 gives solid white image. -// -// Examples: -// -// dstImage = imaging.AdjustBrightness(srcImage, -15) // decrease image brightness by 15% -// dstImage = imaging.AdjustBrightness(srcImage, 10) // increase image brightness by 10% -// -func AdjustBrightness(img image.Image, percentage float64) *image.NRGBA { - percentage = math.Min(math.Max(percentage, -100.0), 100.0) - lut := make([]uint8, 256) - - shift := 255.0 * percentage / 100.0 - for i := 0; i < 256; i++ { - lut[i] = clamp(float64(i) + shift) - } - - return adjustLUT(img, lut) -} - -// AdjustGamma performs a gamma correction on the image and returns the adjusted image. -// Gamma parameter must be positive. Gamma = 1.0 gives the original image. -// Gamma less than 1.0 darkens the image and gamma greater than 1.0 lightens it. -// -// Example: -// -// dstImage = imaging.AdjustGamma(srcImage, 0.7) -// -func AdjustGamma(img image.Image, gamma float64) *image.NRGBA { - e := 1.0 / math.Max(gamma, 0.0001) - lut := make([]uint8, 256) - - for i := 0; i < 256; i++ { - lut[i] = clamp(math.Pow(float64(i)/255.0, e) * 255.0) - } - - return adjustLUT(img, lut) -} - -// AdjustSigmoid changes the contrast of the image using a sigmoidal function and returns the adjusted image. -// It's a non-linear contrast change useful for photo adjustments as it preserves highlight and shadow detail. -// The midpoint parameter is the midpoint of contrast that must be between 0 and 1, typically 0.5. -// The factor parameter indicates how much to increase or decrease the contrast, typically in range (-10, 10). -// If the factor parameter is positive the image contrast is increased otherwise the contrast is decreased. -// -// Examples: -// -// dstImage = imaging.AdjustSigmoid(srcImage, 0.5, 3.0) // increase the contrast -// dstImage = imaging.AdjustSigmoid(srcImage, 0.5, -3.0) // decrease the contrast -// -func AdjustSigmoid(img image.Image, midpoint, factor float64) *image.NRGBA { - if factor == 0 { - return Clone(img) - } - - lut := make([]uint8, 256) - a := math.Min(math.Max(midpoint, 0.0), 1.0) - b := math.Abs(factor) - sig0 := sigmoid(a, b, 0) - sig1 := sigmoid(a, b, 1) - e := 1.0e-6 - - if factor > 0 { - for i := 0; i < 256; i++ { - x := float64(i) / 255.0 - sigX := sigmoid(a, b, x) - f := (sigX - sig0) / (sig1 - sig0) - lut[i] = clamp(f * 255.0) - } - } else { - for i := 0; i < 256; i++ { - x := float64(i) / 255.0 - arg := math.Min(math.Max((sig1-sig0)*x+sig0, e), 1.0-e) - f := a - math.Log(1.0/arg-1.0)/b - lut[i] = clamp(f * 255.0) - } - } - - return adjustLUT(img, lut) -} - -func sigmoid(a, b, x float64) float64 { - return 1 / (1 + math.Exp(b*(a-x))) -} - -// adjustLUT applies the given lookup table to the colors of the image. -func adjustLUT(img image.Image, lut []uint8) *image.NRGBA { - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) - parallel(0, src.h, func(ys <-chan int) { - for y := range ys { - i := y * dst.Stride - src.scan(0, y, src.w, y+1, dst.Pix[i:i+src.w*4]) - for x := 0; x < src.w; x++ { - dst.Pix[i+0] = lut[dst.Pix[i+0]] - dst.Pix[i+1] = lut[dst.Pix[i+1]] - dst.Pix[i+2] = lut[dst.Pix[i+2]] - i += 4 - } - } - }) - return dst -} - -// AdjustFunc applies the fn function to each pixel of the img image and returns the adjusted image. -// -// Example: -// -// dstImage = imaging.AdjustFunc( -// srcImage, -// func(c color.NRGBA) color.NRGBA { -// // shift the red channel by 16 -// r := int(c.R) + 16 -// if r > 255 { -// r = 255 -// } -// return color.NRGBA{uint8(r), c.G, c.B, c.A} -// } -// ) -// -func AdjustFunc(img image.Image, fn func(c color.NRGBA) color.NRGBA) *image.NRGBA { - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) - parallel(0, src.h, func(ys <-chan int) { - for y := range ys { - i := y * dst.Stride - src.scan(0, y, src.w, y+1, dst.Pix[i:i+src.w*4]) - for x := 0; x < src.w; x++ { - r := dst.Pix[i+0] - g := dst.Pix[i+1] - b := dst.Pix[i+2] - a := dst.Pix[i+3] - c := fn(color.NRGBA{r, g, b, a}) - dst.Pix[i+0] = c.R - dst.Pix[i+1] = c.G - dst.Pix[i+2] = c.B - dst.Pix[i+3] = c.A - i += 4 - } - } - }) - return dst -} diff --git a/vendor/github.com/disintegration/imaging/convolution.go b/vendor/github.com/disintegration/imaging/convolution.go deleted file mode 100644 index 9e6404d..0000000 --- a/vendor/github.com/disintegration/imaging/convolution.go +++ /dev/null @@ -1,146 +0,0 @@ -package imaging - -import ( - "image" -) - -// ConvolveOptions are convolution parameters. -type ConvolveOptions struct { - // If Normalize is true the kernel is normalized before convolution. - Normalize bool - - // If Abs is true the absolute value of each color channel is taken after convolution. - Abs bool - - // Bias is added to each color channel value after convolution. - Bias int -} - -// Convolve3x3 convolves the image with the specified 3x3 convolution kernel. -// Default parameters are used if a nil *ConvolveOptions is passed. -func Convolve3x3(img image.Image, kernel [9]float64, options *ConvolveOptions) *image.NRGBA { - return convolve(img, kernel[:], options) -} - -// Convolve5x5 convolves the image with the specified 5x5 convolution kernel. -// Default parameters are used if a nil *ConvolveOptions is passed. -func Convolve5x5(img image.Image, kernel [25]float64, options *ConvolveOptions) *image.NRGBA { - return convolve(img, kernel[:], options) -} - -func convolve(img image.Image, kernel []float64, options *ConvolveOptions) *image.NRGBA { - src := toNRGBA(img) - w := src.Bounds().Max.X - h := src.Bounds().Max.Y - dst := image.NewNRGBA(image.Rect(0, 0, w, h)) - - if w < 1 || h < 1 { - return dst - } - - if options == nil { - options = &ConvolveOptions{} - } - - if options.Normalize { - normalizeKernel(kernel) - } - - type coef struct { - x, y int - k float64 - } - var coefs []coef - var m int - - switch len(kernel) { - case 9: - m = 1 - case 25: - m = 2 - } - - i := 0 - for y := -m; y <= m; y++ { - for x := -m; x <= m; x++ { - if kernel[i] != 0 { - coefs = append(coefs, coef{x: x, y: y, k: kernel[i]}) - } - i++ - } - } - - parallel(0, h, func(ys <-chan int) { - for y := range ys { - for x := 0; x < w; x++ { - var r, g, b float64 - for _, c := range coefs { - ix := x + c.x - if ix < 0 { - ix = 0 - } else if ix >= w { - ix = w - 1 - } - - iy := y + c.y - if iy < 0 { - iy = 0 - } else if iy >= h { - iy = h - 1 - } - - off := iy*src.Stride + ix*4 - r += float64(src.Pix[off+0]) * c.k - g += float64(src.Pix[off+1]) * c.k - b += float64(src.Pix[off+2]) * c.k - } - - if options.Abs { - if r < 0 { - r = -r - } - if g < 0 { - g = -g - } - if b < 0 { - b = -b - } - } - - if options.Bias != 0 { - r += float64(options.Bias) - g += float64(options.Bias) - b += float64(options.Bias) - } - - srcOff := y*src.Stride + x*4 - dstOff := y*dst.Stride + x*4 - dst.Pix[dstOff+0] = clamp(r) - dst.Pix[dstOff+1] = clamp(g) - dst.Pix[dstOff+2] = clamp(b) - dst.Pix[dstOff+3] = src.Pix[srcOff+3] - } - } - }) - - return dst -} - -func normalizeKernel(kernel []float64) { - var sum, sumpos float64 - for i := range kernel { - sum += kernel[i] - if kernel[i] > 0 { - sumpos += kernel[i] - } - } - if sum != 0 { - for i := range kernel { - kernel[i] /= sum - } - } else if sumpos != 0 { - for i := range kernel { - kernel[i] /= sumpos - } - } -} diff --git a/vendor/github.com/disintegration/imaging/doc.go b/vendor/github.com/disintegration/imaging/doc.go deleted file mode 100644 index 5d59b46..0000000 --- a/vendor/github.com/disintegration/imaging/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -/* -Package imaging provides basic image processing functions (resize, rotate, crop, brightness/contrast adjustments, etc.). - -All the image processing functions provided by the package accept any image type that implements image.Image interface -as an input, and return a new image of *image.NRGBA type (32bit RGBA colors, not premultiplied by alpha). -*/ -package imaging diff --git a/vendor/github.com/disintegration/imaging/effects.go b/vendor/github.com/disintegration/imaging/effects.go deleted file mode 100644 index 149cfeb..0000000 --- a/vendor/github.com/disintegration/imaging/effects.go +++ /dev/null @@ -1,173 +0,0 @@ -package imaging - -import ( - "image" - "math" -) - -func gaussianBlurKernel(x, sigma float64) float64 { - return math.Exp(-(x*x)/(2*sigma*sigma)) / (sigma * math.Sqrt(2*math.Pi)) -} - -// Blur produces a blurred version of the image using a Gaussian function. -// Sigma parameter must be positive and indicates how much the image will be blurred. -// -// Usage example: -// -// dstImage := imaging.Blur(srcImage, 3.5) -// -func Blur(img image.Image, sigma float64) *image.NRGBA { - if sigma <= 0 { - return Clone(img) - } - - radius := int(math.Ceil(sigma * 3.0)) - kernel := make([]float64, radius+1) - - for i := 0; i <= radius; i++ { - kernel[i] = gaussianBlurKernel(float64(i), sigma) - } - - return blurVertical(blurHorizontal(img, kernel), kernel) -} - -func blurHorizontal(img image.Image, kernel []float64) *image.NRGBA { - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) - radius := len(kernel) - 1 - - parallel(0, src.h, func(ys <-chan int) { - scanLine := make([]uint8, src.w*4) - scanLineF := make([]float64, len(scanLine)) - for y := range ys { - src.scan(0, y, src.w, y+1, scanLine) - for i, v := range scanLine { - scanLineF[i] = float64(v) - } - for x, idx := 0, 0; x < src.w; x, idx = x+1, idx+4 { - min := x - radius - if min < 0 { - min = 0 - } - max := x + radius - if max > src.w-1 { - max = src.w - 1 - } - - var r, g, b, a, wsum float64 - for ix := min; ix <= max; ix++ { - i := ix * 4 - weight := kernel[absint(x-ix)] - wsum += weight - wa := scanLineF[i+3] * weight - r += scanLineF[i+0] * wa - g += scanLineF[i+1] * wa - b += scanLineF[i+2] * wa - a += wa - } - if a != 0 { - r /= a - g /= a - b /= a - } - - scanLine[idx+0] = clamp(r) - scanLine[idx+1] = clamp(g) - scanLine[idx+2] = clamp(b) - scanLine[idx+3] = clamp(a / wsum) - } - copy(dst.Pix[y*dst.Stride:], scanLine) - } - }) - - return dst -} - -func blurVertical(img image.Image, kernel []float64) *image.NRGBA { - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) - radius := len(kernel) - 1 - - parallel(0, src.w, func(xs <-chan int) { - scanLine := make([]uint8, src.h*4) - scanLineF := make([]float64, len(scanLine)) - for x := range xs { - src.scan(x, 0, x+1, src.h, scanLine) - for i, v := range scanLine { - scanLineF[i] = float64(v) - } - for y := 0; y < src.h; y++ { - min := y - radius - if min < 0 { - min = 0 - } - max := y + radius - if max > src.h-1 { - max = src.h - 1 - } - - var r, g, b, a, wsum float64 - for iy := min; iy <= max; iy++ { - i := iy * 4 - weight := kernel[absint(y-iy)] - wsum += weight - wa := scanLineF[i+3] * weight - r += scanLineF[i+0] * wa - g += scanLineF[i+1] * wa - b += scanLineF[i+2] * wa - a += wa - } - if a != 0 { - r /= a - g /= a - b /= a - } - - j := y*dst.Stride + x*4 - dst.Pix[j+0] = clamp(r) - dst.Pix[j+1] = clamp(g) - dst.Pix[j+2] = clamp(b) - dst.Pix[j+3] = clamp(a / wsum) - } - } - }) - - return dst -} - -// Sharpen produces a sharpened version of the image. -// Sigma parameter must be positive and indicates how much the image will be sharpened. -// -// Usage example: -// -// dstImage := imaging.Sharpen(srcImage, 3.5) -// -func Sharpen(img image.Image, sigma float64) *image.NRGBA { - if sigma <= 0 { - return Clone(img) - } - - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) - blurred := Blur(img, sigma) - - parallel(0, src.h, func(ys <-chan int) { - scanLine := make([]uint8, src.w*4) - for y := range ys { - src.scan(0, y, src.w, y+1, scanLine) - j := y * dst.Stride - for i := 0; i < src.w*4; i++ { - val := int(scanLine[i])<<1 - int(blurred.Pix[j]) - if val < 0 { - val = 0 - } else if val > 0xff { - val = 0xff - } - dst.Pix[j] = uint8(val) - j++ - } - } - }) - - return dst -} diff --git a/vendor/github.com/disintegration/imaging/histogram.go b/vendor/github.com/disintegration/imaging/histogram.go deleted file mode 100644 index 5bcb001..0000000 --- a/vendor/github.com/disintegration/imaging/histogram.go +++ /dev/null @@ -1,51 +0,0 @@ -package imaging - -import ( - "image" - "sync" -) - -// Histogram returns a normalized histogram of an image. -// -// Resulting histogram is represented as an array of 256 floats, where -// histogram[i] is a probability of a pixel being of a particular luminance i. -func Histogram(img image.Image) [256]float64 { - var mu sync.Mutex - var histogram [256]float64 - var total float64 - - src := newScanner(img) - if src.w == 0 || src.h == 0 { - return histogram - } - - parallel(0, src.h, func(ys <-chan int) { - var tmpHistogram [256]float64 - var tmpTotal float64 - scanLine := make([]uint8, src.w*4) - for y := range ys { - src.scan(0, y, src.w, y+1, scanLine) - i := 0 - for x := 0; x < src.w; x++ { - r := scanLine[i+0] - g := scanLine[i+1] - b := scanLine[i+2] - y := 0.299*float32(r) + 0.587*float32(g) + 0.114*float32(b) - tmpHistogram[int(y+0.5)]++ - tmpTotal++ - i += 4 - } - } - mu.Lock() - for i := 0; i < 256; i++ { - histogram[i] += tmpHistogram[i] - } - total += tmpTotal - mu.Unlock() - }) - - for i := 0; i < 256; i++ { - histogram[i] = histogram[i] / total - } - return histogram -} diff --git a/vendor/github.com/disintegration/imaging/io.go b/vendor/github.com/disintegration/imaging/io.go deleted file mode 100644 index 557bf2f..0000000 --- a/vendor/github.com/disintegration/imaging/io.go +++ /dev/null @@ -1,463 +0,0 @@ -package imaging - -import ( - "encoding/binary" - "errors" - "image" - "image/draw" - "image/gif" - "image/jpeg" - "image/png" - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "golang.org/x/image/bmp" - "golang.org/x/image/tiff" -) - -// Format is an image file format. -type Format int - -// Image file formats. -const ( - JPEG Format = iota - PNG - GIF - TIFF - BMP -) - -func (f Format) String() string { - switch f { - case JPEG: - return "JPEG" - case PNG: - return "PNG" - case GIF: - return "GIF" - case TIFF: - return "TIFF" - case BMP: - return "BMP" - default: - return "Unsupported" - } -} - -var formatFromExt = map[string]Format{ - "jpg": JPEG, - "jpeg": JPEG, - "png": PNG, - "tif": TIFF, - "tiff": TIFF, - "bmp": BMP, - "gif": GIF, -} - -// FormatFromExtension parses image format from extension: -// "jpg" (or "jpeg"), "png", "gif", "tif" (or "tiff") and "bmp" are supported. -func FormatFromExtension(ext string) (Format, error) { - if f, ok := formatFromExt[strings.ToLower(strings.TrimPrefix(ext, "."))]; ok { - return f, nil - } - return -1, ErrUnsupportedFormat -} - -// FormatFromFilename parses image format from filename extension: -// "jpg" (or "jpeg"), "png", "gif", "tif" (or "tiff") and "bmp" are supported. -func FormatFromFilename(filename string) (Format, error) { - ext := filepath.Ext(filename) - return FormatFromExtension(ext) -} - -var ( - // ErrUnsupportedFormat means the given image format (or file extension) is unsupported. - ErrUnsupportedFormat = errors.New("imaging: unsupported image format") -) - -type fileSystem interface { - Create(string) (io.WriteCloser, error) - Open(string) (io.ReadCloser, error) -} - -type localFS struct{} - -func (localFS) Create(name string) (io.WriteCloser, error) { return os.Create(name) } -func (localFS) Open(name string) (io.ReadCloser, error) { return os.Open(name) } - -var fs fileSystem = localFS{} - -type decodeConfig struct { - autoOrientation bool -} - -var defaultDecodeConfig = decodeConfig{ - autoOrientation: false, -} - -// DecodeOption sets an optional parameter for the Decode and Open functions. -type DecodeOption func(*decodeConfig) - -// AutoOrientation returns a DecodeOption that sets the auto-orientation mode. -// If auto-orientation is enabled, the image will be transformed after decoding -// according to the EXIF orientation tag (if present). By default it's disabled. -func AutoOrientation(enabled bool) DecodeOption { - return func(c *decodeConfig) { - c.autoOrientation = enabled - } -} - -// Decode reads an image from r. -func Decode(r io.Reader, opts ...DecodeOption) (image.Image, error) { - cfg := defaultDecodeConfig - for _, option := range opts { - option(&cfg) - } - - if !cfg.autoOrientation { - img, _, err := image.Decode(r) - return img, err - } - - var orient orientation - pr, pw := io.Pipe() - r = io.TeeReader(r, pw) - done := make(chan struct{}) - go func() { - defer close(done) - orient = readOrientation(pr) - io.Copy(ioutil.Discard, pr) - }() - - img, _, err := image.Decode(r) - pw.Close() - <-done - if err != nil { - return nil, err - } - - return fixOrientation(img, orient), nil -} - -// Open loads an image from file. -// -// Examples: -// -// // Load an image from file. -// img, err := imaging.Open("test.jpg") -// -// // Load an image and transform it depending on the EXIF orientation tag (if present). -// img, err := imaging.Open("test.jpg", imaging.AutoOrientation(true)) -// -func Open(filename string, opts ...DecodeOption) (image.Image, error) { - file, err := fs.Open(filename) - if err != nil { - return nil, err - } - defer file.Close() - return Decode(file, opts...) -} - -type encodeConfig struct { - jpegQuality int - gifNumColors int - gifQuantizer draw.Quantizer - gifDrawer draw.Drawer - pngCompressionLevel png.CompressionLevel -} - -var defaultEncodeConfig = encodeConfig{ - jpegQuality: 95, - gifNumColors: 256, - gifQuantizer: nil, - gifDrawer: nil, - pngCompressionLevel: png.DefaultCompression, -} - -// EncodeOption sets an optional parameter for the Encode and Save functions. -type EncodeOption func(*encodeConfig) - -// JPEGQuality returns an EncodeOption that sets the output JPEG quality. -// Quality ranges from 1 to 100 inclusive, higher is better. Default is 95. -func JPEGQuality(quality int) EncodeOption { - return func(c *encodeConfig) { - c.jpegQuality = quality - } -} - -// GIFNumColors returns an EncodeOption that sets the maximum number of colors -// used in the GIF-encoded image. It ranges from 1 to 256. Default is 256. -func GIFNumColors(numColors int) EncodeOption { - return func(c *encodeConfig) { - c.gifNumColors = numColors - } -} - -// GIFQuantizer returns an EncodeOption that sets the quantizer that is used to produce -// a palette of the GIF-encoded image. -func GIFQuantizer(quantizer draw.Quantizer) EncodeOption { - return func(c *encodeConfig) { - c.gifQuantizer = quantizer - } -} - -// GIFDrawer returns an EncodeOption that sets the drawer that is used to convert -// the source image to the desired palette of the GIF-encoded image. -func GIFDrawer(drawer draw.Drawer) EncodeOption { - return func(c *encodeConfig) { - c.gifDrawer = drawer - } -} - -// PNGCompressionLevel returns an EncodeOption that sets the compression level -// of the PNG-encoded image. Default is png.DefaultCompression. -func PNGCompressionLevel(level png.CompressionLevel) EncodeOption { - return func(c *encodeConfig) { - c.pngCompressionLevel = level - } -} - -// Encode writes the image img to w in the specified format (JPEG, PNG, GIF, TIFF or BMP). -func Encode(w io.Writer, img image.Image, format Format, opts ...EncodeOption) error { - cfg := defaultEncodeConfig - for _, option := range opts { - option(&cfg) - } - - var err error - switch format { - case JPEG: - var rgba *image.RGBA - if nrgba, ok := img.(*image.NRGBA); ok { - if nrgba.Opaque() { - rgba = &image.RGBA{ - Pix: nrgba.Pix, - Stride: nrgba.Stride, - Rect: nrgba.Rect, - } - } - } - if rgba != nil { - err = jpeg.Encode(w, rgba, &jpeg.Options{Quality: cfg.jpegQuality}) - } else { - err = jpeg.Encode(w, img, &jpeg.Options{Quality: cfg.jpegQuality}) - } - - case PNG: - enc := png.Encoder{CompressionLevel: cfg.pngCompressionLevel} - err = enc.Encode(w, img) - - case GIF: - err = gif.Encode(w, img, &gif.Options{ - NumColors: cfg.gifNumColors, - Quantizer: cfg.gifQuantizer, - Drawer: cfg.gifDrawer, - }) - - case TIFF: - err = tiff.Encode(w, img, &tiff.Options{Compression: tiff.Deflate, Predictor: true}) - - case BMP: - err = bmp.Encode(w, img) - - default: - err = ErrUnsupportedFormat - } - return err -} - -// Save saves the image to file with the specified filename. -// The format is determined from the filename extension: -// "jpg" (or "jpeg"), "png", "gif", "tif" (or "tiff") and "bmp" are supported. -// -// Examples: -// -// // Save the image as PNG. -// err := imaging.Save(img, "out.png") -// -// // Save the image as JPEG with optional quality parameter set to 80. -// err := imaging.Save(img, "out.jpg", imaging.JPEGQuality(80)) -// -func Save(img image.Image, filename string, opts ...EncodeOption) (err error) { - f, err := FormatFromFilename(filename) - if err != nil { - return err - } - file, err := fs.Create(filename) - if err != nil { - return err - } - - defer func() { - cerr := file.Close() - if err == nil { - err = cerr - } - }() - - return Encode(file, img, f, opts...) -} - -// orientation is an EXIF flag that specifies the transformation -// that should be applied to image to display it correctly. -type orientation int - -const ( - orientationUnspecified = 0 - orientationNormal = 1 - orientationFlipH = 2 - orientationRotate180 = 3 - orientationFlipV = 4 - orientationTranspose = 5 - orientationRotate270 = 6 - orientationTransverse = 7 - orientationRotate90 = 8 -) - -// readOrientation tries to read the orientation EXIF flag from image data in r. -// If the EXIF data block is not found or the orientation flag is not found -// or any other error occures while reading the data, it returns the -// orientationUnspecified (0) value. -func readOrientation(r io.Reader) orientation { - const ( - markerSOI = 0xffd8 - markerAPP1 = 0xffe1 - exifHeader = 0x45786966 - byteOrderBE = 0x4d4d - byteOrderLE = 0x4949 - orientationTag = 0x0112 - ) - - // Check if JPEG SOI marker is present. - var soi uint16 - if err := binary.Read(r, binary.BigEndian, &soi); err != nil { - return orientationUnspecified - } - if soi != markerSOI { - return orientationUnspecified // Missing JPEG SOI marker. - } - - // Find JPEG APP1 marker. - for { - var marker, size uint16 - if err := binary.Read(r, binary.BigEndian, &marker); err != nil { - return orientationUnspecified - } - if err := binary.Read(r, binary.BigEndian, &size); err != nil { - return orientationUnspecified - } - if marker>>8 != 0xff { - return orientationUnspecified // Invalid JPEG marker. - } - if marker == markerAPP1 { - break - } - if size < 2 { - return orientationUnspecified // Invalid block size. - } - if _, err := io.CopyN(ioutil.Discard, r, int64(size-2)); err != nil { - return orientationUnspecified - } - } - - // Check if EXIF header is present. - var header uint32 - if err := binary.Read(r, binary.BigEndian, &header); err != nil { - return orientationUnspecified - } - if header != exifHeader { - return orientationUnspecified - } - if _, err := io.CopyN(ioutil.Discard, r, 2); err != nil { - return orientationUnspecified - } - - // Read byte order information. - var ( - byteOrderTag uint16 - byteOrder binary.ByteOrder - ) - if err := binary.Read(r, binary.BigEndian, &byteOrderTag); err != nil { - return orientationUnspecified - } - switch byteOrderTag { - case byteOrderBE: - byteOrder = binary.BigEndian - case byteOrderLE: - byteOrder = binary.LittleEndian - default: - return orientationUnspecified // Invalid byte order flag. - } - if _, err := io.CopyN(ioutil.Discard, r, 2); err != nil { - return orientationUnspecified - } - - // Skip the EXIF offset. - var offset uint32 - if err := binary.Read(r, byteOrder, &offset); err != nil { - return orientationUnspecified - } - if offset < 8 { - return orientationUnspecified // Invalid offset value. - } - if _, err := io.CopyN(ioutil.Discard, r, int64(offset-8)); err != nil { - return orientationUnspecified - } - - // Read the number of tags. - var numTags uint16 - if err := binary.Read(r, byteOrder, &numTags); err != nil { - return orientationUnspecified - } - - // Find the orientation tag. - for i := 0; i < int(numTags); i++ { - var tag uint16 - if err := binary.Read(r, byteOrder, &tag); err != nil { - return orientationUnspecified - } - if tag != orientationTag { - if _, err := io.CopyN(ioutil.Discard, r, 10); err != nil { - return orientationUnspecified - } - continue - } - if _, err := io.CopyN(ioutil.Discard, r, 6); err != nil { - return orientationUnspecified - } - var val uint16 - if err := binary.Read(r, byteOrder, &val); err != nil { - return orientationUnspecified - } - if val < 1 || val > 8 { - return orientationUnspecified // Invalid tag value. - } - return orientation(val) - } - return orientationUnspecified // Missing orientation tag. -} - -// fixOrientation applies a transform to img corresponding to the given orientation flag. -func fixOrientation(img image.Image, o orientation) image.Image { - switch o { - case orientationNormal: - case orientationFlipH: - img = FlipH(img) - case orientationFlipV: - img = FlipV(img) - case orientationRotate90: - img = Rotate90(img) - case orientationRotate180: - img = Rotate180(img) - case orientationRotate270: - img = Rotate270(img) - case orientationTranspose: - img = Transpose(img) - case orientationTransverse: - img = Transverse(img) - } - return img -} diff --git a/vendor/github.com/disintegration/imaging/resize.go b/vendor/github.com/disintegration/imaging/resize.go deleted file mode 100644 index 97f498a..0000000 --- a/vendor/github.com/disintegration/imaging/resize.go +++ /dev/null @@ -1,572 +0,0 @@ -package imaging - -import ( - "image" - "math" -) - -type indexWeight struct { - index int - weight float64 -} - -func precomputeWeights(dstSize, srcSize int, filter ResampleFilter) [][]indexWeight { - du := float64(srcSize) / float64(dstSize) - scale := du - if scale < 1.0 { - scale = 1.0 - } - ru := math.Ceil(scale * filter.Support) - - out := make([][]indexWeight, dstSize) - tmp := make([]indexWeight, 0, dstSize*int(ru+2)*2) - - for v := 0; v < dstSize; v++ { - fu := (float64(v)+0.5)*du - 0.5 - - begin := int(math.Ceil(fu - ru)) - if begin < 0 { - begin = 0 - } - end := int(math.Floor(fu + ru)) - if end > srcSize-1 { - end = srcSize - 1 - } - - var sum float64 - for u := begin; u <= end; u++ { - w := filter.Kernel((float64(u) - fu) / scale) - if w != 0 { - sum += w - tmp = append(tmp, indexWeight{index: u, weight: w}) - } - } - if sum != 0 { - for i := range tmp { - tmp[i].weight /= sum - } - } - - out[v] = tmp - tmp = tmp[len(tmp):] - } - - return out -} - -// Resize resizes the image to the specified width and height using the specified resampling -// filter and returns the transformed image. If one of width or height is 0, the image aspect -// ratio is preserved. -// -// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, -// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine. -// -// Usage example: -// -// dstImage := imaging.Resize(srcImage, 800, 600, imaging.Lanczos) -// -func Resize(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA { - dstW, dstH := width, height - if dstW < 0 || dstH < 0 { - return &image.NRGBA{} - } - if dstW == 0 && dstH == 0 { - return &image.NRGBA{} - } - - srcW := img.Bounds().Dx() - srcH := img.Bounds().Dy() - if srcW <= 0 || srcH <= 0 { - return &image.NRGBA{} - } - - // If new width or height is 0 then preserve aspect ratio, minimum 1px. - if dstW == 0 { - tmpW := float64(dstH) * float64(srcW) / float64(srcH) - dstW = int(math.Max(1.0, math.Floor(tmpW+0.5))) - } - if dstH == 0 { - tmpH := float64(dstW) * float64(srcH) / float64(srcW) - dstH = int(math.Max(1.0, math.Floor(tmpH+0.5))) - } - - if filter.Support <= 0 { - // Nearest-neighbor special case. - return resizeNearest(img, dstW, dstH) - } - - if srcW != dstW && srcH != dstH { - return resizeVertical(resizeHorizontal(img, dstW, filter), dstH, filter) - } - if srcW != dstW { - return resizeHorizontal(img, dstW, filter) - } - if srcH != dstH { - return resizeVertical(img, dstH, filter) - } - return Clone(img) -} - -func resizeHorizontal(img image.Image, width int, filter ResampleFilter) *image.NRGBA { - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, width, src.h)) - weights := precomputeWeights(width, src.w, filter) - parallel(0, src.h, func(ys <-chan int) { - scanLine := make([]uint8, src.w*4) - for y := range ys { - src.scan(0, y, src.w, y+1, scanLine) - j0 := y * dst.Stride - for x := 0; x < width; x++ { - var r, g, b, a float64 - for _, w := range weights[x] { - i := w.index * 4 - aw := float64(scanLine[i+3]) * w.weight - r += float64(scanLine[i+0]) * aw - g += float64(scanLine[i+1]) * aw - b += float64(scanLine[i+2]) * aw - a += aw - } - if a != 0 { - aInv := 1 / a - j := j0 + x*4 - dst.Pix[j+0] = clamp(r * aInv) - dst.Pix[j+1] = clamp(g * aInv) - dst.Pix[j+2] = clamp(b * aInv) - dst.Pix[j+3] = clamp(a) - } - } - } - }) - return dst -} - -func resizeVertical(img image.Image, height int, filter ResampleFilter) *image.NRGBA { - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, src.w, height)) - weights := precomputeWeights(height, src.h, filter) - parallel(0, src.w, func(xs <-chan int) { - scanLine := make([]uint8, src.h*4) - for x := range xs { - src.scan(x, 0, x+1, src.h, scanLine) - for y := 0; y < height; y++ { - var r, g, b, a float64 - for _, w := range weights[y] { - i := w.index * 4 - aw := float64(scanLine[i+3]) * w.weight - r += float64(scanLine[i+0]) * aw - g += float64(scanLine[i+1]) * aw - b += float64(scanLine[i+2]) * aw - a += aw - } - if a != 0 { - aInv := 1 / a - j := y*dst.Stride + x*4 - dst.Pix[j+0] = clamp(r * aInv) - dst.Pix[j+1] = clamp(g * aInv) - dst.Pix[j+2] = clamp(b * aInv) - dst.Pix[j+3] = clamp(a) - } - } - } - }) - return dst -} - -// resizeNearest is a fast nearest-neighbor resize, no filtering. -func resizeNearest(img image.Image, width, height int) *image.NRGBA { - dst := image.NewNRGBA(image.Rect(0, 0, width, height)) - dx := float64(img.Bounds().Dx()) / float64(width) - dy := float64(img.Bounds().Dy()) / float64(height) - - if dx > 1 && dy > 1 { - src := newScanner(img) - parallel(0, height, func(ys <-chan int) { - for y := range ys { - srcY := int((float64(y) + 0.5) * dy) - dstOff := y * dst.Stride - for x := 0; x < width; x++ { - srcX := int((float64(x) + 0.5) * dx) - src.scan(srcX, srcY, srcX+1, srcY+1, dst.Pix[dstOff:dstOff+4]) - dstOff += 4 - } - } - }) - } else { - src := toNRGBA(img) - parallel(0, height, func(ys <-chan int) { - for y := range ys { - srcY := int((float64(y) + 0.5) * dy) - srcOff0 := srcY * src.Stride - dstOff := y * dst.Stride - for x := 0; x < width; x++ { - srcX := int((float64(x) + 0.5) * dx) - srcOff := srcOff0 + srcX*4 - copy(dst.Pix[dstOff:dstOff+4], src.Pix[srcOff:srcOff+4]) - dstOff += 4 - } - } - }) - } - - return dst -} - -// Fit scales down the image using the specified resample filter to fit the specified -// maximum width and height and returns the transformed image. -// -// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, -// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine. -// -// Usage example: -// -// dstImage := imaging.Fit(srcImage, 800, 600, imaging.Lanczos) -// -func Fit(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA { - maxW, maxH := width, height - - if maxW <= 0 || maxH <= 0 { - return &image.NRGBA{} - } - - srcBounds := img.Bounds() - srcW := srcBounds.Dx() - srcH := srcBounds.Dy() - - if srcW <= 0 || srcH <= 0 { - return &image.NRGBA{} - } - - if srcW <= maxW && srcH <= maxH { - return Clone(img) - } - - srcAspectRatio := float64(srcW) / float64(srcH) - maxAspectRatio := float64(maxW) / float64(maxH) - - var newW, newH int - if srcAspectRatio > maxAspectRatio { - newW = maxW - newH = int(float64(newW) / srcAspectRatio) - } else { - newH = maxH - newW = int(float64(newH) * srcAspectRatio) - } - - return Resize(img, newW, newH, filter) -} - -// Fill scales the image to the smallest possible size that will cover the specified dimensions, -// crops the resized image to the specified dimensions using the given anchor point and returns -// the transformed image. -// -// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, -// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine. -// -// Usage example: -// -// dstImage := imaging.Fill(srcImage, 800, 600, imaging.Center, imaging.Lanczos) -// -func Fill(img image.Image, width, height int, anchor Anchor, filter ResampleFilter) *image.NRGBA { - minW, minH := width, height - - if minW <= 0 || minH <= 0 { - return &image.NRGBA{} - } - - srcBounds := img.Bounds() - srcW := srcBounds.Dx() - srcH := srcBounds.Dy() - - if srcW <= 0 || srcH <= 0 { - return &image.NRGBA{} - } - - if srcW == minW && srcH == minH { - return Clone(img) - } - - srcAspectRatio := float64(srcW) / float64(srcH) - minAspectRatio := float64(minW) / float64(minH) - - var tmp *image.NRGBA - if srcAspectRatio < minAspectRatio { - tmp = Resize(img, minW, 0, filter) - } else { - tmp = Resize(img, 0, minH, filter) - } - - return CropAnchor(tmp, minW, minH, anchor) -} - -// Thumbnail scales the image up or down using the specified resample filter, crops it -// to the specified width and hight and returns the transformed image. -// -// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, -// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine. -// -// Usage example: -// -// dstImage := imaging.Thumbnail(srcImage, 100, 100, imaging.Lanczos) -// -func Thumbnail(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA { - return Fill(img, width, height, Center, filter) -} - -// ResampleFilter is a resampling filter struct. It can be used to define custom filters. -// -// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, -// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine. -// -// General filter recommendations: -// -// - Lanczos -// High-quality resampling filter for photographic images yielding sharp results. -// It's slower than cubic filters (see below). -// -// - CatmullRom -// A sharp cubic filter. It's a good filter for both upscaling and downscaling if sharp results are needed. -// -// - MitchellNetravali -// A high quality cubic filter that produces smoother results with less ringing artifacts than CatmullRom. -// -// - BSpline -// A good filter if a very smooth output is needed. -// -// - Linear -// Bilinear interpolation filter, produces reasonably good, smooth output. -// It's faster than cubic filters. -// -// - Box -// Simple and fast averaging filter appropriate for downscaling. -// When upscaling it's similar to NearestNeighbor. -// -// - NearestNeighbor -// Fastest resampling filter, no antialiasing. -// -type ResampleFilter struct { - Support float64 - Kernel func(float64) float64 -} - -// NearestNeighbor is a nearest-neighbor filter (no anti-aliasing). -var NearestNeighbor ResampleFilter - -// Box filter (averaging pixels). -var Box ResampleFilter - -// Linear filter. -var Linear ResampleFilter - -// Hermite cubic spline filter (BC-spline; B=0; C=0). -var Hermite ResampleFilter - -// MitchellNetravali is Mitchell-Netravali cubic filter (BC-spline; B=1/3; C=1/3). -var MitchellNetravali ResampleFilter - -// CatmullRom is a Catmull-Rom - sharp cubic filter (BC-spline; B=0; C=0.5). -var CatmullRom ResampleFilter - -// BSpline is a smooth cubic filter (BC-spline; B=1; C=0). -var BSpline ResampleFilter - -// Gaussian is a Gaussian blurring Filter. -var Gaussian ResampleFilter - -// Bartlett is a Bartlett-windowed sinc filter (3 lobes). -var Bartlett ResampleFilter - -// Lanczos filter (3 lobes). -var Lanczos ResampleFilter - -// Hann is a Hann-windowed sinc filter (3 lobes). -var Hann ResampleFilter - -// Hamming is a Hamming-windowed sinc filter (3 lobes). -var Hamming ResampleFilter - -// Blackman is a Blackman-windowed sinc filter (3 lobes). -var Blackman ResampleFilter - -// Welch is a Welch-windowed sinc filter (parabolic window, 3 lobes). -var Welch ResampleFilter - -// Cosine is a Cosine-windowed sinc filter (3 lobes). -var Cosine ResampleFilter - -func bcspline(x, b, c float64) float64 { - var y float64 - x = math.Abs(x) - if x < 1.0 { - y = ((12-9*b-6*c)*x*x*x + (-18+12*b+6*c)*x*x + (6 - 2*b)) / 6 - } else if x < 2.0 { - y = ((-b-6*c)*x*x*x + (6*b+30*c)*x*x + (-12*b-48*c)*x + (8*b + 24*c)) / 6 - } - return y -} - -func sinc(x float64) float64 { - if x == 0 { - return 1 - } - return math.Sin(math.Pi*x) / (math.Pi * x) -} - -func init() { - NearestNeighbor = ResampleFilter{ - Support: 0.0, // special case - not applying the filter - } - - Box = ResampleFilter{ - Support: 0.5, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x <= 0.5 { - return 1.0 - } - return 0 - }, - } - - Linear = ResampleFilter{ - Support: 1.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 1.0 { - return 1.0 - x - } - return 0 - }, - } - - Hermite = ResampleFilter{ - Support: 1.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 1.0 { - return bcspline(x, 0.0, 0.0) - } - return 0 - }, - } - - MitchellNetravali = ResampleFilter{ - Support: 2.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 2.0 { - return bcspline(x, 1.0/3.0, 1.0/3.0) - } - return 0 - }, - } - - CatmullRom = ResampleFilter{ - Support: 2.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 2.0 { - return bcspline(x, 0.0, 0.5) - } - return 0 - }, - } - - BSpline = ResampleFilter{ - Support: 2.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 2.0 { - return bcspline(x, 1.0, 0.0) - } - return 0 - }, - } - - Gaussian = ResampleFilter{ - Support: 2.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 2.0 { - return math.Exp(-2 * x * x) - } - return 0 - }, - } - - Bartlett = ResampleFilter{ - Support: 3.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 3.0 { - return sinc(x) * (3.0 - x) / 3.0 - } - return 0 - }, - } - - Lanczos = ResampleFilter{ - Support: 3.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 3.0 { - return sinc(x) * sinc(x/3.0) - } - return 0 - }, - } - - Hann = ResampleFilter{ - Support: 3.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 3.0 { - return sinc(x) * (0.5 + 0.5*math.Cos(math.Pi*x/3.0)) - } - return 0 - }, - } - - Hamming = ResampleFilter{ - Support: 3.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 3.0 { - return sinc(x) * (0.54 + 0.46*math.Cos(math.Pi*x/3.0)) - } - return 0 - }, - } - - Blackman = ResampleFilter{ - Support: 3.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 3.0 { - return sinc(x) * (0.42 - 0.5*math.Cos(math.Pi*x/3.0+math.Pi) + 0.08*math.Cos(2.0*math.Pi*x/3.0)) - } - return 0 - }, - } - - Welch = ResampleFilter{ - Support: 3.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 3.0 { - return sinc(x) * (1.0 - (x * x / 9.0)) - } - return 0 - }, - } - - Cosine = ResampleFilter{ - Support: 3.0, - Kernel: func(x float64) float64 { - x = math.Abs(x) - if x < 3.0 { - return sinc(x) * math.Cos((math.Pi/2.0)*(x/3.0)) - } - return 0 - }, - } -} diff --git a/vendor/github.com/disintegration/imaging/scanner.go b/vendor/github.com/disintegration/imaging/scanner.go deleted file mode 100644 index c4dbfe1..0000000 --- a/vendor/github.com/disintegration/imaging/scanner.go +++ /dev/null @@ -1,250 +0,0 @@ -package imaging - -import ( - "image" - "image/color" -) - -type scanner struct { - image image.Image - w, h int - palette []color.NRGBA -} - -func newScanner(img image.Image) *scanner { - s := &scanner{ - image: img, - w: img.Bounds().Dx(), - h: img.Bounds().Dy(), - } - if img, ok := img.(*image.Paletted); ok { - s.palette = make([]color.NRGBA, len(img.Palette)) - for i := 0; i < len(img.Palette); i++ { - s.palette[i] = color.NRGBAModel.Convert(img.Palette[i]).(color.NRGBA) - } - } - return s -} - -// scan scans the given rectangular region of the image into dst. -func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) { - switch img := s.image.(type) { - case *image.NRGBA: - size := (x2 - x1) * 4 - j := 0 - i := y1*img.Stride + x1*4 - for y := y1; y < y2; y++ { - copy(dst[j:j+size], img.Pix[i:i+size]) - j += size - i += img.Stride - } - - case *image.NRGBA64: - j := 0 - for y := y1; y < y2; y++ { - i := y*img.Stride + x1*8 - for x := x1; x < x2; x++ { - dst[j+0] = img.Pix[i+0] - dst[j+1] = img.Pix[i+2] - dst[j+2] = img.Pix[i+4] - dst[j+3] = img.Pix[i+6] - j += 4 - i += 8 - } - } - - case *image.RGBA: - j := 0 - for y := y1; y < y2; y++ { - i := y*img.Stride + x1*4 - for x := x1; x < x2; x++ { - a := img.Pix[i+3] - switch a { - case 0: - dst[j+0] = 0 - dst[j+1] = 0 - dst[j+2] = 0 - case 0xff: - dst[j+0] = img.Pix[i+0] - dst[j+1] = img.Pix[i+1] - dst[j+2] = img.Pix[i+2] - default: - r16 := uint16(img.Pix[i+0]) - g16 := uint16(img.Pix[i+1]) - b16 := uint16(img.Pix[i+2]) - a16 := uint16(a) - dst[j+0] = uint8(r16 * 0xff / a16) - dst[j+1] = uint8(g16 * 0xff / a16) - dst[j+2] = uint8(b16 * 0xff / a16) - } - dst[j+3] = a - j += 4 - i += 4 - } - } - - case *image.RGBA64: - j := 0 - for y := y1; y < y2; y++ { - i := y*img.Stride + x1*8 - for x := x1; x < x2; x++ { - a := img.Pix[i+6] - switch a { - case 0: - dst[j+0] = 0 - dst[j+1] = 0 - dst[j+2] = 0 - case 0xff: - dst[j+0] = img.Pix[i+0] - dst[j+1] = img.Pix[i+2] - dst[j+2] = img.Pix[i+4] - default: - r32 := uint32(img.Pix[i+0])<<8 | uint32(img.Pix[i+1]) - g32 := uint32(img.Pix[i+2])<<8 | uint32(img.Pix[i+3]) - b32 := uint32(img.Pix[i+4])<<8 | uint32(img.Pix[i+5]) - a32 := uint32(img.Pix[i+6])<<8 | uint32(img.Pix[i+7]) - dst[j+0] = uint8((r32 * 0xffff / a32) >> 8) - dst[j+1] = uint8((g32 * 0xffff / a32) >> 8) - dst[j+2] = uint8((b32 * 0xffff / a32) >> 8) - } - dst[j+3] = a - j += 4 - i += 8 - } - } - - case *image.Gray: - j := 0 - for y := y1; y < y2; y++ { - i := y*img.Stride + x1 - for x := x1; x < x2; x++ { - c := img.Pix[i] - dst[j+0] = c - dst[j+1] = c - dst[j+2] = c - dst[j+3] = 0xff - j += 4 - i++ - } - } - - case *image.Gray16: - j := 0 - for y := y1; y < y2; y++ { - i := y*img.Stride + x1*2 - for x := x1; x < x2; x++ { - c := img.Pix[i] - dst[j+0] = c - dst[j+1] = c - dst[j+2] = c - dst[j+3] = 0xff - j += 4 - i += 2 - } - } - - case *image.YCbCr: - j := 0 - x1 += img.Rect.Min.X - x2 += img.Rect.Min.X - y1 += img.Rect.Min.Y - y2 += img.Rect.Min.Y - for y := y1; y < y2; y++ { - iy := (y-img.Rect.Min.Y)*img.YStride + (x1 - img.Rect.Min.X) - for x := x1; x < x2; x++ { - var ic int - switch img.SubsampleRatio { - case image.YCbCrSubsampleRatio444: - ic = (y-img.Rect.Min.Y)*img.CStride + (x - img.Rect.Min.X) - case image.YCbCrSubsampleRatio422: - ic = (y-img.Rect.Min.Y)*img.CStride + (x/2 - img.Rect.Min.X/2) - case image.YCbCrSubsampleRatio420: - ic = (y/2-img.Rect.Min.Y/2)*img.CStride + (x/2 - img.Rect.Min.X/2) - case image.YCbCrSubsampleRatio440: - ic = (y/2-img.Rect.Min.Y/2)*img.CStride + (x - img.Rect.Min.X) - default: - ic = img.COffset(x, y) - } - - yy := int(img.Y[iy]) - cb := int(img.Cb[ic]) - 128 - cr := int(img.Cr[ic]) - 128 - - r := (yy<<16 + 91881*cr + 1<<15) >> 16 - if r > 0xff { - r = 0xff - } else if r < 0 { - r = 0 - } - - g := (yy<<16 - 22554*cb - 46802*cr + 1<<15) >> 16 - if g > 0xff { - g = 0xff - } else if g < 0 { - g = 0 - } - - b := (yy<<16 + 116130*cb + 1<<15) >> 16 - if b > 0xff { - b = 0xff - } else if b < 0 { - b = 0 - } - - dst[j+0] = uint8(r) - dst[j+1] = uint8(g) - dst[j+2] = uint8(b) - dst[j+3] = 0xff - - iy++ - j += 4 - } - } - - case *image.Paletted: - j := 0 - for y := y1; y < y2; y++ { - i := y*img.Stride + x1 - for x := x1; x < x2; x++ { - c := s.palette[img.Pix[i]] - dst[j+0] = c.R - dst[j+1] = c.G - dst[j+2] = c.B - dst[j+3] = c.A - j += 4 - i++ - } - } - - default: - j := 0 - b := s.image.Bounds() - x1 += b.Min.X - x2 += b.Min.X - y1 += b.Min.Y - y2 += b.Min.Y - for y := y1; y < y2; y++ { - for x := x1; x < x2; x++ { - r16, g16, b16, a16 := s.image.At(x, y).RGBA() - switch a16 { - case 0xffff: - dst[j+0] = uint8(r16 >> 8) - dst[j+1] = uint8(g16 >> 8) - dst[j+2] = uint8(b16 >> 8) - dst[j+3] = 0xff - case 0: - dst[j+0] = 0 - dst[j+1] = 0 - dst[j+2] = 0 - dst[j+3] = 0 - default: - dst[j+0] = uint8(((r16 * 0xffff) / a16) >> 8) - dst[j+1] = uint8(((g16 * 0xffff) / a16) >> 8) - dst[j+2] = uint8(((b16 * 0xffff) / a16) >> 8) - dst[j+3] = uint8(a16 >> 8) - } - j += 4 - } - } - } -} diff --git a/vendor/github.com/disintegration/imaging/tools.go b/vendor/github.com/disintegration/imaging/tools.go deleted file mode 100644 index 7887946..0000000 --- a/vendor/github.com/disintegration/imaging/tools.go +++ /dev/null @@ -1,247 +0,0 @@ -package imaging - -import ( - "bytes" - "image" - "image/color" - "math" -) - -// New creates a new image with the specified width and height, and fills it with the specified color. -func New(width, height int, fillColor color.Color) *image.NRGBA { - if width <= 0 || height <= 0 { - return &image.NRGBA{} - } - - c := color.NRGBAModel.Convert(fillColor).(color.NRGBA) - if (c == color.NRGBA{0, 0, 0, 0}) { - return image.NewNRGBA(image.Rect(0, 0, width, height)) - } - - return &image.NRGBA{ - Pix: bytes.Repeat([]byte{c.R, c.G, c.B, c.A}, width*height), - Stride: 4 * width, - Rect: image.Rect(0, 0, width, height), - } -} - -// Clone returns a copy of the given image. -func Clone(img image.Image) *image.NRGBA { - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) - size := src.w * 4 - parallel(0, src.h, func(ys <-chan int) { - for y := range ys { - i := y * dst.Stride - src.scan(0, y, src.w, y+1, dst.Pix[i:i+size]) - } - }) - return dst -} - -// Anchor is the anchor point for image alignment. -type Anchor int - -// Anchor point positions. -const ( - Center Anchor = iota - TopLeft - Top - TopRight - Left - Right - BottomLeft - Bottom - BottomRight -) - -func anchorPt(b image.Rectangle, w, h int, anchor Anchor) image.Point { - var x, y int - switch anchor { - case TopLeft: - x = b.Min.X - y = b.Min.Y - case Top: - x = b.Min.X + (b.Dx()-w)/2 - y = b.Min.Y - case TopRight: - x = b.Max.X - w - y = b.Min.Y - case Left: - x = b.Min.X - y = b.Min.Y + (b.Dy()-h)/2 - case Right: - x = b.Max.X - w - y = b.Min.Y + (b.Dy()-h)/2 - case BottomLeft: - x = b.Min.X - y = b.Max.Y - h - case Bottom: - x = b.Min.X + (b.Dx()-w)/2 - y = b.Max.Y - h - case BottomRight: - x = b.Max.X - w - y = b.Max.Y - h - default: - x = b.Min.X + (b.Dx()-w)/2 - y = b.Min.Y + (b.Dy()-h)/2 - } - return image.Pt(x, y) -} - -// Crop cuts out a rectangular region with the specified bounds -// from the image and returns the cropped image. -func Crop(img image.Image, rect image.Rectangle) *image.NRGBA { - r := rect.Intersect(img.Bounds()).Sub(img.Bounds().Min) - if r.Empty() { - return &image.NRGBA{} - } - src := newScanner(img) - dst := image.NewNRGBA(image.Rect(0, 0, r.Dx(), r.Dy())) - rowSize := r.Dx() * 4 - parallel(r.Min.Y, r.Max.Y, func(ys <-chan int) { - for y := range ys { - i := (y - r.Min.Y) * dst.Stride - src.scan(r.Min.X, y, r.Max.X, y+1, dst.Pix[i:i+rowSize]) - } - }) - return dst -} - -// CropAnchor cuts out a rectangular region with the specified size -// from the image using the specified anchor point and returns the cropped image. -func CropAnchor(img image.Image, width, height int, anchor Anchor) *image.NRGBA { - srcBounds := img.Bounds() - pt := anchorPt(srcBounds, width, height, anchor) - r := image.Rect(0, 0, width, height).Add(pt) - b := srcBounds.Intersect(r) - return Crop(img, b) -} - -// CropCenter cuts out a rectangular region with the specified size -// from the center of the image and returns the cropped image. -func CropCenter(img image.Image, width, height int) *image.NRGBA { - return CropAnchor(img, width, height, Center) -} - -// Paste pastes the img image to the background image at the specified position and returns the combined image. -func Paste(background, img image.Image, pos image.Point) *image.NRGBA { - dst := Clone(background) - pos = pos.Sub(background.Bounds().Min) - pasteRect := image.Rectangle{Min: pos, Max: pos.Add(img.Bounds().Size())} - interRect := pasteRect.Intersect(dst.Bounds()) - if interRect.Empty() { - return dst - } - src := newScanner(img) - parallel(interRect.Min.Y, interRect.Max.Y, func(ys <-chan int) { - for y := range ys { - x1 := interRect.Min.X - pasteRect.Min.X - x2 := interRect.Max.X - pasteRect.Min.X - y1 := y - pasteRect.Min.Y - y2 := y1 + 1 - i1 := y*dst.Stride + interRect.Min.X*4 - i2 := i1 + interRect.Dx()*4 - src.scan(x1, y1, x2, y2, dst.Pix[i1:i2]) - } - }) - return dst -} - -// PasteCenter pastes the img image to the center of the background image and returns the combined image. -func PasteCenter(background, img image.Image) *image.NRGBA { - bgBounds := background.Bounds() - bgW := bgBounds.Dx() - bgH := bgBounds.Dy() - bgMinX := bgBounds.Min.X - bgMinY := bgBounds.Min.Y - - centerX := bgMinX + bgW/2 - centerY := bgMinY + bgH/2 - - x0 := centerX - img.Bounds().Dx()/2 - y0 := centerY - img.Bounds().Dy()/2 - - return Paste(background, img, image.Pt(x0, y0)) -} - -// Overlay draws the img image over the background image at given position -// and returns the combined image. Opacity parameter is the opacity of the img -// image layer, used to compose the images, it must be from 0.0 to 1.0. -// -// Usage examples: -// -// // Draw spriteImage over backgroundImage at the given position (x=50, y=50). -// dstImage := imaging.Overlay(backgroundImage, spriteImage, image.Pt(50, 50), 1.0) -// -// // Blend two opaque images of the same size. -// dstImage := imaging.Overlay(imageOne, imageTwo, image.Pt(0, 0), 0.5) -// -func Overlay(background, img image.Image, pos image.Point, opacity float64) *image.NRGBA { - opacity = math.Min(math.Max(opacity, 0.0), 1.0) // Ensure 0.0 <= opacity <= 1.0. - dst := Clone(background) - pos = pos.Sub(background.Bounds().Min) - pasteRect := image.Rectangle{Min: pos, Max: pos.Add(img.Bounds().Size())} - interRect := pasteRect.Intersect(dst.Bounds()) - if interRect.Empty() { - return dst - } - src := newScanner(img) - parallel(interRect.Min.Y, interRect.Max.Y, func(ys <-chan int) { - scanLine := make([]uint8, interRect.Dx()*4) - for y := range ys { - x1 := interRect.Min.X - pasteRect.Min.X - x2 := interRect.Max.X - pasteRect.Min.X - y1 := y - pasteRect.Min.Y - y2 := y1 + 1 - src.scan(x1, y1, x2, y2, scanLine) - i := y*dst.Stride + interRect.Min.X*4 - j := 0 - for x := interRect.Min.X; x < interRect.Max.X; x++ { - r1 := float64(dst.Pix[i+0]) - g1 := float64(dst.Pix[i+1]) - b1 := float64(dst.Pix[i+2]) - a1 := float64(dst.Pix[i+3]) - - r2 := float64(scanLine[j+0]) - g2 := float64(scanLine[j+1]) - b2 := float64(scanLine[j+2]) - a2 := float64(scanLine[j+3]) - - coef2 := opacity * a2 / 255 - coef1 := (1 - coef2) * a1 / 255 - coefSum := coef1 + coef2 - coef1 /= coefSum - coef2 /= coefSum - - dst.Pix[i+0] = uint8(r1*coef1 + r2*coef2) - dst.Pix[i+1] = uint8(g1*coef1 + g2*coef2) - dst.Pix[i+2] = uint8(b1*coef1 + b2*coef2) - dst.Pix[i+3] = uint8(math.Min(a1+a2*opacity*(255-a1)/255, 255)) - - i += 4 - j += 4 - } - } - }) - return dst -} - -// OverlayCenter overlays the img image to the center of the background image and -// returns the combined image. Opacity parameter is the opacity of the img -// image layer, used to compose the images, it must be from 0.0 to 1.0. -func OverlayCenter(background, img image.Image, opacity float64) *image.NRGBA { - bgBounds := background.Bounds() - bgW := bgBounds.Dx() - bgH := bgBounds.Dy() - bgMinX := bgBounds.Min.X - bgMinY := bgBounds.Min.Y - - centerX := bgMinX + bgW/2 - centerY := bgMinY + bgH/2 - - x0 := centerX - img.Bounds().Dx()/2 - y0 := centerY - img.Bounds().Dy()/2 - - return Overlay(background, img, image.Point{x0, y0}, opacity) -} diff --git a/vendor/github.com/disintegration/imaging/transform.go b/vendor/github.com/disintegration/imaging/transform.go deleted file mode 100644 index d788d0d..0000000 --- a/vendor/github.com/disintegration/imaging/transform.go +++ /dev/null @@ -1,271 +0,0 @@ -package imaging - -import ( - "image" - "image/color" - "math" -) - -// FlipH flips the image horizontally (from left to right) and returns the transformed image. -func FlipH(img image.Image) *image.NRGBA { - src := newScanner(img) - dstW := src.w - dstH := src.h - rowSize := dstW * 4 - dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) - parallel(0, dstH, func(ys <-chan int) { - for dstY := range ys { - i := dstY * dst.Stride - srcY := dstY - src.scan(0, srcY, src.w, srcY+1, dst.Pix[i:i+rowSize]) - reverse(dst.Pix[i : i+rowSize]) - } - }) - return dst -} - -// FlipV flips the image vertically (from top to bottom) and returns the transformed image. -func FlipV(img image.Image) *image.NRGBA { - src := newScanner(img) - dstW := src.w - dstH := src.h - rowSize := dstW * 4 - dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) - parallel(0, dstH, func(ys <-chan int) { - for dstY := range ys { - i := dstY * dst.Stride - srcY := dstH - dstY - 1 - src.scan(0, srcY, src.w, srcY+1, dst.Pix[i:i+rowSize]) - } - }) - return dst -} - -// Transpose flips the image horizontally and rotates 90 degrees counter-clockwise. -func Transpose(img image.Image) *image.NRGBA { - src := newScanner(img) - dstW := src.h - dstH := src.w - rowSize := dstW * 4 - dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) - parallel(0, dstH, func(ys <-chan int) { - for dstY := range ys { - i := dstY * dst.Stride - srcX := dstY - src.scan(srcX, 0, srcX+1, src.h, dst.Pix[i:i+rowSize]) - } - }) - return dst -} - -// Transverse flips the image vertically and rotates 90 degrees counter-clockwise. -func Transverse(img image.Image) *image.NRGBA { - src := newScanner(img) - dstW := src.h - dstH := src.w - rowSize := dstW * 4 - dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) - parallel(0, dstH, func(ys <-chan int) { - for dstY := range ys { - i := dstY * dst.Stride - srcX := dstH - dstY - 1 - src.scan(srcX, 0, srcX+1, src.h, dst.Pix[i:i+rowSize]) - reverse(dst.Pix[i : i+rowSize]) - } - }) - return dst -} - -// Rotate90 rotates the image 90 degrees counter-clockwise and returns the transformed image. -func Rotate90(img image.Image) *image.NRGBA { - src := newScanner(img) - dstW := src.h - dstH := src.w - rowSize := dstW * 4 - dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) - parallel(0, dstH, func(ys <-chan int) { - for dstY := range ys { - i := dstY * dst.Stride - srcX := dstH - dstY - 1 - src.scan(srcX, 0, srcX+1, src.h, dst.Pix[i:i+rowSize]) - } - }) - return dst -} - -// Rotate180 rotates the image 180 degrees counter-clockwise and returns the transformed image. -func Rotate180(img image.Image) *image.NRGBA { - src := newScanner(img) - dstW := src.w - dstH := src.h - rowSize := dstW * 4 - dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) - parallel(0, dstH, func(ys <-chan int) { - for dstY := range ys { - i := dstY * dst.Stride - srcY := dstH - dstY - 1 - src.scan(0, srcY, src.w, srcY+1, dst.Pix[i:i+rowSize]) - reverse(dst.Pix[i : i+rowSize]) - } - }) - return dst -} - -// Rotate270 rotates the image 270 degrees counter-clockwise and returns the transformed image. -func Rotate270(img image.Image) *image.NRGBA { - src := newScanner(img) - dstW := src.h - dstH := src.w - rowSize := dstW * 4 - dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) - parallel(0, dstH, func(ys <-chan int) { - for dstY := range ys { - i := dstY * dst.Stride - srcX := dstY - src.scan(srcX, 0, srcX+1, src.h, dst.Pix[i:i+rowSize]) - reverse(dst.Pix[i : i+rowSize]) - } - }) - return dst -} - -// Rotate rotates an image by the given angle counter-clockwise . -// The angle parameter is the rotation angle in degrees. -// The bgColor parameter specifies the color of the uncovered zone after the rotation. -func Rotate(img image.Image, angle float64, bgColor color.Color) *image.NRGBA { - angle = angle - math.Floor(angle/360)*360 - - switch angle { - case 0: - return Clone(img) - case 90: - return Rotate90(img) - case 180: - return Rotate180(img) - case 270: - return Rotate270(img) - } - - src := toNRGBA(img) - srcW := src.Bounds().Max.X - srcH := src.Bounds().Max.Y - dstW, dstH := rotatedSize(srcW, srcH, angle) - dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH)) - - if dstW <= 0 || dstH <= 0 { - return dst - } - - srcXOff := float64(srcW)/2 - 0.5 - srcYOff := float64(srcH)/2 - 0.5 - dstXOff := float64(dstW)/2 - 0.5 - dstYOff := float64(dstH)/2 - 0.5 - - bgColorNRGBA := color.NRGBAModel.Convert(bgColor).(color.NRGBA) - sin, cos := math.Sincos(math.Pi * angle / 180) - - parallel(0, dstH, func(ys <-chan int) { - for dstY := range ys { - for dstX := 0; dstX < dstW; dstX++ { - xf, yf := rotatePoint(float64(dstX)-dstXOff, float64(dstY)-dstYOff, sin, cos) - xf, yf = xf+srcXOff, yf+srcYOff - interpolatePoint(dst, dstX, dstY, src, xf, yf, bgColorNRGBA) - } - } - }) - - return dst -} - -func rotatePoint(x, y, sin, cos float64) (float64, float64) { - return x*cos - y*sin, x*sin + y*cos -} - -func rotatedSize(w, h int, angle float64) (int, int) { - if w <= 0 || h <= 0 { - return 0, 0 - } - - sin, cos := math.Sincos(math.Pi * angle / 180) - x1, y1 := rotatePoint(float64(w-1), 0, sin, cos) - x2, y2 := rotatePoint(float64(w-1), float64(h-1), sin, cos) - x3, y3 := rotatePoint(0, float64(h-1), sin, cos) - - minx := math.Min(x1, math.Min(x2, math.Min(x3, 0))) - maxx := math.Max(x1, math.Max(x2, math.Max(x3, 0))) - miny := math.Min(y1, math.Min(y2, math.Min(y3, 0))) - maxy := math.Max(y1, math.Max(y2, math.Max(y3, 0))) - - neww := maxx - minx + 1 - if neww-math.Floor(neww) > 0.1 { - neww++ - } - newh := maxy - miny + 1 - if newh-math.Floor(newh) > 0.1 { - newh++ - } - - return int(neww), int(newh) -} - -func interpolatePoint(dst *image.NRGBA, dstX, dstY int, src *image.NRGBA, xf, yf float64, bgColor color.NRGBA) { - dstIndex := dstY*dst.Stride + dstX*4 - - x0 := int(math.Floor(xf)) - y0 := int(math.Floor(yf)) - bounds := src.Bounds() - if !image.Pt(x0, y0).In(image.Rect(bounds.Min.X-1, bounds.Min.Y-1, bounds.Max.X, bounds.Max.Y)) { - dst.Pix[dstIndex+0] = bgColor.R - dst.Pix[dstIndex+1] = bgColor.G - dst.Pix[dstIndex+2] = bgColor.B - dst.Pix[dstIndex+3] = bgColor.A - return - } - - xq := xf - float64(x0) - yq := yf - float64(y0) - - var pxs [4]color.NRGBA - var cfs [4]float64 - - for i := 0; i < 2; i++ { - for j := 0; j < 2; j++ { - k := i*2 + j - pt := image.Pt(x0+j, y0+i) - if pt.In(bounds) { - l := pt.Y*src.Stride + pt.X*4 - pxs[k].R = src.Pix[l+0] - pxs[k].G = src.Pix[l+1] - pxs[k].B = src.Pix[l+2] - pxs[k].A = src.Pix[l+3] - } else { - pxs[k] = bgColor - } - } - } - - cfs[0] = (1 - xq) * (1 - yq) - cfs[1] = xq * (1 - yq) - cfs[2] = (1 - xq) * yq - cfs[3] = xq * yq - - var r, g, b, a float64 - for i := range pxs { - wa := float64(pxs[i].A) * cfs[i] - r += float64(pxs[i].R) * wa - g += float64(pxs[i].G) * wa - b += float64(pxs[i].B) * wa - a += wa - } - - if a != 0 { - r /= a - g /= a - b /= a - } - - dst.Pix[dstIndex+0] = clamp(r) - dst.Pix[dstIndex+1] = clamp(g) - dst.Pix[dstIndex+2] = clamp(b) - dst.Pix[dstIndex+3] = clamp(a) -} diff --git a/vendor/github.com/disintegration/imaging/utils.go b/vendor/github.com/disintegration/imaging/utils.go deleted file mode 100644 index 3b6ad2e..0000000 --- a/vendor/github.com/disintegration/imaging/utils.go +++ /dev/null @@ -1,83 +0,0 @@ -package imaging - -import ( - "image" - "runtime" - "sync" -) - -// parallel processes the data in separate goroutines. -func parallel(start, stop int, fn func(<-chan int)) { - count := stop - start - if count < 1 { - return - } - - procs := runtime.GOMAXPROCS(0) - if procs > count { - procs = count - } - - c := make(chan int, count) - for i := start; i < stop; i++ { - c <- i - } - close(c) - - var wg sync.WaitGroup - for i := 0; i < procs; i++ { - wg.Add(1) - go func() { - defer wg.Done() - fn(c) - }() - } - wg.Wait() -} - -// absint returns the absolute value of i. -func absint(i int) int { - if i < 0 { - return -i - } - return i -} - -// clamp rounds and clamps float64 value to fit into uint8. -func clamp(x float64) uint8 { - v := int64(x + 0.5) - if v > 255 { - return 255 - } - if v > 0 { - return uint8(v) - } - return 0 -} - -func reverse(pix []uint8) { - if len(pix) <= 4 { - return - } - i := 0 - j := len(pix) - 4 - for i < j { - pix[i+0], pix[j+0] = pix[j+0], pix[i+0] - pix[i+1], pix[j+1] = pix[j+1], pix[i+1] - pix[i+2], pix[j+2] = pix[j+2], pix[i+2] - pix[i+3], pix[j+3] = pix[j+3], pix[i+3] - i += 4 - j -= 4 - } -} - -func toNRGBA(img image.Image) *image.NRGBA { - if img, ok := img.(*image.NRGBA); ok { - return &image.NRGBA{ - Pix: img.Pix, - Stride: img.Stride, - Rect: img.Rect.Sub(img.Rect.Min), - } - } - return Clone(img) -} diff --git a/vendor/github.com/gdamore/encoding/.appveyor.yml b/vendor/github.com/gdamore/encoding/.appveyor.yml deleted file mode 100644 index 19a4c5d..0000000 --- a/vendor/github.com/gdamore/encoding/.appveyor.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 1.0.{build} -clone_folder: c:\gopath\src\github.com\gdamore\encoding -environment: - GOPATH: c:\gopath -build_script: -- go version -- go env -- SET PATH=%LOCALAPPDATA%\atom\bin;%GOPATH%\bin;%PATH% -- go get -t ./... -- go build -- go install ./... -test_script: -- go test ./... diff --git a/vendor/github.com/gdamore/encoding/.travis.yml b/vendor/github.com/gdamore/encoding/.travis.yml deleted file mode 100644 index cfc7547..0000000 --- a/vendor/github.com/gdamore/encoding/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: go - -go: - - 1.3 - - 1.5 - - tip diff --git a/vendor/github.com/gdamore/encoding/LICENSE b/vendor/github.com/gdamore/encoding/LICENSE deleted file mode 100644 index d645695..0000000 --- a/vendor/github.com/gdamore/encoding/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/gdamore/encoding/README.md b/vendor/github.com/gdamore/encoding/README.md deleted file mode 100644 index 3db2b4c..0000000 --- a/vendor/github.com/gdamore/encoding/README.md +++ /dev/null @@ -1,19 +0,0 @@ -## encoding - -[![Linux Status](https://img.shields.io/travis/gdamore/encoding.svg?label=linux)](https://travis-ci.org/gdamore/encoding) -[![Windows Status](https://img.shields.io/appveyor/ci/gdamore/encoding.svg?label=windows)](https://ci.appveyor.com/project/gdamore/encoding) -[![Apache License](https://img.shields.io/badge/license-APACHE2-blue.svg)](https://github.com/gdamore/encoding/blob/master/LICENSE) -[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/gdamore/encoding) -[![Go Report Card](http://goreportcard.com/badge/gdamore/encoding)](http://goreportcard.com/report/gdamore/encoding) - -Package encoding provides a number of encodings that are missing from the -standard Go [encoding]("https://godoc.org/golang.org/x/text/encoding") package. - -We hope that we can contribute these to the standard Go library someday. It -turns out that some of these are useful for dealing with I/O streams coming -from non-UTF friendly sources. - -The UTF8 Encoder is also useful for situations where valid UTF-8 might be -carried in streams that contain non-valid UTF; in particular I use it for -helping me cope with terminals that embed escape sequences in otherwise -valid UTF-8. diff --git a/vendor/github.com/gdamore/encoding/ascii.go b/vendor/github.com/gdamore/encoding/ascii.go deleted file mode 100644 index b7321f4..0000000 --- a/vendor/github.com/gdamore/encoding/ascii.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 Garrett D'Amore -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use file except in compliance with the License. -// You may obtain a copy of the license at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package encoding - -import ( - "golang.org/x/text/encoding" -) - -// ASCII represents the 7-bit US-ASCII scheme. It decodes directly to -// UTF-8 without change, as all ASCII values are legal UTF-8. -// Unicode values less than 128 (i.e. 7 bits) map 1:1 with ASCII. -// It encodes runes outside of that to 0x1A, the ASCII substitution character. -var ASCII encoding.Encoding - -func init() { - amap := make(map[byte]rune) - for i := 128; i <= 255; i++ { - amap[byte(i)] = RuneError - } - - cm := &Charmap{Map: amap} - cm.Init() - ASCII = cm -} diff --git a/vendor/github.com/gdamore/encoding/charmap.go b/vendor/github.com/gdamore/encoding/charmap.go deleted file mode 100644 index e64eaed..0000000 --- a/vendor/github.com/gdamore/encoding/charmap.go +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright 2015 Garrett D'Amore -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use file except in compliance with the License. -// You may obtain a copy of the license at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package encoding - -import ( - "sync" - "unicode/utf8" - - "golang.org/x/text/transform" - "golang.org/x/text/encoding" -) - -const ( - // RuneError is an alias for the UTF-8 replacement rune, '\uFFFD'. - RuneError = '\uFFFD' - - // RuneSelf is the rune below which UTF-8 and the Unicode values are - // identical. Its also the limit for ASCII. - RuneSelf = 0x80 - - // ASCIISub is the ASCII substitution character. - ASCIISub = '\x1a' -) - -// Charmap is a structure for setting up encodings for 8-bit character sets, -// for transforming between UTF8 and that other character set. It has some -// ideas borrowed from golang.org/x/text/encoding/charmap, but it uses a -// different implementation. This implementation uses maps, and supports -// user-defined maps. -// -// We do assume that a character map has a reasonable substitution character, -// and that valid encodings are stable (exactly a 1:1 map) and stateless -// (that is there is no shift character or anything like that.) Hence this -// approach will not work for many East Asian character sets. -// -// Measurement shows little or no measurable difference in the performance of -// the two approaches. The difference was down to a couple of nsec/op, and -// no consistent pattern as to which ran faster. With the conversion to -// UTF-8 the code takes about 25 nsec/op. The conversion in the reverse -// direction takes about 100 nsec/op. (The larger cost for conversion -// from UTF-8 is most likely due to the need to convert the UTF-8 byte stream -// to a rune before conversion. -// -type Charmap struct { - transform.NopResetter - bytes map[rune]byte - runes [256][]byte - once sync.Once - - // The map between bytes and runes. To indicate that a specific - // byte value is invalid for a charcter set, use the rune - // utf8.RuneError. Values that are absent from this map will - // be assumed to have the identity mapping -- that is the default - // is to assume ISO8859-1, where all 8-bit characters have the same - // numeric value as their Unicode runes. (Not to be confused with - // the UTF-8 values, which *will* be different for non-ASCII runes.) - // - // If no values less than RuneSelf are changed (or have non-identity - // mappings), then the character set is assumed to be an ASCII - // superset, and certain assumptions and optimizations become - // available for ASCII bytes. - Map map[byte]rune - - // The ReplacementChar is the byte value to use for substitution. - // It should normally be ASCIISub for ASCII encodings. This may be - // unset (left to zero) for mappings that are strictly ASCII supersets. - // In that case ASCIISub will be assumed instead. - ReplacementChar byte -} - -type cmapDecoder struct { - transform.NopResetter - runes [256][]byte -} - -type cmapEncoder struct { - transform.NopResetter - bytes map[rune]byte - replace byte -} - -// Init initializes internal values of a character map. This should -// be done early, to minimize the cost of allocation of transforms -// later. It is not strictly necessary however, as the allocation -// functions will arrange to call it if it has not already been done. -func (c *Charmap) Init() { - c.once.Do(c.initialize) -} - -func (c *Charmap) initialize() { - c.bytes = make(map[rune]byte) - ascii := true - - for i := 0; i < 256; i++ { - r, ok := c.Map[byte(i)] - if !ok { - r = rune(i) - } - if r < 128 && r != rune(i) { - ascii = false - } - if r != RuneError { - c.bytes[r] = byte(i) - } - utf := make([]byte, utf8.RuneLen(r)) - utf8.EncodeRune(utf, r) - c.runes[i] = utf - } - if ascii && c.ReplacementChar == '\x00' { - c.ReplacementChar = ASCIISub - } -} - -// NewDecoder returns a Decoder the converts from the 8-bit -// character set to UTF-8. Unknown mappings, if any, are mapped -// to '\uFFFD'. -func (c *Charmap) NewDecoder() *encoding.Decoder { - c.Init() - return &encoding.Decoder{Transformer: &cmapDecoder{runes: c.runes}} -} - -// NewEncoder returns a Transformer that converts from UTF8 to the -// 8-bit character set. Unknown mappings are mapped to 0x1A. -func (c *Charmap) NewEncoder() *encoding.Encoder { - c.Init() - return &encoding.Encoder{Transformer: - &cmapEncoder{bytes: c.bytes, replace: c.ReplacementChar}} -} - -func (d *cmapDecoder) Transform(dst, src []byte, atEOF bool) (int, int, error) { - var e error - var ndst, nsrc int - - for _, c := range src { - b := d.runes[c] - l := len(b) - - if ndst+l > len(dst) { - e = transform.ErrShortDst - break - } - for i := 0; i < l; i++ { - dst[ndst] = b[i] - ndst++ - } - nsrc++ - } - return ndst, nsrc, e -} - -func (d *cmapEncoder) Transform(dst, src []byte, atEOF bool) (int, int, error) { - var e error - var ndst, nsrc int - for nsrc < len(src) { - if ndst >= len(dst) { - e = transform.ErrShortDst - break - } - - r, sz := utf8.DecodeRune(src[nsrc:]) - if r == utf8.RuneError && sz == 1 { - // If its inconclusive due to insufficient data in - // in the source, report it - if !atEOF && !utf8.FullRune(src[nsrc:]) { - e = transform.ErrShortSrc - break - } - } - - if c, ok := d.bytes[r]; ok { - dst[ndst] = c - } else { - dst[ndst] = d.replace - } - nsrc += sz - ndst++ - } - - return ndst, nsrc, e -} diff --git a/vendor/github.com/gdamore/encoding/doc.go b/vendor/github.com/gdamore/encoding/doc.go deleted file mode 100644 index 8a7b48d..0000000 --- a/vendor/github.com/gdamore/encoding/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 Garrett D'Amore -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use file except in compliance with the License. -// You may obtain a copy of the license at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package encoding provides a few of the encoding structures that are -// missing from the Go x/text/encoding tree. -package encoding diff --git a/vendor/github.com/gdamore/encoding/ebcdic.go b/vendor/github.com/gdamore/encoding/ebcdic.go deleted file mode 100644 index 8e13f1a..0000000 --- a/vendor/github.com/gdamore/encoding/ebcdic.go +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright 2015 Garrett D'Amore -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use file except in compliance with the License. -// You may obtain a copy of the license at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package encoding - -import ( - "golang.org/x/text/encoding" -) - -// EBCDIC represents the 8-bit EBCDIC scheme, found in some mainframe -// environments. If you don't know what this is, consider yourself lucky. -var EBCDIC encoding.Encoding - -func init() { - cm := &Charmap{ - ReplacementChar: '\x3f', - Map: map[byte]rune{ - // 0x00-0x03 match - 0x04: RuneError, - 0x05: '\t', - 0x06: RuneError, - 0x07: '\x7f', - 0x08: RuneError, - 0x09: RuneError, - 0x0a: RuneError, - // 0x0b-0x13 match - 0x14: RuneError, - 0x15: '\x85', // Not in any ISO code - 0x16: '\x08', - 0x17: RuneError, - // 0x18-0x19 match - 0x1a: RuneError, - 0x1b: RuneError, - // 0x1c-0x1f match - 0x20: RuneError, - 0x21: RuneError, - 0x22: RuneError, - 0x23: RuneError, - 0x24: RuneError, - 0x25: '\n', - 0x26: '\x17', - 0x27: '\x1b', - 0x28: RuneError, - 0x29: RuneError, - 0x2a: RuneError, - 0x2b: RuneError, - 0x2c: RuneError, - 0x2d: '\x05', - 0x2e: '\x06', - 0x2f: '\x07', - 0x30: RuneError, - 0x31: RuneError, - 0x32: '\x16', - 0x33: RuneError, - 0x34: RuneError, - 0x35: RuneError, - 0x36: RuneError, - 0x37: '\x04', - 0x38: RuneError, - 0x39: RuneError, - 0x3a: RuneError, - 0x3b: RuneError, - 0x3c: '\x14', - 0x3d: '\x15', - 0x3e: RuneError, - 0x3f: '\x1a', // also replacement char - 0x40: ' ', - 0x41: '\xa0', - 0x42: RuneError, - 0x43: RuneError, - 0x44: RuneError, - 0x45: RuneError, - 0x46: RuneError, - 0x47: RuneError, - 0x48: RuneError, - 0x49: RuneError, - 0x4a: RuneError, - 0x4b: '.', - 0x4c: '<', - 0x4d: '(', - 0x4e: '+', - 0x4f: '|', - 0x50: '&', - 0x51: RuneError, - 0x52: RuneError, - 0x53: RuneError, - 0x54: RuneError, - 0x55: RuneError, - 0x56: RuneError, - 0x57: RuneError, - 0x58: RuneError, - 0x59: RuneError, - 0x5a: '!', - 0x5b: '$', - 0x5c: '*', - 0x5d: ')', - 0x5e: ';', - 0x5f: '¬', - 0x60: '-', - 0x61: '/', - 0x62: RuneError, - 0x63: RuneError, - 0x64: RuneError, - 0x65: RuneError, - 0x66: RuneError, - 0x67: RuneError, - 0x68: RuneError, - 0x69: RuneError, - 0x6a: '¦', - 0x6b: ',', - 0x6c: '%', - 0x6d: '_', - 0x6e: '>', - 0x6f: '?', - 0x70: RuneError, - 0x71: RuneError, - 0x72: RuneError, - 0x73: RuneError, - 0x74: RuneError, - 0x75: RuneError, - 0x76: RuneError, - 0x77: RuneError, - 0x78: RuneError, - 0x79: '`', - 0x7a: ':', - 0x7b: '#', - 0x7c: '@', - 0x7d: '\'', - 0x7e: '=', - 0x7f: '"', - 0x80: RuneError, - 0x81: 'a', - 0x82: 'b', - 0x83: 'c', - 0x84: 'd', - 0x85: 'e', - 0x86: 'f', - 0x87: 'g', - 0x88: 'h', - 0x89: 'i', - 0x8a: RuneError, - 0x8b: RuneError, - 0x8c: RuneError, - 0x8d: RuneError, - 0x8e: RuneError, - 0x8f: '±', - 0x90: RuneError, - 0x91: 'j', - 0x92: 'k', - 0x93: 'l', - 0x94: 'm', - 0x95: 'n', - 0x96: 'o', - 0x97: 'p', - 0x98: 'q', - 0x99: 'r', - 0x9a: RuneError, - 0x9b: RuneError, - 0x9c: RuneError, - 0x9d: RuneError, - 0x9e: RuneError, - 0x9f: RuneError, - 0xa0: RuneError, - 0xa1: '~', - 0xa2: 's', - 0xa3: 't', - 0xa4: 'u', - 0xa5: 'v', - 0xa6: 'w', - 0xa7: 'x', - 0xa8: 'y', - 0xa9: 'z', - 0xaa: RuneError, - 0xab: RuneError, - 0xac: RuneError, - 0xad: RuneError, - 0xae: RuneError, - 0xaf: RuneError, - 0xb0: '^', - 0xb1: RuneError, - 0xb2: RuneError, - 0xb3: RuneError, - 0xb4: RuneError, - 0xb5: RuneError, - 0xb6: RuneError, - 0xb7: RuneError, - 0xb8: RuneError, - 0xb9: RuneError, - 0xba: '[', - 0xbb: ']', - 0xbc: RuneError, - 0xbd: RuneError, - 0xbe: RuneError, - 0xbf: RuneError, - 0xc0: '{', - 0xc1: 'A', - 0xc2: 'B', - 0xc3: 'C', - 0xc4: 'D', - 0xc5: 'E', - 0xc6: 'F', - 0xc7: 'G', - 0xc8: 'H', - 0xc9: 'I', - 0xca: '\xad', // NB: soft hyphen - 0xcb: RuneError, - 0xcc: RuneError, - 0xcd: RuneError, - 0xce: RuneError, - 0xcf: RuneError, - 0xd0: '}', - 0xd1: 'J', - 0xd2: 'K', - 0xd3: 'L', - 0xd4: 'M', - 0xd5: 'N', - 0xd6: 'O', - 0xd7: 'P', - 0xd8: 'Q', - 0xd9: 'R', - 0xda: RuneError, - 0xdb: RuneError, - 0xdc: RuneError, - 0xdd: RuneError, - 0xde: RuneError, - 0xdf: RuneError, - 0xe0: '\\', - 0xe1: '\u2007', // Non-breaking space - 0xe2: 'S', - 0xe3: 'T', - 0xe4: 'U', - 0xe5: 'V', - 0xe6: 'W', - 0xe7: 'X', - 0xe8: 'Y', - 0xe9: 'Z', - 0xea: RuneError, - 0xeb: RuneError, - 0xec: RuneError, - 0xed: RuneError, - 0xee: RuneError, - 0xef: RuneError, - 0xf0: '0', - 0xf1: '1', - 0xf2: '2', - 0xf3: '3', - 0xf4: '4', - 0xf5: '5', - 0xf6: '6', - 0xf7: '7', - 0xf8: '8', - 0xf9: '9', - 0xfa: RuneError, - 0xfb: RuneError, - 0xfc: RuneError, - 0xfd: RuneError, - 0xfe: RuneError, - 0xff: RuneError, - }} - cm.Init() - EBCDIC = cm -} diff --git a/vendor/github.com/gdamore/encoding/latin1.go b/vendor/github.com/gdamore/encoding/latin1.go deleted file mode 100644 index 226bf01..0000000 --- a/vendor/github.com/gdamore/encoding/latin1.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 Garrett D'Amore -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use file except in compliance with the License. -// You may obtain a copy of the license at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package encoding - -import ( - "golang.org/x/text/encoding" -) - -// ISO8859_1 represents the 8-bit ISO8859-1 scheme. It decodes directly to -// UTF-8 without change, as all ISO8859-1 values are legal UTF-8. -// Unicode values less than 256 (i.e. 8 bits) map 1:1 with 8859-1. -// It encodes runes outside of that to 0x1A, the ASCII substitution character. -var ISO8859_1 encoding.Encoding - -func init() { - cm := &Charmap{} - cm.Init() - - // 8859-1 is the 8-bit identity map for Unicode. - ISO8859_1 = cm -} diff --git a/vendor/github.com/gdamore/encoding/latin5.go b/vendor/github.com/gdamore/encoding/latin5.go deleted file mode 100644 index c75ecf2..0000000 --- a/vendor/github.com/gdamore/encoding/latin5.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 Garrett D'Amore -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use file except in compliance with the License. -// You may obtain a copy of the license at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package encoding - -import ( - "golang.org/x/text/encoding" -) - -// ISO8859_9 represents the 8-bit ISO8859-9 scheme. -var ISO8859_9 encoding.Encoding - -func init() { - cm := &Charmap{Map: map[byte]rune{ - 0xD0: 'Ğ', - 0xDD: 'İ', - 0xDE: 'Ş', - 0xF0: 'ğ', - 0xFD: 'ı', - 0xFE: 'ş', - }} - cm.Init() - ISO8859_9 = cm -} diff --git a/vendor/github.com/gdamore/encoding/utf8.go b/vendor/github.com/gdamore/encoding/utf8.go deleted file mode 100644 index 2d59f4b..0000000 --- a/vendor/github.com/gdamore/encoding/utf8.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 Garrett D'Amore -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use file except in compliance with the License. -// You may obtain a copy of the license at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package encoding - -import ( - "golang.org/x/text/encoding" -) - -type validUtf8 struct{} - -// UTF8 is an encoding for UTF-8. All it does is verify that the UTF-8 -// in is valid. The main reason for its existence is that it will detect -// and report ErrSrcShort or ErrDstShort, whereas the Nop encoding just -// passes every byte, blithely. -var UTF8 encoding.Encoding = validUtf8{} - -func (validUtf8) NewDecoder() *encoding.Decoder { - return &encoding.Decoder{Transformer: encoding.UTF8Validator} -} - -func (validUtf8) NewEncoder() *encoding.Encoder { - return &encoding.Encoder{Transformer: encoding.UTF8Validator} -} diff --git a/vendor/github.com/kyokomi/emoji/.gitignore b/vendor/github.com/kyokomi/emoji/.gitignore deleted file mode 100644 index 8cd9b91..0000000 --- a/vendor/github.com/kyokomi/emoji/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.idea -emoji.iml diff --git a/vendor/github.com/kyokomi/emoji/LICENSE b/vendor/github.com/kyokomi/emoji/LICENSE deleted file mode 100644 index 239874e..0000000 --- a/vendor/github.com/kyokomi/emoji/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 kyokomi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/kyokomi/emoji/README.md b/vendor/github.com/kyokomi/emoji/README.md deleted file mode 100644 index ec588ee..0000000 --- a/vendor/github.com/kyokomi/emoji/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# Emoji -Emoji is a simple golang package. - -[![wercker status](https://app.wercker.com/status/7bef60de2c6d3e0e6c13d56b2393c5d8/s/master "wercker status")](https://app.wercker.com/project/byKey/7bef60de2c6d3e0e6c13d56b2393c5d8) -[![Coverage Status](https://coveralls.io/repos/kyokomi/emoji/badge.png?branch=master)](https://coveralls.io/r/kyokomi/emoji?branch=master) -[![GoDoc](https://godoc.org/github.com/kyokomi/emoji?status.svg)](https://godoc.org/github.com/kyokomi/emoji) - -Get it: - -``` -go get gopkg.in/kyokomi/emoji.v1 -``` - -Import it: - -``` -import ( - "gopkg.in/kyokomi/emoji.v1" -) -``` - -## Usage - -```go -package main - -import ( - "fmt" - - "github.com/kyokomi/emoji" -) - -func main() { - fmt.Println("Hello World Emoji!") - - emoji.Println(":beer: Beer!!!") - - pizzaMessage := emoji.Sprint("I like a :pizza: and :sushi:!!") - fmt.Println(pizzaMessage) -} -``` - -## Demo - -![demo](screen/image.png) - -## Reference - -- [GitHub EMOJI CHEAT SHEET](http://www.emoji-cheat-sheet.com/) - -## License - -[MIT](https://github.com/kyokomi/emoji/blob/master/LICENSE) diff --git a/vendor/github.com/kyokomi/emoji/emoji.go b/vendor/github.com/kyokomi/emoji/emoji.go deleted file mode 100644 index 1b33667..0000000 --- a/vendor/github.com/kyokomi/emoji/emoji.go +++ /dev/null @@ -1,153 +0,0 @@ -// Package emoji terminal output. -package emoji - -import ( - "bytes" - "errors" - "fmt" - "io" - "regexp" - "unicode" -) - -//go:generate generateEmojiCodeMap -pkg emoji - -// Replace Padding character for emoji. -const ( - ReplacePadding = " " -) - -// CodeMap gets the underlying map of emoji. -func CodeMap() map[string]string { - return emojiCodeMap -} - -// regular expression that matches :flag-[countrycode]: -var flagRegexp = regexp.MustCompile(":flag-([a-z]{2}):") - -func emojize(x string) string { - str, ok := emojiCodeMap[x] - if ok { - return str + ReplacePadding - } - if match := flagRegexp.FindStringSubmatch(x); len(match) == 2 { - return regionalIndicator(match[1][0]) + regionalIndicator(match[1][1]) - } - return x -} - -// regionalIndicator maps a lowercase letter to a unicode regional indicator -func regionalIndicator(i byte) string { - return string('\U0001F1E6' + rune(i) - 'a') -} - -func replaseEmoji(input *bytes.Buffer) string { - emoji := bytes.NewBufferString(":") - for { - i, _, err := input.ReadRune() - if err != nil { - // not replase - return emoji.String() - } - - if i == ':' && emoji.Len() == 1 { - return emoji.String() + replaseEmoji(input) - } - - emoji.WriteRune(i) - switch { - case unicode.IsSpace(i): - return emoji.String() - case i == ':': - return emojize(emoji.String()) - } - } -} - -func compile(x string) string { - if x == "" { - return "" - } - - input := bytes.NewBufferString(x) - output := bytes.NewBufferString("") - - for { - i, _, err := input.ReadRune() - if err != nil { - break - } - switch i { - default: - output.WriteRune(i) - case ':': - output.WriteString(replaseEmoji(input)) - } - } - return output.String() -} - -func compileValues(a *[]interface{}) { - for i, x := range *a { - if str, ok := x.(string); ok { - (*a)[i] = compile(str) - } - } -} - -// Print is fmt.Print which supports emoji -func Print(a ...interface{}) (int, error) { - compileValues(&a) - return fmt.Print(a...) -} - -// Println is fmt.Println which supports emoji -func Println(a ...interface{}) (int, error) { - compileValues(&a) - return fmt.Println(a...) -} - -// Printf is fmt.Printf which supports emoji -func Printf(format string, a ...interface{}) (int, error) { - format = compile(format) - compileValues(&a) - return fmt.Printf(format, a...) -} - -// Fprint is fmt.Fprint which supports emoji -func Fprint(w io.Writer, a ...interface{}) (int, error) { - compileValues(&a) - return fmt.Fprint(w, a...) -} - -// Fprintln is fmt.Fprintln which supports emoji -func Fprintln(w io.Writer, a ...interface{}) (int, error) { - compileValues(&a) - return fmt.Fprintln(w, a...) -} - -// Fprintf is fmt.Fprintf which supports emoji -func Fprintf(w io.Writer, format string, a ...interface{}) (int, error) { - format = compile(format) - compileValues(&a) - return fmt.Fprintf(w, format, a...) -} - -// Sprint is fmt.Sprint which supports emoji -func Sprint(a ...interface{}) string { - compileValues(&a) - return fmt.Sprint(a...) -} - -// Sprintf is fmt.Sprintf which supports emoji -func Sprintf(format string, a ...interface{}) string { - format = compile(format) - compileValues(&a) - return fmt.Sprintf(format, a...) -} - -// Errorf is fmt.Errorf which supports emoji -func Errorf(format string, a ...interface{}) error { - compileValues(&a) - return errors.New(Sprintf(format, a...)) -} diff --git a/vendor/github.com/kyokomi/emoji/emoji_codemap.go b/vendor/github.com/kyokomi/emoji/emoji_codemap.go deleted file mode 100644 index 1f93284..0000000 --- a/vendor/github.com/kyokomi/emoji/emoji_codemap.go +++ /dev/null @@ -1,1517 +0,0 @@ -package emoji - -// NOTE: THIS FILE WAS PRODUCED BY THE -// EMOJICODEMAP CODE GENERATION TOOL (github.com/kyokomi/generateEmojiCodeMap) -// DO NOT EDIT - -// Mapping from character to concrete escape code. -var emojiCodeMap = map[string]string{ - ":+1:": "\U0001f44d", - ":-1:": "\U0001f44e", - ":100:": "\U0001f4af", - ":1234:": "\U0001f522", - ":1st_place_medal:": "\U0001f947", - ":2nd_place_medal:": "\U0001f948", - ":3rd_place_medal:": "\U0001f949", - ":8ball:": "\U0001f3b1", - ":a:": "\U0001f170\ufe0f", - ":ab:": "\U0001f18e", - ":abc:": "\U0001f524", - ":abcd:": "\U0001f521", - ":accept:": "\U0001f251", - ":aerial_tramway:": "\U0001f6a1", - ":afghanistan:": "\U0001f1e6\U0001f1eb", - ":airplane:": "\u2708\ufe0f", - ":aland_islands:": "\U0001f1e6\U0001f1fd", - ":alarm_clock:": "\u23f0", - ":albania:": "\U0001f1e6\U0001f1f1", - ":alembic:": "\u2697\ufe0f", - ":algeria:": "\U0001f1e9\U0001f1ff", - ":alien:": "\U0001f47d", - ":ambulance:": "\U0001f691", - ":american_samoa:": "\U0001f1e6\U0001f1f8", - ":amphora:": "\U0001f3fa", - ":anchor:": "\u2693\ufe0f", - ":andorra:": "\U0001f1e6\U0001f1e9", - ":angel:": "\U0001f47c", - ":anger:": "\U0001f4a2", - ":angola:": "\U0001f1e6\U0001f1f4", - ":angry:": "\U0001f620", - ":anguilla:": "\U0001f1e6\U0001f1ee", - ":anguished:": "\U0001f627", - ":ant:": "\U0001f41c", - ":antarctica:": "\U0001f1e6\U0001f1f6", - ":antigua_barbuda:": "\U0001f1e6\U0001f1ec", - ":apple:": "\U0001f34e", - ":aquarius:": "\u2652\ufe0f", - ":argentina:": "\U0001f1e6\U0001f1f7", - ":aries:": "\u2648\ufe0f", - ":armenia:": "\U0001f1e6\U0001f1f2", - ":arrow_backward:": "\u25c0\ufe0f", - ":arrow_double_down:": "\u23ec", - ":arrow_double_up:": "\u23eb", - ":arrow_down:": "\u2b07\ufe0f", - ":arrow_down_small:": "\U0001f53d", - ":arrow_forward:": "\u25b6\ufe0f", - ":arrow_heading_down:": "\u2935\ufe0f", - ":arrow_heading_up:": "\u2934\ufe0f", - ":arrow_left:": "\u2b05\ufe0f", - ":arrow_lower_left:": "\u2199\ufe0f", - ":arrow_lower_right:": "\u2198\ufe0f", - ":arrow_right:": "\u27a1\ufe0f", - ":arrow_right_hook:": "\u21aa\ufe0f", - ":arrow_up:": "\u2b06\ufe0f", - ":arrow_up_down:": "\u2195\ufe0f", - ":arrow_up_small:": "\U0001f53c", - ":arrow_upper_left:": "\u2196\ufe0f", - ":arrow_upper_right:": "\u2197\ufe0f", - ":arrows_clockwise:": "\U0001f503", - ":arrows_counterclockwise:": "\U0001f504", - ":art:": "\U0001f3a8", - ":articulated_lorry:": "\U0001f69b", - ":artificial_satellite:": "\U0001f6f0", - ":aruba:": "\U0001f1e6\U0001f1fc", - ":asterisk:": "*\ufe0f\u20e3", - ":astonished:": "\U0001f632", - ":athletic_shoe:": "\U0001f45f", - ":atm:": "\U0001f3e7", - ":atom_symbol:": "\u269b\ufe0f", - ":australia:": "\U0001f1e6\U0001f1fa", - ":austria:": "\U0001f1e6\U0001f1f9", - ":avocado:": "\U0001f951", - ":azerbaijan:": "\U0001f1e6\U0001f1ff", - ":b:": "\U0001f171\ufe0f", - ":baby:": "\U0001f476", - ":baby_bottle:": "\U0001f37c", - ":baby_chick:": "\U0001f424", - ":baby_symbol:": "\U0001f6bc", - ":back:": "\U0001f519", - ":bacon:": "\U0001f953", - ":badminton:": "\U0001f3f8", - ":baggage_claim:": "\U0001f6c4", - ":baguette_bread:": "\U0001f956", - ":bahamas:": "\U0001f1e7\U0001f1f8", - ":bahrain:": "\U0001f1e7\U0001f1ed", - ":balance_scale:": "\u2696\ufe0f", - ":balloon:": "\U0001f388", - ":ballot_box:": "\U0001f5f3", - ":ballot_box_with_check:": "\u2611\ufe0f", - ":bamboo:": "\U0001f38d", - ":banana:": "\U0001f34c", - ":bangbang:": "\u203c\ufe0f", - ":bangladesh:": "\U0001f1e7\U0001f1e9", - ":bank:": "\U0001f3e6", - ":bar_chart:": "\U0001f4ca", - ":barbados:": "\U0001f1e7\U0001f1e7", - ":barber:": "\U0001f488", - ":baseball:": "\u26be\ufe0f", - ":basecamp:": "", - ":basecampy:": "", - ":basketball:": "\U0001f3c0", - ":basketball_man:": "\u26f9", - ":basketball_woman:": "\u26f9\ufe0f\u200d\u2640\ufe0f", - ":bat:": "\U0001f987", - ":bath:": "\U0001f6c0", - ":bathtub:": "\U0001f6c1", - ":battery:": "\U0001f50b", - ":beach_umbrella:": "\U0001f3d6", - ":bear:": "\U0001f43b", - ":bed:": "\U0001f6cf", - ":bee:": "\U0001f41d", - ":beer:": "\U0001f37a", - ":beers:": "\U0001f37b", - ":beetle:": "\U0001f41e", - ":beginner:": "\U0001f530", - ":belarus:": "\U0001f1e7\U0001f1fe", - ":belgium:": "\U0001f1e7\U0001f1ea", - ":belize:": "\U0001f1e7\U0001f1ff", - ":bell:": "\U0001f514", - ":bellhop_bell:": "\U0001f6ce", - ":benin:": "\U0001f1e7\U0001f1ef", - ":bento:": "\U0001f371", - ":bermuda:": "\U0001f1e7\U0001f1f2", - ":bhutan:": "\U0001f1e7\U0001f1f9", - ":bicyclist:": "\U0001f6b4", - ":bike:": "\U0001f6b2", - ":biking_man:": "\U0001f6b4", - ":biking_woman:": "\U0001f6b4\u200d\u2640", - ":bikini:": "\U0001f459", - ":biohazard:": "\u2623\ufe0f", - ":bird:": "\U0001f426", - ":birthday:": "\U0001f382", - ":black_circle:": "\u26ab\ufe0f", - ":black_flag:": "\U0001f3f4", - ":black_heart:": "\U0001f5a4", - ":black_joker:": "\U0001f0cf", - ":black_large_square:": "\u2b1b\ufe0f", - ":black_medium_small_square:": "\u25fe\ufe0f", - ":black_medium_square:": "\u25fc\ufe0f", - ":black_nib:": "\u2712\ufe0f", - ":black_small_square:": "\u25aa\ufe0f", - ":black_square_button:": "\U0001f532", - ":blonde_man:": "\U0001f471", - ":blonde_woman:": "\U0001f471\u200d\u2640", - ":blossom:": "\U0001f33c", - ":blowfish:": "\U0001f421", - ":blue_book:": "\U0001f4d8", - ":blue_car:": "\U0001f699", - ":blue_heart:": "\U0001f499", - ":blush:": "\U0001f60a", - ":boar:": "\U0001f417", - ":boat:": "\u26f5\ufe0f", - ":bolivia:": "\U0001f1e7\U0001f1f4", - ":bomb:": "\U0001f4a3", - ":book:": "\U0001f4d6", - ":bookmark:": "\U0001f516", - ":bookmark_tabs:": "\U0001f4d1", - ":books:": "\U0001f4da", - ":boom:": "\U0001f4a5", - ":boot:": "\U0001f462", - ":bosnia_herzegovina:": "\U0001f1e7\U0001f1e6", - ":botswana:": "\U0001f1e7\U0001f1fc", - ":bouquet:": "\U0001f490", - ":bow:": "\U0001f647", - ":bow_and_arrow:": "\U0001f3f9", - ":bowing_man:": "\U0001f647", - ":bowing_woman:": "\U0001f647\u200d\u2640", - ":bowling:": "\U0001f3b3", - ":bowtie:": "", - ":boxing_glove:": "\U0001f94a", - ":boy:": "\U0001f466", - ":brazil:": "\U0001f1e7\U0001f1f7", - ":bread:": "\U0001f35e", - ":bride_with_veil:": "\U0001f470", - ":bridge_at_night:": "\U0001f309", - ":briefcase:": "\U0001f4bc", - ":british_indian_ocean_territory:": "\U0001f1ee\U0001f1f4", - ":british_virgin_islands:": "\U0001f1fb\U0001f1ec", - ":broken_heart:": "\U0001f494", - ":brunei:": "\U0001f1e7\U0001f1f3", - ":bug:": "\U0001f41b", - ":building_construction:": "\U0001f3d7", - ":bulb:": "\U0001f4a1", - ":bulgaria:": "\U0001f1e7\U0001f1ec", - ":bullettrain_front:": "\U0001f685", - ":bullettrain_side:": "\U0001f684", - ":burkina_faso:": "\U0001f1e7\U0001f1eb", - ":burrito:": "\U0001f32f", - ":burundi:": "\U0001f1e7\U0001f1ee", - ":bus:": "\U0001f68c", - ":business_suit_levitating:": "\U0001f574", - ":busstop:": "\U0001f68f", - ":bust_in_silhouette:": "\U0001f464", - ":busts_in_silhouette:": "\U0001f465", - ":butterfly:": "\U0001f98b", - ":cactus:": "\U0001f335", - ":cake:": "\U0001f370", - ":calendar:": "\U0001f4c6", - ":call_me_hand:": "\U0001f919", - ":calling:": "\U0001f4f2", - ":cambodia:": "\U0001f1f0\U0001f1ed", - ":camel:": "\U0001f42b", - ":camera:": "\U0001f4f7", - ":camera_flash:": "\U0001f4f8", - ":cameroon:": "\U0001f1e8\U0001f1f2", - ":camping:": "\U0001f3d5", - ":canada:": "\U0001f1e8\U0001f1e6", - ":canary_islands:": "\U0001f1ee\U0001f1e8", - ":cancer:": "\u264b\ufe0f", - ":candle:": "\U0001f56f", - ":candy:": "\U0001f36c", - ":canoe:": "\U0001f6f6", - ":cape_verde:": "\U0001f1e8\U0001f1fb", - ":capital_abcd:": "\U0001f520", - ":capricorn:": "\u2651\ufe0f", - ":car:": "\U0001f697", - ":card_file_box:": "\U0001f5c3", - ":card_index:": "\U0001f4c7", - ":card_index_dividers:": "\U0001f5c2", - ":caribbean_netherlands:": "\U0001f1e7\U0001f1f6", - ":carousel_horse:": "\U0001f3a0", - ":carrot:": "\U0001f955", - ":cat:": "\U0001f431", - ":cat2:": "\U0001f408", - ":cayman_islands:": "\U0001f1f0\U0001f1fe", - ":cd:": "\U0001f4bf", - ":central_african_republic:": "\U0001f1e8\U0001f1eb", - ":chad:": "\U0001f1f9\U0001f1e9", - ":chains:": "\u26d3", - ":champagne:": "\U0001f37e", - ":chart:": "\U0001f4b9", - ":chart_with_downwards_trend:": "\U0001f4c9", - ":chart_with_upwards_trend:": "\U0001f4c8", - ":checkered_flag:": "\U0001f3c1", - ":cheese:": "\U0001f9c0", - ":cherries:": "\U0001f352", - ":cherry_blossom:": "\U0001f338", - ":chestnut:": "\U0001f330", - ":chicken:": "\U0001f414", - ":children_crossing:": "\U0001f6b8", - ":chile:": "\U0001f1e8\U0001f1f1", - ":chipmunk:": "\U0001f43f", - ":chocolate_bar:": "\U0001f36b", - ":christmas_island:": "\U0001f1e8\U0001f1fd", - ":christmas_tree:": "\U0001f384", - ":church:": "\u26ea\ufe0f", - ":cinema:": "\U0001f3a6", - ":circus_tent:": "\U0001f3aa", - ":city_sunrise:": "\U0001f307", - ":city_sunset:": "\U0001f306", - ":cityscape:": "\U0001f3d9", - ":cl:": "\U0001f191", - ":clamp:": "\U0001f5dc", - ":clap:": "\U0001f44f", - ":clapper:": "\U0001f3ac", - ":classical_building:": "\U0001f3db", - ":clinking_glasses:": "\U0001f942", - ":clipboard:": "\U0001f4cb", - ":clock1:": "\U0001f550", - ":clock10:": "\U0001f559", - ":clock1030:": "\U0001f565", - ":clock11:": "\U0001f55a", - ":clock1130:": "\U0001f566", - ":clock12:": "\U0001f55b", - ":clock1230:": "\U0001f567", - ":clock130:": "\U0001f55c", - ":clock2:": "\U0001f551", - ":clock230:": "\U0001f55d", - ":clock3:": "\U0001f552", - ":clock330:": "\U0001f55e", - ":clock4:": "\U0001f553", - ":clock430:": "\U0001f55f", - ":clock5:": "\U0001f554", - ":clock530:": "\U0001f560", - ":clock6:": "\U0001f555", - ":clock630:": "\U0001f561", - ":clock7:": "\U0001f556", - ":clock730:": "\U0001f562", - ":clock8:": "\U0001f557", - ":clock830:": "\U0001f563", - ":clock9:": "\U0001f558", - ":clock930:": "\U0001f564", - ":closed_book:": "\U0001f4d5", - ":closed_lock_with_key:": "\U0001f510", - ":closed_umbrella:": "\U0001f302", - ":cloud:": "\u2601\ufe0f", - ":cloud_with_lightning:": "\U0001f329", - ":cloud_with_lightning_and_rain:": "\u26c8", - ":cloud_with_rain:": "\U0001f327", - ":cloud_with_snow:": "\U0001f328", - ":clown_face:": "\U0001f921", - ":clubs:": "\u2663\ufe0f", - ":cn:": "\U0001f1e8\U0001f1f3", - ":cocktail:": "\U0001f378", - ":cocos_islands:": "\U0001f1e8\U0001f1e8", - ":coffee:": "\u2615\ufe0f", - ":coffin:": "\u26b0\ufe0f", - ":cold_sweat:": "\U0001f630", - ":collision:": "\U0001f4a5", - ":colombia:": "\U0001f1e8\U0001f1f4", - ":comet:": "\u2604", - ":comoros:": "\U0001f1f0\U0001f1f2", - ":computer:": "\U0001f4bb", - ":computer_mouse:": "\U0001f5b1", - ":confetti_ball:": "\U0001f38a", - ":confounded:": "\U0001f616", - ":confused:": "\U0001f615", - ":congo_brazzaville:": "\U0001f1e8\U0001f1ec", - ":congo_kinshasa:": "\U0001f1e8\U0001f1e9", - ":congratulations:": "\u3297\ufe0f", - ":construction:": "\U0001f6a7", - ":construction_worker:": "\U0001f477", - ":construction_worker_man:": "\U0001f477", - ":construction_worker_woman:": "\U0001f477\u200d\u2640", - ":control_knobs:": "\U0001f39b", - ":convenience_store:": "\U0001f3ea", - ":cook_islands:": "\U0001f1e8\U0001f1f0", - ":cookie:": "\U0001f36a", - ":cool:": "\U0001f192", - ":cop:": "\U0001f46e", - ":copyright:": "\u00a9\ufe0f", - ":corn:": "\U0001f33d", - ":costa_rica:": "\U0001f1e8\U0001f1f7", - ":cote_divoire:": "\U0001f1e8\U0001f1ee", - ":couch_and_lamp:": "\U0001f6cb", - ":couple:": "\U0001f46b", - ":couple_with_heart:": "\U0001f491", - ":couple_with_heart_man_man:": "\U0001f468\u200d\u2764\ufe0f\u200d\U0001f468", - ":couple_with_heart_woman_man:": "\U0001f491", - ":couple_with_heart_woman_woman:": "\U0001f469\u200d\u2764\ufe0f\u200d\U0001f469", - ":couplekiss_man_man:": "\U0001f468\u200d\u2764\ufe0f\u200d\U0001f48b\u200d\U0001f468", - ":couplekiss_man_woman:": "\U0001f48f", - ":couplekiss_woman_woman:": "\U0001f469\u200d\u2764\ufe0f\u200d\U0001f48b\u200d\U0001f469", - ":cow:": "\U0001f42e", - ":cow2:": "\U0001f404", - ":cowboy_hat_face:": "\U0001f920", - ":crab:": "\U0001f980", - ":crayon:": "\U0001f58d", - ":credit_card:": "\U0001f4b3", - ":crescent_moon:": "\U0001f319", - ":cricket:": "\U0001f3cf", - ":croatia:": "\U0001f1ed\U0001f1f7", - ":crocodile:": "\U0001f40a", - ":croissant:": "\U0001f950", - ":crossed_fingers:": "\U0001f91e", - ":crossed_flags:": "\U0001f38c", - ":crossed_swords:": "\u2694\ufe0f", - ":crown:": "\U0001f451", - ":cry:": "\U0001f622", - ":crying_cat_face:": "\U0001f63f", - ":crystal_ball:": "\U0001f52e", - ":cuba:": "\U0001f1e8\U0001f1fa", - ":cucumber:": "\U0001f952", - ":cupid:": "\U0001f498", - ":curacao:": "\U0001f1e8\U0001f1fc", - ":curly_loop:": "\u27b0", - ":currency_exchange:": "\U0001f4b1", - ":curry:": "\U0001f35b", - ":custard:": "\U0001f36e", - ":customs:": "\U0001f6c3", - ":cyclone:": "\U0001f300", - ":cyprus:": "\U0001f1e8\U0001f1fe", - ":czech_republic:": "\U0001f1e8\U0001f1ff", - ":dagger:": "\U0001f5e1", - ":dancer:": "\U0001f483", - ":dancers:": "\U0001f46f", - ":dancing_men:": "\U0001f46f\u200d\u2642", - ":dancing_women:": "\U0001f46f", - ":dango:": "\U0001f361", - ":dark_sunglasses:": "\U0001f576", - ":dart:": "\U0001f3af", - ":dash:": "\U0001f4a8", - ":date:": "\U0001f4c5", - ":de:": "\U0001f1e9\U0001f1ea", - ":deciduous_tree:": "\U0001f333", - ":deer:": "\U0001f98c", - ":denmark:": "\U0001f1e9\U0001f1f0", - ":department_store:": "\U0001f3ec", - ":derelict_house:": "\U0001f3da", - ":desert:": "\U0001f3dc", - ":desert_island:": "\U0001f3dd", - ":desktop_computer:": "\U0001f5a5", - ":detective:": "\U0001f575", - ":diamond_shape_with_a_dot_inside:": "\U0001f4a0", - ":diamonds:": "\u2666\ufe0f", - ":disappointed:": "\U0001f61e", - ":disappointed_relieved:": "\U0001f625", - ":dizzy:": "\U0001f4ab", - ":dizzy_face:": "\U0001f635", - ":djibouti:": "\U0001f1e9\U0001f1ef", - ":do_not_litter:": "\U0001f6af", - ":dog:": "\U0001f436", - ":dog2:": "\U0001f415", - ":dollar:": "\U0001f4b5", - ":dolls:": "\U0001f38e", - ":dolphin:": "\U0001f42c", - ":dominica:": "\U0001f1e9\U0001f1f2", - ":dominican_republic:": "\U0001f1e9\U0001f1f4", - ":door:": "\U0001f6aa", - ":doughnut:": "\U0001f369", - ":dove:": "\U0001f54a", - ":dragon:": "\U0001f409", - ":dragon_face:": "\U0001f432", - ":dress:": "\U0001f457", - ":dromedary_camel:": "\U0001f42a", - ":drooling_face:": "\U0001f924", - ":droplet:": "\U0001f4a7", - ":drum:": "\U0001f941", - ":duck:": "\U0001f986", - ":dvd:": "\U0001f4c0", - ":e-mail:": "\U0001f4e7", - ":eagle:": "\U0001f985", - ":ear:": "\U0001f442", - ":ear_of_rice:": "\U0001f33e", - ":earth_africa:": "\U0001f30d", - ":earth_americas:": "\U0001f30e", - ":earth_asia:": "\U0001f30f", - ":ecuador:": "\U0001f1ea\U0001f1e8", - ":egg:": "\U0001f95a", - ":eggplant:": "\U0001f346", - ":egypt:": "\U0001f1ea\U0001f1ec", - ":eight:": "8\ufe0f\u20e3", - ":eight_pointed_black_star:": "\u2734\ufe0f", - ":eight_spoked_asterisk:": "\u2733\ufe0f", - ":el_salvador:": "\U0001f1f8\U0001f1fb", - ":electric_plug:": "\U0001f50c", - ":elephant:": "\U0001f418", - ":email:": "\u2709\ufe0f", - ":end:": "\U0001f51a", - ":envelope:": "\u2709\ufe0f", - ":envelope_with_arrow:": "\U0001f4e9", - ":equatorial_guinea:": "\U0001f1ec\U0001f1f6", - ":eritrea:": "\U0001f1ea\U0001f1f7", - ":es:": "\U0001f1ea\U0001f1f8", - ":estonia:": "\U0001f1ea\U0001f1ea", - ":ethiopia:": "\U0001f1ea\U0001f1f9", - ":eu:": "\U0001f1ea\U0001f1fa", - ":euro:": "\U0001f4b6", - ":european_castle:": "\U0001f3f0", - ":european_post_office:": "\U0001f3e4", - ":european_union:": "\U0001f1ea\U0001f1fa", - ":evergreen_tree:": "\U0001f332", - ":exclamation:": "\u2757\ufe0f", - ":expressionless:": "\U0001f611", - ":eye:": "\U0001f441", - ":eye_speech_bubble:": "\U0001f441\u200d\U0001f5e8", - ":eyeglasses:": "\U0001f453", - ":eyes:": "\U0001f440", - ":face_with_head_bandage:": "\U0001f915", - ":face_with_thermometer:": "\U0001f912", - ":facepunch:": "\U0001f44a", - ":factory:": "\U0001f3ed", - ":falkland_islands:": "\U0001f1eb\U0001f1f0", - ":fallen_leaf:": "\U0001f342", - ":family:": "\U0001f46a", - ":family_man_boy:": "\U0001f468\u200d\U0001f466", - ":family_man_boy_boy:": "\U0001f468\u200d\U0001f466\u200d\U0001f466", - ":family_man_girl:": "\U0001f468\u200d\U0001f467", - ":family_man_girl_boy:": "\U0001f468\u200d\U0001f467\u200d\U0001f466", - ":family_man_girl_girl:": "\U0001f468\u200d\U0001f467\u200d\U0001f467", - ":family_man_man_boy:": "\U0001f468\u200d\U0001f468\u200d\U0001f466", - ":family_man_man_boy_boy:": "\U0001f468\u200d\U0001f468\u200d\U0001f466\u200d\U0001f466", - ":family_man_man_girl:": "\U0001f468\u200d\U0001f468\u200d\U0001f467", - ":family_man_man_girl_boy:": "\U0001f468\u200d\U0001f468\u200d\U0001f467\u200d\U0001f466", - ":family_man_man_girl_girl:": "\U0001f468\u200d\U0001f468\u200d\U0001f467\u200d\U0001f467", - ":family_man_woman_boy:": "\U0001f46a", - ":family_man_woman_boy_boy:": "\U0001f468\u200d\U0001f469\u200d\U0001f466\u200d\U0001f466", - ":family_man_woman_girl:": "\U0001f468\u200d\U0001f469\u200d\U0001f467", - ":family_man_woman_girl_boy:": "\U0001f468\u200d\U0001f469\u200d\U0001f467\u200d\U0001f466", - ":family_man_woman_girl_girl:": "\U0001f468\u200d\U0001f469\u200d\U0001f467\u200d\U0001f467", - ":family_woman_boy:": "\U0001f469\u200d\U0001f466", - ":family_woman_boy_boy:": "\U0001f469\u200d\U0001f466\u200d\U0001f466", - ":family_woman_girl:": "\U0001f469\u200d\U0001f467", - ":family_woman_girl_boy:": "\U0001f469\u200d\U0001f467\u200d\U0001f466", - ":family_woman_girl_girl:": "\U0001f469\u200d\U0001f467\u200d\U0001f467", - ":family_woman_woman_boy:": "\U0001f469\u200d\U0001f469\u200d\U0001f466", - ":family_woman_woman_boy_boy:": "\U0001f469\u200d\U0001f469\u200d\U0001f466\u200d\U0001f466", - ":family_woman_woman_girl:": "\U0001f469\u200d\U0001f469\u200d\U0001f467", - ":family_woman_woman_girl_boy:": "\U0001f469\u200d\U0001f469\u200d\U0001f467\u200d\U0001f466", - ":family_woman_woman_girl_girl:": "\U0001f469\u200d\U0001f469\u200d\U0001f467\u200d\U0001f467", - ":faroe_islands:": "\U0001f1eb\U0001f1f4", - ":fast_forward:": "\u23e9", - ":fax:": "\U0001f4e0", - ":fearful:": "\U0001f628", - ":feelsgood:": "", - ":feet:": "\U0001f43e", - ":female_detective:": "\U0001f575\ufe0f\u200d\u2640\ufe0f", - ":ferris_wheel:": "\U0001f3a1", - ":ferry:": "\u26f4", - ":field_hockey:": "\U0001f3d1", - ":fiji:": "\U0001f1eb\U0001f1ef", - ":file_cabinet:": "\U0001f5c4", - ":file_folder:": "\U0001f4c1", - ":film_projector:": "\U0001f4fd", - ":film_strip:": "\U0001f39e", - ":finland:": "\U0001f1eb\U0001f1ee", - ":finnadie:": "", - ":fire:": "\U0001f525", - ":fire_engine:": "\U0001f692", - ":fireworks:": "\U0001f386", - ":first_quarter_moon:": "\U0001f313", - ":first_quarter_moon_with_face:": "\U0001f31b", - ":fish:": "\U0001f41f", - ":fish_cake:": "\U0001f365", - ":fishing_pole_and_fish:": "\U0001f3a3", - ":fist:": "\u270a", - ":fist_left:": "\U0001f91b", - ":fist_oncoming:": "\U0001f44a", - ":fist_raised:": "\u270a", - ":fist_right:": "\U0001f91c", - ":five:": "5\ufe0f\u20e3", - ":flags:": "\U0001f38f", - ":flashlight:": "\U0001f526", - ":fleur_de_lis:": "\u269c\ufe0f", - ":flight_arrival:": "\U0001f6ec", - ":flight_departure:": "\U0001f6eb", - ":flipper:": "\U0001f42c", - ":floppy_disk:": "\U0001f4be", - ":flower_playing_cards:": "\U0001f3b4", - ":flushed:": "\U0001f633", - ":fog:": "\U0001f32b", - ":foggy:": "\U0001f301", - ":football:": "\U0001f3c8", - ":footprints:": "\U0001f463", - ":fork_and_knife:": "\U0001f374", - ":fountain:": "\u26f2\ufe0f", - ":fountain_pen:": "\U0001f58b", - ":four:": "4\ufe0f\u20e3", - ":four_leaf_clover:": "\U0001f340", - ":fox_face:": "\U0001f98a", - ":fr:": "\U0001f1eb\U0001f1f7", - ":framed_picture:": "\U0001f5bc", - ":free:": "\U0001f193", - ":french_guiana:": "\U0001f1ec\U0001f1eb", - ":french_polynesia:": "\U0001f1f5\U0001f1eb", - ":french_southern_territories:": "\U0001f1f9\U0001f1eb", - ":fried_egg:": "\U0001f373", - ":fried_shrimp:": "\U0001f364", - ":fries:": "\U0001f35f", - ":frog:": "\U0001f438", - ":frowning:": "\U0001f626", - ":frowning_face:": "\u2639\ufe0f", - ":frowning_man:": "\U0001f64d\u200d\u2642", - ":frowning_woman:": "\U0001f64d", - ":fu:": "\U0001f595", - ":fuelpump:": "\u26fd\ufe0f", - ":full_moon:": "\U0001f315", - ":full_moon_with_face:": "\U0001f31d", - ":funeral_urn:": "\u26b1\ufe0f", - ":gabon:": "\U0001f1ec\U0001f1e6", - ":gambia:": "\U0001f1ec\U0001f1f2", - ":game_die:": "\U0001f3b2", - ":gb:": "\U0001f1ec\U0001f1e7", - ":gear:": "\u2699\ufe0f", - ":gem:": "\U0001f48e", - ":gemini:": "\u264a\ufe0f", - ":georgia:": "\U0001f1ec\U0001f1ea", - ":ghana:": "\U0001f1ec\U0001f1ed", - ":ghost:": "\U0001f47b", - ":gibraltar:": "\U0001f1ec\U0001f1ee", - ":gift:": "\U0001f381", - ":gift_heart:": "\U0001f49d", - ":girl:": "\U0001f467", - ":globe_with_meridians:": "\U0001f310", - ":goal_net:": "\U0001f945", - ":goat:": "\U0001f410", - ":goberserk:": "", - ":godmode:": "", - ":golf:": "\u26f3\ufe0f", - ":golfing_man:": "\U0001f3cc", - ":golfing_woman:": "\U0001f3cc\ufe0f\u200d\u2640\ufe0f", - ":gorilla:": "\U0001f98d", - ":grapes:": "\U0001f347", - ":greece:": "\U0001f1ec\U0001f1f7", - ":green_apple:": "\U0001f34f", - ":green_book:": "\U0001f4d7", - ":green_heart:": "\U0001f49a", - ":green_salad:": "\U0001f957", - ":greenland:": "\U0001f1ec\U0001f1f1", - ":grenada:": "\U0001f1ec\U0001f1e9", - ":grey_exclamation:": "\u2755", - ":grey_question:": "\u2754", - ":grimacing:": "\U0001f62c", - ":grin:": "\U0001f601", - ":grinning:": "\U0001f600", - ":guadeloupe:": "\U0001f1ec\U0001f1f5", - ":guam:": "\U0001f1ec\U0001f1fa", - ":guardsman:": "\U0001f482", - ":guardswoman:": "\U0001f482\u200d\u2640", - ":guatemala:": "\U0001f1ec\U0001f1f9", - ":guernsey:": "\U0001f1ec\U0001f1ec", - ":guinea:": "\U0001f1ec\U0001f1f3", - ":guinea_bissau:": "\U0001f1ec\U0001f1fc", - ":guitar:": "\U0001f3b8", - ":gun:": "\U0001f52b", - ":guyana:": "\U0001f1ec\U0001f1fe", - ":haircut:": "\U0001f487", - ":haircut_man:": "\U0001f487\u200d\u2642", - ":haircut_woman:": "\U0001f487", - ":haiti:": "\U0001f1ed\U0001f1f9", - ":hamburger:": "\U0001f354", - ":hammer:": "\U0001f528", - ":hammer_and_pick:": "\u2692", - ":hammer_and_wrench:": "\U0001f6e0", - ":hamster:": "\U0001f439", - ":hand:": "\u270b", - ":handbag:": "\U0001f45c", - ":handshake:": "\U0001f91d", - ":hankey:": "\U0001f4a9", - ":hash:": "#\ufe0f\u20e3", - ":hatched_chick:": "\U0001f425", - ":hatching_chick:": "\U0001f423", - ":headphones:": "\U0001f3a7", - ":hear_no_evil:": "\U0001f649", - ":heart:": "\u2764\ufe0f", - ":heart_decoration:": "\U0001f49f", - ":heart_eyes:": "\U0001f60d", - ":heart_eyes_cat:": "\U0001f63b", - ":heartbeat:": "\U0001f493", - ":heartpulse:": "\U0001f497", - ":hearts:": "\u2665\ufe0f", - ":heavy_check_mark:": "\u2714\ufe0f", - ":heavy_division_sign:": "\u2797", - ":heavy_dollar_sign:": "\U0001f4b2", - ":heavy_exclamation_mark:": "\u2757\ufe0f", - ":heavy_heart_exclamation:": "\u2763\ufe0f", - ":heavy_minus_sign:": "\u2796", - ":heavy_multiplication_x:": "\u2716\ufe0f", - ":heavy_plus_sign:": "\u2795", - ":helicopter:": "\U0001f681", - ":herb:": "\U0001f33f", - ":hibiscus:": "\U0001f33a", - ":high_brightness:": "\U0001f506", - ":high_heel:": "\U0001f460", - ":hocho:": "\U0001f52a", - ":hole:": "\U0001f573", - ":honduras:": "\U0001f1ed\U0001f1f3", - ":honey_pot:": "\U0001f36f", - ":honeybee:": "\U0001f41d", - ":hong_kong:": "\U0001f1ed\U0001f1f0", - ":horse:": "\U0001f434", - ":horse_racing:": "\U0001f3c7", - ":hospital:": "\U0001f3e5", - ":hot_pepper:": "\U0001f336", - ":hotdog:": "\U0001f32d", - ":hotel:": "\U0001f3e8", - ":hotsprings:": "\u2668\ufe0f", - ":hourglass:": "\u231b\ufe0f", - ":hourglass_flowing_sand:": "\u23f3", - ":house:": "\U0001f3e0", - ":house_with_garden:": "\U0001f3e1", - ":houses:": "\U0001f3d8", - ":hugs:": "\U0001f917", - ":hungary:": "\U0001f1ed\U0001f1fa", - ":hurtrealbad:": "", - ":hushed:": "\U0001f62f", - ":ice_cream:": "\U0001f368", - ":ice_hockey:": "\U0001f3d2", - ":ice_skate:": "\u26f8", - ":icecream:": "\U0001f366", - ":iceland:": "\U0001f1ee\U0001f1f8", - ":id:": "\U0001f194", - ":ideograph_advantage:": "\U0001f250", - ":imp:": "\U0001f47f", - ":inbox_tray:": "\U0001f4e5", - ":incoming_envelope:": "\U0001f4e8", - ":india:": "\U0001f1ee\U0001f1f3", - ":indonesia:": "\U0001f1ee\U0001f1e9", - ":information_desk_person:": "\U0001f481", - ":information_source:": "\u2139\ufe0f", - ":innocent:": "\U0001f607", - ":interrobang:": "\u2049\ufe0f", - ":iphone:": "\U0001f4f1", - ":iran:": "\U0001f1ee\U0001f1f7", - ":iraq:": "\U0001f1ee\U0001f1f6", - ":ireland:": "\U0001f1ee\U0001f1ea", - ":isle_of_man:": "\U0001f1ee\U0001f1f2", - ":israel:": "\U0001f1ee\U0001f1f1", - ":it:": "\U0001f1ee\U0001f1f9", - ":izakaya_lantern:": "\U0001f3ee", - ":jack_o_lantern:": "\U0001f383", - ":jamaica:": "\U0001f1ef\U0001f1f2", - ":japan:": "\U0001f5fe", - ":japanese_castle:": "\U0001f3ef", - ":japanese_goblin:": "\U0001f47a", - ":japanese_ogre:": "\U0001f479", - ":jeans:": "\U0001f456", - ":jersey:": "\U0001f1ef\U0001f1ea", - ":jordan:": "\U0001f1ef\U0001f1f4", - ":joy:": "\U0001f602", - ":joy_cat:": "\U0001f639", - ":joystick:": "\U0001f579", - ":jp:": "\U0001f1ef\U0001f1f5", - ":kaaba:": "\U0001f54b", - ":kazakhstan:": "\U0001f1f0\U0001f1ff", - ":kenya:": "\U0001f1f0\U0001f1ea", - ":key:": "\U0001f511", - ":keyboard:": "\u2328\ufe0f", - ":keycap_ten:": "\U0001f51f", - ":kick_scooter:": "\U0001f6f4", - ":kimono:": "\U0001f458", - ":kiribati:": "\U0001f1f0\U0001f1ee", - ":kiss:": "\U0001f48b", - ":kissing:": "\U0001f617", - ":kissing_cat:": "\U0001f63d", - ":kissing_closed_eyes:": "\U0001f61a", - ":kissing_heart:": "\U0001f618", - ":kissing_smiling_eyes:": "\U0001f619", - ":kiwi_fruit:": "\U0001f95d", - ":knife:": "\U0001f52a", - ":koala:": "\U0001f428", - ":koko:": "\U0001f201", - ":kosovo:": "\U0001f1fd\U0001f1f0", - ":kr:": "\U0001f1f0\U0001f1f7", - ":kuwait:": "\U0001f1f0\U0001f1fc", - ":kyrgyzstan:": "\U0001f1f0\U0001f1ec", - ":label:": "\U0001f3f7", - ":lantern:": "\U0001f3ee", - ":laos:": "\U0001f1f1\U0001f1e6", - ":large_blue_circle:": "\U0001f535", - ":large_blue_diamond:": "\U0001f537", - ":large_orange_diamond:": "\U0001f536", - ":last_quarter_moon:": "\U0001f317", - ":last_quarter_moon_with_face:": "\U0001f31c", - ":latin_cross:": "\u271d\ufe0f", - ":latvia:": "\U0001f1f1\U0001f1fb", - ":laughing:": "\U0001f606", - ":leaves:": "\U0001f343", - ":lebanon:": "\U0001f1f1\U0001f1e7", - ":ledger:": "\U0001f4d2", - ":left_luggage:": "\U0001f6c5", - ":left_right_arrow:": "\u2194\ufe0f", - ":leftwards_arrow_with_hook:": "\u21a9\ufe0f", - ":lemon:": "\U0001f34b", - ":leo:": "\u264c\ufe0f", - ":leopard:": "\U0001f406", - ":lesotho:": "\U0001f1f1\U0001f1f8", - ":level_slider:": "\U0001f39a", - ":liberia:": "\U0001f1f1\U0001f1f7", - ":libra:": "\u264e\ufe0f", - ":libya:": "\U0001f1f1\U0001f1fe", - ":liechtenstein:": "\U0001f1f1\U0001f1ee", - ":light_rail:": "\U0001f688", - ":link:": "\U0001f517", - ":lion:": "\U0001f981", - ":lips:": "\U0001f444", - ":lipstick:": "\U0001f484", - ":lithuania:": "\U0001f1f1\U0001f1f9", - ":lizard:": "\U0001f98e", - ":lock:": "\U0001f512", - ":lock_with_ink_pen:": "\U0001f50f", - ":lollipop:": "\U0001f36d", - ":loop:": "\u27bf", - ":loud_sound:": "\U0001f50a", - ":loudspeaker:": "\U0001f4e2", - ":love_hotel:": "\U0001f3e9", - ":love_letter:": "\U0001f48c", - ":low_brightness:": "\U0001f505", - ":luxembourg:": "\U0001f1f1\U0001f1fa", - ":lying_face:": "\U0001f925", - ":m:": "\u24c2\ufe0f", - ":macau:": "\U0001f1f2\U0001f1f4", - ":macedonia:": "\U0001f1f2\U0001f1f0", - ":madagascar:": "\U0001f1f2\U0001f1ec", - ":mag:": "\U0001f50d", - ":mag_right:": "\U0001f50e", - ":mahjong:": "\U0001f004\ufe0f", - ":mailbox:": "\U0001f4eb", - ":mailbox_closed:": "\U0001f4ea", - ":mailbox_with_mail:": "\U0001f4ec", - ":mailbox_with_no_mail:": "\U0001f4ed", - ":malawi:": "\U0001f1f2\U0001f1fc", - ":malaysia:": "\U0001f1f2\U0001f1fe", - ":maldives:": "\U0001f1f2\U0001f1fb", - ":male_detective:": "\U0001f575", - ":mali:": "\U0001f1f2\U0001f1f1", - ":malta:": "\U0001f1f2\U0001f1f9", - ":man:": "\U0001f468", - ":man_artist:": "\U0001f468\u200d\U0001f3a8", - ":man_astronaut:": "\U0001f468\u200d\U0001f680", - ":man_cartwheeling:": "\U0001f938\u200d\u2642", - ":man_cook:": "\U0001f468\u200d\U0001f373", - ":man_dancing:": "\U0001f57a", - ":man_facepalming:": "\U0001f926\u200d\u2642", - ":man_factory_worker:": "\U0001f468\u200d\U0001f3ed", - ":man_farmer:": "\U0001f468\u200d\U0001f33e", - ":man_firefighter:": "\U0001f468\u200d\U0001f692", - ":man_health_worker:": "\U0001f468\u200d\u2695", - ":man_in_tuxedo:": "\U0001f935", - ":man_judge:": "\U0001f468\u200d\u2696", - ":man_juggling:": "\U0001f939\u200d\u2642", - ":man_mechanic:": "\U0001f468\u200d\U0001f527", - ":man_office_worker:": "\U0001f468\u200d\U0001f4bc", - ":man_pilot:": "\U0001f468\u200d\u2708", - ":man_playing_handball:": "\U0001f93e\u200d\u2642", - ":man_playing_water_polo:": "\U0001f93d\u200d\u2642", - ":man_scientist:": "\U0001f468\u200d\U0001f52c", - ":man_shrugging:": "\U0001f937\u200d\u2642", - ":man_singer:": "\U0001f468\u200d\U0001f3a4", - ":man_student:": "\U0001f468\u200d\U0001f393", - ":man_teacher:": "\U0001f468\u200d\U0001f3eb", - ":man_technologist:": "\U0001f468\u200d\U0001f4bb", - ":man_with_gua_pi_mao:": "\U0001f472", - ":man_with_turban:": "\U0001f473", - ":mandarin:": "\U0001f34a", - ":mans_shoe:": "\U0001f45e", - ":mantelpiece_clock:": "\U0001f570", - ":maple_leaf:": "\U0001f341", - ":marshall_islands:": "\U0001f1f2\U0001f1ed", - ":martial_arts_uniform:": "\U0001f94b", - ":martinique:": "\U0001f1f2\U0001f1f6", - ":mask:": "\U0001f637", - ":massage:": "\U0001f486", - ":massage_man:": "\U0001f486\u200d\u2642", - ":massage_woman:": "\U0001f486", - ":mauritania:": "\U0001f1f2\U0001f1f7", - ":mauritius:": "\U0001f1f2\U0001f1fa", - ":mayotte:": "\U0001f1fe\U0001f1f9", - ":meat_on_bone:": "\U0001f356", - ":medal_military:": "\U0001f396", - ":medal_sports:": "\U0001f3c5", - ":mega:": "\U0001f4e3", - ":melon:": "\U0001f348", - ":memo:": "\U0001f4dd", - ":men_wrestling:": "\U0001f93c\u200d\u2642", - ":menorah:": "\U0001f54e", - ":mens:": "\U0001f6b9", - ":metal:": "\U0001f918", - ":metro:": "\U0001f687", - ":mexico:": "\U0001f1f2\U0001f1fd", - ":micronesia:": "\U0001f1eb\U0001f1f2", - ":microphone:": "\U0001f3a4", - ":microscope:": "\U0001f52c", - ":middle_finger:": "\U0001f595", - ":milk_glass:": "\U0001f95b", - ":milky_way:": "\U0001f30c", - ":minibus:": "\U0001f690", - ":minidisc:": "\U0001f4bd", - ":mobile_phone_off:": "\U0001f4f4", - ":moldova:": "\U0001f1f2\U0001f1e9", - ":monaco:": "\U0001f1f2\U0001f1e8", - ":money_mouth_face:": "\U0001f911", - ":money_with_wings:": "\U0001f4b8", - ":moneybag:": "\U0001f4b0", - ":mongolia:": "\U0001f1f2\U0001f1f3", - ":monkey:": "\U0001f412", - ":monkey_face:": "\U0001f435", - ":monorail:": "\U0001f69d", - ":montenegro:": "\U0001f1f2\U0001f1ea", - ":montserrat:": "\U0001f1f2\U0001f1f8", - ":moon:": "\U0001f314", - ":morocco:": "\U0001f1f2\U0001f1e6", - ":mortar_board:": "\U0001f393", - ":mosque:": "\U0001f54c", - ":motor_boat:": "\U0001f6e5", - ":motor_scooter:": "\U0001f6f5", - ":motorcycle:": "\U0001f3cd", - ":motorway:": "\U0001f6e3", - ":mount_fuji:": "\U0001f5fb", - ":mountain:": "\u26f0", - ":mountain_bicyclist:": "\U0001f6b5", - ":mountain_biking_man:": "\U0001f6b5", - ":mountain_biking_woman:": "\U0001f6b5\u200d\u2640", - ":mountain_cableway:": "\U0001f6a0", - ":mountain_railway:": "\U0001f69e", - ":mountain_snow:": "\U0001f3d4", - ":mouse:": "\U0001f42d", - ":mouse2:": "\U0001f401", - ":movie_camera:": "\U0001f3a5", - ":moyai:": "\U0001f5ff", - ":mozambique:": "\U0001f1f2\U0001f1ff", - ":mrs_claus:": "\U0001f936", - ":muscle:": "\U0001f4aa", - ":mushroom:": "\U0001f344", - ":musical_keyboard:": "\U0001f3b9", - ":musical_note:": "\U0001f3b5", - ":musical_score:": "\U0001f3bc", - ":mute:": "\U0001f507", - ":myanmar:": "\U0001f1f2\U0001f1f2", - ":nail_care:": "\U0001f485", - ":name_badge:": "\U0001f4db", - ":namibia:": "\U0001f1f3\U0001f1e6", - ":national_park:": "\U0001f3de", - ":nauru:": "\U0001f1f3\U0001f1f7", - ":nauseated_face:": "\U0001f922", - ":neckbeard:": "", - ":necktie:": "\U0001f454", - ":negative_squared_cross_mark:": "\u274e", - ":nepal:": "\U0001f1f3\U0001f1f5", - ":nerd_face:": "\U0001f913", - ":netherlands:": "\U0001f1f3\U0001f1f1", - ":neutral_face:": "\U0001f610", - ":new:": "\U0001f195", - ":new_caledonia:": "\U0001f1f3\U0001f1e8", - ":new_moon:": "\U0001f311", - ":new_moon_with_face:": "\U0001f31a", - ":new_zealand:": "\U0001f1f3\U0001f1ff", - ":newspaper:": "\U0001f4f0", - ":newspaper_roll:": "\U0001f5de", - ":next_track_button:": "\u23ed", - ":ng:": "\U0001f196", - ":ng_man:": "\U0001f645\u200d\u2642", - ":ng_woman:": "\U0001f645", - ":nicaragua:": "\U0001f1f3\U0001f1ee", - ":niger:": "\U0001f1f3\U0001f1ea", - ":nigeria:": "\U0001f1f3\U0001f1ec", - ":night_with_stars:": "\U0001f303", - ":nine:": "9\ufe0f\u20e3", - ":niue:": "\U0001f1f3\U0001f1fa", - ":no_bell:": "\U0001f515", - ":no_bicycles:": "\U0001f6b3", - ":no_entry:": "\u26d4\ufe0f", - ":no_entry_sign:": "\U0001f6ab", - ":no_good:": "\U0001f645", - ":no_good_man:": "\U0001f645\u200d\u2642", - ":no_good_woman:": "\U0001f645", - ":no_mobile_phones:": "\U0001f4f5", - ":no_mouth:": "\U0001f636", - ":no_pedestrians:": "\U0001f6b7", - ":no_smoking:": "\U0001f6ad", - ":non-potable_water:": "\U0001f6b1", - ":norfolk_island:": "\U0001f1f3\U0001f1eb", - ":north_korea:": "\U0001f1f0\U0001f1f5", - ":northern_mariana_islands:": "\U0001f1f2\U0001f1f5", - ":norway:": "\U0001f1f3\U0001f1f4", - ":nose:": "\U0001f443", - ":notebook:": "\U0001f4d3", - ":notebook_with_decorative_cover:": "\U0001f4d4", - ":notes:": "\U0001f3b6", - ":nut_and_bolt:": "\U0001f529", - ":o:": "\u2b55\ufe0f", - ":o2:": "\U0001f17e\ufe0f", - ":ocean:": "\U0001f30a", - ":octocat:": "", - ":octopus:": "\U0001f419", - ":oden:": "\U0001f362", - ":office:": "\U0001f3e2", - ":oil_drum:": "\U0001f6e2", - ":ok:": "\U0001f197", - ":ok_hand:": "\U0001f44c", - ":ok_man:": "\U0001f646\u200d\u2642", - ":ok_woman:": "\U0001f646", - ":old_key:": "\U0001f5dd", - ":older_man:": "\U0001f474", - ":older_woman:": "\U0001f475", - ":om:": "\U0001f549", - ":oman:": "\U0001f1f4\U0001f1f2", - ":on:": "\U0001f51b", - ":oncoming_automobile:": "\U0001f698", - ":oncoming_bus:": "\U0001f68d", - ":oncoming_police_car:": "\U0001f694", - ":oncoming_taxi:": "\U0001f696", - ":one:": "1\ufe0f\u20e3", - ":open_book:": "\U0001f4d6", - ":open_file_folder:": "\U0001f4c2", - ":open_hands:": "\U0001f450", - ":open_mouth:": "\U0001f62e", - ":open_umbrella:": "\u2602\ufe0f", - ":ophiuchus:": "\u26ce", - ":orange:": "\U0001f34a", - ":orange_book:": "\U0001f4d9", - ":orthodox_cross:": "\u2626\ufe0f", - ":outbox_tray:": "\U0001f4e4", - ":owl:": "\U0001f989", - ":ox:": "\U0001f402", - ":package:": "\U0001f4e6", - ":page_facing_up:": "\U0001f4c4", - ":page_with_curl:": "\U0001f4c3", - ":pager:": "\U0001f4df", - ":paintbrush:": "\U0001f58c", - ":pakistan:": "\U0001f1f5\U0001f1f0", - ":palau:": "\U0001f1f5\U0001f1fc", - ":palestinian_territories:": "\U0001f1f5\U0001f1f8", - ":palm_tree:": "\U0001f334", - ":panama:": "\U0001f1f5\U0001f1e6", - ":pancakes:": "\U0001f95e", - ":panda_face:": "\U0001f43c", - ":paperclip:": "\U0001f4ce", - ":paperclips:": "\U0001f587", - ":papua_new_guinea:": "\U0001f1f5\U0001f1ec", - ":paraguay:": "\U0001f1f5\U0001f1fe", - ":parasol_on_ground:": "\u26f1", - ":parking:": "\U0001f17f\ufe0f", - ":part_alternation_mark:": "\u303d\ufe0f", - ":partly_sunny:": "\u26c5\ufe0f", - ":passenger_ship:": "\U0001f6f3", - ":passport_control:": "\U0001f6c2", - ":pause_button:": "\u23f8", - ":paw_prints:": "\U0001f43e", - ":peace_symbol:": "\u262e\ufe0f", - ":peach:": "\U0001f351", - ":peanuts:": "\U0001f95c", - ":pear:": "\U0001f350", - ":pen:": "\U0001f58a", - ":pencil:": "\U0001f4dd", - ":pencil2:": "\u270f\ufe0f", - ":penguin:": "\U0001f427", - ":pensive:": "\U0001f614", - ":performing_arts:": "\U0001f3ad", - ":persevere:": "\U0001f623", - ":person_fencing:": "\U0001f93a", - ":person_frowning:": "\U0001f64d", - ":person_with_blond_hair:": "\U0001f471", - ":person_with_pouting_face:": "\U0001f64e", - ":peru:": "\U0001f1f5\U0001f1ea", - ":philippines:": "\U0001f1f5\U0001f1ed", - ":phone:": "\u260e\ufe0f", - ":pick:": "\u26cf", - ":pig:": "\U0001f437", - ":pig2:": "\U0001f416", - ":pig_nose:": "\U0001f43d", - ":pill:": "\U0001f48a", - ":pineapple:": "\U0001f34d", - ":ping_pong:": "\U0001f3d3", - ":pisces:": "\u2653\ufe0f", - ":pitcairn_islands:": "\U0001f1f5\U0001f1f3", - ":pizza:": "\U0001f355", - ":place_of_worship:": "\U0001f6d0", - ":plate_with_cutlery:": "\U0001f37d", - ":play_or_pause_button:": "\u23ef", - ":point_down:": "\U0001f447", - ":point_left:": "\U0001f448", - ":point_right:": "\U0001f449", - ":point_up:": "\u261d\ufe0f", - ":point_up_2:": "\U0001f446", - ":poland:": "\U0001f1f5\U0001f1f1", - ":police_car:": "\U0001f693", - ":policeman:": "\U0001f46e", - ":policewoman:": "\U0001f46e\u200d\u2640", - ":poodle:": "\U0001f429", - ":poop:": "\U0001f4a9", - ":popcorn:": "\U0001f37f", - ":portugal:": "\U0001f1f5\U0001f1f9", - ":post_office:": "\U0001f3e3", - ":postal_horn:": "\U0001f4ef", - ":postbox:": "\U0001f4ee", - ":potable_water:": "\U0001f6b0", - ":potato:": "\U0001f954", - ":pouch:": "\U0001f45d", - ":poultry_leg:": "\U0001f357", - ":pound:": "\U0001f4b7", - ":pout:": "\U0001f621", - ":pouting_cat:": "\U0001f63e", - ":pouting_man:": "\U0001f64e\u200d\u2642", - ":pouting_woman:": "\U0001f64e", - ":pray:": "\U0001f64f", - ":prayer_beads:": "\U0001f4ff", - ":pregnant_woman:": "\U0001f930", - ":previous_track_button:": "\u23ee", - ":prince:": "\U0001f934", - ":princess:": "\U0001f478", - ":printer:": "\U0001f5a8", - ":puerto_rico:": "\U0001f1f5\U0001f1f7", - ":punch:": "\U0001f44a", - ":purple_heart:": "\U0001f49c", - ":purse:": "\U0001f45b", - ":pushpin:": "\U0001f4cc", - ":put_litter_in_its_place:": "\U0001f6ae", - ":qatar:": "\U0001f1f6\U0001f1e6", - ":question:": "\u2753", - ":rabbit:": "\U0001f430", - ":rabbit2:": "\U0001f407", - ":racehorse:": "\U0001f40e", - ":racing_car:": "\U0001f3ce", - ":radio:": "\U0001f4fb", - ":radio_button:": "\U0001f518", - ":radioactive:": "\u2622\ufe0f", - ":rage:": "\U0001f621", - ":rage1:": "", - ":rage2:": "", - ":rage3:": "", - ":rage4:": "", - ":railway_car:": "\U0001f683", - ":railway_track:": "\U0001f6e4", - ":rainbow:": "\U0001f308", - ":rainbow_flag:": "\U0001f3f3\ufe0f\u200d\U0001f308", - ":raised_back_of_hand:": "\U0001f91a", - ":raised_hand:": "\u270b", - ":raised_hand_with_fingers_splayed:": "\U0001f590", - ":raised_hands:": "\U0001f64c", - ":raising_hand:": "\U0001f64b", - ":raising_hand_man:": "\U0001f64b\u200d\u2642", - ":raising_hand_woman:": "\U0001f64b", - ":ram:": "\U0001f40f", - ":ramen:": "\U0001f35c", - ":rat:": "\U0001f400", - ":record_button:": "\u23fa", - ":recycle:": "\u267b\ufe0f", - ":red_car:": "\U0001f697", - ":red_circle:": "\U0001f534", - ":registered:": "\u00ae\ufe0f", - ":relaxed:": "\u263a\ufe0f", - ":relieved:": "\U0001f60c", - ":reminder_ribbon:": "\U0001f397", - ":repeat:": "\U0001f501", - ":repeat_one:": "\U0001f502", - ":rescue_worker_helmet:": "\u26d1", - ":restroom:": "\U0001f6bb", - ":reunion:": "\U0001f1f7\U0001f1ea", - ":revolving_hearts:": "\U0001f49e", - ":rewind:": "\u23ea", - ":rhinoceros:": "\U0001f98f", - ":ribbon:": "\U0001f380", - ":rice:": "\U0001f35a", - ":rice_ball:": "\U0001f359", - ":rice_cracker:": "\U0001f358", - ":rice_scene:": "\U0001f391", - ":right_anger_bubble:": "\U0001f5ef", - ":ring:": "\U0001f48d", - ":robot:": "\U0001f916", - ":rocket:": "\U0001f680", - ":rofl:": "\U0001f923", - ":roll_eyes:": "\U0001f644", - ":roller_coaster:": "\U0001f3a2", - ":romania:": "\U0001f1f7\U0001f1f4", - ":rooster:": "\U0001f413", - ":rose:": "\U0001f339", - ":rosette:": "\U0001f3f5", - ":rotating_light:": "\U0001f6a8", - ":round_pushpin:": "\U0001f4cd", - ":rowboat:": "\U0001f6a3", - ":rowing_man:": "\U0001f6a3", - ":rowing_woman:": "\U0001f6a3\u200d\u2640", - ":ru:": "\U0001f1f7\U0001f1fa", - ":rugby_football:": "\U0001f3c9", - ":runner:": "\U0001f3c3", - ":running:": "\U0001f3c3", - ":running_man:": "\U0001f3c3", - ":running_shirt_with_sash:": "\U0001f3bd", - ":running_woman:": "\U0001f3c3\u200d\u2640", - ":rwanda:": "\U0001f1f7\U0001f1fc", - ":sa:": "\U0001f202\ufe0f", - ":sagittarius:": "\u2650\ufe0f", - ":sailboat:": "\u26f5\ufe0f", - ":sake:": "\U0001f376", - ":samoa:": "\U0001f1fc\U0001f1f8", - ":san_marino:": "\U0001f1f8\U0001f1f2", - ":sandal:": "\U0001f461", - ":santa:": "\U0001f385", - ":sao_tome_principe:": "\U0001f1f8\U0001f1f9", - ":sassy_man:": "\U0001f481\u200d\u2642", - ":sassy_woman:": "\U0001f481", - ":satellite:": "\U0001f4e1", - ":satisfied:": "\U0001f606", - ":saudi_arabia:": "\U0001f1f8\U0001f1e6", - ":saxophone:": "\U0001f3b7", - ":school:": "\U0001f3eb", - ":school_satchel:": "\U0001f392", - ":scissors:": "\u2702\ufe0f", - ":scorpion:": "\U0001f982", - ":scorpius:": "\u264f\ufe0f", - ":scream:": "\U0001f631", - ":scream_cat:": "\U0001f640", - ":scroll:": "\U0001f4dc", - ":seat:": "\U0001f4ba", - ":secret:": "\u3299\ufe0f", - ":see_no_evil:": "\U0001f648", - ":seedling:": "\U0001f331", - ":selfie:": "\U0001f933", - ":senegal:": "\U0001f1f8\U0001f1f3", - ":serbia:": "\U0001f1f7\U0001f1f8", - ":seven:": "7\ufe0f\u20e3", - ":seychelles:": "\U0001f1f8\U0001f1e8", - ":shallow_pan_of_food:": "\U0001f958", - ":shamrock:": "\u2618\ufe0f", - ":shark:": "\U0001f988", - ":shaved_ice:": "\U0001f367", - ":sheep:": "\U0001f411", - ":shell:": "\U0001f41a", - ":shield:": "\U0001f6e1", - ":shinto_shrine:": "\u26e9", - ":ship:": "\U0001f6a2", - ":shipit:": "", - ":shirt:": "\U0001f455", - ":shit:": "\U0001f4a9", - ":shoe:": "\U0001f45e", - ":shopping:": "\U0001f6cd", - ":shopping_cart:": "\U0001f6d2", - ":shower:": "\U0001f6bf", - ":shrimp:": "\U0001f990", - ":sierra_leone:": "\U0001f1f8\U0001f1f1", - ":signal_strength:": "\U0001f4f6", - ":singapore:": "\U0001f1f8\U0001f1ec", - ":sint_maarten:": "\U0001f1f8\U0001f1fd", - ":six:": "6\ufe0f\u20e3", - ":six_pointed_star:": "\U0001f52f", - ":ski:": "\U0001f3bf", - ":skier:": "\u26f7", - ":skull:": "\U0001f480", - ":skull_and_crossbones:": "\u2620\ufe0f", - ":sleeping:": "\U0001f634", - ":sleeping_bed:": "\U0001f6cc", - ":sleepy:": "\U0001f62a", - ":slightly_frowning_face:": "\U0001f641", - ":slightly_smiling_face:": "\U0001f642", - ":slot_machine:": "\U0001f3b0", - ":slovakia:": "\U0001f1f8\U0001f1f0", - ":slovenia:": "\U0001f1f8\U0001f1ee", - ":small_airplane:": "\U0001f6e9", - ":small_blue_diamond:": "\U0001f539", - ":small_orange_diamond:": "\U0001f538", - ":small_red_triangle:": "\U0001f53a", - ":small_red_triangle_down:": "\U0001f53b", - ":smile:": "\U0001f604", - ":smile_cat:": "\U0001f638", - ":smiley:": "\U0001f603", - ":smiley_cat:": "\U0001f63a", - ":smiling_imp:": "\U0001f608", - ":smirk:": "\U0001f60f", - ":smirk_cat:": "\U0001f63c", - ":smoking:": "\U0001f6ac", - ":snail:": "\U0001f40c", - ":snake:": "\U0001f40d", - ":sneezing_face:": "\U0001f927", - ":snowboarder:": "\U0001f3c2", - ":snowflake:": "\u2744\ufe0f", - ":snowman:": "\u26c4\ufe0f", - ":snowman_with_snow:": "\u2603\ufe0f", - ":sob:": "\U0001f62d", - ":soccer:": "\u26bd\ufe0f", - ":solomon_islands:": "\U0001f1f8\U0001f1e7", - ":somalia:": "\U0001f1f8\U0001f1f4", - ":soon:": "\U0001f51c", - ":sos:": "\U0001f198", - ":sound:": "\U0001f509", - ":south_africa:": "\U0001f1ff\U0001f1e6", - ":south_georgia_south_sandwich_islands:": "\U0001f1ec\U0001f1f8", - ":south_sudan:": "\U0001f1f8\U0001f1f8", - ":space_invader:": "\U0001f47e", - ":spades:": "\u2660\ufe0f", - ":spaghetti:": "\U0001f35d", - ":sparkle:": "\u2747\ufe0f", - ":sparkler:": "\U0001f387", - ":sparkles:": "\u2728", - ":sparkling_heart:": "\U0001f496", - ":speak_no_evil:": "\U0001f64a", - ":speaker:": "\U0001f508", - ":speaking_head:": "\U0001f5e3", - ":speech_balloon:": "\U0001f4ac", - ":speedboat:": "\U0001f6a4", - ":spider:": "\U0001f577", - ":spider_web:": "\U0001f578", - ":spiral_calendar:": "\U0001f5d3", - ":spiral_notepad:": "\U0001f5d2", - ":spoon:": "\U0001f944", - ":squid:": "\U0001f991", - ":squirrel:": "", - ":sri_lanka:": "\U0001f1f1\U0001f1f0", - ":st_barthelemy:": "\U0001f1e7\U0001f1f1", - ":st_helena:": "\U0001f1f8\U0001f1ed", - ":st_kitts_nevis:": "\U0001f1f0\U0001f1f3", - ":st_lucia:": "\U0001f1f1\U0001f1e8", - ":st_pierre_miquelon:": "\U0001f1f5\U0001f1f2", - ":st_vincent_grenadines:": "\U0001f1fb\U0001f1e8", - ":stadium:": "\U0001f3df", - ":star:": "\u2b50\ufe0f", - ":star2:": "\U0001f31f", - ":star_and_crescent:": "\u262a\ufe0f", - ":star_of_david:": "\u2721\ufe0f", - ":stars:": "\U0001f320", - ":station:": "\U0001f689", - ":statue_of_liberty:": "\U0001f5fd", - ":steam_locomotive:": "\U0001f682", - ":stew:": "\U0001f372", - ":stop_button:": "\u23f9", - ":stop_sign:": "\U0001f6d1", - ":stopwatch:": "\u23f1", - ":straight_ruler:": "\U0001f4cf", - ":strawberry:": "\U0001f353", - ":stuck_out_tongue:": "\U0001f61b", - ":stuck_out_tongue_closed_eyes:": "\U0001f61d", - ":stuck_out_tongue_winking_eye:": "\U0001f61c", - ":studio_microphone:": "\U0001f399", - ":stuffed_flatbread:": "\U0001f959", - ":sudan:": "\U0001f1f8\U0001f1e9", - ":sun_behind_large_cloud:": "\U0001f325", - ":sun_behind_rain_cloud:": "\U0001f326", - ":sun_behind_small_cloud:": "\U0001f324", - ":sun_with_face:": "\U0001f31e", - ":sunflower:": "\U0001f33b", - ":sunglasses:": "\U0001f60e", - ":sunny:": "\u2600\ufe0f", - ":sunrise:": "\U0001f305", - ":sunrise_over_mountains:": "\U0001f304", - ":surfer:": "\U0001f3c4", - ":surfing_man:": "\U0001f3c4", - ":surfing_woman:": "\U0001f3c4\u200d\u2640", - ":suriname:": "\U0001f1f8\U0001f1f7", - ":sushi:": "\U0001f363", - ":suspect:": "", - ":suspension_railway:": "\U0001f69f", - ":swaziland:": "\U0001f1f8\U0001f1ff", - ":sweat:": "\U0001f613", - ":sweat_drops:": "\U0001f4a6", - ":sweat_smile:": "\U0001f605", - ":sweden:": "\U0001f1f8\U0001f1ea", - ":sweet_potato:": "\U0001f360", - ":swimmer:": "\U0001f3ca", - ":swimming_man:": "\U0001f3ca", - ":swimming_woman:": "\U0001f3ca\u200d\u2640", - ":switzerland:": "\U0001f1e8\U0001f1ed", - ":symbols:": "\U0001f523", - ":synagogue:": "\U0001f54d", - ":syria:": "\U0001f1f8\U0001f1fe", - ":syringe:": "\U0001f489", - ":taco:": "\U0001f32e", - ":tada:": "\U0001f389", - ":taiwan:": "\U0001f1f9\U0001f1fc", - ":tajikistan:": "\U0001f1f9\U0001f1ef", - ":tanabata_tree:": "\U0001f38b", - ":tangerine:": "\U0001f34a", - ":tanzania:": "\U0001f1f9\U0001f1ff", - ":taurus:": "\u2649\ufe0f", - ":taxi:": "\U0001f695", - ":tea:": "\U0001f375", - ":telephone:": "\u260e\ufe0f", - ":telephone_receiver:": "\U0001f4de", - ":telescope:": "\U0001f52d", - ":tennis:": "\U0001f3be", - ":tent:": "\u26fa\ufe0f", - ":thailand:": "\U0001f1f9\U0001f1ed", - ":thermometer:": "\U0001f321", - ":thinking:": "\U0001f914", - ":thought_balloon:": "\U0001f4ad", - ":three:": "3\ufe0f\u20e3", - ":thumbsdown:": "\U0001f44e", - ":thumbsup:": "\U0001f44d", - ":ticket:": "\U0001f3ab", - ":tickets:": "\U0001f39f", - ":tiger:": "\U0001f42f", - ":tiger2:": "\U0001f405", - ":timer_clock:": "\u23f2", - ":timor_leste:": "\U0001f1f9\U0001f1f1", - ":tipping_hand_man:": "\U0001f481\u200d\u2642", - ":tipping_hand_woman:": "\U0001f481", - ":tired_face:": "\U0001f62b", - ":tm:": "\u2122\ufe0f", - ":togo:": "\U0001f1f9\U0001f1ec", - ":toilet:": "\U0001f6bd", - ":tokelau:": "\U0001f1f9\U0001f1f0", - ":tokyo_tower:": "\U0001f5fc", - ":tomato:": "\U0001f345", - ":tonga:": "\U0001f1f9\U0001f1f4", - ":tongue:": "\U0001f445", - ":top:": "\U0001f51d", - ":tophat:": "\U0001f3a9", - ":tornado:": "\U0001f32a", - ":tr:": "\U0001f1f9\U0001f1f7", - ":trackball:": "\U0001f5b2", - ":tractor:": "\U0001f69c", - ":traffic_light:": "\U0001f6a5", - ":train:": "\U0001f68b", - ":train2:": "\U0001f686", - ":tram:": "\U0001f68a", - ":triangular_flag_on_post:": "\U0001f6a9", - ":triangular_ruler:": "\U0001f4d0", - ":trident:": "\U0001f531", - ":trinidad_tobago:": "\U0001f1f9\U0001f1f9", - ":triumph:": "\U0001f624", - ":trolleybus:": "\U0001f68e", - ":trollface:": "", - ":trophy:": "\U0001f3c6", - ":tropical_drink:": "\U0001f379", - ":tropical_fish:": "\U0001f420", - ":truck:": "\U0001f69a", - ":trumpet:": "\U0001f3ba", - ":tshirt:": "\U0001f455", - ":tulip:": "\U0001f337", - ":tumbler_glass:": "\U0001f943", - ":tunisia:": "\U0001f1f9\U0001f1f3", - ":turkey:": "\U0001f983", - ":turkmenistan:": "\U0001f1f9\U0001f1f2", - ":turks_caicos_islands:": "\U0001f1f9\U0001f1e8", - ":turtle:": "\U0001f422", - ":tuvalu:": "\U0001f1f9\U0001f1fb", - ":tv:": "\U0001f4fa", - ":twisted_rightwards_arrows:": "\U0001f500", - ":two:": "2\ufe0f\u20e3", - ":two_hearts:": "\U0001f495", - ":two_men_holding_hands:": "\U0001f46c", - ":two_women_holding_hands:": "\U0001f46d", - ":u5272:": "\U0001f239", - ":u5408:": "\U0001f234", - ":u55b6:": "\U0001f23a", - ":u6307:": "\U0001f22f\ufe0f", - ":u6708:": "\U0001f237\ufe0f", - ":u6709:": "\U0001f236", - ":u6e80:": "\U0001f235", - ":u7121:": "\U0001f21a\ufe0f", - ":u7533:": "\U0001f238", - ":u7981:": "\U0001f232", - ":u7a7a:": "\U0001f233", - ":uganda:": "\U0001f1fa\U0001f1ec", - ":uk:": "\U0001f1ec\U0001f1e7", - ":ukraine:": "\U0001f1fa\U0001f1e6", - ":umbrella:": "\u2614\ufe0f", - ":unamused:": "\U0001f612", - ":underage:": "\U0001f51e", - ":unicorn:": "\U0001f984", - ":united_arab_emirates:": "\U0001f1e6\U0001f1ea", - ":unlock:": "\U0001f513", - ":up:": "\U0001f199", - ":upside_down_face:": "\U0001f643", - ":uruguay:": "\U0001f1fa\U0001f1fe", - ":us:": "\U0001f1fa\U0001f1f8", - ":us_virgin_islands:": "\U0001f1fb\U0001f1ee", - ":uzbekistan:": "\U0001f1fa\U0001f1ff", - ":v:": "\u270c\ufe0f", - ":vanuatu:": "\U0001f1fb\U0001f1fa", - ":vatican_city:": "\U0001f1fb\U0001f1e6", - ":venezuela:": "\U0001f1fb\U0001f1ea", - ":vertical_traffic_light:": "\U0001f6a6", - ":vhs:": "\U0001f4fc", - ":vibration_mode:": "\U0001f4f3", - ":video_camera:": "\U0001f4f9", - ":video_game:": "\U0001f3ae", - ":vietnam:": "\U0001f1fb\U0001f1f3", - ":violin:": "\U0001f3bb", - ":virgo:": "\u264d\ufe0f", - ":volcano:": "\U0001f30b", - ":volleyball:": "\U0001f3d0", - ":vs:": "\U0001f19a", - ":vulcan_salute:": "\U0001f596", - ":walking:": "\U0001f6b6", - ":walking_man:": "\U0001f6b6", - ":walking_woman:": "\U0001f6b6\u200d\u2640", - ":wallis_futuna:": "\U0001f1fc\U0001f1eb", - ":waning_crescent_moon:": "\U0001f318", - ":waning_gibbous_moon:": "\U0001f316", - ":warning:": "\u26a0\ufe0f", - ":wastebasket:": "\U0001f5d1", - ":watch:": "\u231a\ufe0f", - ":water_buffalo:": "\U0001f403", - ":watermelon:": "\U0001f349", - ":wave:": "\U0001f44b", - ":wavy_dash:": "\u3030\ufe0f", - ":waxing_crescent_moon:": "\U0001f312", - ":waxing_gibbous_moon:": "\U0001f314", - ":wc:": "\U0001f6be", - ":weary:": "\U0001f629", - ":wedding:": "\U0001f492", - ":weight_lifting_man:": "\U0001f3cb", - ":weight_lifting_woman:": "\U0001f3cb\ufe0f\u200d\u2640\ufe0f", - ":western_sahara:": "\U0001f1ea\U0001f1ed", - ":whale:": "\U0001f433", - ":whale2:": "\U0001f40b", - ":wheel_of_dharma:": "\u2638\ufe0f", - ":wheelchair:": "\u267f\ufe0f", - ":white_check_mark:": "\u2705", - ":white_circle:": "\u26aa\ufe0f", - ":white_flag:": "\U0001f3f3\ufe0f", - ":white_flower:": "\U0001f4ae", - ":white_large_square:": "\u2b1c\ufe0f", - ":white_medium_small_square:": "\u25fd\ufe0f", - ":white_medium_square:": "\u25fb\ufe0f", - ":white_small_square:": "\u25ab\ufe0f", - ":white_square_button:": "\U0001f533", - ":wilted_flower:": "\U0001f940", - ":wind_chime:": "\U0001f390", - ":wind_face:": "\U0001f32c", - ":wine_glass:": "\U0001f377", - ":wink:": "\U0001f609", - ":wolf:": "\U0001f43a", - ":woman:": "\U0001f469", - ":woman_artist:": "\U0001f469\u200d\U0001f3a8", - ":woman_astronaut:": "\U0001f469\u200d\U0001f680", - ":woman_cartwheeling:": "\U0001f938\u200d\u2640", - ":woman_cook:": "\U0001f469\u200d\U0001f373", - ":woman_facepalming:": "\U0001f926\u200d\u2640", - ":woman_factory_worker:": "\U0001f469\u200d\U0001f3ed", - ":woman_farmer:": "\U0001f469\u200d\U0001f33e", - ":woman_firefighter:": "\U0001f469\u200d\U0001f692", - ":woman_health_worker:": "\U0001f469\u200d\u2695", - ":woman_judge:": "\U0001f469\u200d\u2696", - ":woman_juggling:": "\U0001f939\u200d\u2640", - ":woman_mechanic:": "\U0001f469\u200d\U0001f527", - ":woman_office_worker:": "\U0001f469\u200d\U0001f4bc", - ":woman_pilot:": "\U0001f469\u200d\u2708", - ":woman_playing_handball:": "\U0001f93e\u200d\u2640", - ":woman_playing_water_polo:": "\U0001f93d\u200d\u2640", - ":woman_scientist:": "\U0001f469\u200d\U0001f52c", - ":woman_shrugging:": "\U0001f937\u200d\u2640", - ":woman_singer:": "\U0001f469\u200d\U0001f3a4", - ":woman_student:": "\U0001f469\u200d\U0001f393", - ":woman_teacher:": "\U0001f469\u200d\U0001f3eb", - ":woman_technologist:": "\U0001f469\u200d\U0001f4bb", - ":woman_with_turban:": "\U0001f473\u200d\u2640", - ":womans_clothes:": "\U0001f45a", - ":womans_hat:": "\U0001f452", - ":women_wrestling:": "\U0001f93c\u200d\u2640", - ":womens:": "\U0001f6ba", - ":world_map:": "\U0001f5fa", - ":worried:": "\U0001f61f", - ":wrench:": "\U0001f527", - ":writing_hand:": "\u270d\ufe0f", - ":x:": "\u274c", - ":yellow_heart:": "\U0001f49b", - ":yemen:": "\U0001f1fe\U0001f1ea", - ":yen:": "\U0001f4b4", - ":yin_yang:": "\u262f\ufe0f", - ":yum:": "\U0001f60b", - ":zambia:": "\U0001f1ff\U0001f1f2", - ":zap:": "\u26a1\ufe0f", - ":zero:": "0\ufe0f\u20e3", - ":zimbabwe:": "\U0001f1ff\U0001f1fc", - ":zipper_mouth_face:": "\U0001f910", - ":zzz:": "\U0001f4a4", -} diff --git a/vendor/github.com/kyokomi/emoji/wercker.yml b/vendor/github.com/kyokomi/emoji/wercker.yml deleted file mode 100644 index 7c2bb72..0000000 --- a/vendor/github.com/kyokomi/emoji/wercker.yml +++ /dev/null @@ -1,25 +0,0 @@ -box: golang -build: - steps: - - setup-go-workspace - - script: - name: install goveralls - code: | - go get github.com/mattn/goveralls - - script: - name: go get - code: | - go get - - script: - name: go build - code: | - go build ./... - - script: - name: go test - code: | - go test ./... - - script: - name: coveralls - code: | - goveralls -v -service wercker.com -repotoken $COVERALLS_TOKEN - diff --git a/vendor/github.com/lucasb-eyer/go-colorful/.gitignore b/vendor/github.com/lucasb-eyer/go-colorful/.gitignore deleted file mode 100644 index 47fda8e..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Vim swap files -.*.sw? - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe - -# Code coverage stuff -coverage.out diff --git a/vendor/github.com/lucasb-eyer/go-colorful/.travis.yml b/vendor/github.com/lucasb-eyer/go-colorful/.travis.yml deleted file mode 100644 index ca5aed4..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go -install: - - go get golang.org/x/tools/cmd/cover - - go get gopkg.in/DATA-DOG/go-sqlmock.v1 - - go get github.com/mattn/goveralls -script: - - go test -v -covermode=count -coverprofile=coverage.out - - if [[ "$TRAVIS_PULL_REQUEST" = "false" ]]; then $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN; fi diff --git a/vendor/github.com/lucasb-eyer/go-colorful/LICENSE b/vendor/github.com/lucasb-eyer/go-colorful/LICENSE deleted file mode 100644 index 4e402a0..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2013 Lucas Beyer - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/lucasb-eyer/go-colorful/README.md b/vendor/github.com/lucasb-eyer/go-colorful/README.md deleted file mode 100644 index 8c89c38..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/README.md +++ /dev/null @@ -1,488 +0,0 @@ -go-colorful -=========== -A library for playing with colors in go (golang). - -[![Build Status](https://travis-ci.org/lucasb-eyer/go-colorful.svg?branch=master)](https://travis-ci.org/lucasb-eyer/go-colorful) -[![Coverage Status](https://coveralls.io/repos/github/lucasb-eyer/go-colorful/badge.svg?branch=master)](https://coveralls.io/github/lucasb-eyer/go-colorful?branch=master) - -Why? -==== -I love games. I make games. I love detail and I get lost in detail. -One such detail popped up during the development of [Memory Which Does Not Suck](https://github.com/lucasb-eyer/mwdns/), -when we wanted the server to assign the players random colors. Sometimes -two players got very similar colors, which bugged me. The very same evening, -[I want hue](http://tools.medialab.sciences-po.fr/iwanthue/) was the top post -on HackerNews' frontpage and showed me how to Do It Right™. Last but not -least, there was no library for handling color spaces available in go. Colorful -does just that and implements Go's `color.Color` interface. - -What? -===== -Go-Colorful stores colors in RGB and provides methods from converting these to various color-spaces. Currently supported colorspaces are: - -- **RGB:** All three of Red, Green and Blue in [0..1]. -- **HSL:** Hue in [0..360], Saturation and Luminance in [0..1]. For legacy reasons; please forget that it exists. -- **HSV:** Hue in [0..360], Saturation and Value in [0..1]. You're better off using HCL, see below. -- **Hex RGB:** The "internet" color format, as in #FF00FF. -- **Linear RGB:** See [gamma correct rendering](http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/). -- **CIE-XYZ:** CIE's standard color space, almost in [0..1]. -- **CIE-xyY:** encodes chromacity in x and y and luminance in Y, all in [0..1] -- **CIE-L\*a\*b\*:** A *perceptually uniform* color space, i.e. distances are meaningful. L\* in [0..1] and a\*, b\* almost in [-1..1]. -- **CIE-L\*u\*v\*:** Very similar to CIE-L\*a\*b\*, there is [no consensus](http://en.wikipedia.org/wiki/CIELUV#Historical_background) on which one is "better". -- **CIE-L\*C\*h° (HCL):** This is generally the [most useful](http://vis4.net/blog/posts/avoid-equidistant-hsv-colors/) one; CIE-L\*a\*b\* space in polar coordinates, i.e. a *better* HSV. H° is in [0..360], C\* almost in [-1..1] and L\* as in CIE-L\*a\*b\*. - -For the colorspaces where it makes sense (XYZ, Lab, Luv, HCl), the -[D65](http://en.wikipedia.org/wiki/Illuminant_D65) is used as reference white -by default but methods for using your own reference white are provided. - -A coordinate being *almost in* a range means that generally it is, but for very -bright colors and depending on the reference white, it might overflow this -range slightly. For example, C\* of #0000ff is 1.338. - -Unit-tests are provided. - -Nice, but what's it useful for? -------------------------------- - -- Converting color spaces. Some people like to do that. -- Blending (interpolating) between colors in a "natural" look by using the right colorspace. -- Generating random colors under some constraints (e.g. colors of the same shade, or shades of one color.) -- Generating gorgeous random palettes with distinct colors of a same temperature. - -What not (yet)? -=============== -There are a few features which are currently missing and might be useful. -I just haven't implemented them yet because I didn't have the need for it. -Pull requests welcome. - -- Sorting colors (potentially using above mentioned distances) - -So which colorspace should I use? -================================= -It depends on what you want to do. I think the folks from *I want hue* are -on-spot when they say that RGB fits to how *screens produce* color, CIE L\*a\*b\* -fits how *humans perceive* color and HCL fits how *humans think* colors. - -Whenever you'd use HSV, rather go for CIE-L\*C\*h°. for fixed lightness L\* and -chroma C\* values, the hue angle h° rotates through colors of the same -perceived brightness and intensity. - -How? -==== - -### Installing -Installing the library is as easy as - -```bash -$ go get github.com/lucasb-eyer/go-colorful -``` - -The package can then be used through an - -```go -import "github.com/lucasb-eyer/go-colorful" -``` - -### Basic usage - -Create a beautiful blue color using different source space: - -```go -// Any of the following should be the same -c := colorful.Color{0.313725, 0.478431, 0.721569} -c, err := colorful.Hex("#517AB8") -if err != nil{ - log.Fatal(err) -} -c = colorful.Hsv(216.0, 0.56, 0.722) -c = colorful.Xyz(0.189165, 0.190837, 0.480248) -c = colorful.Xyy(0.219895, 0.221839, 0.190837) -c = colorful.Lab(0.507850, 0.040585,-0.370945) -c = colorful.Luv(0.507849,-0.194172,-0.567924) -c = colorful.Hcl(276.2440, 0.373160, 0.507849) -fmt.Printf("RGB values: %v, %v, %v", c.R, c.G, c.B) -``` - -And then converting this color back into various color spaces: - -```go -hex := c.Hex() -h, s, v := c.Hsv() -x, y, z := c.Xyz() -x, y, Y := c.Xyy() -l, a, b := c.Lab() -l, u, v := c.Luv() -h, c, l := c.Hcl() -``` - -Note that, because of Go's unfortunate choice of requiring an initial uppercase, -the name of the functions relating to the xyY space are just off. If you have -any good suggestion, please open an issue. (I don't consider XyY good.) - -### The `color.Color` interface -Because a `colorful.Color` implements Go's `color.Color` interface (found in the -`image/color` package), it can be used anywhere that expects a `color.Color`. - -Furthermore, you can convert anything that implements the `color.Color` interface -into a `colorful.Color` using the `MakeColor` function: - -```go -c, ok := colorful.MakeColor(color.Gray16{12345}) -``` - -**Caveat:** Be aware that this latter conversion (using `MakeColor`) hits a -corner-case when alpha is exactly zero. Because `color.Color` uses pre-multiplied -alpha colors, this means the RGB values are lost (set to 0) and it's impossible -to recover them. In such a case `MakeColor` will return `false` as its second value. - -### Comparing colors -In the RGB color space, the Euclidian distance between colors *doesn't* correspond -to visual/perceptual distance. This means that two pairs of colors which have the -same distance in RGB space can look much further apart. This is fixed by the -CIE-L\*a\*b\*, CIE-L\*u\*v\* and CIE-L\*C\*h° color spaces. -Thus you should only compare colors in any of these space. -(Note that the distance in CIE-L\*a\*b\* and CIE-L\*C\*h° are the same, since it's the same space but in cylindrical coordinates) - -![Color distance comparison](doc/colordist/colordist.png) - -The two colors shown on the top look much more different than the two shown on -the bottom. Still, in RGB space, their distance is the same. -Here is a little example program which shows the distances between the top two -and bottom two colors in RGB, CIE-L\*a\*b\* and CIE-L\*u\*v\* space. You can find it in `doc/colordist/colordist.go`. - -```go -package main - -import "fmt" -import "github.com/lucasb-eyer/go-colorful" - -func main() { - c1a := colorful.Color{150.0/255.0, 10.0/255.0, 150.0/255.0} - c1b := colorful.Color{ 53.0/255.0, 10.0/255.0, 150.0/255.0} - c2a := colorful.Color{10.0/255.0, 150.0/255.0, 50.0/255.0} - c2b := colorful.Color{99.9/255.0, 150.0/255.0, 10.0/255.0} - - fmt.Printf("DistanceRgb: c1: %v\tand c2: %v\n", c1a.DistanceRgb(c1b), c2a.DistanceRgb(c2b)) - fmt.Printf("DistanceLab: c1: %v\tand c2: %v\n", c1a.DistanceLab(c1b), c2a.DistanceLab(c2b)) - fmt.Printf("DistanceLuv: c1: %v\tand c2: %v\n", c1a.DistanceLuv(c1b), c2a.DistanceLuv(c2b)) - fmt.Printf("DistanceCIE76: c1: %v\tand c2: %v\n", c1a.DistanceCIE76(c1b), c2a.DistanceCIE76(c2b)) - fmt.Printf("DistanceCIE94: c1: %v\tand c2: %v\n", c1a.DistanceCIE94(c1b), c2a.DistanceCIE94(c2b)) -} -``` - -Running the above program shows that you should always prefer any of the CIE distances: - -```bash -$ go run colordist.go -DistanceRgb: c1: 0.3803921568627451 and c2: 0.3858713931171159 -DistanceLab: c1: 0.3204845831279805 and c2: 0.2439715175856528 -DistanceLuv: c1: 0.5134369614199698 and c2: 0.25686928398606323 -DistanceCIE76: c1: 0.3204845831279805 and c2: 0.2439715175856528 -DistanceCIE94: c1: 0.19799168128511327 and c2: 0.12207136371167401 -``` - -It also shows that `DistanceLab` is more formally known as `DistanceCIE76` and -has been superseded by the slightly more accurate, but much more expensive -`DistanceCIE94`. - -Note that `AlmostEqualRgb` is provided mainly for (unit-)testing purposes. Use -it only if you really know what you're doing. It will eat your cat. - -### Blending colors -Blending is highly connected to distance, since it basically "walks through" the -colorspace thus, if the colorspace maps distances well, the walk is "smooth". - -Colorful comes with blending functions in RGB, HSV and any of the LAB spaces. -Of course, you'd rather want to use the blending functions of the LAB spaces since -these spaces map distances well but, just in case, here is an example showing -you how the blendings (`#fdffcc` to `#242a42`) are done in the various spaces: - -![Blending colors in different spaces.](doc/colorblend/colorblend.png) - -What you see is that HSV is really bad: it adds some green, which is not present -in the original colors at all! RGB is much better, but it stays light a little -too long. LUV and LAB both hit the right lightness but LAB has a little more -color. HCL works in the same vein as HSV (both cylindrical interpolations) but -it does it right in that there is no green appearing and the lighthness changes -in a linear manner. - -While this seems all good, you need to know one thing: When interpolating in any -of the CIE color spaces, you might get invalid RGB colors! This is important if -the starting and ending colors are user-input or random. An example of where this -happens is when blending between `#eeef61` and `#1e3140`: - -![Invalid RGB colors may crop up when blending in CIE spaces.](doc/colorblend/invalid.png) - -You can test whether a color is a valid RGB color by calling the `IsValid` method -and indeed, calling IsValid will return false for the redish colors on the bottom. -One way to "fix" this is to get a valid color close to the invalid one by calling -`Clamped`, which always returns a nearby valid color. Doing this, we get the -following result, which is satisfactory: - -![Fixing invalid RGB colors by clamping them to the valid range.](doc/colorblend/clamped.png) - -The following is the code creating the above three images; it can be found in `doc/colorblend/colorblend.go` - -```go -package main - -import "fmt" -import "github.com/lucasb-eyer/go-colorful" -import "image" -import "image/draw" -import "image/png" -import "os" - -func main() { - blocks := 10 - blockw := 40 - img := image.NewRGBA(image.Rect(0,0,blocks*blockw,200)) - - c1, _ := colorful.Hex("#fdffcc") - c2, _ := colorful.Hex("#242a42") - - // Use these colors to get invalid RGB in the gradient. - //c1, _ := colorful.Hex("#EEEF61") - //c2, _ := colorful.Hex("#1E3140") - - for i := 0 ; i < blocks ; i++ { - draw.Draw(img, image.Rect(i*blockw, 0,(i+1)*blockw, 40), &image.Uniform{c1.BlendHsv(c2, float64(i)/float64(blocks-1))}, image.ZP, draw.Src) - draw.Draw(img, image.Rect(i*blockw, 40,(i+1)*blockw, 80), &image.Uniform{c1.BlendLuv(c2, float64(i)/float64(blocks-1))}, image.ZP, draw.Src) - draw.Draw(img, image.Rect(i*blockw, 80,(i+1)*blockw,120), &image.Uniform{c1.BlendRgb(c2, float64(i)/float64(blocks-1))}, image.ZP, draw.Src) - draw.Draw(img, image.Rect(i*blockw,120,(i+1)*blockw,160), &image.Uniform{c1.BlendLab(c2, float64(i)/float64(blocks-1))}, image.ZP, draw.Src) - draw.Draw(img, image.Rect(i*blockw,160,(i+1)*blockw,200), &image.Uniform{c1.BlendHcl(c2, float64(i)/float64(blocks-1))}, image.ZP, draw.Src) - - // This can be used to "fix" invalid colors in the gradient. - //draw.Draw(img, image.Rect(i*blockw,160,(i+1)*blockw,200), &image.Uniform{c1.BlendHcl(c2, float64(i)/float64(blocks-1)).Clamped()}, image.ZP, draw.Src) - } - - toimg, err := os.Create("colorblend.png") - if err != nil { - fmt.Printf("Error: %v", err) - return - } - defer toimg.Close() - - png.Encode(toimg, img) -} -``` - -#### Generating color gradients -A very common reason to blend colors is creating gradients. There is an example -program in [doc/gradientgen.go](doc/gradientgen/gradientgen.go); it doesn't use any API -which hasn't been used in the previous example code, so I won't bother pasting -the code in here. Just look at that gorgeous gradient it generated in HCL space: - -!["Spectral" colorbrewer gradient in HCL space.](doc/gradientgen/gradientgen.png) - -### Getting random colors -It is sometimes necessary to generate random colors. You could simply do this -on your own by generating colors with random values. By restricting the random -values to a range smaller than [0..1] and using a space such as CIE-H\*C\*l° or -HSV, you can generate both random shades of a color or random colors of a -lightness: - -```go -random_blue := colorful.Hcl(180.0+rand.Float64()*50.0, 0.2+rand.Float64()*0.8, 0.3+rand.Float64()*0.7) -random_dark := colorful.Hcl(rand.Float64()*360.0, rand.Float64(), rand.Float64()*0.4) -random_light := colorful.Hcl(rand.Float64()*360.0, rand.Float64(), 0.6+rand.Float64()*0.4) -``` - -Since getting random "warm" and "happy" colors is quite a common task, there -are some helper functions: - -```go -colorful.WarmColor() -colorful.HappyColor() -colorful.FastWarmColor() -colorful.FastHappyColor() -``` - -The ones prefixed by `Fast` are faster but less coherent since they use the HSV -space as opposed to the regular ones which use CIE-L\*C\*h° space. The -following picture shows the warm colors in the top two rows and happy colors -in the bottom two rows. Within these, the first is the regular one and the -second is the fast one. - -![Warm, fast warm, happy and fast happy random colors, respectively.](doc/colorgens/colorgens.png) - -Don't forget to initialize the random seed! You can see the code used for -generating this picture in `doc/colorgens/colorgens.go`. - -### Getting random palettes -As soon as you need to generate more than one random color, you probably want -them to be distinguishible. Playing against an opponent which has almost the -same blue as I do is not fun. This is where random palettes can help. - -These palettes are generated using an algorithm which ensures that all colors -on the palette are as distinguishible as possible. Again, there is a `Fast` -method which works in HSV and is less perceptually uniform and a non-`Fast` -method which works in CIE spaces. For more theory on `SoftPalette`, check out -[I want hue](http://tools.medialab.sciences-po.fr/iwanthue/theory.php). Yet -again, there is a `Happy` and a `Warm` version, which do what you expect, but -now there is an additional `Soft` version, which is more configurable: you can -give a constraint on the color space in order to get colors within a certain *feel*. - -Let's start with the simple methods first, all they take is the amount of -colors to generate, which could, for example, be the player count. They return -an array of `colorful.Color` objects: - -```go -pal1, err1 := colorful.WarmPalette(10) -pal2 := colorful.FastWarmPalette(10) -pal3, err3 := colorful.HappyPalette(10) -pal4 := colorful.FastHappyPalette(10) -pal5, err5 := colorful.SoftPalette(10) -``` - -Note that the non-fast methods *may* fail if you ask for way too many colors. -Let's move on to the advanced one, namely `SoftPaletteEx`. Besides the color -count, this function takes a `SoftPaletteSettings` object as argument. The -interesting part here is its `CheckColor` member, which is a boolean function -taking three floating points as arguments: `l`, `a` and `b`. This function -should return `true` for colors which lie within the region you want and `false` -otherwise. The other members are `Iteration`, which should be within [5..100] -where higher means slower but more exact palette, and `ManySamples` which you -should set to `true` in case your `CheckColor` constraint rejects a large part -of the color space. - -For example, to create a palette of 10 brownish colors, you'd call it like this: - -```go -func isbrowny(l, a, b float64) bool { - h, c, L := colorful.LabToHcl(l, a, b) - return 10.0 < h && h < 50.0 && 0.1 < c && c < 0.5 && L < 0.5 -} -// Since the above function is pretty restrictive, we set ManySamples to true. -brownies := colorful.SoftPaletteEx(10, colorful.SoftPaletteSettings{isbrowny, 50, true}) -``` - -The following picture shows the palettes generated by all of these methods -(sourcecode in `doc/palettegens/palettegens.go`), in the order they were presented, i.e. -from top to bottom: `Warm`, `FastWarm`, `Happy`, `FastHappy`, `Soft`, -`SoftEx(isbrowny)`. All of them contain some randomness, so YMMV. - -![All example palettes](doc/palettegens/palettegens.png) - -### Sorting colors -TODO: Sort using dist fn. - -### Using linear RGB for computations -There are two methods for transforming RGB<->Linear RGB: a fast and almost precise one, -and a slow and precise one. - -```go -r, g, b := colorful.Hex("#FF0000").FastLinearRgb() -``` - -TODO: describe some more. - -### Want to use some other reference point? - -```go -c := colorful.LabWhiteRef(0.507850, 0.040585,-0.370945, colorful.D50) -l, a, b := c.LabWhiteRef(colorful.D50) -``` - -### Reading and writing colors from databases - -The type `HexColor` makes it easy to store colors as strings in a database. It -implements the [https://godoc.org/database/sql#Scanner](database/sql.Scanner) -and [database/sql/driver.Value](https://godoc.org/database/sql/driver.Value) -interfaces which provide automatic type conversion. - -Example: - -```go -var hc HexColor -_, err := db.QueryRow("SELECT '#ff0000';").Scan(&hc) -// hc == HexColor{R: 1, G: 0, B: 0}; err == nil -``` - -FAQ -=== - -### Q: I get all f!@#ed up values! Your library sucks! -A: You probably provided values in the wrong range. For example, RGB values are -expected to reside between 0 and 1, *not* between 0 and 255. Normalize your colors. - -### Q: Lab/Luv/HCl seem broken! Your library sucks! -They look like this: - - - -A: You're likely trying to generate and display colors that can't be represented by RGB, -and thus monitors. When you're trying to convert, say, `HCL(190.0, 1.0, 1.0).RGB255()`, -you're asking for RGB values of `(-2105.254 300.680 286.185)`, which clearly don't exist, -and the `RGB255` function just casts these numbers to `uint8`, creating wrap-around and -what looks like a completely broken gradient. What you want to do, is either use more -reasonable values of colors which actually exist in RGB, or just `Clamp()` the resulting -color to its nearest existing one, living with the consequences: -`HCL(190.0, 1.0, 1.0).Clamp().RGB255()`. It will look something like this: - - - -[Here's an issue going in-depth about this](https://github.com/lucasb-eyer/go-colorful/issues/14), -as well as [my answer](https://github.com/lucasb-eyer/go-colorful/issues/14#issuecomment-324205385), -both with code and pretty pictures. Also note that this was somewhat covered above in the -["Blending colors" section](https://github.com/lucasb-eyer/go-colorful#blending-colors). - -### Q: In a tight loop, conversion to Lab/Luv/HCl/... are slooooow! -A: Yes, they are. -This library aims for correctness, readability, and modularity; it wasn't written with speed in mind. -A large part of the slowness comes from these conversions going through `LinearRgb` which uses powers. -I implemented a fast approximation to `LinearRgb` called `FastLinearRgb` by using Taylor approximations. -The approximation is roughly 5x faster and precise up to roughly 0.5%, -the major caveat being that if the input values are outside the range 0-1, accuracy drops dramatically. -You can use these in your conversions as follows: - -```go -col := // Get your color somehow -l, a, b := XyzToLab(LinearRgbToXyz(col.LinearRgb())) -``` - -If you need faster versions of `Distance*` and `Blend*` that make use of this fast approximation, -feel free to implement them and open a pull-request, I'll happily accept. - -The derivation of these functions can be followed in [this Jupyter notebook](doc/LinearRGB Approximations.ipynb). -Here's the main figure showing the approximation quality: - -![approximation quality](doc/approx-quality.png) - -More speed could be gained by using SIMD instructions in many places. -You can also get more speed for specific conversions by approximating the full conversion function, -but that is outside the scope of this library. -Thanks to [@ZirconiumX](https://github.com/ZirconiumX) for starting this investigation, -see [issue #18](https://github.com/lucasb-eyer/go-colorful/issues/18) for details. - -### Q: Why would `MakeColor` ever fail!? -A: `MakeColor` fails when the alpha channel is zero. In that case, the -conversion is undefined. See [issue 21](https://github.com/lucasb-eyer/go-colorful/issues/21) -as well as the short caveat note in the ["The `color.Color` interface"](README.md#the-colorcolor-interface) -section above. - -Who? -==== - -This library has been developed by Lucas Beyer with contributions from -Bastien Dejean (@baskerville), Phil Kulak (@pkulak) and Christian Muehlhaeuser (@muesli). - -Release Notes -============= - -### Version 1.0 -- API Breaking change in `MakeColor`: instead of `panic`ing when alpha is zero, it now returns a secondary, boolean return value indicating success. See [the color.Color interface](https://github.com/lucasb-eyer/go-colorful#the-colorcolor-interface) section and [this FAQ entry](https://github.com/lucasb-eyer/go-colorful#q-why-would-makecolor-ever-fail) for details. - -### Version 0.9 -- Initial version number after having ignored versioning for a long time :) - -License: MIT -============ -Copyright (c) 2013 Lucas Beyer - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/vendor/github.com/lucasb-eyer/go-colorful/colorgens.go b/vendor/github.com/lucasb-eyer/go-colorful/colorgens.go deleted file mode 100644 index 2e2e49e..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/colorgens.go +++ /dev/null @@ -1,55 +0,0 @@ -// Various ways to generate single random colors - -package colorful - -import ( - "math/rand" -) - -// Creates a random dark, "warm" color through a restricted HSV space. -func FastWarmColor() Color { - return Hsv( - rand.Float64()*360.0, - 0.5+rand.Float64()*0.3, - 0.3+rand.Float64()*0.3) -} - -// Creates a random dark, "warm" color through restricted HCL space. -// This is slower than FastWarmColor but will likely give you colors which have -// the same "warmness" if you run it many times. -func WarmColor() (c Color) { - for c = randomWarm(); !c.IsValid(); c = randomWarm() { - } - return -} - -func randomWarm() Color { - return Hcl( - rand.Float64()*360.0, - 0.1+rand.Float64()*0.3, - 0.2+rand.Float64()*0.3) -} - -// Creates a random bright, "pimpy" color through a restricted HSV space. -func FastHappyColor() Color { - return Hsv( - rand.Float64()*360.0, - 0.7+rand.Float64()*0.3, - 0.6+rand.Float64()*0.3) -} - -// Creates a random bright, "pimpy" color through restricted HCL space. -// This is slower than FastHappyColor but will likely give you colors which -// have the same "brightness" if you run it many times. -func HappyColor() (c Color) { - for c = randomPimp(); !c.IsValid(); c = randomPimp() { - } - return -} - -func randomPimp() Color { - return Hcl( - rand.Float64()*360.0, - 0.5+rand.Float64()*0.3, - 0.5+rand.Float64()*0.3) -} diff --git a/vendor/github.com/lucasb-eyer/go-colorful/colors.go b/vendor/github.com/lucasb-eyer/go-colorful/colors.go deleted file mode 100644 index febf94c..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/colors.go +++ /dev/null @@ -1,819 +0,0 @@ -// The colorful package provides all kinds of functions for working with colors. -package colorful - -import ( - "fmt" - "image/color" - "math" -) - -// A color is stored internally using sRGB (standard RGB) values in the range 0-1 -type Color struct { - R, G, B float64 -} - -// Implement the Go color.Color interface. -func (col Color) RGBA() (r, g, b, a uint32) { - r = uint32(col.R*65535.0 + 0.5) - g = uint32(col.G*65535.0 + 0.5) - b = uint32(col.B*65535.0 + 0.5) - a = 0xFFFF - return -} - -// Constructs a colorful.Color from something implementing color.Color -func MakeColor(col color.Color) (Color, bool) { - r, g, b, a := col.RGBA() - if a == 0 { - return Color{0, 0, 0}, false - } - - // Since color.Color is alpha pre-multiplied, we need to divide the - // RGB values by alpha again in order to get back the original RGB. - r *= 0xffff - r /= a - g *= 0xffff - g /= a - b *= 0xffff - b /= a - - return Color{float64(r) / 65535.0, float64(g) / 65535.0, float64(b) / 65535.0}, true -} - -// Might come in handy sometimes to reduce boilerplate code. -func (col Color) RGB255() (r, g, b uint8) { - r = uint8(col.R*255.0 + 0.5) - g = uint8(col.G*255.0 + 0.5) - b = uint8(col.B*255.0 + 0.5) - return -} - -// This is the tolerance used when comparing colors using AlmostEqualRgb. -const Delta = 1.0 / 255.0 - -// This is the default reference white point. -var D65 = [3]float64{0.95047, 1.00000, 1.08883} - -// And another one. -var D50 = [3]float64{0.96422, 1.00000, 0.82521} - -// Checks whether the color exists in RGB space, i.e. all values are in [0..1] -func (c Color) IsValid() bool { - return 0.0 <= c.R && c.R <= 1.0 && - 0.0 <= c.G && c.G <= 1.0 && - 0.0 <= c.B && c.B <= 1.0 -} - -func clamp01(v float64) float64 { - return math.Max(0.0, math.Min(v, 1.0)) -} - -// Returns Clamps the color into valid range, clamping each value to [0..1] -// If the color is valid already, this is a no-op. -func (c Color) Clamped() Color { - return Color{clamp01(c.R), clamp01(c.G), clamp01(c.B)} -} - -func sq(v float64) float64 { - return v * v -} - -func cub(v float64) float64 { - return v * v * v -} - -// DistanceRgb computes the distance between two colors in RGB space. -// This is not a good measure! Rather do it in Lab space. -func (c1 Color) DistanceRgb(c2 Color) float64 { - return math.Sqrt(sq(c1.R-c2.R) + sq(c1.G-c2.G) + sq(c1.B-c2.B)) -} - -// Check for equality between colors within the tolerance Delta (1/255). -func (c1 Color) AlmostEqualRgb(c2 Color) bool { - return math.Abs(c1.R-c2.R)+ - math.Abs(c1.G-c2.G)+ - math.Abs(c1.B-c2.B) < 3.0*Delta -} - -// You don't really want to use this, do you? Go for BlendLab, BlendLuv or BlendHcl. -func (c1 Color) BlendRgb(c2 Color, t float64) Color { - return Color{c1.R + t*(c2.R-c1.R), - c1.G + t*(c2.G-c1.G), - c1.B + t*(c2.B-c1.B)} -} - -// Utility used by Hxx color-spaces for interpolating between two angles in [0,360]. -func interp_angle(a0, a1, t float64) float64 { - // Based on the answer here: http://stackoverflow.com/a/14498790/2366315 - // With potential proof that it works here: http://math.stackexchange.com/a/2144499 - delta := math.Mod(math.Mod(a1-a0, 360.0)+540, 360.0) - 180.0 - return math.Mod(a0+t*delta+360.0, 360.0) -} - -/// HSV /// -/////////// -// From http://en.wikipedia.org/wiki/HSL_and_HSV -// Note that h is in [0..360] and s,v in [0..1] - -// Hsv returns the Hue [0..360], Saturation and Value [0..1] of the color. -func (col Color) Hsv() (h, s, v float64) { - min := math.Min(math.Min(col.R, col.G), col.B) - v = math.Max(math.Max(col.R, col.G), col.B) - C := v - min - - s = 0.0 - if v != 0.0 { - s = C / v - } - - h = 0.0 // We use 0 instead of undefined as in wp. - if min != v { - if v == col.R { - h = math.Mod((col.G-col.B)/C, 6.0) - } - if v == col.G { - h = (col.B-col.R)/C + 2.0 - } - if v == col.B { - h = (col.R-col.G)/C + 4.0 - } - h *= 60.0 - if h < 0.0 { - h += 360.0 - } - } - return -} - -// Hsv creates a new Color given a Hue in [0..360], a Saturation and a Value in [0..1] -func Hsv(H, S, V float64) Color { - Hp := H / 60.0 - C := V * S - X := C * (1.0 - math.Abs(math.Mod(Hp, 2.0)-1.0)) - - m := V - C - r, g, b := 0.0, 0.0, 0.0 - - switch { - case 0.0 <= Hp && Hp < 1.0: - r = C - g = X - case 1.0 <= Hp && Hp < 2.0: - r = X - g = C - case 2.0 <= Hp && Hp < 3.0: - g = C - b = X - case 3.0 <= Hp && Hp < 4.0: - g = X - b = C - case 4.0 <= Hp && Hp < 5.0: - r = X - b = C - case 5.0 <= Hp && Hp < 6.0: - r = C - b = X - } - - return Color{m + r, m + g, m + b} -} - -// You don't really want to use this, do you? Go for BlendLab, BlendLuv or BlendHcl. -func (c1 Color) BlendHsv(c2 Color, t float64) Color { - h1, s1, v1 := c1.Hsv() - h2, s2, v2 := c2.Hsv() - - // We know that h are both in [0..360] - return Hsv(interp_angle(h1, h2, t), s1+t*(s2-s1), v1+t*(v2-v1)) -} - -/// HSL /// -/////////// - -// Hsl returns the Hue [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color. -func (col Color) Hsl() (h, s, l float64) { - min := math.Min(math.Min(col.R, col.G), col.B) - max := math.Max(math.Max(col.R, col.G), col.B) - - l = (max + min) / 2 - - if min == max { - s = 0 - h = 0 - } else { - if l < 0.5 { - s = (max - min) / (max + min) - } else { - s = (max - min) / (2.0 - max - min) - } - - if max == col.R { - h = (col.G - col.B) / (max - min) - } else if max == col.G { - h = 2.0 + (col.B-col.R)/(max-min) - } else { - h = 4.0 + (col.R-col.G)/(max-min) - } - - h *= 60 - - if h < 0 { - h += 360 - } - } - - return -} - -// Hsl creates a new Color given a Hue in [0..360], a Saturation [0..1], and a Luminance (lightness) in [0..1] -func Hsl(h, s, l float64) Color { - if s == 0 { - return Color{l, l, l} - } - - var r, g, b float64 - var t1 float64 - var t2 float64 - var tr float64 - var tg float64 - var tb float64 - - if l < 0.5 { - t1 = l * (1.0 + s) - } else { - t1 = l + s - l*s - } - - t2 = 2*l - t1 - h = h / 360 - tr = h + 1.0/3.0 - tg = h - tb = h - 1.0/3.0 - - if tr < 0 { - tr++ - } - if tr > 1 { - tr-- - } - if tg < 0 { - tg++ - } - if tg > 1 { - tg-- - } - if tb < 0 { - tb++ - } - if tb > 1 { - tb-- - } - - // Red - if 6*tr < 1 { - r = t2 + (t1-t2)*6*tr - } else if 2*tr < 1 { - r = t1 - } else if 3*tr < 2 { - r = t2 + (t1-t2)*(2.0/3.0-tr)*6 - } else { - r = t2 - } - - // Green - if 6*tg < 1 { - g = t2 + (t1-t2)*6*tg - } else if 2*tg < 1 { - g = t1 - } else if 3*tg < 2 { - g = t2 + (t1-t2)*(2.0/3.0-tg)*6 - } else { - g = t2 - } - - // Blue - if 6*tb < 1 { - b = t2 + (t1-t2)*6*tb - } else if 2*tb < 1 { - b = t1 - } else if 3*tb < 2 { - b = t2 + (t1-t2)*(2.0/3.0-tb)*6 - } else { - b = t2 - } - - return Color{r, g, b} -} - -/// Hex /// -/////////// - -// Hex returns the hex "html" representation of the color, as in #ff0080. -func (col Color) Hex() string { - // Add 0.5 for rounding - return fmt.Sprintf("#%02x%02x%02x", uint8(col.R*255.0+0.5), uint8(col.G*255.0+0.5), uint8(col.B*255.0+0.5)) -} - -// Hex parses a "html" hex color-string, either in the 3 "#f0c" or 6 "#ff1034" digits form. -func Hex(scol string) (Color, error) { - format := "#%02x%02x%02x" - factor := 1.0 / 255.0 - if len(scol) == 4 { - format = "#%1x%1x%1x" - factor = 1.0 / 15.0 - } - - var r, g, b uint8 - n, err := fmt.Sscanf(scol, format, &r, &g, &b) - if err != nil { - return Color{}, err - } - if n != 3 { - return Color{}, fmt.Errorf("color: %v is not a hex-color", scol) - } - - return Color{float64(r) * factor, float64(g) * factor, float64(b) * factor}, nil -} - -/// Linear /// -////////////// -// http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/ -// http://www.brucelindbloom.com/Eqn_RGB_to_XYZ.html - -func linearize(v float64) float64 { - if v <= 0.04045 { - return v / 12.92 - } - return math.Pow((v+0.055)/1.055, 2.4) -} - -// LinearRgb converts the color into the linear RGB space (see http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/). -func (col Color) LinearRgb() (r, g, b float64) { - r = linearize(col.R) - g = linearize(col.G) - b = linearize(col.B) - return -} - -// A much faster and still quite precise linearization using a 6th-order Taylor approximation. -// See the accompanying Jupyter notebook for derivation of the constants. -func linearize_fast(v float64) float64 { - v1 := v - 0.5 - v2 := v1 * v1 - v3 := v2 * v1 - v4 := v2 * v2 - //v5 := v3*v2 - return -0.248750514614486 + 0.925583310193438*v + 1.16740237321695*v2 + 0.280457026598666*v3 - 0.0757991963780179*v4 //+ 0.0437040411548932*v5 -} - -// FastLinearRgb is much faster than and almost as accurate as LinearRgb. -// BUT it is important to NOTE that they only produce good results for valid colors r,g,b in [0,1]. -func (col Color) FastLinearRgb() (r, g, b float64) { - r = linearize_fast(col.R) - g = linearize_fast(col.G) - b = linearize_fast(col.B) - return -} - -func delinearize(v float64) float64 { - if v <= 0.0031308 { - return 12.92 * v - } - return 1.055*math.Pow(v, 1.0/2.4) - 0.055 -} - -// LinearRgb creates an sRGB color out of the given linear RGB color (see http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/). -func LinearRgb(r, g, b float64) Color { - return Color{delinearize(r), delinearize(g), delinearize(b)} -} - -func delinearize_fast(v float64) float64 { - // This function (fractional root) is much harder to linearize, so we need to split. - if v > 0.2 { - v1 := v - 0.6 - v2 := v1 * v1 - v3 := v2 * v1 - v4 := v2 * v2 - v5 := v3 * v2 - return 0.442430344268235 + 0.592178981271708*v - 0.287864782562636*v2 + 0.253214392068985*v3 - 0.272557158129811*v4 + 0.325554383321718*v5 - } else if v > 0.03 { - v1 := v - 0.115 - v2 := v1 * v1 - v3 := v2 * v1 - v4 := v2 * v2 - v5 := v3 * v2 - return 0.194915592891669 + 1.55227076330229*v - 3.93691860257828*v2 + 18.0679839248761*v3 - 101.468750302746*v4 + 632.341487393927*v5 - } else { - v1 := v - 0.015 - v2 := v1 * v1 - v3 := v2 * v1 - v4 := v2 * v2 - v5 := v3 * v2 - // You can clearly see from the involved constants that the low-end is highly nonlinear. - return 0.0519565234928877 + 5.09316778537561*v - 99.0338180489702*v2 + 3484.52322764895*v3 - 150028.083412663*v4 + 7168008.42971613*v5 - } -} - -// FastLinearRgb is much faster than and almost as accurate as LinearRgb. -// BUT it is important to NOTE that they only produce good results for valid inputs r,g,b in [0,1]. -func FastLinearRgb(r, g, b float64) Color { - return Color{delinearize_fast(r), delinearize_fast(g), delinearize_fast(b)} -} - -// XyzToLinearRgb converts from CIE XYZ-space to Linear RGB space. -func XyzToLinearRgb(x, y, z float64) (r, g, b float64) { - r = 3.2404542*x - 1.5371385*y - 0.4985314*z - g = -0.9692660*x + 1.8760108*y + 0.0415560*z - b = 0.0556434*x - 0.2040259*y + 1.0572252*z - return -} - -func LinearRgbToXyz(r, g, b float64) (x, y, z float64) { - x = 0.4124564*r + 0.3575761*g + 0.1804375*b - y = 0.2126729*r + 0.7151522*g + 0.0721750*b - z = 0.0193339*r + 0.1191920*g + 0.9503041*b - return -} - -/// XYZ /// -/////////// -// http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/ - -func (col Color) Xyz() (x, y, z float64) { - return LinearRgbToXyz(col.LinearRgb()) -} - -func Xyz(x, y, z float64) Color { - return LinearRgb(XyzToLinearRgb(x, y, z)) -} - -/// xyY /// -/////////// -// http://www.brucelindbloom.com/Eqn_XYZ_to_xyY.html - -// Well, the name is bad, since it's xyY but Golang needs me to start with a -// capital letter to make the method public. -func XyzToXyy(X, Y, Z float64) (x, y, Yout float64) { - return XyzToXyyWhiteRef(X, Y, Z, D65) -} - -func XyzToXyyWhiteRef(X, Y, Z float64, wref [3]float64) (x, y, Yout float64) { - Yout = Y - N := X + Y + Z - if math.Abs(N) < 1e-14 { - // When we have black, Bruce Lindbloom recommends to use - // the reference white's chromacity for x and y. - x = wref[0] / (wref[0] + wref[1] + wref[2]) - y = wref[1] / (wref[0] + wref[1] + wref[2]) - } else { - x = X / N - y = Y / N - } - return -} - -func XyyToXyz(x, y, Y float64) (X, Yout, Z float64) { - Yout = Y - - if -1e-14 < y && y < 1e-14 { - X = 0.0 - Z = 0.0 - } else { - X = Y / y * x - Z = Y / y * (1.0 - x - y) - } - - return -} - -// Converts the given color to CIE xyY space using D65 as reference white. -// (Note that the reference white is only used for black input.) -// x, y and Y are in [0..1] -func (col Color) Xyy() (x, y, Y float64) { - return XyzToXyy(col.Xyz()) -} - -// Converts the given color to CIE xyY space, taking into account -// a given reference white. (i.e. the monitor's white) -// (Note that the reference white is only used for black input.) -// x, y and Y are in [0..1] -func (col Color) XyyWhiteRef(wref [3]float64) (x, y, Y float64) { - X, Y2, Z := col.Xyz() - return XyzToXyyWhiteRef(X, Y2, Z, wref) -} - -// Generates a color by using data given in CIE xyY space. -// x, y and Y are in [0..1] -func Xyy(x, y, Y float64) Color { - return Xyz(XyyToXyz(x, y, Y)) -} - -/// L*a*b* /// -////////////// -// http://en.wikipedia.org/wiki/Lab_color_space#CIELAB-CIEXYZ_conversions -// For L*a*b*, we need to L*a*b*<->XYZ->RGB and the first one is device dependent. - -func lab_f(t float64) float64 { - if t > 6.0/29.0*6.0/29.0*6.0/29.0 { - return math.Cbrt(t) - } - return t/3.0*29.0/6.0*29.0/6.0 + 4.0/29.0 -} - -func XyzToLab(x, y, z float64) (l, a, b float64) { - // Use D65 white as reference point by default. - // http://www.fredmiranda.com/forum/topic/1035332 - // http://en.wikipedia.org/wiki/Standard_illuminant - return XyzToLabWhiteRef(x, y, z, D65) -} - -func XyzToLabWhiteRef(x, y, z float64, wref [3]float64) (l, a, b float64) { - fy := lab_f(y / wref[1]) - l = 1.16*fy - 0.16 - a = 5.0 * (lab_f(x/wref[0]) - fy) - b = 2.0 * (fy - lab_f(z/wref[2])) - return -} - -func lab_finv(t float64) float64 { - if t > 6.0/29.0 { - return t * t * t - } - return 3.0 * 6.0 / 29.0 * 6.0 / 29.0 * (t - 4.0/29.0) -} - -func LabToXyz(l, a, b float64) (x, y, z float64) { - // D65 white (see above). - return LabToXyzWhiteRef(l, a, b, D65) -} - -func LabToXyzWhiteRef(l, a, b float64, wref [3]float64) (x, y, z float64) { - l2 := (l + 0.16) / 1.16 - x = wref[0] * lab_finv(l2+a/5.0) - y = wref[1] * lab_finv(l2) - z = wref[2] * lab_finv(l2-b/2.0) - return -} - -// Converts the given color to CIE L*a*b* space using D65 as reference white. -func (col Color) Lab() (l, a, b float64) { - return XyzToLab(col.Xyz()) -} - -// Converts the given color to CIE L*a*b* space, taking into account -// a given reference white. (i.e. the monitor's white) -func (col Color) LabWhiteRef(wref [3]float64) (l, a, b float64) { - x, y, z := col.Xyz() - return XyzToLabWhiteRef(x, y, z, wref) -} - -// Generates a color by using data given in CIE L*a*b* space using D65 as reference white. -// WARNING: many combinations of `l`, `a`, and `b` values do not have corresponding -// valid RGB values, check the FAQ in the README if you're unsure. -func Lab(l, a, b float64) Color { - return Xyz(LabToXyz(l, a, b)) -} - -// Generates a color by using data given in CIE L*a*b* space, taking -// into account a given reference white. (i.e. the monitor's white) -func LabWhiteRef(l, a, b float64, wref [3]float64) Color { - return Xyz(LabToXyzWhiteRef(l, a, b, wref)) -} - -// DistanceLab is a good measure of visual similarity between two colors! -// A result of 0 would mean identical colors, while a result of 1 or higher -// means the colors differ a lot. -func (c1 Color) DistanceLab(c2 Color) float64 { - l1, a1, b1 := c1.Lab() - l2, a2, b2 := c2.Lab() - return math.Sqrt(sq(l1-l2) + sq(a1-a2) + sq(b1-b2)) -} - -// That's actually the same, but I don't want to break code. -func (c1 Color) DistanceCIE76(c2 Color) float64 { - return c1.DistanceLab(c2) -} - -// Uses the CIE94 formula to calculate color distance. More accurate than -// DistanceLab, but also more work. -func (cl Color) DistanceCIE94(cr Color) float64 { - l1, a1, b1 := cl.Lab() - l2, a2, b2 := cr.Lab() - - // NOTE: Since all those formulas expect L,a,b values 100x larger than we - // have them in this library, we either need to adjust all constants - // in the formula, or convert the ranges of L,a,b before, and then - // scale the distances down again. The latter is less error-prone. - l1, a1, b1 = l1*100.0, a1*100.0, b1*100.0 - l2, a2, b2 = l2*100.0, a2*100.0, b2*100.0 - - kl := 1.0 // 2.0 for textiles - kc := 1.0 - kh := 1.0 - k1 := 0.045 // 0.048 for textiles - k2 := 0.015 // 0.014 for textiles. - - deltaL := l1 - l2 - c1 := math.Sqrt(sq(a1) + sq(b1)) - c2 := math.Sqrt(sq(a2) + sq(b2)) - deltaCab := c1 - c2 - - // Not taking Sqrt here for stability, and it's unnecessary. - deltaHab2 := sq(a1-a2) + sq(b1-b2) - sq(deltaCab) - sl := 1.0 - sc := 1.0 + k1*c1 - sh := 1.0 + k2*c1 - - vL2 := sq(deltaL / (kl * sl)) - vC2 := sq(deltaCab / (kc * sc)) - vH2 := deltaHab2 / sq(kh*sh) - - return math.Sqrt(vL2+vC2+vH2) * 0.01 // See above. -} - -// BlendLab blends two colors in the L*a*b* color-space, which should result in a smoother blend. -// t == 0 results in c1, t == 1 results in c2 -func (c1 Color) BlendLab(c2 Color, t float64) Color { - l1, a1, b1 := c1.Lab() - l2, a2, b2 := c2.Lab() - return Lab(l1+t*(l2-l1), - a1+t*(a2-a1), - b1+t*(b2-b1)) -} - -/// L*u*v* /// -////////////// -// http://en.wikipedia.org/wiki/CIELUV#XYZ_.E2.86.92_CIELUV_and_CIELUV_.E2.86.92_XYZ_conversions -// For L*u*v*, we need to L*u*v*<->XYZ<->RGB and the first one is device dependent. - -func XyzToLuv(x, y, z float64) (l, a, b float64) { - // Use D65 white as reference point by default. - // http://www.fredmiranda.com/forum/topic/1035332 - // http://en.wikipedia.org/wiki/Standard_illuminant - return XyzToLuvWhiteRef(x, y, z, D65) -} - -func XyzToLuvWhiteRef(x, y, z float64, wref [3]float64) (l, u, v float64) { - if y/wref[1] <= 6.0/29.0*6.0/29.0*6.0/29.0 { - l = y / wref[1] * 29.0 / 3.0 * 29.0 / 3.0 * 29.0 / 3.0 - } else { - l = 1.16*math.Cbrt(y/wref[1]) - 0.16 - } - ubis, vbis := xyz_to_uv(x, y, z) - un, vn := xyz_to_uv(wref[0], wref[1], wref[2]) - u = 13.0 * l * (ubis - un) - v = 13.0 * l * (vbis - vn) - return -} - -// For this part, we do as R's graphics.hcl does, not as wikipedia does. -// Or is it the same? -func xyz_to_uv(x, y, z float64) (u, v float64) { - denom := x + 15.0*y + 3.0*z - if denom == 0.0 { - u, v = 0.0, 0.0 - } else { - u = 4.0 * x / denom - v = 9.0 * y / denom - } - return -} - -func LuvToXyz(l, u, v float64) (x, y, z float64) { - // D65 white (see above). - return LuvToXyzWhiteRef(l, u, v, D65) -} - -func LuvToXyzWhiteRef(l, u, v float64, wref [3]float64) (x, y, z float64) { - //y = wref[1] * lab_finv((l + 0.16) / 1.16) - if l <= 0.08 { - y = wref[1] * l * 100.0 * 3.0 / 29.0 * 3.0 / 29.0 * 3.0 / 29.0 - } else { - y = wref[1] * cub((l+0.16)/1.16) - } - un, vn := xyz_to_uv(wref[0], wref[1], wref[2]) - if l != 0.0 { - ubis := u/(13.0*l) + un - vbis := v/(13.0*l) + vn - x = y * 9.0 * ubis / (4.0 * vbis) - z = y * (12.0 - 3.0*ubis - 20.0*vbis) / (4.0 * vbis) - } else { - x, y = 0.0, 0.0 - } - return -} - -// Converts the given color to CIE L*u*v* space using D65 as reference white. -// L* is in [0..1] and both u* and v* are in about [-1..1] -func (col Color) Luv() (l, u, v float64) { - return XyzToLuv(col.Xyz()) -} - -// Converts the given color to CIE L*u*v* space, taking into account -// a given reference white. (i.e. the monitor's white) -// L* is in [0..1] and both u* and v* are in about [-1..1] -func (col Color) LuvWhiteRef(wref [3]float64) (l, u, v float64) { - x, y, z := col.Xyz() - return XyzToLuvWhiteRef(x, y, z, wref) -} - -// Generates a color by using data given in CIE L*u*v* space using D65 as reference white. -// L* is in [0..1] and both u* and v* are in about [-1..1] -// WARNING: many combinations of `l`, `a`, and `b` values do not have corresponding -// valid RGB values, check the FAQ in the README if you're unsure. -func Luv(l, u, v float64) Color { - return Xyz(LuvToXyz(l, u, v)) -} - -// Generates a color by using data given in CIE L*u*v* space, taking -// into account a given reference white. (i.e. the monitor's white) -// L* is in [0..1] and both u* and v* are in about [-1..1] -func LuvWhiteRef(l, u, v float64, wref [3]float64) Color { - return Xyz(LuvToXyzWhiteRef(l, u, v, wref)) -} - -// DistanceLuv is a good measure of visual similarity between two colors! -// A result of 0 would mean identical colors, while a result of 1 or higher -// means the colors differ a lot. -func (c1 Color) DistanceLuv(c2 Color) float64 { - l1, u1, v1 := c1.Luv() - l2, u2, v2 := c2.Luv() - return math.Sqrt(sq(l1-l2) + sq(u1-u2) + sq(v1-v2)) -} - -// BlendLuv blends two colors in the CIE-L*u*v* color-space, which should result in a smoother blend. -// t == 0 results in c1, t == 1 results in c2 -func (c1 Color) BlendLuv(c2 Color, t float64) Color { - l1, u1, v1 := c1.Luv() - l2, u2, v2 := c2.Luv() - return Luv(l1+t*(l2-l1), - u1+t*(u2-u1), - v1+t*(v2-v1)) -} - -/// HCL /// -/////////// -// HCL is nothing else than L*a*b* in cylindrical coordinates! -// (this was wrong on English wikipedia, I fixed it, let's hope the fix stays.) -// But it is widely popular since it is a "correct HSV" -// http://www.hunterlab.com/appnotes/an09_96a.pdf - -// Converts the given color to HCL space using D65 as reference white. -// H values are in [0..360], C and L values are in [0..1] although C can overshoot 1.0 -func (col Color) Hcl() (h, c, l float64) { - return col.HclWhiteRef(D65) -} - -func LabToHcl(L, a, b float64) (h, c, l float64) { - // Oops, floating point workaround necessary if a ~= b and both are very small (i.e. almost zero). - if math.Abs(b-a) > 1e-4 && math.Abs(a) > 1e-4 { - h = math.Mod(57.29577951308232087721*math.Atan2(b, a)+360.0, 360.0) // Rad2Deg - } else { - h = 0.0 - } - c = math.Sqrt(sq(a) + sq(b)) - l = L - return -} - -// Converts the given color to HCL space, taking into account -// a given reference white. (i.e. the monitor's white) -// H values are in [0..360], C and L values are in [0..1] -func (col Color) HclWhiteRef(wref [3]float64) (h, c, l float64) { - L, a, b := col.LabWhiteRef(wref) - return LabToHcl(L, a, b) -} - -// Generates a color by using data given in HCL space using D65 as reference white. -// H values are in [0..360], C and L values are in [0..1] -// WARNING: many combinations of `l`, `a`, and `b` values do not have corresponding -// valid RGB values, check the FAQ in the README if you're unsure. -func Hcl(h, c, l float64) Color { - return HclWhiteRef(h, c, l, D65) -} - -func HclToLab(h, c, l float64) (L, a, b float64) { - H := 0.01745329251994329576 * h // Deg2Rad - a = c * math.Cos(H) - b = c * math.Sin(H) - L = l - return -} - -// Generates a color by using data given in HCL space, taking -// into account a given reference white. (i.e. the monitor's white) -// H values are in [0..360], C and L values are in [0..1] -func HclWhiteRef(h, c, l float64, wref [3]float64) Color { - L, a, b := HclToLab(h, c, l) - return LabWhiteRef(L, a, b, wref) -} - -// BlendHcl blends two colors in the CIE-L*C*h° color-space, which should result in a smoother blend. -// t == 0 results in c1, t == 1 results in c2 -func (col1 Color) BlendHcl(col2 Color, t float64) Color { - h1, c1, l1 := col1.Hcl() - h2, c2, l2 := col2.Hcl() - - // We know that h are both in [0..360] - return Hcl(interp_angle(h1, h2, t), c1+t*(c2-c1), l1+t*(l2-l1)) -} diff --git a/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go b/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go deleted file mode 100644 index bb66dfa..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/happy_palettegen.go +++ /dev/null @@ -1,25 +0,0 @@ -package colorful - -import ( - "math/rand" -) - -// Uses the HSV color space to generate colors with similar S,V but distributed -// evenly along their Hue. This is fast but not always pretty. -// If you've got time to spare, use Lab (the non-fast below). -func FastHappyPalette(colorsCount int) (colors []Color) { - colors = make([]Color, colorsCount) - - for i := 0; i < colorsCount; i++ { - colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.8+rand.Float64()*0.2, 0.65+rand.Float64()*0.2) - } - return -} - -func HappyPalette(colorsCount int) ([]Color, error) { - pimpy := func(l, a, b float64) bool { - _, c, _ := LabToHcl(l, a, b) - return 0.3 <= c && 0.4 <= l && l <= 0.8 - } - return SoftPaletteEx(colorsCount, SoftPaletteSettings{pimpy, 50, true}) -} diff --git a/vendor/github.com/lucasb-eyer/go-colorful/hexcolor.go b/vendor/github.com/lucasb-eyer/go-colorful/hexcolor.go deleted file mode 100644 index 86a5ed9..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/hexcolor.go +++ /dev/null @@ -1,37 +0,0 @@ -package colorful - -import ( - "database/sql/driver" - "fmt" - "reflect" -) - -// A HexColor is a Color stored as a hex string "#rrggbb". It implements the -// database/sql.Scanner and database/sql/driver.Value interfaces. -type HexColor Color - -type errUnsupportedType struct { - got interface{} - want reflect.Type -} - -func (hc *HexColor) Scan(value interface{}) error { - s, ok := value.(string) - if !ok { - return errUnsupportedType{got: reflect.TypeOf(value), want: reflect.TypeOf("")} - } - c, err := Hex(s) - if err != nil { - return err - } - *hc = HexColor(c) - return nil -} - -func (hc *HexColor) Value() (driver.Value, error) { - return Color(*hc).Hex(), nil -} - -func (e errUnsupportedType) Error() string { - return fmt.Sprintf("unsupported type: got %v, want a %s", e.got, e.want) -} diff --git a/vendor/github.com/lucasb-eyer/go-colorful/soft_palettegen.go b/vendor/github.com/lucasb-eyer/go-colorful/soft_palettegen.go deleted file mode 100644 index 0154ac9..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/soft_palettegen.go +++ /dev/null @@ -1,185 +0,0 @@ -// Largely inspired by the descriptions in http://lab.medialab.sciences-po.fr/iwanthue/ -// but written from scratch. - -package colorful - -import ( - "fmt" - "math" - "math/rand" -) - -// The algorithm works in L*a*b* color space and converts to RGB in the end. -// L* in [0..1], a* and b* in [-1..1] -type lab_t struct { - L, A, B float64 -} - -type SoftPaletteSettings struct { - // A function which can be used to restrict the allowed color-space. - CheckColor func(l, a, b float64) bool - - // The higher, the better quality but the slower. Usually two figures. - Iterations int - - // Use up to 160000 or 8000 samples of the L*a*b* space (and thus calls to CheckColor). - // Set this to true only if your CheckColor shapes the Lab space weirdly. - ManySamples bool -} - -// Yeah, windows-stype Foo, FooEx, screw you golang... -// Uses K-means to cluster the color-space and return the means of the clusters -// as a new palette of distinctive colors. Falls back to K-medoid if the mean -// happens to fall outside of the color-space, which can only happen if you -// specify a CheckColor function. -func SoftPaletteEx(colorsCount int, settings SoftPaletteSettings) ([]Color, error) { - - // Checks whether it's a valid RGB and also fulfills the potentially provided constraint. - check := func(col lab_t) bool { - c := Lab(col.L, col.A, col.B) - return c.IsValid() && (settings.CheckColor == nil || settings.CheckColor(col.L, col.A, col.B)) - } - - // Sample the color space. These will be the points k-means is run on. - dl := 0.05 - dab := 0.1 - if settings.ManySamples { - dl = 0.01 - dab = 0.05 - } - - samples := make([]lab_t, 0, int(1.0/dl*2.0/dab*2.0/dab)) - for l := 0.0; l <= 1.0; l += dl { - for a := -1.0; a <= 1.0; a += dab { - for b := -1.0; b <= 1.0; b += dab { - if check(lab_t{l, a, b}) { - samples = append(samples, lab_t{l, a, b}) - } - } - } - } - - // That would cause some infinite loops down there... - if len(samples) < colorsCount { - return nil, fmt.Errorf("palettegen: more colors requested (%v) than samples available (%v). Your requested color count may be wrong, you might want to use many samples or your constraint function makes the valid color space too small.", colorsCount, len(samples)) - } else if len(samples) == colorsCount { - return labs2cols(samples), nil // Oops? - } - - // We take the initial means out of the samples, so they are in fact medoids. - // This helps us avoid infinite loops or arbitrary cutoffs with too restrictive constraints. - means := make([]lab_t, colorsCount) - for i := 0; i < colorsCount; i++ { - for means[i] = samples[rand.Intn(len(samples))]; in(means, i, means[i]); means[i] = samples[rand.Intn(len(samples))] { - } - } - - clusters := make([]int, len(samples)) - samples_used := make([]bool, len(samples)) - - // The actual k-means/medoid iterations - for i := 0; i < settings.Iterations; i++ { - // Reassing the samples to clusters, i.e. to their closest mean. - // By the way, also check if any sample is used as a medoid and if so, mark that. - for isample, sample := range samples { - samples_used[isample] = false - mindist := math.Inf(+1) - for imean, mean := range means { - dist := lab_dist(sample, mean) - if dist < mindist { - mindist = dist - clusters[isample] = imean - } - - // Mark samples which are used as a medoid. - if lab_eq(sample, mean) { - samples_used[isample] = true - } - } - } - - // Compute new means according to the samples. - for imean := range means { - // The new mean is the average of all samples belonging to it.. - nsamples := 0 - newmean := lab_t{0.0, 0.0, 0.0} - for isample, sample := range samples { - if clusters[isample] == imean { - nsamples++ - newmean.L += sample.L - newmean.A += sample.A - newmean.B += sample.B - } - } - if nsamples > 0 { - newmean.L /= float64(nsamples) - newmean.A /= float64(nsamples) - newmean.B /= float64(nsamples) - } else { - // That mean doesn't have any samples? Get a new mean from the sample list! - var inewmean int - for inewmean = rand.Intn(len(samples_used)); samples_used[inewmean]; inewmean = rand.Intn(len(samples_used)) { - } - newmean = samples[inewmean] - samples_used[inewmean] = true - } - - // But now we still need to check whether the new mean is an allowed color. - if nsamples > 0 && check(newmean) { - // It does, life's good (TM) - means[imean] = newmean - } else { - // New mean isn't an allowed color or doesn't have any samples! - // Switch to medoid mode and pick the closest (unused) sample. - // This should always find something thanks to len(samples) >= colorsCount - mindist := math.Inf(+1) - for isample, sample := range samples { - if !samples_used[isample] { - dist := lab_dist(sample, newmean) - if dist < mindist { - mindist = dist - newmean = sample - } - } - } - } - } - } - return labs2cols(means), nil -} - -// A wrapper which uses common parameters. -func SoftPalette(colorsCount int) ([]Color, error) { - return SoftPaletteEx(colorsCount, SoftPaletteSettings{nil, 50, false}) -} - -func in(haystack []lab_t, upto int, needle lab_t) bool { - for i := 0; i < upto && i < len(haystack); i++ { - if haystack[i] == needle { - return true - } - } - return false -} - -const LAB_DELTA = 1e-6 - -func lab_eq(lab1, lab2 lab_t) bool { - return math.Abs(lab1.L-lab2.L) < LAB_DELTA && - math.Abs(lab1.A-lab2.A) < LAB_DELTA && - math.Abs(lab1.B-lab2.B) < LAB_DELTA -} - -// That's faster than using colorful's DistanceLab since we would have to -// convert back and forth for that. Here is no conversion. -func lab_dist(lab1, lab2 lab_t) float64 { - return math.Sqrt(sq(lab1.L-lab2.L) + sq(lab1.A-lab2.A) + sq(lab1.B-lab2.B)) -} - -func labs2cols(labs []lab_t) (cols []Color) { - cols = make([]Color, len(labs)) - for k, v := range labs { - cols[k] = Lab(v.L, v.A, v.B) - } - return cols -} diff --git a/vendor/github.com/lucasb-eyer/go-colorful/warm_palettegen.go b/vendor/github.com/lucasb-eyer/go-colorful/warm_palettegen.go deleted file mode 100644 index 00f42a5..0000000 --- a/vendor/github.com/lucasb-eyer/go-colorful/warm_palettegen.go +++ /dev/null @@ -1,25 +0,0 @@ -package colorful - -import ( - "math/rand" -) - -// Uses the HSV color space to generate colors with similar S,V but distributed -// evenly along their Hue. This is fast but not always pretty. -// If you've got time to spare, use Lab (the non-fast below). -func FastWarmPalette(colorsCount int) (colors []Color) { - colors = make([]Color, colorsCount) - - for i := 0; i < colorsCount; i++ { - colors[i] = Hsv(float64(i)*(360.0/float64(colorsCount)), 0.55+rand.Float64()*0.2, 0.35+rand.Float64()*0.2) - } - return -} - -func WarmPalette(colorsCount int) ([]Color, error) { - warmy := func(l, a, b float64) bool { - _, c, _ := LabToHcl(l, a, b) - return 0.1 <= c && c <= 0.4 && 0.2 <= l && l <= 0.5 - } - return SoftPaletteEx(colorsCount, SoftPaletteSettings{warmy, 50, true}) -} diff --git a/vendor/github.com/mattn/go-runewidth/.travis.yml b/vendor/github.com/mattn/go-runewidth/.travis.yml deleted file mode 100644 index 5c9c2a3..0000000 --- a/vendor/github.com/mattn/go-runewidth/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go -go: - - tip -before_install: - - go get github.com/mattn/goveralls - - go get golang.org/x/tools/cmd/cover -script: - - $HOME/gopath/bin/goveralls -repotoken lAKAWPzcGsD3A8yBX3BGGtRUdJ6CaGERL diff --git a/vendor/github.com/mattn/go-runewidth/LICENSE b/vendor/github.com/mattn/go-runewidth/LICENSE deleted file mode 100644 index 91b5cef..0000000 --- a/vendor/github.com/mattn/go-runewidth/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Yasuhiro Matsumoto - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/mattn/go-runewidth/README.mkd b/vendor/github.com/mattn/go-runewidth/README.mkd deleted file mode 100644 index 66663a9..0000000 --- a/vendor/github.com/mattn/go-runewidth/README.mkd +++ /dev/null @@ -1,27 +0,0 @@ -go-runewidth -============ - -[![Build Status](https://travis-ci.org/mattn/go-runewidth.png?branch=master)](https://travis-ci.org/mattn/go-runewidth) -[![Coverage Status](https://coveralls.io/repos/mattn/go-runewidth/badge.png?branch=HEAD)](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD) -[![GoDoc](https://godoc.org/github.com/mattn/go-runewidth?status.svg)](http://godoc.org/github.com/mattn/go-runewidth) -[![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-runewidth)](https://goreportcard.com/report/github.com/mattn/go-runewidth) - -Provides functions to get fixed width of the character or string. - -Usage ------ - -```go -runewidth.StringWidth("つのだ☆HIRO") == 12 -``` - - -Author ------- - -Yasuhiro Matsumoto - -License -------- - -under the MIT License: http://mattn.mit-license.org/2013 diff --git a/vendor/github.com/mattn/go-runewidth/runewidth.go b/vendor/github.com/mattn/go-runewidth/runewidth.go deleted file mode 100644 index 82568a1..0000000 --- a/vendor/github.com/mattn/go-runewidth/runewidth.go +++ /dev/null @@ -1,1235 +0,0 @@ -package runewidth - -import "os" - -var ( - // EastAsianWidth will be set true if the current locale is CJK - EastAsianWidth bool - - // DefaultCondition is a condition in current locale - DefaultCondition = &Condition{EastAsianWidth} -) - -func init() { - env := os.Getenv("RUNEWIDTH_EASTASIAN") - if env == "" { - EastAsianWidth = IsEastAsian() - } else { - EastAsianWidth = env == "1" - } -} - -type interval struct { - first rune - last rune -} - -type table []interval - -func inTables(r rune, ts ...table) bool { - for _, t := range ts { - if inTable(r, t) { - return true - } - } - return false -} - -func inTable(r rune, t table) bool { - // func (t table) IncludesRune(r rune) bool { - if r < t[0].first { - return false - } - - bot := 0 - top := len(t) - 1 - for top >= bot { - mid := (bot + top) / 2 - - switch { - case t[mid].last < r: - bot = mid + 1 - case t[mid].first > r: - top = mid - 1 - default: - return true - } - } - - return false -} - -var private = table{ - {0x00E000, 0x00F8FF}, {0x0F0000, 0x0FFFFD}, {0x100000, 0x10FFFD}, -} - -var nonprint = table{ - {0x0000, 0x001F}, {0x007F, 0x009F}, {0x00AD, 0x00AD}, - {0x070F, 0x070F}, {0x180B, 0x180E}, {0x200B, 0x200F}, - {0x2028, 0x2029}, - {0x202A, 0x202E}, {0x206A, 0x206F}, {0xD800, 0xDFFF}, - {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0xFFFE, 0xFFFF}, -} - -var combining = table{ - {0x0300, 0x036F}, {0x0483, 0x0489}, {0x0591, 0x05BD}, - {0x05BF, 0x05BF}, {0x05C1, 0x05C2}, {0x05C4, 0x05C5}, - {0x05C7, 0x05C7}, {0x0610, 0x061A}, {0x064B, 0x065F}, - {0x0670, 0x0670}, {0x06D6, 0x06DC}, {0x06DF, 0x06E4}, - {0x06E7, 0x06E8}, {0x06EA, 0x06ED}, {0x0711, 0x0711}, - {0x0730, 0x074A}, {0x07A6, 0x07B0}, {0x07EB, 0x07F3}, - {0x0816, 0x0819}, {0x081B, 0x0823}, {0x0825, 0x0827}, - {0x0829, 0x082D}, {0x0859, 0x085B}, {0x08D4, 0x08E1}, - {0x08E3, 0x0903}, {0x093A, 0x093C}, {0x093E, 0x094F}, - {0x0951, 0x0957}, {0x0962, 0x0963}, {0x0981, 0x0983}, - {0x09BC, 0x09BC}, {0x09BE, 0x09C4}, {0x09C7, 0x09C8}, - {0x09CB, 0x09CD}, {0x09D7, 0x09D7}, {0x09E2, 0x09E3}, - {0x0A01, 0x0A03}, {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A42}, - {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51}, - {0x0A70, 0x0A71}, {0x0A75, 0x0A75}, {0x0A81, 0x0A83}, - {0x0ABC, 0x0ABC}, {0x0ABE, 0x0AC5}, {0x0AC7, 0x0AC9}, - {0x0ACB, 0x0ACD}, {0x0AE2, 0x0AE3}, {0x0B01, 0x0B03}, - {0x0B3C, 0x0B3C}, {0x0B3E, 0x0B44}, {0x0B47, 0x0B48}, - {0x0B4B, 0x0B4D}, {0x0B56, 0x0B57}, {0x0B62, 0x0B63}, - {0x0B82, 0x0B82}, {0x0BBE, 0x0BC2}, {0x0BC6, 0x0BC8}, - {0x0BCA, 0x0BCD}, {0x0BD7, 0x0BD7}, {0x0C00, 0x0C03}, - {0x0C3E, 0x0C44}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, - {0x0C55, 0x0C56}, {0x0C62, 0x0C63}, {0x0C81, 0x0C83}, - {0x0CBC, 0x0CBC}, {0x0CBE, 0x0CC4}, {0x0CC6, 0x0CC8}, - {0x0CCA, 0x0CCD}, {0x0CD5, 0x0CD6}, {0x0CE2, 0x0CE3}, - {0x0D01, 0x0D03}, {0x0D3E, 0x0D44}, {0x0D46, 0x0D48}, - {0x0D4A, 0x0D4D}, {0x0D57, 0x0D57}, {0x0D62, 0x0D63}, - {0x0D82, 0x0D83}, {0x0DCA, 0x0DCA}, {0x0DCF, 0x0DD4}, - {0x0DD6, 0x0DD6}, {0x0DD8, 0x0DDF}, {0x0DF2, 0x0DF3}, - {0x0E31, 0x0E31}, {0x0E34, 0x0E3A}, {0x0E47, 0x0E4E}, - {0x0EB1, 0x0EB1}, {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC}, - {0x0EC8, 0x0ECD}, {0x0F18, 0x0F19}, {0x0F35, 0x0F35}, - {0x0F37, 0x0F37}, {0x0F39, 0x0F39}, {0x0F3E, 0x0F3F}, - {0x0F71, 0x0F84}, {0x0F86, 0x0F87}, {0x0F8D, 0x0F97}, - {0x0F99, 0x0FBC}, {0x0FC6, 0x0FC6}, {0x102B, 0x103E}, - {0x1056, 0x1059}, {0x105E, 0x1060}, {0x1062, 0x1064}, - {0x1067, 0x106D}, {0x1071, 0x1074}, {0x1082, 0x108D}, - {0x108F, 0x108F}, {0x109A, 0x109D}, {0x135D, 0x135F}, - {0x1712, 0x1714}, {0x1732, 0x1734}, {0x1752, 0x1753}, - {0x1772, 0x1773}, {0x17B4, 0x17D3}, {0x17DD, 0x17DD}, - {0x180B, 0x180D}, {0x1885, 0x1886}, {0x18A9, 0x18A9}, - {0x1920, 0x192B}, {0x1930, 0x193B}, {0x1A17, 0x1A1B}, - {0x1A55, 0x1A5E}, {0x1A60, 0x1A7C}, {0x1A7F, 0x1A7F}, - {0x1AB0, 0x1ABE}, {0x1B00, 0x1B04}, {0x1B34, 0x1B44}, - {0x1B6B, 0x1B73}, {0x1B80, 0x1B82}, {0x1BA1, 0x1BAD}, - {0x1BE6, 0x1BF3}, {0x1C24, 0x1C37}, {0x1CD0, 0x1CD2}, - {0x1CD4, 0x1CE8}, {0x1CED, 0x1CED}, {0x1CF2, 0x1CF4}, - {0x1CF8, 0x1CF9}, {0x1DC0, 0x1DF5}, {0x1DFB, 0x1DFF}, - {0x20D0, 0x20F0}, {0x2CEF, 0x2CF1}, {0x2D7F, 0x2D7F}, - {0x2DE0, 0x2DFF}, {0x302A, 0x302F}, {0x3099, 0x309A}, - {0xA66F, 0xA672}, {0xA674, 0xA67D}, {0xA69E, 0xA69F}, - {0xA6F0, 0xA6F1}, {0xA802, 0xA802}, {0xA806, 0xA806}, - {0xA80B, 0xA80B}, {0xA823, 0xA827}, {0xA880, 0xA881}, - {0xA8B4, 0xA8C5}, {0xA8E0, 0xA8F1}, {0xA926, 0xA92D}, - {0xA947, 0xA953}, {0xA980, 0xA983}, {0xA9B3, 0xA9C0}, - {0xA9E5, 0xA9E5}, {0xAA29, 0xAA36}, {0xAA43, 0xAA43}, - {0xAA4C, 0xAA4D}, {0xAA7B, 0xAA7D}, {0xAAB0, 0xAAB0}, - {0xAAB2, 0xAAB4}, {0xAAB7, 0xAAB8}, {0xAABE, 0xAABF}, - {0xAAC1, 0xAAC1}, {0xAAEB, 0xAAEF}, {0xAAF5, 0xAAF6}, - {0xABE3, 0xABEA}, {0xABEC, 0xABED}, {0xFB1E, 0xFB1E}, - {0xFE00, 0xFE0F}, {0xFE20, 0xFE2F}, {0x101FD, 0x101FD}, - {0x102E0, 0x102E0}, {0x10376, 0x1037A}, {0x10A01, 0x10A03}, - {0x10A05, 0x10A06}, {0x10A0C, 0x10A0F}, {0x10A38, 0x10A3A}, - {0x10A3F, 0x10A3F}, {0x10AE5, 0x10AE6}, {0x11000, 0x11002}, - {0x11038, 0x11046}, {0x1107F, 0x11082}, {0x110B0, 0x110BA}, - {0x11100, 0x11102}, {0x11127, 0x11134}, {0x11173, 0x11173}, - {0x11180, 0x11182}, {0x111B3, 0x111C0}, {0x111CA, 0x111CC}, - {0x1122C, 0x11237}, {0x1123E, 0x1123E}, {0x112DF, 0x112EA}, - {0x11300, 0x11303}, {0x1133C, 0x1133C}, {0x1133E, 0x11344}, - {0x11347, 0x11348}, {0x1134B, 0x1134D}, {0x11357, 0x11357}, - {0x11362, 0x11363}, {0x11366, 0x1136C}, {0x11370, 0x11374}, - {0x11435, 0x11446}, {0x114B0, 0x114C3}, {0x115AF, 0x115B5}, - {0x115B8, 0x115C0}, {0x115DC, 0x115DD}, {0x11630, 0x11640}, - {0x116AB, 0x116B7}, {0x1171D, 0x1172B}, {0x11C2F, 0x11C36}, - {0x11C38, 0x11C3F}, {0x11C92, 0x11CA7}, {0x11CA9, 0x11CB6}, - {0x16AF0, 0x16AF4}, {0x16B30, 0x16B36}, {0x16F51, 0x16F7E}, - {0x16F8F, 0x16F92}, {0x1BC9D, 0x1BC9E}, {0x1D165, 0x1D169}, - {0x1D16D, 0x1D172}, {0x1D17B, 0x1D182}, {0x1D185, 0x1D18B}, - {0x1D1AA, 0x1D1AD}, {0x1D242, 0x1D244}, {0x1DA00, 0x1DA36}, - {0x1DA3B, 0x1DA6C}, {0x1DA75, 0x1DA75}, {0x1DA84, 0x1DA84}, - {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF}, {0x1E000, 0x1E006}, - {0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, {0x1E023, 0x1E024}, - {0x1E026, 0x1E02A}, {0x1E8D0, 0x1E8D6}, {0x1E944, 0x1E94A}, - {0xE0100, 0xE01EF}, -} - -var doublewidth = table{ - {0x1100, 0x115F}, {0x231A, 0x231B}, {0x2329, 0x232A}, - {0x23E9, 0x23EC}, {0x23F0, 0x23F0}, {0x23F3, 0x23F3}, - {0x25FD, 0x25FE}, {0x2614, 0x2615}, {0x2648, 0x2653}, - {0x267F, 0x267F}, {0x2693, 0x2693}, {0x26A1, 0x26A1}, - {0x26AA, 0x26AB}, {0x26BD, 0x26BE}, {0x26C4, 0x26C5}, - {0x26CE, 0x26CE}, {0x26D4, 0x26D4}, {0x26EA, 0x26EA}, - {0x26F2, 0x26F3}, {0x26F5, 0x26F5}, {0x26FA, 0x26FA}, - {0x26FD, 0x26FD}, {0x2705, 0x2705}, {0x270A, 0x270B}, - {0x2728, 0x2728}, {0x274C, 0x274C}, {0x274E, 0x274E}, - {0x2753, 0x2755}, {0x2757, 0x2757}, {0x2795, 0x2797}, - {0x27B0, 0x27B0}, {0x27BF, 0x27BF}, {0x2B1B, 0x2B1C}, - {0x2B50, 0x2B50}, {0x2B55, 0x2B55}, {0x2E80, 0x2E99}, - {0x2E9B, 0x2EF3}, {0x2F00, 0x2FD5}, {0x2FF0, 0x2FFB}, - {0x3000, 0x303E}, {0x3041, 0x3096}, {0x3099, 0x30FF}, - {0x3105, 0x312D}, {0x3131, 0x318E}, {0x3190, 0x31BA}, - {0x31C0, 0x31E3}, {0x31F0, 0x321E}, {0x3220, 0x3247}, - {0x3250, 0x32FE}, {0x3300, 0x4DBF}, {0x4E00, 0xA48C}, - {0xA490, 0xA4C6}, {0xA960, 0xA97C}, {0xAC00, 0xD7A3}, - {0xF900, 0xFAFF}, {0xFE10, 0xFE19}, {0xFE30, 0xFE52}, - {0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, {0xFF01, 0xFF60}, - {0xFFE0, 0xFFE6}, {0x16FE0, 0x16FE0}, {0x17000, 0x187EC}, - {0x18800, 0x18AF2}, {0x1B000, 0x1B001}, {0x1F004, 0x1F004}, - {0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A}, - {0x1F200, 0x1F202}, {0x1F210, 0x1F23B}, {0x1F240, 0x1F248}, - {0x1F250, 0x1F251}, {0x1F300, 0x1F320}, {0x1F32D, 0x1F335}, - {0x1F337, 0x1F37C}, {0x1F37E, 0x1F393}, {0x1F3A0, 0x1F3CA}, - {0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0}, {0x1F3F4, 0x1F3F4}, - {0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440}, {0x1F442, 0x1F4FC}, - {0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E}, {0x1F550, 0x1F567}, - {0x1F57A, 0x1F57A}, {0x1F595, 0x1F596}, {0x1F5A4, 0x1F5A4}, - {0x1F5FB, 0x1F64F}, {0x1F680, 0x1F6C5}, {0x1F6CC, 0x1F6CC}, - {0x1F6D0, 0x1F6D2}, {0x1F6EB, 0x1F6EC}, {0x1F6F4, 0x1F6F6}, - {0x1F910, 0x1F91E}, {0x1F920, 0x1F927}, {0x1F930, 0x1F930}, - {0x1F933, 0x1F93E}, {0x1F940, 0x1F94B}, {0x1F950, 0x1F95E}, - {0x1F980, 0x1F991}, {0x1F9C0, 0x1F9C0}, {0x20000, 0x2FFFD}, - {0x30000, 0x3FFFD}, -} - -var ambiguous = table{ - {0x00A1, 0x00A1}, {0x00A4, 0x00A4}, {0x00A7, 0x00A8}, - {0x00AA, 0x00AA}, {0x00AD, 0x00AE}, {0x00B0, 0x00B4}, - {0x00B6, 0x00BA}, {0x00BC, 0x00BF}, {0x00C6, 0x00C6}, - {0x00D0, 0x00D0}, {0x00D7, 0x00D8}, {0x00DE, 0x00E1}, - {0x00E6, 0x00E6}, {0x00E8, 0x00EA}, {0x00EC, 0x00ED}, - {0x00F0, 0x00F0}, {0x00F2, 0x00F3}, {0x00F7, 0x00FA}, - {0x00FC, 0x00FC}, {0x00FE, 0x00FE}, {0x0101, 0x0101}, - {0x0111, 0x0111}, {0x0113, 0x0113}, {0x011B, 0x011B}, - {0x0126, 0x0127}, {0x012B, 0x012B}, {0x0131, 0x0133}, - {0x0138, 0x0138}, {0x013F, 0x0142}, {0x0144, 0x0144}, - {0x0148, 0x014B}, {0x014D, 0x014D}, {0x0152, 0x0153}, - {0x0166, 0x0167}, {0x016B, 0x016B}, {0x01CE, 0x01CE}, - {0x01D0, 0x01D0}, {0x01D2, 0x01D2}, {0x01D4, 0x01D4}, - {0x01D6, 0x01D6}, {0x01D8, 0x01D8}, {0x01DA, 0x01DA}, - {0x01DC, 0x01DC}, {0x0251, 0x0251}, {0x0261, 0x0261}, - {0x02C4, 0x02C4}, {0x02C7, 0x02C7}, {0x02C9, 0x02CB}, - {0x02CD, 0x02CD}, {0x02D0, 0x02D0}, {0x02D8, 0x02DB}, - {0x02DD, 0x02DD}, {0x02DF, 0x02DF}, {0x0300, 0x036F}, - {0x0391, 0x03A1}, {0x03A3, 0x03A9}, {0x03B1, 0x03C1}, - {0x03C3, 0x03C9}, {0x0401, 0x0401}, {0x0410, 0x044F}, - {0x0451, 0x0451}, {0x2010, 0x2010}, {0x2013, 0x2016}, - {0x2018, 0x2019}, {0x201C, 0x201D}, {0x2020, 0x2022}, - {0x2024, 0x2027}, {0x2030, 0x2030}, {0x2032, 0x2033}, - {0x2035, 0x2035}, {0x203B, 0x203B}, {0x203E, 0x203E}, - {0x2074, 0x2074}, {0x207F, 0x207F}, {0x2081, 0x2084}, - {0x20AC, 0x20AC}, {0x2103, 0x2103}, {0x2105, 0x2105}, - {0x2109, 0x2109}, {0x2113, 0x2113}, {0x2116, 0x2116}, - {0x2121, 0x2122}, {0x2126, 0x2126}, {0x212B, 0x212B}, - {0x2153, 0x2154}, {0x215B, 0x215E}, {0x2160, 0x216B}, - {0x2170, 0x2179}, {0x2189, 0x2189}, {0x2190, 0x2199}, - {0x21B8, 0x21B9}, {0x21D2, 0x21D2}, {0x21D4, 0x21D4}, - {0x21E7, 0x21E7}, {0x2200, 0x2200}, {0x2202, 0x2203}, - {0x2207, 0x2208}, {0x220B, 0x220B}, {0x220F, 0x220F}, - {0x2211, 0x2211}, {0x2215, 0x2215}, {0x221A, 0x221A}, - {0x221D, 0x2220}, {0x2223, 0x2223}, {0x2225, 0x2225}, - {0x2227, 0x222C}, {0x222E, 0x222E}, {0x2234, 0x2237}, - {0x223C, 0x223D}, {0x2248, 0x2248}, {0x224C, 0x224C}, - {0x2252, 0x2252}, {0x2260, 0x2261}, {0x2264, 0x2267}, - {0x226A, 0x226B}, {0x226E, 0x226F}, {0x2282, 0x2283}, - {0x2286, 0x2287}, {0x2295, 0x2295}, {0x2299, 0x2299}, - {0x22A5, 0x22A5}, {0x22BF, 0x22BF}, {0x2312, 0x2312}, - {0x2460, 0x24E9}, {0x24EB, 0x254B}, {0x2550, 0x2573}, - {0x2580, 0x258F}, {0x2592, 0x2595}, {0x25A0, 0x25A1}, - {0x25A3, 0x25A9}, {0x25B2, 0x25B3}, {0x25B6, 0x25B7}, - {0x25BC, 0x25BD}, {0x25C0, 0x25C1}, {0x25C6, 0x25C8}, - {0x25CB, 0x25CB}, {0x25CE, 0x25D1}, {0x25E2, 0x25E5}, - {0x25EF, 0x25EF}, {0x2605, 0x2606}, {0x2609, 0x2609}, - {0x260E, 0x260F}, {0x261C, 0x261C}, {0x261E, 0x261E}, - {0x2640, 0x2640}, {0x2642, 0x2642}, {0x2660, 0x2661}, - {0x2663, 0x2665}, {0x2667, 0x266A}, {0x266C, 0x266D}, - {0x266F, 0x266F}, {0x269E, 0x269F}, {0x26BF, 0x26BF}, - {0x26C6, 0x26CD}, {0x26CF, 0x26D3}, {0x26D5, 0x26E1}, - {0x26E3, 0x26E3}, {0x26E8, 0x26E9}, {0x26EB, 0x26F1}, - {0x26F4, 0x26F4}, {0x26F6, 0x26F9}, {0x26FB, 0x26FC}, - {0x26FE, 0x26FF}, {0x273D, 0x273D}, {0x2776, 0x277F}, - {0x2B56, 0x2B59}, {0x3248, 0x324F}, {0xE000, 0xF8FF}, - {0xFE00, 0xFE0F}, {0xFFFD, 0xFFFD}, {0x1F100, 0x1F10A}, - {0x1F110, 0x1F12D}, {0x1F130, 0x1F169}, {0x1F170, 0x1F18D}, - {0x1F18F, 0x1F190}, {0x1F19B, 0x1F1AC}, {0xE0100, 0xE01EF}, - {0xF0000, 0xFFFFD}, {0x100000, 0x10FFFD}, -} - -var emoji = table{ - {0x1F1E6, 0x1F1FF}, {0x1F321, 0x1F321}, {0x1F324, 0x1F32C}, - {0x1F336, 0x1F336}, {0x1F37D, 0x1F37D}, {0x1F396, 0x1F397}, - {0x1F399, 0x1F39B}, {0x1F39E, 0x1F39F}, {0x1F3CB, 0x1F3CE}, - {0x1F3D4, 0x1F3DF}, {0x1F3F3, 0x1F3F5}, {0x1F3F7, 0x1F3F7}, - {0x1F43F, 0x1F43F}, {0x1F441, 0x1F441}, {0x1F4FD, 0x1F4FD}, - {0x1F549, 0x1F54A}, {0x1F56F, 0x1F570}, {0x1F573, 0x1F579}, - {0x1F587, 0x1F587}, {0x1F58A, 0x1F58D}, {0x1F590, 0x1F590}, - {0x1F5A5, 0x1F5A5}, {0x1F5A8, 0x1F5A8}, {0x1F5B1, 0x1F5B2}, - {0x1F5BC, 0x1F5BC}, {0x1F5C2, 0x1F5C4}, {0x1F5D1, 0x1F5D3}, - {0x1F5DC, 0x1F5DE}, {0x1F5E1, 0x1F5E1}, {0x1F5E3, 0x1F5E3}, - {0x1F5E8, 0x1F5E8}, {0x1F5EF, 0x1F5EF}, {0x1F5F3, 0x1F5F3}, - {0x1F5FA, 0x1F5FA}, {0x1F6CB, 0x1F6CF}, {0x1F6E0, 0x1F6E5}, - {0x1F6E9, 0x1F6E9}, {0x1F6F0, 0x1F6F0}, {0x1F6F3, 0x1F6F3}, -} - -var notassigned = table{ - {0x0378, 0x0379}, {0x0380, 0x0383}, {0x038B, 0x038B}, - {0x038D, 0x038D}, {0x03A2, 0x03A2}, {0x0530, 0x0530}, - {0x0557, 0x0558}, {0x0560, 0x0560}, {0x0588, 0x0588}, - {0x058B, 0x058C}, {0x0590, 0x0590}, {0x05C8, 0x05CF}, - {0x05EB, 0x05EF}, {0x05F5, 0x05FF}, {0x061D, 0x061D}, - {0x070E, 0x070E}, {0x074B, 0x074C}, {0x07B2, 0x07BF}, - {0x07FB, 0x07FF}, {0x082E, 0x082F}, {0x083F, 0x083F}, - {0x085C, 0x085D}, {0x085F, 0x089F}, {0x08B5, 0x08B5}, - {0x08BE, 0x08D3}, {0x0984, 0x0984}, {0x098D, 0x098E}, - {0x0991, 0x0992}, {0x09A9, 0x09A9}, {0x09B1, 0x09B1}, - {0x09B3, 0x09B5}, {0x09BA, 0x09BB}, {0x09C5, 0x09C6}, - {0x09C9, 0x09CA}, {0x09CF, 0x09D6}, {0x09D8, 0x09DB}, - {0x09DE, 0x09DE}, {0x09E4, 0x09E5}, {0x09FC, 0x0A00}, - {0x0A04, 0x0A04}, {0x0A0B, 0x0A0E}, {0x0A11, 0x0A12}, - {0x0A29, 0x0A29}, {0x0A31, 0x0A31}, {0x0A34, 0x0A34}, - {0x0A37, 0x0A37}, {0x0A3A, 0x0A3B}, {0x0A3D, 0x0A3D}, - {0x0A43, 0x0A46}, {0x0A49, 0x0A4A}, {0x0A4E, 0x0A50}, - {0x0A52, 0x0A58}, {0x0A5D, 0x0A5D}, {0x0A5F, 0x0A65}, - {0x0A76, 0x0A80}, {0x0A84, 0x0A84}, {0x0A8E, 0x0A8E}, - {0x0A92, 0x0A92}, {0x0AA9, 0x0AA9}, {0x0AB1, 0x0AB1}, - {0x0AB4, 0x0AB4}, {0x0ABA, 0x0ABB}, {0x0AC6, 0x0AC6}, - {0x0ACA, 0x0ACA}, {0x0ACE, 0x0ACF}, {0x0AD1, 0x0ADF}, - {0x0AE4, 0x0AE5}, {0x0AF2, 0x0AF8}, {0x0AFA, 0x0B00}, - {0x0B04, 0x0B04}, {0x0B0D, 0x0B0E}, {0x0B11, 0x0B12}, - {0x0B29, 0x0B29}, {0x0B31, 0x0B31}, {0x0B34, 0x0B34}, - {0x0B3A, 0x0B3B}, {0x0B45, 0x0B46}, {0x0B49, 0x0B4A}, - {0x0B4E, 0x0B55}, {0x0B58, 0x0B5B}, {0x0B5E, 0x0B5E}, - {0x0B64, 0x0B65}, {0x0B78, 0x0B81}, {0x0B84, 0x0B84}, - {0x0B8B, 0x0B8D}, {0x0B91, 0x0B91}, {0x0B96, 0x0B98}, - {0x0B9B, 0x0B9B}, {0x0B9D, 0x0B9D}, {0x0BA0, 0x0BA2}, - {0x0BA5, 0x0BA7}, {0x0BAB, 0x0BAD}, {0x0BBA, 0x0BBD}, - {0x0BC3, 0x0BC5}, {0x0BC9, 0x0BC9}, {0x0BCE, 0x0BCF}, - {0x0BD1, 0x0BD6}, {0x0BD8, 0x0BE5}, {0x0BFB, 0x0BFF}, - {0x0C04, 0x0C04}, {0x0C0D, 0x0C0D}, {0x0C11, 0x0C11}, - {0x0C29, 0x0C29}, {0x0C3A, 0x0C3C}, {0x0C45, 0x0C45}, - {0x0C49, 0x0C49}, {0x0C4E, 0x0C54}, {0x0C57, 0x0C57}, - {0x0C5B, 0x0C5F}, {0x0C64, 0x0C65}, {0x0C70, 0x0C77}, - {0x0C84, 0x0C84}, {0x0C8D, 0x0C8D}, {0x0C91, 0x0C91}, - {0x0CA9, 0x0CA9}, {0x0CB4, 0x0CB4}, {0x0CBA, 0x0CBB}, - {0x0CC5, 0x0CC5}, {0x0CC9, 0x0CC9}, {0x0CCE, 0x0CD4}, - {0x0CD7, 0x0CDD}, {0x0CDF, 0x0CDF}, {0x0CE4, 0x0CE5}, - {0x0CF0, 0x0CF0}, {0x0CF3, 0x0D00}, {0x0D04, 0x0D04}, - {0x0D0D, 0x0D0D}, {0x0D11, 0x0D11}, {0x0D3B, 0x0D3C}, - {0x0D45, 0x0D45}, {0x0D49, 0x0D49}, {0x0D50, 0x0D53}, - {0x0D64, 0x0D65}, {0x0D80, 0x0D81}, {0x0D84, 0x0D84}, - {0x0D97, 0x0D99}, {0x0DB2, 0x0DB2}, {0x0DBC, 0x0DBC}, - {0x0DBE, 0x0DBF}, {0x0DC7, 0x0DC9}, {0x0DCB, 0x0DCE}, - {0x0DD5, 0x0DD5}, {0x0DD7, 0x0DD7}, {0x0DE0, 0x0DE5}, - {0x0DF0, 0x0DF1}, {0x0DF5, 0x0E00}, {0x0E3B, 0x0E3E}, - {0x0E5C, 0x0E80}, {0x0E83, 0x0E83}, {0x0E85, 0x0E86}, - {0x0E89, 0x0E89}, {0x0E8B, 0x0E8C}, {0x0E8E, 0x0E93}, - {0x0E98, 0x0E98}, {0x0EA0, 0x0EA0}, {0x0EA4, 0x0EA4}, - {0x0EA6, 0x0EA6}, {0x0EA8, 0x0EA9}, {0x0EAC, 0x0EAC}, - {0x0EBA, 0x0EBA}, {0x0EBE, 0x0EBF}, {0x0EC5, 0x0EC5}, - {0x0EC7, 0x0EC7}, {0x0ECE, 0x0ECF}, {0x0EDA, 0x0EDB}, - {0x0EE0, 0x0EFF}, {0x0F48, 0x0F48}, {0x0F6D, 0x0F70}, - {0x0F98, 0x0F98}, {0x0FBD, 0x0FBD}, {0x0FCD, 0x0FCD}, - {0x0FDB, 0x0FFF}, {0x10C6, 0x10C6}, {0x10C8, 0x10CC}, - {0x10CE, 0x10CF}, {0x1249, 0x1249}, {0x124E, 0x124F}, - {0x1257, 0x1257}, {0x1259, 0x1259}, {0x125E, 0x125F}, - {0x1289, 0x1289}, {0x128E, 0x128F}, {0x12B1, 0x12B1}, - {0x12B6, 0x12B7}, {0x12BF, 0x12BF}, {0x12C1, 0x12C1}, - {0x12C6, 0x12C7}, {0x12D7, 0x12D7}, {0x1311, 0x1311}, - {0x1316, 0x1317}, {0x135B, 0x135C}, {0x137D, 0x137F}, - {0x139A, 0x139F}, {0x13F6, 0x13F7}, {0x13FE, 0x13FF}, - {0x169D, 0x169F}, {0x16F9, 0x16FF}, {0x170D, 0x170D}, - {0x1715, 0x171F}, {0x1737, 0x173F}, {0x1754, 0x175F}, - {0x176D, 0x176D}, {0x1771, 0x1771}, {0x1774, 0x177F}, - {0x17DE, 0x17DF}, {0x17EA, 0x17EF}, {0x17FA, 0x17FF}, - {0x180F, 0x180F}, {0x181A, 0x181F}, {0x1878, 0x187F}, - {0x18AB, 0x18AF}, {0x18F6, 0x18FF}, {0x191F, 0x191F}, - {0x192C, 0x192F}, {0x193C, 0x193F}, {0x1941, 0x1943}, - {0x196E, 0x196F}, {0x1975, 0x197F}, {0x19AC, 0x19AF}, - {0x19CA, 0x19CF}, {0x19DB, 0x19DD}, {0x1A1C, 0x1A1D}, - {0x1A5F, 0x1A5F}, {0x1A7D, 0x1A7E}, {0x1A8A, 0x1A8F}, - {0x1A9A, 0x1A9F}, {0x1AAE, 0x1AAF}, {0x1ABF, 0x1AFF}, - {0x1B4C, 0x1B4F}, {0x1B7D, 0x1B7F}, {0x1BF4, 0x1BFB}, - {0x1C38, 0x1C3A}, {0x1C4A, 0x1C4C}, {0x1C89, 0x1CBF}, - {0x1CC8, 0x1CCF}, {0x1CF7, 0x1CF7}, {0x1CFA, 0x1CFF}, - {0x1DF6, 0x1DFA}, {0x1F16, 0x1F17}, {0x1F1E, 0x1F1F}, - {0x1F46, 0x1F47}, {0x1F4E, 0x1F4F}, {0x1F58, 0x1F58}, - {0x1F5A, 0x1F5A}, {0x1F5C, 0x1F5C}, {0x1F5E, 0x1F5E}, - {0x1F7E, 0x1F7F}, {0x1FB5, 0x1FB5}, {0x1FC5, 0x1FC5}, - {0x1FD4, 0x1FD5}, {0x1FDC, 0x1FDC}, {0x1FF0, 0x1FF1}, - {0x1FF5, 0x1FF5}, {0x1FFF, 0x1FFF}, {0x2065, 0x2065}, - {0x2072, 0x2073}, {0x208F, 0x208F}, {0x209D, 0x209F}, - {0x20BF, 0x20CF}, {0x20F1, 0x20FF}, {0x218C, 0x218F}, - {0x23FF, 0x23FF}, {0x2427, 0x243F}, {0x244B, 0x245F}, - {0x2B74, 0x2B75}, {0x2B96, 0x2B97}, {0x2BBA, 0x2BBC}, - {0x2BC9, 0x2BC9}, {0x2BD2, 0x2BEB}, {0x2BF0, 0x2BFF}, - {0x2C2F, 0x2C2F}, {0x2C5F, 0x2C5F}, {0x2CF4, 0x2CF8}, - {0x2D26, 0x2D26}, {0x2D28, 0x2D2C}, {0x2D2E, 0x2D2F}, - {0x2D68, 0x2D6E}, {0x2D71, 0x2D7E}, {0x2D97, 0x2D9F}, - {0x2DA7, 0x2DA7}, {0x2DAF, 0x2DAF}, {0x2DB7, 0x2DB7}, - {0x2DBF, 0x2DBF}, {0x2DC7, 0x2DC7}, {0x2DCF, 0x2DCF}, - {0x2DD7, 0x2DD7}, {0x2DDF, 0x2DDF}, {0x2E45, 0x2E7F}, - {0x2E9A, 0x2E9A}, {0x2EF4, 0x2EFF}, {0x2FD6, 0x2FEF}, - {0x2FFC, 0x2FFF}, {0x3040, 0x3040}, {0x3097, 0x3098}, - {0x3100, 0x3104}, {0x312E, 0x3130}, {0x318F, 0x318F}, - {0x31BB, 0x31BF}, {0x31E4, 0x31EF}, {0x321F, 0x321F}, - {0x32FF, 0x32FF}, {0x4DB6, 0x4DBF}, {0x9FD6, 0x9FFF}, - {0xA48D, 0xA48F}, {0xA4C7, 0xA4CF}, {0xA62C, 0xA63F}, - {0xA6F8, 0xA6FF}, {0xA7AF, 0xA7AF}, {0xA7B8, 0xA7F6}, - {0xA82C, 0xA82F}, {0xA83A, 0xA83F}, {0xA878, 0xA87F}, - {0xA8C6, 0xA8CD}, {0xA8DA, 0xA8DF}, {0xA8FE, 0xA8FF}, - {0xA954, 0xA95E}, {0xA97D, 0xA97F}, {0xA9CE, 0xA9CE}, - {0xA9DA, 0xA9DD}, {0xA9FF, 0xA9FF}, {0xAA37, 0xAA3F}, - {0xAA4E, 0xAA4F}, {0xAA5A, 0xAA5B}, {0xAAC3, 0xAADA}, - {0xAAF7, 0xAB00}, {0xAB07, 0xAB08}, {0xAB0F, 0xAB10}, - {0xAB17, 0xAB1F}, {0xAB27, 0xAB27}, {0xAB2F, 0xAB2F}, - {0xAB66, 0xAB6F}, {0xABEE, 0xABEF}, {0xABFA, 0xABFF}, - {0xD7A4, 0xD7AF}, {0xD7C7, 0xD7CA}, {0xD7FC, 0xD7FF}, - {0xFA6E, 0xFA6F}, {0xFADA, 0xFAFF}, {0xFB07, 0xFB12}, - {0xFB18, 0xFB1C}, {0xFB37, 0xFB37}, {0xFB3D, 0xFB3D}, - {0xFB3F, 0xFB3F}, {0xFB42, 0xFB42}, {0xFB45, 0xFB45}, - {0xFBC2, 0xFBD2}, {0xFD40, 0xFD4F}, {0xFD90, 0xFD91}, - {0xFDC8, 0xFDEF}, {0xFDFE, 0xFDFF}, {0xFE1A, 0xFE1F}, - {0xFE53, 0xFE53}, {0xFE67, 0xFE67}, {0xFE6C, 0xFE6F}, - {0xFE75, 0xFE75}, {0xFEFD, 0xFEFE}, {0xFF00, 0xFF00}, - {0xFFBF, 0xFFC1}, {0xFFC8, 0xFFC9}, {0xFFD0, 0xFFD1}, - {0xFFD8, 0xFFD9}, {0xFFDD, 0xFFDF}, {0xFFE7, 0xFFE7}, - {0xFFEF, 0xFFF8}, {0xFFFE, 0xFFFF}, {0x1000C, 0x1000C}, - {0x10027, 0x10027}, {0x1003B, 0x1003B}, {0x1003E, 0x1003E}, - {0x1004E, 0x1004F}, {0x1005E, 0x1007F}, {0x100FB, 0x100FF}, - {0x10103, 0x10106}, {0x10134, 0x10136}, {0x1018F, 0x1018F}, - {0x1019C, 0x1019F}, {0x101A1, 0x101CF}, {0x101FE, 0x1027F}, - {0x1029D, 0x1029F}, {0x102D1, 0x102DF}, {0x102FC, 0x102FF}, - {0x10324, 0x1032F}, {0x1034B, 0x1034F}, {0x1037B, 0x1037F}, - {0x1039E, 0x1039E}, {0x103C4, 0x103C7}, {0x103D6, 0x103FF}, - {0x1049E, 0x1049F}, {0x104AA, 0x104AF}, {0x104D4, 0x104D7}, - {0x104FC, 0x104FF}, {0x10528, 0x1052F}, {0x10564, 0x1056E}, - {0x10570, 0x105FF}, {0x10737, 0x1073F}, {0x10756, 0x1075F}, - {0x10768, 0x107FF}, {0x10806, 0x10807}, {0x10809, 0x10809}, - {0x10836, 0x10836}, {0x10839, 0x1083B}, {0x1083D, 0x1083E}, - {0x10856, 0x10856}, {0x1089F, 0x108A6}, {0x108B0, 0x108DF}, - {0x108F3, 0x108F3}, {0x108F6, 0x108FA}, {0x1091C, 0x1091E}, - {0x1093A, 0x1093E}, {0x10940, 0x1097F}, {0x109B8, 0x109BB}, - {0x109D0, 0x109D1}, {0x10A04, 0x10A04}, {0x10A07, 0x10A0B}, - {0x10A14, 0x10A14}, {0x10A18, 0x10A18}, {0x10A34, 0x10A37}, - {0x10A3B, 0x10A3E}, {0x10A48, 0x10A4F}, {0x10A59, 0x10A5F}, - {0x10AA0, 0x10ABF}, {0x10AE7, 0x10AEA}, {0x10AF7, 0x10AFF}, - {0x10B36, 0x10B38}, {0x10B56, 0x10B57}, {0x10B73, 0x10B77}, - {0x10B92, 0x10B98}, {0x10B9D, 0x10BA8}, {0x10BB0, 0x10BFF}, - {0x10C49, 0x10C7F}, {0x10CB3, 0x10CBF}, {0x10CF3, 0x10CF9}, - {0x10D00, 0x10E5F}, {0x10E7F, 0x10FFF}, {0x1104E, 0x11051}, - {0x11070, 0x1107E}, {0x110C2, 0x110CF}, {0x110E9, 0x110EF}, - {0x110FA, 0x110FF}, {0x11135, 0x11135}, {0x11144, 0x1114F}, - {0x11177, 0x1117F}, {0x111CE, 0x111CF}, {0x111E0, 0x111E0}, - {0x111F5, 0x111FF}, {0x11212, 0x11212}, {0x1123F, 0x1127F}, - {0x11287, 0x11287}, {0x11289, 0x11289}, {0x1128E, 0x1128E}, - {0x1129E, 0x1129E}, {0x112AA, 0x112AF}, {0x112EB, 0x112EF}, - {0x112FA, 0x112FF}, {0x11304, 0x11304}, {0x1130D, 0x1130E}, - {0x11311, 0x11312}, {0x11329, 0x11329}, {0x11331, 0x11331}, - {0x11334, 0x11334}, {0x1133A, 0x1133B}, {0x11345, 0x11346}, - {0x11349, 0x1134A}, {0x1134E, 0x1134F}, {0x11351, 0x11356}, - {0x11358, 0x1135C}, {0x11364, 0x11365}, {0x1136D, 0x1136F}, - {0x11375, 0x113FF}, {0x1145A, 0x1145A}, {0x1145C, 0x1145C}, - {0x1145E, 0x1147F}, {0x114C8, 0x114CF}, {0x114DA, 0x1157F}, - {0x115B6, 0x115B7}, {0x115DE, 0x115FF}, {0x11645, 0x1164F}, - {0x1165A, 0x1165F}, {0x1166D, 0x1167F}, {0x116B8, 0x116BF}, - {0x116CA, 0x116FF}, {0x1171A, 0x1171C}, {0x1172C, 0x1172F}, - {0x11740, 0x1189F}, {0x118F3, 0x118FE}, {0x11900, 0x11ABF}, - {0x11AF9, 0x11BFF}, {0x11C09, 0x11C09}, {0x11C37, 0x11C37}, - {0x11C46, 0x11C4F}, {0x11C6D, 0x11C6F}, {0x11C90, 0x11C91}, - {0x11CA8, 0x11CA8}, {0x11CB7, 0x11FFF}, {0x1239A, 0x123FF}, - {0x1246F, 0x1246F}, {0x12475, 0x1247F}, {0x12544, 0x12FFF}, - {0x1342F, 0x143FF}, {0x14647, 0x167FF}, {0x16A39, 0x16A3F}, - {0x16A5F, 0x16A5F}, {0x16A6A, 0x16A6D}, {0x16A70, 0x16ACF}, - {0x16AEE, 0x16AEF}, {0x16AF6, 0x16AFF}, {0x16B46, 0x16B4F}, - {0x16B5A, 0x16B5A}, {0x16B62, 0x16B62}, {0x16B78, 0x16B7C}, - {0x16B90, 0x16EFF}, {0x16F45, 0x16F4F}, {0x16F7F, 0x16F8E}, - {0x16FA0, 0x16FDF}, {0x16FE1, 0x16FFF}, {0x187ED, 0x187FF}, - {0x18AF3, 0x1AFFF}, {0x1B002, 0x1BBFF}, {0x1BC6B, 0x1BC6F}, - {0x1BC7D, 0x1BC7F}, {0x1BC89, 0x1BC8F}, {0x1BC9A, 0x1BC9B}, - {0x1BCA4, 0x1CFFF}, {0x1D0F6, 0x1D0FF}, {0x1D127, 0x1D128}, - {0x1D1E9, 0x1D1FF}, {0x1D246, 0x1D2FF}, {0x1D357, 0x1D35F}, - {0x1D372, 0x1D3FF}, {0x1D455, 0x1D455}, {0x1D49D, 0x1D49D}, - {0x1D4A0, 0x1D4A1}, {0x1D4A3, 0x1D4A4}, {0x1D4A7, 0x1D4A8}, - {0x1D4AD, 0x1D4AD}, {0x1D4BA, 0x1D4BA}, {0x1D4BC, 0x1D4BC}, - {0x1D4C4, 0x1D4C4}, {0x1D506, 0x1D506}, {0x1D50B, 0x1D50C}, - {0x1D515, 0x1D515}, {0x1D51D, 0x1D51D}, {0x1D53A, 0x1D53A}, - {0x1D53F, 0x1D53F}, {0x1D545, 0x1D545}, {0x1D547, 0x1D549}, - {0x1D551, 0x1D551}, {0x1D6A6, 0x1D6A7}, {0x1D7CC, 0x1D7CD}, - {0x1DA8C, 0x1DA9A}, {0x1DAA0, 0x1DAA0}, {0x1DAB0, 0x1DFFF}, - {0x1E007, 0x1E007}, {0x1E019, 0x1E01A}, {0x1E022, 0x1E022}, - {0x1E025, 0x1E025}, {0x1E02B, 0x1E7FF}, {0x1E8C5, 0x1E8C6}, - {0x1E8D7, 0x1E8FF}, {0x1E94B, 0x1E94F}, {0x1E95A, 0x1E95D}, - {0x1E960, 0x1EDFF}, {0x1EE04, 0x1EE04}, {0x1EE20, 0x1EE20}, - {0x1EE23, 0x1EE23}, {0x1EE25, 0x1EE26}, {0x1EE28, 0x1EE28}, - {0x1EE33, 0x1EE33}, {0x1EE38, 0x1EE38}, {0x1EE3A, 0x1EE3A}, - {0x1EE3C, 0x1EE41}, {0x1EE43, 0x1EE46}, {0x1EE48, 0x1EE48}, - {0x1EE4A, 0x1EE4A}, {0x1EE4C, 0x1EE4C}, {0x1EE50, 0x1EE50}, - {0x1EE53, 0x1EE53}, {0x1EE55, 0x1EE56}, {0x1EE58, 0x1EE58}, - {0x1EE5A, 0x1EE5A}, {0x1EE5C, 0x1EE5C}, {0x1EE5E, 0x1EE5E}, - {0x1EE60, 0x1EE60}, {0x1EE63, 0x1EE63}, {0x1EE65, 0x1EE66}, - {0x1EE6B, 0x1EE6B}, {0x1EE73, 0x1EE73}, {0x1EE78, 0x1EE78}, - {0x1EE7D, 0x1EE7D}, {0x1EE7F, 0x1EE7F}, {0x1EE8A, 0x1EE8A}, - {0x1EE9C, 0x1EEA0}, {0x1EEA4, 0x1EEA4}, {0x1EEAA, 0x1EEAA}, - {0x1EEBC, 0x1EEEF}, {0x1EEF2, 0x1EFFF}, {0x1F02C, 0x1F02F}, - {0x1F094, 0x1F09F}, {0x1F0AF, 0x1F0B0}, {0x1F0C0, 0x1F0C0}, - {0x1F0D0, 0x1F0D0}, {0x1F0F6, 0x1F0FF}, {0x1F10D, 0x1F10F}, - {0x1F12F, 0x1F12F}, {0x1F16C, 0x1F16F}, {0x1F1AD, 0x1F1E5}, - {0x1F203, 0x1F20F}, {0x1F23C, 0x1F23F}, {0x1F249, 0x1F24F}, - {0x1F252, 0x1F2FF}, {0x1F6D3, 0x1F6DF}, {0x1F6ED, 0x1F6EF}, - {0x1F6F7, 0x1F6FF}, {0x1F774, 0x1F77F}, {0x1F7D5, 0x1F7FF}, - {0x1F80C, 0x1F80F}, {0x1F848, 0x1F84F}, {0x1F85A, 0x1F85F}, - {0x1F888, 0x1F88F}, {0x1F8AE, 0x1F90F}, {0x1F91F, 0x1F91F}, - {0x1F928, 0x1F92F}, {0x1F931, 0x1F932}, {0x1F93F, 0x1F93F}, - {0x1F94C, 0x1F94F}, {0x1F95F, 0x1F97F}, {0x1F992, 0x1F9BF}, - {0x1F9C1, 0x1FFFF}, {0x2A6D7, 0x2A6FF}, {0x2B735, 0x2B73F}, - {0x2B81E, 0x2B81F}, {0x2CEA2, 0x2F7FF}, {0x2FA1E, 0xE0000}, - {0xE0002, 0xE001F}, {0xE0080, 0xE00FF}, {0xE01F0, 0xEFFFF}, - {0xFFFFE, 0xFFFFF}, -} - -var neutral = table{ - {0x0000, 0x001F}, {0x007F, 0x007F}, {0x0080, 0x009F}, - {0x00A0, 0x00A0}, {0x00A9, 0x00A9}, {0x00AB, 0x00AB}, - {0x00B5, 0x00B5}, {0x00BB, 0x00BB}, {0x00C0, 0x00C5}, - {0x00C7, 0x00CF}, {0x00D1, 0x00D6}, {0x00D9, 0x00DD}, - {0x00E2, 0x00E5}, {0x00E7, 0x00E7}, {0x00EB, 0x00EB}, - {0x00EE, 0x00EF}, {0x00F1, 0x00F1}, {0x00F4, 0x00F6}, - {0x00FB, 0x00FB}, {0x00FD, 0x00FD}, {0x00FF, 0x00FF}, - {0x0100, 0x0100}, {0x0102, 0x0110}, {0x0112, 0x0112}, - {0x0114, 0x011A}, {0x011C, 0x0125}, {0x0128, 0x012A}, - {0x012C, 0x0130}, {0x0134, 0x0137}, {0x0139, 0x013E}, - {0x0143, 0x0143}, {0x0145, 0x0147}, {0x014C, 0x014C}, - {0x014E, 0x0151}, {0x0154, 0x0165}, {0x0168, 0x016A}, - {0x016C, 0x017F}, {0x0180, 0x01BA}, {0x01BB, 0x01BB}, - {0x01BC, 0x01BF}, {0x01C0, 0x01C3}, {0x01C4, 0x01CD}, - {0x01CF, 0x01CF}, {0x01D1, 0x01D1}, {0x01D3, 0x01D3}, - {0x01D5, 0x01D5}, {0x01D7, 0x01D7}, {0x01D9, 0x01D9}, - {0x01DB, 0x01DB}, {0x01DD, 0x024F}, {0x0250, 0x0250}, - {0x0252, 0x0260}, {0x0262, 0x0293}, {0x0294, 0x0294}, - {0x0295, 0x02AF}, {0x02B0, 0x02C1}, {0x02C2, 0x02C3}, - {0x02C5, 0x02C5}, {0x02C6, 0x02C6}, {0x02C8, 0x02C8}, - {0x02CC, 0x02CC}, {0x02CE, 0x02CF}, {0x02D1, 0x02D1}, - {0x02D2, 0x02D7}, {0x02DC, 0x02DC}, {0x02DE, 0x02DE}, - {0x02E0, 0x02E4}, {0x02E5, 0x02EB}, {0x02EC, 0x02EC}, - {0x02ED, 0x02ED}, {0x02EE, 0x02EE}, {0x02EF, 0x02FF}, - {0x0370, 0x0373}, {0x0374, 0x0374}, {0x0375, 0x0375}, - {0x0376, 0x0377}, {0x037A, 0x037A}, {0x037B, 0x037D}, - {0x037E, 0x037E}, {0x037F, 0x037F}, {0x0384, 0x0385}, - {0x0386, 0x0386}, {0x0387, 0x0387}, {0x0388, 0x038A}, - {0x038C, 0x038C}, {0x038E, 0x0390}, {0x03AA, 0x03B0}, - {0x03C2, 0x03C2}, {0x03CA, 0x03F5}, {0x03F6, 0x03F6}, - {0x03F7, 0x03FF}, {0x0400, 0x0400}, {0x0402, 0x040F}, - {0x0450, 0x0450}, {0x0452, 0x0481}, {0x0482, 0x0482}, - {0x0483, 0x0487}, {0x0488, 0x0489}, {0x048A, 0x04FF}, - {0x0500, 0x052F}, {0x0531, 0x0556}, {0x0559, 0x0559}, - {0x055A, 0x055F}, {0x0561, 0x0587}, {0x0589, 0x0589}, - {0x058A, 0x058A}, {0x058D, 0x058E}, {0x058F, 0x058F}, - {0x0591, 0x05BD}, {0x05BE, 0x05BE}, {0x05BF, 0x05BF}, - {0x05C0, 0x05C0}, {0x05C1, 0x05C2}, {0x05C3, 0x05C3}, - {0x05C4, 0x05C5}, {0x05C6, 0x05C6}, {0x05C7, 0x05C7}, - {0x05D0, 0x05EA}, {0x05F0, 0x05F2}, {0x05F3, 0x05F4}, - {0x0600, 0x0605}, {0x0606, 0x0608}, {0x0609, 0x060A}, - {0x060B, 0x060B}, {0x060C, 0x060D}, {0x060E, 0x060F}, - {0x0610, 0x061A}, {0x061B, 0x061B}, {0x061C, 0x061C}, - {0x061E, 0x061F}, {0x0620, 0x063F}, {0x0640, 0x0640}, - {0x0641, 0x064A}, {0x064B, 0x065F}, {0x0660, 0x0669}, - {0x066A, 0x066D}, {0x066E, 0x066F}, {0x0670, 0x0670}, - {0x0671, 0x06D3}, {0x06D4, 0x06D4}, {0x06D5, 0x06D5}, - {0x06D6, 0x06DC}, {0x06DD, 0x06DD}, {0x06DE, 0x06DE}, - {0x06DF, 0x06E4}, {0x06E5, 0x06E6}, {0x06E7, 0x06E8}, - {0x06E9, 0x06E9}, {0x06EA, 0x06ED}, {0x06EE, 0x06EF}, - {0x06F0, 0x06F9}, {0x06FA, 0x06FC}, {0x06FD, 0x06FE}, - {0x06FF, 0x06FF}, {0x0700, 0x070D}, {0x070F, 0x070F}, - {0x0710, 0x0710}, {0x0711, 0x0711}, {0x0712, 0x072F}, - {0x0730, 0x074A}, {0x074D, 0x074F}, {0x0750, 0x077F}, - {0x0780, 0x07A5}, {0x07A6, 0x07B0}, {0x07B1, 0x07B1}, - {0x07C0, 0x07C9}, {0x07CA, 0x07EA}, {0x07EB, 0x07F3}, - {0x07F4, 0x07F5}, {0x07F6, 0x07F6}, {0x07F7, 0x07F9}, - {0x07FA, 0x07FA}, {0x0800, 0x0815}, {0x0816, 0x0819}, - {0x081A, 0x081A}, {0x081B, 0x0823}, {0x0824, 0x0824}, - {0x0825, 0x0827}, {0x0828, 0x0828}, {0x0829, 0x082D}, - {0x0830, 0x083E}, {0x0840, 0x0858}, {0x0859, 0x085B}, - {0x085E, 0x085E}, {0x08A0, 0x08B4}, {0x08B6, 0x08BD}, - {0x08D4, 0x08E1}, {0x08E2, 0x08E2}, {0x08E3, 0x08FF}, - {0x0900, 0x0902}, {0x0903, 0x0903}, {0x0904, 0x0939}, - {0x093A, 0x093A}, {0x093B, 0x093B}, {0x093C, 0x093C}, - {0x093D, 0x093D}, {0x093E, 0x0940}, {0x0941, 0x0948}, - {0x0949, 0x094C}, {0x094D, 0x094D}, {0x094E, 0x094F}, - {0x0950, 0x0950}, {0x0951, 0x0957}, {0x0958, 0x0961}, - {0x0962, 0x0963}, {0x0964, 0x0965}, {0x0966, 0x096F}, - {0x0970, 0x0970}, {0x0971, 0x0971}, {0x0972, 0x097F}, - {0x0980, 0x0980}, {0x0981, 0x0981}, {0x0982, 0x0983}, - {0x0985, 0x098C}, {0x098F, 0x0990}, {0x0993, 0x09A8}, - {0x09AA, 0x09B0}, {0x09B2, 0x09B2}, {0x09B6, 0x09B9}, - {0x09BC, 0x09BC}, {0x09BD, 0x09BD}, {0x09BE, 0x09C0}, - {0x09C1, 0x09C4}, {0x09C7, 0x09C8}, {0x09CB, 0x09CC}, - {0x09CD, 0x09CD}, {0x09CE, 0x09CE}, {0x09D7, 0x09D7}, - {0x09DC, 0x09DD}, {0x09DF, 0x09E1}, {0x09E2, 0x09E3}, - {0x09E6, 0x09EF}, {0x09F0, 0x09F1}, {0x09F2, 0x09F3}, - {0x09F4, 0x09F9}, {0x09FA, 0x09FA}, {0x09FB, 0x09FB}, - {0x0A01, 0x0A02}, {0x0A03, 0x0A03}, {0x0A05, 0x0A0A}, - {0x0A0F, 0x0A10}, {0x0A13, 0x0A28}, {0x0A2A, 0x0A30}, - {0x0A32, 0x0A33}, {0x0A35, 0x0A36}, {0x0A38, 0x0A39}, - {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A40}, {0x0A41, 0x0A42}, - {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51}, - {0x0A59, 0x0A5C}, {0x0A5E, 0x0A5E}, {0x0A66, 0x0A6F}, - {0x0A70, 0x0A71}, {0x0A72, 0x0A74}, {0x0A75, 0x0A75}, - {0x0A81, 0x0A82}, {0x0A83, 0x0A83}, {0x0A85, 0x0A8D}, - {0x0A8F, 0x0A91}, {0x0A93, 0x0AA8}, {0x0AAA, 0x0AB0}, - {0x0AB2, 0x0AB3}, {0x0AB5, 0x0AB9}, {0x0ABC, 0x0ABC}, - {0x0ABD, 0x0ABD}, {0x0ABE, 0x0AC0}, {0x0AC1, 0x0AC5}, - {0x0AC7, 0x0AC8}, {0x0AC9, 0x0AC9}, {0x0ACB, 0x0ACC}, - {0x0ACD, 0x0ACD}, {0x0AD0, 0x0AD0}, {0x0AE0, 0x0AE1}, - {0x0AE2, 0x0AE3}, {0x0AE6, 0x0AEF}, {0x0AF0, 0x0AF0}, - {0x0AF1, 0x0AF1}, {0x0AF9, 0x0AF9}, {0x0B01, 0x0B01}, - {0x0B02, 0x0B03}, {0x0B05, 0x0B0C}, {0x0B0F, 0x0B10}, - {0x0B13, 0x0B28}, {0x0B2A, 0x0B30}, {0x0B32, 0x0B33}, - {0x0B35, 0x0B39}, {0x0B3C, 0x0B3C}, {0x0B3D, 0x0B3D}, - {0x0B3E, 0x0B3E}, {0x0B3F, 0x0B3F}, {0x0B40, 0x0B40}, - {0x0B41, 0x0B44}, {0x0B47, 0x0B48}, {0x0B4B, 0x0B4C}, - {0x0B4D, 0x0B4D}, {0x0B56, 0x0B56}, {0x0B57, 0x0B57}, - {0x0B5C, 0x0B5D}, {0x0B5F, 0x0B61}, {0x0B62, 0x0B63}, - {0x0B66, 0x0B6F}, {0x0B70, 0x0B70}, {0x0B71, 0x0B71}, - {0x0B72, 0x0B77}, {0x0B82, 0x0B82}, {0x0B83, 0x0B83}, - {0x0B85, 0x0B8A}, {0x0B8E, 0x0B90}, {0x0B92, 0x0B95}, - {0x0B99, 0x0B9A}, {0x0B9C, 0x0B9C}, {0x0B9E, 0x0B9F}, - {0x0BA3, 0x0BA4}, {0x0BA8, 0x0BAA}, {0x0BAE, 0x0BB9}, - {0x0BBE, 0x0BBF}, {0x0BC0, 0x0BC0}, {0x0BC1, 0x0BC2}, - {0x0BC6, 0x0BC8}, {0x0BCA, 0x0BCC}, {0x0BCD, 0x0BCD}, - {0x0BD0, 0x0BD0}, {0x0BD7, 0x0BD7}, {0x0BE6, 0x0BEF}, - {0x0BF0, 0x0BF2}, {0x0BF3, 0x0BF8}, {0x0BF9, 0x0BF9}, - {0x0BFA, 0x0BFA}, {0x0C00, 0x0C00}, {0x0C01, 0x0C03}, - {0x0C05, 0x0C0C}, {0x0C0E, 0x0C10}, {0x0C12, 0x0C28}, - {0x0C2A, 0x0C39}, {0x0C3D, 0x0C3D}, {0x0C3E, 0x0C40}, - {0x0C41, 0x0C44}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, - {0x0C55, 0x0C56}, {0x0C58, 0x0C5A}, {0x0C60, 0x0C61}, - {0x0C62, 0x0C63}, {0x0C66, 0x0C6F}, {0x0C78, 0x0C7E}, - {0x0C7F, 0x0C7F}, {0x0C80, 0x0C80}, {0x0C81, 0x0C81}, - {0x0C82, 0x0C83}, {0x0C85, 0x0C8C}, {0x0C8E, 0x0C90}, - {0x0C92, 0x0CA8}, {0x0CAA, 0x0CB3}, {0x0CB5, 0x0CB9}, - {0x0CBC, 0x0CBC}, {0x0CBD, 0x0CBD}, {0x0CBE, 0x0CBE}, - {0x0CBF, 0x0CBF}, {0x0CC0, 0x0CC4}, {0x0CC6, 0x0CC6}, - {0x0CC7, 0x0CC8}, {0x0CCA, 0x0CCB}, {0x0CCC, 0x0CCD}, - {0x0CD5, 0x0CD6}, {0x0CDE, 0x0CDE}, {0x0CE0, 0x0CE1}, - {0x0CE2, 0x0CE3}, {0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF2}, - {0x0D01, 0x0D01}, {0x0D02, 0x0D03}, {0x0D05, 0x0D0C}, - {0x0D0E, 0x0D10}, {0x0D12, 0x0D3A}, {0x0D3D, 0x0D3D}, - {0x0D3E, 0x0D40}, {0x0D41, 0x0D44}, {0x0D46, 0x0D48}, - {0x0D4A, 0x0D4C}, {0x0D4D, 0x0D4D}, {0x0D4E, 0x0D4E}, - {0x0D4F, 0x0D4F}, {0x0D54, 0x0D56}, {0x0D57, 0x0D57}, - {0x0D58, 0x0D5E}, {0x0D5F, 0x0D61}, {0x0D62, 0x0D63}, - {0x0D66, 0x0D6F}, {0x0D70, 0x0D78}, {0x0D79, 0x0D79}, - {0x0D7A, 0x0D7F}, {0x0D82, 0x0D83}, {0x0D85, 0x0D96}, - {0x0D9A, 0x0DB1}, {0x0DB3, 0x0DBB}, {0x0DBD, 0x0DBD}, - {0x0DC0, 0x0DC6}, {0x0DCA, 0x0DCA}, {0x0DCF, 0x0DD1}, - {0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0DD8, 0x0DDF}, - {0x0DE6, 0x0DEF}, {0x0DF2, 0x0DF3}, {0x0DF4, 0x0DF4}, - {0x0E01, 0x0E30}, {0x0E31, 0x0E31}, {0x0E32, 0x0E33}, - {0x0E34, 0x0E3A}, {0x0E3F, 0x0E3F}, {0x0E40, 0x0E45}, - {0x0E46, 0x0E46}, {0x0E47, 0x0E4E}, {0x0E4F, 0x0E4F}, - {0x0E50, 0x0E59}, {0x0E5A, 0x0E5B}, {0x0E81, 0x0E82}, - {0x0E84, 0x0E84}, {0x0E87, 0x0E88}, {0x0E8A, 0x0E8A}, - {0x0E8D, 0x0E8D}, {0x0E94, 0x0E97}, {0x0E99, 0x0E9F}, - {0x0EA1, 0x0EA3}, {0x0EA5, 0x0EA5}, {0x0EA7, 0x0EA7}, - {0x0EAA, 0x0EAB}, {0x0EAD, 0x0EB0}, {0x0EB1, 0x0EB1}, - {0x0EB2, 0x0EB3}, {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC}, - {0x0EBD, 0x0EBD}, {0x0EC0, 0x0EC4}, {0x0EC6, 0x0EC6}, - {0x0EC8, 0x0ECD}, {0x0ED0, 0x0ED9}, {0x0EDC, 0x0EDF}, - {0x0F00, 0x0F00}, {0x0F01, 0x0F03}, {0x0F04, 0x0F12}, - {0x0F13, 0x0F13}, {0x0F14, 0x0F14}, {0x0F15, 0x0F17}, - {0x0F18, 0x0F19}, {0x0F1A, 0x0F1F}, {0x0F20, 0x0F29}, - {0x0F2A, 0x0F33}, {0x0F34, 0x0F34}, {0x0F35, 0x0F35}, - {0x0F36, 0x0F36}, {0x0F37, 0x0F37}, {0x0F38, 0x0F38}, - {0x0F39, 0x0F39}, {0x0F3A, 0x0F3A}, {0x0F3B, 0x0F3B}, - {0x0F3C, 0x0F3C}, {0x0F3D, 0x0F3D}, {0x0F3E, 0x0F3F}, - {0x0F40, 0x0F47}, {0x0F49, 0x0F6C}, {0x0F71, 0x0F7E}, - {0x0F7F, 0x0F7F}, {0x0F80, 0x0F84}, {0x0F85, 0x0F85}, - {0x0F86, 0x0F87}, {0x0F88, 0x0F8C}, {0x0F8D, 0x0F97}, - {0x0F99, 0x0FBC}, {0x0FBE, 0x0FC5}, {0x0FC6, 0x0FC6}, - {0x0FC7, 0x0FCC}, {0x0FCE, 0x0FCF}, {0x0FD0, 0x0FD4}, - {0x0FD5, 0x0FD8}, {0x0FD9, 0x0FDA}, {0x1000, 0x102A}, - {0x102B, 0x102C}, {0x102D, 0x1030}, {0x1031, 0x1031}, - {0x1032, 0x1037}, {0x1038, 0x1038}, {0x1039, 0x103A}, - {0x103B, 0x103C}, {0x103D, 0x103E}, {0x103F, 0x103F}, - {0x1040, 0x1049}, {0x104A, 0x104F}, {0x1050, 0x1055}, - {0x1056, 0x1057}, {0x1058, 0x1059}, {0x105A, 0x105D}, - {0x105E, 0x1060}, {0x1061, 0x1061}, {0x1062, 0x1064}, - {0x1065, 0x1066}, {0x1067, 0x106D}, {0x106E, 0x1070}, - {0x1071, 0x1074}, {0x1075, 0x1081}, {0x1082, 0x1082}, - {0x1083, 0x1084}, {0x1085, 0x1086}, {0x1087, 0x108C}, - {0x108D, 0x108D}, {0x108E, 0x108E}, {0x108F, 0x108F}, - {0x1090, 0x1099}, {0x109A, 0x109C}, {0x109D, 0x109D}, - {0x109E, 0x109F}, {0x10A0, 0x10C5}, {0x10C7, 0x10C7}, - {0x10CD, 0x10CD}, {0x10D0, 0x10FA}, {0x10FB, 0x10FB}, - {0x10FC, 0x10FC}, {0x10FD, 0x10FF}, {0x1160, 0x11FF}, - {0x1200, 0x1248}, {0x124A, 0x124D}, {0x1250, 0x1256}, - {0x1258, 0x1258}, {0x125A, 0x125D}, {0x1260, 0x1288}, - {0x128A, 0x128D}, {0x1290, 0x12B0}, {0x12B2, 0x12B5}, - {0x12B8, 0x12BE}, {0x12C0, 0x12C0}, {0x12C2, 0x12C5}, - {0x12C8, 0x12D6}, {0x12D8, 0x1310}, {0x1312, 0x1315}, - {0x1318, 0x135A}, {0x135D, 0x135F}, {0x1360, 0x1368}, - {0x1369, 0x137C}, {0x1380, 0x138F}, {0x1390, 0x1399}, - {0x13A0, 0x13F5}, {0x13F8, 0x13FD}, {0x1400, 0x1400}, - {0x1401, 0x166C}, {0x166D, 0x166E}, {0x166F, 0x167F}, - {0x1680, 0x1680}, {0x1681, 0x169A}, {0x169B, 0x169B}, - {0x169C, 0x169C}, {0x16A0, 0x16EA}, {0x16EB, 0x16ED}, - {0x16EE, 0x16F0}, {0x16F1, 0x16F8}, {0x1700, 0x170C}, - {0x170E, 0x1711}, {0x1712, 0x1714}, {0x1720, 0x1731}, - {0x1732, 0x1734}, {0x1735, 0x1736}, {0x1740, 0x1751}, - {0x1752, 0x1753}, {0x1760, 0x176C}, {0x176E, 0x1770}, - {0x1772, 0x1773}, {0x1780, 0x17B3}, {0x17B4, 0x17B5}, - {0x17B6, 0x17B6}, {0x17B7, 0x17BD}, {0x17BE, 0x17C5}, - {0x17C6, 0x17C6}, {0x17C7, 0x17C8}, {0x17C9, 0x17D3}, - {0x17D4, 0x17D6}, {0x17D7, 0x17D7}, {0x17D8, 0x17DA}, - {0x17DB, 0x17DB}, {0x17DC, 0x17DC}, {0x17DD, 0x17DD}, - {0x17E0, 0x17E9}, {0x17F0, 0x17F9}, {0x1800, 0x1805}, - {0x1806, 0x1806}, {0x1807, 0x180A}, {0x180B, 0x180D}, - {0x180E, 0x180E}, {0x1810, 0x1819}, {0x1820, 0x1842}, - {0x1843, 0x1843}, {0x1844, 0x1877}, {0x1880, 0x1884}, - {0x1885, 0x1886}, {0x1887, 0x18A8}, {0x18A9, 0x18A9}, - {0x18AA, 0x18AA}, {0x18B0, 0x18F5}, {0x1900, 0x191E}, - {0x1920, 0x1922}, {0x1923, 0x1926}, {0x1927, 0x1928}, - {0x1929, 0x192B}, {0x1930, 0x1931}, {0x1932, 0x1932}, - {0x1933, 0x1938}, {0x1939, 0x193B}, {0x1940, 0x1940}, - {0x1944, 0x1945}, {0x1946, 0x194F}, {0x1950, 0x196D}, - {0x1970, 0x1974}, {0x1980, 0x19AB}, {0x19B0, 0x19C9}, - {0x19D0, 0x19D9}, {0x19DA, 0x19DA}, {0x19DE, 0x19DF}, - {0x19E0, 0x19FF}, {0x1A00, 0x1A16}, {0x1A17, 0x1A18}, - {0x1A19, 0x1A1A}, {0x1A1B, 0x1A1B}, {0x1A1E, 0x1A1F}, - {0x1A20, 0x1A54}, {0x1A55, 0x1A55}, {0x1A56, 0x1A56}, - {0x1A57, 0x1A57}, {0x1A58, 0x1A5E}, {0x1A60, 0x1A60}, - {0x1A61, 0x1A61}, {0x1A62, 0x1A62}, {0x1A63, 0x1A64}, - {0x1A65, 0x1A6C}, {0x1A6D, 0x1A72}, {0x1A73, 0x1A7C}, - {0x1A7F, 0x1A7F}, {0x1A80, 0x1A89}, {0x1A90, 0x1A99}, - {0x1AA0, 0x1AA6}, {0x1AA7, 0x1AA7}, {0x1AA8, 0x1AAD}, - {0x1AB0, 0x1ABD}, {0x1ABE, 0x1ABE}, {0x1B00, 0x1B03}, - {0x1B04, 0x1B04}, {0x1B05, 0x1B33}, {0x1B34, 0x1B34}, - {0x1B35, 0x1B35}, {0x1B36, 0x1B3A}, {0x1B3B, 0x1B3B}, - {0x1B3C, 0x1B3C}, {0x1B3D, 0x1B41}, {0x1B42, 0x1B42}, - {0x1B43, 0x1B44}, {0x1B45, 0x1B4B}, {0x1B50, 0x1B59}, - {0x1B5A, 0x1B60}, {0x1B61, 0x1B6A}, {0x1B6B, 0x1B73}, - {0x1B74, 0x1B7C}, {0x1B80, 0x1B81}, {0x1B82, 0x1B82}, - {0x1B83, 0x1BA0}, {0x1BA1, 0x1BA1}, {0x1BA2, 0x1BA5}, - {0x1BA6, 0x1BA7}, {0x1BA8, 0x1BA9}, {0x1BAA, 0x1BAA}, - {0x1BAB, 0x1BAD}, {0x1BAE, 0x1BAF}, {0x1BB0, 0x1BB9}, - {0x1BBA, 0x1BBF}, {0x1BC0, 0x1BE5}, {0x1BE6, 0x1BE6}, - {0x1BE7, 0x1BE7}, {0x1BE8, 0x1BE9}, {0x1BEA, 0x1BEC}, - {0x1BED, 0x1BED}, {0x1BEE, 0x1BEE}, {0x1BEF, 0x1BF1}, - {0x1BF2, 0x1BF3}, {0x1BFC, 0x1BFF}, {0x1C00, 0x1C23}, - {0x1C24, 0x1C2B}, {0x1C2C, 0x1C33}, {0x1C34, 0x1C35}, - {0x1C36, 0x1C37}, {0x1C3B, 0x1C3F}, {0x1C40, 0x1C49}, - {0x1C4D, 0x1C4F}, {0x1C50, 0x1C59}, {0x1C5A, 0x1C77}, - {0x1C78, 0x1C7D}, {0x1C7E, 0x1C7F}, {0x1C80, 0x1C88}, - {0x1CC0, 0x1CC7}, {0x1CD0, 0x1CD2}, {0x1CD3, 0x1CD3}, - {0x1CD4, 0x1CE0}, {0x1CE1, 0x1CE1}, {0x1CE2, 0x1CE8}, - {0x1CE9, 0x1CEC}, {0x1CED, 0x1CED}, {0x1CEE, 0x1CF1}, - {0x1CF2, 0x1CF3}, {0x1CF4, 0x1CF4}, {0x1CF5, 0x1CF6}, - {0x1CF8, 0x1CF9}, {0x1D00, 0x1D2B}, {0x1D2C, 0x1D6A}, - {0x1D6B, 0x1D77}, {0x1D78, 0x1D78}, {0x1D79, 0x1D7F}, - {0x1D80, 0x1D9A}, {0x1D9B, 0x1DBF}, {0x1DC0, 0x1DF5}, - {0x1DFB, 0x1DFF}, {0x1E00, 0x1EFF}, {0x1F00, 0x1F15}, - {0x1F18, 0x1F1D}, {0x1F20, 0x1F45}, {0x1F48, 0x1F4D}, - {0x1F50, 0x1F57}, {0x1F59, 0x1F59}, {0x1F5B, 0x1F5B}, - {0x1F5D, 0x1F5D}, {0x1F5F, 0x1F7D}, {0x1F80, 0x1FB4}, - {0x1FB6, 0x1FBC}, {0x1FBD, 0x1FBD}, {0x1FBE, 0x1FBE}, - {0x1FBF, 0x1FC1}, {0x1FC2, 0x1FC4}, {0x1FC6, 0x1FCC}, - {0x1FCD, 0x1FCF}, {0x1FD0, 0x1FD3}, {0x1FD6, 0x1FDB}, - {0x1FDD, 0x1FDF}, {0x1FE0, 0x1FEC}, {0x1FED, 0x1FEF}, - {0x1FF2, 0x1FF4}, {0x1FF6, 0x1FFC}, {0x1FFD, 0x1FFE}, - {0x2000, 0x200A}, {0x200B, 0x200F}, {0x2011, 0x2012}, - {0x2017, 0x2017}, {0x201A, 0x201A}, {0x201B, 0x201B}, - {0x201E, 0x201E}, {0x201F, 0x201F}, {0x2023, 0x2023}, - {0x2028, 0x2028}, {0x2029, 0x2029}, {0x202A, 0x202E}, - {0x202F, 0x202F}, {0x2031, 0x2031}, {0x2034, 0x2034}, - {0x2036, 0x2038}, {0x2039, 0x2039}, {0x203A, 0x203A}, - {0x203C, 0x203D}, {0x203F, 0x2040}, {0x2041, 0x2043}, - {0x2044, 0x2044}, {0x2045, 0x2045}, {0x2046, 0x2046}, - {0x2047, 0x2051}, {0x2052, 0x2052}, {0x2053, 0x2053}, - {0x2054, 0x2054}, {0x2055, 0x205E}, {0x205F, 0x205F}, - {0x2060, 0x2064}, {0x2066, 0x206F}, {0x2070, 0x2070}, - {0x2071, 0x2071}, {0x2075, 0x2079}, {0x207A, 0x207C}, - {0x207D, 0x207D}, {0x207E, 0x207E}, {0x2080, 0x2080}, - {0x2085, 0x2089}, {0x208A, 0x208C}, {0x208D, 0x208D}, - {0x208E, 0x208E}, {0x2090, 0x209C}, {0x20A0, 0x20A8}, - {0x20AA, 0x20AB}, {0x20AD, 0x20BE}, {0x20D0, 0x20DC}, - {0x20DD, 0x20E0}, {0x20E1, 0x20E1}, {0x20E2, 0x20E4}, - {0x20E5, 0x20F0}, {0x2100, 0x2101}, {0x2102, 0x2102}, - {0x2104, 0x2104}, {0x2106, 0x2106}, {0x2107, 0x2107}, - {0x2108, 0x2108}, {0x210A, 0x2112}, {0x2114, 0x2114}, - {0x2115, 0x2115}, {0x2117, 0x2117}, {0x2118, 0x2118}, - {0x2119, 0x211D}, {0x211E, 0x2120}, {0x2123, 0x2123}, - {0x2124, 0x2124}, {0x2125, 0x2125}, {0x2127, 0x2127}, - {0x2128, 0x2128}, {0x2129, 0x2129}, {0x212A, 0x212A}, - {0x212C, 0x212D}, {0x212E, 0x212E}, {0x212F, 0x2134}, - {0x2135, 0x2138}, {0x2139, 0x2139}, {0x213A, 0x213B}, - {0x213C, 0x213F}, {0x2140, 0x2144}, {0x2145, 0x2149}, - {0x214A, 0x214A}, {0x214B, 0x214B}, {0x214C, 0x214D}, - {0x214E, 0x214E}, {0x214F, 0x214F}, {0x2150, 0x2152}, - {0x2155, 0x215A}, {0x215F, 0x215F}, {0x216C, 0x216F}, - {0x217A, 0x2182}, {0x2183, 0x2184}, {0x2185, 0x2188}, - {0x218A, 0x218B}, {0x219A, 0x219B}, {0x219C, 0x219F}, - {0x21A0, 0x21A0}, {0x21A1, 0x21A2}, {0x21A3, 0x21A3}, - {0x21A4, 0x21A5}, {0x21A6, 0x21A6}, {0x21A7, 0x21AD}, - {0x21AE, 0x21AE}, {0x21AF, 0x21B7}, {0x21BA, 0x21CD}, - {0x21CE, 0x21CF}, {0x21D0, 0x21D1}, {0x21D3, 0x21D3}, - {0x21D5, 0x21E6}, {0x21E8, 0x21F3}, {0x21F4, 0x21FF}, - {0x2201, 0x2201}, {0x2204, 0x2206}, {0x2209, 0x220A}, - {0x220C, 0x220E}, {0x2210, 0x2210}, {0x2212, 0x2214}, - {0x2216, 0x2219}, {0x221B, 0x221C}, {0x2221, 0x2222}, - {0x2224, 0x2224}, {0x2226, 0x2226}, {0x222D, 0x222D}, - {0x222F, 0x2233}, {0x2238, 0x223B}, {0x223E, 0x2247}, - {0x2249, 0x224B}, {0x224D, 0x2251}, {0x2253, 0x225F}, - {0x2262, 0x2263}, {0x2268, 0x2269}, {0x226C, 0x226D}, - {0x2270, 0x2281}, {0x2284, 0x2285}, {0x2288, 0x2294}, - {0x2296, 0x2298}, {0x229A, 0x22A4}, {0x22A6, 0x22BE}, - {0x22C0, 0x22FF}, {0x2300, 0x2307}, {0x2308, 0x2308}, - {0x2309, 0x2309}, {0x230A, 0x230A}, {0x230B, 0x230B}, - {0x230C, 0x2311}, {0x2313, 0x2319}, {0x231C, 0x231F}, - {0x2320, 0x2321}, {0x2322, 0x2328}, {0x232B, 0x237B}, - {0x237C, 0x237C}, {0x237D, 0x239A}, {0x239B, 0x23B3}, - {0x23B4, 0x23DB}, {0x23DC, 0x23E1}, {0x23E2, 0x23E8}, - {0x23ED, 0x23EF}, {0x23F1, 0x23F2}, {0x23F4, 0x23FE}, - {0x2400, 0x2426}, {0x2440, 0x244A}, {0x24EA, 0x24EA}, - {0x254C, 0x254F}, {0x2574, 0x257F}, {0x2590, 0x2591}, - {0x2596, 0x259F}, {0x25A2, 0x25A2}, {0x25AA, 0x25B1}, - {0x25B4, 0x25B5}, {0x25B8, 0x25BB}, {0x25BE, 0x25BF}, - {0x25C2, 0x25C5}, {0x25C9, 0x25CA}, {0x25CC, 0x25CD}, - {0x25D2, 0x25E1}, {0x25E6, 0x25EE}, {0x25F0, 0x25F7}, - {0x25F8, 0x25FC}, {0x25FF, 0x25FF}, {0x2600, 0x2604}, - {0x2607, 0x2608}, {0x260A, 0x260D}, {0x2610, 0x2613}, - {0x2616, 0x261B}, {0x261D, 0x261D}, {0x261F, 0x263F}, - {0x2641, 0x2641}, {0x2643, 0x2647}, {0x2654, 0x265F}, - {0x2662, 0x2662}, {0x2666, 0x2666}, {0x266B, 0x266B}, - {0x266E, 0x266E}, {0x2670, 0x267E}, {0x2680, 0x2692}, - {0x2694, 0x269D}, {0x26A0, 0x26A0}, {0x26A2, 0x26A9}, - {0x26AC, 0x26BC}, {0x26C0, 0x26C3}, {0x26E2, 0x26E2}, - {0x26E4, 0x26E7}, {0x2700, 0x2704}, {0x2706, 0x2709}, - {0x270C, 0x2727}, {0x2729, 0x273C}, {0x273E, 0x274B}, - {0x274D, 0x274D}, {0x274F, 0x2752}, {0x2756, 0x2756}, - {0x2758, 0x2767}, {0x2768, 0x2768}, {0x2769, 0x2769}, - {0x276A, 0x276A}, {0x276B, 0x276B}, {0x276C, 0x276C}, - {0x276D, 0x276D}, {0x276E, 0x276E}, {0x276F, 0x276F}, - {0x2770, 0x2770}, {0x2771, 0x2771}, {0x2772, 0x2772}, - {0x2773, 0x2773}, {0x2774, 0x2774}, {0x2775, 0x2775}, - {0x2780, 0x2793}, {0x2794, 0x2794}, {0x2798, 0x27AF}, - {0x27B1, 0x27BE}, {0x27C0, 0x27C4}, {0x27C5, 0x27C5}, - {0x27C6, 0x27C6}, {0x27C7, 0x27E5}, {0x27EE, 0x27EE}, - {0x27EF, 0x27EF}, {0x27F0, 0x27FF}, {0x2800, 0x28FF}, - {0x2900, 0x297F}, {0x2980, 0x2982}, {0x2983, 0x2983}, - {0x2984, 0x2984}, {0x2987, 0x2987}, {0x2988, 0x2988}, - {0x2989, 0x2989}, {0x298A, 0x298A}, {0x298B, 0x298B}, - {0x298C, 0x298C}, {0x298D, 0x298D}, {0x298E, 0x298E}, - {0x298F, 0x298F}, {0x2990, 0x2990}, {0x2991, 0x2991}, - {0x2992, 0x2992}, {0x2993, 0x2993}, {0x2994, 0x2994}, - {0x2995, 0x2995}, {0x2996, 0x2996}, {0x2997, 0x2997}, - {0x2998, 0x2998}, {0x2999, 0x29D7}, {0x29D8, 0x29D8}, - {0x29D9, 0x29D9}, {0x29DA, 0x29DA}, {0x29DB, 0x29DB}, - {0x29DC, 0x29FB}, {0x29FC, 0x29FC}, {0x29FD, 0x29FD}, - {0x29FE, 0x29FF}, {0x2A00, 0x2AFF}, {0x2B00, 0x2B1A}, - {0x2B1D, 0x2B2F}, {0x2B30, 0x2B44}, {0x2B45, 0x2B46}, - {0x2B47, 0x2B4C}, {0x2B4D, 0x2B4F}, {0x2B51, 0x2B54}, - {0x2B5A, 0x2B73}, {0x2B76, 0x2B95}, {0x2B98, 0x2BB9}, - {0x2BBD, 0x2BC8}, {0x2BCA, 0x2BD1}, {0x2BEC, 0x2BEF}, - {0x2C00, 0x2C2E}, {0x2C30, 0x2C5E}, {0x2C60, 0x2C7B}, - {0x2C7C, 0x2C7D}, {0x2C7E, 0x2C7F}, {0x2C80, 0x2CE4}, - {0x2CE5, 0x2CEA}, {0x2CEB, 0x2CEE}, {0x2CEF, 0x2CF1}, - {0x2CF2, 0x2CF3}, {0x2CF9, 0x2CFC}, {0x2CFD, 0x2CFD}, - {0x2CFE, 0x2CFF}, {0x2D00, 0x2D25}, {0x2D27, 0x2D27}, - {0x2D2D, 0x2D2D}, {0x2D30, 0x2D67}, {0x2D6F, 0x2D6F}, - {0x2D70, 0x2D70}, {0x2D7F, 0x2D7F}, {0x2D80, 0x2D96}, - {0x2DA0, 0x2DA6}, {0x2DA8, 0x2DAE}, {0x2DB0, 0x2DB6}, - {0x2DB8, 0x2DBE}, {0x2DC0, 0x2DC6}, {0x2DC8, 0x2DCE}, - {0x2DD0, 0x2DD6}, {0x2DD8, 0x2DDE}, {0x2DE0, 0x2DFF}, - {0x2E00, 0x2E01}, {0x2E02, 0x2E02}, {0x2E03, 0x2E03}, - {0x2E04, 0x2E04}, {0x2E05, 0x2E05}, {0x2E06, 0x2E08}, - {0x2E09, 0x2E09}, {0x2E0A, 0x2E0A}, {0x2E0B, 0x2E0B}, - {0x2E0C, 0x2E0C}, {0x2E0D, 0x2E0D}, {0x2E0E, 0x2E16}, - {0x2E17, 0x2E17}, {0x2E18, 0x2E19}, {0x2E1A, 0x2E1A}, - {0x2E1B, 0x2E1B}, {0x2E1C, 0x2E1C}, {0x2E1D, 0x2E1D}, - {0x2E1E, 0x2E1F}, {0x2E20, 0x2E20}, {0x2E21, 0x2E21}, - {0x2E22, 0x2E22}, {0x2E23, 0x2E23}, {0x2E24, 0x2E24}, - {0x2E25, 0x2E25}, {0x2E26, 0x2E26}, {0x2E27, 0x2E27}, - {0x2E28, 0x2E28}, {0x2E29, 0x2E29}, {0x2E2A, 0x2E2E}, - {0x2E2F, 0x2E2F}, {0x2E30, 0x2E39}, {0x2E3A, 0x2E3B}, - {0x2E3C, 0x2E3F}, {0x2E40, 0x2E40}, {0x2E41, 0x2E41}, - {0x2E42, 0x2E42}, {0x2E43, 0x2E44}, {0x303F, 0x303F}, - {0x4DC0, 0x4DFF}, {0xA4D0, 0xA4F7}, {0xA4F8, 0xA4FD}, - {0xA4FE, 0xA4FF}, {0xA500, 0xA60B}, {0xA60C, 0xA60C}, - {0xA60D, 0xA60F}, {0xA610, 0xA61F}, {0xA620, 0xA629}, - {0xA62A, 0xA62B}, {0xA640, 0xA66D}, {0xA66E, 0xA66E}, - {0xA66F, 0xA66F}, {0xA670, 0xA672}, {0xA673, 0xA673}, - {0xA674, 0xA67D}, {0xA67E, 0xA67E}, {0xA67F, 0xA67F}, - {0xA680, 0xA69B}, {0xA69C, 0xA69D}, {0xA69E, 0xA69F}, - {0xA6A0, 0xA6E5}, {0xA6E6, 0xA6EF}, {0xA6F0, 0xA6F1}, - {0xA6F2, 0xA6F7}, {0xA700, 0xA716}, {0xA717, 0xA71F}, - {0xA720, 0xA721}, {0xA722, 0xA76F}, {0xA770, 0xA770}, - {0xA771, 0xA787}, {0xA788, 0xA788}, {0xA789, 0xA78A}, - {0xA78B, 0xA78E}, {0xA78F, 0xA78F}, {0xA790, 0xA7AE}, - {0xA7B0, 0xA7B7}, {0xA7F7, 0xA7F7}, {0xA7F8, 0xA7F9}, - {0xA7FA, 0xA7FA}, {0xA7FB, 0xA7FF}, {0xA800, 0xA801}, - {0xA802, 0xA802}, {0xA803, 0xA805}, {0xA806, 0xA806}, - {0xA807, 0xA80A}, {0xA80B, 0xA80B}, {0xA80C, 0xA822}, - {0xA823, 0xA824}, {0xA825, 0xA826}, {0xA827, 0xA827}, - {0xA828, 0xA82B}, {0xA830, 0xA835}, {0xA836, 0xA837}, - {0xA838, 0xA838}, {0xA839, 0xA839}, {0xA840, 0xA873}, - {0xA874, 0xA877}, {0xA880, 0xA881}, {0xA882, 0xA8B3}, - {0xA8B4, 0xA8C3}, {0xA8C4, 0xA8C5}, {0xA8CE, 0xA8CF}, - {0xA8D0, 0xA8D9}, {0xA8E0, 0xA8F1}, {0xA8F2, 0xA8F7}, - {0xA8F8, 0xA8FA}, {0xA8FB, 0xA8FB}, {0xA8FC, 0xA8FC}, - {0xA8FD, 0xA8FD}, {0xA900, 0xA909}, {0xA90A, 0xA925}, - {0xA926, 0xA92D}, {0xA92E, 0xA92F}, {0xA930, 0xA946}, - {0xA947, 0xA951}, {0xA952, 0xA953}, {0xA95F, 0xA95F}, - {0xA980, 0xA982}, {0xA983, 0xA983}, {0xA984, 0xA9B2}, - {0xA9B3, 0xA9B3}, {0xA9B4, 0xA9B5}, {0xA9B6, 0xA9B9}, - {0xA9BA, 0xA9BB}, {0xA9BC, 0xA9BC}, {0xA9BD, 0xA9C0}, - {0xA9C1, 0xA9CD}, {0xA9CF, 0xA9CF}, {0xA9D0, 0xA9D9}, - {0xA9DE, 0xA9DF}, {0xA9E0, 0xA9E4}, {0xA9E5, 0xA9E5}, - {0xA9E6, 0xA9E6}, {0xA9E7, 0xA9EF}, {0xA9F0, 0xA9F9}, - {0xA9FA, 0xA9FE}, {0xAA00, 0xAA28}, {0xAA29, 0xAA2E}, - {0xAA2F, 0xAA30}, {0xAA31, 0xAA32}, {0xAA33, 0xAA34}, - {0xAA35, 0xAA36}, {0xAA40, 0xAA42}, {0xAA43, 0xAA43}, - {0xAA44, 0xAA4B}, {0xAA4C, 0xAA4C}, {0xAA4D, 0xAA4D}, - {0xAA50, 0xAA59}, {0xAA5C, 0xAA5F}, {0xAA60, 0xAA6F}, - {0xAA70, 0xAA70}, {0xAA71, 0xAA76}, {0xAA77, 0xAA79}, - {0xAA7A, 0xAA7A}, {0xAA7B, 0xAA7B}, {0xAA7C, 0xAA7C}, - {0xAA7D, 0xAA7D}, {0xAA7E, 0xAA7F}, {0xAA80, 0xAAAF}, - {0xAAB0, 0xAAB0}, {0xAAB1, 0xAAB1}, {0xAAB2, 0xAAB4}, - {0xAAB5, 0xAAB6}, {0xAAB7, 0xAAB8}, {0xAAB9, 0xAABD}, - {0xAABE, 0xAABF}, {0xAAC0, 0xAAC0}, {0xAAC1, 0xAAC1}, - {0xAAC2, 0xAAC2}, {0xAADB, 0xAADC}, {0xAADD, 0xAADD}, - {0xAADE, 0xAADF}, {0xAAE0, 0xAAEA}, {0xAAEB, 0xAAEB}, - {0xAAEC, 0xAAED}, {0xAAEE, 0xAAEF}, {0xAAF0, 0xAAF1}, - {0xAAF2, 0xAAF2}, {0xAAF3, 0xAAF4}, {0xAAF5, 0xAAF5}, - {0xAAF6, 0xAAF6}, {0xAB01, 0xAB06}, {0xAB09, 0xAB0E}, - {0xAB11, 0xAB16}, {0xAB20, 0xAB26}, {0xAB28, 0xAB2E}, - {0xAB30, 0xAB5A}, {0xAB5B, 0xAB5B}, {0xAB5C, 0xAB5F}, - {0xAB60, 0xAB65}, {0xAB70, 0xABBF}, {0xABC0, 0xABE2}, - {0xABE3, 0xABE4}, {0xABE5, 0xABE5}, {0xABE6, 0xABE7}, - {0xABE8, 0xABE8}, {0xABE9, 0xABEA}, {0xABEB, 0xABEB}, - {0xABEC, 0xABEC}, {0xABED, 0xABED}, {0xABF0, 0xABF9}, - {0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, {0xD800, 0xDB7F}, - {0xDB80, 0xDBFF}, {0xDC00, 0xDFFF}, {0xFB00, 0xFB06}, - {0xFB13, 0xFB17}, {0xFB1D, 0xFB1D}, {0xFB1E, 0xFB1E}, - {0xFB1F, 0xFB28}, {0xFB29, 0xFB29}, {0xFB2A, 0xFB36}, - {0xFB38, 0xFB3C}, {0xFB3E, 0xFB3E}, {0xFB40, 0xFB41}, - {0xFB43, 0xFB44}, {0xFB46, 0xFB4F}, {0xFB50, 0xFBB1}, - {0xFBB2, 0xFBC1}, {0xFBD3, 0xFD3D}, {0xFD3E, 0xFD3E}, - {0xFD3F, 0xFD3F}, {0xFD50, 0xFD8F}, {0xFD92, 0xFDC7}, - {0xFDF0, 0xFDFB}, {0xFDFC, 0xFDFC}, {0xFDFD, 0xFDFD}, - {0xFE20, 0xFE2F}, {0xFE70, 0xFE74}, {0xFE76, 0xFEFC}, - {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0xFFFC, 0xFFFC}, - {0x10000, 0x1000B}, {0x1000D, 0x10026}, {0x10028, 0x1003A}, - {0x1003C, 0x1003D}, {0x1003F, 0x1004D}, {0x10050, 0x1005D}, - {0x10080, 0x100FA}, {0x10100, 0x10102}, {0x10107, 0x10133}, - {0x10137, 0x1013F}, {0x10140, 0x10174}, {0x10175, 0x10178}, - {0x10179, 0x10189}, {0x1018A, 0x1018B}, {0x1018C, 0x1018E}, - {0x10190, 0x1019B}, {0x101A0, 0x101A0}, {0x101D0, 0x101FC}, - {0x101FD, 0x101FD}, {0x10280, 0x1029C}, {0x102A0, 0x102D0}, - {0x102E0, 0x102E0}, {0x102E1, 0x102FB}, {0x10300, 0x1031F}, - {0x10320, 0x10323}, {0x10330, 0x10340}, {0x10341, 0x10341}, - {0x10342, 0x10349}, {0x1034A, 0x1034A}, {0x10350, 0x10375}, - {0x10376, 0x1037A}, {0x10380, 0x1039D}, {0x1039F, 0x1039F}, - {0x103A0, 0x103C3}, {0x103C8, 0x103CF}, {0x103D0, 0x103D0}, - {0x103D1, 0x103D5}, {0x10400, 0x1044F}, {0x10450, 0x1047F}, - {0x10480, 0x1049D}, {0x104A0, 0x104A9}, {0x104B0, 0x104D3}, - {0x104D8, 0x104FB}, {0x10500, 0x10527}, {0x10530, 0x10563}, - {0x1056F, 0x1056F}, {0x10600, 0x10736}, {0x10740, 0x10755}, - {0x10760, 0x10767}, {0x10800, 0x10805}, {0x10808, 0x10808}, - {0x1080A, 0x10835}, {0x10837, 0x10838}, {0x1083C, 0x1083C}, - {0x1083F, 0x1083F}, {0x10840, 0x10855}, {0x10857, 0x10857}, - {0x10858, 0x1085F}, {0x10860, 0x10876}, {0x10877, 0x10878}, - {0x10879, 0x1087F}, {0x10880, 0x1089E}, {0x108A7, 0x108AF}, - {0x108E0, 0x108F2}, {0x108F4, 0x108F5}, {0x108FB, 0x108FF}, - {0x10900, 0x10915}, {0x10916, 0x1091B}, {0x1091F, 0x1091F}, - {0x10920, 0x10939}, {0x1093F, 0x1093F}, {0x10980, 0x1099F}, - {0x109A0, 0x109B7}, {0x109BC, 0x109BD}, {0x109BE, 0x109BF}, - {0x109C0, 0x109CF}, {0x109D2, 0x109FF}, {0x10A00, 0x10A00}, - {0x10A01, 0x10A03}, {0x10A05, 0x10A06}, {0x10A0C, 0x10A0F}, - {0x10A10, 0x10A13}, {0x10A15, 0x10A17}, {0x10A19, 0x10A33}, - {0x10A38, 0x10A3A}, {0x10A3F, 0x10A3F}, {0x10A40, 0x10A47}, - {0x10A50, 0x10A58}, {0x10A60, 0x10A7C}, {0x10A7D, 0x10A7E}, - {0x10A7F, 0x10A7F}, {0x10A80, 0x10A9C}, {0x10A9D, 0x10A9F}, - {0x10AC0, 0x10AC7}, {0x10AC8, 0x10AC8}, {0x10AC9, 0x10AE4}, - {0x10AE5, 0x10AE6}, {0x10AEB, 0x10AEF}, {0x10AF0, 0x10AF6}, - {0x10B00, 0x10B35}, {0x10B39, 0x10B3F}, {0x10B40, 0x10B55}, - {0x10B58, 0x10B5F}, {0x10B60, 0x10B72}, {0x10B78, 0x10B7F}, - {0x10B80, 0x10B91}, {0x10B99, 0x10B9C}, {0x10BA9, 0x10BAF}, - {0x10C00, 0x10C48}, {0x10C80, 0x10CB2}, {0x10CC0, 0x10CF2}, - {0x10CFA, 0x10CFF}, {0x10E60, 0x10E7E}, {0x11000, 0x11000}, - {0x11001, 0x11001}, {0x11002, 0x11002}, {0x11003, 0x11037}, - {0x11038, 0x11046}, {0x11047, 0x1104D}, {0x11052, 0x11065}, - {0x11066, 0x1106F}, {0x1107F, 0x1107F}, {0x11080, 0x11081}, - {0x11082, 0x11082}, {0x11083, 0x110AF}, {0x110B0, 0x110B2}, - {0x110B3, 0x110B6}, {0x110B7, 0x110B8}, {0x110B9, 0x110BA}, - {0x110BB, 0x110BC}, {0x110BD, 0x110BD}, {0x110BE, 0x110C1}, - {0x110D0, 0x110E8}, {0x110F0, 0x110F9}, {0x11100, 0x11102}, - {0x11103, 0x11126}, {0x11127, 0x1112B}, {0x1112C, 0x1112C}, - {0x1112D, 0x11134}, {0x11136, 0x1113F}, {0x11140, 0x11143}, - {0x11150, 0x11172}, {0x11173, 0x11173}, {0x11174, 0x11175}, - {0x11176, 0x11176}, {0x11180, 0x11181}, {0x11182, 0x11182}, - {0x11183, 0x111B2}, {0x111B3, 0x111B5}, {0x111B6, 0x111BE}, - {0x111BF, 0x111C0}, {0x111C1, 0x111C4}, {0x111C5, 0x111C9}, - {0x111CA, 0x111CC}, {0x111CD, 0x111CD}, {0x111D0, 0x111D9}, - {0x111DA, 0x111DA}, {0x111DB, 0x111DB}, {0x111DC, 0x111DC}, - {0x111DD, 0x111DF}, {0x111E1, 0x111F4}, {0x11200, 0x11211}, - {0x11213, 0x1122B}, {0x1122C, 0x1122E}, {0x1122F, 0x11231}, - {0x11232, 0x11233}, {0x11234, 0x11234}, {0x11235, 0x11235}, - {0x11236, 0x11237}, {0x11238, 0x1123D}, {0x1123E, 0x1123E}, - {0x11280, 0x11286}, {0x11288, 0x11288}, {0x1128A, 0x1128D}, - {0x1128F, 0x1129D}, {0x1129F, 0x112A8}, {0x112A9, 0x112A9}, - {0x112B0, 0x112DE}, {0x112DF, 0x112DF}, {0x112E0, 0x112E2}, - {0x112E3, 0x112EA}, {0x112F0, 0x112F9}, {0x11300, 0x11301}, - {0x11302, 0x11303}, {0x11305, 0x1130C}, {0x1130F, 0x11310}, - {0x11313, 0x11328}, {0x1132A, 0x11330}, {0x11332, 0x11333}, - {0x11335, 0x11339}, {0x1133C, 0x1133C}, {0x1133D, 0x1133D}, - {0x1133E, 0x1133F}, {0x11340, 0x11340}, {0x11341, 0x11344}, - {0x11347, 0x11348}, {0x1134B, 0x1134D}, {0x11350, 0x11350}, - {0x11357, 0x11357}, {0x1135D, 0x11361}, {0x11362, 0x11363}, - {0x11366, 0x1136C}, {0x11370, 0x11374}, {0x11400, 0x11434}, - {0x11435, 0x11437}, {0x11438, 0x1143F}, {0x11440, 0x11441}, - {0x11442, 0x11444}, {0x11445, 0x11445}, {0x11446, 0x11446}, - {0x11447, 0x1144A}, {0x1144B, 0x1144F}, {0x11450, 0x11459}, - {0x1145B, 0x1145B}, {0x1145D, 0x1145D}, {0x11480, 0x114AF}, - {0x114B0, 0x114B2}, {0x114B3, 0x114B8}, {0x114B9, 0x114B9}, - {0x114BA, 0x114BA}, {0x114BB, 0x114BE}, {0x114BF, 0x114C0}, - {0x114C1, 0x114C1}, {0x114C2, 0x114C3}, {0x114C4, 0x114C5}, - {0x114C6, 0x114C6}, {0x114C7, 0x114C7}, {0x114D0, 0x114D9}, - {0x11580, 0x115AE}, {0x115AF, 0x115B1}, {0x115B2, 0x115B5}, - {0x115B8, 0x115BB}, {0x115BC, 0x115BD}, {0x115BE, 0x115BE}, - {0x115BF, 0x115C0}, {0x115C1, 0x115D7}, {0x115D8, 0x115DB}, - {0x115DC, 0x115DD}, {0x11600, 0x1162F}, {0x11630, 0x11632}, - {0x11633, 0x1163A}, {0x1163B, 0x1163C}, {0x1163D, 0x1163D}, - {0x1163E, 0x1163E}, {0x1163F, 0x11640}, {0x11641, 0x11643}, - {0x11644, 0x11644}, {0x11650, 0x11659}, {0x11660, 0x1166C}, - {0x11680, 0x116AA}, {0x116AB, 0x116AB}, {0x116AC, 0x116AC}, - {0x116AD, 0x116AD}, {0x116AE, 0x116AF}, {0x116B0, 0x116B5}, - {0x116B6, 0x116B6}, {0x116B7, 0x116B7}, {0x116C0, 0x116C9}, - {0x11700, 0x11719}, {0x1171D, 0x1171F}, {0x11720, 0x11721}, - {0x11722, 0x11725}, {0x11726, 0x11726}, {0x11727, 0x1172B}, - {0x11730, 0x11739}, {0x1173A, 0x1173B}, {0x1173C, 0x1173E}, - {0x1173F, 0x1173F}, {0x118A0, 0x118DF}, {0x118E0, 0x118E9}, - {0x118EA, 0x118F2}, {0x118FF, 0x118FF}, {0x11AC0, 0x11AF8}, - {0x11C00, 0x11C08}, {0x11C0A, 0x11C2E}, {0x11C2F, 0x11C2F}, - {0x11C30, 0x11C36}, {0x11C38, 0x11C3D}, {0x11C3E, 0x11C3E}, - {0x11C3F, 0x11C3F}, {0x11C40, 0x11C40}, {0x11C41, 0x11C45}, - {0x11C50, 0x11C59}, {0x11C5A, 0x11C6C}, {0x11C70, 0x11C71}, - {0x11C72, 0x11C8F}, {0x11C92, 0x11CA7}, {0x11CA9, 0x11CA9}, - {0x11CAA, 0x11CB0}, {0x11CB1, 0x11CB1}, {0x11CB2, 0x11CB3}, - {0x11CB4, 0x11CB4}, {0x11CB5, 0x11CB6}, {0x12000, 0x12399}, - {0x12400, 0x1246E}, {0x12470, 0x12474}, {0x12480, 0x12543}, - {0x13000, 0x1342E}, {0x14400, 0x14646}, {0x16800, 0x16A38}, - {0x16A40, 0x16A5E}, {0x16A60, 0x16A69}, {0x16A6E, 0x16A6F}, - {0x16AD0, 0x16AED}, {0x16AF0, 0x16AF4}, {0x16AF5, 0x16AF5}, - {0x16B00, 0x16B2F}, {0x16B30, 0x16B36}, {0x16B37, 0x16B3B}, - {0x16B3C, 0x16B3F}, {0x16B40, 0x16B43}, {0x16B44, 0x16B44}, - {0x16B45, 0x16B45}, {0x16B50, 0x16B59}, {0x16B5B, 0x16B61}, - {0x16B63, 0x16B77}, {0x16B7D, 0x16B8F}, {0x16F00, 0x16F44}, - {0x16F50, 0x16F50}, {0x16F51, 0x16F7E}, {0x16F8F, 0x16F92}, - {0x16F93, 0x16F9F}, {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C}, - {0x1BC80, 0x1BC88}, {0x1BC90, 0x1BC99}, {0x1BC9C, 0x1BC9C}, - {0x1BC9D, 0x1BC9E}, {0x1BC9F, 0x1BC9F}, {0x1BCA0, 0x1BCA3}, - {0x1D000, 0x1D0F5}, {0x1D100, 0x1D126}, {0x1D129, 0x1D164}, - {0x1D165, 0x1D166}, {0x1D167, 0x1D169}, {0x1D16A, 0x1D16C}, - {0x1D16D, 0x1D172}, {0x1D173, 0x1D17A}, {0x1D17B, 0x1D182}, - {0x1D183, 0x1D184}, {0x1D185, 0x1D18B}, {0x1D18C, 0x1D1A9}, - {0x1D1AA, 0x1D1AD}, {0x1D1AE, 0x1D1E8}, {0x1D200, 0x1D241}, - {0x1D242, 0x1D244}, {0x1D245, 0x1D245}, {0x1D300, 0x1D356}, - {0x1D360, 0x1D371}, {0x1D400, 0x1D454}, {0x1D456, 0x1D49C}, - {0x1D49E, 0x1D49F}, {0x1D4A2, 0x1D4A2}, {0x1D4A5, 0x1D4A6}, - {0x1D4A9, 0x1D4AC}, {0x1D4AE, 0x1D4B9}, {0x1D4BB, 0x1D4BB}, - {0x1D4BD, 0x1D4C3}, {0x1D4C5, 0x1D505}, {0x1D507, 0x1D50A}, - {0x1D50D, 0x1D514}, {0x1D516, 0x1D51C}, {0x1D51E, 0x1D539}, - {0x1D53B, 0x1D53E}, {0x1D540, 0x1D544}, {0x1D546, 0x1D546}, - {0x1D54A, 0x1D550}, {0x1D552, 0x1D6A5}, {0x1D6A8, 0x1D6C0}, - {0x1D6C1, 0x1D6C1}, {0x1D6C2, 0x1D6DA}, {0x1D6DB, 0x1D6DB}, - {0x1D6DC, 0x1D6FA}, {0x1D6FB, 0x1D6FB}, {0x1D6FC, 0x1D714}, - {0x1D715, 0x1D715}, {0x1D716, 0x1D734}, {0x1D735, 0x1D735}, - {0x1D736, 0x1D74E}, {0x1D74F, 0x1D74F}, {0x1D750, 0x1D76E}, - {0x1D76F, 0x1D76F}, {0x1D770, 0x1D788}, {0x1D789, 0x1D789}, - {0x1D78A, 0x1D7A8}, {0x1D7A9, 0x1D7A9}, {0x1D7AA, 0x1D7C2}, - {0x1D7C3, 0x1D7C3}, {0x1D7C4, 0x1D7CB}, {0x1D7CE, 0x1D7FF}, - {0x1D800, 0x1D9FF}, {0x1DA00, 0x1DA36}, {0x1DA37, 0x1DA3A}, - {0x1DA3B, 0x1DA6C}, {0x1DA6D, 0x1DA74}, {0x1DA75, 0x1DA75}, - {0x1DA76, 0x1DA83}, {0x1DA84, 0x1DA84}, {0x1DA85, 0x1DA86}, - {0x1DA87, 0x1DA8B}, {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF}, - {0x1E000, 0x1E006}, {0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, - {0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, {0x1E800, 0x1E8C4}, - {0x1E8C7, 0x1E8CF}, {0x1E8D0, 0x1E8D6}, {0x1E900, 0x1E943}, - {0x1E944, 0x1E94A}, {0x1E950, 0x1E959}, {0x1E95E, 0x1E95F}, - {0x1EE00, 0x1EE03}, {0x1EE05, 0x1EE1F}, {0x1EE21, 0x1EE22}, - {0x1EE24, 0x1EE24}, {0x1EE27, 0x1EE27}, {0x1EE29, 0x1EE32}, - {0x1EE34, 0x1EE37}, {0x1EE39, 0x1EE39}, {0x1EE3B, 0x1EE3B}, - {0x1EE42, 0x1EE42}, {0x1EE47, 0x1EE47}, {0x1EE49, 0x1EE49}, - {0x1EE4B, 0x1EE4B}, {0x1EE4D, 0x1EE4F}, {0x1EE51, 0x1EE52}, - {0x1EE54, 0x1EE54}, {0x1EE57, 0x1EE57}, {0x1EE59, 0x1EE59}, - {0x1EE5B, 0x1EE5B}, {0x1EE5D, 0x1EE5D}, {0x1EE5F, 0x1EE5F}, - {0x1EE61, 0x1EE62}, {0x1EE64, 0x1EE64}, {0x1EE67, 0x1EE6A}, - {0x1EE6C, 0x1EE72}, {0x1EE74, 0x1EE77}, {0x1EE79, 0x1EE7C}, - {0x1EE7E, 0x1EE7E}, {0x1EE80, 0x1EE89}, {0x1EE8B, 0x1EE9B}, - {0x1EEA1, 0x1EEA3}, {0x1EEA5, 0x1EEA9}, {0x1EEAB, 0x1EEBB}, - {0x1EEF0, 0x1EEF1}, {0x1F000, 0x1F003}, {0x1F005, 0x1F02B}, - {0x1F030, 0x1F093}, {0x1F0A0, 0x1F0AE}, {0x1F0B1, 0x1F0BF}, - {0x1F0C1, 0x1F0CE}, {0x1F0D1, 0x1F0F5}, {0x1F10B, 0x1F10C}, - {0x1F12E, 0x1F12E}, {0x1F16A, 0x1F16B}, {0x1F1E6, 0x1F1FF}, - {0x1F321, 0x1F32C}, {0x1F336, 0x1F336}, {0x1F37D, 0x1F37D}, - {0x1F394, 0x1F39F}, {0x1F3CB, 0x1F3CE}, {0x1F3D4, 0x1F3DF}, - {0x1F3F1, 0x1F3F3}, {0x1F3F5, 0x1F3F7}, {0x1F43F, 0x1F43F}, - {0x1F441, 0x1F441}, {0x1F4FD, 0x1F4FE}, {0x1F53E, 0x1F54A}, - {0x1F54F, 0x1F54F}, {0x1F568, 0x1F579}, {0x1F57B, 0x1F594}, - {0x1F597, 0x1F5A3}, {0x1F5A5, 0x1F5FA}, {0x1F650, 0x1F67F}, - {0x1F6C6, 0x1F6CB}, {0x1F6CD, 0x1F6CF}, {0x1F6E0, 0x1F6EA}, - {0x1F6F0, 0x1F6F3}, {0x1F700, 0x1F773}, {0x1F780, 0x1F7D4}, - {0x1F800, 0x1F80B}, {0x1F810, 0x1F847}, {0x1F850, 0x1F859}, - {0x1F860, 0x1F887}, {0x1F890, 0x1F8AD}, {0xE0001, 0xE0001}, - {0xE0020, 0xE007F}, -} - -// Condition have flag EastAsianWidth whether the current locale is CJK or not. -type Condition struct { - EastAsianWidth bool -} - -// NewCondition return new instance of Condition which is current locale. -func NewCondition() *Condition { - return &Condition{EastAsianWidth} -} - -// RuneWidth returns the number of cells in r. -// See http://www.unicode.org/reports/tr11/ -func (c *Condition) RuneWidth(r rune) int { - switch { - case r < 0 || r > 0x10FFFF || - inTables(r, nonprint, combining, notassigned): - return 0 - case (c.EastAsianWidth && IsAmbiguousWidth(r)) || - inTables(r, doublewidth, emoji): - return 2 - default: - return 1 - } -} - -// StringWidth return width as you can see -func (c *Condition) StringWidth(s string) (width int) { - for _, r := range []rune(s) { - width += c.RuneWidth(r) - } - return width -} - -// Truncate return string truncated with w cells -func (c *Condition) Truncate(s string, w int, tail string) string { - if c.StringWidth(s) <= w { - return s - } - r := []rune(s) - tw := c.StringWidth(tail) - w -= tw - width := 0 - i := 0 - for ; i < len(r); i++ { - cw := c.RuneWidth(r[i]) - if width+cw > w { - break - } - width += cw - } - return string(r[0:i]) + tail -} - -// Wrap return string wrapped with w cells -func (c *Condition) Wrap(s string, w int) string { - width := 0 - out := "" - for _, r := range []rune(s) { - cw := RuneWidth(r) - if r == '\n' { - out += string(r) - width = 0 - continue - } else if width+cw > w { - out += "\n" - width = 0 - out += string(r) - width += cw - continue - } - out += string(r) - width += cw - } - return out -} - -// FillLeft return string filled in left by spaces in w cells -func (c *Condition) FillLeft(s string, w int) string { - width := c.StringWidth(s) - count := w - width - if count > 0 { - b := make([]byte, count) - for i := range b { - b[i] = ' ' - } - return string(b) + s - } - return s -} - -// FillRight return string filled in left by spaces in w cells -func (c *Condition) FillRight(s string, w int) string { - width := c.StringWidth(s) - count := w - width - if count > 0 { - b := make([]byte, count) - for i := range b { - b[i] = ' ' - } - return s + string(b) - } - return s -} - -// RuneWidth returns the number of cells in r. -// See http://www.unicode.org/reports/tr11/ -func RuneWidth(r rune) int { - return DefaultCondition.RuneWidth(r) -} - -// IsAmbiguousWidth returns whether is ambiguous width or not. -func IsAmbiguousWidth(r rune) bool { - return inTables(r, private, ambiguous) -} - -// IsNeutralWidth returns whether is neutral width or not. -func IsNeutralWidth(r rune) bool { - return inTable(r, neutral) -} - -// StringWidth return width as you can see -func StringWidth(s string) (width int) { - return DefaultCondition.StringWidth(s) -} - -// Truncate return string truncated with w cells -func Truncate(s string, w int, tail string) string { - return DefaultCondition.Truncate(s, w, tail) -} - -// Wrap return string wrapped with w cells -func Wrap(s string, w int) string { - return DefaultCondition.Wrap(s, w) -} - -// FillLeft return string filled in left by spaces in w cells -func FillLeft(s string, w int) string { - return DefaultCondition.FillLeft(s, w) -} - -// FillRight return string filled in left by spaces in w cells -func FillRight(s string, w int) string { - return DefaultCondition.FillRight(s, w) -} diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_js.go b/vendor/github.com/mattn/go-runewidth/runewidth_js.go deleted file mode 100644 index 0ce32c5..0000000 --- a/vendor/github.com/mattn/go-runewidth/runewidth_js.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build js - -package runewidth - -func IsEastAsian() bool { - // TODO: Implement this for the web. Detect east asian in a compatible way, and return true. - return false -} diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_posix.go b/vendor/github.com/mattn/go-runewidth/runewidth_posix.go deleted file mode 100644 index c579e9a..0000000 --- a/vendor/github.com/mattn/go-runewidth/runewidth_posix.go +++ /dev/null @@ -1,77 +0,0 @@ -// +build !windows,!js - -package runewidth - -import ( - "os" - "regexp" - "strings" -) - -var reLoc = regexp.MustCompile(`^[a-z][a-z][a-z]?(?:_[A-Z][A-Z])?\.(.+)`) - -var mblenTable = map[string]int{ - "utf-8": 6, - "utf8": 6, - "jis": 8, - "eucjp": 3, - "euckr": 2, - "euccn": 2, - "sjis": 2, - "cp932": 2, - "cp51932": 2, - "cp936": 2, - "cp949": 2, - "cp950": 2, - "big5": 2, - "gbk": 2, - "gb2312": 2, -} - -func isEastAsian(locale string) bool { - charset := strings.ToLower(locale) - r := reLoc.FindStringSubmatch(locale) - if len(r) == 2 { - charset = strings.ToLower(r[1]) - } - - if strings.HasSuffix(charset, "@cjk_narrow") { - return false - } - - for pos, b := range []byte(charset) { - if b == '@' { - charset = charset[:pos] - break - } - } - max := 1 - if m, ok := mblenTable[charset]; ok { - max = m - } - if max > 1 && (charset[0] != 'u' || - strings.HasPrefix(locale, "ja") || - strings.HasPrefix(locale, "ko") || - strings.HasPrefix(locale, "zh")) { - return true - } - return false -} - -// IsEastAsian return true if the current locale is CJK -func IsEastAsian() bool { - locale := os.Getenv("LC_CTYPE") - if locale == "" { - locale = os.Getenv("LANG") - } - - // ignore C locale - if locale == "POSIX" || locale == "C" { - return false - } - if len(locale) > 1 && locale[0] == 'C' && (locale[1] == '.' || locale[1] == '-') { - return false - } - - return isEastAsian(locale) -} diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_windows.go b/vendor/github.com/mattn/go-runewidth/runewidth_windows.go deleted file mode 100644 index 0258876..0000000 --- a/vendor/github.com/mattn/go-runewidth/runewidth_windows.go +++ /dev/null @@ -1,25 +0,0 @@ -package runewidth - -import ( - "syscall" -) - -var ( - kernel32 = syscall.NewLazyDLL("kernel32") - procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP") -) - -// IsEastAsian return true if the current locale is CJK -func IsEastAsian() bool { - r1, _, _ := procGetConsoleOutputCP.Call() - if r1 == 0 { - return false - } - - switch int(r1) { - case 932, 51932, 936, 949, 950: - return true - } - - return false -} diff --git a/vendor/github.com/nu7hatch/gouuid/.gitignore b/vendor/github.com/nu7hatch/gouuid/.gitignore deleted file mode 100644 index f9d9cd8..0000000 --- a/vendor/github.com/nu7hatch/gouuid/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -_obj -_test -*.6 -*.out -_testmain.go -\#* -.\#* -*.log -_cgo* -*.o -*.a diff --git a/vendor/github.com/nu7hatch/gouuid/COPYING b/vendor/github.com/nu7hatch/gouuid/COPYING deleted file mode 100644 index d7849fd..0000000 --- a/vendor/github.com/nu7hatch/gouuid/COPYING +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2011 by Krzysztof Kowalik - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/nu7hatch/gouuid/README.md b/vendor/github.com/nu7hatch/gouuid/README.md deleted file mode 100644 index e3d025d..0000000 --- a/vendor/github.com/nu7hatch/gouuid/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Pure Go UUID implementation - -This package provides immutable UUID structs and the functions -NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 -and 5 UUIDs as specified in [RFC 4122](http://www.ietf.org/rfc/rfc4122.txt). - -## Installation - -Use the `go` tool: - - $ go get github.com/nu7hatch/gouuid - -## Usage - -See [documentation and examples](http://godoc.org/github.com/nu7hatch/gouuid) -for more information. - -## Copyright - -Copyright (C) 2011 by Krzysztof Kowalik . See [COPYING](https://github.com/nu7hatch/gouuid/tree/master/COPYING) -file for details. diff --git a/vendor/github.com/nu7hatch/gouuid/uuid.go b/vendor/github.com/nu7hatch/gouuid/uuid.go deleted file mode 100644 index ac9623b..0000000 --- a/vendor/github.com/nu7hatch/gouuid/uuid.go +++ /dev/null @@ -1,173 +0,0 @@ -// This package provides immutable UUID structs and the functions -// NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 -// and 5 UUIDs as specified in RFC 4122. -// -// Copyright (C) 2011 by Krzysztof Kowalik -package uuid - -import ( - "crypto/md5" - "crypto/rand" - "crypto/sha1" - "encoding/hex" - "errors" - "fmt" - "hash" - "regexp" -) - -// The UUID reserved variants. -const ( - ReservedNCS byte = 0x80 - ReservedRFC4122 byte = 0x40 - ReservedMicrosoft byte = 0x20 - ReservedFuture byte = 0x00 -) - -// The following standard UUIDs are for use with NewV3() or NewV5(). -var ( - NamespaceDNS, _ = ParseHex("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - NamespaceURL, _ = ParseHex("6ba7b811-9dad-11d1-80b4-00c04fd430c8") - NamespaceOID, _ = ParseHex("6ba7b812-9dad-11d1-80b4-00c04fd430c8") - NamespaceX500, _ = ParseHex("6ba7b814-9dad-11d1-80b4-00c04fd430c8") -) - -// Pattern used to parse hex string representation of the UUID. -// FIXME: do something to consider both brackets at one time, -// current one allows to parse string with only one opening -// or closing bracket. -const hexPattern = "^(urn\\:uuid\\:)?\\{?([a-z0-9]{8})-([a-z0-9]{4})-" + - "([1-5][a-z0-9]{3})-([a-z0-9]{4})-([a-z0-9]{12})\\}?$" - -var re = regexp.MustCompile(hexPattern) - -// A UUID representation compliant with specification in -// RFC 4122 document. -type UUID [16]byte - -// ParseHex creates a UUID object from given hex string -// representation. Function accepts UUID string in following -// formats: -// -// uuid.ParseHex("6ba7b814-9dad-11d1-80b4-00c04fd430c8") -// uuid.ParseHex("{6ba7b814-9dad-11d1-80b4-00c04fd430c8}") -// uuid.ParseHex("urn:uuid:6ba7b814-9dad-11d1-80b4-00c04fd430c8") -// -func ParseHex(s string) (u *UUID, err error) { - md := re.FindStringSubmatch(s) - if md == nil { - err = errors.New("Invalid UUID string") - return - } - hash := md[2] + md[3] + md[4] + md[5] + md[6] - b, err := hex.DecodeString(hash) - if err != nil { - return - } - u = new(UUID) - copy(u[:], b) - return -} - -// Parse creates a UUID object from given bytes slice. -func Parse(b []byte) (u *UUID, err error) { - if len(b) != 16 { - err = errors.New("Given slice is not valid UUID sequence") - return - } - u = new(UUID) - copy(u[:], b) - return -} - -// Generate a UUID based on the MD5 hash of a namespace identifier -// and a name. -func NewV3(ns *UUID, name []byte) (u *UUID, err error) { - if ns == nil { - err = errors.New("Invalid namespace UUID") - return - } - u = new(UUID) - // Set all bits to MD5 hash generated from namespace and name. - u.setBytesFromHash(md5.New(), ns[:], name) - u.setVariant(ReservedRFC4122) - u.setVersion(3) - return -} - -// Generate a random UUID. -func NewV4() (u *UUID, err error) { - u = new(UUID) - // Set all bits to randomly (or pseudo-randomly) chosen values. - _, err = rand.Read(u[:]) - if err != nil { - return - } - u.setVariant(ReservedRFC4122) - u.setVersion(4) - return -} - -// Generate a UUID based on the SHA-1 hash of a namespace identifier -// and a name. -func NewV5(ns *UUID, name []byte) (u *UUID, err error) { - u = new(UUID) - // Set all bits to truncated SHA1 hash generated from namespace - // and name. - u.setBytesFromHash(sha1.New(), ns[:], name) - u.setVariant(ReservedRFC4122) - u.setVersion(5) - return -} - -// Generate a MD5 hash of a namespace and a name, and copy it to the -// UUID slice. -func (u *UUID) setBytesFromHash(hash hash.Hash, ns, name []byte) { - hash.Write(ns[:]) - hash.Write(name) - copy(u[:], hash.Sum([]byte{})[:16]) -} - -// Set the two most significant bits (bits 6 and 7) of the -// clock_seq_hi_and_reserved to zero and one, respectively. -func (u *UUID) setVariant(v byte) { - switch v { - case ReservedNCS: - u[8] = (u[8] | ReservedNCS) & 0xBF - case ReservedRFC4122: - u[8] = (u[8] | ReservedRFC4122) & 0x7F - case ReservedMicrosoft: - u[8] = (u[8] | ReservedMicrosoft) & 0x3F - } -} - -// Variant returns the UUID Variant, which determines the internal -// layout of the UUID. This will be one of the constants: RESERVED_NCS, -// RFC_4122, RESERVED_MICROSOFT, RESERVED_FUTURE. -func (u *UUID) Variant() byte { - if u[8]&ReservedNCS == ReservedNCS { - return ReservedNCS - } else if u[8]&ReservedRFC4122 == ReservedRFC4122 { - return ReservedRFC4122 - } else if u[8]&ReservedMicrosoft == ReservedMicrosoft { - return ReservedMicrosoft - } - return ReservedFuture -} - -// Set the four most significant bits (bits 12 through 15) of the -// time_hi_and_version field to the 4-bit version number. -func (u *UUID) setVersion(v byte) { - u[6] = (u[6] & 0xF) | (v << 4) -} - -// Version returns a version number of the algorithm used to -// generate the UUID sequence. -func (u *UUID) Version() uint { - return uint(u[6] >> 4) -} - -// Returns unparsed version of the generated UUID sequence. -func (u *UUID) String() string { - return fmt.Sprintf("%x-%x-%x-%x-%x", u[0:4], u[4:6], u[6:8], u[8:10], u[10:]) -} diff --git a/vendor/github.com/pmezard/go-difflib/LICENSE b/vendor/github.com/pmezard/go-difflib/LICENSE deleted file mode 100644 index c67dad6..0000000 --- a/vendor/github.com/pmezard/go-difflib/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013, Patrick Mezard -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - The names of its contributors may not be used to endorse or promote -products derived from this software without specific prior written -permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go b/vendor/github.com/pmezard/go-difflib/difflib/difflib.go deleted file mode 100644 index 003e99f..0000000 --- a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go +++ /dev/null @@ -1,772 +0,0 @@ -// Package difflib is a partial port of Python difflib module. -// -// It provides tools to compare sequences of strings and generate textual diffs. -// -// The following class and functions have been ported: -// -// - SequenceMatcher -// -// - unified_diff -// -// - context_diff -// -// Getting unified diffs was the main goal of the port. Keep in mind this code -// is mostly suitable to output text differences in a human friendly way, there -// are no guarantees generated diffs are consumable by patch(1). -package difflib - -import ( - "bufio" - "bytes" - "fmt" - "io" - "strings" -) - -func min(a, b int) int { - if a < b { - return a - } - return b -} - -func max(a, b int) int { - if a > b { - return a - } - return b -} - -func calculateRatio(matches, length int) float64 { - if length > 0 { - return 2.0 * float64(matches) / float64(length) - } - return 1.0 -} - -type Match struct { - A int - B int - Size int -} - -type OpCode struct { - Tag byte - I1 int - I2 int - J1 int - J2 int -} - -// SequenceMatcher compares sequence of strings. The basic -// algorithm predates, and is a little fancier than, an algorithm -// published in the late 1980's by Ratcliff and Obershelp under the -// hyperbolic name "gestalt pattern matching". The basic idea is to find -// the longest contiguous matching subsequence that contains no "junk" -// elements (R-O doesn't address junk). The same idea is then applied -// recursively to the pieces of the sequences to the left and to the right -// of the matching subsequence. This does not yield minimal edit -// sequences, but does tend to yield matches that "look right" to people. -// -// SequenceMatcher tries to compute a "human-friendly diff" between two -// sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the -// longest *contiguous* & junk-free matching subsequence. That's what -// catches peoples' eyes. The Windows(tm) windiff has another interesting -// notion, pairing up elements that appear uniquely in each sequence. -// That, and the method here, appear to yield more intuitive difference -// reports than does diff. This method appears to be the least vulnerable -// to synching up on blocks of "junk lines", though (like blank lines in -// ordinary text files, or maybe "

" lines in HTML files). That may be -// because this is the only method of the 3 that has a *concept* of -// "junk" . -// -// Timing: Basic R-O is cubic time worst case and quadratic time expected -// case. SequenceMatcher is quadratic time for the worst case and has -// expected-case behavior dependent in a complicated way on how many -// elements the sequences have in common; best case time is linear. -type SequenceMatcher struct { - a []string - b []string - b2j map[string][]int - IsJunk func(string) bool - autoJunk bool - bJunk map[string]struct{} - matchingBlocks []Match - fullBCount map[string]int - bPopular map[string]struct{} - opCodes []OpCode -} - -func NewMatcher(a, b []string) *SequenceMatcher { - m := SequenceMatcher{autoJunk: true} - m.SetSeqs(a, b) - return &m -} - -func NewMatcherWithJunk(a, b []string, autoJunk bool, - isJunk func(string) bool) *SequenceMatcher { - - m := SequenceMatcher{IsJunk: isJunk, autoJunk: autoJunk} - m.SetSeqs(a, b) - return &m -} - -// Set two sequences to be compared. -func (m *SequenceMatcher) SetSeqs(a, b []string) { - m.SetSeq1(a) - m.SetSeq2(b) -} - -// Set the first sequence to be compared. The second sequence to be compared is -// not changed. -// -// SequenceMatcher computes and caches detailed information about the second -// sequence, so if you want to compare one sequence S against many sequences, -// use .SetSeq2(s) once and call .SetSeq1(x) repeatedly for each of the other -// sequences. -// -// See also SetSeqs() and SetSeq2(). -func (m *SequenceMatcher) SetSeq1(a []string) { - if &a == &m.a { - return - } - m.a = a - m.matchingBlocks = nil - m.opCodes = nil -} - -// Set the second sequence to be compared. The first sequence to be compared is -// not changed. -func (m *SequenceMatcher) SetSeq2(b []string) { - if &b == &m.b { - return - } - m.b = b - m.matchingBlocks = nil - m.opCodes = nil - m.fullBCount = nil - m.chainB() -} - -func (m *SequenceMatcher) chainB() { - // Populate line -> index mapping - b2j := map[string][]int{} - for i, s := range m.b { - indices := b2j[s] - indices = append(indices, i) - b2j[s] = indices - } - - // Purge junk elements - m.bJunk = map[string]struct{}{} - if m.IsJunk != nil { - junk := m.bJunk - for s, _ := range b2j { - if m.IsJunk(s) { - junk[s] = struct{}{} - } - } - for s, _ := range junk { - delete(b2j, s) - } - } - - // Purge remaining popular elements - popular := map[string]struct{}{} - n := len(m.b) - if m.autoJunk && n >= 200 { - ntest := n/100 + 1 - for s, indices := range b2j { - if len(indices) > ntest { - popular[s] = struct{}{} - } - } - for s, _ := range popular { - delete(b2j, s) - } - } - m.bPopular = popular - m.b2j = b2j -} - -func (m *SequenceMatcher) isBJunk(s string) bool { - _, ok := m.bJunk[s] - return ok -} - -// Find longest matching block in a[alo:ahi] and b[blo:bhi]. -// -// If IsJunk is not defined: -// -// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where -// alo <= i <= i+k <= ahi -// blo <= j <= j+k <= bhi -// and for all (i',j',k') meeting those conditions, -// k >= k' -// i <= i' -// and if i == i', j <= j' -// -// In other words, of all maximal matching blocks, return one that -// starts earliest in a, and of all those maximal matching blocks that -// start earliest in a, return the one that starts earliest in b. -// -// If IsJunk is defined, first the longest matching block is -// determined as above, but with the additional restriction that no -// junk element appears in the block. Then that block is extended as -// far as possible by matching (only) junk elements on both sides. So -// the resulting block never matches on junk except as identical junk -// happens to be adjacent to an "interesting" match. -// -// If no blocks match, return (alo, blo, 0). -func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match { - // CAUTION: stripping common prefix or suffix would be incorrect. - // E.g., - // ab - // acab - // Longest matching block is "ab", but if common prefix is - // stripped, it's "a" (tied with "b"). UNIX(tm) diff does so - // strip, so ends up claiming that ab is changed to acab by - // inserting "ca" in the middle. That's minimal but unintuitive: - // "it's obvious" that someone inserted "ac" at the front. - // Windiff ends up at the same place as diff, but by pairing up - // the unique 'b's and then matching the first two 'a's. - besti, bestj, bestsize := alo, blo, 0 - - // find longest junk-free match - // during an iteration of the loop, j2len[j] = length of longest - // junk-free match ending with a[i-1] and b[j] - j2len := map[int]int{} - for i := alo; i != ahi; i++ { - // look at all instances of a[i] in b; note that because - // b2j has no junk keys, the loop is skipped if a[i] is junk - newj2len := map[int]int{} - for _, j := range m.b2j[m.a[i]] { - // a[i] matches b[j] - if j < blo { - continue - } - if j >= bhi { - break - } - k := j2len[j-1] + 1 - newj2len[j] = k - if k > bestsize { - besti, bestj, bestsize = i-k+1, j-k+1, k - } - } - j2len = newj2len - } - - // Extend the best by non-junk elements on each end. In particular, - // "popular" non-junk elements aren't in b2j, which greatly speeds - // the inner loop above, but also means "the best" match so far - // doesn't contain any junk *or* popular non-junk elements. - for besti > alo && bestj > blo && !m.isBJunk(m.b[bestj-1]) && - m.a[besti-1] == m.b[bestj-1] { - besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 - } - for besti+bestsize < ahi && bestj+bestsize < bhi && - !m.isBJunk(m.b[bestj+bestsize]) && - m.a[besti+bestsize] == m.b[bestj+bestsize] { - bestsize += 1 - } - - // Now that we have a wholly interesting match (albeit possibly - // empty!), we may as well suck up the matching junk on each - // side of it too. Can't think of a good reason not to, and it - // saves post-processing the (possibly considerable) expense of - // figuring out what to do with it. In the case of an empty - // interesting match, this is clearly the right thing to do, - // because no other kind of match is possible in the regions. - for besti > alo && bestj > blo && m.isBJunk(m.b[bestj-1]) && - m.a[besti-1] == m.b[bestj-1] { - besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 - } - for besti+bestsize < ahi && bestj+bestsize < bhi && - m.isBJunk(m.b[bestj+bestsize]) && - m.a[besti+bestsize] == m.b[bestj+bestsize] { - bestsize += 1 - } - - return Match{A: besti, B: bestj, Size: bestsize} -} - -// Return list of triples describing matching subsequences. -// -// Each triple is of the form (i, j, n), and means that -// a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in -// i and in j. It's also guaranteed that if (i, j, n) and (i', j', n') are -// adjacent triples in the list, and the second is not the last triple in the -// list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe -// adjacent equal blocks. -// -// The last triple is a dummy, (len(a), len(b), 0), and is the only -// triple with n==0. -func (m *SequenceMatcher) GetMatchingBlocks() []Match { - if m.matchingBlocks != nil { - return m.matchingBlocks - } - - var matchBlocks func(alo, ahi, blo, bhi int, matched []Match) []Match - matchBlocks = func(alo, ahi, blo, bhi int, matched []Match) []Match { - match := m.findLongestMatch(alo, ahi, blo, bhi) - i, j, k := match.A, match.B, match.Size - if match.Size > 0 { - if alo < i && blo < j { - matched = matchBlocks(alo, i, blo, j, matched) - } - matched = append(matched, match) - if i+k < ahi && j+k < bhi { - matched = matchBlocks(i+k, ahi, j+k, bhi, matched) - } - } - return matched - } - matched := matchBlocks(0, len(m.a), 0, len(m.b), nil) - - // It's possible that we have adjacent equal blocks in the - // matching_blocks list now. - nonAdjacent := []Match{} - i1, j1, k1 := 0, 0, 0 - for _, b := range matched { - // Is this block adjacent to i1, j1, k1? - i2, j2, k2 := b.A, b.B, b.Size - if i1+k1 == i2 && j1+k1 == j2 { - // Yes, so collapse them -- this just increases the length of - // the first block by the length of the second, and the first - // block so lengthened remains the block to compare against. - k1 += k2 - } else { - // Not adjacent. Remember the first block (k1==0 means it's - // the dummy we started with), and make the second block the - // new block to compare against. - if k1 > 0 { - nonAdjacent = append(nonAdjacent, Match{i1, j1, k1}) - } - i1, j1, k1 = i2, j2, k2 - } - } - if k1 > 0 { - nonAdjacent = append(nonAdjacent, Match{i1, j1, k1}) - } - - nonAdjacent = append(nonAdjacent, Match{len(m.a), len(m.b), 0}) - m.matchingBlocks = nonAdjacent - return m.matchingBlocks -} - -// Return list of 5-tuples describing how to turn a into b. -// -// Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple -// has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the -// tuple preceding it, and likewise for j1 == the previous j2. -// -// The tags are characters, with these meanings: -// -// 'r' (replace): a[i1:i2] should be replaced by b[j1:j2] -// -// 'd' (delete): a[i1:i2] should be deleted, j1==j2 in this case. -// -// 'i' (insert): b[j1:j2] should be inserted at a[i1:i1], i1==i2 in this case. -// -// 'e' (equal): a[i1:i2] == b[j1:j2] -func (m *SequenceMatcher) GetOpCodes() []OpCode { - if m.opCodes != nil { - return m.opCodes - } - i, j := 0, 0 - matching := m.GetMatchingBlocks() - opCodes := make([]OpCode, 0, len(matching)) - for _, m := range matching { - // invariant: we've pumped out correct diffs to change - // a[:i] into b[:j], and the next matching block is - // a[ai:ai+size] == b[bj:bj+size]. So we need to pump - // out a diff to change a[i:ai] into b[j:bj], pump out - // the matching block, and move (i,j) beyond the match - ai, bj, size := m.A, m.B, m.Size - tag := byte(0) - if i < ai && j < bj { - tag = 'r' - } else if i < ai { - tag = 'd' - } else if j < bj { - tag = 'i' - } - if tag > 0 { - opCodes = append(opCodes, OpCode{tag, i, ai, j, bj}) - } - i, j = ai+size, bj+size - // the list of matching blocks is terminated by a - // sentinel with size 0 - if size > 0 { - opCodes = append(opCodes, OpCode{'e', ai, i, bj, j}) - } - } - m.opCodes = opCodes - return m.opCodes -} - -// Isolate change clusters by eliminating ranges with no changes. -// -// Return a generator of groups with up to n lines of context. -// Each group is in the same format as returned by GetOpCodes(). -func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode { - if n < 0 { - n = 3 - } - codes := m.GetOpCodes() - if len(codes) == 0 { - codes = []OpCode{OpCode{'e', 0, 1, 0, 1}} - } - // Fixup leading and trailing groups if they show no changes. - if codes[0].Tag == 'e' { - c := codes[0] - i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 - codes[0] = OpCode{c.Tag, max(i1, i2-n), i2, max(j1, j2-n), j2} - } - if codes[len(codes)-1].Tag == 'e' { - c := codes[len(codes)-1] - i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 - codes[len(codes)-1] = OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)} - } - nn := n + n - groups := [][]OpCode{} - group := []OpCode{} - for _, c := range codes { - i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 - // End the current group and start a new one whenever - // there is a large range with no changes. - if c.Tag == 'e' && i2-i1 > nn { - group = append(group, OpCode{c.Tag, i1, min(i2, i1+n), - j1, min(j2, j1+n)}) - groups = append(groups, group) - group = []OpCode{} - i1, j1 = max(i1, i2-n), max(j1, j2-n) - } - group = append(group, OpCode{c.Tag, i1, i2, j1, j2}) - } - if len(group) > 0 && !(len(group) == 1 && group[0].Tag == 'e') { - groups = append(groups, group) - } - return groups -} - -// Return a measure of the sequences' similarity (float in [0,1]). -// -// Where T is the total number of elements in both sequences, and -// M is the number of matches, this is 2.0*M / T. -// Note that this is 1 if the sequences are identical, and 0 if -// they have nothing in common. -// -// .Ratio() is expensive to compute if you haven't already computed -// .GetMatchingBlocks() or .GetOpCodes(), in which case you may -// want to try .QuickRatio() or .RealQuickRation() first to get an -// upper bound. -func (m *SequenceMatcher) Ratio() float64 { - matches := 0 - for _, m := range m.GetMatchingBlocks() { - matches += m.Size - } - return calculateRatio(matches, len(m.a)+len(m.b)) -} - -// Return an upper bound on ratio() relatively quickly. -// -// This isn't defined beyond that it is an upper bound on .Ratio(), and -// is faster to compute. -func (m *SequenceMatcher) QuickRatio() float64 { - // viewing a and b as multisets, set matches to the cardinality - // of their intersection; this counts the number of matches - // without regard to order, so is clearly an upper bound - if m.fullBCount == nil { - m.fullBCount = map[string]int{} - for _, s := range m.b { - m.fullBCount[s] = m.fullBCount[s] + 1 - } - } - - // avail[x] is the number of times x appears in 'b' less the - // number of times we've seen it in 'a' so far ... kinda - avail := map[string]int{} - matches := 0 - for _, s := range m.a { - n, ok := avail[s] - if !ok { - n = m.fullBCount[s] - } - avail[s] = n - 1 - if n > 0 { - matches += 1 - } - } - return calculateRatio(matches, len(m.a)+len(m.b)) -} - -// Return an upper bound on ratio() very quickly. -// -// This isn't defined beyond that it is an upper bound on .Ratio(), and -// is faster to compute than either .Ratio() or .QuickRatio(). -func (m *SequenceMatcher) RealQuickRatio() float64 { - la, lb := len(m.a), len(m.b) - return calculateRatio(min(la, lb), la+lb) -} - -// Convert range to the "ed" format -func formatRangeUnified(start, stop int) string { - // Per the diff spec at http://www.unix.org/single_unix_specification/ - beginning := start + 1 // lines start numbering with one - length := stop - start - if length == 1 { - return fmt.Sprintf("%d", beginning) - } - if length == 0 { - beginning -= 1 // empty ranges begin at line just before the range - } - return fmt.Sprintf("%d,%d", beginning, length) -} - -// Unified diff parameters -type UnifiedDiff struct { - A []string // First sequence lines - FromFile string // First file name - FromDate string // First file time - B []string // Second sequence lines - ToFile string // Second file name - ToDate string // Second file time - Eol string // Headers end of line, defaults to LF - Context int // Number of context lines -} - -// Compare two sequences of lines; generate the delta as a unified diff. -// -// Unified diffs are a compact way of showing line changes and a few -// lines of context. The number of context lines is set by 'n' which -// defaults to three. -// -// By default, the diff control lines (those with ---, +++, or @@) are -// created with a trailing newline. This is helpful so that inputs -// created from file.readlines() result in diffs that are suitable for -// file.writelines() since both the inputs and outputs have trailing -// newlines. -// -// For inputs that do not have trailing newlines, set the lineterm -// argument to "" so that the output will be uniformly newline free. -// -// The unidiff format normally has a header for filenames and modification -// times. Any or all of these may be specified using strings for -// 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. -// The modification times are normally expressed in the ISO 8601 format. -func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error { - buf := bufio.NewWriter(writer) - defer buf.Flush() - wf := func(format string, args ...interface{}) error { - _, err := buf.WriteString(fmt.Sprintf(format, args...)) - return err - } - ws := func(s string) error { - _, err := buf.WriteString(s) - return err - } - - if len(diff.Eol) == 0 { - diff.Eol = "\n" - } - - started := false - m := NewMatcher(diff.A, diff.B) - for _, g := range m.GetGroupedOpCodes(diff.Context) { - if !started { - started = true - fromDate := "" - if len(diff.FromDate) > 0 { - fromDate = "\t" + diff.FromDate - } - toDate := "" - if len(diff.ToDate) > 0 { - toDate = "\t" + diff.ToDate - } - if diff.FromFile != "" || diff.ToFile != "" { - err := wf("--- %s%s%s", diff.FromFile, fromDate, diff.Eol) - if err != nil { - return err - } - err = wf("+++ %s%s%s", diff.ToFile, toDate, diff.Eol) - if err != nil { - return err - } - } - } - first, last := g[0], g[len(g)-1] - range1 := formatRangeUnified(first.I1, last.I2) - range2 := formatRangeUnified(first.J1, last.J2) - if err := wf("@@ -%s +%s @@%s", range1, range2, diff.Eol); err != nil { - return err - } - for _, c := range g { - i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 - if c.Tag == 'e' { - for _, line := range diff.A[i1:i2] { - if err := ws(" " + line); err != nil { - return err - } - } - continue - } - if c.Tag == 'r' || c.Tag == 'd' { - for _, line := range diff.A[i1:i2] { - if err := ws("-" + line); err != nil { - return err - } - } - } - if c.Tag == 'r' || c.Tag == 'i' { - for _, line := range diff.B[j1:j2] { - if err := ws("+" + line); err != nil { - return err - } - } - } - } - } - return nil -} - -// Like WriteUnifiedDiff but returns the diff a string. -func GetUnifiedDiffString(diff UnifiedDiff) (string, error) { - w := &bytes.Buffer{} - err := WriteUnifiedDiff(w, diff) - return string(w.Bytes()), err -} - -// Convert range to the "ed" format. -func formatRangeContext(start, stop int) string { - // Per the diff spec at http://www.unix.org/single_unix_specification/ - beginning := start + 1 // lines start numbering with one - length := stop - start - if length == 0 { - beginning -= 1 // empty ranges begin at line just before the range - } - if length <= 1 { - return fmt.Sprintf("%d", beginning) - } - return fmt.Sprintf("%d,%d", beginning, beginning+length-1) -} - -type ContextDiff UnifiedDiff - -// Compare two sequences of lines; generate the delta as a context diff. -// -// Context diffs are a compact way of showing line changes and a few -// lines of context. The number of context lines is set by diff.Context -// which defaults to three. -// -// By default, the diff control lines (those with *** or ---) are -// created with a trailing newline. -// -// For inputs that do not have trailing newlines, set the diff.Eol -// argument to "" so that the output will be uniformly newline free. -// -// The context diff format normally has a header for filenames and -// modification times. Any or all of these may be specified using -// strings for diff.FromFile, diff.ToFile, diff.FromDate, diff.ToDate. -// The modification times are normally expressed in the ISO 8601 format. -// If not specified, the strings default to blanks. -func WriteContextDiff(writer io.Writer, diff ContextDiff) error { - buf := bufio.NewWriter(writer) - defer buf.Flush() - var diffErr error - wf := func(format string, args ...interface{}) { - _, err := buf.WriteString(fmt.Sprintf(format, args...)) - if diffErr == nil && err != nil { - diffErr = err - } - } - ws := func(s string) { - _, err := buf.WriteString(s) - if diffErr == nil && err != nil { - diffErr = err - } - } - - if len(diff.Eol) == 0 { - diff.Eol = "\n" - } - - prefix := map[byte]string{ - 'i': "+ ", - 'd': "- ", - 'r': "! ", - 'e': " ", - } - - started := false - m := NewMatcher(diff.A, diff.B) - for _, g := range m.GetGroupedOpCodes(diff.Context) { - if !started { - started = true - fromDate := "" - if len(diff.FromDate) > 0 { - fromDate = "\t" + diff.FromDate - } - toDate := "" - if len(diff.ToDate) > 0 { - toDate = "\t" + diff.ToDate - } - if diff.FromFile != "" || diff.ToFile != "" { - wf("*** %s%s%s", diff.FromFile, fromDate, diff.Eol) - wf("--- %s%s%s", diff.ToFile, toDate, diff.Eol) - } - } - - first, last := g[0], g[len(g)-1] - ws("***************" + diff.Eol) - - range1 := formatRangeContext(first.I1, last.I2) - wf("*** %s ****%s", range1, diff.Eol) - for _, c := range g { - if c.Tag == 'r' || c.Tag == 'd' { - for _, cc := range g { - if cc.Tag == 'i' { - continue - } - for _, line := range diff.A[cc.I1:cc.I2] { - ws(prefix[cc.Tag] + line) - } - } - break - } - } - - range2 := formatRangeContext(first.J1, last.J2) - wf("--- %s ----%s", range2, diff.Eol) - for _, c := range g { - if c.Tag == 'r' || c.Tag == 'i' { - for _, cc := range g { - if cc.Tag == 'd' { - continue - } - for _, line := range diff.B[cc.J1:cc.J2] { - ws(prefix[cc.Tag] + line) - } - } - break - } - } - } - return diffErr -} - -// Like WriteContextDiff but returns the diff a string. -func GetContextDiffString(diff ContextDiff) (string, error) { - w := &bytes.Buffer{} - err := WriteContextDiff(w, diff) - return string(w.Bytes()), err -} - -// Split a string on "\n" while preserving them. The output can be used -// as input for UnifiedDiff and ContextDiff structures. -func SplitLines(s string) []string { - lines := strings.SplitAfter(s, "\n") - lines[len(lines)-1] += "\n" - return lines -} diff --git a/vendor/github.com/renstrom/fuzzysearch/LICENSE b/vendor/github.com/renstrom/fuzzysearch/LICENSE deleted file mode 100644 index dee3d1d..0000000 --- a/vendor/github.com/renstrom/fuzzysearch/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2018 Peter Lithammer - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/renstrom/fuzzysearch/fuzzy/fuzzy.go b/vendor/github.com/renstrom/fuzzysearch/fuzzy/fuzzy.go deleted file mode 100644 index 33d4898..0000000 --- a/vendor/github.com/renstrom/fuzzysearch/fuzzy/fuzzy.go +++ /dev/null @@ -1,173 +0,0 @@ -// Fuzzy searching allows for flexibly matching a string with partial input, -// useful for filtering data very quickly based on lightweight user input. -package fuzzy - -import ( - "unicode" - "unicode/utf8" -) - -var noop = func(r rune) rune { return r } - -// Match returns true if source matches target using a fuzzy-searching -// algorithm. Note that it doesn't implement Levenshtein distance (see -// RankMatch instead), but rather a simplified version where there's no -// approximation. The method will return true only if each character in the -// source can be found in the target and occurs after the preceding matches. -func Match(source, target string) bool { - return match(source, target, noop) -} - -// MatchFold is a case-insensitive version of Match. -func MatchFold(source, target string) bool { - return match(source, target, unicode.ToLower) -} - -func match(source, target string, fn func(rune) rune) bool { - lenDiff := len(target) - len(source) - - if lenDiff < 0 { - return false - } - - if lenDiff == 0 && source == target { - return true - } - -Outer: - for _, r1 := range source { - for i, r2 := range target { - if fn(r1) == fn(r2) { - target = target[i+utf8.RuneLen(r2):] - continue Outer - } - } - return false - } - - return true -} - -// Find will return a list of strings in targets that fuzzy matches source. -func Find(source string, targets []string) []string { - return find(source, targets, noop) -} - -// FindFold is a case-insensitive version of Find. -func FindFold(source string, targets []string) []string { - return find(source, targets, unicode.ToLower) -} - -func find(source string, targets []string, fn func(rune) rune) []string { - var matches []string - - for _, target := range targets { - if match(source, target, fn) { - matches = append(matches, target) - } - } - - return matches -} - -// RankMatch is similar to Match except it will measure the Levenshtein -// distance between the source and the target and return its result. If there -// was no match, it will return -1. -// Given the requirements of match, RankMatch only needs to perform a subset of -// the Levenshtein calculation, only deletions need be considered, required -// additions and substitutions would fail the match test. -func RankMatch(source, target string) int { - return rank(source, target, noop) -} - -// RankMatchFold is a case-insensitive version of RankMatch. -func RankMatchFold(source, target string) int { - return rank(source, target, unicode.ToLower) -} - -func rank(source, target string, fn func(rune) rune) int { - lenDiff := len(target) - len(source) - - if lenDiff < 0 { - return -1 - } - - if lenDiff == 0 && source == target { - return 0 - } - - runeDiff := 0 - -Outer: - for _, r1 := range source { - for i, r2 := range target { - if fn(r1) == fn(r2) { - target = target[i+utf8.RuneLen(r2):] - continue Outer - } else { - runeDiff++ - } - } - return -1 - } - - // Count up remaining char - runeDiff += utf8.RuneCountInString(target) - - return runeDiff -} - -// RankFind is similar to Find, except it will also rank all matches using -// Levenshtein distance. -func RankFind(source string, targets []string) Ranks { - var r Ranks - - for index, target := range targets { - if match(source, target, noop) { - distance := LevenshteinDistance(source, target) - r = append(r, Rank{source, target, distance, index}) - } - } - return r -} - -// RankFindFold is a case-insensitive version of RankFind. -func RankFindFold(source string, targets []string) Ranks { - var r Ranks - - for index, target := range targets { - if match(source, target, unicode.ToLower) { - distance := LevenshteinDistance(source, target) - r = append(r, Rank{source, target, distance, index}) - } - } - return r -} - -type Rank struct { - // Source is used as the source for matching. - Source string - - // Target is the word matched against. - Target string - - // Distance is the Levenshtein distance between Source and Target. - Distance int - - // Location of Target in original list - OriginalIndex int -} - -type Ranks []Rank - -func (r Ranks) Len() int { - return len(r) -} - -func (r Ranks) Swap(i, j int) { - r[i], r[j] = r[j], r[i] -} - -func (r Ranks) Less(i, j int) bool { - return r[i].Distance < r[j].Distance -} diff --git a/vendor/github.com/renstrom/fuzzysearch/fuzzy/levenshtein.go b/vendor/github.com/renstrom/fuzzysearch/fuzzy/levenshtein.go deleted file mode 100644 index 237923d..0000000 --- a/vendor/github.com/renstrom/fuzzysearch/fuzzy/levenshtein.go +++ /dev/null @@ -1,43 +0,0 @@ -package fuzzy - -// LevenshteinDistance measures the difference between two strings. -// The Levenshtein distance between two words is the minimum number of -// single-character edits (i.e. insertions, deletions or substitutions) -// required to change one word into the other. -// -// This implemention is optimized to use O(min(m,n)) space and is based on the -// optimized C version found here: -// http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#C -func LevenshteinDistance(s, t string) int { - r1, r2 := []rune(s), []rune(t) - column := make([]int, len(r1)+1) - - for y := 1; y <= len(r1); y++ { - column[y] = y - } - - for x := 1; x <= len(r2); x++ { - column[0] = x - - for y, lastDiag := 1, x-1; y <= len(r1); y++ { - oldDiag := column[y] - cost := 0 - if r1[y-1] != r2[x-1] { - cost = 1 - } - column[y] = min(column[y]+1, column[y-1]+1, lastDiag+cost) - lastDiag = oldDiag - } - } - - return column[len(r1)] -} - -func min(a, b, c int) int { - if a < b && a < c { - return a - } else if b < c { - return b - } - return c -} diff --git a/vendor/github.com/shurcooL/sanitized_anchor_name/.travis.yml b/vendor/github.com/shurcooL/sanitized_anchor_name/.travis.yml deleted file mode 100644 index 93b1fcd..0000000 --- a/vendor/github.com/shurcooL/sanitized_anchor_name/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -sudo: false -language: go -go: - - 1.x - - master -matrix: - allow_failures: - - go: master - fast_finish: true -install: - - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step). -script: - - go get -t -v ./... - - diff -u <(echo -n) <(gofmt -d -s .) - - go tool vet . - - go test -v -race ./... diff --git a/vendor/github.com/shurcooL/sanitized_anchor_name/LICENSE b/vendor/github.com/shurcooL/sanitized_anchor_name/LICENSE deleted file mode 100644 index c35c17a..0000000 --- a/vendor/github.com/shurcooL/sanitized_anchor_name/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2015 Dmitri Shuralyov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/shurcooL/sanitized_anchor_name/README.md b/vendor/github.com/shurcooL/sanitized_anchor_name/README.md deleted file mode 100644 index 670bf0f..0000000 --- a/vendor/github.com/shurcooL/sanitized_anchor_name/README.md +++ /dev/null @@ -1,36 +0,0 @@ -sanitized_anchor_name -===================== - -[![Build Status](https://travis-ci.org/shurcooL/sanitized_anchor_name.svg?branch=master)](https://travis-ci.org/shurcooL/sanitized_anchor_name) [![GoDoc](https://godoc.org/github.com/shurcooL/sanitized_anchor_name?status.svg)](https://godoc.org/github.com/shurcooL/sanitized_anchor_name) - -Package sanitized_anchor_name provides a func to create sanitized anchor names. - -Its logic can be reused by multiple packages to create interoperable anchor names -and links to those anchors. - -At this time, it does not try to ensure that generated anchor names -are unique, that responsibility falls on the caller. - -Installation ------------- - -```bash -go get -u github.com/shurcooL/sanitized_anchor_name -``` - -Example -------- - -```Go -anchorName := sanitized_anchor_name.Create("This is a header") - -fmt.Println(anchorName) - -// Output: -// this-is-a-header -``` - -License -------- - -- [MIT License](LICENSE) diff --git a/vendor/github.com/shurcooL/sanitized_anchor_name/main.go b/vendor/github.com/shurcooL/sanitized_anchor_name/main.go deleted file mode 100644 index 6a77d12..0000000 --- a/vendor/github.com/shurcooL/sanitized_anchor_name/main.go +++ /dev/null @@ -1,29 +0,0 @@ -// Package sanitized_anchor_name provides a func to create sanitized anchor names. -// -// Its logic can be reused by multiple packages to create interoperable anchor names -// and links to those anchors. -// -// At this time, it does not try to ensure that generated anchor names -// are unique, that responsibility falls on the caller. -package sanitized_anchor_name // import "github.com/shurcooL/sanitized_anchor_name" - -import "unicode" - -// Create returns a sanitized anchor name for the given text. -func Create(text string) string { - var anchorName []rune - var futureDash = false - for _, r := range text { - switch { - case unicode.IsLetter(r) || unicode.IsNumber(r): - if futureDash && len(anchorName) > 0 { - anchorName = append(anchorName, '-') - } - futureDash = false - anchorName = append(anchorName, unicode.ToLower(r)) - default: - futureDash = true - } - } - return string(anchorName) -} diff --git a/vendor/github.com/stretchr/testify/LICENSE b/vendor/github.com/stretchr/testify/LICENSE deleted file mode 100644 index 473b670..0000000 --- a/vendor/github.com/stretchr/testify/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell - -Please consider promoting this project if you find it useful. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of the Software, -and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go deleted file mode 100644 index aa1c2b9..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_format.go +++ /dev/null @@ -1,484 +0,0 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ - -package assert - -import ( - http "net/http" - url "net/url" - time "time" -) - -// Conditionf uses a Comparison to assert a complex condition. -func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Condition(t, comp, append([]interface{}{msg}, args...)...) -} - -// Containsf asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") -// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") -// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") -func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Contains(t, s, contains, append([]interface{}{msg}, args...)...) -} - -// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return DirExists(t, path, append([]interface{}{msg}, args...)...) -} - -// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") -func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...) -} - -// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// assert.Emptyf(t, obj, "error message %s", "formatted") -func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Empty(t, object, append([]interface{}{msg}, args...)...) -} - -// Equalf asserts that two objects are equal. -// -// assert.Equalf(t, 123, 123, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Equal(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") -func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...) -} - -// EqualValuesf asserts that two objects are equal or convertable to the same types -// and equal. -// -// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123)) -func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// Errorf asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if assert.Errorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } -func Errorf(t TestingT, err error, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Error(t, err, append([]interface{}{msg}, args...)...) -} - -// Exactlyf asserts that two objects are equal in value and type. -// -// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123)) -func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// Failf reports a failure through -func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Fail(t, failureMessage, append([]interface{}{msg}, args...)...) -} - -// FailNowf fails test -func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...) -} - -// Falsef asserts that the specified value is false. -// -// assert.Falsef(t, myBool, "error message %s", "formatted") -func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return False(t, value, append([]interface{}{msg}, args...)...) -} - -// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return FileExists(t, path, append([]interface{}{msg}, args...)...) -} - -// HTTPBodyContainsf asserts that a specified handler returns a -// body that contains a string. -// -// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...) -} - -// HTTPBodyNotContainsf asserts that a specified handler returns a -// body that does not contain a string. -// -// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...) -} - -// HTTPErrorf asserts that a specified handler returns an error status code. -// -// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...) -} - -// HTTPRedirectf asserts that a specified handler returns a redirect status code. -// -// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...) -} - -// HTTPSuccessf asserts that a specified handler returns a success status code. -// -// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...) -} - -// Implementsf asserts that an object is implemented by the specified interface. -// -// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) -func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...) -} - -// InDeltaf asserts that the two numerals are within delta of each other. -// -// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) -func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...) -} - -// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...) -} - -// InDeltaSlicef is the same as InDelta, except it compares two slices. -func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...) -} - -// InEpsilonf asserts that expected and actual have a relative error less than epsilon -func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...) -} - -// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. -func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...) -} - -// IsTypef asserts that the specified objects are of the same type. -func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...) -} - -// JSONEqf asserts that two JSON strings are equivalent. -// -// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") -func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// Lenf asserts that the specified object has specific length. -// Lenf also fails if the object has a type that len() not accept. -// -// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") -func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Len(t, object, length, append([]interface{}{msg}, args...)...) -} - -// Nilf asserts that the specified object is nil. -// -// assert.Nilf(t, err, "error message %s", "formatted") -func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Nil(t, object, append([]interface{}{msg}, args...)...) -} - -// NoErrorf asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if assert.NoErrorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } -func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NoError(t, err, append([]interface{}{msg}, args...)...) -} - -// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") -func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotContains(t, s, contains, append([]interface{}{msg}, args...)...) -} - -// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } -func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotEmpty(t, object, append([]interface{}{msg}, args...)...) -} - -// NotEqualf asserts that the specified values are NOT equal. -// -// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// NotNilf asserts that the specified object is not nil. -// -// assert.NotNilf(t, err, "error message %s", "formatted") -func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotNil(t, object, append([]interface{}{msg}, args...)...) -} - -// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") -func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotPanics(t, f, append([]interface{}{msg}, args...)...) -} - -// NotRegexpf asserts that a specified regexp does not match a string. -// -// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") -// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") -func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...) -} - -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") -func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...) -} - -// NotZerof asserts that i is not the zero value for its type. -func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotZero(t, i, append([]interface{}{msg}, args...)...) -} - -// Panicsf asserts that the code inside the specified PanicTestFunc panics. -// -// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") -func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Panics(t, f, append([]interface{}{msg}, args...)...) -} - -// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") -func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...) -} - -// Regexpf asserts that a specified regexp matches a string. -// -// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") -// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") -func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Regexp(t, rx, str, append([]interface{}{msg}, args...)...) -} - -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") -func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Subset(t, list, subset, append([]interface{}{msg}, args...)...) -} - -// Truef asserts that the specified value is true. -// -// assert.Truef(t, myBool, "error message %s", "formatted") -func Truef(t TestingT, value bool, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return True(t, value, append([]interface{}{msg}, args...)...) -} - -// WithinDurationf asserts that the two times are within duration delta of each other. -// -// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") -func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...) -} - -// Zerof asserts that i is the zero value for its type. -func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Zero(t, i, append([]interface{}{msg}, args...)...) -} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl deleted file mode 100644 index d2bb0b8..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl +++ /dev/null @@ -1,5 +0,0 @@ -{{.CommentFormat}} -func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { - if h, ok := t.(tHelper); ok { h.Helper() } - return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) -} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go deleted file mode 100644 index de39f79..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go +++ /dev/null @@ -1,956 +0,0 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ - -package assert - -import ( - http "net/http" - url "net/url" - time "time" -) - -// Condition uses a Comparison to assert a complex condition. -func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Condition(a.t, comp, msgAndArgs...) -} - -// Conditionf uses a Comparison to assert a complex condition. -func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Conditionf(a.t, comp, msg, args...) -} - -// Contains asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// a.Contains("Hello World", "World") -// a.Contains(["Hello", "World"], "World") -// a.Contains({"Hello": "World"}, "Hello") -func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Contains(a.t, s, contains, msgAndArgs...) -} - -// Containsf asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// a.Containsf("Hello World", "World", "error message %s", "formatted") -// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted") -// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") -func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Containsf(a.t, s, contains, msg, args...) -} - -// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return DirExists(a.t, path, msgAndArgs...) -} - -// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return DirExistsf(a.t, path, msg, args...) -} - -// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2]) -func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return ElementsMatch(a.t, listA, listB, msgAndArgs...) -} - -// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") -func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return ElementsMatchf(a.t, listA, listB, msg, args...) -} - -// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// a.Empty(obj) -func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Empty(a.t, object, msgAndArgs...) -} - -// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// a.Emptyf(obj, "error message %s", "formatted") -func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Emptyf(a.t, object, msg, args...) -} - -// Equal asserts that two objects are equal. -// -// a.Equal(123, 123) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Equal(a.t, expected, actual, msgAndArgs...) -} - -// EqualError asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// a.EqualError(err, expectedErrorString) -func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return EqualError(a.t, theError, errString, msgAndArgs...) -} - -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") -func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return EqualErrorf(a.t, theError, errString, msg, args...) -} - -// EqualValues asserts that two objects are equal or convertable to the same types -// and equal. -// -// a.EqualValues(uint32(123), int32(123)) -func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return EqualValues(a.t, expected, actual, msgAndArgs...) -} - -// EqualValuesf asserts that two objects are equal or convertable to the same types -// and equal. -// -// a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123)) -func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return EqualValuesf(a.t, expected, actual, msg, args...) -} - -// Equalf asserts that two objects are equal. -// -// a.Equalf(123, 123, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Equalf(a.t, expected, actual, msg, args...) -} - -// Error asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if a.Error(err) { -// assert.Equal(t, expectedError, err) -// } -func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Error(a.t, err, msgAndArgs...) -} - -// Errorf asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if a.Errorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } -func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Errorf(a.t, err, msg, args...) -} - -// Exactly asserts that two objects are equal in value and type. -// -// a.Exactly(int32(123), int64(123)) -func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Exactly(a.t, expected, actual, msgAndArgs...) -} - -// Exactlyf asserts that two objects are equal in value and type. -// -// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123)) -func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Exactlyf(a.t, expected, actual, msg, args...) -} - -// Fail reports a failure through -func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Fail(a.t, failureMessage, msgAndArgs...) -} - -// FailNow fails test -func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return FailNow(a.t, failureMessage, msgAndArgs...) -} - -// FailNowf fails test -func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return FailNowf(a.t, failureMessage, msg, args...) -} - -// Failf reports a failure through -func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Failf(a.t, failureMessage, msg, args...) -} - -// False asserts that the specified value is false. -// -// a.False(myBool) -func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return False(a.t, value, msgAndArgs...) -} - -// Falsef asserts that the specified value is false. -// -// a.Falsef(myBool, "error message %s", "formatted") -func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Falsef(a.t, value, msg, args...) -} - -// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return FileExists(a.t, path, msgAndArgs...) -} - -// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return FileExistsf(a.t, path, msg, args...) -} - -// HTTPBodyContains asserts that a specified handler returns a -// body that contains a string. -// -// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...) -} - -// HTTPBodyContainsf asserts that a specified handler returns a -// body that contains a string. -// -// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...) -} - -// HTTPBodyNotContains asserts that a specified handler returns a -// body that does not contain a string. -// -// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...) -} - -// HTTPBodyNotContainsf asserts that a specified handler returns a -// body that does not contain a string. -// -// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...) -} - -// HTTPError asserts that a specified handler returns an error status code. -// -// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPError(a.t, handler, method, url, values, msgAndArgs...) -} - -// HTTPErrorf asserts that a specified handler returns an error status code. -// -// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPErrorf(a.t, handler, method, url, values, msg, args...) -} - -// HTTPRedirect asserts that a specified handler returns a redirect status code. -// -// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...) -} - -// HTTPRedirectf asserts that a specified handler returns a redirect status code. -// -// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPRedirectf(a.t, handler, method, url, values, msg, args...) -} - -// HTTPSuccess asserts that a specified handler returns a success status code. -// -// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...) -} - -// HTTPSuccessf asserts that a specified handler returns a success status code. -// -// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPSuccessf(a.t, handler, method, url, values, msg, args...) -} - -// Implements asserts that an object is implemented by the specified interface. -// -// a.Implements((*MyInterface)(nil), new(MyObject)) -func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Implements(a.t, interfaceObject, object, msgAndArgs...) -} - -// Implementsf asserts that an object is implemented by the specified interface. -// -// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) -func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Implementsf(a.t, interfaceObject, object, msg, args...) -} - -// InDelta asserts that the two numerals are within delta of each other. -// -// a.InDelta(math.Pi, (22 / 7.0), 0.01) -func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDelta(a.t, expected, actual, delta, msgAndArgs...) -} - -// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...) -} - -// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...) -} - -// InDeltaSlice is the same as InDelta, except it compares two slices. -func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...) -} - -// InDeltaSlicef is the same as InDelta, except it compares two slices. -func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaSlicef(a.t, expected, actual, delta, msg, args...) -} - -// InDeltaf asserts that the two numerals are within delta of each other. -// -// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) -func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaf(a.t, expected, actual, delta, msg, args...) -} - -// InEpsilon asserts that expected and actual have a relative error less than epsilon -func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...) -} - -// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. -func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...) -} - -// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. -func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...) -} - -// InEpsilonf asserts that expected and actual have a relative error less than epsilon -func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InEpsilonf(a.t, expected, actual, epsilon, msg, args...) -} - -// IsType asserts that the specified objects are of the same type. -func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return IsType(a.t, expectedType, object, msgAndArgs...) -} - -// IsTypef asserts that the specified objects are of the same type. -func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return IsTypef(a.t, expectedType, object, msg, args...) -} - -// JSONEq asserts that two JSON strings are equivalent. -// -// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) -func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return JSONEq(a.t, expected, actual, msgAndArgs...) -} - -// JSONEqf asserts that two JSON strings are equivalent. -// -// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") -func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return JSONEqf(a.t, expected, actual, msg, args...) -} - -// Len asserts that the specified object has specific length. -// Len also fails if the object has a type that len() not accept. -// -// a.Len(mySlice, 3) -func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Len(a.t, object, length, msgAndArgs...) -} - -// Lenf asserts that the specified object has specific length. -// Lenf also fails if the object has a type that len() not accept. -// -// a.Lenf(mySlice, 3, "error message %s", "formatted") -func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Lenf(a.t, object, length, msg, args...) -} - -// Nil asserts that the specified object is nil. -// -// a.Nil(err) -func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Nil(a.t, object, msgAndArgs...) -} - -// Nilf asserts that the specified object is nil. -// -// a.Nilf(err, "error message %s", "formatted") -func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Nilf(a.t, object, msg, args...) -} - -// NoError asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if a.NoError(err) { -// assert.Equal(t, expectedObj, actualObj) -// } -func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NoError(a.t, err, msgAndArgs...) -} - -// NoErrorf asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if a.NoErrorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } -func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NoErrorf(a.t, err, msg, args...) -} - -// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// a.NotContains("Hello World", "Earth") -// a.NotContains(["Hello", "World"], "Earth") -// a.NotContains({"Hello": "World"}, "Earth") -func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotContains(a.t, s, contains, msgAndArgs...) -} - -// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted") -// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted") -// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted") -func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotContainsf(a.t, s, contains, msg, args...) -} - -// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if a.NotEmpty(obj) { -// assert.Equal(t, "two", obj[1]) -// } -func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotEmpty(a.t, object, msgAndArgs...) -} - -// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if a.NotEmptyf(obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } -func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotEmptyf(a.t, object, msg, args...) -} - -// NotEqual asserts that the specified values are NOT equal. -// -// a.NotEqual(obj1, obj2) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotEqual(a.t, expected, actual, msgAndArgs...) -} - -// NotEqualf asserts that the specified values are NOT equal. -// -// a.NotEqualf(obj1, obj2, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotEqualf(a.t, expected, actual, msg, args...) -} - -// NotNil asserts that the specified object is not nil. -// -// a.NotNil(err) -func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotNil(a.t, object, msgAndArgs...) -} - -// NotNilf asserts that the specified object is not nil. -// -// a.NotNilf(err, "error message %s", "formatted") -func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotNilf(a.t, object, msg, args...) -} - -// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// a.NotPanics(func(){ RemainCalm() }) -func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotPanics(a.t, f, msgAndArgs...) -} - -// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted") -func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotPanicsf(a.t, f, msg, args...) -} - -// NotRegexp asserts that a specified regexp does not match a string. -// -// a.NotRegexp(regexp.MustCompile("starts"), "it's starting") -// a.NotRegexp("^start", "it's not starting") -func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotRegexp(a.t, rx, str, msgAndArgs...) -} - -// NotRegexpf asserts that a specified regexp does not match a string. -// -// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") -// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") -func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotRegexpf(a.t, rx, str, msg, args...) -} - -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") -func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotSubset(a.t, list, subset, msgAndArgs...) -} - -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") -func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotSubsetf(a.t, list, subset, msg, args...) -} - -// NotZero asserts that i is not the zero value for its type. -func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotZero(a.t, i, msgAndArgs...) -} - -// NotZerof asserts that i is not the zero value for its type. -func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotZerof(a.t, i, msg, args...) -} - -// Panics asserts that the code inside the specified PanicTestFunc panics. -// -// a.Panics(func(){ GoCrazy() }) -func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Panics(a.t, f, msgAndArgs...) -} - -// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) -func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return PanicsWithValue(a.t, expected, f, msgAndArgs...) -} - -// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") -func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return PanicsWithValuef(a.t, expected, f, msg, args...) -} - -// Panicsf asserts that the code inside the specified PanicTestFunc panics. -// -// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted") -func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Panicsf(a.t, f, msg, args...) -} - -// Regexp asserts that a specified regexp matches a string. -// -// a.Regexp(regexp.MustCompile("start"), "it's starting") -// a.Regexp("start...$", "it's not starting") -func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Regexp(a.t, rx, str, msgAndArgs...) -} - -// Regexpf asserts that a specified regexp matches a string. -// -// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") -// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") -func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Regexpf(a.t, rx, str, msg, args...) -} - -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") -func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Subset(a.t, list, subset, msgAndArgs...) -} - -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") -func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Subsetf(a.t, list, subset, msg, args...) -} - -// True asserts that the specified value is true. -// -// a.True(myBool) -func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return True(a.t, value, msgAndArgs...) -} - -// Truef asserts that the specified value is true. -// -// a.Truef(myBool, "error message %s", "formatted") -func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Truef(a.t, value, msg, args...) -} - -// WithinDuration asserts that the two times are within duration delta of each other. -// -// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) -func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return WithinDuration(a.t, expected, actual, delta, msgAndArgs...) -} - -// WithinDurationf asserts that the two times are within duration delta of each other. -// -// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") -func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return WithinDurationf(a.t, expected, actual, delta, msg, args...) -} - -// Zero asserts that i is the zero value for its type. -func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Zero(a.t, i, msgAndArgs...) -} - -// Zerof asserts that i is the zero value for its type. -func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Zerof(a.t, i, msg, args...) -} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl deleted file mode 100644 index 188bb9e..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl +++ /dev/null @@ -1,5 +0,0 @@ -{{.CommentWithoutT "a"}} -func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { - if h, ok := a.t.(tHelper); ok { h.Helper() } - return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) -} diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go deleted file mode 100644 index 5bdec56..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ /dev/null @@ -1,1394 +0,0 @@ -package assert - -import ( - "bufio" - "bytes" - "encoding/json" - "errors" - "fmt" - "math" - "os" - "reflect" - "regexp" - "runtime" - "strings" - "time" - "unicode" - "unicode/utf8" - - "github.com/davecgh/go-spew/spew" - "github.com/pmezard/go-difflib/difflib" -) - -//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_format.go.tmpl - -// TestingT is an interface wrapper around *testing.T -type TestingT interface { - Errorf(format string, args ...interface{}) -} - -// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful -// for table driven tests. -type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) bool - -// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful -// for table driven tests. -type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) bool - -// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful -// for table driven tests. -type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool - -// ValuesAssertionFunc is a common function prototype when validating an error value. Can be useful -// for table driven tests. -type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool - -// Comparison a custom function that returns true on success and false on failure -type Comparison func() (success bool) - -/* - Helper functions -*/ - -// ObjectsAreEqual determines if two objects are considered equal. -// -// This function does no assertion of any kind. -func ObjectsAreEqual(expected, actual interface{}) bool { - if expected == nil || actual == nil { - return expected == actual - } - - exp, ok := expected.([]byte) - if !ok { - return reflect.DeepEqual(expected, actual) - } - - act, ok := actual.([]byte) - if !ok { - return false - } - if exp == nil || act == nil { - return exp == nil && act == nil - } - return bytes.Equal(exp, act) -} - -// ObjectsAreEqualValues gets whether two objects are equal, or if their -// values are equal. -func ObjectsAreEqualValues(expected, actual interface{}) bool { - if ObjectsAreEqual(expected, actual) { - return true - } - - actualType := reflect.TypeOf(actual) - if actualType == nil { - return false - } - expectedValue := reflect.ValueOf(expected) - if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) { - // Attempt comparison after type conversion - return reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), actual) - } - - return false -} - -/* CallerInfo is necessary because the assert functions use the testing object -internally, causing it to print the file:line of the assert method, rather than where -the problem actually occurred in calling code.*/ - -// CallerInfo returns an array of strings containing the file and line number -// of each stack frame leading from the current test to the assert call that -// failed. -func CallerInfo() []string { - - pc := uintptr(0) - file := "" - line := 0 - ok := false - name := "" - - callers := []string{} - for i := 0; ; i++ { - pc, file, line, ok = runtime.Caller(i) - if !ok { - // The breaks below failed to terminate the loop, and we ran off the - // end of the call stack. - break - } - - // This is a huge edge case, but it will panic if this is the case, see #180 - if file == "" { - break - } - - f := runtime.FuncForPC(pc) - if f == nil { - break - } - name = f.Name() - - // testing.tRunner is the standard library function that calls - // tests. Subtests are called directly by tRunner, without going through - // the Test/Benchmark/Example function that contains the t.Run calls, so - // with subtests we should break when we hit tRunner, without adding it - // to the list of callers. - if name == "testing.tRunner" { - break - } - - parts := strings.Split(file, "/") - file = parts[len(parts)-1] - if len(parts) > 1 { - dir := parts[len(parts)-2] - if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { - callers = append(callers, fmt.Sprintf("%s:%d", file, line)) - } - } - - // Drop the package - segments := strings.Split(name, ".") - name = segments[len(segments)-1] - if isTest(name, "Test") || - isTest(name, "Benchmark") || - isTest(name, "Example") { - break - } - } - - return callers -} - -// Stolen from the `go test` tool. -// isTest tells whether name looks like a test (or benchmark, according to prefix). -// It is a Test (say) if there is a character after Test that is not a lower-case letter. -// We don't want TesticularCancer. -func isTest(name, prefix string) bool { - if !strings.HasPrefix(name, prefix) { - return false - } - if len(name) == len(prefix) { // "Test" is ok - return true - } - rune, _ := utf8.DecodeRuneInString(name[len(prefix):]) - return !unicode.IsLower(rune) -} - -func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { - if len(msgAndArgs) == 0 || msgAndArgs == nil { - return "" - } - if len(msgAndArgs) == 1 { - return msgAndArgs[0].(string) - } - if len(msgAndArgs) > 1 { - return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...) - } - return "" -} - -// Aligns the provided message so that all lines after the first line start at the same location as the first line. -// Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab). -// The longestLabelLen parameter specifies the length of the longest label in the output (required becaues this is the -// basis on which the alignment occurs). -func indentMessageLines(message string, longestLabelLen int) string { - outBuf := new(bytes.Buffer) - - for i, scanner := 0, bufio.NewScanner(strings.NewReader(message)); scanner.Scan(); i++ { - // no need to align first line because it starts at the correct location (after the label) - if i != 0 { - // append alignLen+1 spaces to align with "{{longestLabel}}:" before adding tab - outBuf.WriteString("\n\t" + strings.Repeat(" ", longestLabelLen+1) + "\t") - } - outBuf.WriteString(scanner.Text()) - } - - return outBuf.String() -} - -type failNower interface { - FailNow() -} - -// FailNow fails test -func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - Fail(t, failureMessage, msgAndArgs...) - - // We cannot extend TestingT with FailNow() and - // maintain backwards compatibility, so we fallback - // to panicking when FailNow is not available in - // TestingT. - // See issue #263 - - if t, ok := t.(failNower); ok { - t.FailNow() - } else { - panic("test failed and t is missing `FailNow()`") - } - return false -} - -// Fail reports a failure through -func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - content := []labeledContent{ - {"Error Trace", strings.Join(CallerInfo(), "\n\t\t\t")}, - {"Error", failureMessage}, - } - - // Add test name if the Go version supports it - if n, ok := t.(interface { - Name() string - }); ok { - content = append(content, labeledContent{"Test", n.Name()}) - } - - message := messageFromMsgAndArgs(msgAndArgs...) - if len(message) > 0 { - content = append(content, labeledContent{"Messages", message}) - } - - t.Errorf("\n%s", ""+labeledOutput(content...)) - - return false -} - -type labeledContent struct { - label string - content string -} - -// labeledOutput returns a string consisting of the provided labeledContent. Each labeled output is appended in the following manner: -// -// \t{{label}}:{{align_spaces}}\t{{content}}\n -// -// The initial carriage return is required to undo/erase any padding added by testing.T.Errorf. The "\t{{label}}:" is for the label. -// If a label is shorter than the longest label provided, padding spaces are added to make all the labels match in length. Once this -// alignment is achieved, "\t{{content}}\n" is added for the output. -// -// If the content of the labeledOutput contains line breaks, the subsequent lines are aligned so that they start at the same location as the first line. -func labeledOutput(content ...labeledContent) string { - longestLabel := 0 - for _, v := range content { - if len(v.label) > longestLabel { - longestLabel = len(v.label) - } - } - var output string - for _, v := range content { - output += "\t" + v.label + ":" + strings.Repeat(" ", longestLabel-len(v.label)) + "\t" + indentMessageLines(v.content, longestLabel) + "\n" - } - return output -} - -// Implements asserts that an object is implemented by the specified interface. -// -// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) -func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - interfaceType := reflect.TypeOf(interfaceObject).Elem() - - if object == nil { - return Fail(t, fmt.Sprintf("Cannot check if nil implements %v", interfaceType), msgAndArgs...) - } - if !reflect.TypeOf(object).Implements(interfaceType) { - return Fail(t, fmt.Sprintf("%T must implement %v", object, interfaceType), msgAndArgs...) - } - - return true -} - -// IsType asserts that the specified objects are of the same type. -func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if !ObjectsAreEqual(reflect.TypeOf(object), reflect.TypeOf(expectedType)) { - return Fail(t, fmt.Sprintf("Object expected to be of type %v, but was %v", reflect.TypeOf(expectedType), reflect.TypeOf(object)), msgAndArgs...) - } - - return true -} - -// Equal asserts that two objects are equal. -// -// assert.Equal(t, 123, 123) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if err := validateEqualArgs(expected, actual); err != nil { - return Fail(t, fmt.Sprintf("Invalid operation: %#v == %#v (%s)", - expected, actual, err), msgAndArgs...) - } - - if !ObjectsAreEqual(expected, actual) { - diff := diff(expected, actual) - expected, actual = formatUnequalValues(expected, actual) - return Fail(t, fmt.Sprintf("Not equal: \n"+ - "expected: %s\n"+ - "actual : %s%s", expected, actual, diff), msgAndArgs...) - } - - return true - -} - -// formatUnequalValues takes two values of arbitrary types and returns string -// representations appropriate to be presented to the user. -// -// If the values are not of like type, the returned strings will be prefixed -// with the type name, and the value will be enclosed in parenthesis similar -// to a type conversion in the Go grammar. -func formatUnequalValues(expected, actual interface{}) (e string, a string) { - if reflect.TypeOf(expected) != reflect.TypeOf(actual) { - return fmt.Sprintf("%T(%#v)", expected, expected), - fmt.Sprintf("%T(%#v)", actual, actual) - } - - return fmt.Sprintf("%#v", expected), - fmt.Sprintf("%#v", actual) -} - -// EqualValues asserts that two objects are equal or convertable to the same types -// and equal. -// -// assert.EqualValues(t, uint32(123), int32(123)) -func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if !ObjectsAreEqualValues(expected, actual) { - diff := diff(expected, actual) - expected, actual = formatUnequalValues(expected, actual) - return Fail(t, fmt.Sprintf("Not equal: \n"+ - "expected: %s\n"+ - "actual : %s%s", expected, actual, diff), msgAndArgs...) - } - - return true - -} - -// Exactly asserts that two objects are equal in value and type. -// -// assert.Exactly(t, int32(123), int64(123)) -func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - aType := reflect.TypeOf(expected) - bType := reflect.TypeOf(actual) - - if aType != bType { - return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...) - } - - return Equal(t, expected, actual, msgAndArgs...) - -} - -// NotNil asserts that the specified object is not nil. -// -// assert.NotNil(t, err) -func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if !isNil(object) { - return true - } - return Fail(t, "Expected value not to be nil.", msgAndArgs...) -} - -// isNil checks if a specified object is nil or not, without Failing. -func isNil(object interface{}) bool { - if object == nil { - return true - } - - value := reflect.ValueOf(object) - kind := value.Kind() - if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() { - return true - } - - return false -} - -// Nil asserts that the specified object is nil. -// -// assert.Nil(t, err) -func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if isNil(object) { - return true - } - return Fail(t, fmt.Sprintf("Expected nil, but got: %#v", object), msgAndArgs...) -} - -// isEmpty gets whether the specified object is considered empty or not. -func isEmpty(object interface{}) bool { - - // get nil case out of the way - if object == nil { - return true - } - - objValue := reflect.ValueOf(object) - - switch objValue.Kind() { - // collection types are empty when they have no element - case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: - return objValue.Len() == 0 - // pointers are empty if nil or if the value they point to is empty - case reflect.Ptr: - if objValue.IsNil() { - return true - } - deref := objValue.Elem().Interface() - return isEmpty(deref) - // for all other types, compare against the zero value - default: - zero := reflect.Zero(objValue.Type()) - return reflect.DeepEqual(object, zero.Interface()) - } -} - -// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// assert.Empty(t, obj) -func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - pass := isEmpty(object) - if !pass { - Fail(t, fmt.Sprintf("Should be empty, but was %v", object), msgAndArgs...) - } - - return pass - -} - -// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if assert.NotEmpty(t, obj) { -// assert.Equal(t, "two", obj[1]) -// } -func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - pass := !isEmpty(object) - if !pass { - Fail(t, fmt.Sprintf("Should NOT be empty, but was %v", object), msgAndArgs...) - } - - return pass - -} - -// getLen try to get length of object. -// return (false, 0) if impossible. -func getLen(x interface{}) (ok bool, length int) { - v := reflect.ValueOf(x) - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - return true, v.Len() -} - -// Len asserts that the specified object has specific length. -// Len also fails if the object has a type that len() not accept. -// -// assert.Len(t, mySlice, 3) -func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - ok, l := getLen(object) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", object), msgAndArgs...) - } - - if l != length { - return Fail(t, fmt.Sprintf("\"%s\" should have %d item(s), but has %d", object, length, l), msgAndArgs...) - } - return true -} - -// True asserts that the specified value is true. -// -// assert.True(t, myBool) -func True(t TestingT, value bool, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if h, ok := t.(interface { - Helper() - }); ok { - h.Helper() - } - - if value != true { - return Fail(t, "Should be true", msgAndArgs...) - } - - return true - -} - -// False asserts that the specified value is false. -// -// assert.False(t, myBool) -func False(t TestingT, value bool, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if value != false { - return Fail(t, "Should be false", msgAndArgs...) - } - - return true - -} - -// NotEqual asserts that the specified values are NOT equal. -// -// assert.NotEqual(t, obj1, obj2) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if err := validateEqualArgs(expected, actual); err != nil { - return Fail(t, fmt.Sprintf("Invalid operation: %#v != %#v (%s)", - expected, actual, err), msgAndArgs...) - } - - if ObjectsAreEqual(expected, actual) { - return Fail(t, fmt.Sprintf("Should not be: %#v\n", actual), msgAndArgs...) - } - - return true - -} - -// containsElement try loop over the list check if the list includes the element. -// return (false, false) if impossible. -// return (true, false) if element was not found. -// return (true, true) if element was found. -func includeElement(list interface{}, element interface{}) (ok, found bool) { - - listValue := reflect.ValueOf(list) - elementValue := reflect.ValueOf(element) - defer func() { - if e := recover(); e != nil { - ok = false - found = false - } - }() - - if reflect.TypeOf(list).Kind() == reflect.String { - return true, strings.Contains(listValue.String(), elementValue.String()) - } - - if reflect.TypeOf(list).Kind() == reflect.Map { - mapKeys := listValue.MapKeys() - for i := 0; i < len(mapKeys); i++ { - if ObjectsAreEqual(mapKeys[i].Interface(), element) { - return true, true - } - } - return true, false - } - - for i := 0; i < listValue.Len(); i++ { - if ObjectsAreEqual(listValue.Index(i).Interface(), element) { - return true, true - } - } - return true, false - -} - -// Contains asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// assert.Contains(t, "Hello World", "World") -// assert.Contains(t, ["Hello", "World"], "World") -// assert.Contains(t, {"Hello": "World"}, "Hello") -func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - ok, found := includeElement(s, contains) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...) - } - if !found { - return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", s, contains), msgAndArgs...) - } - - return true - -} - -// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// assert.NotContains(t, "Hello World", "Earth") -// assert.NotContains(t, ["Hello", "World"], "Earth") -// assert.NotContains(t, {"Hello": "World"}, "Earth") -func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - ok, found := includeElement(s, contains) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...) - } - if found { - return Fail(t, fmt.Sprintf("\"%s\" should not contain \"%s\"", s, contains), msgAndArgs...) - } - - return true - -} - -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") -func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if subset == nil { - return true // we consider nil to be equal to the nil set - } - - subsetValue := reflect.ValueOf(subset) - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - - if listKind != reflect.Array && listKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) - } - - if subsetKind != reflect.Array && subsetKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) - } - - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() - ok, found := includeElement(list, element) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) - } - if !found { - return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...) - } - } - - return true -} - -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") -func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if subset == nil { - return Fail(t, fmt.Sprintf("nil is the empty set which is a subset of every set"), msgAndArgs...) - } - - subsetValue := reflect.ValueOf(subset) - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - - if listKind != reflect.Array && listKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) - } - - if subsetKind != reflect.Array && subsetKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) - } - - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() - ok, found := includeElement(list, element) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) - } - if !found { - return true - } - } - - return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...) -} - -// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2]) -func ElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if isEmpty(listA) && isEmpty(listB) { - return true - } - - aKind := reflect.TypeOf(listA).Kind() - bKind := reflect.TypeOf(listB).Kind() - - if aKind != reflect.Array && aKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", listA, aKind), msgAndArgs...) - } - - if bKind != reflect.Array && bKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", listB, bKind), msgAndArgs...) - } - - aValue := reflect.ValueOf(listA) - bValue := reflect.ValueOf(listB) - - aLen := aValue.Len() - bLen := bValue.Len() - - if aLen != bLen { - return Fail(t, fmt.Sprintf("lengths don't match: %d != %d", aLen, bLen), msgAndArgs...) - } - - // Mark indexes in bValue that we already used - visited := make([]bool, bLen) - for i := 0; i < aLen; i++ { - element := aValue.Index(i).Interface() - found := false - for j := 0; j < bLen; j++ { - if visited[j] { - continue - } - if ObjectsAreEqual(bValue.Index(j).Interface(), element) { - visited[j] = true - found = true - break - } - } - if !found { - return Fail(t, fmt.Sprintf("element %s appears more times in %s than in %s", element, aValue, bValue), msgAndArgs...) - } - } - - return true -} - -// Condition uses a Comparison to assert a complex condition. -func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - result := comp() - if !result { - Fail(t, "Condition failed!", msgAndArgs...) - } - return result -} - -// PanicTestFunc defines a func that should be passed to the assert.Panics and assert.NotPanics -// methods, and represents a simple func that takes no arguments, and returns nothing. -type PanicTestFunc func() - -// didPanic returns true if the function passed to it panics. Otherwise, it returns false. -func didPanic(f PanicTestFunc) (bool, interface{}) { - - didPanic := false - var message interface{} - func() { - - defer func() { - if message = recover(); message != nil { - didPanic = true - } - }() - - // call the target function - f() - - }() - - return didPanic, message - -} - -// Panics asserts that the code inside the specified PanicTestFunc panics. -// -// assert.Panics(t, func(){ GoCrazy() }) -func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if funcDidPanic, panicValue := didPanic(f); !funcDidPanic { - return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...) - } - - return true -} - -// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) -func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - funcDidPanic, panicValue := didPanic(f) - if !funcDidPanic { - return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...) - } - if panicValue != expected { - return Fail(t, fmt.Sprintf("func %#v should panic with value:\t%#v\n\tPanic value:\t%#v", f, expected, panicValue), msgAndArgs...) - } - - return true -} - -// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// assert.NotPanics(t, func(){ RemainCalm() }) -func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if funcDidPanic, panicValue := didPanic(f); funcDidPanic { - return Fail(t, fmt.Sprintf("func %#v should not panic\n\tPanic value:\t%v", f, panicValue), msgAndArgs...) - } - - return true -} - -// WithinDuration asserts that the two times are within duration delta of each other. -// -// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) -func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - dt := expected.Sub(actual) - if dt < -delta || dt > delta { - return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...) - } - - return true -} - -func toFloat(x interface{}) (float64, bool) { - var xf float64 - xok := true - - switch xn := x.(type) { - case uint8: - xf = float64(xn) - case uint16: - xf = float64(xn) - case uint32: - xf = float64(xn) - case uint64: - xf = float64(xn) - case int: - xf = float64(xn) - case int8: - xf = float64(xn) - case int16: - xf = float64(xn) - case int32: - xf = float64(xn) - case int64: - xf = float64(xn) - case float32: - xf = float64(xn) - case float64: - xf = float64(xn) - case time.Duration: - xf = float64(xn) - default: - xok = false - } - - return xf, xok -} - -// InDelta asserts that the two numerals are within delta of each other. -// -// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) -func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - af, aok := toFloat(expected) - bf, bok := toFloat(actual) - - if !aok || !bok { - return Fail(t, fmt.Sprintf("Parameters must be numerical"), msgAndArgs...) - } - - if math.IsNaN(af) { - return Fail(t, fmt.Sprintf("Expected must not be NaN"), msgAndArgs...) - } - - if math.IsNaN(bf) { - return Fail(t, fmt.Sprintf("Expected %v with delta %v, but was NaN", expected, delta), msgAndArgs...) - } - - dt := af - bf - if dt < -delta || dt > delta { - return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...) - } - - return true -} - -// InDeltaSlice is the same as InDelta, except it compares two slices. -func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if expected == nil || actual == nil || - reflect.TypeOf(actual).Kind() != reflect.Slice || - reflect.TypeOf(expected).Kind() != reflect.Slice { - return Fail(t, fmt.Sprintf("Parameters must be slice"), msgAndArgs...) - } - - actualSlice := reflect.ValueOf(actual) - expectedSlice := reflect.ValueOf(expected) - - for i := 0; i < actualSlice.Len(); i++ { - result := InDelta(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), delta, msgAndArgs...) - if !result { - return result - } - } - - return true -} - -// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if expected == nil || actual == nil || - reflect.TypeOf(actual).Kind() != reflect.Map || - reflect.TypeOf(expected).Kind() != reflect.Map { - return Fail(t, "Arguments must be maps", msgAndArgs...) - } - - expectedMap := reflect.ValueOf(expected) - actualMap := reflect.ValueOf(actual) - - if expectedMap.Len() != actualMap.Len() { - return Fail(t, "Arguments must have the same number of keys", msgAndArgs...) - } - - for _, k := range expectedMap.MapKeys() { - ev := expectedMap.MapIndex(k) - av := actualMap.MapIndex(k) - - if !ev.IsValid() { - return Fail(t, fmt.Sprintf("missing key %q in expected map", k), msgAndArgs...) - } - - if !av.IsValid() { - return Fail(t, fmt.Sprintf("missing key %q in actual map", k), msgAndArgs...) - } - - if !InDelta( - t, - ev.Interface(), - av.Interface(), - delta, - msgAndArgs..., - ) { - return false - } - } - - return true -} - -func calcRelativeError(expected, actual interface{}) (float64, error) { - af, aok := toFloat(expected) - if !aok { - return 0, fmt.Errorf("expected value %q cannot be converted to float", expected) - } - if af == 0 { - return 0, fmt.Errorf("expected value must have a value other than zero to calculate the relative error") - } - bf, bok := toFloat(actual) - if !bok { - return 0, fmt.Errorf("actual value %q cannot be converted to float", actual) - } - - return math.Abs(af-bf) / math.Abs(af), nil -} - -// InEpsilon asserts that expected and actual have a relative error less than epsilon -func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - actualEpsilon, err := calcRelativeError(expected, actual) - if err != nil { - return Fail(t, err.Error(), msgAndArgs...) - } - if actualEpsilon > epsilon { - return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+ - " < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...) - } - - return true -} - -// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. -func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if expected == nil || actual == nil || - reflect.TypeOf(actual).Kind() != reflect.Slice || - reflect.TypeOf(expected).Kind() != reflect.Slice { - return Fail(t, fmt.Sprintf("Parameters must be slice"), msgAndArgs...) - } - - actualSlice := reflect.ValueOf(actual) - expectedSlice := reflect.ValueOf(expected) - - for i := 0; i < actualSlice.Len(); i++ { - result := InEpsilon(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), epsilon) - if !result { - return result - } - } - - return true -} - -/* - Errors -*/ - -// NoError asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if assert.NoError(t, err) { -// assert.Equal(t, expectedObj, actualObj) -// } -func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if err != nil { - return Fail(t, fmt.Sprintf("Received unexpected error:\n%+v", err), msgAndArgs...) - } - - return true -} - -// Error asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if assert.Error(t, err) { -// assert.Equal(t, expectedError, err) -// } -func Error(t TestingT, err error, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if err == nil { - return Fail(t, "An error is expected but got nil.", msgAndArgs...) - } - - return true -} - -// EqualError asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// assert.EqualError(t, err, expectedErrorString) -func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if !Error(t, theError, msgAndArgs...) { - return false - } - expected := errString - actual := theError.Error() - // don't need to use deep equals here, we know they are both strings - if expected != actual { - return Fail(t, fmt.Sprintf("Error message not equal:\n"+ - "expected: %q\n"+ - "actual : %q", expected, actual), msgAndArgs...) - } - return true -} - -// matchRegexp return true if a specified regexp matches a string. -func matchRegexp(rx interface{}, str interface{}) bool { - - var r *regexp.Regexp - if rr, ok := rx.(*regexp.Regexp); ok { - r = rr - } else { - r = regexp.MustCompile(fmt.Sprint(rx)) - } - - return (r.FindStringIndex(fmt.Sprint(str)) != nil) - -} - -// Regexp asserts that a specified regexp matches a string. -// -// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") -// assert.Regexp(t, "start...$", "it's not starting") -func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - match := matchRegexp(rx, str) - - if !match { - Fail(t, fmt.Sprintf("Expect \"%v\" to match \"%v\"", str, rx), msgAndArgs...) - } - - return match -} - -// NotRegexp asserts that a specified regexp does not match a string. -// -// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") -// assert.NotRegexp(t, "^start", "it's not starting") -func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - match := matchRegexp(rx, str) - - if match { - Fail(t, fmt.Sprintf("Expect \"%v\" to NOT match \"%v\"", str, rx), msgAndArgs...) - } - - return !match - -} - -// Zero asserts that i is the zero value for its type. -func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if i != nil && !reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) { - return Fail(t, fmt.Sprintf("Should be zero, but was %v", i), msgAndArgs...) - } - return true -} - -// NotZero asserts that i is not the zero value for its type. -func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if i == nil || reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) { - return Fail(t, fmt.Sprintf("Should not be zero, but was %v", i), msgAndArgs...) - } - return true -} - -// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func FileExists(t TestingT, path string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - info, err := os.Lstat(path) - if err != nil { - if os.IsNotExist(err) { - return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...) - } - return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...) - } - if info.IsDir() { - return Fail(t, fmt.Sprintf("%q is a directory", path), msgAndArgs...) - } - return true -} - -// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func DirExists(t TestingT, path string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - info, err := os.Lstat(path) - if err != nil { - if os.IsNotExist(err) { - return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...) - } - return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...) - } - if !info.IsDir() { - return Fail(t, fmt.Sprintf("%q is a file", path), msgAndArgs...) - } - return true -} - -// JSONEq asserts that two JSON strings are equivalent. -// -// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) -func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - var expectedJSONAsInterface, actualJSONAsInterface interface{} - - if err := json.Unmarshal([]byte(expected), &expectedJSONAsInterface); err != nil { - return Fail(t, fmt.Sprintf("Expected value ('%s') is not valid json.\nJSON parsing error: '%s'", expected, err.Error()), msgAndArgs...) - } - - if err := json.Unmarshal([]byte(actual), &actualJSONAsInterface); err != nil { - return Fail(t, fmt.Sprintf("Input ('%s') needs to be valid json.\nJSON parsing error: '%s'", actual, err.Error()), msgAndArgs...) - } - - return Equal(t, expectedJSONAsInterface, actualJSONAsInterface, msgAndArgs...) -} - -func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) { - t := reflect.TypeOf(v) - k := t.Kind() - - if k == reflect.Ptr { - t = t.Elem() - k = t.Kind() - } - return t, k -} - -// diff returns a diff of both values as long as both are of the same type and -// are a struct, map, slice or array. Otherwise it returns an empty string. -func diff(expected interface{}, actual interface{}) string { - if expected == nil || actual == nil { - return "" - } - - et, ek := typeAndKind(expected) - at, _ := typeAndKind(actual) - - if et != at { - return "" - } - - if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array && ek != reflect.String { - return "" - } - - var e, a string - if ek != reflect.String { - e = spewConfig.Sdump(expected) - a = spewConfig.Sdump(actual) - } else { - e = expected.(string) - a = actual.(string) - } - - diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{ - A: difflib.SplitLines(e), - B: difflib.SplitLines(a), - FromFile: "Expected", - FromDate: "", - ToFile: "Actual", - ToDate: "", - Context: 1, - }) - - return "\n\nDiff:\n" + diff -} - -// validateEqualArgs checks whether provided arguments can be safely used in the -// Equal/NotEqual functions. -func validateEqualArgs(expected, actual interface{}) error { - if isFunction(expected) || isFunction(actual) { - return errors.New("cannot take func type as argument") - } - return nil -} - -func isFunction(arg interface{}) bool { - if arg == nil { - return false - } - return reflect.TypeOf(arg).Kind() == reflect.Func -} - -var spewConfig = spew.ConfigState{ - Indent: " ", - DisablePointerAddresses: true, - DisableCapacities: true, - SortKeys: true, -} - -type tHelper interface { - Helper() -} diff --git a/vendor/github.com/stretchr/testify/assert/doc.go b/vendor/github.com/stretchr/testify/assert/doc.go deleted file mode 100644 index c9dccc4..0000000 --- a/vendor/github.com/stretchr/testify/assert/doc.go +++ /dev/null @@ -1,45 +0,0 @@ -// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. -// -// Example Usage -// -// The following is a complete example using assert in a standard test function: -// import ( -// "testing" -// "github.com/stretchr/testify/assert" -// ) -// -// func TestSomething(t *testing.T) { -// -// var a string = "Hello" -// var b string = "Hello" -// -// assert.Equal(t, a, b, "The two words should be the same.") -// -// } -// -// if you assert many times, use the format below: -// -// import ( -// "testing" -// "github.com/stretchr/testify/assert" -// ) -// -// func TestSomething(t *testing.T) { -// assert := assert.New(t) -// -// var a string = "Hello" -// var b string = "Hello" -// -// assert.Equal(a, b, "The two words should be the same.") -// } -// -// Assertions -// -// Assertions allow you to easily write test code, and are global funcs in the `assert` package. -// All assertion functions take, as the first argument, the `*testing.T` object provided by the -// testing framework. This allows the assertion funcs to write the failings and other details to -// the correct place. -// -// Every assertion function also takes an optional string message as the final argument, -// allowing custom error messages to be appended to the message the assertion method outputs. -package assert diff --git a/vendor/github.com/stretchr/testify/assert/errors.go b/vendor/github.com/stretchr/testify/assert/errors.go deleted file mode 100644 index ac9dc9d..0000000 --- a/vendor/github.com/stretchr/testify/assert/errors.go +++ /dev/null @@ -1,10 +0,0 @@ -package assert - -import ( - "errors" -) - -// AnError is an error instance useful for testing. If the code does not care -// about error specifics, and only needs to return the error for example, this -// error should be used to make the test code more readable. -var AnError = errors.New("assert.AnError general error for testing") diff --git a/vendor/github.com/stretchr/testify/assert/forward_assertions.go b/vendor/github.com/stretchr/testify/assert/forward_assertions.go deleted file mode 100644 index 9ad5685..0000000 --- a/vendor/github.com/stretchr/testify/assert/forward_assertions.go +++ /dev/null @@ -1,16 +0,0 @@ -package assert - -// Assertions provides assertion methods around the -// TestingT interface. -type Assertions struct { - t TestingT -} - -// New makes a new Assertions object for the specified TestingT. -func New(t TestingT) *Assertions { - return &Assertions{ - t: t, - } -} - -//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions.go b/vendor/github.com/stretchr/testify/assert/http_assertions.go deleted file mode 100644 index df46fa7..0000000 --- a/vendor/github.com/stretchr/testify/assert/http_assertions.go +++ /dev/null @@ -1,143 +0,0 @@ -package assert - -import ( - "fmt" - "net/http" - "net/http/httptest" - "net/url" - "strings" -) - -// httpCode is a helper that returns HTTP code of the response. It returns -1 and -// an error if building a new request fails. -func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) { - w := httptest.NewRecorder() - req, err := http.NewRequest(method, url, nil) - if err != nil { - return -1, err - } - req.URL.RawQuery = values.Encode() - handler(w, req) - return w.Code, nil -} - -// HTTPSuccess asserts that a specified handler returns a success status code. -// -// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - code, err := httpCode(handler, method, url, values) - if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) - return false - } - - isSuccessCode := code >= http.StatusOK && code <= http.StatusPartialContent - if !isSuccessCode { - Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code)) - } - - return isSuccessCode -} - -// HTTPRedirect asserts that a specified handler returns a redirect status code. -// -// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - code, err := httpCode(handler, method, url, values) - if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) - return false - } - - isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect - if !isRedirectCode { - Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code)) - } - - return isRedirectCode -} - -// HTTPError asserts that a specified handler returns an error status code. -// -// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - code, err := httpCode(handler, method, url, values) - if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) - return false - } - - isErrorCode := code >= http.StatusBadRequest - if !isErrorCode { - Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code)) - } - - return isErrorCode -} - -// HTTPBody is a helper that returns HTTP body of the response. It returns -// empty string if building a new request fails. -func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string { - w := httptest.NewRecorder() - req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) - if err != nil { - return "" - } - handler(w, req) - return w.Body.String() -} - -// HTTPBodyContains asserts that a specified handler returns a -// body that contains a string. -// -// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - body := HTTPBody(handler, method, url, values) - - contains := strings.Contains(body, fmt.Sprint(str)) - if !contains { - Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) - } - - return contains -} - -// HTTPBodyNotContains asserts that a specified handler returns a -// body that does not contain a string. -// -// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - body := HTTPBody(handler, method, url, values) - - contains := strings.Contains(body, fmt.Sprint(str)) - if contains { - Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) - } - - return !contains -} diff --git a/vendor/github.com/zyedidia/clipboard/.travis.yml b/vendor/github.com/zyedidia/clipboard/.travis.yml deleted file mode 100644 index f339196..0000000 --- a/vendor/github.com/zyedidia/clipboard/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: go - -go: - - go1.2.2 - - go1.3.3 - - go1.4.3 - - go1.5.3 - - go1.6 - -before_install: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - -script: - - sudo apt-get install xsel - - go test -v . - - sudo apt-get install xclip - - go test -v . diff --git a/vendor/github.com/zyedidia/clipboard/LICENSE b/vendor/github.com/zyedidia/clipboard/LICENSE deleted file mode 100644 index bdec9a5..0000000 --- a/vendor/github.com/zyedidia/clipboard/LICENSE +++ /dev/null @@ -1,31 +0,0 @@ -Copyright (c) 2018 Zachary Yedidia. Modifications to atotto/clipboard. - -Original license: - -Copyright (c) 2013 Ato Araki. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of @atotto. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/zyedidia/clipboard/README.md b/vendor/github.com/zyedidia/clipboard/README.md deleted file mode 100644 index 8691eb1..0000000 --- a/vendor/github.com/zyedidia/clipboard/README.md +++ /dev/null @@ -1,54 +0,0 @@ -# This is a fork of atotto/clipboard - -This fork is used for `zyedidia/micro` and has some modifications, namely: support for the primary clipboard on linux and support for an internal clipboard if the system clipboard is not available. - -[![Build Status](https://travis-ci.org/atotto/clipboard.svg?branch=master)](https://travis-ci.org/atotto/clipboard) [![Build Status](https://drone.io/github.com/atotto/clipboard/status.png)](https://drone.io/github.com/atotto/clipboard/latest) - -[![GoDoc](https://godoc.org/github.com/atotto/clipboard?status.svg)](http://godoc.org/github.com/atotto/clipboard) - -# Clipboard for Go - -Provide copying and pasting to the Clipboard for Go. - -Download shell commands at https://drone.io/github.com/atotto/clipboard/files - -Build: - - $ go get github.com/atotto/clipboard - -Platforms: - -* OSX -* Windows 7 (probably work on other Windows) -* Linux, Unix (requires 'xclip' or 'xsel' command to be installed) - - -Document: - -* http://godoc.org/github.com/atotto/clipboard - -Notes: - -* Text string only -* UTF-8 text encoding only (no conversion) - -TODO: - -* Clipboard watcher(?) - -## Commands: - -paste shell command: - - $ go get github.com/atotto/clipboard/cmd/gopaste - $ # example: - $ gopaste > document.txt - -copy shell command: - - $ go get github.com/atotto/clipboard/cmd/gocopy - $ # example: - $ cat document.txt | gocopy - - - diff --git a/vendor/github.com/zyedidia/clipboard/clipboard.go b/vendor/github.com/zyedidia/clipboard/clipboard.go deleted file mode 100644 index 49e590d..0000000 --- a/vendor/github.com/zyedidia/clipboard/clipboard.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 @atotto. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package clipboard read/write on clipboard -package clipboard - -import () - -// ReadAll read string from clipboard -func ReadAll(register string) (string, error) { - return readAll(register) -} - -// WriteAll write string to clipboard -func WriteAll(text string, register string) error { - return writeAll(text, register) -} - -// Unsupported might be set true during clipboard init, to help callers decide -// whether or not to offer clipboard options. -var Unsupported bool diff --git a/vendor/github.com/zyedidia/clipboard/clipboard_darwin.go b/vendor/github.com/zyedidia/clipboard/clipboard_darwin.go deleted file mode 100644 index 66662cd..0000000 --- a/vendor/github.com/zyedidia/clipboard/clipboard_darwin.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2013 @atotto. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin - -package clipboard - -import ( - "os/exec" -) - -var ( - pasteCmdArgs = "pbpaste" - copyCmdArgs = "pbcopy" -) - -func getPasteCommand() *exec.Cmd { - return exec.Command(pasteCmdArgs) -} - -func getCopyCommand() *exec.Cmd { - return exec.Command(copyCmdArgs) -} - -func readAll(register string) (string, error) { - if register != "clipboard" { - return "", nil - } - pasteCmd := getPasteCommand() - out, err := pasteCmd.Output() - if err != nil { - return "", err - } - return string(out), nil -} - -func writeAll(text string, register string) error { - if register != "clipboard" { - return nil - } - copyCmd := getCopyCommand() - in, err := copyCmd.StdinPipe() - if err != nil { - return err - } - - if err := copyCmd.Start(); err != nil { - return err - } - if _, err := in.Write([]byte(text)); err != nil { - return err - } - if err := in.Close(); err != nil { - return err - } - return copyCmd.Wait() -} diff --git a/vendor/github.com/zyedidia/clipboard/clipboard_unix.go b/vendor/github.com/zyedidia/clipboard/clipboard_unix.go deleted file mode 100644 index 87d0251..0000000 --- a/vendor/github.com/zyedidia/clipboard/clipboard_unix.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2013 @atotto. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build freebsd linux netbsd openbsd solaris - -package clipboard - -import "os/exec" - -const ( - xsel = "xsel" - xclip = "xclip" -) - -var ( - internalClipboards map[string]string -) - -func init() { - if _, err := exec.LookPath(xclip); err == nil { - if err := exec.Command("xclip", "-o").Run(); err == nil { - return - } - } - if _, err := exec.LookPath(xsel); err == nil { - if err := exec.Command("xsel").Run(); err == nil { - return - } - } - - internalClipboards = make(map[string]string) - Unsupported = true -} - -func copyCommand(register string) []string { - if _, err := exec.LookPath(xclip); err == nil { - return []string{xclip, "-in", "-selection", register} - } - - if _, err := exec.LookPath(xsel); err == nil { - return []string{xsel, "--input", "--" + register} - } - - return []string{} -} -func pasteCommand(register string) []string { - if _, err := exec.LookPath(xclip); err == nil { - return []string{xclip, "-out", "-selection", register} - } - - if _, err := exec.LookPath(xsel); err == nil { - return []string{xsel, "--output", "--" + register} - } - - return []string{} -} - -func getPasteCommand(register string) *exec.Cmd { - pasteCmdArgs := pasteCommand(register) - return exec.Command(pasteCmdArgs[0], pasteCmdArgs[1:]...) -} - -func getCopyCommand(register string) *exec.Cmd { - copyCmdArgs := copyCommand(register) - return exec.Command(copyCmdArgs[0], copyCmdArgs[1:]...) -} - -func readAll(register string) (string, error) { - if Unsupported { - if text, ok := internalClipboards[register]; ok { - return text, nil - } - return "", nil - } - pasteCmd := getPasteCommand(register) - out, err := pasteCmd.Output() - if err != nil { - return "", err - } - return string(out), nil -} - -func writeAll(text string, register string) error { - if Unsupported { - internalClipboards[register] = text - return nil - } - copyCmd := getCopyCommand(register) - in, err := copyCmd.StdinPipe() - if err != nil { - return err - } - - if err := copyCmd.Start(); err != nil { - return err - } - if _, err := in.Write([]byte(text)); err != nil { - return err - } - if err := in.Close(); err != nil { - return err - } - return copyCmd.Wait() -} diff --git a/vendor/github.com/zyedidia/clipboard/clipboard_windows.go b/vendor/github.com/zyedidia/clipboard/clipboard_windows.go deleted file mode 100644 index 2c1fecf..0000000 --- a/vendor/github.com/zyedidia/clipboard/clipboard_windows.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2013 @atotto. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package clipboard - -import ( - "syscall" - "unsafe" -) - -const ( - cfUnicodetext = 13 - gmemFixed = 0x0000 -) - -var ( - user32 = syscall.MustLoadDLL("user32") - openClipboard = user32.MustFindProc("OpenClipboard") - closeClipboard = user32.MustFindProc("CloseClipboard") - emptyClipboard = user32.MustFindProc("EmptyClipboard") - getClipboardData = user32.MustFindProc("GetClipboardData") - setClipboardData = user32.MustFindProc("SetClipboardData") - - kernel32 = syscall.NewLazyDLL("kernel32") - globalAlloc = kernel32.NewProc("GlobalAlloc") - globalFree = kernel32.NewProc("GlobalFree") - globalLock = kernel32.NewProc("GlobalLock") - globalUnlock = kernel32.NewProc("GlobalUnlock") - lstrcpy = kernel32.NewProc("lstrcpyW") -) - -func readAll(register string) (string, error) { - if register != "clipboard" { - return "", nil - } - r, _, err := openClipboard.Call(0) - if r == 0 { - return "", err - } - defer closeClipboard.Call() - - h, _, err := getClipboardData.Call(cfUnicodetext) - if r == 0 { - return "", err - } - - l, _, err := globalLock.Call(h) - if l == 0 { - return "", err - } - - text := syscall.UTF16ToString((*[1 << 20]uint16)(unsafe.Pointer(l))[:]) - - r, _, err = globalUnlock.Call(h) - if r == 0 { - return "", err - } - - return text, nil -} - -func writeAll(text string, register string) error { - if register != "clipboard" { - return nil - } - r, _, err := openClipboard.Call(0) - if r == 0 { - return err - } - defer closeClipboard.Call() - - r, _, err = emptyClipboard.Call(0) - if r == 0 { - return err - } - - data := syscall.StringToUTF16(text) - - h, _, err := globalAlloc.Call(gmemFixed, uintptr(len(data)*int(unsafe.Sizeof(data[0])))) - if h == 0 { - return err - } - - l, _, err := globalLock.Call(h) - if l == 0 { - return err - } - - r, _, err = lstrcpy.Call(l, uintptr(unsafe.Pointer(&data[0]))) - if r == 0 { - return err - } - - r, _, err = globalUnlock.Call(h) - if r == 0 { - return err - } - - r, _, err = setClipboardData.Call(cfUnicodetext, h) - if r == 0 { - return err - } - return nil -} diff --git a/vendor/golang.org/x/image/AUTHORS b/vendor/golang.org/x/image/AUTHORS deleted file mode 100644 index 15167cd..0000000 --- a/vendor/golang.org/x/image/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/image/CONTRIBUTORS b/vendor/golang.org/x/image/CONTRIBUTORS deleted file mode 100644 index 1c4577e..0000000 --- a/vendor/golang.org/x/image/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/image/LICENSE b/vendor/golang.org/x/image/LICENSE deleted file mode 100644 index 6a66aea..0000000 --- a/vendor/golang.org/x/image/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/image/PATENTS b/vendor/golang.org/x/image/PATENTS deleted file mode 100644 index 7330990..0000000 --- a/vendor/golang.org/x/image/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/image/bmp/reader.go b/vendor/golang.org/x/image/bmp/reader.go deleted file mode 100644 index c10a022..0000000 --- a/vendor/golang.org/x/image/bmp/reader.go +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package bmp implements a BMP image decoder and encoder. -// -// The BMP specification is at http://www.digicamsoft.com/bmp/bmp.html. -package bmp // import "golang.org/x/image/bmp" - -import ( - "errors" - "image" - "image/color" - "io" -) - -// ErrUnsupported means that the input BMP image uses a valid but unsupported -// feature. -var ErrUnsupported = errors.New("bmp: unsupported BMP image") - -func readUint16(b []byte) uint16 { - return uint16(b[0]) | uint16(b[1])<<8 -} - -func readUint32(b []byte) uint32 { - return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 -} - -// decodePaletted reads an 8 bit-per-pixel BMP image from r. -// If topDown is false, the image rows will be read bottom-up. -func decodePaletted(r io.Reader, c image.Config, topDown bool) (image.Image, error) { - paletted := image.NewPaletted(image.Rect(0, 0, c.Width, c.Height), c.ColorModel.(color.Palette)) - if c.Width == 0 || c.Height == 0 { - return paletted, nil - } - var tmp [4]byte - y0, y1, yDelta := c.Height-1, -1, -1 - if topDown { - y0, y1, yDelta = 0, c.Height, +1 - } - for y := y0; y != y1; y += yDelta { - p := paletted.Pix[y*paletted.Stride : y*paletted.Stride+c.Width] - if _, err := io.ReadFull(r, p); err != nil { - return nil, err - } - // Each row is 4-byte aligned. - if c.Width%4 != 0 { - _, err := io.ReadFull(r, tmp[:4-c.Width%4]) - if err != nil { - return nil, err - } - } - } - return paletted, nil -} - -// decodeRGB reads a 24 bit-per-pixel BMP image from r. -// If topDown is false, the image rows will be read bottom-up. -func decodeRGB(r io.Reader, c image.Config, topDown bool) (image.Image, error) { - rgba := image.NewRGBA(image.Rect(0, 0, c.Width, c.Height)) - if c.Width == 0 || c.Height == 0 { - return rgba, nil - } - // There are 3 bytes per pixel, and each row is 4-byte aligned. - b := make([]byte, (3*c.Width+3)&^3) - y0, y1, yDelta := c.Height-1, -1, -1 - if topDown { - y0, y1, yDelta = 0, c.Height, +1 - } - for y := y0; y != y1; y += yDelta { - if _, err := io.ReadFull(r, b); err != nil { - return nil, err - } - p := rgba.Pix[y*rgba.Stride : y*rgba.Stride+c.Width*4] - for i, j := 0, 0; i < len(p); i, j = i+4, j+3 { - // BMP images are stored in BGR order rather than RGB order. - p[i+0] = b[j+2] - p[i+1] = b[j+1] - p[i+2] = b[j+0] - p[i+3] = 0xFF - } - } - return rgba, nil -} - -// decodeNRGBA reads a 32 bit-per-pixel BMP image from r. -// If topDown is false, the image rows will be read bottom-up. -func decodeNRGBA(r io.Reader, c image.Config, topDown bool) (image.Image, error) { - rgba := image.NewNRGBA(image.Rect(0, 0, c.Width, c.Height)) - if c.Width == 0 || c.Height == 0 { - return rgba, nil - } - y0, y1, yDelta := c.Height-1, -1, -1 - if topDown { - y0, y1, yDelta = 0, c.Height, +1 - } - for y := y0; y != y1; y += yDelta { - p := rgba.Pix[y*rgba.Stride : y*rgba.Stride+c.Width*4] - if _, err := io.ReadFull(r, p); err != nil { - return nil, err - } - for i := 0; i < len(p); i += 4 { - // BMP images are stored in BGRA order rather than RGBA order. - p[i+0], p[i+2] = p[i+2], p[i+0] - } - } - return rgba, nil -} - -// Decode reads a BMP image from r and returns it as an image.Image. -// Limitation: The file must be 8, 24 or 32 bits per pixel. -func Decode(r io.Reader) (image.Image, error) { - c, bpp, topDown, err := decodeConfig(r) - if err != nil { - return nil, err - } - switch bpp { - case 8: - return decodePaletted(r, c, topDown) - case 24: - return decodeRGB(r, c, topDown) - case 32: - return decodeNRGBA(r, c, topDown) - } - panic("unreachable") -} - -// DecodeConfig returns the color model and dimensions of a BMP image without -// decoding the entire image. -// Limitation: The file must be 8, 24 or 32 bits per pixel. -func DecodeConfig(r io.Reader) (image.Config, error) { - config, _, _, err := decodeConfig(r) - return config, err -} - -func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown bool, err error) { - // We only support those BMP images that are a BITMAPFILEHEADER - // immediately followed by a BITMAPINFOHEADER. - const ( - fileHeaderLen = 14 - infoHeaderLen = 40 - v4InfoHeaderLen = 108 - v5InfoHeaderLen = 124 - ) - var b [1024]byte - if _, err := io.ReadFull(r, b[:fileHeaderLen+4]); err != nil { - return image.Config{}, 0, false, err - } - if string(b[:2]) != "BM" { - return image.Config{}, 0, false, errors.New("bmp: invalid format") - } - offset := readUint32(b[10:14]) - infoLen := readUint32(b[14:18]) - if infoLen != infoHeaderLen && infoLen != v4InfoHeaderLen && infoLen != v5InfoHeaderLen { - return image.Config{}, 0, false, ErrUnsupported - } - if _, err := io.ReadFull(r, b[fileHeaderLen+4:fileHeaderLen+infoLen]); err != nil { - return image.Config{}, 0, false, err - } - width := int(int32(readUint32(b[18:22]))) - height := int(int32(readUint32(b[22:26]))) - if height < 0 { - height, topDown = -height, true - } - if width < 0 || height < 0 { - return image.Config{}, 0, false, ErrUnsupported - } - // We only support 1 plane and 8, 24 or 32 bits per pixel and no - // compression. - planes, bpp, compression := readUint16(b[26:28]), readUint16(b[28:30]), readUint32(b[30:34]) - // if compression is set to BITFIELDS, but the bitmask is set to the default bitmask - // that would be used if compression was set to 0, we can continue as if compression was 0 - if compression == 3 && infoLen > infoHeaderLen && - readUint32(b[54:58]) == 0xff0000 && readUint32(b[58:62]) == 0xff00 && - readUint32(b[62:66]) == 0xff && readUint32(b[66:70]) == 0xff000000 { - compression = 0 - } - if planes != 1 || compression != 0 { - return image.Config{}, 0, false, ErrUnsupported - } - switch bpp { - case 8: - if offset != fileHeaderLen+infoLen+256*4 { - return image.Config{}, 0, false, ErrUnsupported - } - _, err = io.ReadFull(r, b[:256*4]) - if err != nil { - return image.Config{}, 0, false, err - } - pcm := make(color.Palette, 256) - for i := range pcm { - // BMP images are stored in BGR order rather than RGB order. - // Every 4th byte is padding. - pcm[i] = color.RGBA{b[4*i+2], b[4*i+1], b[4*i+0], 0xFF} - } - return image.Config{ColorModel: pcm, Width: width, Height: height}, 8, topDown, nil - case 24: - if offset != fileHeaderLen+infoLen { - return image.Config{}, 0, false, ErrUnsupported - } - return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 24, topDown, nil - case 32: - if offset != fileHeaderLen+infoLen { - return image.Config{}, 0, false, ErrUnsupported - } - return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 32, topDown, nil - } - return image.Config{}, 0, false, ErrUnsupported -} - -func init() { - image.RegisterFormat("bmp", "BM????\x00\x00\x00\x00", Decode, DecodeConfig) -} diff --git a/vendor/golang.org/x/image/bmp/writer.go b/vendor/golang.org/x/image/bmp/writer.go deleted file mode 100644 index f07b39d..0000000 --- a/vendor/golang.org/x/image/bmp/writer.go +++ /dev/null @@ -1,262 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bmp - -import ( - "encoding/binary" - "errors" - "image" - "io" -) - -type header struct { - sigBM [2]byte - fileSize uint32 - resverved [2]uint16 - pixOffset uint32 - dibHeaderSize uint32 - width uint32 - height uint32 - colorPlane uint16 - bpp uint16 - compression uint32 - imageSize uint32 - xPixelsPerMeter uint32 - yPixelsPerMeter uint32 - colorUse uint32 - colorImportant uint32 -} - -func encodePaletted(w io.Writer, pix []uint8, dx, dy, stride, step int) error { - var padding []byte - if dx < step { - padding = make([]byte, step-dx) - } - for y := dy - 1; y >= 0; y-- { - min := y*stride + 0 - max := y*stride + dx - if _, err := w.Write(pix[min:max]); err != nil { - return err - } - if padding != nil { - if _, err := w.Write(padding); err != nil { - return err - } - } - } - return nil -} - -func encodeRGBA(w io.Writer, pix []uint8, dx, dy, stride, step int, opaque bool) error { - buf := make([]byte, step) - if opaque { - for y := dy - 1; y >= 0; y-- { - min := y*stride + 0 - max := y*stride + dx*4 - off := 0 - for i := min; i < max; i += 4 { - buf[off+2] = pix[i+0] - buf[off+1] = pix[i+1] - buf[off+0] = pix[i+2] - off += 3 - } - if _, err := w.Write(buf); err != nil { - return err - } - } - } else { - for y := dy - 1; y >= 0; y-- { - min := y*stride + 0 - max := y*stride + dx*4 - off := 0 - for i := min; i < max; i += 4 { - a := uint32(pix[i+3]) - if a == 0 { - buf[off+2] = 0 - buf[off+1] = 0 - buf[off+0] = 0 - buf[off+3] = 0 - off += 4 - continue - } else if a == 0xff { - buf[off+2] = pix[i+0] - buf[off+1] = pix[i+1] - buf[off+0] = pix[i+2] - buf[off+3] = 0xff - off += 4 - continue - } - buf[off+2] = uint8(((uint32(pix[i+0]) * 0xffff) / a) >> 8) - buf[off+1] = uint8(((uint32(pix[i+1]) * 0xffff) / a) >> 8) - buf[off+0] = uint8(((uint32(pix[i+2]) * 0xffff) / a) >> 8) - buf[off+3] = uint8(a) - off += 4 - } - if _, err := w.Write(buf); err != nil { - return err - } - } - } - return nil -} - -func encodeNRGBA(w io.Writer, pix []uint8, dx, dy, stride, step int, opaque bool) error { - buf := make([]byte, step) - if opaque { - for y := dy - 1; y >= 0; y-- { - min := y*stride + 0 - max := y*stride + dx*4 - off := 0 - for i := min; i < max; i += 4 { - buf[off+2] = pix[i+0] - buf[off+1] = pix[i+1] - buf[off+0] = pix[i+2] - off += 3 - } - if _, err := w.Write(buf); err != nil { - return err - } - } - } else { - for y := dy - 1; y >= 0; y-- { - min := y*stride + 0 - max := y*stride + dx*4 - off := 0 - for i := min; i < max; i += 4 { - buf[off+2] = pix[i+0] - buf[off+1] = pix[i+1] - buf[off+0] = pix[i+2] - buf[off+3] = pix[i+3] - off += 4 - } - if _, err := w.Write(buf); err != nil { - return err - } - } - } - return nil -} - -func encode(w io.Writer, m image.Image, step int) error { - b := m.Bounds() - buf := make([]byte, step) - for y := b.Max.Y - 1; y >= b.Min.Y; y-- { - off := 0 - for x := b.Min.X; x < b.Max.X; x++ { - r, g, b, _ := m.At(x, y).RGBA() - buf[off+2] = byte(r >> 8) - buf[off+1] = byte(g >> 8) - buf[off+0] = byte(b >> 8) - off += 3 - } - if _, err := w.Write(buf); err != nil { - return err - } - } - return nil -} - -// Encode writes the image m to w in BMP format. -func Encode(w io.Writer, m image.Image) error { - d := m.Bounds().Size() - if d.X < 0 || d.Y < 0 { - return errors.New("bmp: negative bounds") - } - h := &header{ - sigBM: [2]byte{'B', 'M'}, - fileSize: 14 + 40, - pixOffset: 14 + 40, - dibHeaderSize: 40, - width: uint32(d.X), - height: uint32(d.Y), - colorPlane: 1, - } - - var step int - var palette []byte - var opaque bool - switch m := m.(type) { - case *image.Gray: - step = (d.X + 3) &^ 3 - palette = make([]byte, 1024) - for i := 0; i < 256; i++ { - palette[i*4+0] = uint8(i) - palette[i*4+1] = uint8(i) - palette[i*4+2] = uint8(i) - palette[i*4+3] = 0xFF - } - h.imageSize = uint32(d.Y * step) - h.fileSize += uint32(len(palette)) + h.imageSize - h.pixOffset += uint32(len(palette)) - h.bpp = 8 - - case *image.Paletted: - step = (d.X + 3) &^ 3 - palette = make([]byte, 1024) - for i := 0; i < len(m.Palette) && i < 256; i++ { - r, g, b, _ := m.Palette[i].RGBA() - palette[i*4+0] = uint8(b >> 8) - palette[i*4+1] = uint8(g >> 8) - palette[i*4+2] = uint8(r >> 8) - palette[i*4+3] = 0xFF - } - h.imageSize = uint32(d.Y * step) - h.fileSize += uint32(len(palette)) + h.imageSize - h.pixOffset += uint32(len(palette)) - h.bpp = 8 - case *image.RGBA: - opaque = m.Opaque() - if opaque { - step = (3*d.X + 3) &^ 3 - h.bpp = 24 - } else { - step = 4 * d.X - h.bpp = 32 - } - h.imageSize = uint32(d.Y * step) - h.fileSize += h.imageSize - case *image.NRGBA: - opaque = m.Opaque() - if opaque { - step = (3*d.X + 3) &^ 3 - h.bpp = 24 - } else { - step = 4 * d.X - h.bpp = 32 - } - h.imageSize = uint32(d.Y * step) - h.fileSize += h.imageSize - default: - step = (3*d.X + 3) &^ 3 - h.imageSize = uint32(d.Y * step) - h.fileSize += h.imageSize - h.bpp = 24 - } - - if err := binary.Write(w, binary.LittleEndian, h); err != nil { - return err - } - if palette != nil { - if err := binary.Write(w, binary.LittleEndian, palette); err != nil { - return err - } - } - - if d.X == 0 || d.Y == 0 { - return nil - } - - switch m := m.(type) { - case *image.Gray: - return encodePaletted(w, m.Pix, d.X, d.Y, m.Stride, step) - case *image.Paletted: - return encodePaletted(w, m.Pix, d.X, d.Y, m.Stride, step) - case *image.RGBA: - return encodeRGBA(w, m.Pix, d.X, d.Y, m.Stride, step, opaque) - case *image.NRGBA: - return encodeNRGBA(w, m.Pix, d.X, d.Y, m.Stride, step, opaque) - } - return encode(w, m, step) -} diff --git a/vendor/golang.org/x/image/riff/riff.go b/vendor/golang.org/x/image/riff/riff.go deleted file mode 100644 index 38dc0e5..0000000 --- a/vendor/golang.org/x/image/riff/riff.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package riff implements the Resource Interchange File Format, used by media -// formats such as AVI, WAVE and WEBP. -// -// A RIFF stream contains a sequence of chunks. Each chunk consists of an 8-byte -// header (containing a 4-byte chunk type and a 4-byte chunk length), the chunk -// data (presented as an io.Reader), and some padding bytes. -// -// A detailed description of the format is at -// http://www.tactilemedia.com/info/MCI_Control_Info.html -package riff // import "golang.org/x/image/riff" - -import ( - "errors" - "io" - "io/ioutil" - "math" -) - -var ( - errMissingPaddingByte = errors.New("riff: missing padding byte") - errMissingRIFFChunkHeader = errors.New("riff: missing RIFF chunk header") - errListSubchunkTooLong = errors.New("riff: list subchunk too long") - errShortChunkData = errors.New("riff: short chunk data") - errShortChunkHeader = errors.New("riff: short chunk header") - errStaleReader = errors.New("riff: stale reader") -) - -// u32 decodes the first four bytes of b as a little-endian integer. -func u32(b []byte) uint32 { - return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 -} - -const chunkHeaderSize = 8 - -// FourCC is a four character code. -type FourCC [4]byte - -// LIST is the "LIST" FourCC. -var LIST = FourCC{'L', 'I', 'S', 'T'} - -// NewReader returns the RIFF stream's form type, such as "AVI " or "WAVE", and -// its chunks as a *Reader. -func NewReader(r io.Reader) (formType FourCC, data *Reader, err error) { - var buf [chunkHeaderSize]byte - if _, err := io.ReadFull(r, buf[:]); err != nil { - if err == io.EOF || err == io.ErrUnexpectedEOF { - err = errMissingRIFFChunkHeader - } - return FourCC{}, nil, err - } - if buf[0] != 'R' || buf[1] != 'I' || buf[2] != 'F' || buf[3] != 'F' { - return FourCC{}, nil, errMissingRIFFChunkHeader - } - return NewListReader(u32(buf[4:]), r) -} - -// NewListReader returns a LIST chunk's list type, such as "movi" or "wavl", -// and its chunks as a *Reader. -func NewListReader(chunkLen uint32, chunkData io.Reader) (listType FourCC, data *Reader, err error) { - if chunkLen < 4 { - return FourCC{}, nil, errShortChunkData - } - z := &Reader{r: chunkData} - if _, err := io.ReadFull(chunkData, z.buf[:4]); err != nil { - if err == io.EOF || err == io.ErrUnexpectedEOF { - err = errShortChunkData - } - return FourCC{}, nil, err - } - z.totalLen = chunkLen - 4 - return FourCC{z.buf[0], z.buf[1], z.buf[2], z.buf[3]}, z, nil -} - -// Reader reads chunks from an underlying io.Reader. -type Reader struct { - r io.Reader - err error - - totalLen uint32 - chunkLen uint32 - - chunkReader *chunkReader - buf [chunkHeaderSize]byte - padded bool -} - -// Next returns the next chunk's ID, length and data. It returns io.EOF if there -// are no more chunks. The io.Reader returned becomes stale after the next Next -// call, and should no longer be used. -// -// It is valid to call Next even if all of the previous chunk's data has not -// been read. -func (z *Reader) Next() (chunkID FourCC, chunkLen uint32, chunkData io.Reader, err error) { - if z.err != nil { - return FourCC{}, 0, nil, z.err - } - - // Drain the rest of the previous chunk. - if z.chunkLen != 0 { - want := z.chunkLen - var got int64 - got, z.err = io.Copy(ioutil.Discard, z.chunkReader) - if z.err == nil && uint32(got) != want { - z.err = errShortChunkData - } - if z.err != nil { - return FourCC{}, 0, nil, z.err - } - } - z.chunkReader = nil - if z.padded { - if z.totalLen == 0 { - z.err = errListSubchunkTooLong - return FourCC{}, 0, nil, z.err - } - z.totalLen-- - _, z.err = io.ReadFull(z.r, z.buf[:1]) - if z.err != nil { - if z.err == io.EOF { - z.err = errMissingPaddingByte - } - return FourCC{}, 0, nil, z.err - } - } - - // We are done if we have no more data. - if z.totalLen == 0 { - z.err = io.EOF - return FourCC{}, 0, nil, z.err - } - - // Read the next chunk header. - if z.totalLen < chunkHeaderSize { - z.err = errShortChunkHeader - return FourCC{}, 0, nil, z.err - } - z.totalLen -= chunkHeaderSize - if _, z.err = io.ReadFull(z.r, z.buf[:chunkHeaderSize]); z.err != nil { - if z.err == io.EOF || z.err == io.ErrUnexpectedEOF { - z.err = errShortChunkHeader - } - return FourCC{}, 0, nil, z.err - } - chunkID = FourCC{z.buf[0], z.buf[1], z.buf[2], z.buf[3]} - z.chunkLen = u32(z.buf[4:]) - if z.chunkLen > z.totalLen { - z.err = errListSubchunkTooLong - return FourCC{}, 0, nil, z.err - } - z.padded = z.chunkLen&1 == 1 - z.chunkReader = &chunkReader{z} - return chunkID, z.chunkLen, z.chunkReader, nil -} - -type chunkReader struct { - z *Reader -} - -func (c *chunkReader) Read(p []byte) (int, error) { - if c != c.z.chunkReader { - return 0, errStaleReader - } - z := c.z - if z.err != nil { - if z.err == io.EOF { - return 0, errStaleReader - } - return 0, z.err - } - - n := int(z.chunkLen) - if n == 0 { - return 0, io.EOF - } - if n < 0 { - // Converting uint32 to int overflowed. - n = math.MaxInt32 - } - if n > len(p) { - n = len(p) - } - n, err := z.r.Read(p[:n]) - z.totalLen -= uint32(n) - z.chunkLen -= uint32(n) - if err != io.EOF { - z.err = err - } - return n, err -} diff --git a/vendor/golang.org/x/image/tiff/buffer.go b/vendor/golang.org/x/image/tiff/buffer.go deleted file mode 100644 index d1801be..0000000 --- a/vendor/golang.org/x/image/tiff/buffer.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tiff - -import "io" - -// buffer buffers an io.Reader to satisfy io.ReaderAt. -type buffer struct { - r io.Reader - buf []byte -} - -// fill reads data from b.r until the buffer contains at least end bytes. -func (b *buffer) fill(end int) error { - m := len(b.buf) - if end > m { - if end > cap(b.buf) { - newcap := 1024 - for newcap < end { - newcap *= 2 - } - newbuf := make([]byte, end, newcap) - copy(newbuf, b.buf) - b.buf = newbuf - } else { - b.buf = b.buf[:end] - } - if n, err := io.ReadFull(b.r, b.buf[m:end]); err != nil { - end = m + n - b.buf = b.buf[:end] - return err - } - } - return nil -} - -func (b *buffer) ReadAt(p []byte, off int64) (int, error) { - o := int(off) - end := o + len(p) - if int64(end) != off+int64(len(p)) { - return 0, io.ErrUnexpectedEOF - } - - err := b.fill(end) - return copy(p, b.buf[o:end]), err -} - -// Slice returns a slice of the underlying buffer. The slice contains -// n bytes starting at offset off. -func (b *buffer) Slice(off, n int) ([]byte, error) { - end := off + n - if err := b.fill(end); err != nil { - return nil, err - } - return b.buf[off:end], nil -} - -// newReaderAt converts an io.Reader into an io.ReaderAt. -func newReaderAt(r io.Reader) io.ReaderAt { - if ra, ok := r.(io.ReaderAt); ok { - return ra - } - return &buffer{ - r: r, - buf: make([]byte, 0, 1024), - } -} diff --git a/vendor/golang.org/x/image/tiff/compress.go b/vendor/golang.org/x/image/tiff/compress.go deleted file mode 100644 index 3f176f0..0000000 --- a/vendor/golang.org/x/image/tiff/compress.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tiff - -import ( - "bufio" - "io" -) - -type byteReader interface { - io.Reader - io.ByteReader -} - -// unpackBits decodes the PackBits-compressed data in src and returns the -// uncompressed data. -// -// The PackBits compression format is described in section 9 (p. 42) -// of the TIFF spec. -func unpackBits(r io.Reader) ([]byte, error) { - buf := make([]byte, 128) - dst := make([]byte, 0, 1024) - br, ok := r.(byteReader) - if !ok { - br = bufio.NewReader(r) - } - - for { - b, err := br.ReadByte() - if err != nil { - if err == io.EOF { - return dst, nil - } - return nil, err - } - code := int(int8(b)) - switch { - case code >= 0: - n, err := io.ReadFull(br, buf[:code+1]) - if err != nil { - return nil, err - } - dst = append(dst, buf[:n]...) - case code == -128: - // No-op. - default: - if b, err = br.ReadByte(); err != nil { - return nil, err - } - for j := 0; j < 1-code; j++ { - buf[j] = b - } - dst = append(dst, buf[:1-code]...) - } - } -} diff --git a/vendor/golang.org/x/image/tiff/consts.go b/vendor/golang.org/x/image/tiff/consts.go deleted file mode 100644 index 3c51a70..0000000 --- a/vendor/golang.org/x/image/tiff/consts.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tiff - -// A tiff image file contains one or more images. The metadata -// of each image is contained in an Image File Directory (IFD), -// which contains entries of 12 bytes each and is described -// on page 14-16 of the specification. An IFD entry consists of -// -// - a tag, which describes the signification of the entry, -// - the data type and length of the entry, -// - the data itself or a pointer to it if it is more than 4 bytes. -// -// The presence of a length means that each IFD is effectively an array. - -const ( - leHeader = "II\x2A\x00" // Header for little-endian files. - beHeader = "MM\x00\x2A" // Header for big-endian files. - - ifdLen = 12 // Length of an IFD entry in bytes. -) - -// Data types (p. 14-16 of the spec). -const ( - dtByte = 1 - dtASCII = 2 - dtShort = 3 - dtLong = 4 - dtRational = 5 -) - -// The length of one instance of each data type in bytes. -var lengths = [...]uint32{0, 1, 1, 2, 4, 8} - -// Tags (see p. 28-41 of the spec). -const ( - tImageWidth = 256 - tImageLength = 257 - tBitsPerSample = 258 - tCompression = 259 - tPhotometricInterpretation = 262 - - tStripOffsets = 273 - tSamplesPerPixel = 277 - tRowsPerStrip = 278 - tStripByteCounts = 279 - - tTileWidth = 322 - tTileLength = 323 - tTileOffsets = 324 - tTileByteCounts = 325 - - tXResolution = 282 - tYResolution = 283 - tResolutionUnit = 296 - - tPredictor = 317 - tColorMap = 320 - tExtraSamples = 338 - tSampleFormat = 339 -) - -// Compression types (defined in various places in the spec and supplements). -const ( - cNone = 1 - cCCITT = 2 - cG3 = 3 // Group 3 Fax. - cG4 = 4 // Group 4 Fax. - cLZW = 5 - cJPEGOld = 6 // Superseded by cJPEG. - cJPEG = 7 - cDeflate = 8 // zlib compression. - cPackBits = 32773 - cDeflateOld = 32946 // Superseded by cDeflate. -) - -// Photometric interpretation values (see p. 37 of the spec). -const ( - pWhiteIsZero = 0 - pBlackIsZero = 1 - pRGB = 2 - pPaletted = 3 - pTransMask = 4 // transparency mask - pCMYK = 5 - pYCbCr = 6 - pCIELab = 8 -) - -// Values for the tPredictor tag (page 64-65 of the spec). -const ( - prNone = 1 - prHorizontal = 2 -) - -// Values for the tResolutionUnit tag (page 18). -const ( - resNone = 1 - resPerInch = 2 // Dots per inch. - resPerCM = 3 // Dots per centimeter. -) - -// imageMode represents the mode of the image. -type imageMode int - -const ( - mBilevel imageMode = iota - mPaletted - mGray - mGrayInvert - mRGB - mRGBA - mNRGBA -) - -// CompressionType describes the type of compression used in Options. -type CompressionType int - -const ( - Uncompressed CompressionType = iota - Deflate -) - -// specValue returns the compression type constant from the TIFF spec that -// is equivalent to c. -func (c CompressionType) specValue() uint32 { - switch c { - case Deflate: - return cDeflate - } - return cNone -} diff --git a/vendor/golang.org/x/image/tiff/lzw/reader.go b/vendor/golang.org/x/image/tiff/lzw/reader.go deleted file mode 100644 index 51ae39f..0000000 --- a/vendor/golang.org/x/image/tiff/lzw/reader.go +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package lzw implements the Lempel-Ziv-Welch compressed data format, -// described in T. A. Welch, ``A Technique for High-Performance Data -// Compression'', Computer, 17(6) (June 1984), pp 8-19. -// -// In particular, it implements LZW as used by the TIFF file format, including -// an "off by one" algorithmic difference when compared to standard LZW. -package lzw // import "golang.org/x/image/tiff/lzw" - -/* -This file was branched from src/pkg/compress/lzw/reader.go in the -standard library. Differences from the original are marked with "NOTE". - -The tif_lzw.c file in the libtiff C library has this comment: - ----- -The 5.0 spec describes a different algorithm than Aldus -implements. Specifically, Aldus does code length transitions -one code earlier than should be done (for real LZW). -Earlier versions of this library implemented the correct -LZW algorithm, but emitted codes in a bit order opposite -to the TIFF spec. Thus, to maintain compatibility w/ Aldus -we interpret MSB-LSB ordered codes to be images written w/ -old versions of this library, but otherwise adhere to the -Aldus "off by one" algorithm. ----- - -The Go code doesn't read (invalid) TIFF files written by old versions of -libtiff, but the LZW algorithm in this package still differs from the one in -Go's standard package library to accomodate this "off by one" in valid TIFFs. -*/ - -import ( - "bufio" - "errors" - "fmt" - "io" -) - -// Order specifies the bit ordering in an LZW data stream. -type Order int - -const ( - // LSB means Least Significant Bits first, as used in the GIF file format. - LSB Order = iota - // MSB means Most Significant Bits first, as used in the TIFF and PDF - // file formats. - MSB -) - -const ( - maxWidth = 12 - decoderInvalidCode = 0xffff - flushBuffer = 1 << maxWidth -) - -// decoder is the state from which the readXxx method converts a byte -// stream into a code stream. -type decoder struct { - r io.ByteReader - bits uint32 - nBits uint - width uint - read func(*decoder) (uint16, error) // readLSB or readMSB - litWidth int // width in bits of literal codes - err error - - // The first 1<= 1<>= d.width - d.nBits -= d.width - return code, nil -} - -// readMSB returns the next code for "Most Significant Bits first" data. -func (d *decoder) readMSB() (uint16, error) { - for d.nBits < d.width { - x, err := d.r.ReadByte() - if err != nil { - return 0, err - } - d.bits |= uint32(x) << (24 - d.nBits) - d.nBits += 8 - } - code := uint16(d.bits >> (32 - d.width)) - d.bits <<= d.width - d.nBits -= d.width - return code, nil -} - -func (d *decoder) Read(b []byte) (int, error) { - for { - if len(d.toRead) > 0 { - n := copy(b, d.toRead) - d.toRead = d.toRead[n:] - return n, nil - } - if d.err != nil { - return 0, d.err - } - d.decode() - } -} - -// decode decompresses bytes from r and leaves them in d.toRead. -// read specifies how to decode bytes into codes. -// litWidth is the width in bits of literal codes. -func (d *decoder) decode() { - // Loop over the code stream, converting codes into decompressed bytes. -loop: - for { - code, err := d.read(d) - if err != nil { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - d.err = err - break - } - switch { - case code < d.clear: - // We have a literal code. - d.output[d.o] = uint8(code) - d.o++ - if d.last != decoderInvalidCode { - // Save what the hi code expands to. - d.suffix[d.hi] = uint8(code) - d.prefix[d.hi] = d.last - } - case code == d.clear: - d.width = 1 + uint(d.litWidth) - d.hi = d.eof - d.overflow = 1 << d.width - d.last = decoderInvalidCode - continue - case code == d.eof: - d.err = io.EOF - break loop - case code <= d.hi: - c, i := code, len(d.output)-1 - if code == d.hi { - // code == hi is a special case which expands to the last expansion - // followed by the head of the last expansion. To find the head, we walk - // the prefix chain until we find a literal code. - c = d.last - for c >= d.clear { - c = d.prefix[c] - } - d.output[i] = uint8(c) - i-- - c = d.last - } - // Copy the suffix chain into output and then write that to w. - for c >= d.clear { - d.output[i] = d.suffix[c] - i-- - c = d.prefix[c] - } - d.output[i] = uint8(c) - d.o += copy(d.output[d.o:], d.output[i:]) - if d.last != decoderInvalidCode { - // Save what the hi code expands to. - d.suffix[d.hi] = uint8(c) - d.prefix[d.hi] = d.last - } - default: - d.err = errors.New("lzw: invalid code") - break loop - } - d.last, d.hi = code, d.hi+1 - if d.hi+1 >= d.overflow { // NOTE: the "+1" is where TIFF's LZW differs from the standard algorithm. - if d.width == maxWidth { - d.last = decoderInvalidCode - } else { - d.width++ - d.overflow <<= 1 - } - } - if d.o >= flushBuffer { - break - } - } - // Flush pending output. - d.toRead = d.output[:d.o] - d.o = 0 -} - -var errClosed = errors.New("lzw: reader/writer is closed") - -func (d *decoder) Close() error { - d.err = errClosed // in case any Reads come along - return nil -} - -// NewReader creates a new io.ReadCloser. -// Reads from the returned io.ReadCloser read and decompress data from r. -// If r does not also implement io.ByteReader, -// the decompressor may read more data than necessary from r. -// It is the caller's responsibility to call Close on the ReadCloser when -// finished reading. -// The number of bits to use for literal codes, litWidth, must be in the -// range [2,8] and is typically 8. It must equal the litWidth -// used during compression. -func NewReader(r io.Reader, order Order, litWidth int) io.ReadCloser { - d := new(decoder) - switch order { - case LSB: - d.read = (*decoder).readLSB - case MSB: - d.read = (*decoder).readMSB - default: - d.err = errors.New("lzw: unknown order") - return d - } - if litWidth < 2 || 8 < litWidth { - d.err = fmt.Errorf("lzw: litWidth %d out of range", litWidth) - return d - } - if br, ok := r.(io.ByteReader); ok { - d.r = br - } else { - d.r = bufio.NewReader(r) - } - d.litWidth = litWidth - d.width = 1 + uint(litWidth) - d.clear = uint16(1) << uint(litWidth) - d.eof, d.hi = d.clear+1, d.clear+1 - d.overflow = uint16(1) << d.width - d.last = decoderInvalidCode - - return d -} diff --git a/vendor/golang.org/x/image/tiff/reader.go b/vendor/golang.org/x/image/tiff/reader.go deleted file mode 100644 index ce2ef71..0000000 --- a/vendor/golang.org/x/image/tiff/reader.go +++ /dev/null @@ -1,684 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package tiff implements a TIFF image decoder and encoder. -// -// The TIFF specification is at http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf -package tiff // import "golang.org/x/image/tiff" - -import ( - "compress/zlib" - "encoding/binary" - "fmt" - "image" - "image/color" - "io" - "io/ioutil" - "math" - - "golang.org/x/image/tiff/lzw" -) - -// A FormatError reports that the input is not a valid TIFF image. -type FormatError string - -func (e FormatError) Error() string { - return "tiff: invalid format: " + string(e) -} - -// An UnsupportedError reports that the input uses a valid but -// unimplemented feature. -type UnsupportedError string - -func (e UnsupportedError) Error() string { - return "tiff: unsupported feature: " + string(e) -} - -var errNoPixels = FormatError("not enough pixel data") - -type decoder struct { - r io.ReaderAt - byteOrder binary.ByteOrder - config image.Config - mode imageMode - bpp uint - features map[int][]uint - palette []color.Color - - buf []byte - off int // Current offset in buf. - v uint32 // Buffer value for reading with arbitrary bit depths. - nbits uint // Remaining number of bits in v. -} - -// firstVal returns the first uint of the features entry with the given tag, -// or 0 if the tag does not exist. -func (d *decoder) firstVal(tag int) uint { - f := d.features[tag] - if len(f) == 0 { - return 0 - } - return f[0] -} - -// ifdUint decodes the IFD entry in p, which must be of the Byte, Short -// or Long type, and returns the decoded uint values. -func (d *decoder) ifdUint(p []byte) (u []uint, err error) { - var raw []byte - if len(p) < ifdLen { - return nil, FormatError("bad IFD entry") - } - - datatype := d.byteOrder.Uint16(p[2:4]) - if dt := int(datatype); dt <= 0 || dt >= len(lengths) { - return nil, UnsupportedError("IFD entry datatype") - } - - count := d.byteOrder.Uint32(p[4:8]) - if count > math.MaxInt32/lengths[datatype] { - return nil, FormatError("IFD data too large") - } - if datalen := lengths[datatype] * count; datalen > 4 { - // The IFD contains a pointer to the real value. - raw = make([]byte, datalen) - _, err = d.r.ReadAt(raw, int64(d.byteOrder.Uint32(p[8:12]))) - } else { - raw = p[8 : 8+datalen] - } - if err != nil { - return nil, err - } - - u = make([]uint, count) - switch datatype { - case dtByte: - for i := uint32(0); i < count; i++ { - u[i] = uint(raw[i]) - } - case dtShort: - for i := uint32(0); i < count; i++ { - u[i] = uint(d.byteOrder.Uint16(raw[2*i : 2*(i+1)])) - } - case dtLong: - for i := uint32(0); i < count; i++ { - u[i] = uint(d.byteOrder.Uint32(raw[4*i : 4*(i+1)])) - } - default: - return nil, UnsupportedError("data type") - } - return u, nil -} - -// parseIFD decides whether the IFD entry in p is "interesting" and -// stows away the data in the decoder. It returns the tag number of the -// entry and an error, if any. -func (d *decoder) parseIFD(p []byte) (int, error) { - tag := d.byteOrder.Uint16(p[0:2]) - switch tag { - case tBitsPerSample, - tExtraSamples, - tPhotometricInterpretation, - tCompression, - tPredictor, - tStripOffsets, - tStripByteCounts, - tRowsPerStrip, - tTileWidth, - tTileLength, - tTileOffsets, - tTileByteCounts, - tImageLength, - tImageWidth: - val, err := d.ifdUint(p) - if err != nil { - return 0, err - } - d.features[int(tag)] = val - case tColorMap: - val, err := d.ifdUint(p) - if err != nil { - return 0, err - } - numcolors := len(val) / 3 - if len(val)%3 != 0 || numcolors <= 0 || numcolors > 256 { - return 0, FormatError("bad ColorMap length") - } - d.palette = make([]color.Color, numcolors) - for i := 0; i < numcolors; i++ { - d.palette[i] = color.RGBA64{ - uint16(val[i]), - uint16(val[i+numcolors]), - uint16(val[i+2*numcolors]), - 0xffff, - } - } - case tSampleFormat: - // Page 27 of the spec: If the SampleFormat is present and - // the value is not 1 [= unsigned integer data], a Baseline - // TIFF reader that cannot handle the SampleFormat value - // must terminate the import process gracefully. - val, err := d.ifdUint(p) - if err != nil { - return 0, err - } - for _, v := range val { - if v != 1 { - return 0, UnsupportedError("sample format") - } - } - } - return int(tag), nil -} - -// readBits reads n bits from the internal buffer starting at the current offset. -func (d *decoder) readBits(n uint) (v uint32, ok bool) { - for d.nbits < n { - d.v <<= 8 - if d.off >= len(d.buf) { - return 0, false - } - d.v |= uint32(d.buf[d.off]) - d.off++ - d.nbits += 8 - } - d.nbits -= n - rv := d.v >> d.nbits - d.v &^= rv << d.nbits - return rv, true -} - -// flushBits discards the unread bits in the buffer used by readBits. -// It is used at the end of a line. -func (d *decoder) flushBits() { - d.v = 0 - d.nbits = 0 -} - -// minInt returns the smaller of x or y. -func minInt(a, b int) int { - if a <= b { - return a - } - return b -} - -// decode decodes the raw data of an image. -// It reads from d.buf and writes the strip or tile into dst. -func (d *decoder) decode(dst image.Image, xmin, ymin, xmax, ymax int) error { - d.off = 0 - - // Apply horizontal predictor if necessary. - // In this case, p contains the color difference to the preceding pixel. - // See page 64-65 of the spec. - if d.firstVal(tPredictor) == prHorizontal { - switch d.bpp { - case 16: - var off int - n := 2 * len(d.features[tBitsPerSample]) // bytes per sample times samples per pixel - for y := ymin; y < ymax; y++ { - off += n - for x := 0; x < (xmax-xmin-1)*n; x += 2 { - if off+2 > len(d.buf) { - return errNoPixels - } - v0 := d.byteOrder.Uint16(d.buf[off-n : off-n+2]) - v1 := d.byteOrder.Uint16(d.buf[off : off+2]) - d.byteOrder.PutUint16(d.buf[off:off+2], v1+v0) - off += 2 - } - } - case 8: - var off int - n := 1 * len(d.features[tBitsPerSample]) // bytes per sample times samples per pixel - for y := ymin; y < ymax; y++ { - off += n - for x := 0; x < (xmax-xmin-1)*n; x++ { - if off >= len(d.buf) { - return errNoPixels - } - d.buf[off] += d.buf[off-n] - off++ - } - } - case 1: - return UnsupportedError("horizontal predictor with 1 BitsPerSample") - } - } - - rMaxX := minInt(xmax, dst.Bounds().Max.X) - rMaxY := minInt(ymax, dst.Bounds().Max.Y) - switch d.mode { - case mGray, mGrayInvert: - if d.bpp == 16 { - img := dst.(*image.Gray16) - for y := ymin; y < rMaxY; y++ { - for x := xmin; x < rMaxX; x++ { - if d.off+2 > len(d.buf) { - return errNoPixels - } - v := d.byteOrder.Uint16(d.buf[d.off : d.off+2]) - d.off += 2 - if d.mode == mGrayInvert { - v = 0xffff - v - } - img.SetGray16(x, y, color.Gray16{v}) - } - if rMaxX == img.Bounds().Max.X { - d.off += 2 * (xmax - img.Bounds().Max.X) - } - } - } else { - img := dst.(*image.Gray) - max := uint32((1 << d.bpp) - 1) - for y := ymin; y < rMaxY; y++ { - for x := xmin; x < rMaxX; x++ { - v, ok := d.readBits(d.bpp) - if !ok { - return errNoPixels - } - v = v * 0xff / max - if d.mode == mGrayInvert { - v = 0xff - v - } - img.SetGray(x, y, color.Gray{uint8(v)}) - } - d.flushBits() - } - } - case mPaletted: - img := dst.(*image.Paletted) - for y := ymin; y < rMaxY; y++ { - for x := xmin; x < rMaxX; x++ { - v, ok := d.readBits(d.bpp) - if !ok { - return errNoPixels - } - img.SetColorIndex(x, y, uint8(v)) - } - d.flushBits() - } - case mRGB: - if d.bpp == 16 { - img := dst.(*image.RGBA64) - for y := ymin; y < rMaxY; y++ { - for x := xmin; x < rMaxX; x++ { - if d.off+6 > len(d.buf) { - return errNoPixels - } - r := d.byteOrder.Uint16(d.buf[d.off+0 : d.off+2]) - g := d.byteOrder.Uint16(d.buf[d.off+2 : d.off+4]) - b := d.byteOrder.Uint16(d.buf[d.off+4 : d.off+6]) - d.off += 6 - img.SetRGBA64(x, y, color.RGBA64{r, g, b, 0xffff}) - } - } - } else { - img := dst.(*image.RGBA) - for y := ymin; y < rMaxY; y++ { - min := img.PixOffset(xmin, y) - max := img.PixOffset(rMaxX, y) - off := (y - ymin) * (xmax - xmin) * 3 - for i := min; i < max; i += 4 { - if off+3 > len(d.buf) { - return errNoPixels - } - img.Pix[i+0] = d.buf[off+0] - img.Pix[i+1] = d.buf[off+1] - img.Pix[i+2] = d.buf[off+2] - img.Pix[i+3] = 0xff - off += 3 - } - } - } - case mNRGBA: - if d.bpp == 16 { - img := dst.(*image.NRGBA64) - for y := ymin; y < rMaxY; y++ { - for x := xmin; x < rMaxX; x++ { - if d.off+8 > len(d.buf) { - return errNoPixels - } - r := d.byteOrder.Uint16(d.buf[d.off+0 : d.off+2]) - g := d.byteOrder.Uint16(d.buf[d.off+2 : d.off+4]) - b := d.byteOrder.Uint16(d.buf[d.off+4 : d.off+6]) - a := d.byteOrder.Uint16(d.buf[d.off+6 : d.off+8]) - d.off += 8 - img.SetNRGBA64(x, y, color.NRGBA64{r, g, b, a}) - } - } - } else { - img := dst.(*image.NRGBA) - for y := ymin; y < rMaxY; y++ { - min := img.PixOffset(xmin, y) - max := img.PixOffset(rMaxX, y) - i0, i1 := (y-ymin)*(xmax-xmin)*4, (y-ymin+1)*(xmax-xmin)*4 - if i1 > len(d.buf) { - return errNoPixels - } - copy(img.Pix[min:max], d.buf[i0:i1]) - } - } - case mRGBA: - if d.bpp == 16 { - img := dst.(*image.RGBA64) - for y := ymin; y < rMaxY; y++ { - for x := xmin; x < rMaxX; x++ { - if d.off+8 > len(d.buf) { - return errNoPixels - } - r := d.byteOrder.Uint16(d.buf[d.off+0 : d.off+2]) - g := d.byteOrder.Uint16(d.buf[d.off+2 : d.off+4]) - b := d.byteOrder.Uint16(d.buf[d.off+4 : d.off+6]) - a := d.byteOrder.Uint16(d.buf[d.off+6 : d.off+8]) - d.off += 8 - img.SetRGBA64(x, y, color.RGBA64{r, g, b, a}) - } - } - } else { - img := dst.(*image.RGBA) - for y := ymin; y < rMaxY; y++ { - min := img.PixOffset(xmin, y) - max := img.PixOffset(rMaxX, y) - i0, i1 := (y-ymin)*(xmax-xmin)*4, (y-ymin+1)*(xmax-xmin)*4 - if i1 > len(d.buf) { - return errNoPixels - } - copy(img.Pix[min:max], d.buf[i0:i1]) - } - } - } - - return nil -} - -func newDecoder(r io.Reader) (*decoder, error) { - d := &decoder{ - r: newReaderAt(r), - features: make(map[int][]uint), - } - - p := make([]byte, 8) - if _, err := d.r.ReadAt(p, 0); err != nil { - return nil, err - } - switch string(p[0:4]) { - case leHeader: - d.byteOrder = binary.LittleEndian - case beHeader: - d.byteOrder = binary.BigEndian - default: - return nil, FormatError("malformed header") - } - - ifdOffset := int64(d.byteOrder.Uint32(p[4:8])) - - // The first two bytes contain the number of entries (12 bytes each). - if _, err := d.r.ReadAt(p[0:2], ifdOffset); err != nil { - return nil, err - } - numItems := int(d.byteOrder.Uint16(p[0:2])) - - // All IFD entries are read in one chunk. - p = make([]byte, ifdLen*numItems) - if _, err := d.r.ReadAt(p, ifdOffset+2); err != nil { - return nil, err - } - - prevTag := -1 - for i := 0; i < len(p); i += ifdLen { - tag, err := d.parseIFD(p[i : i+ifdLen]) - if err != nil { - return nil, err - } - if tag <= prevTag { - return nil, FormatError("tags are not sorted in ascending order") - } - prevTag = tag - } - - d.config.Width = int(d.firstVal(tImageWidth)) - d.config.Height = int(d.firstVal(tImageLength)) - - if _, ok := d.features[tBitsPerSample]; !ok { - return nil, FormatError("BitsPerSample tag missing") - } - d.bpp = d.firstVal(tBitsPerSample) - switch d.bpp { - case 0: - return nil, FormatError("BitsPerSample must not be 0") - case 1, 8, 16: - // Nothing to do, these are accepted by this implementation. - default: - return nil, UnsupportedError(fmt.Sprintf("BitsPerSample of %v", d.bpp)) - } - - // Determine the image mode. - switch d.firstVal(tPhotometricInterpretation) { - case pRGB: - if d.bpp == 16 { - for _, b := range d.features[tBitsPerSample] { - if b != 16 { - return nil, FormatError("wrong number of samples for 16bit RGB") - } - } - } else { - for _, b := range d.features[tBitsPerSample] { - if b != 8 { - return nil, FormatError("wrong number of samples for 8bit RGB") - } - } - } - // RGB images normally have 3 samples per pixel. - // If there are more, ExtraSamples (p. 31-32 of the spec) - // gives their meaning (usually an alpha channel). - // - // This implementation does not support extra samples - // of an unspecified type. - switch len(d.features[tBitsPerSample]) { - case 3: - d.mode = mRGB - if d.bpp == 16 { - d.config.ColorModel = color.RGBA64Model - } else { - d.config.ColorModel = color.RGBAModel - } - case 4: - switch d.firstVal(tExtraSamples) { - case 1: - d.mode = mRGBA - if d.bpp == 16 { - d.config.ColorModel = color.RGBA64Model - } else { - d.config.ColorModel = color.RGBAModel - } - case 2: - d.mode = mNRGBA - if d.bpp == 16 { - d.config.ColorModel = color.NRGBA64Model - } else { - d.config.ColorModel = color.NRGBAModel - } - default: - return nil, FormatError("wrong number of samples for RGB") - } - default: - return nil, FormatError("wrong number of samples for RGB") - } - case pPaletted: - d.mode = mPaletted - d.config.ColorModel = color.Palette(d.palette) - case pWhiteIsZero: - d.mode = mGrayInvert - if d.bpp == 16 { - d.config.ColorModel = color.Gray16Model - } else { - d.config.ColorModel = color.GrayModel - } - case pBlackIsZero: - d.mode = mGray - if d.bpp == 16 { - d.config.ColorModel = color.Gray16Model - } else { - d.config.ColorModel = color.GrayModel - } - default: - return nil, UnsupportedError("color model") - } - - return d, nil -} - -// DecodeConfig returns the color model and dimensions of a TIFF image without -// decoding the entire image. -func DecodeConfig(r io.Reader) (image.Config, error) { - d, err := newDecoder(r) - if err != nil { - return image.Config{}, err - } - return d.config, nil -} - -// Decode reads a TIFF image from r and returns it as an image.Image. -// The type of Image returned depends on the contents of the TIFF. -func Decode(r io.Reader) (img image.Image, err error) { - d, err := newDecoder(r) - if err != nil { - return - } - - blockPadding := false - blockWidth := d.config.Width - blockHeight := d.config.Height - blocksAcross := 1 - blocksDown := 1 - - if d.config.Width == 0 { - blocksAcross = 0 - } - if d.config.Height == 0 { - blocksDown = 0 - } - - var blockOffsets, blockCounts []uint - - if int(d.firstVal(tTileWidth)) != 0 { - blockPadding = true - - blockWidth = int(d.firstVal(tTileWidth)) - blockHeight = int(d.firstVal(tTileLength)) - - if blockWidth != 0 { - blocksAcross = (d.config.Width + blockWidth - 1) / blockWidth - } - if blockHeight != 0 { - blocksDown = (d.config.Height + blockHeight - 1) / blockHeight - } - - blockCounts = d.features[tTileByteCounts] - blockOffsets = d.features[tTileOffsets] - - } else { - if int(d.firstVal(tRowsPerStrip)) != 0 { - blockHeight = int(d.firstVal(tRowsPerStrip)) - } - - if blockHeight != 0 { - blocksDown = (d.config.Height + blockHeight - 1) / blockHeight - } - - blockOffsets = d.features[tStripOffsets] - blockCounts = d.features[tStripByteCounts] - } - - // Check if we have the right number of strips/tiles, offsets and counts. - if n := blocksAcross * blocksDown; len(blockOffsets) < n || len(blockCounts) < n { - return nil, FormatError("inconsistent header") - } - - imgRect := image.Rect(0, 0, d.config.Width, d.config.Height) - switch d.mode { - case mGray, mGrayInvert: - if d.bpp == 16 { - img = image.NewGray16(imgRect) - } else { - img = image.NewGray(imgRect) - } - case mPaletted: - img = image.NewPaletted(imgRect, d.palette) - case mNRGBA: - if d.bpp == 16 { - img = image.NewNRGBA64(imgRect) - } else { - img = image.NewNRGBA(imgRect) - } - case mRGB, mRGBA: - if d.bpp == 16 { - img = image.NewRGBA64(imgRect) - } else { - img = image.NewRGBA(imgRect) - } - } - - for i := 0; i < blocksAcross; i++ { - blkW := blockWidth - if !blockPadding && i == blocksAcross-1 && d.config.Width%blockWidth != 0 { - blkW = d.config.Width % blockWidth - } - for j := 0; j < blocksDown; j++ { - blkH := blockHeight - if !blockPadding && j == blocksDown-1 && d.config.Height%blockHeight != 0 { - blkH = d.config.Height % blockHeight - } - offset := int64(blockOffsets[j*blocksAcross+i]) - n := int64(blockCounts[j*blocksAcross+i]) - switch d.firstVal(tCompression) { - - // According to the spec, Compression does not have a default value, - // but some tools interpret a missing Compression value as none so we do - // the same. - case cNone, 0: - if b, ok := d.r.(*buffer); ok { - d.buf, err = b.Slice(int(offset), int(n)) - } else { - d.buf = make([]byte, n) - _, err = d.r.ReadAt(d.buf, offset) - } - case cLZW: - r := lzw.NewReader(io.NewSectionReader(d.r, offset, n), lzw.MSB, 8) - d.buf, err = ioutil.ReadAll(r) - r.Close() - case cDeflate, cDeflateOld: - var r io.ReadCloser - r, err = zlib.NewReader(io.NewSectionReader(d.r, offset, n)) - if err != nil { - return nil, err - } - d.buf, err = ioutil.ReadAll(r) - r.Close() - case cPackBits: - d.buf, err = unpackBits(io.NewSectionReader(d.r, offset, n)) - default: - err = UnsupportedError(fmt.Sprintf("compression value %d", d.firstVal(tCompression))) - } - if err != nil { - return nil, err - } - - xmin := i * blockWidth - ymin := j * blockHeight - xmax := xmin + blkW - ymax := ymin + blkH - err = d.decode(img, xmin, ymin, xmax, ymax) - if err != nil { - return nil, err - } - } - } - return -} - -func init() { - image.RegisterFormat("tiff", leHeader, Decode, DecodeConfig) - image.RegisterFormat("tiff", beHeader, Decode, DecodeConfig) -} diff --git a/vendor/golang.org/x/image/tiff/writer.go b/vendor/golang.org/x/image/tiff/writer.go deleted file mode 100644 index c8a01ce..0000000 --- a/vendor/golang.org/x/image/tiff/writer.go +++ /dev/null @@ -1,438 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package tiff - -import ( - "bytes" - "compress/zlib" - "encoding/binary" - "image" - "io" - "sort" -) - -// The TIFF format allows to choose the order of the different elements freely. -// The basic structure of a TIFF file written by this package is: -// -// 1. Header (8 bytes). -// 2. Image data. -// 3. Image File Directory (IFD). -// 4. "Pointer area" for larger entries in the IFD. - -// We only write little-endian TIFF files. -var enc = binary.LittleEndian - -// An ifdEntry is a single entry in an Image File Directory. -// A value of type dtRational is composed of two 32-bit values, -// thus data contains two uints (numerator and denominator) for a single number. -type ifdEntry struct { - tag int - datatype int - data []uint32 -} - -func (e ifdEntry) putData(p []byte) { - for _, d := range e.data { - switch e.datatype { - case dtByte, dtASCII: - p[0] = byte(d) - p = p[1:] - case dtShort: - enc.PutUint16(p, uint16(d)) - p = p[2:] - case dtLong, dtRational: - enc.PutUint32(p, uint32(d)) - p = p[4:] - } - } -} - -type byTag []ifdEntry - -func (d byTag) Len() int { return len(d) } -func (d byTag) Less(i, j int) bool { return d[i].tag < d[j].tag } -func (d byTag) Swap(i, j int) { d[i], d[j] = d[j], d[i] } - -func encodeGray(w io.Writer, pix []uint8, dx, dy, stride int, predictor bool) error { - if !predictor { - return writePix(w, pix, dy, dx, stride) - } - buf := make([]byte, dx) - for y := 0; y < dy; y++ { - min := y*stride + 0 - max := y*stride + dx - off := 0 - var v0 uint8 - for i := min; i < max; i++ { - v1 := pix[i] - buf[off] = v1 - v0 - v0 = v1 - off++ - } - if _, err := w.Write(buf); err != nil { - return err - } - } - return nil -} - -func encodeGray16(w io.Writer, pix []uint8, dx, dy, stride int, predictor bool) error { - buf := make([]byte, dx*2) - for y := 0; y < dy; y++ { - min := y*stride + 0 - max := y*stride + dx*2 - off := 0 - var v0 uint16 - for i := min; i < max; i += 2 { - // An image.Gray16's Pix is in big-endian order. - v1 := uint16(pix[i])<<8 | uint16(pix[i+1]) - if predictor { - v0, v1 = v1, v1-v0 - } - // We only write little-endian TIFF files. - buf[off+0] = byte(v1) - buf[off+1] = byte(v1 >> 8) - off += 2 - } - if _, err := w.Write(buf); err != nil { - return err - } - } - return nil -} - -func encodeRGBA(w io.Writer, pix []uint8, dx, dy, stride int, predictor bool) error { - if !predictor { - return writePix(w, pix, dy, dx*4, stride) - } - buf := make([]byte, dx*4) - for y := 0; y < dy; y++ { - min := y*stride + 0 - max := y*stride + dx*4 - off := 0 - var r0, g0, b0, a0 uint8 - for i := min; i < max; i += 4 { - r1, g1, b1, a1 := pix[i+0], pix[i+1], pix[i+2], pix[i+3] - buf[off+0] = r1 - r0 - buf[off+1] = g1 - g0 - buf[off+2] = b1 - b0 - buf[off+3] = a1 - a0 - off += 4 - r0, g0, b0, a0 = r1, g1, b1, a1 - } - if _, err := w.Write(buf); err != nil { - return err - } - } - return nil -} - -func encodeRGBA64(w io.Writer, pix []uint8, dx, dy, stride int, predictor bool) error { - buf := make([]byte, dx*8) - for y := 0; y < dy; y++ { - min := y*stride + 0 - max := y*stride + dx*8 - off := 0 - var r0, g0, b0, a0 uint16 - for i := min; i < max; i += 8 { - // An image.RGBA64's Pix is in big-endian order. - r1 := uint16(pix[i+0])<<8 | uint16(pix[i+1]) - g1 := uint16(pix[i+2])<<8 | uint16(pix[i+3]) - b1 := uint16(pix[i+4])<<8 | uint16(pix[i+5]) - a1 := uint16(pix[i+6])<<8 | uint16(pix[i+7]) - if predictor { - r0, r1 = r1, r1-r0 - g0, g1 = g1, g1-g0 - b0, b1 = b1, b1-b0 - a0, a1 = a1, a1-a0 - } - // We only write little-endian TIFF files. - buf[off+0] = byte(r1) - buf[off+1] = byte(r1 >> 8) - buf[off+2] = byte(g1) - buf[off+3] = byte(g1 >> 8) - buf[off+4] = byte(b1) - buf[off+5] = byte(b1 >> 8) - buf[off+6] = byte(a1) - buf[off+7] = byte(a1 >> 8) - off += 8 - } - if _, err := w.Write(buf); err != nil { - return err - } - } - return nil -} - -func encode(w io.Writer, m image.Image, predictor bool) error { - bounds := m.Bounds() - buf := make([]byte, 4*bounds.Dx()) - for y := bounds.Min.Y; y < bounds.Max.Y; y++ { - off := 0 - if predictor { - var r0, g0, b0, a0 uint8 - for x := bounds.Min.X; x < bounds.Max.X; x++ { - r, g, b, a := m.At(x, y).RGBA() - r1 := uint8(r >> 8) - g1 := uint8(g >> 8) - b1 := uint8(b >> 8) - a1 := uint8(a >> 8) - buf[off+0] = r1 - r0 - buf[off+1] = g1 - g0 - buf[off+2] = b1 - b0 - buf[off+3] = a1 - a0 - off += 4 - r0, g0, b0, a0 = r1, g1, b1, a1 - } - } else { - for x := bounds.Min.X; x < bounds.Max.X; x++ { - r, g, b, a := m.At(x, y).RGBA() - buf[off+0] = uint8(r >> 8) - buf[off+1] = uint8(g >> 8) - buf[off+2] = uint8(b >> 8) - buf[off+3] = uint8(a >> 8) - off += 4 - } - } - if _, err := w.Write(buf); err != nil { - return err - } - } - return nil -} - -// writePix writes the internal byte array of an image to w. It is less general -// but much faster then encode. writePix is used when pix directly -// corresponds to one of the TIFF image types. -func writePix(w io.Writer, pix []byte, nrows, length, stride int) error { - if length == stride { - _, err := w.Write(pix[:nrows*length]) - return err - } - for ; nrows > 0; nrows-- { - if _, err := w.Write(pix[:length]); err != nil { - return err - } - pix = pix[stride:] - } - return nil -} - -func writeIFD(w io.Writer, ifdOffset int, d []ifdEntry) error { - var buf [ifdLen]byte - // Make space for "pointer area" containing IFD entry data - // longer than 4 bytes. - parea := make([]byte, 1024) - pstart := ifdOffset + ifdLen*len(d) + 6 - var o int // Current offset in parea. - - // The IFD has to be written with the tags in ascending order. - sort.Sort(byTag(d)) - - // Write the number of entries in this IFD. - if err := binary.Write(w, enc, uint16(len(d))); err != nil { - return err - } - for _, ent := range d { - enc.PutUint16(buf[0:2], uint16(ent.tag)) - enc.PutUint16(buf[2:4], uint16(ent.datatype)) - count := uint32(len(ent.data)) - if ent.datatype == dtRational { - count /= 2 - } - enc.PutUint32(buf[4:8], count) - datalen := int(count * lengths[ent.datatype]) - if datalen <= 4 { - ent.putData(buf[8:12]) - } else { - if (o + datalen) > len(parea) { - newlen := len(parea) + 1024 - for (o + datalen) > newlen { - newlen += 1024 - } - newarea := make([]byte, newlen) - copy(newarea, parea) - parea = newarea - } - ent.putData(parea[o : o+datalen]) - enc.PutUint32(buf[8:12], uint32(pstart+o)) - o += datalen - } - if _, err := w.Write(buf[:]); err != nil { - return err - } - } - // The IFD ends with the offset of the next IFD in the file, - // or zero if it is the last one (page 14). - if err := binary.Write(w, enc, uint32(0)); err != nil { - return err - } - _, err := w.Write(parea[:o]) - return err -} - -// Options are the encoding parameters. -type Options struct { - // Compression is the type of compression used. - Compression CompressionType - // Predictor determines whether a differencing predictor is used; - // if true, instead of each pixel's color, the color difference to the - // preceding one is saved. This improves the compression for certain - // types of images and compressors. For example, it works well for - // photos with Deflate compression. - Predictor bool -} - -// Encode writes the image m to w. opt determines the options used for -// encoding, such as the compression type. If opt is nil, an uncompressed -// image is written. -func Encode(w io.Writer, m image.Image, opt *Options) error { - d := m.Bounds().Size() - - compression := uint32(cNone) - predictor := false - if opt != nil { - compression = opt.Compression.specValue() - // The predictor field is only used with LZW. See page 64 of the spec. - predictor = opt.Predictor && compression == cLZW - } - - _, err := io.WriteString(w, leHeader) - if err != nil { - return err - } - - // Compressed data is written into a buffer first, so that we - // know the compressed size. - var buf bytes.Buffer - // dst holds the destination for the pixel data of the image -- - // either w or a writer to buf. - var dst io.Writer - // imageLen is the length of the pixel data in bytes. - // The offset of the IFD is imageLen + 8 header bytes. - var imageLen int - - switch compression { - case cNone: - dst = w - // Write IFD offset before outputting pixel data. - switch m.(type) { - case *image.Paletted: - imageLen = d.X * d.Y * 1 - case *image.Gray: - imageLen = d.X * d.Y * 1 - case *image.Gray16: - imageLen = d.X * d.Y * 2 - case *image.RGBA64: - imageLen = d.X * d.Y * 8 - case *image.NRGBA64: - imageLen = d.X * d.Y * 8 - default: - imageLen = d.X * d.Y * 4 - } - err = binary.Write(w, enc, uint32(imageLen+8)) - if err != nil { - return err - } - case cDeflate: - dst = zlib.NewWriter(&buf) - } - - pr := uint32(prNone) - photometricInterpretation := uint32(pRGB) - samplesPerPixel := uint32(4) - bitsPerSample := []uint32{8, 8, 8, 8} - extraSamples := uint32(0) - colorMap := []uint32{} - - if predictor { - pr = prHorizontal - } - switch m := m.(type) { - case *image.Paletted: - photometricInterpretation = pPaletted - samplesPerPixel = 1 - bitsPerSample = []uint32{8} - colorMap = make([]uint32, 256*3) - for i := 0; i < 256 && i < len(m.Palette); i++ { - r, g, b, _ := m.Palette[i].RGBA() - colorMap[i+0*256] = uint32(r) - colorMap[i+1*256] = uint32(g) - colorMap[i+2*256] = uint32(b) - } - err = encodeGray(dst, m.Pix, d.X, d.Y, m.Stride, predictor) - case *image.Gray: - photometricInterpretation = pBlackIsZero - samplesPerPixel = 1 - bitsPerSample = []uint32{8} - err = encodeGray(dst, m.Pix, d.X, d.Y, m.Stride, predictor) - case *image.Gray16: - photometricInterpretation = pBlackIsZero - samplesPerPixel = 1 - bitsPerSample = []uint32{16} - err = encodeGray16(dst, m.Pix, d.X, d.Y, m.Stride, predictor) - case *image.NRGBA: - extraSamples = 2 // Unassociated alpha. - err = encodeRGBA(dst, m.Pix, d.X, d.Y, m.Stride, predictor) - case *image.NRGBA64: - extraSamples = 2 // Unassociated alpha. - bitsPerSample = []uint32{16, 16, 16, 16} - err = encodeRGBA64(dst, m.Pix, d.X, d.Y, m.Stride, predictor) - case *image.RGBA: - extraSamples = 1 // Associated alpha. - err = encodeRGBA(dst, m.Pix, d.X, d.Y, m.Stride, predictor) - case *image.RGBA64: - extraSamples = 1 // Associated alpha. - bitsPerSample = []uint32{16, 16, 16, 16} - err = encodeRGBA64(dst, m.Pix, d.X, d.Y, m.Stride, predictor) - default: - extraSamples = 1 // Associated alpha. - err = encode(dst, m, predictor) - } - if err != nil { - return err - } - - if compression != cNone { - if err = dst.(io.Closer).Close(); err != nil { - return err - } - imageLen = buf.Len() - if err = binary.Write(w, enc, uint32(imageLen+8)); err != nil { - return err - } - if _, err = buf.WriteTo(w); err != nil { - return err - } - } - - ifd := []ifdEntry{ - {tImageWidth, dtShort, []uint32{uint32(d.X)}}, - {tImageLength, dtShort, []uint32{uint32(d.Y)}}, - {tBitsPerSample, dtShort, bitsPerSample}, - {tCompression, dtShort, []uint32{compression}}, - {tPhotometricInterpretation, dtShort, []uint32{photometricInterpretation}}, - {tStripOffsets, dtLong, []uint32{8}}, - {tSamplesPerPixel, dtShort, []uint32{samplesPerPixel}}, - {tRowsPerStrip, dtShort, []uint32{uint32(d.Y)}}, - {tStripByteCounts, dtLong, []uint32{uint32(imageLen)}}, - // There is currently no support for storing the image - // resolution, so give a bogus value of 72x72 dpi. - {tXResolution, dtRational, []uint32{72, 1}}, - {tYResolution, dtRational, []uint32{72, 1}}, - {tResolutionUnit, dtShort, []uint32{resPerInch}}, - } - if pr != prNone { - ifd = append(ifd, ifdEntry{tPredictor, dtShort, []uint32{pr}}) - } - if len(colorMap) != 0 { - ifd = append(ifd, ifdEntry{tColorMap, dtShort, colorMap}) - } - if extraSamples > 0 { - ifd = append(ifd, ifdEntry{tExtraSamples, dtShort, []uint32{extraSamples}}) - } - - return writeIFD(w, imageLen+8, ifd) -} diff --git a/vendor/golang.org/x/image/vp8/decode.go b/vendor/golang.org/x/image/vp8/decode.go deleted file mode 100644 index 2aa9fee..0000000 --- a/vendor/golang.org/x/image/vp8/decode.go +++ /dev/null @@ -1,403 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package vp8 implements a decoder for the VP8 lossy image format. -// -// The VP8 specification is RFC 6386. -package vp8 // import "golang.org/x/image/vp8" - -// This file implements the top-level decoding algorithm. - -import ( - "errors" - "image" - "io" -) - -// limitReader wraps an io.Reader to read at most n bytes from it. -type limitReader struct { - r io.Reader - n int -} - -// ReadFull reads exactly len(p) bytes into p. -func (r *limitReader) ReadFull(p []byte) error { - if len(p) > r.n { - return io.ErrUnexpectedEOF - } - n, err := io.ReadFull(r.r, p) - r.n -= n - return err -} - -// FrameHeader is a frame header, as specified in section 9.1. -type FrameHeader struct { - KeyFrame bool - VersionNumber uint8 - ShowFrame bool - FirstPartitionLen uint32 - Width int - Height int - XScale uint8 - YScale uint8 -} - -const ( - nSegment = 4 - nSegmentProb = 3 -) - -// segmentHeader holds segment-related header information. -type segmentHeader struct { - useSegment bool - updateMap bool - relativeDelta bool - quantizer [nSegment]int8 - filterStrength [nSegment]int8 - prob [nSegmentProb]uint8 -} - -const ( - nRefLFDelta = 4 - nModeLFDelta = 4 -) - -// filterHeader holds filter-related header information. -type filterHeader struct { - simple bool - level int8 - sharpness uint8 - useLFDelta bool - refLFDelta [nRefLFDelta]int8 - modeLFDelta [nModeLFDelta]int8 - perSegmentLevel [nSegment]int8 -} - -// mb is the per-macroblock decode state. A decoder maintains mbw+1 of these -// as it is decoding macroblocks left-to-right and top-to-bottom: mbw for the -// macroblocks in the row above, and one for the macroblock to the left. -type mb struct { - // pred is the predictor mode for the 4 bottom or right 4x4 luma regions. - pred [4]uint8 - // nzMask is a mask of 8 bits: 4 for the bottom or right 4x4 luma regions, - // and 2 + 2 for the bottom or right 4x4 chroma regions. A 1 bit indicates - // that region has non-zero coefficients. - nzMask uint8 - // nzY16 is a 0/1 value that is 1 if the macroblock used Y16 prediction and - // had non-zero coefficients. - nzY16 uint8 -} - -// Decoder decodes VP8 bitstreams into frames. Decoding one frame consists of -// calling Init, DecodeFrameHeader and then DecodeFrame in that order. -// A Decoder can be re-used to decode multiple frames. -type Decoder struct { - // r is the input bitsream. - r limitReader - // scratch is a scratch buffer. - scratch [8]byte - // img is the YCbCr image to decode into. - img *image.YCbCr - // mbw and mbh are the number of 16x16 macroblocks wide and high the image is. - mbw, mbh int - // frameHeader is the frame header. When decoding multiple frames, - // frames that aren't key frames will inherit the Width, Height, - // XScale and YScale of the most recent key frame. - frameHeader FrameHeader - // Other headers. - segmentHeader segmentHeader - filterHeader filterHeader - // The image data is divided into a number of independent partitions. - // There is 1 "first partition" and between 1 and 8 "other partitions" - // for coefficient data. - fp partition - op [8]partition - nOP int - // Quantization factors. - quant [nSegment]quant - // DCT/WHT coefficient decoding probabilities. - tokenProb [nPlane][nBand][nContext][nProb]uint8 - useSkipProb bool - skipProb uint8 - // Loop filter parameters. - filterParams [nSegment][2]filterParam - perMBFilterParams []filterParam - - // The eight fields below relate to the current macroblock being decoded. - // - // Segment-based adjustments. - segment int - // Per-macroblock state for the macroblock immediately left of and those - // macroblocks immediately above the current macroblock. - leftMB mb - upMB []mb - // Bitmasks for which 4x4 regions of coeff contain non-zero coefficients. - nzDCMask, nzACMask uint32 - // Predictor modes. - usePredY16 bool // The libwebp C code calls this !is_i4x4_. - predY16 uint8 - predC8 uint8 - predY4 [4][4]uint8 - - // The two fields below form a workspace for reconstructing a macroblock. - // Their specific sizes are documented in reconstruct.go. - coeff [1*16*16 + 2*8*8 + 1*4*4]int16 - ybr [1 + 16 + 1 + 8][32]uint8 -} - -// NewDecoder returns a new Decoder. -func NewDecoder() *Decoder { - return &Decoder{} -} - -// Init initializes the decoder to read at most n bytes from r. -func (d *Decoder) Init(r io.Reader, n int) { - d.r = limitReader{r, n} -} - -// DecodeFrameHeader decodes the frame header. -func (d *Decoder) DecodeFrameHeader() (fh FrameHeader, err error) { - // All frame headers are at least 3 bytes long. - b := d.scratch[:3] - if err = d.r.ReadFull(b); err != nil { - return - } - d.frameHeader.KeyFrame = (b[0] & 1) == 0 - d.frameHeader.VersionNumber = (b[0] >> 1) & 7 - d.frameHeader.ShowFrame = (b[0]>>4)&1 == 1 - d.frameHeader.FirstPartitionLen = uint32(b[0])>>5 | uint32(b[1])<<3 | uint32(b[2])<<11 - if !d.frameHeader.KeyFrame { - return d.frameHeader, nil - } - // Frame headers for key frames are an additional 7 bytes long. - b = d.scratch[:7] - if err = d.r.ReadFull(b); err != nil { - return - } - // Check the magic sync code. - if b[0] != 0x9d || b[1] != 0x01 || b[2] != 0x2a { - err = errors.New("vp8: invalid format") - return - } - d.frameHeader.Width = int(b[4]&0x3f)<<8 | int(b[3]) - d.frameHeader.Height = int(b[6]&0x3f)<<8 | int(b[5]) - d.frameHeader.XScale = b[4] >> 6 - d.frameHeader.YScale = b[6] >> 6 - d.mbw = (d.frameHeader.Width + 0x0f) >> 4 - d.mbh = (d.frameHeader.Height + 0x0f) >> 4 - d.segmentHeader = segmentHeader{ - prob: [3]uint8{0xff, 0xff, 0xff}, - } - d.tokenProb = defaultTokenProb - d.segment = 0 - return d.frameHeader, nil -} - -// ensureImg ensures that d.img is large enough to hold the decoded frame. -func (d *Decoder) ensureImg() { - if d.img != nil { - p0, p1 := d.img.Rect.Min, d.img.Rect.Max - if p0.X == 0 && p0.Y == 0 && p1.X >= 16*d.mbw && p1.Y >= 16*d.mbh { - return - } - } - m := image.NewYCbCr(image.Rect(0, 0, 16*d.mbw, 16*d.mbh), image.YCbCrSubsampleRatio420) - d.img = m.SubImage(image.Rect(0, 0, d.frameHeader.Width, d.frameHeader.Height)).(*image.YCbCr) - d.perMBFilterParams = make([]filterParam, d.mbw*d.mbh) - d.upMB = make([]mb, d.mbw) -} - -// parseSegmentHeader parses the segment header, as specified in section 9.3. -func (d *Decoder) parseSegmentHeader() { - d.segmentHeader.useSegment = d.fp.readBit(uniformProb) - if !d.segmentHeader.useSegment { - d.segmentHeader.updateMap = false - return - } - d.segmentHeader.updateMap = d.fp.readBit(uniformProb) - if d.fp.readBit(uniformProb) { - d.segmentHeader.relativeDelta = !d.fp.readBit(uniformProb) - for i := range d.segmentHeader.quantizer { - d.segmentHeader.quantizer[i] = int8(d.fp.readOptionalInt(uniformProb, 7)) - } - for i := range d.segmentHeader.filterStrength { - d.segmentHeader.filterStrength[i] = int8(d.fp.readOptionalInt(uniformProb, 6)) - } - } - if !d.segmentHeader.updateMap { - return - } - for i := range d.segmentHeader.prob { - if d.fp.readBit(uniformProb) { - d.segmentHeader.prob[i] = uint8(d.fp.readUint(uniformProb, 8)) - } else { - d.segmentHeader.prob[i] = 0xff - } - } -} - -// parseFilterHeader parses the filter header, as specified in section 9.4. -func (d *Decoder) parseFilterHeader() { - d.filterHeader.simple = d.fp.readBit(uniformProb) - d.filterHeader.level = int8(d.fp.readUint(uniformProb, 6)) - d.filterHeader.sharpness = uint8(d.fp.readUint(uniformProb, 3)) - d.filterHeader.useLFDelta = d.fp.readBit(uniformProb) - if d.filterHeader.useLFDelta && d.fp.readBit(uniformProb) { - for i := range d.filterHeader.refLFDelta { - d.filterHeader.refLFDelta[i] = int8(d.fp.readOptionalInt(uniformProb, 6)) - } - for i := range d.filterHeader.modeLFDelta { - d.filterHeader.modeLFDelta[i] = int8(d.fp.readOptionalInt(uniformProb, 6)) - } - } - if d.filterHeader.level == 0 { - return - } - if d.segmentHeader.useSegment { - for i := range d.filterHeader.perSegmentLevel { - strength := d.segmentHeader.filterStrength[i] - if d.segmentHeader.relativeDelta { - strength += d.filterHeader.level - } - d.filterHeader.perSegmentLevel[i] = strength - } - } else { - d.filterHeader.perSegmentLevel[0] = d.filterHeader.level - } - d.computeFilterParams() -} - -// parseOtherPartitions parses the other partitions, as specified in section 9.5. -func (d *Decoder) parseOtherPartitions() error { - const maxNOP = 1 << 3 - var partLens [maxNOP]int - d.nOP = 1 << d.fp.readUint(uniformProb, 2) - - // The final partition length is implied by the remaining chunk data - // (d.r.n) and the other d.nOP-1 partition lengths. Those d.nOP-1 partition - // lengths are stored as 24-bit uints, i.e. up to 16 MiB per partition. - n := 3 * (d.nOP - 1) - partLens[d.nOP-1] = d.r.n - n - if partLens[d.nOP-1] < 0 { - return io.ErrUnexpectedEOF - } - if n > 0 { - buf := make([]byte, n) - if err := d.r.ReadFull(buf); err != nil { - return err - } - for i := 0; i < d.nOP-1; i++ { - pl := int(buf[3*i+0]) | int(buf[3*i+1])<<8 | int(buf[3*i+2])<<16 - if pl > partLens[d.nOP-1] { - return io.ErrUnexpectedEOF - } - partLens[i] = pl - partLens[d.nOP-1] -= pl - } - } - - // We check if the final partition length can also fit into a 24-bit uint. - // Strictly speaking, this isn't part of the spec, but it guards against a - // malicious WEBP image that is too large to ReadFull the encoded DCT - // coefficients into memory, whether that's because the actual WEBP file is - // too large, or whether its RIFF metadata lists too large a chunk. - if 1<<24 <= partLens[d.nOP-1] { - return errors.New("vp8: too much data to decode") - } - - buf := make([]byte, d.r.n) - if err := d.r.ReadFull(buf); err != nil { - return err - } - for i, pl := range partLens { - if i == d.nOP { - break - } - d.op[i].init(buf[:pl]) - buf = buf[pl:] - } - return nil -} - -// parseOtherHeaders parses header information other than the frame header. -func (d *Decoder) parseOtherHeaders() error { - // Initialize and parse the first partition. - firstPartition := make([]byte, d.frameHeader.FirstPartitionLen) - if err := d.r.ReadFull(firstPartition); err != nil { - return err - } - d.fp.init(firstPartition) - if d.frameHeader.KeyFrame { - // Read and ignore the color space and pixel clamp values. They are - // specified in section 9.2, but are unimplemented. - d.fp.readBit(uniformProb) - d.fp.readBit(uniformProb) - } - d.parseSegmentHeader() - d.parseFilterHeader() - if err := d.parseOtherPartitions(); err != nil { - return err - } - d.parseQuant() - if !d.frameHeader.KeyFrame { - // Golden and AltRef frames are specified in section 9.7. - // TODO(nigeltao): implement. Note that they are only used for video, not still images. - return errors.New("vp8: Golden / AltRef frames are not implemented") - } - // Read and ignore the refreshLastFrameBuffer bit, specified in section 9.8. - // It applies only to video, and not still images. - d.fp.readBit(uniformProb) - d.parseTokenProb() - d.useSkipProb = d.fp.readBit(uniformProb) - if d.useSkipProb { - d.skipProb = uint8(d.fp.readUint(uniformProb, 8)) - } - if d.fp.unexpectedEOF { - return io.ErrUnexpectedEOF - } - return nil -} - -// DecodeFrame decodes the frame and returns it as an YCbCr image. -// The image's contents are valid up until the next call to Decoder.Init. -func (d *Decoder) DecodeFrame() (*image.YCbCr, error) { - d.ensureImg() - if err := d.parseOtherHeaders(); err != nil { - return nil, err - } - // Reconstruct the rows. - for mbx := 0; mbx < d.mbw; mbx++ { - d.upMB[mbx] = mb{} - } - for mby := 0; mby < d.mbh; mby++ { - d.leftMB = mb{} - for mbx := 0; mbx < d.mbw; mbx++ { - skip := d.reconstruct(mbx, mby) - fs := d.filterParams[d.segment][btou(!d.usePredY16)] - fs.inner = fs.inner || !skip - d.perMBFilterParams[d.mbw*mby+mbx] = fs - } - } - if d.fp.unexpectedEOF { - return nil, io.ErrUnexpectedEOF - } - for i := 0; i < d.nOP; i++ { - if d.op[i].unexpectedEOF { - return nil, io.ErrUnexpectedEOF - } - } - // Apply the loop filter. - // - // Even if we are using per-segment levels, section 15 says that "loop - // filtering must be skipped entirely if loop_filter_level at either the - // frame header level or macroblock override level is 0". - if d.filterHeader.level != 0 { - if d.filterHeader.simple { - d.simpleFilter() - } else { - d.normalFilter() - } - } - return d.img, nil -} diff --git a/vendor/golang.org/x/image/vp8/filter.go b/vendor/golang.org/x/image/vp8/filter.go deleted file mode 100644 index e34a811..0000000 --- a/vendor/golang.org/x/image/vp8/filter.go +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8 - -// filter2 modifies a 2-pixel wide or 2-pixel high band along an edge. -func filter2(pix []byte, level, index, iStep, jStep int) { - for n := 16; n > 0; n, index = n-1, index+iStep { - p1 := int(pix[index-2*jStep]) - p0 := int(pix[index-1*jStep]) - q0 := int(pix[index+0*jStep]) - q1 := int(pix[index+1*jStep]) - if abs(p0-q0)<<1+abs(p1-q1)>>1 > level { - continue - } - a := 3*(q0-p0) + clamp127(p1-q1) - a1 := clamp15((a + 4) >> 3) - a2 := clamp15((a + 3) >> 3) - pix[index-1*jStep] = clamp255(p0 + a2) - pix[index+0*jStep] = clamp255(q0 - a1) - } -} - -// filter246 modifies a 2-, 4- or 6-pixel wide or high band along an edge. -func filter246(pix []byte, n, level, ilevel, hlevel, index, iStep, jStep int, fourNotSix bool) { - for ; n > 0; n, index = n-1, index+iStep { - p3 := int(pix[index-4*jStep]) - p2 := int(pix[index-3*jStep]) - p1 := int(pix[index-2*jStep]) - p0 := int(pix[index-1*jStep]) - q0 := int(pix[index+0*jStep]) - q1 := int(pix[index+1*jStep]) - q2 := int(pix[index+2*jStep]) - q3 := int(pix[index+3*jStep]) - if abs(p0-q0)<<1+abs(p1-q1)>>1 > level { - continue - } - if abs(p3-p2) > ilevel || - abs(p2-p1) > ilevel || - abs(p1-p0) > ilevel || - abs(q1-q0) > ilevel || - abs(q2-q1) > ilevel || - abs(q3-q2) > ilevel { - continue - } - if abs(p1-p0) > hlevel || abs(q1-q0) > hlevel { - // Filter 2 pixels. - a := 3*(q0-p0) + clamp127(p1-q1) - a1 := clamp15((a + 4) >> 3) - a2 := clamp15((a + 3) >> 3) - pix[index-1*jStep] = clamp255(p0 + a2) - pix[index+0*jStep] = clamp255(q0 - a1) - } else if fourNotSix { - // Filter 4 pixels. - a := 3 * (q0 - p0) - a1 := clamp15((a + 4) >> 3) - a2 := clamp15((a + 3) >> 3) - a3 := (a1 + 1) >> 1 - pix[index-2*jStep] = clamp255(p1 + a3) - pix[index-1*jStep] = clamp255(p0 + a2) - pix[index+0*jStep] = clamp255(q0 - a1) - pix[index+1*jStep] = clamp255(q1 - a3) - } else { - // Filter 6 pixels. - a := clamp127(3*(q0-p0) + clamp127(p1-q1)) - a1 := (27*a + 63) >> 7 - a2 := (18*a + 63) >> 7 - a3 := (9*a + 63) >> 7 - pix[index-3*jStep] = clamp255(p2 + a3) - pix[index-2*jStep] = clamp255(p1 + a2) - pix[index-1*jStep] = clamp255(p0 + a1) - pix[index+0*jStep] = clamp255(q0 - a1) - pix[index+1*jStep] = clamp255(q1 - a2) - pix[index+2*jStep] = clamp255(q2 - a3) - } - } -} - -// simpleFilter implements the simple filter, as specified in section 15.2. -func (d *Decoder) simpleFilter() { - for mby := 0; mby < d.mbh; mby++ { - for mbx := 0; mbx < d.mbw; mbx++ { - f := d.perMBFilterParams[d.mbw*mby+mbx] - if f.level == 0 { - continue - } - l := int(f.level) - yIndex := (mby*d.img.YStride + mbx) * 16 - if mbx > 0 { - filter2(d.img.Y, l+4, yIndex, d.img.YStride, 1) - } - if f.inner { - filter2(d.img.Y, l, yIndex+0x4, d.img.YStride, 1) - filter2(d.img.Y, l, yIndex+0x8, d.img.YStride, 1) - filter2(d.img.Y, l, yIndex+0xc, d.img.YStride, 1) - } - if mby > 0 { - filter2(d.img.Y, l+4, yIndex, 1, d.img.YStride) - } - if f.inner { - filter2(d.img.Y, l, yIndex+d.img.YStride*0x4, 1, d.img.YStride) - filter2(d.img.Y, l, yIndex+d.img.YStride*0x8, 1, d.img.YStride) - filter2(d.img.Y, l, yIndex+d.img.YStride*0xc, 1, d.img.YStride) - } - } - } -} - -// normalFilter implements the normal filter, as specified in section 15.3. -func (d *Decoder) normalFilter() { - for mby := 0; mby < d.mbh; mby++ { - for mbx := 0; mbx < d.mbw; mbx++ { - f := d.perMBFilterParams[d.mbw*mby+mbx] - if f.level == 0 { - continue - } - l, il, hl := int(f.level), int(f.ilevel), int(f.hlevel) - yIndex := (mby*d.img.YStride + mbx) * 16 - cIndex := (mby*d.img.CStride + mbx) * 8 - if mbx > 0 { - filter246(d.img.Y, 16, l+4, il, hl, yIndex, d.img.YStride, 1, false) - filter246(d.img.Cb, 8, l+4, il, hl, cIndex, d.img.CStride, 1, false) - filter246(d.img.Cr, 8, l+4, il, hl, cIndex, d.img.CStride, 1, false) - } - if f.inner { - filter246(d.img.Y, 16, l, il, hl, yIndex+0x4, d.img.YStride, 1, true) - filter246(d.img.Y, 16, l, il, hl, yIndex+0x8, d.img.YStride, 1, true) - filter246(d.img.Y, 16, l, il, hl, yIndex+0xc, d.img.YStride, 1, true) - filter246(d.img.Cb, 8, l, il, hl, cIndex+0x4, d.img.CStride, 1, true) - filter246(d.img.Cr, 8, l, il, hl, cIndex+0x4, d.img.CStride, 1, true) - } - if mby > 0 { - filter246(d.img.Y, 16, l+4, il, hl, yIndex, 1, d.img.YStride, false) - filter246(d.img.Cb, 8, l+4, il, hl, cIndex, 1, d.img.CStride, false) - filter246(d.img.Cr, 8, l+4, il, hl, cIndex, 1, d.img.CStride, false) - } - if f.inner { - filter246(d.img.Y, 16, l, il, hl, yIndex+d.img.YStride*0x4, 1, d.img.YStride, true) - filter246(d.img.Y, 16, l, il, hl, yIndex+d.img.YStride*0x8, 1, d.img.YStride, true) - filter246(d.img.Y, 16, l, il, hl, yIndex+d.img.YStride*0xc, 1, d.img.YStride, true) - filter246(d.img.Cb, 8, l, il, hl, cIndex+d.img.CStride*0x4, 1, d.img.CStride, true) - filter246(d.img.Cr, 8, l, il, hl, cIndex+d.img.CStride*0x4, 1, d.img.CStride, true) - } - } - } -} - -// filterParam holds the loop filter parameters for a macroblock. -type filterParam struct { - // The first three fields are thresholds used by the loop filter to smooth - // over the edges and interior of a macroblock. level is used by both the - // simple and normal filters. The inner level and high edge variance level - // are only used by the normal filter. - level, ilevel, hlevel uint8 - // inner is whether the inner loop filter cannot be optimized out as a - // no-op for this particular macroblock. - inner bool -} - -// computeFilterParams computes the loop filter parameters, as specified in -// section 15.4. -func (d *Decoder) computeFilterParams() { - for i := range d.filterParams { - baseLevel := d.filterHeader.level - if d.segmentHeader.useSegment { - baseLevel = d.segmentHeader.filterStrength[i] - if d.segmentHeader.relativeDelta { - baseLevel += d.filterHeader.level - } - } - - for j := range d.filterParams[i] { - p := &d.filterParams[i][j] - p.inner = j != 0 - level := baseLevel - if d.filterHeader.useLFDelta { - // The libwebp C code has a "TODO: only CURRENT is handled for now." - level += d.filterHeader.refLFDelta[0] - if j != 0 { - level += d.filterHeader.modeLFDelta[0] - } - } - if level <= 0 { - p.level = 0 - continue - } - if level > 63 { - level = 63 - } - ilevel := level - if d.filterHeader.sharpness > 0 { - if d.filterHeader.sharpness > 4 { - ilevel >>= 2 - } else { - ilevel >>= 1 - } - if x := int8(9 - d.filterHeader.sharpness); ilevel > x { - ilevel = x - } - } - if ilevel < 1 { - ilevel = 1 - } - p.ilevel = uint8(ilevel) - p.level = uint8(2*level + ilevel) - if d.frameHeader.KeyFrame { - if level < 15 { - p.hlevel = 0 - } else if level < 40 { - p.hlevel = 1 - } else { - p.hlevel = 2 - } - } else { - if level < 15 { - p.hlevel = 0 - } else if level < 20 { - p.hlevel = 1 - } else if level < 40 { - p.hlevel = 2 - } else { - p.hlevel = 3 - } - } - } - } -} - -// intSize is either 32 or 64. -const intSize = 32 << (^uint(0) >> 63) - -func abs(x int) int { - // m := -1 if x < 0. m := 0 otherwise. - m := x >> (intSize - 1) - - // In two's complement representation, the negative number - // of any number (except the smallest one) can be computed - // by flipping all the bits and add 1. This is faster than - // code with a branch. - // See Hacker's Delight, section 2-4. - return (x ^ m) - m -} - -func clamp15(x int) int { - if x < -16 { - return -16 - } - if x > 15 { - return 15 - } - return x -} - -func clamp127(x int) int { - if x < -128 { - return -128 - } - if x > 127 { - return 127 - } - return x -} - -func clamp255(x int) uint8 { - if x < 0 { - return 0 - } - if x > 255 { - return 255 - } - return uint8(x) -} diff --git a/vendor/golang.org/x/image/vp8/idct.go b/vendor/golang.org/x/image/vp8/idct.go deleted file mode 100644 index 929af2c..0000000 --- a/vendor/golang.org/x/image/vp8/idct.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8 - -// This file implements the inverse Discrete Cosine Transform and the inverse -// Walsh Hadamard Transform (WHT), as specified in sections 14.3 and 14.4. - -func clip8(i int32) uint8 { - if i < 0 { - return 0 - } - if i > 255 { - return 255 - } - return uint8(i) -} - -func (z *Decoder) inverseDCT4(y, x, coeffBase int) { - const ( - c1 = 85627 // 65536 * cos(pi/8) * sqrt(2). - c2 = 35468 // 65536 * sin(pi/8) * sqrt(2). - ) - var m [4][4]int32 - for i := 0; i < 4; i++ { - a := int32(z.coeff[coeffBase+0]) + int32(z.coeff[coeffBase+8]) - b := int32(z.coeff[coeffBase+0]) - int32(z.coeff[coeffBase+8]) - c := (int32(z.coeff[coeffBase+4])*c2)>>16 - (int32(z.coeff[coeffBase+12])*c1)>>16 - d := (int32(z.coeff[coeffBase+4])*c1)>>16 + (int32(z.coeff[coeffBase+12])*c2)>>16 - m[i][0] = a + d - m[i][1] = b + c - m[i][2] = b - c - m[i][3] = a - d - coeffBase++ - } - for j := 0; j < 4; j++ { - dc := m[0][j] + 4 - a := dc + m[2][j] - b := dc - m[2][j] - c := (m[1][j]*c2)>>16 - (m[3][j]*c1)>>16 - d := (m[1][j]*c1)>>16 + (m[3][j]*c2)>>16 - z.ybr[y+j][x+0] = clip8(int32(z.ybr[y+j][x+0]) + (a+d)>>3) - z.ybr[y+j][x+1] = clip8(int32(z.ybr[y+j][x+1]) + (b+c)>>3) - z.ybr[y+j][x+2] = clip8(int32(z.ybr[y+j][x+2]) + (b-c)>>3) - z.ybr[y+j][x+3] = clip8(int32(z.ybr[y+j][x+3]) + (a-d)>>3) - } -} - -func (z *Decoder) inverseDCT4DCOnly(y, x, coeffBase int) { - dc := (int32(z.coeff[coeffBase+0]) + 4) >> 3 - for j := 0; j < 4; j++ { - for i := 0; i < 4; i++ { - z.ybr[y+j][x+i] = clip8(int32(z.ybr[y+j][x+i]) + dc) - } - } -} - -func (z *Decoder) inverseDCT8(y, x, coeffBase int) { - z.inverseDCT4(y+0, x+0, coeffBase+0*16) - z.inverseDCT4(y+0, x+4, coeffBase+1*16) - z.inverseDCT4(y+4, x+0, coeffBase+2*16) - z.inverseDCT4(y+4, x+4, coeffBase+3*16) -} - -func (z *Decoder) inverseDCT8DCOnly(y, x, coeffBase int) { - z.inverseDCT4DCOnly(y+0, x+0, coeffBase+0*16) - z.inverseDCT4DCOnly(y+0, x+4, coeffBase+1*16) - z.inverseDCT4DCOnly(y+4, x+0, coeffBase+2*16) - z.inverseDCT4DCOnly(y+4, x+4, coeffBase+3*16) -} - -func (d *Decoder) inverseWHT16() { - var m [16]int32 - for i := 0; i < 4; i++ { - a0 := int32(d.coeff[384+0+i]) + int32(d.coeff[384+12+i]) - a1 := int32(d.coeff[384+4+i]) + int32(d.coeff[384+8+i]) - a2 := int32(d.coeff[384+4+i]) - int32(d.coeff[384+8+i]) - a3 := int32(d.coeff[384+0+i]) - int32(d.coeff[384+12+i]) - m[0+i] = a0 + a1 - m[8+i] = a0 - a1 - m[4+i] = a3 + a2 - m[12+i] = a3 - a2 - } - out := 0 - for i := 0; i < 4; i++ { - dc := m[0+i*4] + 3 - a0 := dc + m[3+i*4] - a1 := m[1+i*4] + m[2+i*4] - a2 := m[1+i*4] - m[2+i*4] - a3 := dc - m[3+i*4] - d.coeff[out+0] = int16((a0 + a1) >> 3) - d.coeff[out+16] = int16((a3 + a2) >> 3) - d.coeff[out+32] = int16((a0 - a1) >> 3) - d.coeff[out+48] = int16((a3 - a2) >> 3) - out += 64 - } -} diff --git a/vendor/golang.org/x/image/vp8/partition.go b/vendor/golang.org/x/image/vp8/partition.go deleted file mode 100644 index 72288bd..0000000 --- a/vendor/golang.org/x/image/vp8/partition.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8 - -// Each VP8 frame consists of between 2 and 9 bitstream partitions. -// Each partition is byte-aligned and is independently arithmetic-encoded. -// -// This file implements decoding a partition's bitstream, as specified in -// chapter 7. The implementation follows libwebp's approach instead of the -// specification's reference C implementation. For example, we use a look-up -// table instead of a for loop to recalibrate the encoded range. - -var ( - lutShift = [127]uint8{ - 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - } - lutRangeM1 = [127]uint8{ - 127, - 127, 191, - 127, 159, 191, 223, - 127, 143, 159, 175, 191, 207, 223, 239, - 127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, 231, 239, 247, - 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, 187, - 191, 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239, 243, 247, 251, - 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, - 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, - 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, - 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, - } -) - -// uniformProb represents a 50% probability that the next bit is 0. -const uniformProb = 128 - -// partition holds arithmetic-coded bits. -type partition struct { - // buf is the input bytes. - buf []byte - // r is how many of buf's bytes have been consumed. - r int - // rangeM1 is range minus 1, where range is in the arithmetic coding sense, - // not the Go language sense. - rangeM1 uint32 - // bits and nBits hold those bits shifted out of buf but not yet consumed. - bits uint32 - nBits uint8 - // unexpectedEOF tells whether we tried to read past buf. - unexpectedEOF bool -} - -// init initializes the partition. -func (p *partition) init(buf []byte) { - p.buf = buf - p.r = 0 - p.rangeM1 = 254 - p.bits = 0 - p.nBits = 0 - p.unexpectedEOF = false -} - -// readBit returns the next bit. -func (p *partition) readBit(prob uint8) bool { - if p.nBits < 8 { - if p.r >= len(p.buf) { - p.unexpectedEOF = true - return false - } - // Expression split for 386 compiler. - x := uint32(p.buf[p.r]) - p.bits |= x << (8 - p.nBits) - p.r++ - p.nBits += 8 - } - split := (p.rangeM1*uint32(prob))>>8 + 1 - bit := p.bits >= split<<8 - if bit { - p.rangeM1 -= split - p.bits -= split << 8 - } else { - p.rangeM1 = split - 1 - } - if p.rangeM1 < 127 { - shift := lutShift[p.rangeM1] - p.rangeM1 = uint32(lutRangeM1[p.rangeM1]) - p.bits <<= shift - p.nBits -= shift - } - return bit -} - -// readUint returns the next n-bit unsigned integer. -func (p *partition) readUint(prob, n uint8) uint32 { - var u uint32 - for n > 0 { - n-- - if p.readBit(prob) { - u |= 1 << n - } - } - return u -} - -// readInt returns the next n-bit signed integer. -func (p *partition) readInt(prob, n uint8) int32 { - u := p.readUint(prob, n) - b := p.readBit(prob) - if b { - return -int32(u) - } - return int32(u) -} - -// readOptionalInt returns the next n-bit signed integer in an encoding -// where the likely result is zero. -func (p *partition) readOptionalInt(prob, n uint8) int32 { - if !p.readBit(prob) { - return 0 - } - return p.readInt(prob, n) -} diff --git a/vendor/golang.org/x/image/vp8/pred.go b/vendor/golang.org/x/image/vp8/pred.go deleted file mode 100644 index 58c2689..0000000 --- a/vendor/golang.org/x/image/vp8/pred.go +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8 - -// This file implements parsing the predictor modes, as specified in chapter -// 11. - -func (d *Decoder) parsePredModeY16(mbx int) { - var p uint8 - if !d.fp.readBit(156) { - if !d.fp.readBit(163) { - p = predDC - } else { - p = predVE - } - } else if !d.fp.readBit(128) { - p = predHE - } else { - p = predTM - } - for i := 0; i < 4; i++ { - d.upMB[mbx].pred[i] = p - d.leftMB.pred[i] = p - } - d.predY16 = p -} - -func (d *Decoder) parsePredModeC8() { - if !d.fp.readBit(142) { - d.predC8 = predDC - } else if !d.fp.readBit(114) { - d.predC8 = predVE - } else if !d.fp.readBit(183) { - d.predC8 = predHE - } else { - d.predC8 = predTM - } -} - -func (d *Decoder) parsePredModeY4(mbx int) { - for j := 0; j < 4; j++ { - p := d.leftMB.pred[j] - for i := 0; i < 4; i++ { - prob := &predProb[d.upMB[mbx].pred[i]][p] - if !d.fp.readBit(prob[0]) { - p = predDC - } else if !d.fp.readBit(prob[1]) { - p = predTM - } else if !d.fp.readBit(prob[2]) { - p = predVE - } else if !d.fp.readBit(prob[3]) { - if !d.fp.readBit(prob[4]) { - p = predHE - } else if !d.fp.readBit(prob[5]) { - p = predRD - } else { - p = predVR - } - } else if !d.fp.readBit(prob[6]) { - p = predLD - } else if !d.fp.readBit(prob[7]) { - p = predVL - } else if !d.fp.readBit(prob[8]) { - p = predHD - } else { - p = predHU - } - d.predY4[j][i] = p - d.upMB[mbx].pred[i] = p - } - d.leftMB.pred[j] = p - } -} - -// predProb are the probabilities to decode a 4x4 region's predictor mode given -// the predictor modes of the regions above and left of it. -// These values are specified in section 11.5. -var predProb = [nPred][nPred][9]uint8{ - { - {231, 120, 48, 89, 115, 113, 120, 152, 112}, - {152, 179, 64, 126, 170, 118, 46, 70, 95}, - {175, 69, 143, 80, 85, 82, 72, 155, 103}, - {56, 58, 10, 171, 218, 189, 17, 13, 152}, - {114, 26, 17, 163, 44, 195, 21, 10, 173}, - {121, 24, 80, 195, 26, 62, 44, 64, 85}, - {144, 71, 10, 38, 171, 213, 144, 34, 26}, - {170, 46, 55, 19, 136, 160, 33, 206, 71}, - {63, 20, 8, 114, 114, 208, 12, 9, 226}, - {81, 40, 11, 96, 182, 84, 29, 16, 36}, - }, - { - {134, 183, 89, 137, 98, 101, 106, 165, 148}, - {72, 187, 100, 130, 157, 111, 32, 75, 80}, - {66, 102, 167, 99, 74, 62, 40, 234, 128}, - {41, 53, 9, 178, 241, 141, 26, 8, 107}, - {74, 43, 26, 146, 73, 166, 49, 23, 157}, - {65, 38, 105, 160, 51, 52, 31, 115, 128}, - {104, 79, 12, 27, 217, 255, 87, 17, 7}, - {87, 68, 71, 44, 114, 51, 15, 186, 23}, - {47, 41, 14, 110, 182, 183, 21, 17, 194}, - {66, 45, 25, 102, 197, 189, 23, 18, 22}, - }, - { - {88, 88, 147, 150, 42, 46, 45, 196, 205}, - {43, 97, 183, 117, 85, 38, 35, 179, 61}, - {39, 53, 200, 87, 26, 21, 43, 232, 171}, - {56, 34, 51, 104, 114, 102, 29, 93, 77}, - {39, 28, 85, 171, 58, 165, 90, 98, 64}, - {34, 22, 116, 206, 23, 34, 43, 166, 73}, - {107, 54, 32, 26, 51, 1, 81, 43, 31}, - {68, 25, 106, 22, 64, 171, 36, 225, 114}, - {34, 19, 21, 102, 132, 188, 16, 76, 124}, - {62, 18, 78, 95, 85, 57, 50, 48, 51}, - }, - { - {193, 101, 35, 159, 215, 111, 89, 46, 111}, - {60, 148, 31, 172, 219, 228, 21, 18, 111}, - {112, 113, 77, 85, 179, 255, 38, 120, 114}, - {40, 42, 1, 196, 245, 209, 10, 25, 109}, - {88, 43, 29, 140, 166, 213, 37, 43, 154}, - {61, 63, 30, 155, 67, 45, 68, 1, 209}, - {100, 80, 8, 43, 154, 1, 51, 26, 71}, - {142, 78, 78, 16, 255, 128, 34, 197, 171}, - {41, 40, 5, 102, 211, 183, 4, 1, 221}, - {51, 50, 17, 168, 209, 192, 23, 25, 82}, - }, - { - {138, 31, 36, 171, 27, 166, 38, 44, 229}, - {67, 87, 58, 169, 82, 115, 26, 59, 179}, - {63, 59, 90, 180, 59, 166, 93, 73, 154}, - {40, 40, 21, 116, 143, 209, 34, 39, 175}, - {47, 15, 16, 183, 34, 223, 49, 45, 183}, - {46, 17, 33, 183, 6, 98, 15, 32, 183}, - {57, 46, 22, 24, 128, 1, 54, 17, 37}, - {65, 32, 73, 115, 28, 128, 23, 128, 205}, - {40, 3, 9, 115, 51, 192, 18, 6, 223}, - {87, 37, 9, 115, 59, 77, 64, 21, 47}, - }, - { - {104, 55, 44, 218, 9, 54, 53, 130, 226}, - {64, 90, 70, 205, 40, 41, 23, 26, 57}, - {54, 57, 112, 184, 5, 41, 38, 166, 213}, - {30, 34, 26, 133, 152, 116, 10, 32, 134}, - {39, 19, 53, 221, 26, 114, 32, 73, 255}, - {31, 9, 65, 234, 2, 15, 1, 118, 73}, - {75, 32, 12, 51, 192, 255, 160, 43, 51}, - {88, 31, 35, 67, 102, 85, 55, 186, 85}, - {56, 21, 23, 111, 59, 205, 45, 37, 192}, - {55, 38, 70, 124, 73, 102, 1, 34, 98}, - }, - { - {125, 98, 42, 88, 104, 85, 117, 175, 82}, - {95, 84, 53, 89, 128, 100, 113, 101, 45}, - {75, 79, 123, 47, 51, 128, 81, 171, 1}, - {57, 17, 5, 71, 102, 57, 53, 41, 49}, - {38, 33, 13, 121, 57, 73, 26, 1, 85}, - {41, 10, 67, 138, 77, 110, 90, 47, 114}, - {115, 21, 2, 10, 102, 255, 166, 23, 6}, - {101, 29, 16, 10, 85, 128, 101, 196, 26}, - {57, 18, 10, 102, 102, 213, 34, 20, 43}, - {117, 20, 15, 36, 163, 128, 68, 1, 26}, - }, - { - {102, 61, 71, 37, 34, 53, 31, 243, 192}, - {69, 60, 71, 38, 73, 119, 28, 222, 37}, - {68, 45, 128, 34, 1, 47, 11, 245, 171}, - {62, 17, 19, 70, 146, 85, 55, 62, 70}, - {37, 43, 37, 154, 100, 163, 85, 160, 1}, - {63, 9, 92, 136, 28, 64, 32, 201, 85}, - {75, 15, 9, 9, 64, 255, 184, 119, 16}, - {86, 6, 28, 5, 64, 255, 25, 248, 1}, - {56, 8, 17, 132, 137, 255, 55, 116, 128}, - {58, 15, 20, 82, 135, 57, 26, 121, 40}, - }, - { - {164, 50, 31, 137, 154, 133, 25, 35, 218}, - {51, 103, 44, 131, 131, 123, 31, 6, 158}, - {86, 40, 64, 135, 148, 224, 45, 183, 128}, - {22, 26, 17, 131, 240, 154, 14, 1, 209}, - {45, 16, 21, 91, 64, 222, 7, 1, 197}, - {56, 21, 39, 155, 60, 138, 23, 102, 213}, - {83, 12, 13, 54, 192, 255, 68, 47, 28}, - {85, 26, 85, 85, 128, 128, 32, 146, 171}, - {18, 11, 7, 63, 144, 171, 4, 4, 246}, - {35, 27, 10, 146, 174, 171, 12, 26, 128}, - }, - { - {190, 80, 35, 99, 180, 80, 126, 54, 45}, - {85, 126, 47, 87, 176, 51, 41, 20, 32}, - {101, 75, 128, 139, 118, 146, 116, 128, 85}, - {56, 41, 15, 176, 236, 85, 37, 9, 62}, - {71, 30, 17, 119, 118, 255, 17, 18, 138}, - {101, 38, 60, 138, 55, 70, 43, 26, 142}, - {146, 36, 19, 30, 171, 255, 97, 27, 20}, - {138, 45, 61, 62, 219, 1, 81, 188, 64}, - {32, 41, 20, 117, 151, 142, 20, 21, 163}, - {112, 19, 12, 61, 195, 128, 48, 4, 24}, - }, -} diff --git a/vendor/golang.org/x/image/vp8/predfunc.go b/vendor/golang.org/x/image/vp8/predfunc.go deleted file mode 100644 index f899958..0000000 --- a/vendor/golang.org/x/image/vp8/predfunc.go +++ /dev/null @@ -1,553 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8 - -// This file implements the predicition functions, as specified in chapter 12. -// -// For each macroblock (of 1x16x16 luma and 2x8x8 chroma coefficients), the -// luma values are either predicted as one large 16x16 region or 16 separate -// 4x4 regions. The chroma values are always predicted as one 8x8 region. -// -// For 4x4 regions, the target block's predicted values (Xs) are a function of -// its previously-decoded top and left border values, as well as a number of -// pixels from the top-right: -// -// a b c d e f g h -// p X X X X -// q X X X X -// r X X X X -// s X X X X -// -// The predictor modes are: -// - DC: all Xs = (b + c + d + e + p + q + r + s + 4) / 8. -// - TM: the first X = (b + p - a), the second X = (c + p - a), and so on. -// - VE: each X = the weighted average of its column's top value and that -// value's neighbors, i.e. averages of abc, bcd, cde or def. -// - HE: similar to VE except rows instead of columns, and the final row is -// an average of r, s and s. -// - RD, VR, LD, VL, HD, HU: these diagonal modes ("Right Down", "Vertical -// Right", etc) are more complicated and are described in section 12.3. -// All Xs are clipped to the range [0, 255]. -// -// For 8x8 and 16x16 regions, the target block's predicted values are a -// function of the top and left border values without the top-right overhang, -// i.e. without the 8x8 or 16x16 equivalent of f, g and h. Furthermore: -// - There are no diagonal predictor modes, only DC, TM, VE and HE. -// - The DC mode has variants for macroblocks in the top row and/or left -// column, i.e. for macroblocks with mby == 0 || mbx == 0. -// - The VE and HE modes take only the column top or row left values; they do -// not smooth that top/left value with its neighbors. - -// nPred is the number of predictor modes, not including the Top/Left versions -// of the DC predictor mode. -const nPred = 10 - -const ( - predDC = iota - predTM - predVE - predHE - predRD - predVR - predLD - predVL - predHD - predHU - predDCTop - predDCLeft - predDCTopLeft -) - -func checkTopLeftPred(mbx, mby int, p uint8) uint8 { - if p != predDC { - return p - } - if mbx == 0 { - if mby == 0 { - return predDCTopLeft - } - return predDCLeft - } - if mby == 0 { - return predDCTop - } - return predDC -} - -var predFunc4 = [...]func(*Decoder, int, int){ - predFunc4DC, - predFunc4TM, - predFunc4VE, - predFunc4HE, - predFunc4RD, - predFunc4VR, - predFunc4LD, - predFunc4VL, - predFunc4HD, - predFunc4HU, - nil, - nil, - nil, -} - -var predFunc8 = [...]func(*Decoder, int, int){ - predFunc8DC, - predFunc8TM, - predFunc8VE, - predFunc8HE, - nil, - nil, - nil, - nil, - nil, - nil, - predFunc8DCTop, - predFunc8DCLeft, - predFunc8DCTopLeft, -} - -var predFunc16 = [...]func(*Decoder, int, int){ - predFunc16DC, - predFunc16TM, - predFunc16VE, - predFunc16HE, - nil, - nil, - nil, - nil, - nil, - nil, - predFunc16DCTop, - predFunc16DCLeft, - predFunc16DCTopLeft, -} - -func predFunc4DC(z *Decoder, y, x int) { - sum := uint32(4) - for i := 0; i < 4; i++ { - sum += uint32(z.ybr[y-1][x+i]) - } - for j := 0; j < 4; j++ { - sum += uint32(z.ybr[y+j][x-1]) - } - avg := uint8(sum / 8) - for j := 0; j < 4; j++ { - for i := 0; i < 4; i++ { - z.ybr[y+j][x+i] = avg - } - } -} - -func predFunc4TM(z *Decoder, y, x int) { - delta0 := -int32(z.ybr[y-1][x-1]) - for j := 0; j < 4; j++ { - delta1 := delta0 + int32(z.ybr[y+j][x-1]) - for i := 0; i < 4; i++ { - delta2 := delta1 + int32(z.ybr[y-1][x+i]) - z.ybr[y+j][x+i] = uint8(clip(delta2, 0, 255)) - } - } -} - -func predFunc4VE(z *Decoder, y, x int) { - a := int32(z.ybr[y-1][x-1]) - b := int32(z.ybr[y-1][x+0]) - c := int32(z.ybr[y-1][x+1]) - d := int32(z.ybr[y-1][x+2]) - e := int32(z.ybr[y-1][x+3]) - f := int32(z.ybr[y-1][x+4]) - abc := uint8((a + 2*b + c + 2) / 4) - bcd := uint8((b + 2*c + d + 2) / 4) - cde := uint8((c + 2*d + e + 2) / 4) - def := uint8((d + 2*e + f + 2) / 4) - for j := 0; j < 4; j++ { - z.ybr[y+j][x+0] = abc - z.ybr[y+j][x+1] = bcd - z.ybr[y+j][x+2] = cde - z.ybr[y+j][x+3] = def - } -} - -func predFunc4HE(z *Decoder, y, x int) { - s := int32(z.ybr[y+3][x-1]) - r := int32(z.ybr[y+2][x-1]) - q := int32(z.ybr[y+1][x-1]) - p := int32(z.ybr[y+0][x-1]) - a := int32(z.ybr[y-1][x-1]) - ssr := uint8((s + 2*s + r + 2) / 4) - srq := uint8((s + 2*r + q + 2) / 4) - rqp := uint8((r + 2*q + p + 2) / 4) - apq := uint8((a + 2*p + q + 2) / 4) - for i := 0; i < 4; i++ { - z.ybr[y+0][x+i] = apq - z.ybr[y+1][x+i] = rqp - z.ybr[y+2][x+i] = srq - z.ybr[y+3][x+i] = ssr - } -} - -func predFunc4RD(z *Decoder, y, x int) { - s := int32(z.ybr[y+3][x-1]) - r := int32(z.ybr[y+2][x-1]) - q := int32(z.ybr[y+1][x-1]) - p := int32(z.ybr[y+0][x-1]) - a := int32(z.ybr[y-1][x-1]) - b := int32(z.ybr[y-1][x+0]) - c := int32(z.ybr[y-1][x+1]) - d := int32(z.ybr[y-1][x+2]) - e := int32(z.ybr[y-1][x+3]) - srq := uint8((s + 2*r + q + 2) / 4) - rqp := uint8((r + 2*q + p + 2) / 4) - qpa := uint8((q + 2*p + a + 2) / 4) - pab := uint8((p + 2*a + b + 2) / 4) - abc := uint8((a + 2*b + c + 2) / 4) - bcd := uint8((b + 2*c + d + 2) / 4) - cde := uint8((c + 2*d + e + 2) / 4) - z.ybr[y+0][x+0] = pab - z.ybr[y+0][x+1] = abc - z.ybr[y+0][x+2] = bcd - z.ybr[y+0][x+3] = cde - z.ybr[y+1][x+0] = qpa - z.ybr[y+1][x+1] = pab - z.ybr[y+1][x+2] = abc - z.ybr[y+1][x+3] = bcd - z.ybr[y+2][x+0] = rqp - z.ybr[y+2][x+1] = qpa - z.ybr[y+2][x+2] = pab - z.ybr[y+2][x+3] = abc - z.ybr[y+3][x+0] = srq - z.ybr[y+3][x+1] = rqp - z.ybr[y+3][x+2] = qpa - z.ybr[y+3][x+3] = pab -} - -func predFunc4VR(z *Decoder, y, x int) { - r := int32(z.ybr[y+2][x-1]) - q := int32(z.ybr[y+1][x-1]) - p := int32(z.ybr[y+0][x-1]) - a := int32(z.ybr[y-1][x-1]) - b := int32(z.ybr[y-1][x+0]) - c := int32(z.ybr[y-1][x+1]) - d := int32(z.ybr[y-1][x+2]) - e := int32(z.ybr[y-1][x+3]) - ab := uint8((a + b + 1) / 2) - bc := uint8((b + c + 1) / 2) - cd := uint8((c + d + 1) / 2) - de := uint8((d + e + 1) / 2) - rqp := uint8((r + 2*q + p + 2) / 4) - qpa := uint8((q + 2*p + a + 2) / 4) - pab := uint8((p + 2*a + b + 2) / 4) - abc := uint8((a + 2*b + c + 2) / 4) - bcd := uint8((b + 2*c + d + 2) / 4) - cde := uint8((c + 2*d + e + 2) / 4) - z.ybr[y+0][x+0] = ab - z.ybr[y+0][x+1] = bc - z.ybr[y+0][x+2] = cd - z.ybr[y+0][x+3] = de - z.ybr[y+1][x+0] = pab - z.ybr[y+1][x+1] = abc - z.ybr[y+1][x+2] = bcd - z.ybr[y+1][x+3] = cde - z.ybr[y+2][x+0] = qpa - z.ybr[y+2][x+1] = ab - z.ybr[y+2][x+2] = bc - z.ybr[y+2][x+3] = cd - z.ybr[y+3][x+0] = rqp - z.ybr[y+3][x+1] = pab - z.ybr[y+3][x+2] = abc - z.ybr[y+3][x+3] = bcd -} - -func predFunc4LD(z *Decoder, y, x int) { - a := int32(z.ybr[y-1][x+0]) - b := int32(z.ybr[y-1][x+1]) - c := int32(z.ybr[y-1][x+2]) - d := int32(z.ybr[y-1][x+3]) - e := int32(z.ybr[y-1][x+4]) - f := int32(z.ybr[y-1][x+5]) - g := int32(z.ybr[y-1][x+6]) - h := int32(z.ybr[y-1][x+7]) - abc := uint8((a + 2*b + c + 2) / 4) - bcd := uint8((b + 2*c + d + 2) / 4) - cde := uint8((c + 2*d + e + 2) / 4) - def := uint8((d + 2*e + f + 2) / 4) - efg := uint8((e + 2*f + g + 2) / 4) - fgh := uint8((f + 2*g + h + 2) / 4) - ghh := uint8((g + 2*h + h + 2) / 4) - z.ybr[y+0][x+0] = abc - z.ybr[y+0][x+1] = bcd - z.ybr[y+0][x+2] = cde - z.ybr[y+0][x+3] = def - z.ybr[y+1][x+0] = bcd - z.ybr[y+1][x+1] = cde - z.ybr[y+1][x+2] = def - z.ybr[y+1][x+3] = efg - z.ybr[y+2][x+0] = cde - z.ybr[y+2][x+1] = def - z.ybr[y+2][x+2] = efg - z.ybr[y+2][x+3] = fgh - z.ybr[y+3][x+0] = def - z.ybr[y+3][x+1] = efg - z.ybr[y+3][x+2] = fgh - z.ybr[y+3][x+3] = ghh -} - -func predFunc4VL(z *Decoder, y, x int) { - a := int32(z.ybr[y-1][x+0]) - b := int32(z.ybr[y-1][x+1]) - c := int32(z.ybr[y-1][x+2]) - d := int32(z.ybr[y-1][x+3]) - e := int32(z.ybr[y-1][x+4]) - f := int32(z.ybr[y-1][x+5]) - g := int32(z.ybr[y-1][x+6]) - h := int32(z.ybr[y-1][x+7]) - ab := uint8((a + b + 1) / 2) - bc := uint8((b + c + 1) / 2) - cd := uint8((c + d + 1) / 2) - de := uint8((d + e + 1) / 2) - abc := uint8((a + 2*b + c + 2) / 4) - bcd := uint8((b + 2*c + d + 2) / 4) - cde := uint8((c + 2*d + e + 2) / 4) - def := uint8((d + 2*e + f + 2) / 4) - efg := uint8((e + 2*f + g + 2) / 4) - fgh := uint8((f + 2*g + h + 2) / 4) - z.ybr[y+0][x+0] = ab - z.ybr[y+0][x+1] = bc - z.ybr[y+0][x+2] = cd - z.ybr[y+0][x+3] = de - z.ybr[y+1][x+0] = abc - z.ybr[y+1][x+1] = bcd - z.ybr[y+1][x+2] = cde - z.ybr[y+1][x+3] = def - z.ybr[y+2][x+0] = bc - z.ybr[y+2][x+1] = cd - z.ybr[y+2][x+2] = de - z.ybr[y+2][x+3] = efg - z.ybr[y+3][x+0] = bcd - z.ybr[y+3][x+1] = cde - z.ybr[y+3][x+2] = def - z.ybr[y+3][x+3] = fgh -} - -func predFunc4HD(z *Decoder, y, x int) { - s := int32(z.ybr[y+3][x-1]) - r := int32(z.ybr[y+2][x-1]) - q := int32(z.ybr[y+1][x-1]) - p := int32(z.ybr[y+0][x-1]) - a := int32(z.ybr[y-1][x-1]) - b := int32(z.ybr[y-1][x+0]) - c := int32(z.ybr[y-1][x+1]) - d := int32(z.ybr[y-1][x+2]) - sr := uint8((s + r + 1) / 2) - rq := uint8((r + q + 1) / 2) - qp := uint8((q + p + 1) / 2) - pa := uint8((p + a + 1) / 2) - srq := uint8((s + 2*r + q + 2) / 4) - rqp := uint8((r + 2*q + p + 2) / 4) - qpa := uint8((q + 2*p + a + 2) / 4) - pab := uint8((p + 2*a + b + 2) / 4) - abc := uint8((a + 2*b + c + 2) / 4) - bcd := uint8((b + 2*c + d + 2) / 4) - z.ybr[y+0][x+0] = pa - z.ybr[y+0][x+1] = pab - z.ybr[y+0][x+2] = abc - z.ybr[y+0][x+3] = bcd - z.ybr[y+1][x+0] = qp - z.ybr[y+1][x+1] = qpa - z.ybr[y+1][x+2] = pa - z.ybr[y+1][x+3] = pab - z.ybr[y+2][x+0] = rq - z.ybr[y+2][x+1] = rqp - z.ybr[y+2][x+2] = qp - z.ybr[y+2][x+3] = qpa - z.ybr[y+3][x+0] = sr - z.ybr[y+3][x+1] = srq - z.ybr[y+3][x+2] = rq - z.ybr[y+3][x+3] = rqp -} - -func predFunc4HU(z *Decoder, y, x int) { - s := int32(z.ybr[y+3][x-1]) - r := int32(z.ybr[y+2][x-1]) - q := int32(z.ybr[y+1][x-1]) - p := int32(z.ybr[y+0][x-1]) - pq := uint8((p + q + 1) / 2) - qr := uint8((q + r + 1) / 2) - rs := uint8((r + s + 1) / 2) - pqr := uint8((p + 2*q + r + 2) / 4) - qrs := uint8((q + 2*r + s + 2) / 4) - rss := uint8((r + 2*s + s + 2) / 4) - sss := uint8(s) - z.ybr[y+0][x+0] = pq - z.ybr[y+0][x+1] = pqr - z.ybr[y+0][x+2] = qr - z.ybr[y+0][x+3] = qrs - z.ybr[y+1][x+0] = qr - z.ybr[y+1][x+1] = qrs - z.ybr[y+1][x+2] = rs - z.ybr[y+1][x+3] = rss - z.ybr[y+2][x+0] = rs - z.ybr[y+2][x+1] = rss - z.ybr[y+2][x+2] = sss - z.ybr[y+2][x+3] = sss - z.ybr[y+3][x+0] = sss - z.ybr[y+3][x+1] = sss - z.ybr[y+3][x+2] = sss - z.ybr[y+3][x+3] = sss -} - -func predFunc8DC(z *Decoder, y, x int) { - sum := uint32(8) - for i := 0; i < 8; i++ { - sum += uint32(z.ybr[y-1][x+i]) - } - for j := 0; j < 8; j++ { - sum += uint32(z.ybr[y+j][x-1]) - } - avg := uint8(sum / 16) - for j := 0; j < 8; j++ { - for i := 0; i < 8; i++ { - z.ybr[y+j][x+i] = avg - } - } -} - -func predFunc8TM(z *Decoder, y, x int) { - delta0 := -int32(z.ybr[y-1][x-1]) - for j := 0; j < 8; j++ { - delta1 := delta0 + int32(z.ybr[y+j][x-1]) - for i := 0; i < 8; i++ { - delta2 := delta1 + int32(z.ybr[y-1][x+i]) - z.ybr[y+j][x+i] = uint8(clip(delta2, 0, 255)) - } - } -} - -func predFunc8VE(z *Decoder, y, x int) { - for j := 0; j < 8; j++ { - for i := 0; i < 8; i++ { - z.ybr[y+j][x+i] = z.ybr[y-1][x+i] - } - } -} - -func predFunc8HE(z *Decoder, y, x int) { - for j := 0; j < 8; j++ { - for i := 0; i < 8; i++ { - z.ybr[y+j][x+i] = z.ybr[y+j][x-1] - } - } -} - -func predFunc8DCTop(z *Decoder, y, x int) { - sum := uint32(4) - for j := 0; j < 8; j++ { - sum += uint32(z.ybr[y+j][x-1]) - } - avg := uint8(sum / 8) - for j := 0; j < 8; j++ { - for i := 0; i < 8; i++ { - z.ybr[y+j][x+i] = avg - } - } -} - -func predFunc8DCLeft(z *Decoder, y, x int) { - sum := uint32(4) - for i := 0; i < 8; i++ { - sum += uint32(z.ybr[y-1][x+i]) - } - avg := uint8(sum / 8) - for j := 0; j < 8; j++ { - for i := 0; i < 8; i++ { - z.ybr[y+j][x+i] = avg - } - } -} - -func predFunc8DCTopLeft(z *Decoder, y, x int) { - for j := 0; j < 8; j++ { - for i := 0; i < 8; i++ { - z.ybr[y+j][x+i] = 0x80 - } - } -} - -func predFunc16DC(z *Decoder, y, x int) { - sum := uint32(16) - for i := 0; i < 16; i++ { - sum += uint32(z.ybr[y-1][x+i]) - } - for j := 0; j < 16; j++ { - sum += uint32(z.ybr[y+j][x-1]) - } - avg := uint8(sum / 32) - for j := 0; j < 16; j++ { - for i := 0; i < 16; i++ { - z.ybr[y+j][x+i] = avg - } - } -} - -func predFunc16TM(z *Decoder, y, x int) { - delta0 := -int32(z.ybr[y-1][x-1]) - for j := 0; j < 16; j++ { - delta1 := delta0 + int32(z.ybr[y+j][x-1]) - for i := 0; i < 16; i++ { - delta2 := delta1 + int32(z.ybr[y-1][x+i]) - z.ybr[y+j][x+i] = uint8(clip(delta2, 0, 255)) - } - } -} - -func predFunc16VE(z *Decoder, y, x int) { - for j := 0; j < 16; j++ { - for i := 0; i < 16; i++ { - z.ybr[y+j][x+i] = z.ybr[y-1][x+i] - } - } -} - -func predFunc16HE(z *Decoder, y, x int) { - for j := 0; j < 16; j++ { - for i := 0; i < 16; i++ { - z.ybr[y+j][x+i] = z.ybr[y+j][x-1] - } - } -} - -func predFunc16DCTop(z *Decoder, y, x int) { - sum := uint32(8) - for j := 0; j < 16; j++ { - sum += uint32(z.ybr[y+j][x-1]) - } - avg := uint8(sum / 16) - for j := 0; j < 16; j++ { - for i := 0; i < 16; i++ { - z.ybr[y+j][x+i] = avg - } - } -} - -func predFunc16DCLeft(z *Decoder, y, x int) { - sum := uint32(8) - for i := 0; i < 16; i++ { - sum += uint32(z.ybr[y-1][x+i]) - } - avg := uint8(sum / 16) - for j := 0; j < 16; j++ { - for i := 0; i < 16; i++ { - z.ybr[y+j][x+i] = avg - } - } -} - -func predFunc16DCTopLeft(z *Decoder, y, x int) { - for j := 0; j < 16; j++ { - for i := 0; i < 16; i++ { - z.ybr[y+j][x+i] = 0x80 - } - } -} diff --git a/vendor/golang.org/x/image/vp8/quant.go b/vendor/golang.org/x/image/vp8/quant.go deleted file mode 100644 index da43616..0000000 --- a/vendor/golang.org/x/image/vp8/quant.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8 - -// This file implements parsing the quantization factors. - -// quant are DC/AC quantization factors. -type quant struct { - y1 [2]uint16 - y2 [2]uint16 - uv [2]uint16 -} - -// clip clips x to the range [min, max] inclusive. -func clip(x, min, max int32) int32 { - if x < min { - return min - } - if x > max { - return max - } - return x -} - -// parseQuant parses the quantization factors, as specified in section 9.6. -func (d *Decoder) parseQuant() { - baseQ0 := d.fp.readUint(uniformProb, 7) - dqy1DC := d.fp.readOptionalInt(uniformProb, 4) - const dqy1AC = 0 - dqy2DC := d.fp.readOptionalInt(uniformProb, 4) - dqy2AC := d.fp.readOptionalInt(uniformProb, 4) - dquvDC := d.fp.readOptionalInt(uniformProb, 4) - dquvAC := d.fp.readOptionalInt(uniformProb, 4) - for i := 0; i < nSegment; i++ { - q := int32(baseQ0) - if d.segmentHeader.useSegment { - if d.segmentHeader.relativeDelta { - q += int32(d.segmentHeader.quantizer[i]) - } else { - q = int32(d.segmentHeader.quantizer[i]) - } - } - d.quant[i].y1[0] = dequantTableDC[clip(q+dqy1DC, 0, 127)] - d.quant[i].y1[1] = dequantTableAC[clip(q+dqy1AC, 0, 127)] - d.quant[i].y2[0] = dequantTableDC[clip(q+dqy2DC, 0, 127)] * 2 - d.quant[i].y2[1] = dequantTableAC[clip(q+dqy2AC, 0, 127)] * 155 / 100 - if d.quant[i].y2[1] < 8 { - d.quant[i].y2[1] = 8 - } - // The 117 is not a typo. The dequant_init function in the spec's Reference - // Decoder Source Code (http://tools.ietf.org/html/rfc6386#section-9.6 Page 145) - // says to clamp the LHS value at 132, which is equal to dequantTableDC[117]. - d.quant[i].uv[0] = dequantTableDC[clip(q+dquvDC, 0, 117)] - d.quant[i].uv[1] = dequantTableAC[clip(q+dquvAC, 0, 127)] - } -} - -// The dequantization tables are specified in section 14.1. -var ( - dequantTableDC = [128]uint16{ - 4, 5, 6, 7, 8, 9, 10, 10, - 11, 12, 13, 14, 15, 16, 17, 17, - 18, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 25, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, - 37, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, - 91, 93, 95, 96, 98, 100, 101, 102, - 104, 106, 108, 110, 112, 114, 116, 118, - 122, 124, 126, 128, 130, 132, 134, 136, - 138, 140, 143, 145, 148, 151, 154, 157, - } - dequantTableAC = [128]uint16{ - 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 60, - 62, 64, 66, 68, 70, 72, 74, 76, - 78, 80, 82, 84, 86, 88, 90, 92, - 94, 96, 98, 100, 102, 104, 106, 108, - 110, 112, 114, 116, 119, 122, 125, 128, - 131, 134, 137, 140, 143, 146, 149, 152, - 155, 158, 161, 164, 167, 170, 173, 177, - 181, 185, 189, 193, 197, 201, 205, 209, - 213, 217, 221, 225, 229, 234, 239, 245, - 249, 254, 259, 264, 269, 274, 279, 284, - } -) diff --git a/vendor/golang.org/x/image/vp8/reconstruct.go b/vendor/golang.org/x/image/vp8/reconstruct.go deleted file mode 100644 index c1cc4b5..0000000 --- a/vendor/golang.org/x/image/vp8/reconstruct.go +++ /dev/null @@ -1,442 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8 - -// This file implements decoding DCT/WHT residual coefficients and -// reconstructing YCbCr data equal to predicted values plus residuals. -// -// There are 1*16*16 + 2*8*8 + 1*4*4 coefficients per macroblock: -// - 1*16*16 luma DCT coefficients, -// - 2*8*8 chroma DCT coefficients, and -// - 1*4*4 luma WHT coefficients. -// Coefficients are read in lots of 16, and the later coefficients in each lot -// are often zero. -// -// The YCbCr data consists of 1*16*16 luma values and 2*8*8 chroma values, -// plus previously decoded values along the top and left borders. The combined -// values are laid out as a [1+16+1+8][32]uint8 so that vertically adjacent -// samples are 32 bytes apart. In detail, the layout is: -// -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// . . . . . . . a b b b b b b b b b b b b b b b b c c c c . . . . 0 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 1 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 2 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 3 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y c c c c . . . . 4 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 5 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 6 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 7 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y c c c c . . . . 8 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 9 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 10 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 11 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y c c c c . . . . 12 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 13 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 14 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 15 -// . . . . . . . d Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y . . . . . . . . 16 -// . . . . . . . e f f f f f f f f . . . . . . . g h h h h h h h h 17 -// . . . . . . . i B B B B B B B B . . . . . . . j R R R R R R R R 18 -// . . . . . . . i B B B B B B B B . . . . . . . j R R R R R R R R 19 -// . . . . . . . i B B B B B B B B . . . . . . . j R R R R R R R R 20 -// . . . . . . . i B B B B B B B B . . . . . . . j R R R R R R R R 21 -// . . . . . . . i B B B B B B B B . . . . . . . j R R R R R R R R 22 -// . . . . . . . i B B B B B B B B . . . . . . . j R R R R R R R R 23 -// . . . . . . . i B B B B B B B B . . . . . . . j R R R R R R R R 24 -// . . . . . . . i B B B B B B B B . . . . . . . j R R R R R R R R 25 -// -// Y, B and R are the reconstructed luma (Y) and chroma (B, R) values. -// The Y values are predicted (either as one 16x16 region or 16 4x4 regions) -// based on the row above's Y values (some combination of {abc} or {dYC}) and -// the column left's Y values (either {ad} or {bY}). Similarly, B and R values -// are predicted on the row above and column left of their respective 8x8 -// region: {efi} for B, {ghj} for R. -// -// For uppermost macroblocks (i.e. those with mby == 0), the {abcefgh} values -// are initialized to 0x81. Otherwise, they are copied from the bottom row of -// the macroblock above. The {c} values are then duplicated from row 0 to rows -// 4, 8 and 12 of the ybr workspace. -// Similarly, for leftmost macroblocks (i.e. those with mbx == 0), the {adeigj} -// values are initialized to 0x7f. Otherwise, they are copied from the right -// column of the macroblock to the left. -// For the top-left macroblock (with mby == 0 && mbx == 0), {aeg} is 0x81. -// -// When moving from one macroblock to the next horizontally, the {adeigj} -// values can simply be copied from the workspace to itself, shifted by 8 or -// 16 columns. When moving from one macroblock to the next vertically, -// filtering can occur and hence the row values have to be copied from the -// post-filtered image instead of the pre-filtered workspace. - -const ( - bCoeffBase = 1*16*16 + 0*8*8 - rCoeffBase = 1*16*16 + 1*8*8 - whtCoeffBase = 1*16*16 + 2*8*8 -) - -const ( - ybrYX = 8 - ybrYY = 1 - ybrBX = 8 - ybrBY = 18 - ybrRX = 24 - ybrRY = 18 -) - -// prepareYBR prepares the {abcdefghij} elements of ybr. -func (d *Decoder) prepareYBR(mbx, mby int) { - if mbx == 0 { - for y := 0; y < 17; y++ { - d.ybr[y][7] = 0x81 - } - for y := 17; y < 26; y++ { - d.ybr[y][7] = 0x81 - d.ybr[y][23] = 0x81 - } - } else { - for y := 0; y < 17; y++ { - d.ybr[y][7] = d.ybr[y][7+16] - } - for y := 17; y < 26; y++ { - d.ybr[y][7] = d.ybr[y][15] - d.ybr[y][23] = d.ybr[y][31] - } - } - if mby == 0 { - for x := 7; x < 28; x++ { - d.ybr[0][x] = 0x7f - } - for x := 7; x < 16; x++ { - d.ybr[17][x] = 0x7f - } - for x := 23; x < 32; x++ { - d.ybr[17][x] = 0x7f - } - } else { - for i := 0; i < 16; i++ { - d.ybr[0][8+i] = d.img.Y[(16*mby-1)*d.img.YStride+16*mbx+i] - } - for i := 0; i < 8; i++ { - d.ybr[17][8+i] = d.img.Cb[(8*mby-1)*d.img.CStride+8*mbx+i] - } - for i := 0; i < 8; i++ { - d.ybr[17][24+i] = d.img.Cr[(8*mby-1)*d.img.CStride+8*mbx+i] - } - if mbx == d.mbw-1 { - for i := 16; i < 20; i++ { - d.ybr[0][8+i] = d.img.Y[(16*mby-1)*d.img.YStride+16*mbx+15] - } - } else { - for i := 16; i < 20; i++ { - d.ybr[0][8+i] = d.img.Y[(16*mby-1)*d.img.YStride+16*mbx+i] - } - } - } - for y := 4; y < 16; y += 4 { - d.ybr[y][24] = d.ybr[0][24] - d.ybr[y][25] = d.ybr[0][25] - d.ybr[y][26] = d.ybr[0][26] - d.ybr[y][27] = d.ybr[0][27] - } -} - -// btou converts a bool to a 0/1 value. -func btou(b bool) uint8 { - if b { - return 1 - } - return 0 -} - -// pack packs four 0/1 values into four bits of a uint32. -func pack(x [4]uint8, shift int) uint32 { - u := uint32(x[0])<<0 | uint32(x[1])<<1 | uint32(x[2])<<2 | uint32(x[3])<<3 - return u << uint(shift) -} - -// unpack unpacks four 0/1 values from a four-bit value. -var unpack = [16][4]uint8{ - {0, 0, 0, 0}, - {1, 0, 0, 0}, - {0, 1, 0, 0}, - {1, 1, 0, 0}, - {0, 0, 1, 0}, - {1, 0, 1, 0}, - {0, 1, 1, 0}, - {1, 1, 1, 0}, - {0, 0, 0, 1}, - {1, 0, 0, 1}, - {0, 1, 0, 1}, - {1, 1, 0, 1}, - {0, 0, 1, 1}, - {1, 0, 1, 1}, - {0, 1, 1, 1}, - {1, 1, 1, 1}, -} - -var ( - // The mapping from 4x4 region position to band is specified in section 13.3. - bands = [17]uint8{0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 0} - // Category probabilties are specified in section 13.2. - // Decoding categories 1 and 2 are done inline. - cat3456 = [4][12]uint8{ - {173, 148, 140, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {176, 155, 140, 135, 0, 0, 0, 0, 0, 0, 0, 0}, - {180, 157, 141, 134, 130, 0, 0, 0, 0, 0, 0, 0}, - {254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0}, - } - // The zigzag order is: - // 0 1 5 6 - // 2 4 7 12 - // 3 8 11 13 - // 9 10 14 15 - zigzag = [16]uint8{0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15} -) - -// parseResiduals4 parses a 4x4 region of residual coefficients, as specified -// in section 13.3, and returns a 0/1 value indicating whether there was at -// least one non-zero coefficient. -// r is the partition to read bits from. -// plane and context describe which token probability table to use. context is -// either 0, 1 or 2, and equals how many of the macroblock left and macroblock -// above have non-zero coefficients. -// quant are the DC/AC quantization factors. -// skipFirstCoeff is whether the DC coefficient has already been parsed. -// coeffBase is the base index of d.coeff to write to. -func (d *Decoder) parseResiduals4(r *partition, plane int, context uint8, quant [2]uint16, skipFirstCoeff bool, coeffBase int) uint8 { - prob, n := &d.tokenProb[plane], 0 - if skipFirstCoeff { - n = 1 - } - p := prob[bands[n]][context] - if !r.readBit(p[0]) { - return 0 - } - for n != 16 { - n++ - if !r.readBit(p[1]) { - p = prob[bands[n]][0] - continue - } - var v uint32 - if !r.readBit(p[2]) { - v = 1 - p = prob[bands[n]][1] - } else { - if !r.readBit(p[3]) { - if !r.readBit(p[4]) { - v = 2 - } else { - v = 3 + r.readUint(p[5], 1) - } - } else if !r.readBit(p[6]) { - if !r.readBit(p[7]) { - // Category 1. - v = 5 + r.readUint(159, 1) - } else { - // Category 2. - v = 7 + 2*r.readUint(165, 1) + r.readUint(145, 1) - } - } else { - // Categories 3, 4, 5 or 6. - b1 := r.readUint(p[8], 1) - b0 := r.readUint(p[9+b1], 1) - cat := 2*b1 + b0 - tab := &cat3456[cat] - v = 0 - for i := 0; tab[i] != 0; i++ { - v *= 2 - v += r.readUint(tab[i], 1) - } - v += 3 + (8 << cat) - } - p = prob[bands[n]][2] - } - z := zigzag[n-1] - c := int32(v) * int32(quant[btou(z > 0)]) - if r.readBit(uniformProb) { - c = -c - } - d.coeff[coeffBase+int(z)] = int16(c) - if n == 16 || !r.readBit(p[0]) { - return 1 - } - } - return 1 -} - -// parseResiduals parses the residuals and returns whether inner loop filtering -// should be skipped for this macroblock. -func (d *Decoder) parseResiduals(mbx, mby int) (skip bool) { - partition := &d.op[mby&(d.nOP-1)] - plane := planeY1SansY2 - quant := &d.quant[d.segment] - - // Parse the DC coefficient of each 4x4 luma region. - if d.usePredY16 { - nz := d.parseResiduals4(partition, planeY2, d.leftMB.nzY16+d.upMB[mbx].nzY16, quant.y2, false, whtCoeffBase) - d.leftMB.nzY16 = nz - d.upMB[mbx].nzY16 = nz - d.inverseWHT16() - plane = planeY1WithY2 - } - - var ( - nzDC, nzAC [4]uint8 - nzDCMask, nzACMask uint32 - coeffBase int - ) - - // Parse the luma coefficients. - lnz := unpack[d.leftMB.nzMask&0x0f] - unz := unpack[d.upMB[mbx].nzMask&0x0f] - for y := 0; y < 4; y++ { - nz := lnz[y] - for x := 0; x < 4; x++ { - nz = d.parseResiduals4(partition, plane, nz+unz[x], quant.y1, d.usePredY16, coeffBase) - unz[x] = nz - nzAC[x] = nz - nzDC[x] = btou(d.coeff[coeffBase] != 0) - coeffBase += 16 - } - lnz[y] = nz - nzDCMask |= pack(nzDC, y*4) - nzACMask |= pack(nzAC, y*4) - } - lnzMask := pack(lnz, 0) - unzMask := pack(unz, 0) - - // Parse the chroma coefficients. - lnz = unpack[d.leftMB.nzMask>>4] - unz = unpack[d.upMB[mbx].nzMask>>4] - for c := 0; c < 4; c += 2 { - for y := 0; y < 2; y++ { - nz := lnz[y+c] - for x := 0; x < 2; x++ { - nz = d.parseResiduals4(partition, planeUV, nz+unz[x+c], quant.uv, false, coeffBase) - unz[x+c] = nz - nzAC[y*2+x] = nz - nzDC[y*2+x] = btou(d.coeff[coeffBase] != 0) - coeffBase += 16 - } - lnz[y+c] = nz - } - nzDCMask |= pack(nzDC, 16+c*2) - nzACMask |= pack(nzAC, 16+c*2) - } - lnzMask |= pack(lnz, 4) - unzMask |= pack(unz, 4) - - // Save decoder state. - d.leftMB.nzMask = uint8(lnzMask) - d.upMB[mbx].nzMask = uint8(unzMask) - d.nzDCMask = nzDCMask - d.nzACMask = nzACMask - - // Section 15.1 of the spec says that "Steps 2 and 4 [of the loop filter] - // are skipped... [if] there is no DCT coefficient coded for the whole - // macroblock." - return nzDCMask == 0 && nzACMask == 0 -} - -// reconstructMacroblock applies the predictor functions and adds the inverse- -// DCT transformed residuals to recover the YCbCr data. -func (d *Decoder) reconstructMacroblock(mbx, mby int) { - if d.usePredY16 { - p := checkTopLeftPred(mbx, mby, d.predY16) - predFunc16[p](d, 1, 8) - for j := 0; j < 4; j++ { - for i := 0; i < 4; i++ { - n := 4*j + i - y := 4*j + 1 - x := 4*i + 8 - mask := uint32(1) << uint(n) - if d.nzACMask&mask != 0 { - d.inverseDCT4(y, x, 16*n) - } else if d.nzDCMask&mask != 0 { - d.inverseDCT4DCOnly(y, x, 16*n) - } - } - } - } else { - for j := 0; j < 4; j++ { - for i := 0; i < 4; i++ { - n := 4*j + i - y := 4*j + 1 - x := 4*i + 8 - predFunc4[d.predY4[j][i]](d, y, x) - mask := uint32(1) << uint(n) - if d.nzACMask&mask != 0 { - d.inverseDCT4(y, x, 16*n) - } else if d.nzDCMask&mask != 0 { - d.inverseDCT4DCOnly(y, x, 16*n) - } - } - } - } - p := checkTopLeftPred(mbx, mby, d.predC8) - predFunc8[p](d, ybrBY, ybrBX) - if d.nzACMask&0x0f0000 != 0 { - d.inverseDCT8(ybrBY, ybrBX, bCoeffBase) - } else if d.nzDCMask&0x0f0000 != 0 { - d.inverseDCT8DCOnly(ybrBY, ybrBX, bCoeffBase) - } - predFunc8[p](d, ybrRY, ybrRX) - if d.nzACMask&0xf00000 != 0 { - d.inverseDCT8(ybrRY, ybrRX, rCoeffBase) - } else if d.nzDCMask&0xf00000 != 0 { - d.inverseDCT8DCOnly(ybrRY, ybrRX, rCoeffBase) - } -} - -// reconstruct reconstructs one macroblock and returns whether inner loop -// filtering should be skipped for it. -func (d *Decoder) reconstruct(mbx, mby int) (skip bool) { - if d.segmentHeader.updateMap { - if !d.fp.readBit(d.segmentHeader.prob[0]) { - d.segment = int(d.fp.readUint(d.segmentHeader.prob[1], 1)) - } else { - d.segment = int(d.fp.readUint(d.segmentHeader.prob[2], 1)) + 2 - } - } - if d.useSkipProb { - skip = d.fp.readBit(d.skipProb) - } - // Prepare the workspace. - for i := range d.coeff { - d.coeff[i] = 0 - } - d.prepareYBR(mbx, mby) - // Parse the predictor modes. - d.usePredY16 = d.fp.readBit(145) - if d.usePredY16 { - d.parsePredModeY16(mbx) - } else { - d.parsePredModeY4(mbx) - } - d.parsePredModeC8() - // Parse the residuals. - if !skip { - skip = d.parseResiduals(mbx, mby) - } else { - if d.usePredY16 { - d.leftMB.nzY16 = 0 - d.upMB[mbx].nzY16 = 0 - } - d.leftMB.nzMask = 0 - d.upMB[mbx].nzMask = 0 - d.nzDCMask = 0 - d.nzACMask = 0 - } - // Reconstruct the YCbCr data and copy it to the image. - d.reconstructMacroblock(mbx, mby) - for i, y := (mby*d.img.YStride+mbx)*16, 0; y < 16; i, y = i+d.img.YStride, y+1 { - copy(d.img.Y[i:i+16], d.ybr[ybrYY+y][ybrYX:ybrYX+16]) - } - for i, y := (mby*d.img.CStride+mbx)*8, 0; y < 8; i, y = i+d.img.CStride, y+1 { - copy(d.img.Cb[i:i+8], d.ybr[ybrBY+y][ybrBX:ybrBX+8]) - copy(d.img.Cr[i:i+8], d.ybr[ybrRY+y][ybrRX:ybrRX+8]) - } - return skip -} diff --git a/vendor/golang.org/x/image/vp8/token.go b/vendor/golang.org/x/image/vp8/token.go deleted file mode 100644 index da99cf0..0000000 --- a/vendor/golang.org/x/image/vp8/token.go +++ /dev/null @@ -1,381 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8 - -// This file contains token probabilities for decoding DCT/WHT coefficients, as -// specified in chapter 13. - -func (d *Decoder) parseTokenProb() { - for i := range d.tokenProb { - for j := range d.tokenProb[i] { - for k := range d.tokenProb[i][j] { - for l := range d.tokenProb[i][j][k] { - if d.fp.readBit(tokenProbUpdateProb[i][j][k][l]) { - d.tokenProb[i][j][k][l] = uint8(d.fp.readUint(uniformProb, 8)) - } - } - } - } - } -} - -// The plane enumeration is specified in section 13.3. -const ( - planeY1WithY2 = iota - planeY2 - planeUV - planeY1SansY2 - nPlane -) - -const ( - nBand = 8 - nContext = 3 - nProb = 11 -) - -// Token probability update probabilities are specified in section 13.4. -var tokenProbUpdateProb = [nPlane][nBand][nContext][nProb]uint8{ - { - { - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255}, - {249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255}, - {234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255}, - {250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255}, - {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - }, - { - { - {217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255}, - {234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255}, - }, - { - {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255}, - {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - }, - { - { - {186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255}, - {234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255}, - {251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255}, - }, - { - {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - }, - { - { - {248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255}, - {248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255}, - {246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255}, - {252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255}, - {248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255}, - {253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255}, - {252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255}, - {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - { - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, - }, - }, -} - -// Default token probabilities are specified in section 13.5. -var defaultTokenProb = [nPlane][nBand][nContext][nProb]uint8{ - { - { - {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, - {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, - {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, - }, - { - {253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128}, - {189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128}, - {106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128}, - }, - { - {1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128}, - {181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128}, - {78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128}, - }, - { - {1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128}, - {184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128}, - {77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128}, - }, - { - {1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128}, - {170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128}, - {37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128}, - }, - { - {1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128}, - {207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128}, - {102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128}, - }, - { - {1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128}, - {177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128}, - {80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128}, - }, - { - {1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - {246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - {255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, - }, - }, - { - { - {198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62}, - {131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1}, - {68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128}, - }, - { - {1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128}, - {184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128}, - {81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128}, - }, - { - {1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128}, - {99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128}, - {23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128}, - }, - { - {1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128}, - {109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128}, - {44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128}, - }, - { - {1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128}, - {94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128}, - {22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128}, - }, - { - {1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128}, - {124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128}, - {35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128}, - }, - { - {1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128}, - {121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128}, - {45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128}, - }, - { - {1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128}, - {203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128}, - {137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128}, - }, - }, - { - { - {253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128}, - {175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128}, - {73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128}, - }, - { - {1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128}, - {239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128}, - {155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128}, - }, - { - {1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128}, - {201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128}, - {69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128}, - }, - { - {1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128}, - {223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128}, - {141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128}, - }, - { - {1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128}, - {190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128}, - {149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - }, - { - {1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - {247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - {240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - }, - { - {1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128}, - {213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128}, - {55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - }, - { - {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, - {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, - {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, - }, - }, - { - { - {202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255}, - {126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128}, - {61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128}, - }, - { - {1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128}, - {166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128}, - {39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128}, - }, - { - {1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128}, - {124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128}, - {24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128}, - }, - { - {1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128}, - {149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128}, - {28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128}, - }, - { - {1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128}, - {123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128}, - {20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128}, - }, - { - {1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128}, - {168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128}, - {47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128}, - }, - { - {1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128}, - {141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128}, - {42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128}, - }, - { - {1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - {244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - {238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128}, - }, - }, -} diff --git a/vendor/golang.org/x/image/vp8l/decode.go b/vendor/golang.org/x/image/vp8l/decode.go deleted file mode 100644 index 4319487..0000000 --- a/vendor/golang.org/x/image/vp8l/decode.go +++ /dev/null @@ -1,603 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package vp8l implements a decoder for the VP8L lossless image format. -// -// The VP8L specification is at: -// https://developers.google.com/speed/webp/docs/riff_container -package vp8l // import "golang.org/x/image/vp8l" - -import ( - "bufio" - "errors" - "image" - "image/color" - "io" -) - -var ( - errInvalidCodeLengths = errors.New("vp8l: invalid code lengths") - errInvalidHuffmanTree = errors.New("vp8l: invalid Huffman tree") -) - -// colorCacheMultiplier is the multiplier used for the color cache hash -// function, specified in section 4.2.3. -const colorCacheMultiplier = 0x1e35a7bd - -// distanceMapTable is the look-up table for distanceMap. -var distanceMapTable = [120]uint8{ - 0x18, 0x07, 0x17, 0x19, 0x28, 0x06, 0x27, 0x29, 0x16, 0x1a, - 0x26, 0x2a, 0x38, 0x05, 0x37, 0x39, 0x15, 0x1b, 0x36, 0x3a, - 0x25, 0x2b, 0x48, 0x04, 0x47, 0x49, 0x14, 0x1c, 0x35, 0x3b, - 0x46, 0x4a, 0x24, 0x2c, 0x58, 0x45, 0x4b, 0x34, 0x3c, 0x03, - 0x57, 0x59, 0x13, 0x1d, 0x56, 0x5a, 0x23, 0x2d, 0x44, 0x4c, - 0x55, 0x5b, 0x33, 0x3d, 0x68, 0x02, 0x67, 0x69, 0x12, 0x1e, - 0x66, 0x6a, 0x22, 0x2e, 0x54, 0x5c, 0x43, 0x4d, 0x65, 0x6b, - 0x32, 0x3e, 0x78, 0x01, 0x77, 0x79, 0x53, 0x5d, 0x11, 0x1f, - 0x64, 0x6c, 0x42, 0x4e, 0x76, 0x7a, 0x21, 0x2f, 0x75, 0x7b, - 0x31, 0x3f, 0x63, 0x6d, 0x52, 0x5e, 0x00, 0x74, 0x7c, 0x41, - 0x4f, 0x10, 0x20, 0x62, 0x6e, 0x30, 0x73, 0x7d, 0x51, 0x5f, - 0x40, 0x72, 0x7e, 0x61, 0x6f, 0x50, 0x71, 0x7f, 0x60, 0x70, -} - -// distanceMap maps a LZ77 backwards reference distance to a two-dimensional -// pixel offset, specified in section 4.2.2. -func distanceMap(w int32, code uint32) int32 { - if int32(code) > int32(len(distanceMapTable)) { - return int32(code) - int32(len(distanceMapTable)) - } - distCode := int32(distanceMapTable[code-1]) - yOffset := distCode >> 4 - xOffset := 8 - distCode&0xf - if d := yOffset*w + xOffset; d >= 1 { - return d - } - return 1 -} - -// decoder holds the bit-stream for a VP8L image. -type decoder struct { - r io.ByteReader - bits uint32 - nBits uint32 -} - -// read reads the next n bits from the decoder's bit-stream. -func (d *decoder) read(n uint32) (uint32, error) { - for d.nBits < n { - c, err := d.r.ReadByte() - if err != nil { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - return 0, err - } - d.bits |= uint32(c) << d.nBits - d.nBits += 8 - } - u := d.bits & (1<>= n - d.nBits -= n - return u, nil -} - -// decodeTransform decodes the next transform and the width of the image after -// transformation (or equivalently, before inverse transformation), specified -// in section 3. -func (d *decoder) decodeTransform(w int32, h int32) (t transform, newWidth int32, err error) { - t.oldWidth = w - t.transformType, err = d.read(2) - if err != nil { - return transform{}, 0, err - } - switch t.transformType { - case transformTypePredictor, transformTypeCrossColor: - t.bits, err = d.read(3) - if err != nil { - return transform{}, 0, err - } - t.bits += 2 - t.pix, err = d.decodePix(nTiles(w, t.bits), nTiles(h, t.bits), 0, false) - if err != nil { - return transform{}, 0, err - } - case transformTypeSubtractGreen: - // No-op. - case transformTypeColorIndexing: - nColors, err := d.read(8) - if err != nil { - return transform{}, 0, err - } - nColors++ - t.bits = 0 - switch { - case nColors <= 2: - t.bits = 3 - case nColors <= 4: - t.bits = 2 - case nColors <= 16: - t.bits = 1 - } - w = nTiles(w, t.bits) - pix, err := d.decodePix(int32(nColors), 1, 4*256, false) - if err != nil { - return transform{}, 0, err - } - for p := 4; p < len(pix); p += 4 { - pix[p+0] += pix[p-4] - pix[p+1] += pix[p-3] - pix[p+2] += pix[p-2] - pix[p+3] += pix[p-1] - } - // The spec says that "if the index is equal or larger than color_table_size, - // the argb color value should be set to 0x00000000 (transparent black)." - // We re-slice up to 256 4-byte pixels. - t.pix = pix[:4*256] - } - return t, w, nil -} - -// repeatsCodeLength is the minimum code length for repeated codes. -const repeatsCodeLength = 16 - -// These magic numbers are specified at the end of section 5.2.2. -// The 3-length arrays apply to code lengths >= repeatsCodeLength. -var ( - codeLengthCodeOrder = [19]uint8{ - 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - } - repeatBits = [3]uint8{2, 3, 7} - repeatOffsets = [3]uint8{3, 3, 11} -) - -// decodeCodeLengths decodes a Huffman tree's code lengths which are themselves -// encoded via a Huffman tree, specified in section 5.2.2. -func (d *decoder) decodeCodeLengths(dst []uint32, codeLengthCodeLengths []uint32) error { - h := hTree{} - if err := h.build(codeLengthCodeLengths); err != nil { - return err - } - - maxSymbol := len(dst) - useLength, err := d.read(1) - if err != nil { - return err - } - if useLength != 0 { - n, err := d.read(3) - if err != nil { - return err - } - n = 2 + 2*n - ms, err := d.read(n) - if err != nil { - return err - } - maxSymbol = int(ms) + 2 - if maxSymbol > len(dst) { - return errInvalidCodeLengths - } - } - - // The spec says that "if code 16 [meaning repeat] is used before - // a non-zero value has been emitted, a value of 8 is repeated." - prevCodeLength := uint32(8) - - for symbol := 0; symbol < len(dst); { - if maxSymbol == 0 { - break - } - maxSymbol-- - codeLength, err := h.next(d) - if err != nil { - return err - } - if codeLength < repeatsCodeLength { - dst[symbol] = codeLength - symbol++ - if codeLength != 0 { - prevCodeLength = codeLength - } - continue - } - - repeat, err := d.read(uint32(repeatBits[codeLength-repeatsCodeLength])) - if err != nil { - return err - } - repeat += uint32(repeatOffsets[codeLength-repeatsCodeLength]) - if symbol+int(repeat) > len(dst) { - return errInvalidCodeLengths - } - // A code length of 16 repeats the previous non-zero code. - // A code length of 17 or 18 repeats zeroes. - cl := uint32(0) - if codeLength == 16 { - cl = prevCodeLength - } - for ; repeat > 0; repeat-- { - dst[symbol] = cl - symbol++ - } - } - return nil -} - -// decodeHuffmanTree decodes a Huffman tree into h. -func (d *decoder) decodeHuffmanTree(h *hTree, alphabetSize uint32) error { - useSimple, err := d.read(1) - if err != nil { - return err - } - if useSimple != 0 { - nSymbols, err := d.read(1) - if err != nil { - return err - } - nSymbols++ - firstSymbolLengthCode, err := d.read(1) - if err != nil { - return err - } - firstSymbolLengthCode = 7*firstSymbolLengthCode + 1 - var symbols [2]uint32 - symbols[0], err = d.read(firstSymbolLengthCode) - if err != nil { - return err - } - if nSymbols == 2 { - symbols[1], err = d.read(8) - if err != nil { - return err - } - } - return h.buildSimple(nSymbols, symbols, alphabetSize) - } - - nCodes, err := d.read(4) - if err != nil { - return err - } - nCodes += 4 - if int(nCodes) > len(codeLengthCodeOrder) { - return errInvalidHuffmanTree - } - codeLengthCodeLengths := [len(codeLengthCodeOrder)]uint32{} - for i := uint32(0); i < nCodes; i++ { - codeLengthCodeLengths[codeLengthCodeOrder[i]], err = d.read(3) - if err != nil { - return err - } - } - codeLengths := make([]uint32, alphabetSize) - if err = d.decodeCodeLengths(codeLengths, codeLengthCodeLengths[:]); err != nil { - return err - } - return h.build(codeLengths) -} - -const ( - huffGreen = 0 - huffRed = 1 - huffBlue = 2 - huffAlpha = 3 - huffDistance = 4 - nHuff = 5 -) - -// hGroup is an array of 5 Huffman trees. -type hGroup [nHuff]hTree - -// decodeHuffmanGroups decodes the one or more hGroups used to decode the pixel -// data. If one hGroup is used for the entire image, then hPix and hBits will -// be zero. If more than one hGroup is used, then hPix contains the meta-image -// that maps tiles to hGroup index, and hBits contains the log-2 tile size. -func (d *decoder) decodeHuffmanGroups(w int32, h int32, topLevel bool, ccBits uint32) ( - hGroups []hGroup, hPix []byte, hBits uint32, err error) { - - maxHGroupIndex := 0 - if topLevel { - useMeta, err := d.read(1) - if err != nil { - return nil, nil, 0, err - } - if useMeta != 0 { - hBits, err = d.read(3) - if err != nil { - return nil, nil, 0, err - } - hBits += 2 - hPix, err = d.decodePix(nTiles(w, hBits), nTiles(h, hBits), 0, false) - if err != nil { - return nil, nil, 0, err - } - for p := 0; p < len(hPix); p += 4 { - i := int(hPix[p])<<8 | int(hPix[p+1]) - if maxHGroupIndex < i { - maxHGroupIndex = i - } - } - } - } - hGroups = make([]hGroup, maxHGroupIndex+1) - for i := range hGroups { - for j, alphabetSize := range alphabetSizes { - if j == 0 && ccBits > 0 { - alphabetSize += 1 << ccBits - } - if err := d.decodeHuffmanTree(&hGroups[i][j], alphabetSize); err != nil { - return nil, nil, 0, err - } - } - } - return hGroups, hPix, hBits, nil -} - -const ( - nLiteralCodes = 256 - nLengthCodes = 24 - nDistanceCodes = 40 -) - -var alphabetSizes = [nHuff]uint32{ - nLiteralCodes + nLengthCodes, - nLiteralCodes, - nLiteralCodes, - nLiteralCodes, - nDistanceCodes, -} - -// decodePix decodes pixel data, specified in section 5.2.2. -func (d *decoder) decodePix(w int32, h int32, minCap int32, topLevel bool) ([]byte, error) { - // Decode the color cache parameters. - ccBits, ccShift, ccEntries := uint32(0), uint32(0), ([]uint32)(nil) - useColorCache, err := d.read(1) - if err != nil { - return nil, err - } - if useColorCache != 0 { - ccBits, err = d.read(4) - if err != nil { - return nil, err - } - if ccBits < 1 || 11 < ccBits { - return nil, errors.New("vp8l: invalid color cache parameters") - } - ccShift = 32 - ccBits - ccEntries = make([]uint32, 1<>hBits) + (x >> hBits)) - hg = &hGroups[uint32(hPix[i])<<8|uint32(hPix[i+1])] - } - - green, err := hg[huffGreen].next(d) - if err != nil { - return nil, err - } - switch { - case green < nLiteralCodes: - // We have a literal pixel. - red, err := hg[huffRed].next(d) - if err != nil { - return nil, err - } - blue, err := hg[huffBlue].next(d) - if err != nil { - return nil, err - } - alpha, err := hg[huffAlpha].next(d) - if err != nil { - return nil, err - } - pix[p+0] = uint8(red) - pix[p+1] = uint8(green) - pix[p+2] = uint8(blue) - pix[p+3] = uint8(alpha) - p += 4 - - x++ - if x == w { - x, y = 0, y+1 - } - lookupHG = hMask != 0 && x&hMask == 0 - - case green < nLiteralCodes+nLengthCodes: - // We have a LZ77 backwards reference. - length, err := d.lz77Param(green - nLiteralCodes) - if err != nil { - return nil, err - } - distSym, err := hg[huffDistance].next(d) - if err != nil { - return nil, err - } - distCode, err := d.lz77Param(distSym) - if err != nil { - return nil, err - } - dist := distanceMap(w, distCode) - pEnd := p + 4*int(length) - q := p - 4*int(dist) - qEnd := pEnd - 4*int(dist) - if p < 0 || len(pix) < pEnd || q < 0 || len(pix) < qEnd { - return nil, errors.New("vp8l: invalid LZ77 parameters") - } - for ; p < pEnd; p, q = p+1, q+1 { - pix[p] = pix[q] - } - - x += int32(length) - for x >= w { - x, y = x-w, y+1 - } - lookupHG = hMask != 0 - - default: - // We have a color cache lookup. First, insert previous pixels - // into the cache. Note that VP8L assumes ARGB order, but the - // Go image.RGBA type is in RGBA order. - for ; cachedP < p; cachedP += 4 { - argb := uint32(pix[cachedP+0])<<16 | - uint32(pix[cachedP+1])<<8 | - uint32(pix[cachedP+2])<<0 | - uint32(pix[cachedP+3])<<24 - ccEntries[(argb*colorCacheMultiplier)>>ccShift] = argb - } - green -= nLiteralCodes + nLengthCodes - if int(green) >= len(ccEntries) { - return nil, errors.New("vp8l: invalid color cache index") - } - argb := ccEntries[green] - pix[p+0] = uint8(argb >> 16) - pix[p+1] = uint8(argb >> 8) - pix[p+2] = uint8(argb >> 0) - pix[p+3] = uint8(argb >> 24) - p += 4 - - x++ - if x == w { - x, y = 0, y+1 - } - lookupHG = hMask != 0 && x&hMask == 0 - } - } - return pix, nil -} - -// lz77Param returns the next LZ77 parameter: a length or a distance, specified -// in section 4.2.2. -func (d *decoder) lz77Param(symbol uint32) (uint32, error) { - if symbol < 4 { - return symbol + 1, nil - } - extraBits := (symbol - 2) >> 1 - offset := (2 + symbol&1) << extraBits - n, err := d.read(extraBits) - if err != nil { - return 0, err - } - return offset + n + 1, nil -} - -// decodeHeader decodes the VP8L header from r. -func decodeHeader(r io.Reader) (d *decoder, w int32, h int32, err error) { - rr, ok := r.(io.ByteReader) - if !ok { - rr = bufio.NewReader(r) - } - d = &decoder{r: rr} - magic, err := d.read(8) - if err != nil { - return nil, 0, 0, err - } - if magic != 0x2f { - return nil, 0, 0, errors.New("vp8l: invalid header") - } - width, err := d.read(14) - if err != nil { - return nil, 0, 0, err - } - width++ - height, err := d.read(14) - if err != nil { - return nil, 0, 0, err - } - height++ - _, err = d.read(1) // Read and ignore the hasAlpha hint. - if err != nil { - return nil, 0, 0, err - } - version, err := d.read(3) - if err != nil { - return nil, 0, 0, err - } - if version != 0 { - return nil, 0, 0, errors.New("vp8l: invalid version") - } - return d, int32(width), int32(height), nil -} - -// DecodeConfig decodes the color model and dimensions of a VP8L image from r. -func DecodeConfig(r io.Reader) (image.Config, error) { - _, w, h, err := decodeHeader(r) - if err != nil { - return image.Config{}, err - } - return image.Config{ - ColorModel: color.NRGBAModel, - Width: int(w), - Height: int(h), - }, nil -} - -// Decode decodes a VP8L image from r. -func Decode(r io.Reader) (image.Image, error) { - d, w, h, err := decodeHeader(r) - if err != nil { - return nil, err - } - // Decode the transforms. - var ( - nTransforms int - transforms [nTransformTypes]transform - transformsSeen [nTransformTypes]bool - originalW = w - ) - for { - more, err := d.read(1) - if err != nil { - return nil, err - } - if more == 0 { - break - } - var t transform - t, w, err = d.decodeTransform(w, h) - if err != nil { - return nil, err - } - if transformsSeen[t.transformType] { - return nil, errors.New("vp8l: repeated transform") - } - transformsSeen[t.transformType] = true - transforms[nTransforms] = t - nTransforms++ - } - // Decode the transformed pixels. - pix, err := d.decodePix(w, h, 0, true) - if err != nil { - return nil, err - } - // Apply the inverse transformations. - for i := nTransforms - 1; i >= 0; i-- { - t := &transforms[i] - pix = inverseTransforms[t.transformType](t, pix, h) - } - return &image.NRGBA{ - Pix: pix, - Stride: 4 * int(originalW), - Rect: image.Rect(0, 0, int(originalW), int(h)), - }, nil -} diff --git a/vendor/golang.org/x/image/vp8l/huffman.go b/vendor/golang.org/x/image/vp8l/huffman.go deleted file mode 100644 index 36368a8..0000000 --- a/vendor/golang.org/x/image/vp8l/huffman.go +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8l - -import ( - "io" -) - -// reverseBits reverses the bits in a byte. -var reverseBits = [256]uint8{ - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, -} - -// hNode is a node in a Huffman tree. -type hNode struct { - // symbol is the symbol held by this node. - symbol uint32 - // children, if positive, is the hTree.nodes index of the first of - // this node's two children. Zero means an uninitialized node, - // and -1 means a leaf node. - children int32 -} - -const leafNode = -1 - -// lutSize is the log-2 size of an hTree's look-up table. -const lutSize, lutMask = 7, 1<<7 - 1 - -// hTree is a Huffman tree. -type hTree struct { - // nodes are the nodes of the Huffman tree. During construction, - // len(nodes) grows from 1 up to cap(nodes) by steps of two. - // After construction, len(nodes) == cap(nodes), and both equal - // 2*theNumberOfSymbols - 1. - nodes []hNode - // lut is a look-up table for walking the nodes. The x in lut[x] is - // the next lutSize bits in the bit-stream. The low 8 bits of lut[x] - // equals 1 plus the number of bits in the next code, or 0 if the - // next code requires more than lutSize bits. The high 24 bits are: - // - the symbol, if the code requires lutSize or fewer bits, or - // - the hTree.nodes index to start the tree traversal from, if - // the next code requires more than lutSize bits. - lut [1 << lutSize]uint32 -} - -// insert inserts into the hTree a symbol whose encoding is the least -// significant codeLength bits of code. -func (h *hTree) insert(symbol uint32, code uint32, codeLength uint32) error { - if symbol > 0xffff || codeLength > 0xfe { - return errInvalidHuffmanTree - } - baseCode := uint32(0) - if codeLength > lutSize { - baseCode = uint32(reverseBits[(code>>(codeLength-lutSize))&0xff]) >> (8 - lutSize) - } else { - baseCode = uint32(reverseBits[code&0xff]) >> (8 - codeLength) - for i := 0; i < 1<<(lutSize-codeLength); i++ { - h.lut[baseCode|uint32(i)< 0; { - codeLength-- - if int(n) > len(h.nodes) { - return errInvalidHuffmanTree - } - switch h.nodes[n].children { - case leafNode: - return errInvalidHuffmanTree - case 0: - if len(h.nodes) == cap(h.nodes) { - return errInvalidHuffmanTree - } - // Create two empty child nodes. - h.nodes[n].children = int32(len(h.nodes)) - h.nodes = h.nodes[:len(h.nodes)+2] - } - n = uint32(h.nodes[n].children) + 1&(code>>codeLength) - jump-- - if jump == 0 && h.lut[baseCode] == 0 { - h.lut[baseCode] = n << 8 - } - } - - switch h.nodes[n].children { - case leafNode: - // No-op. - case 0: - // Turn the uninitialized node into a leaf. - h.nodes[n].children = leafNode - default: - return errInvalidHuffmanTree - } - h.nodes[n].symbol = symbol - return nil -} - -// codeLengthsToCodes returns the canonical Huffman codes implied by the -// sequence of code lengths. -func codeLengthsToCodes(codeLengths []uint32) ([]uint32, error) { - maxCodeLength := uint32(0) - for _, cl := range codeLengths { - if maxCodeLength < cl { - maxCodeLength = cl - } - } - const maxAllowedCodeLength = 15 - if len(codeLengths) == 0 || maxCodeLength > maxAllowedCodeLength { - return nil, errInvalidHuffmanTree - } - histogram := [maxAllowedCodeLength + 1]uint32{} - for _, cl := range codeLengths { - histogram[cl]++ - } - currCode, nextCodes := uint32(0), [maxAllowedCodeLength + 1]uint32{} - for cl := 1; cl < len(nextCodes); cl++ { - currCode = (currCode + histogram[cl-1]) << 1 - nextCodes[cl] = currCode - } - codes := make([]uint32, len(codeLengths)) - for symbol, cl := range codeLengths { - if cl > 0 { - codes[symbol] = nextCodes[cl] - nextCodes[cl]++ - } - } - return codes, nil -} - -// build builds a canonical Huffman tree from the given code lengths. -func (h *hTree) build(codeLengths []uint32) error { - // Calculate the number of symbols. - var nSymbols, lastSymbol uint32 - for symbol, cl := range codeLengths { - if cl != 0 { - nSymbols++ - lastSymbol = uint32(symbol) - } - } - if nSymbols == 0 { - return errInvalidHuffmanTree - } - h.nodes = make([]hNode, 1, 2*nSymbols-1) - // Handle the trivial case. - if nSymbols == 1 { - if len(codeLengths) <= int(lastSymbol) { - return errInvalidHuffmanTree - } - return h.insert(lastSymbol, 0, 0) - } - // Handle the non-trivial case. - codes, err := codeLengthsToCodes(codeLengths) - if err != nil { - return err - } - for symbol, cl := range codeLengths { - if cl > 0 { - if err := h.insert(uint32(symbol), codes[symbol], cl); err != nil { - return err - } - } - } - return nil -} - -// buildSimple builds a Huffman tree with 1 or 2 symbols. -func (h *hTree) buildSimple(nSymbols uint32, symbols [2]uint32, alphabetSize uint32) error { - h.nodes = make([]hNode, 1, 2*nSymbols-1) - for i := uint32(0); i < nSymbols; i++ { - if symbols[i] >= alphabetSize { - return errInvalidHuffmanTree - } - if err := h.insert(symbols[i], i, nSymbols-1); err != nil { - return err - } - } - return nil -} - -// next returns the next Huffman-encoded symbol from the bit-stream d. -func (h *hTree) next(d *decoder) (uint32, error) { - var n uint32 - // Read enough bits so that we can use the look-up table. - if d.nBits < lutSize { - c, err := d.r.ReadByte() - if err != nil { - if err == io.EOF { - // There are no more bytes of data, but we may still be able - // to read the next symbol out of the previously read bits. - goto slowPath - } - return 0, err - } - d.bits |= uint32(c) << d.nBits - d.nBits += 8 - } - // Use the look-up table. - n = h.lut[d.bits&lutMask] - if b := n & 0xff; b != 0 { - b-- - d.bits >>= b - d.nBits -= b - return n >> 8, nil - } - n >>= 8 - d.bits >>= lutSize - d.nBits -= lutSize - -slowPath: - for h.nodes[n].children != leafNode { - if d.nBits == 0 { - c, err := d.r.ReadByte() - if err != nil { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - return 0, err - } - d.bits = uint32(c) - d.nBits = 8 - } - n = uint32(h.nodes[n].children) + 1&d.bits - d.bits >>= 1 - d.nBits-- - } - return h.nodes[n].symbol, nil -} diff --git a/vendor/golang.org/x/image/vp8l/transform.go b/vendor/golang.org/x/image/vp8l/transform.go deleted file mode 100644 index 06543da..0000000 --- a/vendor/golang.org/x/image/vp8l/transform.go +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package vp8l - -// This file deals with image transforms, specified in section 3. - -// nTiles returns the number of tiles needed to cover size pixels, where each -// tile's side is 1<> bits -} - -const ( - transformTypePredictor = 0 - transformTypeCrossColor = 1 - transformTypeSubtractGreen = 2 - transformTypeColorIndexing = 3 - nTransformTypes = 4 -) - -// transform holds the parameters for an invertible transform. -type transform struct { - // transformType is the type of the transform. - transformType uint32 - // oldWidth is the width of the image before transformation (or - // equivalently, after inverse transformation). The color-indexing - // transform can reduce the width. For example, a 50-pixel-wide - // image that only needs 4 bits (half a byte) per color index can - // be transformed into a 25-pixel-wide image. - oldWidth int32 - // bits is the log-2 size of the transform's tiles, for the predictor - // and cross-color transforms. 8>>bits is the number of bits per - // color index, for the color-index transform. - bits uint32 - // pix is the tile values, for the predictor and cross-color - // transforms, and the color palette, for the color-index transform. - pix []byte -} - -var inverseTransforms = [nTransformTypes]func(*transform, []byte, int32) []byte{ - transformTypePredictor: inversePredictor, - transformTypeCrossColor: inverseCrossColor, - transformTypeSubtractGreen: inverseSubtractGreen, - transformTypeColorIndexing: inverseColorIndexing, -} - -func inversePredictor(t *transform, pix []byte, h int32) []byte { - if t.oldWidth == 0 || h == 0 { - return pix - } - // The first pixel's predictor is mode 0 (opaque black). - pix[3] += 0xff - p, mask := int32(4), int32(1)<> t.bits) * tilesPerRow - predictorMode := t.pix[q+1] & 0x0f - q += 4 - for x := int32(1); x < t.oldWidth; x++ { - if x&mask == 0 { - predictorMode = t.pix[q+1] & 0x0f - q += 4 - } - switch predictorMode { - case 0: // Opaque black. - pix[p+3] += 0xff - - case 1: // L. - pix[p+0] += pix[p-4] - pix[p+1] += pix[p-3] - pix[p+2] += pix[p-2] - pix[p+3] += pix[p-1] - - case 2: // T. - pix[p+0] += pix[top+0] - pix[p+1] += pix[top+1] - pix[p+2] += pix[top+2] - pix[p+3] += pix[top+3] - - case 3: // TR. - pix[p+0] += pix[top+4] - pix[p+1] += pix[top+5] - pix[p+2] += pix[top+6] - pix[p+3] += pix[top+7] - - case 4: // TL. - pix[p+0] += pix[top-4] - pix[p+1] += pix[top-3] - pix[p+2] += pix[top-2] - pix[p+3] += pix[top-1] - - case 5: // Average2(Average2(L, TR), T). - pix[p+0] += avg2(avg2(pix[p-4], pix[top+4]), pix[top+0]) - pix[p+1] += avg2(avg2(pix[p-3], pix[top+5]), pix[top+1]) - pix[p+2] += avg2(avg2(pix[p-2], pix[top+6]), pix[top+2]) - pix[p+3] += avg2(avg2(pix[p-1], pix[top+7]), pix[top+3]) - - case 6: // Average2(L, TL). - pix[p+0] += avg2(pix[p-4], pix[top-4]) - pix[p+1] += avg2(pix[p-3], pix[top-3]) - pix[p+2] += avg2(pix[p-2], pix[top-2]) - pix[p+3] += avg2(pix[p-1], pix[top-1]) - - case 7: // Average2(L, T). - pix[p+0] += avg2(pix[p-4], pix[top+0]) - pix[p+1] += avg2(pix[p-3], pix[top+1]) - pix[p+2] += avg2(pix[p-2], pix[top+2]) - pix[p+3] += avg2(pix[p-1], pix[top+3]) - - case 8: // Average2(TL, T). - pix[p+0] += avg2(pix[top-4], pix[top+0]) - pix[p+1] += avg2(pix[top-3], pix[top+1]) - pix[p+2] += avg2(pix[top-2], pix[top+2]) - pix[p+3] += avg2(pix[top-1], pix[top+3]) - - case 9: // Average2(T, TR). - pix[p+0] += avg2(pix[top+0], pix[top+4]) - pix[p+1] += avg2(pix[top+1], pix[top+5]) - pix[p+2] += avg2(pix[top+2], pix[top+6]) - pix[p+3] += avg2(pix[top+3], pix[top+7]) - - case 10: // Average2(Average2(L, TL), Average2(T, TR)). - pix[p+0] += avg2(avg2(pix[p-4], pix[top-4]), avg2(pix[top+0], pix[top+4])) - pix[p+1] += avg2(avg2(pix[p-3], pix[top-3]), avg2(pix[top+1], pix[top+5])) - pix[p+2] += avg2(avg2(pix[p-2], pix[top-2]), avg2(pix[top+2], pix[top+6])) - pix[p+3] += avg2(avg2(pix[p-1], pix[top-1]), avg2(pix[top+3], pix[top+7])) - - case 11: // Select(L, T, TL). - l0 := int32(pix[p-4]) - l1 := int32(pix[p-3]) - l2 := int32(pix[p-2]) - l3 := int32(pix[p-1]) - c0 := int32(pix[top-4]) - c1 := int32(pix[top-3]) - c2 := int32(pix[top-2]) - c3 := int32(pix[top-1]) - t0 := int32(pix[top+0]) - t1 := int32(pix[top+1]) - t2 := int32(pix[top+2]) - t3 := int32(pix[top+3]) - l := abs(c0-t0) + abs(c1-t1) + abs(c2-t2) + abs(c3-t3) - t := abs(c0-l0) + abs(c1-l1) + abs(c2-l2) + abs(c3-l3) - if l < t { - pix[p+0] += uint8(l0) - pix[p+1] += uint8(l1) - pix[p+2] += uint8(l2) - pix[p+3] += uint8(l3) - } else { - pix[p+0] += uint8(t0) - pix[p+1] += uint8(t1) - pix[p+2] += uint8(t2) - pix[p+3] += uint8(t3) - } - - case 12: // ClampAddSubtractFull(L, T, TL). - pix[p+0] += clampAddSubtractFull(pix[p-4], pix[top+0], pix[top-4]) - pix[p+1] += clampAddSubtractFull(pix[p-3], pix[top+1], pix[top-3]) - pix[p+2] += clampAddSubtractFull(pix[p-2], pix[top+2], pix[top-2]) - pix[p+3] += clampAddSubtractFull(pix[p-1], pix[top+3], pix[top-1]) - - case 13: // ClampAddSubtractHalf(Average2(L, T), TL). - pix[p+0] += clampAddSubtractHalf(avg2(pix[p-4], pix[top+0]), pix[top-4]) - pix[p+1] += clampAddSubtractHalf(avg2(pix[p-3], pix[top+1]), pix[top-3]) - pix[p+2] += clampAddSubtractHalf(avg2(pix[p-2], pix[top+2]), pix[top-2]) - pix[p+3] += clampAddSubtractHalf(avg2(pix[p-1], pix[top+3]), pix[top-1]) - } - p, top = p+4, top+4 - } - } - return pix -} - -func inverseCrossColor(t *transform, pix []byte, h int32) []byte { - var greenToRed, greenToBlue, redToBlue int32 - p, mask, tilesPerRow := int32(0), int32(1)<> t.bits) * tilesPerRow - for x := int32(0); x < t.oldWidth; x++ { - if x&mask == 0 { - redToBlue = int32(int8(t.pix[q+0])) - greenToBlue = int32(int8(t.pix[q+1])) - greenToRed = int32(int8(t.pix[q+2])) - q += 4 - } - red := pix[p+0] - green := pix[p+1] - blue := pix[p+2] - red += uint8(uint32(greenToRed*int32(int8(green))) >> 5) - blue += uint8(uint32(greenToBlue*int32(int8(green))) >> 5) - blue += uint8(uint32(redToBlue*int32(int8(red))) >> 5) - pix[p+0] = red - pix[p+2] = blue - p += 4 - } - } - return pix -} - -func inverseSubtractGreen(t *transform, pix []byte, h int32) []byte { - for p := 0; p < len(pix); p += 4 { - green := pix[p+1] - pix[p+0] += green - pix[p+2] += green - } - return pix -} - -func inverseColorIndexing(t *transform, pix []byte, h int32) []byte { - if t.bits == 0 { - for p := 0; p < len(pix); p += 4 { - i := 4 * uint32(pix[p+1]) - pix[p+0] = t.pix[i+0] - pix[p+1] = t.pix[i+1] - pix[p+2] = t.pix[i+2] - pix[p+3] = t.pix[i+3] - } - return pix - } - - vMask, xMask, bitsPerPixel := uint32(0), int32(0), uint32(8>>t.bits) - switch t.bits { - case 1: - vMask, xMask = 0x0f, 0x01 - case 2: - vMask, xMask = 0x03, 0x03 - case 3: - vMask, xMask = 0x01, 0x07 - } - - d, p, v, dst := 0, 0, uint32(0), make([]byte, 4*t.oldWidth*h) - for y := int32(0); y < h; y++ { - for x := int32(0); x < t.oldWidth; x++ { - if x&xMask == 0 { - v = uint32(pix[p+1]) - p += 4 - } - - i := 4 * (v & vMask) - dst[d+0] = t.pix[i+0] - dst[d+1] = t.pix[i+1] - dst[d+2] = t.pix[i+2] - dst[d+3] = t.pix[i+3] - d += 4 - - v >>= bitsPerPixel - } - } - return dst -} - -func abs(x int32) int32 { - if x < 0 { - return -x - } - return x -} - -func avg2(a, b uint8) uint8 { - return uint8((int32(a) + int32(b)) / 2) -} - -func clampAddSubtractFull(a, b, c uint8) uint8 { - x := int32(a) + int32(b) - int32(c) - if x < 0 { - return 0 - } - if x > 255 { - return 255 - } - return uint8(x) -} - -func clampAddSubtractHalf(a, b uint8) uint8 { - x := int32(a) + (int32(a)-int32(b))/2 - if x < 0 { - return 0 - } - if x > 255 { - return 255 - } - return uint8(x) -} diff --git a/vendor/golang.org/x/image/webp/decode.go b/vendor/golang.org/x/image/webp/decode.go deleted file mode 100644 index f77a4eb..0000000 --- a/vendor/golang.org/x/image/webp/decode.go +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webp - -import ( - "bytes" - "errors" - "image" - "image/color" - "io" - - "golang.org/x/image/riff" - "golang.org/x/image/vp8" - "golang.org/x/image/vp8l" -) - -var errInvalidFormat = errors.New("webp: invalid format") - -var ( - fccALPH = riff.FourCC{'A', 'L', 'P', 'H'} - fccVP8 = riff.FourCC{'V', 'P', '8', ' '} - fccVP8L = riff.FourCC{'V', 'P', '8', 'L'} - fccVP8X = riff.FourCC{'V', 'P', '8', 'X'} - fccWEBP = riff.FourCC{'W', 'E', 'B', 'P'} -) - -func decode(r io.Reader, configOnly bool) (image.Image, image.Config, error) { - formType, riffReader, err := riff.NewReader(r) - if err != nil { - return nil, image.Config{}, err - } - if formType != fccWEBP { - return nil, image.Config{}, errInvalidFormat - } - - var ( - alpha []byte - alphaStride int - wantAlpha bool - widthMinusOne uint32 - heightMinusOne uint32 - buf [10]byte - ) - for { - chunkID, chunkLen, chunkData, err := riffReader.Next() - if err == io.EOF { - err = errInvalidFormat - } - if err != nil { - return nil, image.Config{}, err - } - - switch chunkID { - case fccALPH: - if !wantAlpha { - return nil, image.Config{}, errInvalidFormat - } - wantAlpha = false - // Read the Pre-processing | Filter | Compression byte. - if _, err := io.ReadFull(chunkData, buf[:1]); err != nil { - if err == io.EOF { - err = errInvalidFormat - } - return nil, image.Config{}, err - } - alpha, alphaStride, err = readAlpha(chunkData, widthMinusOne, heightMinusOne, buf[0]&0x03) - if err != nil { - return nil, image.Config{}, err - } - unfilterAlpha(alpha, alphaStride, (buf[0]>>2)&0x03) - - case fccVP8: - if wantAlpha || int32(chunkLen) < 0 { - return nil, image.Config{}, errInvalidFormat - } - d := vp8.NewDecoder() - d.Init(chunkData, int(chunkLen)) - fh, err := d.DecodeFrameHeader() - if err != nil { - return nil, image.Config{}, err - } - if configOnly { - return nil, image.Config{ - ColorModel: color.YCbCrModel, - Width: fh.Width, - Height: fh.Height, - }, nil - } - m, err := d.DecodeFrame() - if err != nil { - return nil, image.Config{}, err - } - if alpha != nil { - return &image.NYCbCrA{ - YCbCr: *m, - A: alpha, - AStride: alphaStride, - }, image.Config{}, nil - } - return m, image.Config{}, nil - - case fccVP8L: - if wantAlpha || alpha != nil { - return nil, image.Config{}, errInvalidFormat - } - if configOnly { - c, err := vp8l.DecodeConfig(chunkData) - return nil, c, err - } - m, err := vp8l.Decode(chunkData) - return m, image.Config{}, err - - case fccVP8X: - if chunkLen != 10 { - return nil, image.Config{}, errInvalidFormat - } - if _, err := io.ReadFull(chunkData, buf[:10]); err != nil { - return nil, image.Config{}, err - } - const ( - animationBit = 1 << 1 - xmpMetadataBit = 1 << 2 - exifMetadataBit = 1 << 3 - alphaBit = 1 << 4 - iccProfileBit = 1 << 5 - ) - if buf[0] != alphaBit { - return nil, image.Config{}, errors.New("webp: non-Alpha VP8X is not implemented") - } - widthMinusOne = uint32(buf[4]) | uint32(buf[5])<<8 | uint32(buf[6])<<16 - heightMinusOne = uint32(buf[7]) | uint32(buf[8])<<8 | uint32(buf[9])<<16 - if configOnly { - return nil, image.Config{ - ColorModel: color.NYCbCrAModel, - Width: int(widthMinusOne) + 1, - Height: int(heightMinusOne) + 1, - }, nil - } - wantAlpha = true - - default: - return nil, image.Config{}, errInvalidFormat - } - } -} - -func readAlpha(chunkData io.Reader, widthMinusOne, heightMinusOne uint32, compression byte) ( - alpha []byte, alphaStride int, err error) { - - switch compression { - case 0: - w := int(widthMinusOne) + 1 - h := int(heightMinusOne) + 1 - alpha = make([]byte, w*h) - if _, err := io.ReadFull(chunkData, alpha); err != nil { - return nil, 0, err - } - return alpha, w, nil - - case 1: - // Read the VP8L-compressed alpha values. First, synthesize a 5-byte VP8L header: - // a 1-byte magic number, a 14-bit widthMinusOne, a 14-bit heightMinusOne, - // a 1-bit (ignored, zero) alphaIsUsed and a 3-bit (zero) version. - // TODO(nigeltao): be more efficient than decoding an *image.NRGBA just to - // extract the green values to a separately allocated []byte. Fixing this - // will require changes to the vp8l package's API. - if widthMinusOne > 0x3fff || heightMinusOne > 0x3fff { - return nil, 0, errors.New("webp: invalid format") - } - alphaImage, err := vp8l.Decode(io.MultiReader( - bytes.NewReader([]byte{ - 0x2f, // VP8L magic number. - uint8(widthMinusOne), - uint8(widthMinusOne>>8) | uint8(heightMinusOne<<6), - uint8(heightMinusOne >> 2), - uint8(heightMinusOne >> 10), - }), - chunkData, - )) - if err != nil { - return nil, 0, err - } - // The green values of the inner NRGBA image are the alpha values of the - // outer NYCbCrA image. - pix := alphaImage.(*image.NRGBA).Pix - alpha = make([]byte, len(pix)/4) - for i := range alpha { - alpha[i] = pix[4*i+1] - } - return alpha, int(widthMinusOne) + 1, nil - } - return nil, 0, errInvalidFormat -} - -func unfilterAlpha(alpha []byte, alphaStride int, filter byte) { - if len(alpha) == 0 || alphaStride == 0 { - return - } - switch filter { - case 1: // Horizontal filter. - for i := 1; i < alphaStride; i++ { - alpha[i] += alpha[i-1] - } - for i := alphaStride; i < len(alpha); i += alphaStride { - // The first column is equivalent to the vertical filter. - alpha[i] += alpha[i-alphaStride] - - for j := 1; j < alphaStride; j++ { - alpha[i+j] += alpha[i+j-1] - } - } - - case 2: // Vertical filter. - // The first row is equivalent to the horizontal filter. - for i := 1; i < alphaStride; i++ { - alpha[i] += alpha[i-1] - } - - for i := alphaStride; i < len(alpha); i++ { - alpha[i] += alpha[i-alphaStride] - } - - case 3: // Gradient filter. - // The first row is equivalent to the horizontal filter. - for i := 1; i < alphaStride; i++ { - alpha[i] += alpha[i-1] - } - - for i := alphaStride; i < len(alpha); i += alphaStride { - // The first column is equivalent to the vertical filter. - alpha[i] += alpha[i-alphaStride] - - // The interior is predicted on the three top/left pixels. - for j := 1; j < alphaStride; j++ { - c := int(alpha[i+j-alphaStride-1]) - b := int(alpha[i+j-alphaStride]) - a := int(alpha[i+j-1]) - x := a + b - c - if x < 0 { - x = 0 - } else if x > 255 { - x = 255 - } - alpha[i+j] += uint8(x) - } - } - } -} - -// Decode reads a WEBP image from r and returns it as an image.Image. -func Decode(r io.Reader) (image.Image, error) { - m, _, err := decode(r, false) - if err != nil { - return nil, err - } - return m, err -} - -// DecodeConfig returns the color model and dimensions of a WEBP image without -// decoding the entire image. -func DecodeConfig(r io.Reader) (image.Config, error) { - _, c, err := decode(r, true) - return c, err -} - -func init() { - image.RegisterFormat("webp", "RIFF????WEBPVP8", Decode, DecodeConfig) -} diff --git a/vendor/golang.org/x/image/webp/doc.go b/vendor/golang.org/x/image/webp/doc.go deleted file mode 100644 index e321c85..0000000 --- a/vendor/golang.org/x/image/webp/doc.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package webp implements a decoder for WEBP images. -// -// WEBP is defined at: -// https://developers.google.com/speed/webp/docs/riff_container -package webp // import "golang.org/x/image/webp" diff --git a/vendor/golang.org/x/net/AUTHORS b/vendor/golang.org/x/net/AUTHORS deleted file mode 100644 index 15167cd..0000000 --- a/vendor/golang.org/x/net/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/net/CONTRIBUTORS b/vendor/golang.org/x/net/CONTRIBUTORS deleted file mode 100644 index 1c4577e..0000000 --- a/vendor/golang.org/x/net/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/net/LICENSE b/vendor/golang.org/x/net/LICENSE deleted file mode 100644 index 6a66aea..0000000 --- a/vendor/golang.org/x/net/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/net/PATENTS b/vendor/golang.org/x/net/PATENTS deleted file mode 100644 index 7330990..0000000 --- a/vendor/golang.org/x/net/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/net/html/atom/atom.go b/vendor/golang.org/x/net/html/atom/atom.go deleted file mode 100644 index cd0a8ac..0000000 --- a/vendor/golang.org/x/net/html/atom/atom.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package atom provides integer codes (also known as atoms) for a fixed set of -// frequently occurring HTML strings: tag names and attribute keys such as "p" -// and "id". -// -// Sharing an atom's name between all elements with the same tag can result in -// fewer string allocations when tokenizing and parsing HTML. Integer -// comparisons are also generally faster than string comparisons. -// -// The value of an atom's particular code is not guaranteed to stay the same -// between versions of this package. Neither is any ordering guaranteed: -// whether atom.H1 < atom.H2 may also change. The codes are not guaranteed to -// be dense. The only guarantees are that e.g. looking up "div" will yield -// atom.Div, calling atom.Div.String will return "div", and atom.Div != 0. -package atom // import "golang.org/x/net/html/atom" - -// Atom is an integer code for a string. The zero value maps to "". -type Atom uint32 - -// String returns the atom's name. -func (a Atom) String() string { - start := uint32(a >> 8) - n := uint32(a & 0xff) - if start+n > uint32(len(atomText)) { - return "" - } - return atomText[start : start+n] -} - -func (a Atom) string() string { - return atomText[a>>8 : a>>8+a&0xff] -} - -// fnv computes the FNV hash with an arbitrary starting value h. -func fnv(h uint32, s []byte) uint32 { - for i := range s { - h ^= uint32(s[i]) - h *= 16777619 - } - return h -} - -func match(s string, t []byte) bool { - for i, c := range t { - if s[i] != c { - return false - } - } - return true -} - -// Lookup returns the atom whose name is s. It returns zero if there is no -// such atom. The lookup is case sensitive. -func Lookup(s []byte) Atom { - if len(s) == 0 || len(s) > maxAtomLen { - return 0 - } - h := fnv(hash0, s) - if a := table[h&uint32(len(table)-1)]; int(a&0xff) == len(s) && match(a.string(), s) { - return a - } - if a := table[(h>>16)&uint32(len(table)-1)]; int(a&0xff) == len(s) && match(a.string(), s) { - return a - } - return 0 -} - -// String returns a string whose contents are equal to s. In that sense, it is -// equivalent to string(s) but may be more efficient. -func String(s []byte) string { - if a := Lookup(s); a != 0 { - return a.String() - } - return string(s) -} diff --git a/vendor/golang.org/x/net/html/atom/gen.go b/vendor/golang.org/x/net/html/atom/gen.go deleted file mode 100644 index 5d05278..0000000 --- a/vendor/golang.org/x/net/html/atom/gen.go +++ /dev/null @@ -1,712 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -//go:generate go run gen.go -//go:generate go run gen.go -test - -package main - -import ( - "bytes" - "flag" - "fmt" - "go/format" - "io/ioutil" - "math/rand" - "os" - "sort" - "strings" -) - -// identifier converts s to a Go exported identifier. -// It converts "div" to "Div" and "accept-charset" to "AcceptCharset". -func identifier(s string) string { - b := make([]byte, 0, len(s)) - cap := true - for _, c := range s { - if c == '-' { - cap = true - continue - } - if cap && 'a' <= c && c <= 'z' { - c -= 'a' - 'A' - } - cap = false - b = append(b, byte(c)) - } - return string(b) -} - -var test = flag.Bool("test", false, "generate table_test.go") - -func genFile(name string, buf *bytes.Buffer) { - b, err := format.Source(buf.Bytes()) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if err := ioutil.WriteFile(name, b, 0644); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func main() { - flag.Parse() - - var all []string - all = append(all, elements...) - all = append(all, attributes...) - all = append(all, eventHandlers...) - all = append(all, extra...) - sort.Strings(all) - - // uniq - lists have dups - w := 0 - for _, s := range all { - if w == 0 || all[w-1] != s { - all[w] = s - w++ - } - } - all = all[:w] - - if *test { - var buf bytes.Buffer - fmt.Fprintln(&buf, "// Code generated by go generate gen.go; DO NOT EDIT.\n") - fmt.Fprintln(&buf, "//go:generate go run gen.go -test\n") - fmt.Fprintln(&buf, "package atom\n") - fmt.Fprintln(&buf, "var testAtomList = []string{") - for _, s := range all { - fmt.Fprintf(&buf, "\t%q,\n", s) - } - fmt.Fprintln(&buf, "}") - - genFile("table_test.go", &buf) - return - } - - // Find hash that minimizes table size. - var best *table - for i := 0; i < 1000000; i++ { - if best != nil && 1<<(best.k-1) < len(all) { - break - } - h := rand.Uint32() - for k := uint(0); k <= 16; k++ { - if best != nil && k >= best.k { - break - } - var t table - if t.init(h, k, all) { - best = &t - break - } - } - } - if best == nil { - fmt.Fprintf(os.Stderr, "failed to construct string table\n") - os.Exit(1) - } - - // Lay out strings, using overlaps when possible. - layout := append([]string{}, all...) - - // Remove strings that are substrings of other strings - for changed := true; changed; { - changed = false - for i, s := range layout { - if s == "" { - continue - } - for j, t := range layout { - if i != j && t != "" && strings.Contains(s, t) { - changed = true - layout[j] = "" - } - } - } - } - - // Join strings where one suffix matches another prefix. - for { - // Find best i, j, k such that layout[i][len-k:] == layout[j][:k], - // maximizing overlap length k. - besti := -1 - bestj := -1 - bestk := 0 - for i, s := range layout { - if s == "" { - continue - } - for j, t := range layout { - if i == j { - continue - } - for k := bestk + 1; k <= len(s) && k <= len(t); k++ { - if s[len(s)-k:] == t[:k] { - besti = i - bestj = j - bestk = k - } - } - } - } - if bestk > 0 { - layout[besti] += layout[bestj][bestk:] - layout[bestj] = "" - continue - } - break - } - - text := strings.Join(layout, "") - - atom := map[string]uint32{} - for _, s := range all { - off := strings.Index(text, s) - if off < 0 { - panic("lost string " + s) - } - atom[s] = uint32(off<<8 | len(s)) - } - - var buf bytes.Buffer - // Generate the Go code. - fmt.Fprintln(&buf, "// Code generated by go generate gen.go; DO NOT EDIT.\n") - fmt.Fprintln(&buf, "//go:generate go run gen.go\n") - fmt.Fprintln(&buf, "package atom\n\nconst (") - - // compute max len - maxLen := 0 - for _, s := range all { - if maxLen < len(s) { - maxLen = len(s) - } - fmt.Fprintf(&buf, "\t%s Atom = %#x\n", identifier(s), atom[s]) - } - fmt.Fprintln(&buf, ")\n") - - fmt.Fprintf(&buf, "const hash0 = %#x\n\n", best.h0) - fmt.Fprintf(&buf, "const maxAtomLen = %d\n\n", maxLen) - - fmt.Fprintf(&buf, "var table = [1<<%d]Atom{\n", best.k) - for i, s := range best.tab { - if s == "" { - continue - } - fmt.Fprintf(&buf, "\t%#x: %#x, // %s\n", i, atom[s], s) - } - fmt.Fprintf(&buf, "}\n") - datasize := (1 << best.k) * 4 - - fmt.Fprintln(&buf, "const atomText =") - textsize := len(text) - for len(text) > 60 { - fmt.Fprintf(&buf, "\t%q +\n", text[:60]) - text = text[60:] - } - fmt.Fprintf(&buf, "\t%q\n\n", text) - - genFile("table.go", &buf) - - fmt.Fprintf(os.Stdout, "%d atoms; %d string bytes + %d tables = %d total data\n", len(all), textsize, datasize, textsize+datasize) -} - -type byLen []string - -func (x byLen) Less(i, j int) bool { return len(x[i]) > len(x[j]) } -func (x byLen) Swap(i, j int) { x[i], x[j] = x[j], x[i] } -func (x byLen) Len() int { return len(x) } - -// fnv computes the FNV hash with an arbitrary starting value h. -func fnv(h uint32, s string) uint32 { - for i := 0; i < len(s); i++ { - h ^= uint32(s[i]) - h *= 16777619 - } - return h -} - -// A table represents an attempt at constructing the lookup table. -// The lookup table uses cuckoo hashing, meaning that each string -// can be found in one of two positions. -type table struct { - h0 uint32 - k uint - mask uint32 - tab []string -} - -// hash returns the two hashes for s. -func (t *table) hash(s string) (h1, h2 uint32) { - h := fnv(t.h0, s) - h1 = h & t.mask - h2 = (h >> 16) & t.mask - return -} - -// init initializes the table with the given parameters. -// h0 is the initial hash value, -// k is the number of bits of hash value to use, and -// x is the list of strings to store in the table. -// init returns false if the table cannot be constructed. -func (t *table) init(h0 uint32, k uint, x []string) bool { - t.h0 = h0 - t.k = k - t.tab = make([]string, 1< len(t.tab) { - return false - } - s := t.tab[i] - h1, h2 := t.hash(s) - j := h1 + h2 - i - if t.tab[j] != "" && !t.push(j, depth+1) { - return false - } - t.tab[j] = s - return true -} - -// The lists of element names and attribute keys were taken from -// https://html.spec.whatwg.org/multipage/indices.html#index -// as of the "HTML Living Standard - Last Updated 16 April 2018" version. - -// "command", "keygen" and "menuitem" have been removed from the spec, -// but are kept here for backwards compatibility. -var elements = []string{ - "a", - "abbr", - "address", - "area", - "article", - "aside", - "audio", - "b", - "base", - "bdi", - "bdo", - "blockquote", - "body", - "br", - "button", - "canvas", - "caption", - "cite", - "code", - "col", - "colgroup", - "command", - "data", - "datalist", - "dd", - "del", - "details", - "dfn", - "dialog", - "div", - "dl", - "dt", - "em", - "embed", - "fieldset", - "figcaption", - "figure", - "footer", - "form", - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "head", - "header", - "hgroup", - "hr", - "html", - "i", - "iframe", - "img", - "input", - "ins", - "kbd", - "keygen", - "label", - "legend", - "li", - "link", - "main", - "map", - "mark", - "menu", - "menuitem", - "meta", - "meter", - "nav", - "noscript", - "object", - "ol", - "optgroup", - "option", - "output", - "p", - "param", - "picture", - "pre", - "progress", - "q", - "rp", - "rt", - "ruby", - "s", - "samp", - "script", - "section", - "select", - "slot", - "small", - "source", - "span", - "strong", - "style", - "sub", - "summary", - "sup", - "table", - "tbody", - "td", - "template", - "textarea", - "tfoot", - "th", - "thead", - "time", - "title", - "tr", - "track", - "u", - "ul", - "var", - "video", - "wbr", -} - -// https://html.spec.whatwg.org/multipage/indices.html#attributes-3 -// -// "challenge", "command", "contextmenu", "dropzone", "icon", "keytype", "mediagroup", -// "radiogroup", "spellcheck", "scoped", "seamless", "sortable" and "sorted" have been removed from the spec, -// but are kept here for backwards compatibility. -var attributes = []string{ - "abbr", - "accept", - "accept-charset", - "accesskey", - "action", - "allowfullscreen", - "allowpaymentrequest", - "allowusermedia", - "alt", - "as", - "async", - "autocomplete", - "autofocus", - "autoplay", - "challenge", - "charset", - "checked", - "cite", - "class", - "color", - "cols", - "colspan", - "command", - "content", - "contenteditable", - "contextmenu", - "controls", - "coords", - "crossorigin", - "data", - "datetime", - "default", - "defer", - "dir", - "dirname", - "disabled", - "download", - "draggable", - "dropzone", - "enctype", - "for", - "form", - "formaction", - "formenctype", - "formmethod", - "formnovalidate", - "formtarget", - "headers", - "height", - "hidden", - "high", - "href", - "hreflang", - "http-equiv", - "icon", - "id", - "inputmode", - "integrity", - "is", - "ismap", - "itemid", - "itemprop", - "itemref", - "itemscope", - "itemtype", - "keytype", - "kind", - "label", - "lang", - "list", - "loop", - "low", - "manifest", - "max", - "maxlength", - "media", - "mediagroup", - "method", - "min", - "minlength", - "multiple", - "muted", - "name", - "nomodule", - "nonce", - "novalidate", - "open", - "optimum", - "pattern", - "ping", - "placeholder", - "playsinline", - "poster", - "preload", - "radiogroup", - "readonly", - "referrerpolicy", - "rel", - "required", - "reversed", - "rows", - "rowspan", - "sandbox", - "spellcheck", - "scope", - "scoped", - "seamless", - "selected", - "shape", - "size", - "sizes", - "sortable", - "sorted", - "slot", - "span", - "spellcheck", - "src", - "srcdoc", - "srclang", - "srcset", - "start", - "step", - "style", - "tabindex", - "target", - "title", - "translate", - "type", - "typemustmatch", - "updateviacache", - "usemap", - "value", - "width", - "workertype", - "wrap", -} - -// "onautocomplete", "onautocompleteerror", "onmousewheel", -// "onshow" and "onsort" have been removed from the spec, -// but are kept here for backwards compatibility. -var eventHandlers = []string{ - "onabort", - "onautocomplete", - "onautocompleteerror", - "onauxclick", - "onafterprint", - "onbeforeprint", - "onbeforeunload", - "onblur", - "oncancel", - "oncanplay", - "oncanplaythrough", - "onchange", - "onclick", - "onclose", - "oncontextmenu", - "oncopy", - "oncuechange", - "oncut", - "ondblclick", - "ondrag", - "ondragend", - "ondragenter", - "ondragexit", - "ondragleave", - "ondragover", - "ondragstart", - "ondrop", - "ondurationchange", - "onemptied", - "onended", - "onerror", - "onfocus", - "onhashchange", - "oninput", - "oninvalid", - "onkeydown", - "onkeypress", - "onkeyup", - "onlanguagechange", - "onload", - "onloadeddata", - "onloadedmetadata", - "onloadend", - "onloadstart", - "onmessage", - "onmessageerror", - "onmousedown", - "onmouseenter", - "onmouseleave", - "onmousemove", - "onmouseout", - "onmouseover", - "onmouseup", - "onmousewheel", - "onwheel", - "onoffline", - "ononline", - "onpagehide", - "onpageshow", - "onpaste", - "onpause", - "onplay", - "onplaying", - "onpopstate", - "onprogress", - "onratechange", - "onreset", - "onresize", - "onrejectionhandled", - "onscroll", - "onsecuritypolicyviolation", - "onseeked", - "onseeking", - "onselect", - "onshow", - "onsort", - "onstalled", - "onstorage", - "onsubmit", - "onsuspend", - "ontimeupdate", - "ontoggle", - "onunhandledrejection", - "onunload", - "onvolumechange", - "onwaiting", -} - -// extra are ad-hoc values not covered by any of the lists above. -var extra = []string{ - "acronym", - "align", - "annotation", - "annotation-xml", - "applet", - "basefont", - "bgsound", - "big", - "blink", - "center", - "color", - "desc", - "face", - "font", - "foreignObject", // HTML is case-insensitive, but SVG-embedded-in-HTML is case-sensitive. - "foreignobject", - "frame", - "frameset", - "image", - "isindex", - "listing", - "malignmark", - "marquee", - "math", - "mglyph", - "mi", - "mn", - "mo", - "ms", - "mtext", - "nobr", - "noembed", - "noframes", - "plaintext", - "prompt", - "public", - "rb", - "rtc", - "spacer", - "strike", - "svg", - "system", - "tt", - "xmp", -} diff --git a/vendor/golang.org/x/net/html/atom/table.go b/vendor/golang.org/x/net/html/atom/table.go deleted file mode 100644 index 2a93886..0000000 --- a/vendor/golang.org/x/net/html/atom/table.go +++ /dev/null @@ -1,783 +0,0 @@ -// Code generated by go generate gen.go; DO NOT EDIT. - -//go:generate go run gen.go - -package atom - -const ( - A Atom = 0x1 - Abbr Atom = 0x4 - Accept Atom = 0x1a06 - AcceptCharset Atom = 0x1a0e - Accesskey Atom = 0x2c09 - Acronym Atom = 0xaa07 - Action Atom = 0x27206 - Address Atom = 0x6f307 - Align Atom = 0xb105 - Allowfullscreen Atom = 0x2080f - Allowpaymentrequest Atom = 0xc113 - Allowusermedia Atom = 0xdd0e - Alt Atom = 0xf303 - Annotation Atom = 0x1c90a - AnnotationXml Atom = 0x1c90e - Applet Atom = 0x31906 - Area Atom = 0x35604 - Article Atom = 0x3fc07 - As Atom = 0x3c02 - Aside Atom = 0x10705 - Async Atom = 0xff05 - Audio Atom = 0x11505 - Autocomplete Atom = 0x2780c - Autofocus Atom = 0x12109 - Autoplay Atom = 0x13c08 - B Atom = 0x101 - Base Atom = 0x3b04 - Basefont Atom = 0x3b08 - Bdi Atom = 0xba03 - Bdo Atom = 0x14b03 - Bgsound Atom = 0x15e07 - Big Atom = 0x17003 - Blink Atom = 0x17305 - Blockquote Atom = 0x1870a - Body Atom = 0x2804 - Br Atom = 0x202 - Button Atom = 0x19106 - Canvas Atom = 0x10306 - Caption Atom = 0x23107 - Center Atom = 0x22006 - Challenge Atom = 0x29b09 - Charset Atom = 0x2107 - Checked Atom = 0x47907 - Cite Atom = 0x19c04 - Class Atom = 0x56405 - Code Atom = 0x5c504 - Col Atom = 0x1ab03 - Colgroup Atom = 0x1ab08 - Color Atom = 0x1bf05 - Cols Atom = 0x1c404 - Colspan Atom = 0x1c407 - Command Atom = 0x1d707 - Content Atom = 0x58b07 - Contenteditable Atom = 0x58b0f - Contextmenu Atom = 0x3800b - Controls Atom = 0x1de08 - Coords Atom = 0x1ea06 - Crossorigin Atom = 0x1fb0b - Data Atom = 0x4a504 - Datalist Atom = 0x4a508 - Datetime Atom = 0x2b808 - Dd Atom = 0x2d702 - Default Atom = 0x10a07 - Defer Atom = 0x5c705 - Del Atom = 0x45203 - Desc Atom = 0x56104 - Details Atom = 0x7207 - Dfn Atom = 0x8703 - Dialog Atom = 0xbb06 - Dir Atom = 0x9303 - Dirname Atom = 0x9307 - Disabled Atom = 0x16408 - Div Atom = 0x16b03 - Dl Atom = 0x5e602 - Download Atom = 0x46308 - Draggable Atom = 0x17a09 - Dropzone Atom = 0x40508 - Dt Atom = 0x64b02 - Em Atom = 0x6e02 - Embed Atom = 0x6e05 - Enctype Atom = 0x28d07 - Face Atom = 0x21e04 - Fieldset Atom = 0x22608 - Figcaption Atom = 0x22e0a - Figure Atom = 0x24806 - Font Atom = 0x3f04 - Footer Atom = 0xf606 - For Atom = 0x25403 - ForeignObject Atom = 0x2540d - Foreignobject Atom = 0x2610d - Form Atom = 0x26e04 - Formaction Atom = 0x26e0a - Formenctype Atom = 0x2890b - Formmethod Atom = 0x2a40a - Formnovalidate Atom = 0x2ae0e - Formtarget Atom = 0x2c00a - Frame Atom = 0x8b05 - Frameset Atom = 0x8b08 - H1 Atom = 0x15c02 - H2 Atom = 0x2de02 - H3 Atom = 0x30d02 - H4 Atom = 0x34502 - H5 Atom = 0x34f02 - H6 Atom = 0x64d02 - Head Atom = 0x33104 - Header Atom = 0x33106 - Headers Atom = 0x33107 - Height Atom = 0x5206 - Hgroup Atom = 0x2ca06 - Hidden Atom = 0x2d506 - High Atom = 0x2db04 - Hr Atom = 0x15702 - Href Atom = 0x2e004 - Hreflang Atom = 0x2e008 - Html Atom = 0x5604 - HttpEquiv Atom = 0x2e80a - I Atom = 0x601 - Icon Atom = 0x58a04 - Id Atom = 0x10902 - Iframe Atom = 0x2fc06 - Image Atom = 0x30205 - Img Atom = 0x30703 - Input Atom = 0x44b05 - Inputmode Atom = 0x44b09 - Ins Atom = 0x20403 - Integrity Atom = 0x23f09 - Is Atom = 0x16502 - Isindex Atom = 0x30f07 - Ismap Atom = 0x31605 - Itemid Atom = 0x38b06 - Itemprop Atom = 0x19d08 - Itemref Atom = 0x3cd07 - Itemscope Atom = 0x67109 - Itemtype Atom = 0x31f08 - Kbd Atom = 0xb903 - Keygen Atom = 0x3206 - Keytype Atom = 0xd607 - Kind Atom = 0x17704 - Label Atom = 0x5905 - Lang Atom = 0x2e404 - Legend Atom = 0x18106 - Li Atom = 0xb202 - Link Atom = 0x17404 - List Atom = 0x4a904 - Listing Atom = 0x4a907 - Loop Atom = 0x5d04 - Low Atom = 0xc303 - Main Atom = 0x1004 - Malignmark Atom = 0xb00a - Manifest Atom = 0x6d708 - Map Atom = 0x31803 - Mark Atom = 0xb604 - Marquee Atom = 0x32707 - Math Atom = 0x32e04 - Max Atom = 0x33d03 - Maxlength Atom = 0x33d09 - Media Atom = 0xe605 - Mediagroup Atom = 0xe60a - Menu Atom = 0x38704 - Menuitem Atom = 0x38708 - Meta Atom = 0x4b804 - Meter Atom = 0x9805 - Method Atom = 0x2a806 - Mglyph Atom = 0x30806 - Mi Atom = 0x34702 - Min Atom = 0x34703 - Minlength Atom = 0x34709 - Mn Atom = 0x2b102 - Mo Atom = 0xa402 - Ms Atom = 0x67402 - Mtext Atom = 0x35105 - Multiple Atom = 0x35f08 - Muted Atom = 0x36705 - Name Atom = 0x9604 - Nav Atom = 0x1303 - Nobr Atom = 0x3704 - Noembed Atom = 0x6c07 - Noframes Atom = 0x8908 - Nomodule Atom = 0xa208 - Nonce Atom = 0x1a605 - Noscript Atom = 0x21608 - Novalidate Atom = 0x2b20a - Object Atom = 0x26806 - Ol Atom = 0x13702 - Onabort Atom = 0x19507 - Onafterprint Atom = 0x2360c - Onautocomplete Atom = 0x2760e - Onautocompleteerror Atom = 0x27613 - Onauxclick Atom = 0x61f0a - Onbeforeprint Atom = 0x69e0d - Onbeforeunload Atom = 0x6e70e - Onblur Atom = 0x56d06 - Oncancel Atom = 0x11908 - Oncanplay Atom = 0x14d09 - Oncanplaythrough Atom = 0x14d10 - Onchange Atom = 0x41b08 - Onclick Atom = 0x2f507 - Onclose Atom = 0x36c07 - Oncontextmenu Atom = 0x37e0d - Oncopy Atom = 0x39106 - Oncuechange Atom = 0x3970b - Oncut Atom = 0x3a205 - Ondblclick Atom = 0x3a70a - Ondrag Atom = 0x3b106 - Ondragend Atom = 0x3b109 - Ondragenter Atom = 0x3ba0b - Ondragexit Atom = 0x3c50a - Ondragleave Atom = 0x3df0b - Ondragover Atom = 0x3ea0a - Ondragstart Atom = 0x3f40b - Ondrop Atom = 0x40306 - Ondurationchange Atom = 0x41310 - Onemptied Atom = 0x40a09 - Onended Atom = 0x42307 - Onerror Atom = 0x42a07 - Onfocus Atom = 0x43107 - Onhashchange Atom = 0x43d0c - Oninput Atom = 0x44907 - Oninvalid Atom = 0x45509 - Onkeydown Atom = 0x45e09 - Onkeypress Atom = 0x46b0a - Onkeyup Atom = 0x48007 - Onlanguagechange Atom = 0x48d10 - Onload Atom = 0x49d06 - Onloadeddata Atom = 0x49d0c - Onloadedmetadata Atom = 0x4b010 - Onloadend Atom = 0x4c609 - Onloadstart Atom = 0x4cf0b - Onmessage Atom = 0x4da09 - Onmessageerror Atom = 0x4da0e - Onmousedown Atom = 0x4e80b - Onmouseenter Atom = 0x4f30c - Onmouseleave Atom = 0x4ff0c - Onmousemove Atom = 0x50b0b - Onmouseout Atom = 0x5160a - Onmouseover Atom = 0x5230b - Onmouseup Atom = 0x52e09 - Onmousewheel Atom = 0x53c0c - Onoffline Atom = 0x54809 - Ononline Atom = 0x55108 - Onpagehide Atom = 0x5590a - Onpageshow Atom = 0x5730a - Onpaste Atom = 0x57f07 - Onpause Atom = 0x59a07 - Onplay Atom = 0x5a406 - Onplaying Atom = 0x5a409 - Onpopstate Atom = 0x5ad0a - Onprogress Atom = 0x5b70a - Onratechange Atom = 0x5cc0c - Onrejectionhandled Atom = 0x5d812 - Onreset Atom = 0x5ea07 - Onresize Atom = 0x5f108 - Onscroll Atom = 0x60008 - Onsecuritypolicyviolation Atom = 0x60819 - Onseeked Atom = 0x62908 - Onseeking Atom = 0x63109 - Onselect Atom = 0x63a08 - Onshow Atom = 0x64406 - Onsort Atom = 0x64f06 - Onstalled Atom = 0x65909 - Onstorage Atom = 0x66209 - Onsubmit Atom = 0x66b08 - Onsuspend Atom = 0x67b09 - Ontimeupdate Atom = 0x400c - Ontoggle Atom = 0x68408 - Onunhandledrejection Atom = 0x68c14 - Onunload Atom = 0x6ab08 - Onvolumechange Atom = 0x6b30e - Onwaiting Atom = 0x6c109 - Onwheel Atom = 0x6ca07 - Open Atom = 0x1a304 - Optgroup Atom = 0x5f08 - Optimum Atom = 0x6d107 - Option Atom = 0x6e306 - Output Atom = 0x51d06 - P Atom = 0xc01 - Param Atom = 0xc05 - Pattern Atom = 0x6607 - Picture Atom = 0x7b07 - Ping Atom = 0xef04 - Placeholder Atom = 0x1310b - Plaintext Atom = 0x1b209 - Playsinline Atom = 0x1400b - Poster Atom = 0x2cf06 - Pre Atom = 0x47003 - Preload Atom = 0x48607 - Progress Atom = 0x5b908 - Prompt Atom = 0x53606 - Public Atom = 0x58606 - Q Atom = 0xcf01 - Radiogroup Atom = 0x30a - Rb Atom = 0x3a02 - Readonly Atom = 0x35708 - Referrerpolicy Atom = 0x3d10e - Rel Atom = 0x48703 - Required Atom = 0x24c08 - Reversed Atom = 0x8008 - Rows Atom = 0x9c04 - Rowspan Atom = 0x9c07 - Rp Atom = 0x23c02 - Rt Atom = 0x19a02 - Rtc Atom = 0x19a03 - Ruby Atom = 0xfb04 - S Atom = 0x2501 - Samp Atom = 0x7804 - Sandbox Atom = 0x12907 - Scope Atom = 0x67505 - Scoped Atom = 0x67506 - Script Atom = 0x21806 - Seamless Atom = 0x37108 - Section Atom = 0x56807 - Select Atom = 0x63c06 - Selected Atom = 0x63c08 - Shape Atom = 0x1e505 - Size Atom = 0x5f504 - Sizes Atom = 0x5f505 - Slot Atom = 0x1ef04 - Small Atom = 0x20605 - Sortable Atom = 0x65108 - Sorted Atom = 0x33706 - Source Atom = 0x37806 - Spacer Atom = 0x43706 - Span Atom = 0x9f04 - Spellcheck Atom = 0x4740a - Src Atom = 0x5c003 - Srcdoc Atom = 0x5c006 - Srclang Atom = 0x5f907 - Srcset Atom = 0x6f906 - Start Atom = 0x3fa05 - Step Atom = 0x58304 - Strike Atom = 0xd206 - Strong Atom = 0x6dd06 - Style Atom = 0x6ff05 - Sub Atom = 0x66d03 - Summary Atom = 0x70407 - Sup Atom = 0x70b03 - Svg Atom = 0x70e03 - System Atom = 0x71106 - Tabindex Atom = 0x4be08 - Table Atom = 0x59505 - Target Atom = 0x2c406 - Tbody Atom = 0x2705 - Td Atom = 0x9202 - Template Atom = 0x71408 - Textarea Atom = 0x35208 - Tfoot Atom = 0xf505 - Th Atom = 0x15602 - Thead Atom = 0x33005 - Time Atom = 0x4204 - Title Atom = 0x11005 - Tr Atom = 0xcc02 - Track Atom = 0x1ba05 - Translate Atom = 0x1f209 - Tt Atom = 0x6802 - Type Atom = 0xd904 - Typemustmatch Atom = 0x2900d - U Atom = 0xb01 - Ul Atom = 0xa702 - Updateviacache Atom = 0x460e - Usemap Atom = 0x59e06 - Value Atom = 0x1505 - Var Atom = 0x16d03 - Video Atom = 0x2f105 - Wbr Atom = 0x57c03 - Width Atom = 0x64905 - Workertype Atom = 0x71c0a - Wrap Atom = 0x72604 - Xmp Atom = 0x12f03 -) - -const hash0 = 0x81cdf10e - -const maxAtomLen = 25 - -var table = [1 << 9]Atom{ - 0x1: 0xe60a, // mediagroup - 0x2: 0x2e404, // lang - 0x4: 0x2c09, // accesskey - 0x5: 0x8b08, // frameset - 0x7: 0x63a08, // onselect - 0x8: 0x71106, // system - 0xa: 0x64905, // width - 0xc: 0x2890b, // formenctype - 0xd: 0x13702, // ol - 0xe: 0x3970b, // oncuechange - 0x10: 0x14b03, // bdo - 0x11: 0x11505, // audio - 0x12: 0x17a09, // draggable - 0x14: 0x2f105, // video - 0x15: 0x2b102, // mn - 0x16: 0x38704, // menu - 0x17: 0x2cf06, // poster - 0x19: 0xf606, // footer - 0x1a: 0x2a806, // method - 0x1b: 0x2b808, // datetime - 0x1c: 0x19507, // onabort - 0x1d: 0x460e, // updateviacache - 0x1e: 0xff05, // async - 0x1f: 0x49d06, // onload - 0x21: 0x11908, // oncancel - 0x22: 0x62908, // onseeked - 0x23: 0x30205, // image - 0x24: 0x5d812, // onrejectionhandled - 0x26: 0x17404, // link - 0x27: 0x51d06, // output - 0x28: 0x33104, // head - 0x29: 0x4ff0c, // onmouseleave - 0x2a: 0x57f07, // onpaste - 0x2b: 0x5a409, // onplaying - 0x2c: 0x1c407, // colspan - 0x2f: 0x1bf05, // color - 0x30: 0x5f504, // size - 0x31: 0x2e80a, // http-equiv - 0x33: 0x601, // i - 0x34: 0x5590a, // onpagehide - 0x35: 0x68c14, // onunhandledrejection - 0x37: 0x42a07, // onerror - 0x3a: 0x3b08, // basefont - 0x3f: 0x1303, // nav - 0x40: 0x17704, // kind - 0x41: 0x35708, // readonly - 0x42: 0x30806, // mglyph - 0x44: 0xb202, // li - 0x46: 0x2d506, // hidden - 0x47: 0x70e03, // svg - 0x48: 0x58304, // step - 0x49: 0x23f09, // integrity - 0x4a: 0x58606, // public - 0x4c: 0x1ab03, // col - 0x4d: 0x1870a, // blockquote - 0x4e: 0x34f02, // h5 - 0x50: 0x5b908, // progress - 0x51: 0x5f505, // sizes - 0x52: 0x34502, // h4 - 0x56: 0x33005, // thead - 0x57: 0xd607, // keytype - 0x58: 0x5b70a, // onprogress - 0x59: 0x44b09, // inputmode - 0x5a: 0x3b109, // ondragend - 0x5d: 0x3a205, // oncut - 0x5e: 0x43706, // spacer - 0x5f: 0x1ab08, // colgroup - 0x62: 0x16502, // is - 0x65: 0x3c02, // as - 0x66: 0x54809, // onoffline - 0x67: 0x33706, // sorted - 0x69: 0x48d10, // onlanguagechange - 0x6c: 0x43d0c, // onhashchange - 0x6d: 0x9604, // name - 0x6e: 0xf505, // tfoot - 0x6f: 0x56104, // desc - 0x70: 0x33d03, // max - 0x72: 0x1ea06, // coords - 0x73: 0x30d02, // h3 - 0x74: 0x6e70e, // onbeforeunload - 0x75: 0x9c04, // rows - 0x76: 0x63c06, // select - 0x77: 0x9805, // meter - 0x78: 0x38b06, // itemid - 0x79: 0x53c0c, // onmousewheel - 0x7a: 0x5c006, // srcdoc - 0x7d: 0x1ba05, // track - 0x7f: 0x31f08, // itemtype - 0x82: 0xa402, // mo - 0x83: 0x41b08, // onchange - 0x84: 0x33107, // headers - 0x85: 0x5cc0c, // onratechange - 0x86: 0x60819, // onsecuritypolicyviolation - 0x88: 0x4a508, // datalist - 0x89: 0x4e80b, // onmousedown - 0x8a: 0x1ef04, // slot - 0x8b: 0x4b010, // onloadedmetadata - 0x8c: 0x1a06, // accept - 0x8d: 0x26806, // object - 0x91: 0x6b30e, // onvolumechange - 0x92: 0x2107, // charset - 0x93: 0x27613, // onautocompleteerror - 0x94: 0xc113, // allowpaymentrequest - 0x95: 0x2804, // body - 0x96: 0x10a07, // default - 0x97: 0x63c08, // selected - 0x98: 0x21e04, // face - 0x99: 0x1e505, // shape - 0x9b: 0x68408, // ontoggle - 0x9e: 0x64b02, // dt - 0x9f: 0xb604, // mark - 0xa1: 0xb01, // u - 0xa4: 0x6ab08, // onunload - 0xa5: 0x5d04, // loop - 0xa6: 0x16408, // disabled - 0xaa: 0x42307, // onended - 0xab: 0xb00a, // malignmark - 0xad: 0x67b09, // onsuspend - 0xae: 0x35105, // mtext - 0xaf: 0x64f06, // onsort - 0xb0: 0x19d08, // itemprop - 0xb3: 0x67109, // itemscope - 0xb4: 0x17305, // blink - 0xb6: 0x3b106, // ondrag - 0xb7: 0xa702, // ul - 0xb8: 0x26e04, // form - 0xb9: 0x12907, // sandbox - 0xba: 0x8b05, // frame - 0xbb: 0x1505, // value - 0xbc: 0x66209, // onstorage - 0xbf: 0xaa07, // acronym - 0xc0: 0x19a02, // rt - 0xc2: 0x202, // br - 0xc3: 0x22608, // fieldset - 0xc4: 0x2900d, // typemustmatch - 0xc5: 0xa208, // nomodule - 0xc6: 0x6c07, // noembed - 0xc7: 0x69e0d, // onbeforeprint - 0xc8: 0x19106, // button - 0xc9: 0x2f507, // onclick - 0xca: 0x70407, // summary - 0xcd: 0xfb04, // ruby - 0xce: 0x56405, // class - 0xcf: 0x3f40b, // ondragstart - 0xd0: 0x23107, // caption - 0xd4: 0xdd0e, // allowusermedia - 0xd5: 0x4cf0b, // onloadstart - 0xd9: 0x16b03, // div - 0xda: 0x4a904, // list - 0xdb: 0x32e04, // math - 0xdc: 0x44b05, // input - 0xdf: 0x3ea0a, // ondragover - 0xe0: 0x2de02, // h2 - 0xe2: 0x1b209, // plaintext - 0xe4: 0x4f30c, // onmouseenter - 0xe7: 0x47907, // checked - 0xe8: 0x47003, // pre - 0xea: 0x35f08, // multiple - 0xeb: 0xba03, // bdi - 0xec: 0x33d09, // maxlength - 0xed: 0xcf01, // q - 0xee: 0x61f0a, // onauxclick - 0xf0: 0x57c03, // wbr - 0xf2: 0x3b04, // base - 0xf3: 0x6e306, // option - 0xf5: 0x41310, // ondurationchange - 0xf7: 0x8908, // noframes - 0xf9: 0x40508, // dropzone - 0xfb: 0x67505, // scope - 0xfc: 0x8008, // reversed - 0xfd: 0x3ba0b, // ondragenter - 0xfe: 0x3fa05, // start - 0xff: 0x12f03, // xmp - 0x100: 0x5f907, // srclang - 0x101: 0x30703, // img - 0x104: 0x101, // b - 0x105: 0x25403, // for - 0x106: 0x10705, // aside - 0x107: 0x44907, // oninput - 0x108: 0x35604, // area - 0x109: 0x2a40a, // formmethod - 0x10a: 0x72604, // wrap - 0x10c: 0x23c02, // rp - 0x10d: 0x46b0a, // onkeypress - 0x10e: 0x6802, // tt - 0x110: 0x34702, // mi - 0x111: 0x36705, // muted - 0x112: 0xf303, // alt - 0x113: 0x5c504, // code - 0x114: 0x6e02, // em - 0x115: 0x3c50a, // ondragexit - 0x117: 0x9f04, // span - 0x119: 0x6d708, // manifest - 0x11a: 0x38708, // menuitem - 0x11b: 0x58b07, // content - 0x11d: 0x6c109, // onwaiting - 0x11f: 0x4c609, // onloadend - 0x121: 0x37e0d, // oncontextmenu - 0x123: 0x56d06, // onblur - 0x124: 0x3fc07, // article - 0x125: 0x9303, // dir - 0x126: 0xef04, // ping - 0x127: 0x24c08, // required - 0x128: 0x45509, // oninvalid - 0x129: 0xb105, // align - 0x12b: 0x58a04, // icon - 0x12c: 0x64d02, // h6 - 0x12d: 0x1c404, // cols - 0x12e: 0x22e0a, // figcaption - 0x12f: 0x45e09, // onkeydown - 0x130: 0x66b08, // onsubmit - 0x131: 0x14d09, // oncanplay - 0x132: 0x70b03, // sup - 0x133: 0xc01, // p - 0x135: 0x40a09, // onemptied - 0x136: 0x39106, // oncopy - 0x137: 0x19c04, // cite - 0x138: 0x3a70a, // ondblclick - 0x13a: 0x50b0b, // onmousemove - 0x13c: 0x66d03, // sub - 0x13d: 0x48703, // rel - 0x13e: 0x5f08, // optgroup - 0x142: 0x9c07, // rowspan - 0x143: 0x37806, // source - 0x144: 0x21608, // noscript - 0x145: 0x1a304, // open - 0x146: 0x20403, // ins - 0x147: 0x2540d, // foreignObject - 0x148: 0x5ad0a, // onpopstate - 0x14a: 0x28d07, // enctype - 0x14b: 0x2760e, // onautocomplete - 0x14c: 0x35208, // textarea - 0x14e: 0x2780c, // autocomplete - 0x14f: 0x15702, // hr - 0x150: 0x1de08, // controls - 0x151: 0x10902, // id - 0x153: 0x2360c, // onafterprint - 0x155: 0x2610d, // foreignobject - 0x156: 0x32707, // marquee - 0x157: 0x59a07, // onpause - 0x158: 0x5e602, // dl - 0x159: 0x5206, // height - 0x15a: 0x34703, // min - 0x15b: 0x9307, // dirname - 0x15c: 0x1f209, // translate - 0x15d: 0x5604, // html - 0x15e: 0x34709, // minlength - 0x15f: 0x48607, // preload - 0x160: 0x71408, // template - 0x161: 0x3df0b, // ondragleave - 0x162: 0x3a02, // rb - 0x164: 0x5c003, // src - 0x165: 0x6dd06, // strong - 0x167: 0x7804, // samp - 0x168: 0x6f307, // address - 0x169: 0x55108, // ononline - 0x16b: 0x1310b, // placeholder - 0x16c: 0x2c406, // target - 0x16d: 0x20605, // small - 0x16e: 0x6ca07, // onwheel - 0x16f: 0x1c90a, // annotation - 0x170: 0x4740a, // spellcheck - 0x171: 0x7207, // details - 0x172: 0x10306, // canvas - 0x173: 0x12109, // autofocus - 0x174: 0xc05, // param - 0x176: 0x46308, // download - 0x177: 0x45203, // del - 0x178: 0x36c07, // onclose - 0x179: 0xb903, // kbd - 0x17a: 0x31906, // applet - 0x17b: 0x2e004, // href - 0x17c: 0x5f108, // onresize - 0x17e: 0x49d0c, // onloadeddata - 0x180: 0xcc02, // tr - 0x181: 0x2c00a, // formtarget - 0x182: 0x11005, // title - 0x183: 0x6ff05, // style - 0x184: 0xd206, // strike - 0x185: 0x59e06, // usemap - 0x186: 0x2fc06, // iframe - 0x187: 0x1004, // main - 0x189: 0x7b07, // picture - 0x18c: 0x31605, // ismap - 0x18e: 0x4a504, // data - 0x18f: 0x5905, // label - 0x191: 0x3d10e, // referrerpolicy - 0x192: 0x15602, // th - 0x194: 0x53606, // prompt - 0x195: 0x56807, // section - 0x197: 0x6d107, // optimum - 0x198: 0x2db04, // high - 0x199: 0x15c02, // h1 - 0x19a: 0x65909, // onstalled - 0x19b: 0x16d03, // var - 0x19c: 0x4204, // time - 0x19e: 0x67402, // ms - 0x19f: 0x33106, // header - 0x1a0: 0x4da09, // onmessage - 0x1a1: 0x1a605, // nonce - 0x1a2: 0x26e0a, // formaction - 0x1a3: 0x22006, // center - 0x1a4: 0x3704, // nobr - 0x1a5: 0x59505, // table - 0x1a6: 0x4a907, // listing - 0x1a7: 0x18106, // legend - 0x1a9: 0x29b09, // challenge - 0x1aa: 0x24806, // figure - 0x1ab: 0xe605, // media - 0x1ae: 0xd904, // type - 0x1af: 0x3f04, // font - 0x1b0: 0x4da0e, // onmessageerror - 0x1b1: 0x37108, // seamless - 0x1b2: 0x8703, // dfn - 0x1b3: 0x5c705, // defer - 0x1b4: 0xc303, // low - 0x1b5: 0x19a03, // rtc - 0x1b6: 0x5230b, // onmouseover - 0x1b7: 0x2b20a, // novalidate - 0x1b8: 0x71c0a, // workertype - 0x1ba: 0x3cd07, // itemref - 0x1bd: 0x1, // a - 0x1be: 0x31803, // map - 0x1bf: 0x400c, // ontimeupdate - 0x1c0: 0x15e07, // bgsound - 0x1c1: 0x3206, // keygen - 0x1c2: 0x2705, // tbody - 0x1c5: 0x64406, // onshow - 0x1c7: 0x2501, // s - 0x1c8: 0x6607, // pattern - 0x1cc: 0x14d10, // oncanplaythrough - 0x1ce: 0x2d702, // dd - 0x1cf: 0x6f906, // srcset - 0x1d0: 0x17003, // big - 0x1d2: 0x65108, // sortable - 0x1d3: 0x48007, // onkeyup - 0x1d5: 0x5a406, // onplay - 0x1d7: 0x4b804, // meta - 0x1d8: 0x40306, // ondrop - 0x1da: 0x60008, // onscroll - 0x1db: 0x1fb0b, // crossorigin - 0x1dc: 0x5730a, // onpageshow - 0x1dd: 0x4, // abbr - 0x1de: 0x9202, // td - 0x1df: 0x58b0f, // contenteditable - 0x1e0: 0x27206, // action - 0x1e1: 0x1400b, // playsinline - 0x1e2: 0x43107, // onfocus - 0x1e3: 0x2e008, // hreflang - 0x1e5: 0x5160a, // onmouseout - 0x1e6: 0x5ea07, // onreset - 0x1e7: 0x13c08, // autoplay - 0x1e8: 0x63109, // onseeking - 0x1ea: 0x67506, // scoped - 0x1ec: 0x30a, // radiogroup - 0x1ee: 0x3800b, // contextmenu - 0x1ef: 0x52e09, // onmouseup - 0x1f1: 0x2ca06, // hgroup - 0x1f2: 0x2080f, // allowfullscreen - 0x1f3: 0x4be08, // tabindex - 0x1f6: 0x30f07, // isindex - 0x1f7: 0x1a0e, // accept-charset - 0x1f8: 0x2ae0e, // formnovalidate - 0x1fb: 0x1c90e, // annotation-xml - 0x1fc: 0x6e05, // embed - 0x1fd: 0x21806, // script - 0x1fe: 0xbb06, // dialog - 0x1ff: 0x1d707, // command -} - -const atomText = "abbradiogrouparamainavalueaccept-charsetbodyaccesskeygenobrb" + - "asefontimeupdateviacacheightmlabelooptgroupatternoembedetail" + - "sampictureversedfnoframesetdirnameterowspanomoduleacronymali" + - "gnmarkbdialogallowpaymentrequestrikeytypeallowusermediagroup" + - "ingaltfooterubyasyncanvasidefaultitleaudioncancelautofocusan" + - "dboxmplaceholderautoplaysinlinebdoncanplaythrough1bgsoundisa" + - "bledivarbigblinkindraggablegendblockquotebuttonabortcitempro" + - "penoncecolgrouplaintextrackcolorcolspannotation-xmlcommandco" + - "ntrolshapecoordslotranslatecrossoriginsmallowfullscreenoscri" + - "ptfacenterfieldsetfigcaptionafterprintegrityfigurequiredfore" + - "ignObjectforeignobjectformactionautocompleteerrorformenctype" + - "mustmatchallengeformmethodformnovalidatetimeformtargethgroup" + - "osterhiddenhigh2hreflanghttp-equivideonclickiframeimageimgly" + - "ph3isindexismappletitemtypemarqueematheadersortedmaxlength4m" + - "inlength5mtextareadonlymultiplemutedoncloseamlessourceoncont" + - "extmenuitemidoncopyoncuechangeoncutondblclickondragendondrag" + - "enterondragexitemreferrerpolicyondragleaveondragoverondragst" + - "articleondropzonemptiedondurationchangeonendedonerroronfocus" + - "paceronhashchangeoninputmodeloninvalidonkeydownloadonkeypres" + - "spellcheckedonkeyupreloadonlanguagechangeonloadeddatalisting" + - "onloadedmetadatabindexonloadendonloadstartonmessageerroronmo" + - "usedownonmouseenteronmouseleaveonmousemoveonmouseoutputonmou" + - "seoveronmouseupromptonmousewheelonofflineononlineonpagehides" + - "classectionbluronpageshowbronpastepublicontenteditableonpaus" + - "emaponplayingonpopstateonprogressrcdocodeferonratechangeonre" + - "jectionhandledonresetonresizesrclangonscrollonsecuritypolicy" + - "violationauxclickonseekedonseekingonselectedonshowidth6onsor" + - "tableonstalledonstorageonsubmitemscopedonsuspendontoggleonun" + - "handledrejectionbeforeprintonunloadonvolumechangeonwaitingon" + - "wheeloptimumanifestrongoptionbeforeunloaddressrcsetstylesumm" + - "arysupsvgsystemplateworkertypewrap" diff --git a/vendor/golang.org/x/net/html/const.go b/vendor/golang.org/x/net/html/const.go deleted file mode 100644 index a3a918f..0000000 --- a/vendor/golang.org/x/net/html/const.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -// Section 12.2.4.2 of the HTML5 specification says "The following elements -// have varying levels of special parsing rules". -// https://html.spec.whatwg.org/multipage/syntax.html#the-stack-of-open-elements -var isSpecialElementMap = map[string]bool{ - "address": true, - "applet": true, - "area": true, - "article": true, - "aside": true, - "base": true, - "basefont": true, - "bgsound": true, - "blockquote": true, - "body": true, - "br": true, - "button": true, - "caption": true, - "center": true, - "col": true, - "colgroup": true, - "dd": true, - "details": true, - "dir": true, - "div": true, - "dl": true, - "dt": true, - "embed": true, - "fieldset": true, - "figcaption": true, - "figure": true, - "footer": true, - "form": true, - "frame": true, - "frameset": true, - "h1": true, - "h2": true, - "h3": true, - "h4": true, - "h5": true, - "h6": true, - "head": true, - "header": true, - "hgroup": true, - "hr": true, - "html": true, - "iframe": true, - "img": true, - "input": true, - "isindex": true, // The 'isindex' element has been removed, but keep it for backwards compatibility. - "keygen": true, - "li": true, - "link": true, - "listing": true, - "main": true, - "marquee": true, - "menu": true, - "meta": true, - "nav": true, - "noembed": true, - "noframes": true, - "noscript": true, - "object": true, - "ol": true, - "p": true, - "param": true, - "plaintext": true, - "pre": true, - "script": true, - "section": true, - "select": true, - "source": true, - "style": true, - "summary": true, - "table": true, - "tbody": true, - "td": true, - "template": true, - "textarea": true, - "tfoot": true, - "th": true, - "thead": true, - "title": true, - "tr": true, - "track": true, - "ul": true, - "wbr": true, - "xmp": true, -} - -func isSpecialElement(element *Node) bool { - switch element.Namespace { - case "", "html": - return isSpecialElementMap[element.Data] - case "math": - switch element.Data { - case "mi", "mo", "mn", "ms", "mtext", "annotation-xml": - return true - } - case "svg": - switch element.Data { - case "foreignObject", "desc", "title": - return true - } - } - return false -} diff --git a/vendor/golang.org/x/net/html/doc.go b/vendor/golang.org/x/net/html/doc.go deleted file mode 100644 index 822ed42..0000000 --- a/vendor/golang.org/x/net/html/doc.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -Package html implements an HTML5-compliant tokenizer and parser. - -Tokenization is done by creating a Tokenizer for an io.Reader r. It is the -caller's responsibility to ensure that r provides UTF-8 encoded HTML. - - z := html.NewTokenizer(r) - -Given a Tokenizer z, the HTML is tokenized by repeatedly calling z.Next(), -which parses the next token and returns its type, or an error: - - for { - tt := z.Next() - if tt == html.ErrorToken { - // ... - return ... - } - // Process the current token. - } - -There are two APIs for retrieving the current token. The high-level API is to -call Token; the low-level API is to call Text or TagName / TagAttr. Both APIs -allow optionally calling Raw after Next but before Token, Text, TagName, or -TagAttr. In EBNF notation, the valid call sequence per token is: - - Next {Raw} [ Token | Text | TagName {TagAttr} ] - -Token returns an independent data structure that completely describes a token. -Entities (such as "<") are unescaped, tag names and attribute keys are -lower-cased, and attributes are collected into a []Attribute. For example: - - for { - if z.Next() == html.ErrorToken { - // Returning io.EOF indicates success. - return z.Err() - } - emitToken(z.Token()) - } - -The low-level API performs fewer allocations and copies, but the contents of -the []byte values returned by Text, TagName and TagAttr may change on the next -call to Next. For example, to extract an HTML page's anchor text: - - depth := 0 - for { - tt := z.Next() - switch tt { - case html.ErrorToken: - return z.Err() - case html.TextToken: - if depth > 0 { - // emitBytes should copy the []byte it receives, - // if it doesn't process it immediately. - emitBytes(z.Text()) - } - case html.StartTagToken, html.EndTagToken: - tn, _ := z.TagName() - if len(tn) == 1 && tn[0] == 'a' { - if tt == html.StartTagToken { - depth++ - } else { - depth-- - } - } - } - } - -Parsing is done by calling Parse with an io.Reader, which returns the root of -the parse tree (the document element) as a *Node. It is the caller's -responsibility to ensure that the Reader provides UTF-8 encoded HTML. For -example, to process each anchor node in depth-first order: - - doc, err := html.Parse(r) - if err != nil { - // ... - } - var f func(*html.Node) - f = func(n *html.Node) { - if n.Type == html.ElementNode && n.Data == "a" { - // Do something with n... - } - for c := n.FirstChild; c != nil; c = c.NextSibling { - f(c) - } - } - f(doc) - -The relevant specifications include: -https://html.spec.whatwg.org/multipage/syntax.html and -https://html.spec.whatwg.org/multipage/syntax.html#tokenization -*/ -package html // import "golang.org/x/net/html" - -// The tokenization algorithm implemented by this package is not a line-by-line -// transliteration of the relatively verbose state-machine in the WHATWG -// specification. A more direct approach is used instead, where the program -// counter implies the state, such as whether it is tokenizing a tag or a text -// node. Specification compliance is verified by checking expected and actual -// outputs over a test suite rather than aiming for algorithmic fidelity. - -// TODO(nigeltao): Does a DOM API belong in this package or a separate one? -// TODO(nigeltao): How does parsing interact with a JavaScript engine? diff --git a/vendor/golang.org/x/net/html/doctype.go b/vendor/golang.org/x/net/html/doctype.go deleted file mode 100644 index c484e5a..0000000 --- a/vendor/golang.org/x/net/html/doctype.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -import ( - "strings" -) - -// parseDoctype parses the data from a DoctypeToken into a name, -// public identifier, and system identifier. It returns a Node whose Type -// is DoctypeNode, whose Data is the name, and which has attributes -// named "system" and "public" for the two identifiers if they were present. -// quirks is whether the document should be parsed in "quirks mode". -func parseDoctype(s string) (n *Node, quirks bool) { - n = &Node{Type: DoctypeNode} - - // Find the name. - space := strings.IndexAny(s, whitespace) - if space == -1 { - space = len(s) - } - n.Data = s[:space] - // The comparison to "html" is case-sensitive. - if n.Data != "html" { - quirks = true - } - n.Data = strings.ToLower(n.Data) - s = strings.TrimLeft(s[space:], whitespace) - - if len(s) < 6 { - // It can't start with "PUBLIC" or "SYSTEM". - // Ignore the rest of the string. - return n, quirks || s != "" - } - - key := strings.ToLower(s[:6]) - s = s[6:] - for key == "public" || key == "system" { - s = strings.TrimLeft(s, whitespace) - if s == "" { - break - } - quote := s[0] - if quote != '"' && quote != '\'' { - break - } - s = s[1:] - q := strings.IndexRune(s, rune(quote)) - var id string - if q == -1 { - id = s - s = "" - } else { - id = s[:q] - s = s[q+1:] - } - n.Attr = append(n.Attr, Attribute{Key: key, Val: id}) - if key == "public" { - key = "system" - } else { - key = "" - } - } - - if key != "" || s != "" { - quirks = true - } else if len(n.Attr) > 0 { - if n.Attr[0].Key == "public" { - public := strings.ToLower(n.Attr[0].Val) - switch public { - case "-//w3o//dtd w3 html strict 3.0//en//", "-/w3d/dtd html 4.0 transitional/en", "html": - quirks = true - default: - for _, q := range quirkyIDs { - if strings.HasPrefix(public, q) { - quirks = true - break - } - } - } - // The following two public IDs only cause quirks mode if there is no system ID. - if len(n.Attr) == 1 && (strings.HasPrefix(public, "-//w3c//dtd html 4.01 frameset//") || - strings.HasPrefix(public, "-//w3c//dtd html 4.01 transitional//")) { - quirks = true - } - } - if lastAttr := n.Attr[len(n.Attr)-1]; lastAttr.Key == "system" && - strings.ToLower(lastAttr.Val) == "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd" { - quirks = true - } - } - - return n, quirks -} - -// quirkyIDs is a list of public doctype identifiers that cause a document -// to be interpreted in quirks mode. The identifiers should be in lower case. -var quirkyIDs = []string{ - "+//silmaril//dtd html pro v0r11 19970101//", - "-//advasoft ltd//dtd html 3.0 aswedit + extensions//", - "-//as//dtd html 3.0 aswedit + extensions//", - "-//ietf//dtd html 2.0 level 1//", - "-//ietf//dtd html 2.0 level 2//", - "-//ietf//dtd html 2.0 strict level 1//", - "-//ietf//dtd html 2.0 strict level 2//", - "-//ietf//dtd html 2.0 strict//", - "-//ietf//dtd html 2.0//", - "-//ietf//dtd html 2.1e//", - "-//ietf//dtd html 3.0//", - "-//ietf//dtd html 3.2 final//", - "-//ietf//dtd html 3.2//", - "-//ietf//dtd html 3//", - "-//ietf//dtd html level 0//", - "-//ietf//dtd html level 1//", - "-//ietf//dtd html level 2//", - "-//ietf//dtd html level 3//", - "-//ietf//dtd html strict level 0//", - "-//ietf//dtd html strict level 1//", - "-//ietf//dtd html strict level 2//", - "-//ietf//dtd html strict level 3//", - "-//ietf//dtd html strict//", - "-//ietf//dtd html//", - "-//metrius//dtd metrius presentational//", - "-//microsoft//dtd internet explorer 2.0 html strict//", - "-//microsoft//dtd internet explorer 2.0 html//", - "-//microsoft//dtd internet explorer 2.0 tables//", - "-//microsoft//dtd internet explorer 3.0 html strict//", - "-//microsoft//dtd internet explorer 3.0 html//", - "-//microsoft//dtd internet explorer 3.0 tables//", - "-//netscape comm. corp.//dtd html//", - "-//netscape comm. corp.//dtd strict html//", - "-//o'reilly and associates//dtd html 2.0//", - "-//o'reilly and associates//dtd html extended 1.0//", - "-//o'reilly and associates//dtd html extended relaxed 1.0//", - "-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//", - "-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//", - "-//spyglass//dtd html 2.0 extended//", - "-//sq//dtd html 2.0 hotmetal + extensions//", - "-//sun microsystems corp.//dtd hotjava html//", - "-//sun microsystems corp.//dtd hotjava strict html//", - "-//w3c//dtd html 3 1995-03-24//", - "-//w3c//dtd html 3.2 draft//", - "-//w3c//dtd html 3.2 final//", - "-//w3c//dtd html 3.2//", - "-//w3c//dtd html 3.2s draft//", - "-//w3c//dtd html 4.0 frameset//", - "-//w3c//dtd html 4.0 transitional//", - "-//w3c//dtd html experimental 19960712//", - "-//w3c//dtd html experimental 970421//", - "-//w3c//dtd w3 html//", - "-//w3o//dtd w3 html 3.0//", - "-//webtechs//dtd mozilla html 2.0//", - "-//webtechs//dtd mozilla html//", -} diff --git a/vendor/golang.org/x/net/html/entity.go b/vendor/golang.org/x/net/html/entity.go deleted file mode 100644 index b628880..0000000 --- a/vendor/golang.org/x/net/html/entity.go +++ /dev/null @@ -1,2253 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -// All entities that do not end with ';' are 6 or fewer bytes long. -const longestEntityWithoutSemicolon = 6 - -// entity is a map from HTML entity names to their values. The semicolon matters: -// https://html.spec.whatwg.org/multipage/syntax.html#named-character-references -// lists both "amp" and "amp;" as two separate entries. -// -// Note that the HTML5 list is larger than the HTML4 list at -// http://www.w3.org/TR/html4/sgml/entities.html -var entity = map[string]rune{ - "AElig;": '\U000000C6', - "AMP;": '\U00000026', - "Aacute;": '\U000000C1', - "Abreve;": '\U00000102', - "Acirc;": '\U000000C2', - "Acy;": '\U00000410', - "Afr;": '\U0001D504', - "Agrave;": '\U000000C0', - "Alpha;": '\U00000391', - "Amacr;": '\U00000100', - "And;": '\U00002A53', - "Aogon;": '\U00000104', - "Aopf;": '\U0001D538', - "ApplyFunction;": '\U00002061', - "Aring;": '\U000000C5', - "Ascr;": '\U0001D49C', - "Assign;": '\U00002254', - "Atilde;": '\U000000C3', - "Auml;": '\U000000C4', - "Backslash;": '\U00002216', - "Barv;": '\U00002AE7', - "Barwed;": '\U00002306', - "Bcy;": '\U00000411', - "Because;": '\U00002235', - "Bernoullis;": '\U0000212C', - "Beta;": '\U00000392', - "Bfr;": '\U0001D505', - "Bopf;": '\U0001D539', - "Breve;": '\U000002D8', - "Bscr;": '\U0000212C', - "Bumpeq;": '\U0000224E', - "CHcy;": '\U00000427', - "COPY;": '\U000000A9', - "Cacute;": '\U00000106', - "Cap;": '\U000022D2', - "CapitalDifferentialD;": '\U00002145', - "Cayleys;": '\U0000212D', - "Ccaron;": '\U0000010C', - "Ccedil;": '\U000000C7', - "Ccirc;": '\U00000108', - "Cconint;": '\U00002230', - "Cdot;": '\U0000010A', - "Cedilla;": '\U000000B8', - "CenterDot;": '\U000000B7', - "Cfr;": '\U0000212D', - "Chi;": '\U000003A7', - "CircleDot;": '\U00002299', - "CircleMinus;": '\U00002296', - "CirclePlus;": '\U00002295', - "CircleTimes;": '\U00002297', - "ClockwiseContourIntegral;": '\U00002232', - "CloseCurlyDoubleQuote;": '\U0000201D', - "CloseCurlyQuote;": '\U00002019', - "Colon;": '\U00002237', - "Colone;": '\U00002A74', - "Congruent;": '\U00002261', - "Conint;": '\U0000222F', - "ContourIntegral;": '\U0000222E', - "Copf;": '\U00002102', - "Coproduct;": '\U00002210', - "CounterClockwiseContourIntegral;": '\U00002233', - "Cross;": '\U00002A2F', - "Cscr;": '\U0001D49E', - "Cup;": '\U000022D3', - "CupCap;": '\U0000224D', - "DD;": '\U00002145', - "DDotrahd;": '\U00002911', - "DJcy;": '\U00000402', - "DScy;": '\U00000405', - "DZcy;": '\U0000040F', - "Dagger;": '\U00002021', - "Darr;": '\U000021A1', - "Dashv;": '\U00002AE4', - "Dcaron;": '\U0000010E', - "Dcy;": '\U00000414', - "Del;": '\U00002207', - "Delta;": '\U00000394', - "Dfr;": '\U0001D507', - "DiacriticalAcute;": '\U000000B4', - "DiacriticalDot;": '\U000002D9', - "DiacriticalDoubleAcute;": '\U000002DD', - "DiacriticalGrave;": '\U00000060', - "DiacriticalTilde;": '\U000002DC', - "Diamond;": '\U000022C4', - "DifferentialD;": '\U00002146', - "Dopf;": '\U0001D53B', - "Dot;": '\U000000A8', - "DotDot;": '\U000020DC', - "DotEqual;": '\U00002250', - "DoubleContourIntegral;": '\U0000222F', - "DoubleDot;": '\U000000A8', - "DoubleDownArrow;": '\U000021D3', - "DoubleLeftArrow;": '\U000021D0', - "DoubleLeftRightArrow;": '\U000021D4', - "DoubleLeftTee;": '\U00002AE4', - "DoubleLongLeftArrow;": '\U000027F8', - "DoubleLongLeftRightArrow;": '\U000027FA', - "DoubleLongRightArrow;": '\U000027F9', - "DoubleRightArrow;": '\U000021D2', - "DoubleRightTee;": '\U000022A8', - "DoubleUpArrow;": '\U000021D1', - "DoubleUpDownArrow;": '\U000021D5', - "DoubleVerticalBar;": '\U00002225', - "DownArrow;": '\U00002193', - "DownArrowBar;": '\U00002913', - "DownArrowUpArrow;": '\U000021F5', - "DownBreve;": '\U00000311', - "DownLeftRightVector;": '\U00002950', - "DownLeftTeeVector;": '\U0000295E', - "DownLeftVector;": '\U000021BD', - "DownLeftVectorBar;": '\U00002956', - "DownRightTeeVector;": '\U0000295F', - "DownRightVector;": '\U000021C1', - "DownRightVectorBar;": '\U00002957', - "DownTee;": '\U000022A4', - "DownTeeArrow;": '\U000021A7', - "Downarrow;": '\U000021D3', - "Dscr;": '\U0001D49F', - "Dstrok;": '\U00000110', - "ENG;": '\U0000014A', - "ETH;": '\U000000D0', - "Eacute;": '\U000000C9', - "Ecaron;": '\U0000011A', - "Ecirc;": '\U000000CA', - "Ecy;": '\U0000042D', - "Edot;": '\U00000116', - "Efr;": '\U0001D508', - "Egrave;": '\U000000C8', - "Element;": '\U00002208', - "Emacr;": '\U00000112', - "EmptySmallSquare;": '\U000025FB', - "EmptyVerySmallSquare;": '\U000025AB', - "Eogon;": '\U00000118', - "Eopf;": '\U0001D53C', - "Epsilon;": '\U00000395', - "Equal;": '\U00002A75', - "EqualTilde;": '\U00002242', - "Equilibrium;": '\U000021CC', - "Escr;": '\U00002130', - "Esim;": '\U00002A73', - "Eta;": '\U00000397', - "Euml;": '\U000000CB', - "Exists;": '\U00002203', - "ExponentialE;": '\U00002147', - "Fcy;": '\U00000424', - "Ffr;": '\U0001D509', - "FilledSmallSquare;": '\U000025FC', - "FilledVerySmallSquare;": '\U000025AA', - "Fopf;": '\U0001D53D', - "ForAll;": '\U00002200', - "Fouriertrf;": '\U00002131', - "Fscr;": '\U00002131', - "GJcy;": '\U00000403', - "GT;": '\U0000003E', - "Gamma;": '\U00000393', - "Gammad;": '\U000003DC', - "Gbreve;": '\U0000011E', - "Gcedil;": '\U00000122', - "Gcirc;": '\U0000011C', - "Gcy;": '\U00000413', - "Gdot;": '\U00000120', - "Gfr;": '\U0001D50A', - "Gg;": '\U000022D9', - "Gopf;": '\U0001D53E', - "GreaterEqual;": '\U00002265', - "GreaterEqualLess;": '\U000022DB', - "GreaterFullEqual;": '\U00002267', - "GreaterGreater;": '\U00002AA2', - "GreaterLess;": '\U00002277', - "GreaterSlantEqual;": '\U00002A7E', - "GreaterTilde;": '\U00002273', - "Gscr;": '\U0001D4A2', - "Gt;": '\U0000226B', - "HARDcy;": '\U0000042A', - "Hacek;": '\U000002C7', - "Hat;": '\U0000005E', - "Hcirc;": '\U00000124', - "Hfr;": '\U0000210C', - "HilbertSpace;": '\U0000210B', - "Hopf;": '\U0000210D', - "HorizontalLine;": '\U00002500', - "Hscr;": '\U0000210B', - "Hstrok;": '\U00000126', - "HumpDownHump;": '\U0000224E', - "HumpEqual;": '\U0000224F', - "IEcy;": '\U00000415', - "IJlig;": '\U00000132', - "IOcy;": '\U00000401', - "Iacute;": '\U000000CD', - "Icirc;": '\U000000CE', - "Icy;": '\U00000418', - "Idot;": '\U00000130', - "Ifr;": '\U00002111', - "Igrave;": '\U000000CC', - "Im;": '\U00002111', - "Imacr;": '\U0000012A', - "ImaginaryI;": '\U00002148', - "Implies;": '\U000021D2', - "Int;": '\U0000222C', - "Integral;": '\U0000222B', - "Intersection;": '\U000022C2', - "InvisibleComma;": '\U00002063', - "InvisibleTimes;": '\U00002062', - "Iogon;": '\U0000012E', - "Iopf;": '\U0001D540', - "Iota;": '\U00000399', - "Iscr;": '\U00002110', - "Itilde;": '\U00000128', - "Iukcy;": '\U00000406', - "Iuml;": '\U000000CF', - "Jcirc;": '\U00000134', - "Jcy;": '\U00000419', - "Jfr;": '\U0001D50D', - "Jopf;": '\U0001D541', - "Jscr;": '\U0001D4A5', - "Jsercy;": '\U00000408', - "Jukcy;": '\U00000404', - "KHcy;": '\U00000425', - "KJcy;": '\U0000040C', - "Kappa;": '\U0000039A', - "Kcedil;": '\U00000136', - "Kcy;": '\U0000041A', - "Kfr;": '\U0001D50E', - "Kopf;": '\U0001D542', - "Kscr;": '\U0001D4A6', - "LJcy;": '\U00000409', - "LT;": '\U0000003C', - "Lacute;": '\U00000139', - "Lambda;": '\U0000039B', - "Lang;": '\U000027EA', - "Laplacetrf;": '\U00002112', - "Larr;": '\U0000219E', - "Lcaron;": '\U0000013D', - "Lcedil;": '\U0000013B', - "Lcy;": '\U0000041B', - "LeftAngleBracket;": '\U000027E8', - "LeftArrow;": '\U00002190', - "LeftArrowBar;": '\U000021E4', - "LeftArrowRightArrow;": '\U000021C6', - "LeftCeiling;": '\U00002308', - "LeftDoubleBracket;": '\U000027E6', - "LeftDownTeeVector;": '\U00002961', - "LeftDownVector;": '\U000021C3', - "LeftDownVectorBar;": '\U00002959', - "LeftFloor;": '\U0000230A', - "LeftRightArrow;": '\U00002194', - "LeftRightVector;": '\U0000294E', - "LeftTee;": '\U000022A3', - "LeftTeeArrow;": '\U000021A4', - "LeftTeeVector;": '\U0000295A', - "LeftTriangle;": '\U000022B2', - "LeftTriangleBar;": '\U000029CF', - "LeftTriangleEqual;": '\U000022B4', - "LeftUpDownVector;": '\U00002951', - "LeftUpTeeVector;": '\U00002960', - "LeftUpVector;": '\U000021BF', - "LeftUpVectorBar;": '\U00002958', - "LeftVector;": '\U000021BC', - "LeftVectorBar;": '\U00002952', - "Leftarrow;": '\U000021D0', - "Leftrightarrow;": '\U000021D4', - "LessEqualGreater;": '\U000022DA', - "LessFullEqual;": '\U00002266', - "LessGreater;": '\U00002276', - "LessLess;": '\U00002AA1', - "LessSlantEqual;": '\U00002A7D', - "LessTilde;": '\U00002272', - "Lfr;": '\U0001D50F', - "Ll;": '\U000022D8', - "Lleftarrow;": '\U000021DA', - "Lmidot;": '\U0000013F', - "LongLeftArrow;": '\U000027F5', - "LongLeftRightArrow;": '\U000027F7', - "LongRightArrow;": '\U000027F6', - "Longleftarrow;": '\U000027F8', - "Longleftrightarrow;": '\U000027FA', - "Longrightarrow;": '\U000027F9', - "Lopf;": '\U0001D543', - "LowerLeftArrow;": '\U00002199', - "LowerRightArrow;": '\U00002198', - "Lscr;": '\U00002112', - "Lsh;": '\U000021B0', - "Lstrok;": '\U00000141', - "Lt;": '\U0000226A', - "Map;": '\U00002905', - "Mcy;": '\U0000041C', - "MediumSpace;": '\U0000205F', - "Mellintrf;": '\U00002133', - "Mfr;": '\U0001D510', - "MinusPlus;": '\U00002213', - "Mopf;": '\U0001D544', - "Mscr;": '\U00002133', - "Mu;": '\U0000039C', - "NJcy;": '\U0000040A', - "Nacute;": '\U00000143', - "Ncaron;": '\U00000147', - "Ncedil;": '\U00000145', - "Ncy;": '\U0000041D', - "NegativeMediumSpace;": '\U0000200B', - "NegativeThickSpace;": '\U0000200B', - "NegativeThinSpace;": '\U0000200B', - "NegativeVeryThinSpace;": '\U0000200B', - "NestedGreaterGreater;": '\U0000226B', - "NestedLessLess;": '\U0000226A', - "NewLine;": '\U0000000A', - "Nfr;": '\U0001D511', - "NoBreak;": '\U00002060', - "NonBreakingSpace;": '\U000000A0', - "Nopf;": '\U00002115', - "Not;": '\U00002AEC', - "NotCongruent;": '\U00002262', - "NotCupCap;": '\U0000226D', - "NotDoubleVerticalBar;": '\U00002226', - "NotElement;": '\U00002209', - "NotEqual;": '\U00002260', - "NotExists;": '\U00002204', - "NotGreater;": '\U0000226F', - "NotGreaterEqual;": '\U00002271', - "NotGreaterLess;": '\U00002279', - "NotGreaterTilde;": '\U00002275', - "NotLeftTriangle;": '\U000022EA', - "NotLeftTriangleEqual;": '\U000022EC', - "NotLess;": '\U0000226E', - "NotLessEqual;": '\U00002270', - "NotLessGreater;": '\U00002278', - "NotLessTilde;": '\U00002274', - "NotPrecedes;": '\U00002280', - "NotPrecedesSlantEqual;": '\U000022E0', - "NotReverseElement;": '\U0000220C', - "NotRightTriangle;": '\U000022EB', - "NotRightTriangleEqual;": '\U000022ED', - "NotSquareSubsetEqual;": '\U000022E2', - "NotSquareSupersetEqual;": '\U000022E3', - "NotSubsetEqual;": '\U00002288', - "NotSucceeds;": '\U00002281', - "NotSucceedsSlantEqual;": '\U000022E1', - "NotSupersetEqual;": '\U00002289', - "NotTilde;": '\U00002241', - "NotTildeEqual;": '\U00002244', - "NotTildeFullEqual;": '\U00002247', - "NotTildeTilde;": '\U00002249', - "NotVerticalBar;": '\U00002224', - "Nscr;": '\U0001D4A9', - "Ntilde;": '\U000000D1', - "Nu;": '\U0000039D', - "OElig;": '\U00000152', - "Oacute;": '\U000000D3', - "Ocirc;": '\U000000D4', - "Ocy;": '\U0000041E', - "Odblac;": '\U00000150', - "Ofr;": '\U0001D512', - "Ograve;": '\U000000D2', - "Omacr;": '\U0000014C', - "Omega;": '\U000003A9', - "Omicron;": '\U0000039F', - "Oopf;": '\U0001D546', - "OpenCurlyDoubleQuote;": '\U0000201C', - "OpenCurlyQuote;": '\U00002018', - "Or;": '\U00002A54', - "Oscr;": '\U0001D4AA', - "Oslash;": '\U000000D8', - "Otilde;": '\U000000D5', - "Otimes;": '\U00002A37', - "Ouml;": '\U000000D6', - "OverBar;": '\U0000203E', - "OverBrace;": '\U000023DE', - "OverBracket;": '\U000023B4', - "OverParenthesis;": '\U000023DC', - "PartialD;": '\U00002202', - "Pcy;": '\U0000041F', - "Pfr;": '\U0001D513', - "Phi;": '\U000003A6', - "Pi;": '\U000003A0', - "PlusMinus;": '\U000000B1', - "Poincareplane;": '\U0000210C', - "Popf;": '\U00002119', - "Pr;": '\U00002ABB', - "Precedes;": '\U0000227A', - "PrecedesEqual;": '\U00002AAF', - "PrecedesSlantEqual;": '\U0000227C', - "PrecedesTilde;": '\U0000227E', - "Prime;": '\U00002033', - "Product;": '\U0000220F', - "Proportion;": '\U00002237', - "Proportional;": '\U0000221D', - "Pscr;": '\U0001D4AB', - "Psi;": '\U000003A8', - "QUOT;": '\U00000022', - "Qfr;": '\U0001D514', - "Qopf;": '\U0000211A', - "Qscr;": '\U0001D4AC', - "RBarr;": '\U00002910', - "REG;": '\U000000AE', - "Racute;": '\U00000154', - "Rang;": '\U000027EB', - "Rarr;": '\U000021A0', - "Rarrtl;": '\U00002916', - "Rcaron;": '\U00000158', - "Rcedil;": '\U00000156', - "Rcy;": '\U00000420', - "Re;": '\U0000211C', - "ReverseElement;": '\U0000220B', - "ReverseEquilibrium;": '\U000021CB', - "ReverseUpEquilibrium;": '\U0000296F', - "Rfr;": '\U0000211C', - "Rho;": '\U000003A1', - "RightAngleBracket;": '\U000027E9', - "RightArrow;": '\U00002192', - "RightArrowBar;": '\U000021E5', - "RightArrowLeftArrow;": '\U000021C4', - "RightCeiling;": '\U00002309', - "RightDoubleBracket;": '\U000027E7', - "RightDownTeeVector;": '\U0000295D', - "RightDownVector;": '\U000021C2', - "RightDownVectorBar;": '\U00002955', - "RightFloor;": '\U0000230B', - "RightTee;": '\U000022A2', - "RightTeeArrow;": '\U000021A6', - "RightTeeVector;": '\U0000295B', - "RightTriangle;": '\U000022B3', - "RightTriangleBar;": '\U000029D0', - "RightTriangleEqual;": '\U000022B5', - "RightUpDownVector;": '\U0000294F', - "RightUpTeeVector;": '\U0000295C', - "RightUpVector;": '\U000021BE', - "RightUpVectorBar;": '\U00002954', - "RightVector;": '\U000021C0', - "RightVectorBar;": '\U00002953', - "Rightarrow;": '\U000021D2', - "Ropf;": '\U0000211D', - "RoundImplies;": '\U00002970', - "Rrightarrow;": '\U000021DB', - "Rscr;": '\U0000211B', - "Rsh;": '\U000021B1', - "RuleDelayed;": '\U000029F4', - "SHCHcy;": '\U00000429', - "SHcy;": '\U00000428', - "SOFTcy;": '\U0000042C', - "Sacute;": '\U0000015A', - "Sc;": '\U00002ABC', - "Scaron;": '\U00000160', - "Scedil;": '\U0000015E', - "Scirc;": '\U0000015C', - "Scy;": '\U00000421', - "Sfr;": '\U0001D516', - "ShortDownArrow;": '\U00002193', - "ShortLeftArrow;": '\U00002190', - "ShortRightArrow;": '\U00002192', - "ShortUpArrow;": '\U00002191', - "Sigma;": '\U000003A3', - "SmallCircle;": '\U00002218', - "Sopf;": '\U0001D54A', - "Sqrt;": '\U0000221A', - "Square;": '\U000025A1', - "SquareIntersection;": '\U00002293', - "SquareSubset;": '\U0000228F', - "SquareSubsetEqual;": '\U00002291', - "SquareSuperset;": '\U00002290', - "SquareSupersetEqual;": '\U00002292', - "SquareUnion;": '\U00002294', - "Sscr;": '\U0001D4AE', - "Star;": '\U000022C6', - "Sub;": '\U000022D0', - "Subset;": '\U000022D0', - "SubsetEqual;": '\U00002286', - "Succeeds;": '\U0000227B', - "SucceedsEqual;": '\U00002AB0', - "SucceedsSlantEqual;": '\U0000227D', - "SucceedsTilde;": '\U0000227F', - "SuchThat;": '\U0000220B', - "Sum;": '\U00002211', - "Sup;": '\U000022D1', - "Superset;": '\U00002283', - "SupersetEqual;": '\U00002287', - "Supset;": '\U000022D1', - "THORN;": '\U000000DE', - "TRADE;": '\U00002122', - "TSHcy;": '\U0000040B', - "TScy;": '\U00000426', - "Tab;": '\U00000009', - "Tau;": '\U000003A4', - "Tcaron;": '\U00000164', - "Tcedil;": '\U00000162', - "Tcy;": '\U00000422', - "Tfr;": '\U0001D517', - "Therefore;": '\U00002234', - "Theta;": '\U00000398', - "ThinSpace;": '\U00002009', - "Tilde;": '\U0000223C', - "TildeEqual;": '\U00002243', - "TildeFullEqual;": '\U00002245', - "TildeTilde;": '\U00002248', - "Topf;": '\U0001D54B', - "TripleDot;": '\U000020DB', - "Tscr;": '\U0001D4AF', - "Tstrok;": '\U00000166', - "Uacute;": '\U000000DA', - "Uarr;": '\U0000219F', - "Uarrocir;": '\U00002949', - "Ubrcy;": '\U0000040E', - "Ubreve;": '\U0000016C', - "Ucirc;": '\U000000DB', - "Ucy;": '\U00000423', - "Udblac;": '\U00000170', - "Ufr;": '\U0001D518', - "Ugrave;": '\U000000D9', - "Umacr;": '\U0000016A', - "UnderBar;": '\U0000005F', - "UnderBrace;": '\U000023DF', - "UnderBracket;": '\U000023B5', - "UnderParenthesis;": '\U000023DD', - "Union;": '\U000022C3', - "UnionPlus;": '\U0000228E', - "Uogon;": '\U00000172', - "Uopf;": '\U0001D54C', - "UpArrow;": '\U00002191', - "UpArrowBar;": '\U00002912', - "UpArrowDownArrow;": '\U000021C5', - "UpDownArrow;": '\U00002195', - "UpEquilibrium;": '\U0000296E', - "UpTee;": '\U000022A5', - "UpTeeArrow;": '\U000021A5', - "Uparrow;": '\U000021D1', - "Updownarrow;": '\U000021D5', - "UpperLeftArrow;": '\U00002196', - "UpperRightArrow;": '\U00002197', - "Upsi;": '\U000003D2', - "Upsilon;": '\U000003A5', - "Uring;": '\U0000016E', - "Uscr;": '\U0001D4B0', - "Utilde;": '\U00000168', - "Uuml;": '\U000000DC', - "VDash;": '\U000022AB', - "Vbar;": '\U00002AEB', - "Vcy;": '\U00000412', - "Vdash;": '\U000022A9', - "Vdashl;": '\U00002AE6', - "Vee;": '\U000022C1', - "Verbar;": '\U00002016', - "Vert;": '\U00002016', - "VerticalBar;": '\U00002223', - "VerticalLine;": '\U0000007C', - "VerticalSeparator;": '\U00002758', - "VerticalTilde;": '\U00002240', - "VeryThinSpace;": '\U0000200A', - "Vfr;": '\U0001D519', - "Vopf;": '\U0001D54D', - "Vscr;": '\U0001D4B1', - "Vvdash;": '\U000022AA', - "Wcirc;": '\U00000174', - "Wedge;": '\U000022C0', - "Wfr;": '\U0001D51A', - "Wopf;": '\U0001D54E', - "Wscr;": '\U0001D4B2', - "Xfr;": '\U0001D51B', - "Xi;": '\U0000039E', - "Xopf;": '\U0001D54F', - "Xscr;": '\U0001D4B3', - "YAcy;": '\U0000042F', - "YIcy;": '\U00000407', - "YUcy;": '\U0000042E', - "Yacute;": '\U000000DD', - "Ycirc;": '\U00000176', - "Ycy;": '\U0000042B', - "Yfr;": '\U0001D51C', - "Yopf;": '\U0001D550', - "Yscr;": '\U0001D4B4', - "Yuml;": '\U00000178', - "ZHcy;": '\U00000416', - "Zacute;": '\U00000179', - "Zcaron;": '\U0000017D', - "Zcy;": '\U00000417', - "Zdot;": '\U0000017B', - "ZeroWidthSpace;": '\U0000200B', - "Zeta;": '\U00000396', - "Zfr;": '\U00002128', - "Zopf;": '\U00002124', - "Zscr;": '\U0001D4B5', - "aacute;": '\U000000E1', - "abreve;": '\U00000103', - "ac;": '\U0000223E', - "acd;": '\U0000223F', - "acirc;": '\U000000E2', - "acute;": '\U000000B4', - "acy;": '\U00000430', - "aelig;": '\U000000E6', - "af;": '\U00002061', - "afr;": '\U0001D51E', - "agrave;": '\U000000E0', - "alefsym;": '\U00002135', - "aleph;": '\U00002135', - "alpha;": '\U000003B1', - "amacr;": '\U00000101', - "amalg;": '\U00002A3F', - "amp;": '\U00000026', - "and;": '\U00002227', - "andand;": '\U00002A55', - "andd;": '\U00002A5C', - "andslope;": '\U00002A58', - "andv;": '\U00002A5A', - "ang;": '\U00002220', - "ange;": '\U000029A4', - "angle;": '\U00002220', - "angmsd;": '\U00002221', - "angmsdaa;": '\U000029A8', - "angmsdab;": '\U000029A9', - "angmsdac;": '\U000029AA', - "angmsdad;": '\U000029AB', - "angmsdae;": '\U000029AC', - "angmsdaf;": '\U000029AD', - "angmsdag;": '\U000029AE', - "angmsdah;": '\U000029AF', - "angrt;": '\U0000221F', - "angrtvb;": '\U000022BE', - "angrtvbd;": '\U0000299D', - "angsph;": '\U00002222', - "angst;": '\U000000C5', - "angzarr;": '\U0000237C', - "aogon;": '\U00000105', - "aopf;": '\U0001D552', - "ap;": '\U00002248', - "apE;": '\U00002A70', - "apacir;": '\U00002A6F', - "ape;": '\U0000224A', - "apid;": '\U0000224B', - "apos;": '\U00000027', - "approx;": '\U00002248', - "approxeq;": '\U0000224A', - "aring;": '\U000000E5', - "ascr;": '\U0001D4B6', - "ast;": '\U0000002A', - "asymp;": '\U00002248', - "asympeq;": '\U0000224D', - "atilde;": '\U000000E3', - "auml;": '\U000000E4', - "awconint;": '\U00002233', - "awint;": '\U00002A11', - "bNot;": '\U00002AED', - "backcong;": '\U0000224C', - "backepsilon;": '\U000003F6', - "backprime;": '\U00002035', - "backsim;": '\U0000223D', - "backsimeq;": '\U000022CD', - "barvee;": '\U000022BD', - "barwed;": '\U00002305', - "barwedge;": '\U00002305', - "bbrk;": '\U000023B5', - "bbrktbrk;": '\U000023B6', - "bcong;": '\U0000224C', - "bcy;": '\U00000431', - "bdquo;": '\U0000201E', - "becaus;": '\U00002235', - "because;": '\U00002235', - "bemptyv;": '\U000029B0', - "bepsi;": '\U000003F6', - "bernou;": '\U0000212C', - "beta;": '\U000003B2', - "beth;": '\U00002136', - "between;": '\U0000226C', - "bfr;": '\U0001D51F', - "bigcap;": '\U000022C2', - "bigcirc;": '\U000025EF', - "bigcup;": '\U000022C3', - "bigodot;": '\U00002A00', - "bigoplus;": '\U00002A01', - "bigotimes;": '\U00002A02', - "bigsqcup;": '\U00002A06', - "bigstar;": '\U00002605', - "bigtriangledown;": '\U000025BD', - "bigtriangleup;": '\U000025B3', - "biguplus;": '\U00002A04', - "bigvee;": '\U000022C1', - "bigwedge;": '\U000022C0', - "bkarow;": '\U0000290D', - "blacklozenge;": '\U000029EB', - "blacksquare;": '\U000025AA', - "blacktriangle;": '\U000025B4', - "blacktriangledown;": '\U000025BE', - "blacktriangleleft;": '\U000025C2', - "blacktriangleright;": '\U000025B8', - "blank;": '\U00002423', - "blk12;": '\U00002592', - "blk14;": '\U00002591', - "blk34;": '\U00002593', - "block;": '\U00002588', - "bnot;": '\U00002310', - "bopf;": '\U0001D553', - "bot;": '\U000022A5', - "bottom;": '\U000022A5', - "bowtie;": '\U000022C8', - "boxDL;": '\U00002557', - "boxDR;": '\U00002554', - "boxDl;": '\U00002556', - "boxDr;": '\U00002553', - "boxH;": '\U00002550', - "boxHD;": '\U00002566', - "boxHU;": '\U00002569', - "boxHd;": '\U00002564', - "boxHu;": '\U00002567', - "boxUL;": '\U0000255D', - "boxUR;": '\U0000255A', - "boxUl;": '\U0000255C', - "boxUr;": '\U00002559', - "boxV;": '\U00002551', - "boxVH;": '\U0000256C', - "boxVL;": '\U00002563', - "boxVR;": '\U00002560', - "boxVh;": '\U0000256B', - "boxVl;": '\U00002562', - "boxVr;": '\U0000255F', - "boxbox;": '\U000029C9', - "boxdL;": '\U00002555', - "boxdR;": '\U00002552', - "boxdl;": '\U00002510', - "boxdr;": '\U0000250C', - "boxh;": '\U00002500', - "boxhD;": '\U00002565', - "boxhU;": '\U00002568', - "boxhd;": '\U0000252C', - "boxhu;": '\U00002534', - "boxminus;": '\U0000229F', - "boxplus;": '\U0000229E', - "boxtimes;": '\U000022A0', - "boxuL;": '\U0000255B', - "boxuR;": '\U00002558', - "boxul;": '\U00002518', - "boxur;": '\U00002514', - "boxv;": '\U00002502', - "boxvH;": '\U0000256A', - "boxvL;": '\U00002561', - "boxvR;": '\U0000255E', - "boxvh;": '\U0000253C', - "boxvl;": '\U00002524', - "boxvr;": '\U0000251C', - "bprime;": '\U00002035', - "breve;": '\U000002D8', - "brvbar;": '\U000000A6', - "bscr;": '\U0001D4B7', - "bsemi;": '\U0000204F', - "bsim;": '\U0000223D', - "bsime;": '\U000022CD', - "bsol;": '\U0000005C', - "bsolb;": '\U000029C5', - "bsolhsub;": '\U000027C8', - "bull;": '\U00002022', - "bullet;": '\U00002022', - "bump;": '\U0000224E', - "bumpE;": '\U00002AAE', - "bumpe;": '\U0000224F', - "bumpeq;": '\U0000224F', - "cacute;": '\U00000107', - "cap;": '\U00002229', - "capand;": '\U00002A44', - "capbrcup;": '\U00002A49', - "capcap;": '\U00002A4B', - "capcup;": '\U00002A47', - "capdot;": '\U00002A40', - "caret;": '\U00002041', - "caron;": '\U000002C7', - "ccaps;": '\U00002A4D', - "ccaron;": '\U0000010D', - "ccedil;": '\U000000E7', - "ccirc;": '\U00000109', - "ccups;": '\U00002A4C', - "ccupssm;": '\U00002A50', - "cdot;": '\U0000010B', - "cedil;": '\U000000B8', - "cemptyv;": '\U000029B2', - "cent;": '\U000000A2', - "centerdot;": '\U000000B7', - "cfr;": '\U0001D520', - "chcy;": '\U00000447', - "check;": '\U00002713', - "checkmark;": '\U00002713', - "chi;": '\U000003C7', - "cir;": '\U000025CB', - "cirE;": '\U000029C3', - "circ;": '\U000002C6', - "circeq;": '\U00002257', - "circlearrowleft;": '\U000021BA', - "circlearrowright;": '\U000021BB', - "circledR;": '\U000000AE', - "circledS;": '\U000024C8', - "circledast;": '\U0000229B', - "circledcirc;": '\U0000229A', - "circleddash;": '\U0000229D', - "cire;": '\U00002257', - "cirfnint;": '\U00002A10', - "cirmid;": '\U00002AEF', - "cirscir;": '\U000029C2', - "clubs;": '\U00002663', - "clubsuit;": '\U00002663', - "colon;": '\U0000003A', - "colone;": '\U00002254', - "coloneq;": '\U00002254', - "comma;": '\U0000002C', - "commat;": '\U00000040', - "comp;": '\U00002201', - "compfn;": '\U00002218', - "complement;": '\U00002201', - "complexes;": '\U00002102', - "cong;": '\U00002245', - "congdot;": '\U00002A6D', - "conint;": '\U0000222E', - "copf;": '\U0001D554', - "coprod;": '\U00002210', - "copy;": '\U000000A9', - "copysr;": '\U00002117', - "crarr;": '\U000021B5', - "cross;": '\U00002717', - "cscr;": '\U0001D4B8', - "csub;": '\U00002ACF', - "csube;": '\U00002AD1', - "csup;": '\U00002AD0', - "csupe;": '\U00002AD2', - "ctdot;": '\U000022EF', - "cudarrl;": '\U00002938', - "cudarrr;": '\U00002935', - "cuepr;": '\U000022DE', - "cuesc;": '\U000022DF', - "cularr;": '\U000021B6', - "cularrp;": '\U0000293D', - "cup;": '\U0000222A', - "cupbrcap;": '\U00002A48', - "cupcap;": '\U00002A46', - "cupcup;": '\U00002A4A', - "cupdot;": '\U0000228D', - "cupor;": '\U00002A45', - "curarr;": '\U000021B7', - "curarrm;": '\U0000293C', - "curlyeqprec;": '\U000022DE', - "curlyeqsucc;": '\U000022DF', - "curlyvee;": '\U000022CE', - "curlywedge;": '\U000022CF', - "curren;": '\U000000A4', - "curvearrowleft;": '\U000021B6', - "curvearrowright;": '\U000021B7', - "cuvee;": '\U000022CE', - "cuwed;": '\U000022CF', - "cwconint;": '\U00002232', - "cwint;": '\U00002231', - "cylcty;": '\U0000232D', - "dArr;": '\U000021D3', - "dHar;": '\U00002965', - "dagger;": '\U00002020', - "daleth;": '\U00002138', - "darr;": '\U00002193', - "dash;": '\U00002010', - "dashv;": '\U000022A3', - "dbkarow;": '\U0000290F', - "dblac;": '\U000002DD', - "dcaron;": '\U0000010F', - "dcy;": '\U00000434', - "dd;": '\U00002146', - "ddagger;": '\U00002021', - "ddarr;": '\U000021CA', - "ddotseq;": '\U00002A77', - "deg;": '\U000000B0', - "delta;": '\U000003B4', - "demptyv;": '\U000029B1', - "dfisht;": '\U0000297F', - "dfr;": '\U0001D521', - "dharl;": '\U000021C3', - "dharr;": '\U000021C2', - "diam;": '\U000022C4', - "diamond;": '\U000022C4', - "diamondsuit;": '\U00002666', - "diams;": '\U00002666', - "die;": '\U000000A8', - "digamma;": '\U000003DD', - "disin;": '\U000022F2', - "div;": '\U000000F7', - "divide;": '\U000000F7', - "divideontimes;": '\U000022C7', - "divonx;": '\U000022C7', - "djcy;": '\U00000452', - "dlcorn;": '\U0000231E', - "dlcrop;": '\U0000230D', - "dollar;": '\U00000024', - "dopf;": '\U0001D555', - "dot;": '\U000002D9', - "doteq;": '\U00002250', - "doteqdot;": '\U00002251', - "dotminus;": '\U00002238', - "dotplus;": '\U00002214', - "dotsquare;": '\U000022A1', - "doublebarwedge;": '\U00002306', - "downarrow;": '\U00002193', - "downdownarrows;": '\U000021CA', - "downharpoonleft;": '\U000021C3', - "downharpoonright;": '\U000021C2', - "drbkarow;": '\U00002910', - "drcorn;": '\U0000231F', - "drcrop;": '\U0000230C', - "dscr;": '\U0001D4B9', - "dscy;": '\U00000455', - "dsol;": '\U000029F6', - "dstrok;": '\U00000111', - "dtdot;": '\U000022F1', - "dtri;": '\U000025BF', - "dtrif;": '\U000025BE', - "duarr;": '\U000021F5', - "duhar;": '\U0000296F', - "dwangle;": '\U000029A6', - "dzcy;": '\U0000045F', - "dzigrarr;": '\U000027FF', - "eDDot;": '\U00002A77', - "eDot;": '\U00002251', - "eacute;": '\U000000E9', - "easter;": '\U00002A6E', - "ecaron;": '\U0000011B', - "ecir;": '\U00002256', - "ecirc;": '\U000000EA', - "ecolon;": '\U00002255', - "ecy;": '\U0000044D', - "edot;": '\U00000117', - "ee;": '\U00002147', - "efDot;": '\U00002252', - "efr;": '\U0001D522', - "eg;": '\U00002A9A', - "egrave;": '\U000000E8', - "egs;": '\U00002A96', - "egsdot;": '\U00002A98', - "el;": '\U00002A99', - "elinters;": '\U000023E7', - "ell;": '\U00002113', - "els;": '\U00002A95', - "elsdot;": '\U00002A97', - "emacr;": '\U00000113', - "empty;": '\U00002205', - "emptyset;": '\U00002205', - "emptyv;": '\U00002205', - "emsp;": '\U00002003', - "emsp13;": '\U00002004', - "emsp14;": '\U00002005', - "eng;": '\U0000014B', - "ensp;": '\U00002002', - "eogon;": '\U00000119', - "eopf;": '\U0001D556', - "epar;": '\U000022D5', - "eparsl;": '\U000029E3', - "eplus;": '\U00002A71', - "epsi;": '\U000003B5', - "epsilon;": '\U000003B5', - "epsiv;": '\U000003F5', - "eqcirc;": '\U00002256', - "eqcolon;": '\U00002255', - "eqsim;": '\U00002242', - "eqslantgtr;": '\U00002A96', - "eqslantless;": '\U00002A95', - "equals;": '\U0000003D', - "equest;": '\U0000225F', - "equiv;": '\U00002261', - "equivDD;": '\U00002A78', - "eqvparsl;": '\U000029E5', - "erDot;": '\U00002253', - "erarr;": '\U00002971', - "escr;": '\U0000212F', - "esdot;": '\U00002250', - "esim;": '\U00002242', - "eta;": '\U000003B7', - "eth;": '\U000000F0', - "euml;": '\U000000EB', - "euro;": '\U000020AC', - "excl;": '\U00000021', - "exist;": '\U00002203', - "expectation;": '\U00002130', - "exponentiale;": '\U00002147', - "fallingdotseq;": '\U00002252', - "fcy;": '\U00000444', - "female;": '\U00002640', - "ffilig;": '\U0000FB03', - "fflig;": '\U0000FB00', - "ffllig;": '\U0000FB04', - "ffr;": '\U0001D523', - "filig;": '\U0000FB01', - "flat;": '\U0000266D', - "fllig;": '\U0000FB02', - "fltns;": '\U000025B1', - "fnof;": '\U00000192', - "fopf;": '\U0001D557', - "forall;": '\U00002200', - "fork;": '\U000022D4', - "forkv;": '\U00002AD9', - "fpartint;": '\U00002A0D', - "frac12;": '\U000000BD', - "frac13;": '\U00002153', - "frac14;": '\U000000BC', - "frac15;": '\U00002155', - "frac16;": '\U00002159', - "frac18;": '\U0000215B', - "frac23;": '\U00002154', - "frac25;": '\U00002156', - "frac34;": '\U000000BE', - "frac35;": '\U00002157', - "frac38;": '\U0000215C', - "frac45;": '\U00002158', - "frac56;": '\U0000215A', - "frac58;": '\U0000215D', - "frac78;": '\U0000215E', - "frasl;": '\U00002044', - "frown;": '\U00002322', - "fscr;": '\U0001D4BB', - "gE;": '\U00002267', - "gEl;": '\U00002A8C', - "gacute;": '\U000001F5', - "gamma;": '\U000003B3', - "gammad;": '\U000003DD', - "gap;": '\U00002A86', - "gbreve;": '\U0000011F', - "gcirc;": '\U0000011D', - "gcy;": '\U00000433', - "gdot;": '\U00000121', - "ge;": '\U00002265', - "gel;": '\U000022DB', - "geq;": '\U00002265', - "geqq;": '\U00002267', - "geqslant;": '\U00002A7E', - "ges;": '\U00002A7E', - "gescc;": '\U00002AA9', - "gesdot;": '\U00002A80', - "gesdoto;": '\U00002A82', - "gesdotol;": '\U00002A84', - "gesles;": '\U00002A94', - "gfr;": '\U0001D524', - "gg;": '\U0000226B', - "ggg;": '\U000022D9', - "gimel;": '\U00002137', - "gjcy;": '\U00000453', - "gl;": '\U00002277', - "glE;": '\U00002A92', - "gla;": '\U00002AA5', - "glj;": '\U00002AA4', - "gnE;": '\U00002269', - "gnap;": '\U00002A8A', - "gnapprox;": '\U00002A8A', - "gne;": '\U00002A88', - "gneq;": '\U00002A88', - "gneqq;": '\U00002269', - "gnsim;": '\U000022E7', - "gopf;": '\U0001D558', - "grave;": '\U00000060', - "gscr;": '\U0000210A', - "gsim;": '\U00002273', - "gsime;": '\U00002A8E', - "gsiml;": '\U00002A90', - "gt;": '\U0000003E', - "gtcc;": '\U00002AA7', - "gtcir;": '\U00002A7A', - "gtdot;": '\U000022D7', - "gtlPar;": '\U00002995', - "gtquest;": '\U00002A7C', - "gtrapprox;": '\U00002A86', - "gtrarr;": '\U00002978', - "gtrdot;": '\U000022D7', - "gtreqless;": '\U000022DB', - "gtreqqless;": '\U00002A8C', - "gtrless;": '\U00002277', - "gtrsim;": '\U00002273', - "hArr;": '\U000021D4', - "hairsp;": '\U0000200A', - "half;": '\U000000BD', - "hamilt;": '\U0000210B', - "hardcy;": '\U0000044A', - "harr;": '\U00002194', - "harrcir;": '\U00002948', - "harrw;": '\U000021AD', - "hbar;": '\U0000210F', - "hcirc;": '\U00000125', - "hearts;": '\U00002665', - "heartsuit;": '\U00002665', - "hellip;": '\U00002026', - "hercon;": '\U000022B9', - "hfr;": '\U0001D525', - "hksearow;": '\U00002925', - "hkswarow;": '\U00002926', - "hoarr;": '\U000021FF', - "homtht;": '\U0000223B', - "hookleftarrow;": '\U000021A9', - "hookrightarrow;": '\U000021AA', - "hopf;": '\U0001D559', - "horbar;": '\U00002015', - "hscr;": '\U0001D4BD', - "hslash;": '\U0000210F', - "hstrok;": '\U00000127', - "hybull;": '\U00002043', - "hyphen;": '\U00002010', - "iacute;": '\U000000ED', - "ic;": '\U00002063', - "icirc;": '\U000000EE', - "icy;": '\U00000438', - "iecy;": '\U00000435', - "iexcl;": '\U000000A1', - "iff;": '\U000021D4', - "ifr;": '\U0001D526', - "igrave;": '\U000000EC', - "ii;": '\U00002148', - "iiiint;": '\U00002A0C', - "iiint;": '\U0000222D', - "iinfin;": '\U000029DC', - "iiota;": '\U00002129', - "ijlig;": '\U00000133', - "imacr;": '\U0000012B', - "image;": '\U00002111', - "imagline;": '\U00002110', - "imagpart;": '\U00002111', - "imath;": '\U00000131', - "imof;": '\U000022B7', - "imped;": '\U000001B5', - "in;": '\U00002208', - "incare;": '\U00002105', - "infin;": '\U0000221E', - "infintie;": '\U000029DD', - "inodot;": '\U00000131', - "int;": '\U0000222B', - "intcal;": '\U000022BA', - "integers;": '\U00002124', - "intercal;": '\U000022BA', - "intlarhk;": '\U00002A17', - "intprod;": '\U00002A3C', - "iocy;": '\U00000451', - "iogon;": '\U0000012F', - "iopf;": '\U0001D55A', - "iota;": '\U000003B9', - "iprod;": '\U00002A3C', - "iquest;": '\U000000BF', - "iscr;": '\U0001D4BE', - "isin;": '\U00002208', - "isinE;": '\U000022F9', - "isindot;": '\U000022F5', - "isins;": '\U000022F4', - "isinsv;": '\U000022F3', - "isinv;": '\U00002208', - "it;": '\U00002062', - "itilde;": '\U00000129', - "iukcy;": '\U00000456', - "iuml;": '\U000000EF', - "jcirc;": '\U00000135', - "jcy;": '\U00000439', - "jfr;": '\U0001D527', - "jmath;": '\U00000237', - "jopf;": '\U0001D55B', - "jscr;": '\U0001D4BF', - "jsercy;": '\U00000458', - "jukcy;": '\U00000454', - "kappa;": '\U000003BA', - "kappav;": '\U000003F0', - "kcedil;": '\U00000137', - "kcy;": '\U0000043A', - "kfr;": '\U0001D528', - "kgreen;": '\U00000138', - "khcy;": '\U00000445', - "kjcy;": '\U0000045C', - "kopf;": '\U0001D55C', - "kscr;": '\U0001D4C0', - "lAarr;": '\U000021DA', - "lArr;": '\U000021D0', - "lAtail;": '\U0000291B', - "lBarr;": '\U0000290E', - "lE;": '\U00002266', - "lEg;": '\U00002A8B', - "lHar;": '\U00002962', - "lacute;": '\U0000013A', - "laemptyv;": '\U000029B4', - "lagran;": '\U00002112', - "lambda;": '\U000003BB', - "lang;": '\U000027E8', - "langd;": '\U00002991', - "langle;": '\U000027E8', - "lap;": '\U00002A85', - "laquo;": '\U000000AB', - "larr;": '\U00002190', - "larrb;": '\U000021E4', - "larrbfs;": '\U0000291F', - "larrfs;": '\U0000291D', - "larrhk;": '\U000021A9', - "larrlp;": '\U000021AB', - "larrpl;": '\U00002939', - "larrsim;": '\U00002973', - "larrtl;": '\U000021A2', - "lat;": '\U00002AAB', - "latail;": '\U00002919', - "late;": '\U00002AAD', - "lbarr;": '\U0000290C', - "lbbrk;": '\U00002772', - "lbrace;": '\U0000007B', - "lbrack;": '\U0000005B', - "lbrke;": '\U0000298B', - "lbrksld;": '\U0000298F', - "lbrkslu;": '\U0000298D', - "lcaron;": '\U0000013E', - "lcedil;": '\U0000013C', - "lceil;": '\U00002308', - "lcub;": '\U0000007B', - "lcy;": '\U0000043B', - "ldca;": '\U00002936', - "ldquo;": '\U0000201C', - "ldquor;": '\U0000201E', - "ldrdhar;": '\U00002967', - "ldrushar;": '\U0000294B', - "ldsh;": '\U000021B2', - "le;": '\U00002264', - "leftarrow;": '\U00002190', - "leftarrowtail;": '\U000021A2', - "leftharpoondown;": '\U000021BD', - "leftharpoonup;": '\U000021BC', - "leftleftarrows;": '\U000021C7', - "leftrightarrow;": '\U00002194', - "leftrightarrows;": '\U000021C6', - "leftrightharpoons;": '\U000021CB', - "leftrightsquigarrow;": '\U000021AD', - "leftthreetimes;": '\U000022CB', - "leg;": '\U000022DA', - "leq;": '\U00002264', - "leqq;": '\U00002266', - "leqslant;": '\U00002A7D', - "les;": '\U00002A7D', - "lescc;": '\U00002AA8', - "lesdot;": '\U00002A7F', - "lesdoto;": '\U00002A81', - "lesdotor;": '\U00002A83', - "lesges;": '\U00002A93', - "lessapprox;": '\U00002A85', - "lessdot;": '\U000022D6', - "lesseqgtr;": '\U000022DA', - "lesseqqgtr;": '\U00002A8B', - "lessgtr;": '\U00002276', - "lesssim;": '\U00002272', - "lfisht;": '\U0000297C', - "lfloor;": '\U0000230A', - "lfr;": '\U0001D529', - "lg;": '\U00002276', - "lgE;": '\U00002A91', - "lhard;": '\U000021BD', - "lharu;": '\U000021BC', - "lharul;": '\U0000296A', - "lhblk;": '\U00002584', - "ljcy;": '\U00000459', - "ll;": '\U0000226A', - "llarr;": '\U000021C7', - "llcorner;": '\U0000231E', - "llhard;": '\U0000296B', - "lltri;": '\U000025FA', - "lmidot;": '\U00000140', - "lmoust;": '\U000023B0', - "lmoustache;": '\U000023B0', - "lnE;": '\U00002268', - "lnap;": '\U00002A89', - "lnapprox;": '\U00002A89', - "lne;": '\U00002A87', - "lneq;": '\U00002A87', - "lneqq;": '\U00002268', - "lnsim;": '\U000022E6', - "loang;": '\U000027EC', - "loarr;": '\U000021FD', - "lobrk;": '\U000027E6', - "longleftarrow;": '\U000027F5', - "longleftrightarrow;": '\U000027F7', - "longmapsto;": '\U000027FC', - "longrightarrow;": '\U000027F6', - "looparrowleft;": '\U000021AB', - "looparrowright;": '\U000021AC', - "lopar;": '\U00002985', - "lopf;": '\U0001D55D', - "loplus;": '\U00002A2D', - "lotimes;": '\U00002A34', - "lowast;": '\U00002217', - "lowbar;": '\U0000005F', - "loz;": '\U000025CA', - "lozenge;": '\U000025CA', - "lozf;": '\U000029EB', - "lpar;": '\U00000028', - "lparlt;": '\U00002993', - "lrarr;": '\U000021C6', - "lrcorner;": '\U0000231F', - "lrhar;": '\U000021CB', - "lrhard;": '\U0000296D', - "lrm;": '\U0000200E', - "lrtri;": '\U000022BF', - "lsaquo;": '\U00002039', - "lscr;": '\U0001D4C1', - "lsh;": '\U000021B0', - "lsim;": '\U00002272', - "lsime;": '\U00002A8D', - "lsimg;": '\U00002A8F', - "lsqb;": '\U0000005B', - "lsquo;": '\U00002018', - "lsquor;": '\U0000201A', - "lstrok;": '\U00000142', - "lt;": '\U0000003C', - "ltcc;": '\U00002AA6', - "ltcir;": '\U00002A79', - "ltdot;": '\U000022D6', - "lthree;": '\U000022CB', - "ltimes;": '\U000022C9', - "ltlarr;": '\U00002976', - "ltquest;": '\U00002A7B', - "ltrPar;": '\U00002996', - "ltri;": '\U000025C3', - "ltrie;": '\U000022B4', - "ltrif;": '\U000025C2', - "lurdshar;": '\U0000294A', - "luruhar;": '\U00002966', - "mDDot;": '\U0000223A', - "macr;": '\U000000AF', - "male;": '\U00002642', - "malt;": '\U00002720', - "maltese;": '\U00002720', - "map;": '\U000021A6', - "mapsto;": '\U000021A6', - "mapstodown;": '\U000021A7', - "mapstoleft;": '\U000021A4', - "mapstoup;": '\U000021A5', - "marker;": '\U000025AE', - "mcomma;": '\U00002A29', - "mcy;": '\U0000043C', - "mdash;": '\U00002014', - "measuredangle;": '\U00002221', - "mfr;": '\U0001D52A', - "mho;": '\U00002127', - "micro;": '\U000000B5', - "mid;": '\U00002223', - "midast;": '\U0000002A', - "midcir;": '\U00002AF0', - "middot;": '\U000000B7', - "minus;": '\U00002212', - "minusb;": '\U0000229F', - "minusd;": '\U00002238', - "minusdu;": '\U00002A2A', - "mlcp;": '\U00002ADB', - "mldr;": '\U00002026', - "mnplus;": '\U00002213', - "models;": '\U000022A7', - "mopf;": '\U0001D55E', - "mp;": '\U00002213', - "mscr;": '\U0001D4C2', - "mstpos;": '\U0000223E', - "mu;": '\U000003BC', - "multimap;": '\U000022B8', - "mumap;": '\U000022B8', - "nLeftarrow;": '\U000021CD', - "nLeftrightarrow;": '\U000021CE', - "nRightarrow;": '\U000021CF', - "nVDash;": '\U000022AF', - "nVdash;": '\U000022AE', - "nabla;": '\U00002207', - "nacute;": '\U00000144', - "nap;": '\U00002249', - "napos;": '\U00000149', - "napprox;": '\U00002249', - "natur;": '\U0000266E', - "natural;": '\U0000266E', - "naturals;": '\U00002115', - "nbsp;": '\U000000A0', - "ncap;": '\U00002A43', - "ncaron;": '\U00000148', - "ncedil;": '\U00000146', - "ncong;": '\U00002247', - "ncup;": '\U00002A42', - "ncy;": '\U0000043D', - "ndash;": '\U00002013', - "ne;": '\U00002260', - "neArr;": '\U000021D7', - "nearhk;": '\U00002924', - "nearr;": '\U00002197', - "nearrow;": '\U00002197', - "nequiv;": '\U00002262', - "nesear;": '\U00002928', - "nexist;": '\U00002204', - "nexists;": '\U00002204', - "nfr;": '\U0001D52B', - "nge;": '\U00002271', - "ngeq;": '\U00002271', - "ngsim;": '\U00002275', - "ngt;": '\U0000226F', - "ngtr;": '\U0000226F', - "nhArr;": '\U000021CE', - "nharr;": '\U000021AE', - "nhpar;": '\U00002AF2', - "ni;": '\U0000220B', - "nis;": '\U000022FC', - "nisd;": '\U000022FA', - "niv;": '\U0000220B', - "njcy;": '\U0000045A', - "nlArr;": '\U000021CD', - "nlarr;": '\U0000219A', - "nldr;": '\U00002025', - "nle;": '\U00002270', - "nleftarrow;": '\U0000219A', - "nleftrightarrow;": '\U000021AE', - "nleq;": '\U00002270', - "nless;": '\U0000226E', - "nlsim;": '\U00002274', - "nlt;": '\U0000226E', - "nltri;": '\U000022EA', - "nltrie;": '\U000022EC', - "nmid;": '\U00002224', - "nopf;": '\U0001D55F', - "not;": '\U000000AC', - "notin;": '\U00002209', - "notinva;": '\U00002209', - "notinvb;": '\U000022F7', - "notinvc;": '\U000022F6', - "notni;": '\U0000220C', - "notniva;": '\U0000220C', - "notnivb;": '\U000022FE', - "notnivc;": '\U000022FD', - "npar;": '\U00002226', - "nparallel;": '\U00002226', - "npolint;": '\U00002A14', - "npr;": '\U00002280', - "nprcue;": '\U000022E0', - "nprec;": '\U00002280', - "nrArr;": '\U000021CF', - "nrarr;": '\U0000219B', - "nrightarrow;": '\U0000219B', - "nrtri;": '\U000022EB', - "nrtrie;": '\U000022ED', - "nsc;": '\U00002281', - "nsccue;": '\U000022E1', - "nscr;": '\U0001D4C3', - "nshortmid;": '\U00002224', - "nshortparallel;": '\U00002226', - "nsim;": '\U00002241', - "nsime;": '\U00002244', - "nsimeq;": '\U00002244', - "nsmid;": '\U00002224', - "nspar;": '\U00002226', - "nsqsube;": '\U000022E2', - "nsqsupe;": '\U000022E3', - "nsub;": '\U00002284', - "nsube;": '\U00002288', - "nsubseteq;": '\U00002288', - "nsucc;": '\U00002281', - "nsup;": '\U00002285', - "nsupe;": '\U00002289', - "nsupseteq;": '\U00002289', - "ntgl;": '\U00002279', - "ntilde;": '\U000000F1', - "ntlg;": '\U00002278', - "ntriangleleft;": '\U000022EA', - "ntrianglelefteq;": '\U000022EC', - "ntriangleright;": '\U000022EB', - "ntrianglerighteq;": '\U000022ED', - "nu;": '\U000003BD', - "num;": '\U00000023', - "numero;": '\U00002116', - "numsp;": '\U00002007', - "nvDash;": '\U000022AD', - "nvHarr;": '\U00002904', - "nvdash;": '\U000022AC', - "nvinfin;": '\U000029DE', - "nvlArr;": '\U00002902', - "nvrArr;": '\U00002903', - "nwArr;": '\U000021D6', - "nwarhk;": '\U00002923', - "nwarr;": '\U00002196', - "nwarrow;": '\U00002196', - "nwnear;": '\U00002927', - "oS;": '\U000024C8', - "oacute;": '\U000000F3', - "oast;": '\U0000229B', - "ocir;": '\U0000229A', - "ocirc;": '\U000000F4', - "ocy;": '\U0000043E', - "odash;": '\U0000229D', - "odblac;": '\U00000151', - "odiv;": '\U00002A38', - "odot;": '\U00002299', - "odsold;": '\U000029BC', - "oelig;": '\U00000153', - "ofcir;": '\U000029BF', - "ofr;": '\U0001D52C', - "ogon;": '\U000002DB', - "ograve;": '\U000000F2', - "ogt;": '\U000029C1', - "ohbar;": '\U000029B5', - "ohm;": '\U000003A9', - "oint;": '\U0000222E', - "olarr;": '\U000021BA', - "olcir;": '\U000029BE', - "olcross;": '\U000029BB', - "oline;": '\U0000203E', - "olt;": '\U000029C0', - "omacr;": '\U0000014D', - "omega;": '\U000003C9', - "omicron;": '\U000003BF', - "omid;": '\U000029B6', - "ominus;": '\U00002296', - "oopf;": '\U0001D560', - "opar;": '\U000029B7', - "operp;": '\U000029B9', - "oplus;": '\U00002295', - "or;": '\U00002228', - "orarr;": '\U000021BB', - "ord;": '\U00002A5D', - "order;": '\U00002134', - "orderof;": '\U00002134', - "ordf;": '\U000000AA', - "ordm;": '\U000000BA', - "origof;": '\U000022B6', - "oror;": '\U00002A56', - "orslope;": '\U00002A57', - "orv;": '\U00002A5B', - "oscr;": '\U00002134', - "oslash;": '\U000000F8', - "osol;": '\U00002298', - "otilde;": '\U000000F5', - "otimes;": '\U00002297', - "otimesas;": '\U00002A36', - "ouml;": '\U000000F6', - "ovbar;": '\U0000233D', - "par;": '\U00002225', - "para;": '\U000000B6', - "parallel;": '\U00002225', - "parsim;": '\U00002AF3', - "parsl;": '\U00002AFD', - "part;": '\U00002202', - "pcy;": '\U0000043F', - "percnt;": '\U00000025', - "period;": '\U0000002E', - "permil;": '\U00002030', - "perp;": '\U000022A5', - "pertenk;": '\U00002031', - "pfr;": '\U0001D52D', - "phi;": '\U000003C6', - "phiv;": '\U000003D5', - "phmmat;": '\U00002133', - "phone;": '\U0000260E', - "pi;": '\U000003C0', - "pitchfork;": '\U000022D4', - "piv;": '\U000003D6', - "planck;": '\U0000210F', - "planckh;": '\U0000210E', - "plankv;": '\U0000210F', - "plus;": '\U0000002B', - "plusacir;": '\U00002A23', - "plusb;": '\U0000229E', - "pluscir;": '\U00002A22', - "plusdo;": '\U00002214', - "plusdu;": '\U00002A25', - "pluse;": '\U00002A72', - "plusmn;": '\U000000B1', - "plussim;": '\U00002A26', - "plustwo;": '\U00002A27', - "pm;": '\U000000B1', - "pointint;": '\U00002A15', - "popf;": '\U0001D561', - "pound;": '\U000000A3', - "pr;": '\U0000227A', - "prE;": '\U00002AB3', - "prap;": '\U00002AB7', - "prcue;": '\U0000227C', - "pre;": '\U00002AAF', - "prec;": '\U0000227A', - "precapprox;": '\U00002AB7', - "preccurlyeq;": '\U0000227C', - "preceq;": '\U00002AAF', - "precnapprox;": '\U00002AB9', - "precneqq;": '\U00002AB5', - "precnsim;": '\U000022E8', - "precsim;": '\U0000227E', - "prime;": '\U00002032', - "primes;": '\U00002119', - "prnE;": '\U00002AB5', - "prnap;": '\U00002AB9', - "prnsim;": '\U000022E8', - "prod;": '\U0000220F', - "profalar;": '\U0000232E', - "profline;": '\U00002312', - "profsurf;": '\U00002313', - "prop;": '\U0000221D', - "propto;": '\U0000221D', - "prsim;": '\U0000227E', - "prurel;": '\U000022B0', - "pscr;": '\U0001D4C5', - "psi;": '\U000003C8', - "puncsp;": '\U00002008', - "qfr;": '\U0001D52E', - "qint;": '\U00002A0C', - "qopf;": '\U0001D562', - "qprime;": '\U00002057', - "qscr;": '\U0001D4C6', - "quaternions;": '\U0000210D', - "quatint;": '\U00002A16', - "quest;": '\U0000003F', - "questeq;": '\U0000225F', - "quot;": '\U00000022', - "rAarr;": '\U000021DB', - "rArr;": '\U000021D2', - "rAtail;": '\U0000291C', - "rBarr;": '\U0000290F', - "rHar;": '\U00002964', - "racute;": '\U00000155', - "radic;": '\U0000221A', - "raemptyv;": '\U000029B3', - "rang;": '\U000027E9', - "rangd;": '\U00002992', - "range;": '\U000029A5', - "rangle;": '\U000027E9', - "raquo;": '\U000000BB', - "rarr;": '\U00002192', - "rarrap;": '\U00002975', - "rarrb;": '\U000021E5', - "rarrbfs;": '\U00002920', - "rarrc;": '\U00002933', - "rarrfs;": '\U0000291E', - "rarrhk;": '\U000021AA', - "rarrlp;": '\U000021AC', - "rarrpl;": '\U00002945', - "rarrsim;": '\U00002974', - "rarrtl;": '\U000021A3', - "rarrw;": '\U0000219D', - "ratail;": '\U0000291A', - "ratio;": '\U00002236', - "rationals;": '\U0000211A', - "rbarr;": '\U0000290D', - "rbbrk;": '\U00002773', - "rbrace;": '\U0000007D', - "rbrack;": '\U0000005D', - "rbrke;": '\U0000298C', - "rbrksld;": '\U0000298E', - "rbrkslu;": '\U00002990', - "rcaron;": '\U00000159', - "rcedil;": '\U00000157', - "rceil;": '\U00002309', - "rcub;": '\U0000007D', - "rcy;": '\U00000440', - "rdca;": '\U00002937', - "rdldhar;": '\U00002969', - "rdquo;": '\U0000201D', - "rdquor;": '\U0000201D', - "rdsh;": '\U000021B3', - "real;": '\U0000211C', - "realine;": '\U0000211B', - "realpart;": '\U0000211C', - "reals;": '\U0000211D', - "rect;": '\U000025AD', - "reg;": '\U000000AE', - "rfisht;": '\U0000297D', - "rfloor;": '\U0000230B', - "rfr;": '\U0001D52F', - "rhard;": '\U000021C1', - "rharu;": '\U000021C0', - "rharul;": '\U0000296C', - "rho;": '\U000003C1', - "rhov;": '\U000003F1', - "rightarrow;": '\U00002192', - "rightarrowtail;": '\U000021A3', - "rightharpoondown;": '\U000021C1', - "rightharpoonup;": '\U000021C0', - "rightleftarrows;": '\U000021C4', - "rightleftharpoons;": '\U000021CC', - "rightrightarrows;": '\U000021C9', - "rightsquigarrow;": '\U0000219D', - "rightthreetimes;": '\U000022CC', - "ring;": '\U000002DA', - "risingdotseq;": '\U00002253', - "rlarr;": '\U000021C4', - "rlhar;": '\U000021CC', - "rlm;": '\U0000200F', - "rmoust;": '\U000023B1', - "rmoustache;": '\U000023B1', - "rnmid;": '\U00002AEE', - "roang;": '\U000027ED', - "roarr;": '\U000021FE', - "robrk;": '\U000027E7', - "ropar;": '\U00002986', - "ropf;": '\U0001D563', - "roplus;": '\U00002A2E', - "rotimes;": '\U00002A35', - "rpar;": '\U00000029', - "rpargt;": '\U00002994', - "rppolint;": '\U00002A12', - "rrarr;": '\U000021C9', - "rsaquo;": '\U0000203A', - "rscr;": '\U0001D4C7', - "rsh;": '\U000021B1', - "rsqb;": '\U0000005D', - "rsquo;": '\U00002019', - "rsquor;": '\U00002019', - "rthree;": '\U000022CC', - "rtimes;": '\U000022CA', - "rtri;": '\U000025B9', - "rtrie;": '\U000022B5', - "rtrif;": '\U000025B8', - "rtriltri;": '\U000029CE', - "ruluhar;": '\U00002968', - "rx;": '\U0000211E', - "sacute;": '\U0000015B', - "sbquo;": '\U0000201A', - "sc;": '\U0000227B', - "scE;": '\U00002AB4', - "scap;": '\U00002AB8', - "scaron;": '\U00000161', - "sccue;": '\U0000227D', - "sce;": '\U00002AB0', - "scedil;": '\U0000015F', - "scirc;": '\U0000015D', - "scnE;": '\U00002AB6', - "scnap;": '\U00002ABA', - "scnsim;": '\U000022E9', - "scpolint;": '\U00002A13', - "scsim;": '\U0000227F', - "scy;": '\U00000441', - "sdot;": '\U000022C5', - "sdotb;": '\U000022A1', - "sdote;": '\U00002A66', - "seArr;": '\U000021D8', - "searhk;": '\U00002925', - "searr;": '\U00002198', - "searrow;": '\U00002198', - "sect;": '\U000000A7', - "semi;": '\U0000003B', - "seswar;": '\U00002929', - "setminus;": '\U00002216', - "setmn;": '\U00002216', - "sext;": '\U00002736', - "sfr;": '\U0001D530', - "sfrown;": '\U00002322', - "sharp;": '\U0000266F', - "shchcy;": '\U00000449', - "shcy;": '\U00000448', - "shortmid;": '\U00002223', - "shortparallel;": '\U00002225', - "shy;": '\U000000AD', - "sigma;": '\U000003C3', - "sigmaf;": '\U000003C2', - "sigmav;": '\U000003C2', - "sim;": '\U0000223C', - "simdot;": '\U00002A6A', - "sime;": '\U00002243', - "simeq;": '\U00002243', - "simg;": '\U00002A9E', - "simgE;": '\U00002AA0', - "siml;": '\U00002A9D', - "simlE;": '\U00002A9F', - "simne;": '\U00002246', - "simplus;": '\U00002A24', - "simrarr;": '\U00002972', - "slarr;": '\U00002190', - "smallsetminus;": '\U00002216', - "smashp;": '\U00002A33', - "smeparsl;": '\U000029E4', - "smid;": '\U00002223', - "smile;": '\U00002323', - "smt;": '\U00002AAA', - "smte;": '\U00002AAC', - "softcy;": '\U0000044C', - "sol;": '\U0000002F', - "solb;": '\U000029C4', - "solbar;": '\U0000233F', - "sopf;": '\U0001D564', - "spades;": '\U00002660', - "spadesuit;": '\U00002660', - "spar;": '\U00002225', - "sqcap;": '\U00002293', - "sqcup;": '\U00002294', - "sqsub;": '\U0000228F', - "sqsube;": '\U00002291', - "sqsubset;": '\U0000228F', - "sqsubseteq;": '\U00002291', - "sqsup;": '\U00002290', - "sqsupe;": '\U00002292', - "sqsupset;": '\U00002290', - "sqsupseteq;": '\U00002292', - "squ;": '\U000025A1', - "square;": '\U000025A1', - "squarf;": '\U000025AA', - "squf;": '\U000025AA', - "srarr;": '\U00002192', - "sscr;": '\U0001D4C8', - "ssetmn;": '\U00002216', - "ssmile;": '\U00002323', - "sstarf;": '\U000022C6', - "star;": '\U00002606', - "starf;": '\U00002605', - "straightepsilon;": '\U000003F5', - "straightphi;": '\U000003D5', - "strns;": '\U000000AF', - "sub;": '\U00002282', - "subE;": '\U00002AC5', - "subdot;": '\U00002ABD', - "sube;": '\U00002286', - "subedot;": '\U00002AC3', - "submult;": '\U00002AC1', - "subnE;": '\U00002ACB', - "subne;": '\U0000228A', - "subplus;": '\U00002ABF', - "subrarr;": '\U00002979', - "subset;": '\U00002282', - "subseteq;": '\U00002286', - "subseteqq;": '\U00002AC5', - "subsetneq;": '\U0000228A', - "subsetneqq;": '\U00002ACB', - "subsim;": '\U00002AC7', - "subsub;": '\U00002AD5', - "subsup;": '\U00002AD3', - "succ;": '\U0000227B', - "succapprox;": '\U00002AB8', - "succcurlyeq;": '\U0000227D', - "succeq;": '\U00002AB0', - "succnapprox;": '\U00002ABA', - "succneqq;": '\U00002AB6', - "succnsim;": '\U000022E9', - "succsim;": '\U0000227F', - "sum;": '\U00002211', - "sung;": '\U0000266A', - "sup;": '\U00002283', - "sup1;": '\U000000B9', - "sup2;": '\U000000B2', - "sup3;": '\U000000B3', - "supE;": '\U00002AC6', - "supdot;": '\U00002ABE', - "supdsub;": '\U00002AD8', - "supe;": '\U00002287', - "supedot;": '\U00002AC4', - "suphsol;": '\U000027C9', - "suphsub;": '\U00002AD7', - "suplarr;": '\U0000297B', - "supmult;": '\U00002AC2', - "supnE;": '\U00002ACC', - "supne;": '\U0000228B', - "supplus;": '\U00002AC0', - "supset;": '\U00002283', - "supseteq;": '\U00002287', - "supseteqq;": '\U00002AC6', - "supsetneq;": '\U0000228B', - "supsetneqq;": '\U00002ACC', - "supsim;": '\U00002AC8', - "supsub;": '\U00002AD4', - "supsup;": '\U00002AD6', - "swArr;": '\U000021D9', - "swarhk;": '\U00002926', - "swarr;": '\U00002199', - "swarrow;": '\U00002199', - "swnwar;": '\U0000292A', - "szlig;": '\U000000DF', - "target;": '\U00002316', - "tau;": '\U000003C4', - "tbrk;": '\U000023B4', - "tcaron;": '\U00000165', - "tcedil;": '\U00000163', - "tcy;": '\U00000442', - "tdot;": '\U000020DB', - "telrec;": '\U00002315', - "tfr;": '\U0001D531', - "there4;": '\U00002234', - "therefore;": '\U00002234', - "theta;": '\U000003B8', - "thetasym;": '\U000003D1', - "thetav;": '\U000003D1', - "thickapprox;": '\U00002248', - "thicksim;": '\U0000223C', - "thinsp;": '\U00002009', - "thkap;": '\U00002248', - "thksim;": '\U0000223C', - "thorn;": '\U000000FE', - "tilde;": '\U000002DC', - "times;": '\U000000D7', - "timesb;": '\U000022A0', - "timesbar;": '\U00002A31', - "timesd;": '\U00002A30', - "tint;": '\U0000222D', - "toea;": '\U00002928', - "top;": '\U000022A4', - "topbot;": '\U00002336', - "topcir;": '\U00002AF1', - "topf;": '\U0001D565', - "topfork;": '\U00002ADA', - "tosa;": '\U00002929', - "tprime;": '\U00002034', - "trade;": '\U00002122', - "triangle;": '\U000025B5', - "triangledown;": '\U000025BF', - "triangleleft;": '\U000025C3', - "trianglelefteq;": '\U000022B4', - "triangleq;": '\U0000225C', - "triangleright;": '\U000025B9', - "trianglerighteq;": '\U000022B5', - "tridot;": '\U000025EC', - "trie;": '\U0000225C', - "triminus;": '\U00002A3A', - "triplus;": '\U00002A39', - "trisb;": '\U000029CD', - "tritime;": '\U00002A3B', - "trpezium;": '\U000023E2', - "tscr;": '\U0001D4C9', - "tscy;": '\U00000446', - "tshcy;": '\U0000045B', - "tstrok;": '\U00000167', - "twixt;": '\U0000226C', - "twoheadleftarrow;": '\U0000219E', - "twoheadrightarrow;": '\U000021A0', - "uArr;": '\U000021D1', - "uHar;": '\U00002963', - "uacute;": '\U000000FA', - "uarr;": '\U00002191', - "ubrcy;": '\U0000045E', - "ubreve;": '\U0000016D', - "ucirc;": '\U000000FB', - "ucy;": '\U00000443', - "udarr;": '\U000021C5', - "udblac;": '\U00000171', - "udhar;": '\U0000296E', - "ufisht;": '\U0000297E', - "ufr;": '\U0001D532', - "ugrave;": '\U000000F9', - "uharl;": '\U000021BF', - "uharr;": '\U000021BE', - "uhblk;": '\U00002580', - "ulcorn;": '\U0000231C', - "ulcorner;": '\U0000231C', - "ulcrop;": '\U0000230F', - "ultri;": '\U000025F8', - "umacr;": '\U0000016B', - "uml;": '\U000000A8', - "uogon;": '\U00000173', - "uopf;": '\U0001D566', - "uparrow;": '\U00002191', - "updownarrow;": '\U00002195', - "upharpoonleft;": '\U000021BF', - "upharpoonright;": '\U000021BE', - "uplus;": '\U0000228E', - "upsi;": '\U000003C5', - "upsih;": '\U000003D2', - "upsilon;": '\U000003C5', - "upuparrows;": '\U000021C8', - "urcorn;": '\U0000231D', - "urcorner;": '\U0000231D', - "urcrop;": '\U0000230E', - "uring;": '\U0000016F', - "urtri;": '\U000025F9', - "uscr;": '\U0001D4CA', - "utdot;": '\U000022F0', - "utilde;": '\U00000169', - "utri;": '\U000025B5', - "utrif;": '\U000025B4', - "uuarr;": '\U000021C8', - "uuml;": '\U000000FC', - "uwangle;": '\U000029A7', - "vArr;": '\U000021D5', - "vBar;": '\U00002AE8', - "vBarv;": '\U00002AE9', - "vDash;": '\U000022A8', - "vangrt;": '\U0000299C', - "varepsilon;": '\U000003F5', - "varkappa;": '\U000003F0', - "varnothing;": '\U00002205', - "varphi;": '\U000003D5', - "varpi;": '\U000003D6', - "varpropto;": '\U0000221D', - "varr;": '\U00002195', - "varrho;": '\U000003F1', - "varsigma;": '\U000003C2', - "vartheta;": '\U000003D1', - "vartriangleleft;": '\U000022B2', - "vartriangleright;": '\U000022B3', - "vcy;": '\U00000432', - "vdash;": '\U000022A2', - "vee;": '\U00002228', - "veebar;": '\U000022BB', - "veeeq;": '\U0000225A', - "vellip;": '\U000022EE', - "verbar;": '\U0000007C', - "vert;": '\U0000007C', - "vfr;": '\U0001D533', - "vltri;": '\U000022B2', - "vopf;": '\U0001D567', - "vprop;": '\U0000221D', - "vrtri;": '\U000022B3', - "vscr;": '\U0001D4CB', - "vzigzag;": '\U0000299A', - "wcirc;": '\U00000175', - "wedbar;": '\U00002A5F', - "wedge;": '\U00002227', - "wedgeq;": '\U00002259', - "weierp;": '\U00002118', - "wfr;": '\U0001D534', - "wopf;": '\U0001D568', - "wp;": '\U00002118', - "wr;": '\U00002240', - "wreath;": '\U00002240', - "wscr;": '\U0001D4CC', - "xcap;": '\U000022C2', - "xcirc;": '\U000025EF', - "xcup;": '\U000022C3', - "xdtri;": '\U000025BD', - "xfr;": '\U0001D535', - "xhArr;": '\U000027FA', - "xharr;": '\U000027F7', - "xi;": '\U000003BE', - "xlArr;": '\U000027F8', - "xlarr;": '\U000027F5', - "xmap;": '\U000027FC', - "xnis;": '\U000022FB', - "xodot;": '\U00002A00', - "xopf;": '\U0001D569', - "xoplus;": '\U00002A01', - "xotime;": '\U00002A02', - "xrArr;": '\U000027F9', - "xrarr;": '\U000027F6', - "xscr;": '\U0001D4CD', - "xsqcup;": '\U00002A06', - "xuplus;": '\U00002A04', - "xutri;": '\U000025B3', - "xvee;": '\U000022C1', - "xwedge;": '\U000022C0', - "yacute;": '\U000000FD', - "yacy;": '\U0000044F', - "ycirc;": '\U00000177', - "ycy;": '\U0000044B', - "yen;": '\U000000A5', - "yfr;": '\U0001D536', - "yicy;": '\U00000457', - "yopf;": '\U0001D56A', - "yscr;": '\U0001D4CE', - "yucy;": '\U0000044E', - "yuml;": '\U000000FF', - "zacute;": '\U0000017A', - "zcaron;": '\U0000017E', - "zcy;": '\U00000437', - "zdot;": '\U0000017C', - "zeetrf;": '\U00002128', - "zeta;": '\U000003B6', - "zfr;": '\U0001D537', - "zhcy;": '\U00000436', - "zigrarr;": '\U000021DD', - "zopf;": '\U0001D56B', - "zscr;": '\U0001D4CF', - "zwj;": '\U0000200D', - "zwnj;": '\U0000200C', - "AElig": '\U000000C6', - "AMP": '\U00000026', - "Aacute": '\U000000C1', - "Acirc": '\U000000C2', - "Agrave": '\U000000C0', - "Aring": '\U000000C5', - "Atilde": '\U000000C3', - "Auml": '\U000000C4', - "COPY": '\U000000A9', - "Ccedil": '\U000000C7', - "ETH": '\U000000D0', - "Eacute": '\U000000C9', - "Ecirc": '\U000000CA', - "Egrave": '\U000000C8', - "Euml": '\U000000CB', - "GT": '\U0000003E', - "Iacute": '\U000000CD', - "Icirc": '\U000000CE', - "Igrave": '\U000000CC', - "Iuml": '\U000000CF', - "LT": '\U0000003C', - "Ntilde": '\U000000D1', - "Oacute": '\U000000D3', - "Ocirc": '\U000000D4', - "Ograve": '\U000000D2', - "Oslash": '\U000000D8', - "Otilde": '\U000000D5', - "Ouml": '\U000000D6', - "QUOT": '\U00000022', - "REG": '\U000000AE', - "THORN": '\U000000DE', - "Uacute": '\U000000DA', - "Ucirc": '\U000000DB', - "Ugrave": '\U000000D9', - "Uuml": '\U000000DC', - "Yacute": '\U000000DD', - "aacute": '\U000000E1', - "acirc": '\U000000E2', - "acute": '\U000000B4', - "aelig": '\U000000E6', - "agrave": '\U000000E0', - "amp": '\U00000026', - "aring": '\U000000E5', - "atilde": '\U000000E3', - "auml": '\U000000E4', - "brvbar": '\U000000A6', - "ccedil": '\U000000E7', - "cedil": '\U000000B8', - "cent": '\U000000A2', - "copy": '\U000000A9', - "curren": '\U000000A4', - "deg": '\U000000B0', - "divide": '\U000000F7', - "eacute": '\U000000E9', - "ecirc": '\U000000EA', - "egrave": '\U000000E8', - "eth": '\U000000F0', - "euml": '\U000000EB', - "frac12": '\U000000BD', - "frac14": '\U000000BC', - "frac34": '\U000000BE', - "gt": '\U0000003E', - "iacute": '\U000000ED', - "icirc": '\U000000EE', - "iexcl": '\U000000A1', - "igrave": '\U000000EC', - "iquest": '\U000000BF', - "iuml": '\U000000EF', - "laquo": '\U000000AB', - "lt": '\U0000003C', - "macr": '\U000000AF', - "micro": '\U000000B5', - "middot": '\U000000B7', - "nbsp": '\U000000A0', - "not": '\U000000AC', - "ntilde": '\U000000F1', - "oacute": '\U000000F3', - "ocirc": '\U000000F4', - "ograve": '\U000000F2', - "ordf": '\U000000AA', - "ordm": '\U000000BA', - "oslash": '\U000000F8', - "otilde": '\U000000F5', - "ouml": '\U000000F6', - "para": '\U000000B6', - "plusmn": '\U000000B1', - "pound": '\U000000A3', - "quot": '\U00000022', - "raquo": '\U000000BB', - "reg": '\U000000AE', - "sect": '\U000000A7', - "shy": '\U000000AD', - "sup1": '\U000000B9', - "sup2": '\U000000B2', - "sup3": '\U000000B3', - "szlig": '\U000000DF', - "thorn": '\U000000FE', - "times": '\U000000D7', - "uacute": '\U000000FA', - "ucirc": '\U000000FB', - "ugrave": '\U000000F9', - "uml": '\U000000A8', - "uuml": '\U000000FC', - "yacute": '\U000000FD', - "yen": '\U000000A5', - "yuml": '\U000000FF', -} - -// HTML entities that are two unicode codepoints. -var entity2 = map[string][2]rune{ - // TODO(nigeltao): Handle replacements that are wider than their names. - // "nLt;": {'\u226A', '\u20D2'}, - // "nGt;": {'\u226B', '\u20D2'}, - "NotEqualTilde;": {'\u2242', '\u0338'}, - "NotGreaterFullEqual;": {'\u2267', '\u0338'}, - "NotGreaterGreater;": {'\u226B', '\u0338'}, - "NotGreaterSlantEqual;": {'\u2A7E', '\u0338'}, - "NotHumpDownHump;": {'\u224E', '\u0338'}, - "NotHumpEqual;": {'\u224F', '\u0338'}, - "NotLeftTriangleBar;": {'\u29CF', '\u0338'}, - "NotLessLess;": {'\u226A', '\u0338'}, - "NotLessSlantEqual;": {'\u2A7D', '\u0338'}, - "NotNestedGreaterGreater;": {'\u2AA2', '\u0338'}, - "NotNestedLessLess;": {'\u2AA1', '\u0338'}, - "NotPrecedesEqual;": {'\u2AAF', '\u0338'}, - "NotRightTriangleBar;": {'\u29D0', '\u0338'}, - "NotSquareSubset;": {'\u228F', '\u0338'}, - "NotSquareSuperset;": {'\u2290', '\u0338'}, - "NotSubset;": {'\u2282', '\u20D2'}, - "NotSucceedsEqual;": {'\u2AB0', '\u0338'}, - "NotSucceedsTilde;": {'\u227F', '\u0338'}, - "NotSuperset;": {'\u2283', '\u20D2'}, - "ThickSpace;": {'\u205F', '\u200A'}, - "acE;": {'\u223E', '\u0333'}, - "bne;": {'\u003D', '\u20E5'}, - "bnequiv;": {'\u2261', '\u20E5'}, - "caps;": {'\u2229', '\uFE00'}, - "cups;": {'\u222A', '\uFE00'}, - "fjlig;": {'\u0066', '\u006A'}, - "gesl;": {'\u22DB', '\uFE00'}, - "gvertneqq;": {'\u2269', '\uFE00'}, - "gvnE;": {'\u2269', '\uFE00'}, - "lates;": {'\u2AAD', '\uFE00'}, - "lesg;": {'\u22DA', '\uFE00'}, - "lvertneqq;": {'\u2268', '\uFE00'}, - "lvnE;": {'\u2268', '\uFE00'}, - "nGg;": {'\u22D9', '\u0338'}, - "nGtv;": {'\u226B', '\u0338'}, - "nLl;": {'\u22D8', '\u0338'}, - "nLtv;": {'\u226A', '\u0338'}, - "nang;": {'\u2220', '\u20D2'}, - "napE;": {'\u2A70', '\u0338'}, - "napid;": {'\u224B', '\u0338'}, - "nbump;": {'\u224E', '\u0338'}, - "nbumpe;": {'\u224F', '\u0338'}, - "ncongdot;": {'\u2A6D', '\u0338'}, - "nedot;": {'\u2250', '\u0338'}, - "nesim;": {'\u2242', '\u0338'}, - "ngE;": {'\u2267', '\u0338'}, - "ngeqq;": {'\u2267', '\u0338'}, - "ngeqslant;": {'\u2A7E', '\u0338'}, - "nges;": {'\u2A7E', '\u0338'}, - "nlE;": {'\u2266', '\u0338'}, - "nleqq;": {'\u2266', '\u0338'}, - "nleqslant;": {'\u2A7D', '\u0338'}, - "nles;": {'\u2A7D', '\u0338'}, - "notinE;": {'\u22F9', '\u0338'}, - "notindot;": {'\u22F5', '\u0338'}, - "nparsl;": {'\u2AFD', '\u20E5'}, - "npart;": {'\u2202', '\u0338'}, - "npre;": {'\u2AAF', '\u0338'}, - "npreceq;": {'\u2AAF', '\u0338'}, - "nrarrc;": {'\u2933', '\u0338'}, - "nrarrw;": {'\u219D', '\u0338'}, - "nsce;": {'\u2AB0', '\u0338'}, - "nsubE;": {'\u2AC5', '\u0338'}, - "nsubset;": {'\u2282', '\u20D2'}, - "nsubseteqq;": {'\u2AC5', '\u0338'}, - "nsucceq;": {'\u2AB0', '\u0338'}, - "nsupE;": {'\u2AC6', '\u0338'}, - "nsupset;": {'\u2283', '\u20D2'}, - "nsupseteqq;": {'\u2AC6', '\u0338'}, - "nvap;": {'\u224D', '\u20D2'}, - "nvge;": {'\u2265', '\u20D2'}, - "nvgt;": {'\u003E', '\u20D2'}, - "nvle;": {'\u2264', '\u20D2'}, - "nvlt;": {'\u003C', '\u20D2'}, - "nvltrie;": {'\u22B4', '\u20D2'}, - "nvrtrie;": {'\u22B5', '\u20D2'}, - "nvsim;": {'\u223C', '\u20D2'}, - "race;": {'\u223D', '\u0331'}, - "smtes;": {'\u2AAC', '\uFE00'}, - "sqcaps;": {'\u2293', '\uFE00'}, - "sqcups;": {'\u2294', '\uFE00'}, - "varsubsetneq;": {'\u228A', '\uFE00'}, - "varsubsetneqq;": {'\u2ACB', '\uFE00'}, - "varsupsetneq;": {'\u228B', '\uFE00'}, - "varsupsetneqq;": {'\u2ACC', '\uFE00'}, - "vnsub;": {'\u2282', '\u20D2'}, - "vnsup;": {'\u2283', '\u20D2'}, - "vsubnE;": {'\u2ACB', '\uFE00'}, - "vsubne;": {'\u228A', '\uFE00'}, - "vsupnE;": {'\u2ACC', '\uFE00'}, - "vsupne;": {'\u228B', '\uFE00'}, -} diff --git a/vendor/golang.org/x/net/html/escape.go b/vendor/golang.org/x/net/html/escape.go deleted file mode 100644 index d856139..0000000 --- a/vendor/golang.org/x/net/html/escape.go +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -import ( - "bytes" - "strings" - "unicode/utf8" -) - -// These replacements permit compatibility with old numeric entities that -// assumed Windows-1252 encoding. -// https://html.spec.whatwg.org/multipage/syntax.html#consume-a-character-reference -var replacementTable = [...]rune{ - '\u20AC', // First entry is what 0x80 should be replaced with. - '\u0081', - '\u201A', - '\u0192', - '\u201E', - '\u2026', - '\u2020', - '\u2021', - '\u02C6', - '\u2030', - '\u0160', - '\u2039', - '\u0152', - '\u008D', - '\u017D', - '\u008F', - '\u0090', - '\u2018', - '\u2019', - '\u201C', - '\u201D', - '\u2022', - '\u2013', - '\u2014', - '\u02DC', - '\u2122', - '\u0161', - '\u203A', - '\u0153', - '\u009D', - '\u017E', - '\u0178', // Last entry is 0x9F. - // 0x00->'\uFFFD' is handled programmatically. - // 0x0D->'\u000D' is a no-op. -} - -// unescapeEntity reads an entity like "<" from b[src:] and writes the -// corresponding "<" to b[dst:], returning the incremented dst and src cursors. -// Precondition: b[src] == '&' && dst <= src. -// attribute should be true if parsing an attribute value. -func unescapeEntity(b []byte, dst, src int, attribute bool) (dst1, src1 int) { - // https://html.spec.whatwg.org/multipage/syntax.html#consume-a-character-reference - - // i starts at 1 because we already know that s[0] == '&'. - i, s := 1, b[src:] - - if len(s) <= 1 { - b[dst] = b[src] - return dst + 1, src + 1 - } - - if s[i] == '#' { - if len(s) <= 3 { // We need to have at least "&#.". - b[dst] = b[src] - return dst + 1, src + 1 - } - i++ - c := s[i] - hex := false - if c == 'x' || c == 'X' { - hex = true - i++ - } - - x := '\x00' - for i < len(s) { - c = s[i] - i++ - if hex { - if '0' <= c && c <= '9' { - x = 16*x + rune(c) - '0' - continue - } else if 'a' <= c && c <= 'f' { - x = 16*x + rune(c) - 'a' + 10 - continue - } else if 'A' <= c && c <= 'F' { - x = 16*x + rune(c) - 'A' + 10 - continue - } - } else if '0' <= c && c <= '9' { - x = 10*x + rune(c) - '0' - continue - } - if c != ';' { - i-- - } - break - } - - if i <= 3 { // No characters matched. - b[dst] = b[src] - return dst + 1, src + 1 - } - - if 0x80 <= x && x <= 0x9F { - // Replace characters from Windows-1252 with UTF-8 equivalents. - x = replacementTable[x-0x80] - } else if x == 0 || (0xD800 <= x && x <= 0xDFFF) || x > 0x10FFFF { - // Replace invalid characters with the replacement character. - x = '\uFFFD' - } - - return dst + utf8.EncodeRune(b[dst:], x), src + i - } - - // Consume the maximum number of characters possible, with the - // consumed characters matching one of the named references. - - for i < len(s) { - c := s[i] - i++ - // Lower-cased characters are more common in entities, so we check for them first. - if 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || '0' <= c && c <= '9' { - continue - } - if c != ';' { - i-- - } - break - } - - entityName := string(s[1:i]) - if entityName == "" { - // No-op. - } else if attribute && entityName[len(entityName)-1] != ';' && len(s) > i && s[i] == '=' { - // No-op. - } else if x := entity[entityName]; x != 0 { - return dst + utf8.EncodeRune(b[dst:], x), src + i - } else if x := entity2[entityName]; x[0] != 0 { - dst1 := dst + utf8.EncodeRune(b[dst:], x[0]) - return dst1 + utf8.EncodeRune(b[dst1:], x[1]), src + i - } else if !attribute { - maxLen := len(entityName) - 1 - if maxLen > longestEntityWithoutSemicolon { - maxLen = longestEntityWithoutSemicolon - } - for j := maxLen; j > 1; j-- { - if x := entity[entityName[:j]]; x != 0 { - return dst + utf8.EncodeRune(b[dst:], x), src + j + 1 - } - } - } - - dst1, src1 = dst+i, src+i - copy(b[dst:dst1], b[src:src1]) - return dst1, src1 -} - -// unescape unescapes b's entities in-place, so that "a<b" becomes "a': - esc = ">" - case '"': - // """ is shorter than """. - esc = """ - case '\r': - esc = " " - default: - panic("unrecognized escape character") - } - s = s[i+1:] - if _, err := w.WriteString(esc); err != nil { - return err - } - i = strings.IndexAny(s, escapedChars) - } - _, err := w.WriteString(s) - return err -} - -// EscapeString escapes special characters like "<" to become "<". It -// escapes only five such characters: <, >, &, ' and ". -// UnescapeString(EscapeString(s)) == s always holds, but the converse isn't -// always true. -func EscapeString(s string) string { - if strings.IndexAny(s, escapedChars) == -1 { - return s - } - var buf bytes.Buffer - escape(&buf, s) - return buf.String() -} - -// UnescapeString unescapes entities like "<" to become "<". It unescapes a -// larger range of entities than EscapeString escapes. For example, "á" -// unescapes to "á", as does "á" and "&xE1;". -// UnescapeString(EscapeString(s)) == s always holds, but the converse isn't -// always true. -func UnescapeString(s string) string { - for _, c := range s { - if c == '&' { - return string(unescape([]byte(s), false)) - } - } - return s -} diff --git a/vendor/golang.org/x/net/html/foreign.go b/vendor/golang.org/x/net/html/foreign.go deleted file mode 100644 index 01477a9..0000000 --- a/vendor/golang.org/x/net/html/foreign.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -import ( - "strings" -) - -func adjustAttributeNames(aa []Attribute, nameMap map[string]string) { - for i := range aa { - if newName, ok := nameMap[aa[i].Key]; ok { - aa[i].Key = newName - } - } -} - -func adjustForeignAttributes(aa []Attribute) { - for i, a := range aa { - if a.Key == "" || a.Key[0] != 'x' { - continue - } - switch a.Key { - case "xlink:actuate", "xlink:arcrole", "xlink:href", "xlink:role", "xlink:show", - "xlink:title", "xlink:type", "xml:base", "xml:lang", "xml:space", "xmlns:xlink": - j := strings.Index(a.Key, ":") - aa[i].Namespace = a.Key[:j] - aa[i].Key = a.Key[j+1:] - } - } -} - -func htmlIntegrationPoint(n *Node) bool { - if n.Type != ElementNode { - return false - } - switch n.Namespace { - case "math": - if n.Data == "annotation-xml" { - for _, a := range n.Attr { - if a.Key == "encoding" { - val := strings.ToLower(a.Val) - if val == "text/html" || val == "application/xhtml+xml" { - return true - } - } - } - } - case "svg": - switch n.Data { - case "desc", "foreignObject", "title": - return true - } - } - return false -} - -func mathMLTextIntegrationPoint(n *Node) bool { - if n.Namespace != "math" { - return false - } - switch n.Data { - case "mi", "mo", "mn", "ms", "mtext": - return true - } - return false -} - -// Section 12.2.6.5. -var breakout = map[string]bool{ - "b": true, - "big": true, - "blockquote": true, - "body": true, - "br": true, - "center": true, - "code": true, - "dd": true, - "div": true, - "dl": true, - "dt": true, - "em": true, - "embed": true, - "h1": true, - "h2": true, - "h3": true, - "h4": true, - "h5": true, - "h6": true, - "head": true, - "hr": true, - "i": true, - "img": true, - "li": true, - "listing": true, - "menu": true, - "meta": true, - "nobr": true, - "ol": true, - "p": true, - "pre": true, - "ruby": true, - "s": true, - "small": true, - "span": true, - "strong": true, - "strike": true, - "sub": true, - "sup": true, - "table": true, - "tt": true, - "u": true, - "ul": true, - "var": true, -} - -// Section 12.2.6.5. -var svgTagNameAdjustments = map[string]string{ - "altglyph": "altGlyph", - "altglyphdef": "altGlyphDef", - "altglyphitem": "altGlyphItem", - "animatecolor": "animateColor", - "animatemotion": "animateMotion", - "animatetransform": "animateTransform", - "clippath": "clipPath", - "feblend": "feBlend", - "fecolormatrix": "feColorMatrix", - "fecomponenttransfer": "feComponentTransfer", - "fecomposite": "feComposite", - "feconvolvematrix": "feConvolveMatrix", - "fediffuselighting": "feDiffuseLighting", - "fedisplacementmap": "feDisplacementMap", - "fedistantlight": "feDistantLight", - "feflood": "feFlood", - "fefunca": "feFuncA", - "fefuncb": "feFuncB", - "fefuncg": "feFuncG", - "fefuncr": "feFuncR", - "fegaussianblur": "feGaussianBlur", - "feimage": "feImage", - "femerge": "feMerge", - "femergenode": "feMergeNode", - "femorphology": "feMorphology", - "feoffset": "feOffset", - "fepointlight": "fePointLight", - "fespecularlighting": "feSpecularLighting", - "fespotlight": "feSpotLight", - "fetile": "feTile", - "feturbulence": "feTurbulence", - "foreignobject": "foreignObject", - "glyphref": "glyphRef", - "lineargradient": "linearGradient", - "radialgradient": "radialGradient", - "textpath": "textPath", -} - -// Section 12.2.6.1 -var mathMLAttributeAdjustments = map[string]string{ - "definitionurl": "definitionURL", -} - -var svgAttributeAdjustments = map[string]string{ - "attributename": "attributeName", - "attributetype": "attributeType", - "basefrequency": "baseFrequency", - "baseprofile": "baseProfile", - "calcmode": "calcMode", - "clippathunits": "clipPathUnits", - "contentscripttype": "contentScriptType", - "contentstyletype": "contentStyleType", - "diffuseconstant": "diffuseConstant", - "edgemode": "edgeMode", - "externalresourcesrequired": "externalResourcesRequired", - "filterres": "filterRes", - "filterunits": "filterUnits", - "glyphref": "glyphRef", - "gradienttransform": "gradientTransform", - "gradientunits": "gradientUnits", - "kernelmatrix": "kernelMatrix", - "kernelunitlength": "kernelUnitLength", - "keypoints": "keyPoints", - "keysplines": "keySplines", - "keytimes": "keyTimes", - "lengthadjust": "lengthAdjust", - "limitingconeangle": "limitingConeAngle", - "markerheight": "markerHeight", - "markerunits": "markerUnits", - "markerwidth": "markerWidth", - "maskcontentunits": "maskContentUnits", - "maskunits": "maskUnits", - "numoctaves": "numOctaves", - "pathlength": "pathLength", - "patterncontentunits": "patternContentUnits", - "patterntransform": "patternTransform", - "patternunits": "patternUnits", - "pointsatx": "pointsAtX", - "pointsaty": "pointsAtY", - "pointsatz": "pointsAtZ", - "preservealpha": "preserveAlpha", - "preserveaspectratio": "preserveAspectRatio", - "primitiveunits": "primitiveUnits", - "refx": "refX", - "refy": "refY", - "repeatcount": "repeatCount", - "repeatdur": "repeatDur", - "requiredextensions": "requiredExtensions", - "requiredfeatures": "requiredFeatures", - "specularconstant": "specularConstant", - "specularexponent": "specularExponent", - "spreadmethod": "spreadMethod", - "startoffset": "startOffset", - "stddeviation": "stdDeviation", - "stitchtiles": "stitchTiles", - "surfacescale": "surfaceScale", - "systemlanguage": "systemLanguage", - "tablevalues": "tableValues", - "targetx": "targetX", - "targety": "targetY", - "textlength": "textLength", - "viewbox": "viewBox", - "viewtarget": "viewTarget", - "xchannelselector": "xChannelSelector", - "ychannelselector": "yChannelSelector", - "zoomandpan": "zoomAndPan", -} diff --git a/vendor/golang.org/x/net/html/node.go b/vendor/golang.org/x/net/html/node.go deleted file mode 100644 index 2c1cade..0000000 --- a/vendor/golang.org/x/net/html/node.go +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -import ( - "golang.org/x/net/html/atom" -) - -// A NodeType is the type of a Node. -type NodeType uint32 - -const ( - ErrorNode NodeType = iota - TextNode - DocumentNode - ElementNode - CommentNode - DoctypeNode - scopeMarkerNode -) - -// Section 12.2.4.3 says "The markers are inserted when entering applet, -// object, marquee, template, td, th, and caption elements, and are used -// to prevent formatting from "leaking" into applet, object, marquee, -// template, td, th, and caption elements". -var scopeMarker = Node{Type: scopeMarkerNode} - -// A Node consists of a NodeType and some Data (tag name for element nodes, -// content for text) and are part of a tree of Nodes. Element nodes may also -// have a Namespace and contain a slice of Attributes. Data is unescaped, so -// that it looks like "a 0 { - return (*s)[i-1] - } - return nil -} - -// index returns the index of the top-most occurrence of n in the stack, or -1 -// if n is not present. -func (s *nodeStack) index(n *Node) int { - for i := len(*s) - 1; i >= 0; i-- { - if (*s)[i] == n { - return i - } - } - return -1 -} - -// contains returns whether a is within s. -func (s *nodeStack) contains(a atom.Atom) bool { - for _, n := range *s { - if n.DataAtom == a { - return true - } - } - return false -} - -// insert inserts a node at the given index. -func (s *nodeStack) insert(i int, n *Node) { - (*s) = append(*s, nil) - copy((*s)[i+1:], (*s)[i:]) - (*s)[i] = n -} - -// remove removes a node from the stack. It is a no-op if n is not present. -func (s *nodeStack) remove(n *Node) { - i := s.index(n) - if i == -1 { - return - } - copy((*s)[i:], (*s)[i+1:]) - j := len(*s) - 1 - (*s)[j] = nil - *s = (*s)[:j] -} - -type insertionModeStack []insertionMode - -func (s *insertionModeStack) pop() (im insertionMode) { - i := len(*s) - im = (*s)[i-1] - *s = (*s)[:i-1] - return im -} - -func (s *insertionModeStack) top() insertionMode { - if i := len(*s); i > 0 { - return (*s)[i-1] - } - return nil -} diff --git a/vendor/golang.org/x/net/html/parse.go b/vendor/golang.org/x/net/html/parse.go deleted file mode 100644 index 64a5793..0000000 --- a/vendor/golang.org/x/net/html/parse.go +++ /dev/null @@ -1,2311 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -import ( - "errors" - "fmt" - "io" - "strings" - - a "golang.org/x/net/html/atom" -) - -// A parser implements the HTML5 parsing algorithm: -// https://html.spec.whatwg.org/multipage/syntax.html#tree-construction -type parser struct { - // tokenizer provides the tokens for the parser. - tokenizer *Tokenizer - // tok is the most recently read token. - tok Token - // Self-closing tags like


are treated as start tags, except that - // hasSelfClosingToken is set while they are being processed. - hasSelfClosingToken bool - // doc is the document root element. - doc *Node - // The stack of open elements (section 12.2.4.2) and active formatting - // elements (section 12.2.4.3). - oe, afe nodeStack - // Element pointers (section 12.2.4.4). - head, form *Node - // Other parsing state flags (section 12.2.4.5). - scripting, framesetOK bool - // The stack of template insertion modes - templateStack insertionModeStack - // im is the current insertion mode. - im insertionMode - // originalIM is the insertion mode to go back to after completing a text - // or inTableText insertion mode. - originalIM insertionMode - // fosterParenting is whether new elements should be inserted according to - // the foster parenting rules (section 12.2.6.1). - fosterParenting bool - // quirks is whether the parser is operating in "quirks mode." - quirks bool - // fragment is whether the parser is parsing an HTML fragment. - fragment bool - // context is the context element when parsing an HTML fragment - // (section 12.4). - context *Node -} - -func (p *parser) top() *Node { - if n := p.oe.top(); n != nil { - return n - } - return p.doc -} - -// Stop tags for use in popUntil. These come from section 12.2.4.2. -var ( - defaultScopeStopTags = map[string][]a.Atom{ - "": {a.Applet, a.Caption, a.Html, a.Table, a.Td, a.Th, a.Marquee, a.Object, a.Template}, - "math": {a.AnnotationXml, a.Mi, a.Mn, a.Mo, a.Ms, a.Mtext}, - "svg": {a.Desc, a.ForeignObject, a.Title}, - } -) - -type scope int - -const ( - defaultScope scope = iota - listItemScope - buttonScope - tableScope - tableRowScope - tableBodyScope - selectScope -) - -// popUntil pops the stack of open elements at the highest element whose tag -// is in matchTags, provided there is no higher element in the scope's stop -// tags (as defined in section 12.2.4.2). It returns whether or not there was -// such an element. If there was not, popUntil leaves the stack unchanged. -// -// For example, the set of stop tags for table scope is: "html", "table". If -// the stack was: -// ["html", "body", "font", "table", "b", "i", "u"] -// then popUntil(tableScope, "font") would return false, but -// popUntil(tableScope, "i") would return true and the stack would become: -// ["html", "body", "font", "table", "b"] -// -// If an element's tag is in both the stop tags and matchTags, then the stack -// will be popped and the function returns true (provided, of course, there was -// no higher element in the stack that was also in the stop tags). For example, -// popUntil(tableScope, "table") returns true and leaves: -// ["html", "body", "font"] -func (p *parser) popUntil(s scope, matchTags ...a.Atom) bool { - if i := p.indexOfElementInScope(s, matchTags...); i != -1 { - p.oe = p.oe[:i] - return true - } - return false -} - -// indexOfElementInScope returns the index in p.oe of the highest element whose -// tag is in matchTags that is in scope. If no matching element is in scope, it -// returns -1. -func (p *parser) indexOfElementInScope(s scope, matchTags ...a.Atom) int { - for i := len(p.oe) - 1; i >= 0; i-- { - tagAtom := p.oe[i].DataAtom - if p.oe[i].Namespace == "" { - for _, t := range matchTags { - if t == tagAtom { - return i - } - } - switch s { - case defaultScope: - // No-op. - case listItemScope: - if tagAtom == a.Ol || tagAtom == a.Ul { - return -1 - } - case buttonScope: - if tagAtom == a.Button { - return -1 - } - case tableScope: - if tagAtom == a.Html || tagAtom == a.Table || tagAtom == a.Template { - return -1 - } - case selectScope: - if tagAtom != a.Optgroup && tagAtom != a.Option { - return -1 - } - default: - panic("unreachable") - } - } - switch s { - case defaultScope, listItemScope, buttonScope: - for _, t := range defaultScopeStopTags[p.oe[i].Namespace] { - if t == tagAtom { - return -1 - } - } - } - } - return -1 -} - -// elementInScope is like popUntil, except that it doesn't modify the stack of -// open elements. -func (p *parser) elementInScope(s scope, matchTags ...a.Atom) bool { - return p.indexOfElementInScope(s, matchTags...) != -1 -} - -// clearStackToContext pops elements off the stack of open elements until a -// scope-defined element is found. -func (p *parser) clearStackToContext(s scope) { - for i := len(p.oe) - 1; i >= 0; i-- { - tagAtom := p.oe[i].DataAtom - switch s { - case tableScope: - if tagAtom == a.Html || tagAtom == a.Table || tagAtom == a.Template { - p.oe = p.oe[:i+1] - return - } - case tableRowScope: - if tagAtom == a.Html || tagAtom == a.Tr || tagAtom == a.Template { - p.oe = p.oe[:i+1] - return - } - case tableBodyScope: - if tagAtom == a.Html || tagAtom == a.Tbody || tagAtom == a.Tfoot || tagAtom == a.Thead || tagAtom == a.Template { - p.oe = p.oe[:i+1] - return - } - default: - panic("unreachable") - } - } -} - -// generateImpliedEndTags pops nodes off the stack of open elements as long as -// the top node has a tag name of dd, dt, li, optgroup, option, p, rb, rp, rt or rtc. -// If exceptions are specified, nodes with that name will not be popped off. -func (p *parser) generateImpliedEndTags(exceptions ...string) { - var i int -loop: - for i = len(p.oe) - 1; i >= 0; i-- { - n := p.oe[i] - if n.Type == ElementNode { - switch n.DataAtom { - case a.Dd, a.Dt, a.Li, a.Optgroup, a.Option, a.P, a.Rb, a.Rp, a.Rt, a.Rtc: - for _, except := range exceptions { - if n.Data == except { - break loop - } - } - continue - } - } - break - } - - p.oe = p.oe[:i+1] -} - -// addChild adds a child node n to the top element, and pushes n onto the stack -// of open elements if it is an element node. -func (p *parser) addChild(n *Node) { - if p.shouldFosterParent() { - p.fosterParent(n) - } else { - p.top().AppendChild(n) - } - - if n.Type == ElementNode { - p.oe = append(p.oe, n) - } -} - -// shouldFosterParent returns whether the next node to be added should be -// foster parented. -func (p *parser) shouldFosterParent() bool { - if p.fosterParenting { - switch p.top().DataAtom { - case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr: - return true - } - } - return false -} - -// fosterParent adds a child node according to the foster parenting rules. -// Section 12.2.6.1, "foster parenting". -func (p *parser) fosterParent(n *Node) { - var table, parent, prev, template *Node - var i int - for i = len(p.oe) - 1; i >= 0; i-- { - if p.oe[i].DataAtom == a.Table { - table = p.oe[i] - break - } - } - - var j int - for j = len(p.oe) - 1; j >= 0; j-- { - if p.oe[j].DataAtom == a.Template { - template = p.oe[j] - break - } - } - - if template != nil && (table == nil || j > i) { - template.AppendChild(n) - return - } - - if table == nil { - // The foster parent is the html element. - parent = p.oe[0] - } else { - parent = table.Parent - } - if parent == nil { - parent = p.oe[i-1] - } - - if table != nil { - prev = table.PrevSibling - } else { - prev = parent.LastChild - } - if prev != nil && prev.Type == TextNode && n.Type == TextNode { - prev.Data += n.Data - return - } - - parent.InsertBefore(n, table) -} - -// addText adds text to the preceding node if it is a text node, or else it -// calls addChild with a new text node. -func (p *parser) addText(text string) { - if text == "" { - return - } - - if p.shouldFosterParent() { - p.fosterParent(&Node{ - Type: TextNode, - Data: text, - }) - return - } - - t := p.top() - if n := t.LastChild; n != nil && n.Type == TextNode { - n.Data += text - return - } - p.addChild(&Node{ - Type: TextNode, - Data: text, - }) -} - -// addElement adds a child element based on the current token. -func (p *parser) addElement() { - p.addChild(&Node{ - Type: ElementNode, - DataAtom: p.tok.DataAtom, - Data: p.tok.Data, - Attr: p.tok.Attr, - }) -} - -// Section 12.2.4.3. -func (p *parser) addFormattingElement() { - tagAtom, attr := p.tok.DataAtom, p.tok.Attr - p.addElement() - - // Implement the Noah's Ark clause, but with three per family instead of two. - identicalElements := 0 -findIdenticalElements: - for i := len(p.afe) - 1; i >= 0; i-- { - n := p.afe[i] - if n.Type == scopeMarkerNode { - break - } - if n.Type != ElementNode { - continue - } - if n.Namespace != "" { - continue - } - if n.DataAtom != tagAtom { - continue - } - if len(n.Attr) != len(attr) { - continue - } - compareAttributes: - for _, t0 := range n.Attr { - for _, t1 := range attr { - if t0.Key == t1.Key && t0.Namespace == t1.Namespace && t0.Val == t1.Val { - // Found a match for this attribute, continue with the next attribute. - continue compareAttributes - } - } - // If we get here, there is no attribute that matches a. - // Therefore the element is not identical to the new one. - continue findIdenticalElements - } - - identicalElements++ - if identicalElements >= 3 { - p.afe.remove(n) - } - } - - p.afe = append(p.afe, p.top()) -} - -// Section 12.2.4.3. -func (p *parser) clearActiveFormattingElements() { - for { - n := p.afe.pop() - if len(p.afe) == 0 || n.Type == scopeMarkerNode { - return - } - } -} - -// Section 12.2.4.3. -func (p *parser) reconstructActiveFormattingElements() { - n := p.afe.top() - if n == nil { - return - } - if n.Type == scopeMarkerNode || p.oe.index(n) != -1 { - return - } - i := len(p.afe) - 1 - for n.Type != scopeMarkerNode && p.oe.index(n) == -1 { - if i == 0 { - i = -1 - break - } - i-- - n = p.afe[i] - } - for { - i++ - clone := p.afe[i].clone() - p.addChild(clone) - p.afe[i] = clone - if i == len(p.afe)-1 { - break - } - } -} - -// Section 12.2.5. -func (p *parser) acknowledgeSelfClosingTag() { - p.hasSelfClosingToken = false -} - -// An insertion mode (section 12.2.4.1) is the state transition function from -// a particular state in the HTML5 parser's state machine. It updates the -// parser's fields depending on parser.tok (where ErrorToken means EOF). -// It returns whether the token was consumed. -type insertionMode func(*parser) bool - -// setOriginalIM sets the insertion mode to return to after completing a text or -// inTableText insertion mode. -// Section 12.2.4.1, "using the rules for". -func (p *parser) setOriginalIM() { - if p.originalIM != nil { - panic("html: bad parser state: originalIM was set twice") - } - p.originalIM = p.im -} - -// Section 12.2.4.1, "reset the insertion mode". -func (p *parser) resetInsertionMode() { - for i := len(p.oe) - 1; i >= 0; i-- { - n := p.oe[i] - last := i == 0 - if last && p.context != nil { - n = p.context - } - - switch n.DataAtom { - case a.Select: - if !last { - for ancestor, first := n, p.oe[0]; ancestor != first; { - if ancestor == first { - break - } - ancestor = p.oe[p.oe.index(ancestor)-1] - switch ancestor.DataAtom { - case a.Template: - p.im = inSelectIM - return - case a.Table: - p.im = inSelectInTableIM - return - } - } - } - p.im = inSelectIM - case a.Td, a.Th: - // TODO: remove this divergence from the HTML5 spec. - // - // See https://bugs.chromium.org/p/chromium/issues/detail?id=829668 - p.im = inCellIM - case a.Tr: - p.im = inRowIM - case a.Tbody, a.Thead, a.Tfoot: - p.im = inTableBodyIM - case a.Caption: - p.im = inCaptionIM - case a.Colgroup: - p.im = inColumnGroupIM - case a.Table: - p.im = inTableIM - case a.Template: - // TODO: remove this divergence from the HTML5 spec. - if n.Namespace != "" { - continue - } - p.im = p.templateStack.top() - case a.Head: - // TODO: remove this divergence from the HTML5 spec. - // - // See https://bugs.chromium.org/p/chromium/issues/detail?id=829668 - p.im = inHeadIM - case a.Body: - p.im = inBodyIM - case a.Frameset: - p.im = inFramesetIM - case a.Html: - if p.head == nil { - p.im = beforeHeadIM - } else { - p.im = afterHeadIM - } - default: - if last { - p.im = inBodyIM - return - } - continue - } - return - } -} - -const whitespace = " \t\r\n\f" - -// Section 12.2.6.4.1. -func initialIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - p.tok.Data = strings.TrimLeft(p.tok.Data, whitespace) - if len(p.tok.Data) == 0 { - // It was all whitespace, so ignore it. - return true - } - case CommentToken: - p.doc.AppendChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - case DoctypeToken: - n, quirks := parseDoctype(p.tok.Data) - p.doc.AppendChild(n) - p.quirks = quirks - p.im = beforeHTMLIM - return true - } - p.quirks = true - p.im = beforeHTMLIM - return false -} - -// Section 12.2.6.4.2. -func beforeHTMLIM(p *parser) bool { - switch p.tok.Type { - case DoctypeToken: - // Ignore the token. - return true - case TextToken: - p.tok.Data = strings.TrimLeft(p.tok.Data, whitespace) - if len(p.tok.Data) == 0 { - // It was all whitespace, so ignore it. - return true - } - case StartTagToken: - if p.tok.DataAtom == a.Html { - p.addElement() - p.im = beforeHeadIM - return true - } - case EndTagToken: - switch p.tok.DataAtom { - case a.Head, a.Body, a.Html, a.Br: - p.parseImpliedToken(StartTagToken, a.Html, a.Html.String()) - return false - default: - // Ignore the token. - return true - } - case CommentToken: - p.doc.AppendChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - } - p.parseImpliedToken(StartTagToken, a.Html, a.Html.String()) - return false -} - -// Section 12.2.6.4.3. -func beforeHeadIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - p.tok.Data = strings.TrimLeft(p.tok.Data, whitespace) - if len(p.tok.Data) == 0 { - // It was all whitespace, so ignore it. - return true - } - case StartTagToken: - switch p.tok.DataAtom { - case a.Head: - p.addElement() - p.head = p.top() - p.im = inHeadIM - return true - case a.Html: - return inBodyIM(p) - } - case EndTagToken: - switch p.tok.DataAtom { - case a.Head, a.Body, a.Html, a.Br: - p.parseImpliedToken(StartTagToken, a.Head, a.Head.String()) - return false - default: - // Ignore the token. - return true - } - case CommentToken: - p.addChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - case DoctypeToken: - // Ignore the token. - return true - } - - p.parseImpliedToken(StartTagToken, a.Head, a.Head.String()) - return false -} - -// Section 12.2.6.4.4. -func inHeadIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - s := strings.TrimLeft(p.tok.Data, whitespace) - if len(s) < len(p.tok.Data) { - // Add the initial whitespace to the current node. - p.addText(p.tok.Data[:len(p.tok.Data)-len(s)]) - if s == "" { - return true - } - p.tok.Data = s - } - case StartTagToken: - switch p.tok.DataAtom { - case a.Html: - return inBodyIM(p) - case a.Base, a.Basefont, a.Bgsound, a.Command, a.Link, a.Meta: - p.addElement() - p.oe.pop() - p.acknowledgeSelfClosingTag() - return true - case a.Script, a.Title, a.Noscript, a.Noframes, a.Style: - p.addElement() - p.setOriginalIM() - p.im = textIM - return true - case a.Head: - // Ignore the token. - return true - case a.Template: - p.addElement() - p.afe = append(p.afe, &scopeMarker) - p.framesetOK = false - p.im = inTemplateIM - p.templateStack = append(p.templateStack, inTemplateIM) - return true - } - case EndTagToken: - switch p.tok.DataAtom { - case a.Head: - p.oe.pop() - p.im = afterHeadIM - return true - case a.Body, a.Html, a.Br: - p.parseImpliedToken(EndTagToken, a.Head, a.Head.String()) - return false - case a.Template: - if !p.oe.contains(a.Template) { - return true - } - // TODO: remove this divergence from the HTML5 spec. - // - // See https://bugs.chromium.org/p/chromium/issues/detail?id=829668 - p.generateImpliedEndTags() - for i := len(p.oe) - 1; i >= 0; i-- { - if n := p.oe[i]; n.Namespace == "" && n.DataAtom == a.Template { - p.oe = p.oe[:i] - break - } - } - p.clearActiveFormattingElements() - p.templateStack.pop() - p.resetInsertionMode() - return true - default: - // Ignore the token. - return true - } - case CommentToken: - p.addChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - case DoctypeToken: - // Ignore the token. - return true - } - - p.parseImpliedToken(EndTagToken, a.Head, a.Head.String()) - return false -} - -// Section 12.2.6.4.6. -func afterHeadIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - s := strings.TrimLeft(p.tok.Data, whitespace) - if len(s) < len(p.tok.Data) { - // Add the initial whitespace to the current node. - p.addText(p.tok.Data[:len(p.tok.Data)-len(s)]) - if s == "" { - return true - } - p.tok.Data = s - } - case StartTagToken: - switch p.tok.DataAtom { - case a.Html: - return inBodyIM(p) - case a.Body: - p.addElement() - p.framesetOK = false - p.im = inBodyIM - return true - case a.Frameset: - p.addElement() - p.im = inFramesetIM - return true - case a.Base, a.Basefont, a.Bgsound, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Template, a.Title: - p.oe = append(p.oe, p.head) - defer p.oe.remove(p.head) - return inHeadIM(p) - case a.Head: - // Ignore the token. - return true - } - case EndTagToken: - switch p.tok.DataAtom { - case a.Body, a.Html, a.Br: - // Drop down to creating an implied tag. - case a.Template: - return inHeadIM(p) - default: - // Ignore the token. - return true - } - case CommentToken: - p.addChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - case DoctypeToken: - // Ignore the token. - return true - } - - p.parseImpliedToken(StartTagToken, a.Body, a.Body.String()) - p.framesetOK = true - return false -} - -// copyAttributes copies attributes of src not found on dst to dst. -func copyAttributes(dst *Node, src Token) { - if len(src.Attr) == 0 { - return - } - attr := map[string]string{} - for _, t := range dst.Attr { - attr[t.Key] = t.Val - } - for _, t := range src.Attr { - if _, ok := attr[t.Key]; !ok { - dst.Attr = append(dst.Attr, t) - attr[t.Key] = t.Val - } - } -} - -// Section 12.2.6.4.7. -func inBodyIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - d := p.tok.Data - switch n := p.oe.top(); n.DataAtom { - case a.Pre, a.Listing: - if n.FirstChild == nil { - // Ignore a newline at the start of a
 block.
-				if d != "" && d[0] == '\r' {
-					d = d[1:]
-				}
-				if d != "" && d[0] == '\n' {
-					d = d[1:]
-				}
-			}
-		}
-		d = strings.Replace(d, "\x00", "", -1)
-		if d == "" {
-			return true
-		}
-		p.reconstructActiveFormattingElements()
-		p.addText(d)
-		if p.framesetOK && strings.TrimLeft(d, whitespace) != "" {
-			// There were non-whitespace characters inserted.
-			p.framesetOK = false
-		}
-	case StartTagToken:
-		switch p.tok.DataAtom {
-		case a.Html:
-			if p.oe.contains(a.Template) {
-				return true
-			}
-			copyAttributes(p.oe[0], p.tok)
-		case a.Base, a.Basefont, a.Bgsound, a.Command, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Template, a.Title:
-			return inHeadIM(p)
-		case a.Body:
-			if p.oe.contains(a.Template) {
-				return true
-			}
-			if len(p.oe) >= 2 {
-				body := p.oe[1]
-				if body.Type == ElementNode && body.DataAtom == a.Body {
-					p.framesetOK = false
-					copyAttributes(body, p.tok)
-				}
-			}
-		case a.Frameset:
-			if !p.framesetOK || len(p.oe) < 2 || p.oe[1].DataAtom != a.Body {
-				// Ignore the token.
-				return true
-			}
-			body := p.oe[1]
-			if body.Parent != nil {
-				body.Parent.RemoveChild(body)
-			}
-			p.oe = p.oe[:1]
-			p.addElement()
-			p.im = inFramesetIM
-			return true
-		case a.Address, a.Article, a.Aside, a.Blockquote, a.Center, a.Details, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Menu, a.Nav, a.Ol, a.P, a.Section, a.Summary, a.Ul:
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-		case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
-			p.popUntil(buttonScope, a.P)
-			switch n := p.top(); n.DataAtom {
-			case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
-				p.oe.pop()
-			}
-			p.addElement()
-		case a.Pre, a.Listing:
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-			// The newline, if any, will be dealt with by the TextToken case.
-			p.framesetOK = false
-		case a.Form:
-			if p.form != nil && !p.oe.contains(a.Template) {
-				// Ignore the token
-				return true
-			}
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-			if !p.oe.contains(a.Template) {
-				p.form = p.top()
-			}
-		case a.Li:
-			p.framesetOK = false
-			for i := len(p.oe) - 1; i >= 0; i-- {
-				node := p.oe[i]
-				switch node.DataAtom {
-				case a.Li:
-					p.oe = p.oe[:i]
-				case a.Address, a.Div, a.P:
-					continue
-				default:
-					if !isSpecialElement(node) {
-						continue
-					}
-				}
-				break
-			}
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-		case a.Dd, a.Dt:
-			p.framesetOK = false
-			for i := len(p.oe) - 1; i >= 0; i-- {
-				node := p.oe[i]
-				switch node.DataAtom {
-				case a.Dd, a.Dt:
-					p.oe = p.oe[:i]
-				case a.Address, a.Div, a.P:
-					continue
-				default:
-					if !isSpecialElement(node) {
-						continue
-					}
-				}
-				break
-			}
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-		case a.Plaintext:
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-		case a.Button:
-			p.popUntil(defaultScope, a.Button)
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-			p.framesetOK = false
-		case a.A:
-			for i := len(p.afe) - 1; i >= 0 && p.afe[i].Type != scopeMarkerNode; i-- {
-				if n := p.afe[i]; n.Type == ElementNode && n.DataAtom == a.A {
-					p.inBodyEndTagFormatting(a.A)
-					p.oe.remove(n)
-					p.afe.remove(n)
-					break
-				}
-			}
-			p.reconstructActiveFormattingElements()
-			p.addFormattingElement()
-		case a.B, a.Big, a.Code, a.Em, a.Font, a.I, a.S, a.Small, a.Strike, a.Strong, a.Tt, a.U:
-			p.reconstructActiveFormattingElements()
-			p.addFormattingElement()
-		case a.Nobr:
-			p.reconstructActiveFormattingElements()
-			if p.elementInScope(defaultScope, a.Nobr) {
-				p.inBodyEndTagFormatting(a.Nobr)
-				p.reconstructActiveFormattingElements()
-			}
-			p.addFormattingElement()
-		case a.Applet, a.Marquee, a.Object:
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-			p.afe = append(p.afe, &scopeMarker)
-			p.framesetOK = false
-		case a.Table:
-			if !p.quirks {
-				p.popUntil(buttonScope, a.P)
-			}
-			p.addElement()
-			p.framesetOK = false
-			p.im = inTableIM
-			return true
-		case a.Area, a.Br, a.Embed, a.Img, a.Input, a.Keygen, a.Wbr:
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-			p.oe.pop()
-			p.acknowledgeSelfClosingTag()
-			if p.tok.DataAtom == a.Input {
-				for _, t := range p.tok.Attr {
-					if t.Key == "type" {
-						if strings.ToLower(t.Val) == "hidden" {
-							// Skip setting framesetOK = false
-							return true
-						}
-					}
-				}
-			}
-			p.framesetOK = false
-		case a.Param, a.Source, a.Track:
-			p.addElement()
-			p.oe.pop()
-			p.acknowledgeSelfClosingTag()
-		case a.Hr:
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-			p.oe.pop()
-			p.acknowledgeSelfClosingTag()
-			p.framesetOK = false
-		case a.Image:
-			p.tok.DataAtom = a.Img
-			p.tok.Data = a.Img.String()
-			return false
-		case a.Isindex:
-			if p.form != nil {
-				// Ignore the token.
-				return true
-			}
-			action := ""
-			prompt := "This is a searchable index. Enter search keywords: "
-			attr := []Attribute{{Key: "name", Val: "isindex"}}
-			for _, t := range p.tok.Attr {
-				switch t.Key {
-				case "action":
-					action = t.Val
-				case "name":
-					// Ignore the attribute.
-				case "prompt":
-					prompt = t.Val
-				default:
-					attr = append(attr, t)
-				}
-			}
-			p.acknowledgeSelfClosingTag()
-			p.popUntil(buttonScope, a.P)
-			p.parseImpliedToken(StartTagToken, a.Form, a.Form.String())
-			if p.form == nil {
-				// NOTE: The 'isindex' element has been removed,
-				// and the 'template' element has not been designed to be
-				// collaborative with the index element.
-				//
-				// Ignore the token.
-				return true
-			}
-			if action != "" {
-				p.form.Attr = []Attribute{{Key: "action", Val: action}}
-			}
-			p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
-			p.parseImpliedToken(StartTagToken, a.Label, a.Label.String())
-			p.addText(prompt)
-			p.addChild(&Node{
-				Type:     ElementNode,
-				DataAtom: a.Input,
-				Data:     a.Input.String(),
-				Attr:     attr,
-			})
-			p.oe.pop()
-			p.parseImpliedToken(EndTagToken, a.Label, a.Label.String())
-			p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
-			p.parseImpliedToken(EndTagToken, a.Form, a.Form.String())
-		case a.Textarea:
-			p.addElement()
-			p.setOriginalIM()
-			p.framesetOK = false
-			p.im = textIM
-		case a.Xmp:
-			p.popUntil(buttonScope, a.P)
-			p.reconstructActiveFormattingElements()
-			p.framesetOK = false
-			p.addElement()
-			p.setOriginalIM()
-			p.im = textIM
-		case a.Iframe:
-			p.framesetOK = false
-			p.addElement()
-			p.setOriginalIM()
-			p.im = textIM
-		case a.Noembed, a.Noscript:
-			p.addElement()
-			p.setOriginalIM()
-			p.im = textIM
-		case a.Select:
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-			p.framesetOK = false
-			p.im = inSelectIM
-			return true
-		case a.Optgroup, a.Option:
-			if p.top().DataAtom == a.Option {
-				p.oe.pop()
-			}
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-		case a.Rb, a.Rtc:
-			if p.elementInScope(defaultScope, a.Ruby) {
-				p.generateImpliedEndTags()
-			}
-			p.addElement()
-		case a.Rp, a.Rt:
-			if p.elementInScope(defaultScope, a.Ruby) {
-				p.generateImpliedEndTags("rtc")
-			}
-			p.addElement()
-		case a.Math, a.Svg:
-			p.reconstructActiveFormattingElements()
-			if p.tok.DataAtom == a.Math {
-				adjustAttributeNames(p.tok.Attr, mathMLAttributeAdjustments)
-			} else {
-				adjustAttributeNames(p.tok.Attr, svgAttributeAdjustments)
-			}
-			adjustForeignAttributes(p.tok.Attr)
-			p.addElement()
-			p.top().Namespace = p.tok.Data
-			if p.hasSelfClosingToken {
-				p.oe.pop()
-				p.acknowledgeSelfClosingTag()
-			}
-			return true
-		case a.Caption, a.Col, a.Colgroup, a.Frame, a.Head, a.Tbody, a.Td, a.Tfoot, a.Th, a.Thead, a.Tr:
-			// Ignore the token.
-		default:
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-		}
-	case EndTagToken:
-		switch p.tok.DataAtom {
-		case a.Body:
-			if p.elementInScope(defaultScope, a.Body) {
-				p.im = afterBodyIM
-			}
-		case a.Html:
-			if p.elementInScope(defaultScope, a.Body) {
-				p.parseImpliedToken(EndTagToken, a.Body, a.Body.String())
-				return false
-			}
-			return true
-		case a.Address, a.Article, a.Aside, a.Blockquote, a.Button, a.Center, a.Details, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Listing, a.Menu, a.Nav, a.Ol, a.Pre, a.Section, a.Summary, a.Ul:
-			p.popUntil(defaultScope, p.tok.DataAtom)
-		case a.Form:
-			if p.oe.contains(a.Template) {
-				i := p.indexOfElementInScope(defaultScope, a.Form)
-				if i == -1 {
-					// Ignore the token.
-					return true
-				}
-				p.generateImpliedEndTags()
-				if p.oe[i].DataAtom != a.Form {
-					// Ignore the token.
-					return true
-				}
-				p.popUntil(defaultScope, a.Form)
-			} else {
-				node := p.form
-				p.form = nil
-				i := p.indexOfElementInScope(defaultScope, a.Form)
-				if node == nil || i == -1 || p.oe[i] != node {
-					// Ignore the token.
-					return true
-				}
-				p.generateImpliedEndTags()
-				p.oe.remove(node)
-			}
-		case a.P:
-			if !p.elementInScope(buttonScope, a.P) {
-				p.parseImpliedToken(StartTagToken, a.P, a.P.String())
-			}
-			p.popUntil(buttonScope, a.P)
-		case a.Li:
-			p.popUntil(listItemScope, a.Li)
-		case a.Dd, a.Dt:
-			p.popUntil(defaultScope, p.tok.DataAtom)
-		case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
-			p.popUntil(defaultScope, a.H1, a.H2, a.H3, a.H4, a.H5, a.H6)
-		case a.A, a.B, a.Big, a.Code, a.Em, a.Font, a.I, a.Nobr, a.S, a.Small, a.Strike, a.Strong, a.Tt, a.U:
-			p.inBodyEndTagFormatting(p.tok.DataAtom)
-		case a.Applet, a.Marquee, a.Object:
-			if p.popUntil(defaultScope, p.tok.DataAtom) {
-				p.clearActiveFormattingElements()
-			}
-		case a.Br:
-			p.tok.Type = StartTagToken
-			return false
-		case a.Template:
-			return inHeadIM(p)
-		default:
-			p.inBodyEndTagOther(p.tok.DataAtom)
-		}
-	case CommentToken:
-		p.addChild(&Node{
-			Type: CommentNode,
-			Data: p.tok.Data,
-		})
-	case ErrorToken:
-		// TODO: remove this divergence from the HTML5 spec.
-		if len(p.templateStack) > 0 {
-			p.im = inTemplateIM
-			return false
-		} else {
-			for _, e := range p.oe {
-				switch e.DataAtom {
-				case a.Dd, a.Dt, a.Li, a.Optgroup, a.Option, a.P, a.Rb, a.Rp, a.Rt, a.Rtc, a.Tbody, a.Td, a.Tfoot, a.Th,
-					a.Thead, a.Tr, a.Body, a.Html:
-				default:
-					return true
-				}
-			}
-		}
-	}
-
-	return true
-}
-
-func (p *parser) inBodyEndTagFormatting(tagAtom a.Atom) {
-	// This is the "adoption agency" algorithm, described at
-	// https://html.spec.whatwg.org/multipage/syntax.html#adoptionAgency
-
-	// TODO: this is a fairly literal line-by-line translation of that algorithm.
-	// Once the code successfully parses the comprehensive test suite, we should
-	// refactor this code to be more idiomatic.
-
-	// Steps 1-4. The outer loop.
-	for i := 0; i < 8; i++ {
-		// Step 5. Find the formatting element.
-		var formattingElement *Node
-		for j := len(p.afe) - 1; j >= 0; j-- {
-			if p.afe[j].Type == scopeMarkerNode {
-				break
-			}
-			if p.afe[j].DataAtom == tagAtom {
-				formattingElement = p.afe[j]
-				break
-			}
-		}
-		if formattingElement == nil {
-			p.inBodyEndTagOther(tagAtom)
-			return
-		}
-		feIndex := p.oe.index(formattingElement)
-		if feIndex == -1 {
-			p.afe.remove(formattingElement)
-			return
-		}
-		if !p.elementInScope(defaultScope, tagAtom) {
-			// Ignore the tag.
-			return
-		}
-
-		// Steps 9-10. Find the furthest block.
-		var furthestBlock *Node
-		for _, e := range p.oe[feIndex:] {
-			if isSpecialElement(e) {
-				furthestBlock = e
-				break
-			}
-		}
-		if furthestBlock == nil {
-			e := p.oe.pop()
-			for e != formattingElement {
-				e = p.oe.pop()
-			}
-			p.afe.remove(e)
-			return
-		}
-
-		// Steps 11-12. Find the common ancestor and bookmark node.
-		commonAncestor := p.oe[feIndex-1]
-		bookmark := p.afe.index(formattingElement)
-
-		// Step 13. The inner loop. Find the lastNode to reparent.
-		lastNode := furthestBlock
-		node := furthestBlock
-		x := p.oe.index(node)
-		// Steps 13.1-13.2
-		for j := 0; j < 3; j++ {
-			// Step 13.3.
-			x--
-			node = p.oe[x]
-			// Step 13.4 - 13.5.
-			if p.afe.index(node) == -1 {
-				p.oe.remove(node)
-				continue
-			}
-			// Step 13.6.
-			if node == formattingElement {
-				break
-			}
-			// Step 13.7.
-			clone := node.clone()
-			p.afe[p.afe.index(node)] = clone
-			p.oe[p.oe.index(node)] = clone
-			node = clone
-			// Step 13.8.
-			if lastNode == furthestBlock {
-				bookmark = p.afe.index(node) + 1
-			}
-			// Step 13.9.
-			if lastNode.Parent != nil {
-				lastNode.Parent.RemoveChild(lastNode)
-			}
-			node.AppendChild(lastNode)
-			// Step 13.10.
-			lastNode = node
-		}
-
-		// Step 14. Reparent lastNode to the common ancestor,
-		// or for misnested table nodes, to the foster parent.
-		if lastNode.Parent != nil {
-			lastNode.Parent.RemoveChild(lastNode)
-		}
-		switch commonAncestor.DataAtom {
-		case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr:
-			p.fosterParent(lastNode)
-		default:
-			commonAncestor.AppendChild(lastNode)
-		}
-
-		// Steps 15-17. Reparent nodes from the furthest block's children
-		// to a clone of the formatting element.
-		clone := formattingElement.clone()
-		reparentChildren(clone, furthestBlock)
-		furthestBlock.AppendChild(clone)
-
-		// Step 18. Fix up the list of active formatting elements.
-		if oldLoc := p.afe.index(formattingElement); oldLoc != -1 && oldLoc < bookmark {
-			// Move the bookmark with the rest of the list.
-			bookmark--
-		}
-		p.afe.remove(formattingElement)
-		p.afe.insert(bookmark, clone)
-
-		// Step 19. Fix up the stack of open elements.
-		p.oe.remove(formattingElement)
-		p.oe.insert(p.oe.index(furthestBlock)+1, clone)
-	}
-}
-
-// inBodyEndTagOther performs the "any other end tag" algorithm for inBodyIM.
-// "Any other end tag" handling from 12.2.6.5 The rules for parsing tokens in foreign content
-// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inforeign
-func (p *parser) inBodyEndTagOther(tagAtom a.Atom) {
-	for i := len(p.oe) - 1; i >= 0; i-- {
-		if p.oe[i].DataAtom == tagAtom {
-			p.oe = p.oe[:i]
-			break
-		}
-		if isSpecialElement(p.oe[i]) {
-			break
-		}
-	}
-}
-
-// Section 12.2.6.4.8.
-func textIM(p *parser) bool {
-	switch p.tok.Type {
-	case ErrorToken:
-		p.oe.pop()
-	case TextToken:
-		d := p.tok.Data
-		if n := p.oe.top(); n.DataAtom == a.Textarea && n.FirstChild == nil {
-			// Ignore a newline at the start of a