Skip to content
Permalink
Browse files

Vendor with party

  • Loading branch information...
mjibson committed Jul 15, 2015
1 parent ff44655 commit d53904331fb1593dd3fcf4a07cf023940d6a196f
Showing with 195,376 additions and 30 deletions.
  1. +88 −0 _third_party/code.google.com/p/go-charset/charset/big5.go
  2. +301 −0 _third_party/code.google.com/p/go-charset/charset/charset.go
  3. +279 −0 _third_party/code.google.com/p/go-charset/charset/charset_test.go
  4. +133 −0 _third_party/code.google.com/p/go-charset/charset/codepage.go
  5. +195 −0 _third_party/code.google.com/p/go-charset/charset/cp932.go
  6. +36 −0 _third_party/code.google.com/p/go-charset/charset/example_test.go
  7. +40 −0 _third_party/code.google.com/p/go-charset/charset/file.go
  8. +162 −0 _third_party/code.google.com/p/go-charset/charset/local.go
  9. +110 −0 _third_party/code.google.com/p/go-charset/charset/utf16.go
  10. +51 −0 _third_party/code.google.com/p/go-charset/charset/utf8.go
  11. +18 −0 _third_party/code.google.com/p/go-charset/data/data_big5.dat.go
  12. +18 −0 _third_party/code.google.com/p/go-charset/data/data_charsets.json.go
  13. +18 −0 _third_party/code.google.com/p/go-charset/data/data_cp932.dat.go
  14. +18 −0 _third_party/code.google.com/p/go-charset/data/data_ibm437.cp.go
  15. +18 −0 _third_party/code.google.com/p/go-charset/data/data_ibm850.cp.go
  16. +18 −0 _third_party/code.google.com/p/go-charset/data/data_ibm866.cp.go
  17. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-1.cp.go
  18. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-10.cp.go
  19. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-15.cp.go
  20. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-2.cp.go
  21. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-3.cp.go
  22. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-4.cp.go
  23. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-5.cp.go
  24. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-6.cp.go
  25. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-7.cp.go
  26. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-8.cp.go
  27. +18 −0 _third_party/code.google.com/p/go-charset/data/data_iso-8859-9.cp.go
  28. +18 −0 _third_party/code.google.com/p/go-charset/data/data_jisx0201kana.dat.go
  29. +18 −0 _third_party/code.google.com/p/go-charset/data/data_koi8-r.cp.go
  30. +18 −0 _third_party/code.google.com/p/go-charset/data/data_windows-1250.cp.go
  31. +18 −0 _third_party/code.google.com/p/go-charset/data/data_windows-1251.cp.go
  32. +18 −0 _third_party/code.google.com/p/go-charset/data/data_windows-1252.cp.go
  33. +6 −0 _third_party/code.google.com/p/go-charset/data/doc.go
  34. +97 −0 _third_party/code.google.com/p/go-charset/data/generate.go
  35. +123 −0 _third_party/github.com/MiniProfiler/go/miniprofiler/doc.go
  36. +348 −0 _third_party/github.com/MiniProfiler/go/miniprofiler/miniprofiler.go
  37. +748 −0 _third_party/github.com/MiniProfiler/go/miniprofiler/static.go
  38. +26 −0 _third_party/github.com/MiniProfiler/go/miniprofiler/templates.go
  39. +302 −0 _third_party/github.com/MiniProfiler/go/miniprofiler/types.go
  40. +47 −0 _third_party/github.com/MiniProfiler/go/miniprofiler_gae/doc.go
  41. +129 −0 _third_party/github.com/MiniProfiler/go/miniprofiler_gae/miniprofiler_gae.go
  42. +43 −0 _third_party/github.com/golang/protobuf/proto/Makefile
  43. +2,083 −0 _third_party/github.com/golang/protobuf/proto/all_test.go
  44. +212 −0 _third_party/github.com/golang/protobuf/proto/clone.go
  45. +245 −0 _third_party/github.com/golang/protobuf/proto/clone_test.go
  46. +827 −0 _third_party/github.com/golang/protobuf/proto/decode.go
  47. +1,293 −0 _third_party/github.com/golang/protobuf/proto/encode.go
  48. +256 −0 _third_party/github.com/golang/protobuf/proto/equal.go
  49. +191 −0 _third_party/github.com/golang/protobuf/proto/equal_test.go
  50. +400 −0 _third_party/github.com/golang/protobuf/proto/extensions.go
  51. +292 −0 _third_party/github.com/golang/protobuf/proto/extensions_test.go
  52. +813 −0 _third_party/github.com/golang/protobuf/proto/lib.go
  53. +287 −0 _third_party/github.com/golang/protobuf/proto/message_set.go
  54. +66 −0 _third_party/github.com/golang/protobuf/proto/message_set_test.go
  55. +479 −0 _third_party/github.com/golang/protobuf/proto/pointer_reflect.go
  56. +266 −0 _third_party/github.com/golang/protobuf/proto/pointer_unsafe.go
  57. +742 −0 _third_party/github.com/golang/protobuf/proto/properties.go
  58. +125 −0 _third_party/github.com/golang/protobuf/proto/proto3_test.go
  59. +63 −0 _third_party/github.com/golang/protobuf/proto/size2_test.go
  60. +142 −0 _third_party/github.com/golang/protobuf/proto/size_test.go
  61. +769 −0 _third_party/github.com/golang/protobuf/proto/text.go
  62. +772 −0 _third_party/github.com/golang/protobuf/proto/text_parser.go
  63. +511 −0 _third_party/github.com/golang/protobuf/proto/text_parser_test.go
  64. +441 −0 _third_party/github.com/golang/protobuf/proto/text_test.go
  65. +27 −0 _third_party/github.com/gorilla/context/LICENSE
  66. +7 −0 _third_party/github.com/gorilla/context/README.md
  67. +143 −0 _third_party/github.com/gorilla/context/context.go
  68. +161 −0 _third_party/github.com/gorilla/context/context_test.go
  69. +82 −0 _third_party/github.com/gorilla/context/doc.go
  70. +27 −0 _third_party/github.com/gorilla/mux/LICENSE
  71. +7 −0 _third_party/github.com/gorilla/mux/README.md
  72. +21 −0 _third_party/github.com/gorilla/mux/bench_test.go
  73. +199 −0 _third_party/github.com/gorilla/mux/doc.go
  74. +366 −0 _third_party/github.com/gorilla/mux/mux.go
  75. +1,048 −0 _third_party/github.com/gorilla/mux/mux_test.go
  76. +714 −0 _third_party/github.com/gorilla/mux/old_test.go
  77. +285 −0 _third_party/github.com/gorilla/mux/regexp.go
  78. +571 −0 _third_party/github.com/gorilla/mux/route.go
  79. +5 −0 _third_party/github.com/mjibson/appstats/README.md
  80. +292 −0 _third_party/github.com/mjibson/appstats/appstats.go
  81. +45 −0 _third_party/github.com/mjibson/appstats/bytesize.go
  82. +60 −0 _third_party/github.com/mjibson/appstats/cost.go
  83. +75 −0 _third_party/github.com/mjibson/appstats/doc.go
  84. +69 −0 _third_party/github.com/mjibson/appstats/funcs.go
  85. +356 −0 _third_party/github.com/mjibson/appstats/handler.go
  86. +504 −0 _third_party/github.com/mjibson/appstats/html.go
  87. +15 −0 _third_party/github.com/mjibson/appstats/static.go
  88. +169 −0 _third_party/github.com/mjibson/appstats/types.go
  89. +5 −0 _third_party/github.com/mjibson/goon/README.md
  90. +138 −0 _third_party/github.com/mjibson/goon/doc.go
  91. +850 −0 _third_party/github.com/mjibson/goon/entity.go
  92. +661 −0 _third_party/github.com/mjibson/goon/goon.go
  93. +2,090 −0 _third_party/github.com/mjibson/goon/goon_test.go
  94. +170 −0 _third_party/github.com/mjibson/goon/query.go
  95. +78 −0 _third_party/golang.org/x/net/html/atom/atom.go
  96. +109 −0 _third_party/golang.org/x/net/html/atom/atom_test.go
  97. +648 −0 _third_party/golang.org/x/net/html/atom/gen.go
  98. +713 −0 _third_party/golang.org/x/net/html/atom/table.go
  99. +351 −0 _third_party/golang.org/x/net/html/atom/table_test.go
  100. +244 −0 _third_party/golang.org/x/net/html/charset/charset.go
  101. +236 −0 _third_party/golang.org/x/net/html/charset/charset_test.go
  102. +111 −0 _third_party/golang.org/x/net/html/charset/gen.go
  103. +235 −0 _third_party/golang.org/x/net/html/charset/table.go
  104. +102 −0 _third_party/golang.org/x/net/html/const.go
  105. +106 −0 _third_party/golang.org/x/net/html/doc.go
  106. +156 −0 _third_party/golang.org/x/net/html/doctype.go
  107. +2,253 −0 _third_party/golang.org/x/net/html/entity.go
  108. +29 −0 _third_party/golang.org/x/net/html/entity_test.go
  109. +258 −0 _third_party/golang.org/x/net/html/escape.go
  110. +97 −0 _third_party/golang.org/x/net/html/escape_test.go
  111. +40 −0 _third_party/golang.org/x/net/html/example_test.go
  112. +226 −0 _third_party/golang.org/x/net/html/foreign.go
  113. +193 −0 _third_party/golang.org/x/net/html/node.go
  114. +146 −0 _third_party/golang.org/x/net/html/node_test.go
  115. +2,094 −0 _third_party/golang.org/x/net/html/parse.go
  116. +388 −0 _third_party/golang.org/x/net/html/parse_test.go
  117. +271 −0 _third_party/golang.org/x/net/html/render.go
  118. +156 −0 _third_party/golang.org/x/net/html/render_test.go
  119. +1,219 −0 _third_party/golang.org/x/net/html/token.go
  120. +748 −0 _third_party/golang.org/x/net/html/token_test.go
  121. +110 −0 _third_party/golang.org/x/text/cldr/base.go
  122. +121 −0 _third_party/golang.org/x/text/cldr/cldr.go
  123. +27 −0 _third_party/golang.org/x/text/cldr/cldr_test.go
  124. +359 −0 _third_party/golang.org/x/text/cldr/collate.go
  125. +275 −0 _third_party/golang.org/x/text/cldr/collate_test.go
  126. +186 −0 _third_party/golang.org/x/text/cldr/data_test.go
  127. +169 −0 _third_party/golang.org/x/text/cldr/decode.go
  128. +20 −0 _third_party/golang.org/x/text/cldr/examples_test.go
  129. +400 −0 _third_party/golang.org/x/text/cldr/makexml.go
  130. +602 −0 _third_party/golang.org/x/text/cldr/resolve.go
  131. +368 −0 _third_party/golang.org/x/text/cldr/resolve_test.go
  132. +144 −0 _third_party/golang.org/x/text/cldr/slice.go
  133. +175 −0 _third_party/golang.org/x/text/cldr/slice_test.go
  134. +1,386 −0 _third_party/golang.org/x/text/cldr/xml.go
  135. +209 −0 _third_party/golang.org/x/text/encoding/charmap/charmap.go
  136. +415 −0 _third_party/golang.org/x/text/encoding/charmap/maketables.go
  137. +5,116 −0 _third_party/golang.org/x/text/encoding/charmap/tables.go
  138. +179 −0 _third_party/golang.org/x/text/encoding/encoding.go
  139. +1,036 −0 _third_party/golang.org/x/text/encoding/encoding_test.go
  140. +40 −0 _third_party/golang.org/x/text/encoding/example_test.go
  141. +137 −0 _third_party/golang.org/x/text/encoding/internal/identifier/gen.go
  142. +80 −0 _third_party/golang.org/x/text/encoding/internal/identifier/identifier.go
  143. +1,621 −0 _third_party/golang.org/x/text/encoding/internal/identifier/mib.go
  144. +60 −0 _third_party/golang.org/x/text/encoding/internal/internal.go
  145. +12 −0 _third_party/golang.org/x/text/encoding/japanese/all.go
  146. +210 −0 _third_party/golang.org/x/text/encoding/japanese/eucjp.go
  147. +284 −0 _third_party/golang.org/x/text/encoding/japanese/iso2022jp.go
  148. +161 −0 _third_party/golang.org/x/text/encoding/japanese/maketables.go
  149. +188 −0 _third_party/golang.org/x/text/encoding/japanese/shiftjis.go
  150. +26,971 −0 _third_party/golang.org/x/text/encoding/japanese/tables.go
  151. +177 −0 _third_party/golang.org/x/text/encoding/korean/euckr.go
  152. +143 −0 _third_party/golang.org/x/text/encoding/korean/maketables.go
  153. +34,152 −0 _third_party/golang.org/x/text/encoding/korean/tables.go
  154. +12 −0 _third_party/golang.org/x/text/encoding/simplifiedchinese/all.go
  155. +280 −0 _third_party/golang.org/x/text/encoding/simplifiedchinese/gbk.go
  156. +228 −0 _third_party/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go
  157. +161 −0 _third_party/golang.org/x/text/encoding/simplifiedchinese/maketables.go
  158. +43,999 −0 _third_party/golang.org/x/text/encoding/simplifiedchinese/tables.go
  159. +198 −0 _third_party/golang.org/x/text/encoding/traditionalchinese/big5.go
  160. +140 −0 _third_party/golang.org/x/text/encoding/traditionalchinese/maketables.go
  161. +37,142 −0 _third_party/golang.org/x/text/encoding/traditionalchinese/tables.go
  162. +82 −0 _third_party/golang.org/x/text/encoding/unicode/override.go
  163. +333 −0 _third_party/golang.org/x/text/encoding/unicode/unicode.go
  164. +199 −0 _third_party/golang.org/x/text/internal/gen/gen.go
  165. +37 −0 _third_party/golang.org/x/text/transform/examples_test.go
  166. +616 −0 _third_party/golang.org/x/text/transform/transform.go
  167. +1,082 −0 _third_party/golang.org/x/text/transform/transform_test.go
  168. +2 −2 admin.go
  169. +1 −1 app/app.go
  170. +2 −2 autodiscover.go
  171. +2 −2 charge.go
  172. +2 −2 dev.go
  173. +4 −4 main.go
  174. +1 −1 rss/rss_test.go
  175. +1 −1 sanitizer/sanitize.go
  176. +1 −1 sanitizer/snip.go
  177. +3 −3 tasks.go
  178. +1 −1 types.go
  179. +4 −4 user.go
  180. +6 −6 utils.go
@@ -0,0 +1,88 @@
package charset

import (
"fmt"
"unicode/utf8"
)

func init() {
registerClass("big5", fromBig5, nil)
}

// Big5 consists of 89 fonts of 157 chars each
const (
big5Max = 13973
big5Font = 157
big5Data = "big5.dat"
)

type translateFromBig5 struct {
font int
scratch []byte
big5map []rune
}

func (p *translateFromBig5) Translate(data []byte, eof bool) (int, []byte, error) {
p.scratch = p.scratch[:0]
n := 0
for len(data) > 0 {
c := int(data[0])
data = data[1:]
n++
if p.font == -1 {
// idle state
if c >= 0xa1 {
p.font = c
continue
}
if c == 26 {
c = '\n'
}
continue
}
f := p.font
p.font = -1
r := utf8.RuneError
switch {
case c >= 64 && c <= 126:
c -= 64
case c >= 161 && c <= 254:
c = c - 161 + 63
default:
// bad big5 char
f = 255
}
if f <= 254 {
f -= 161
ix := f*big5Font + c
if ix < len(p.big5map) {
r = p.big5map[ix]
}
if r == -1 {
r = utf8.RuneError
}
}
p.scratch = appendRune(p.scratch, r)
}
return n, p.scratch, nil
}

type big5Key bool

func fromBig5(arg string) (Translator, error) {
big5map, err := cache(big5Key(false), func() (interface{}, error) {
data, err := readFile(big5Data)
if err != nil {
return nil, fmt.Errorf("charset: cannot open big5 data file: %v", err)
}
big5map := []rune(string(data))
if len(big5map) != big5Max {
return nil, fmt.Errorf("charset: corrupt big5 data")
}
return big5map, nil
})
if err != nil {
return nil, err
}
return &translateFromBig5{big5map: big5map.([]rune), font: -1}, nil
}
@@ -0,0 +1,301 @@
// The charset package implements translation between character sets.
// It uses Unicode as the intermediate representation.
// Because it can be large, the character set data is separated
// from the charset package. It can be embedded in the Go
// executable by importing the data package:
//
// import _ "code.google.com/p/go-charset/data"
//
// It can also made available in a data directory (by settting CharsetDir).
package charset

import (
"io"
"strings"
"unicode/utf8"
)

// Charset holds information about a given character set.
type Charset struct {
Name string // Canonical name of character set.
Aliases []string // Known aliases.
Desc string // Description.
NoFrom bool // Not possible to translate from this charset.
NoTo bool // Not possible to translate to this charset.
}

// Translator represents a character set converter.
// The Translate method translates the given data,
// and returns the number of bytes of data consumed,
// a slice containing the converted data (which may be
// overwritten on the next call to Translate), and any
// conversion error. If eof is true, the data represents
// the final bytes of the input.
type Translator interface {
Translate(data []byte, eof bool) (n int, cdata []byte, err error)
}

// A Factory can be used to make character set translators.
type Factory interface {
// TranslatorFrom creates a translator that will translate from the named character
// set to UTF-8.
TranslatorFrom(name string) (Translator, error) // Create a Translator from this character set to.

// TranslatorTo creates a translator that will translate from UTF-8 to the named character set.
TranslatorTo(name string) (Translator, error) // Create a Translator To this character set.

// Names returns all the character set names accessibile through the factory.
Names() []string

// Info returns information on the named character set. It returns nil if the
// factory doesn't recognise the given name.
Info(name string) *Charset
}

var factories = []Factory{localFactory{}}

// Register registers a new Factory which will be consulted when NewReader
// or NewWriter needs a character set translator for a given name.
func Register(factory Factory) {
factories = append(factories, factory)
}

// NewReader returns a new Reader that translates from the named
// character set to UTF-8 as it reads r.
func NewReader(charset string, r io.Reader) (io.Reader, error) {
tr, err := TranslatorFrom(charset)
if err != nil {
return nil, err
}
return NewTranslatingReader(r, tr), nil
}

// NewWriter returns a new WriteCloser writing to w. It converts writes
// of UTF-8 text into writes on w of text in the named character set.
// The Close is necessary to flush any remaining partially translated
// characters to the output.
func NewWriter(charset string, w io.Writer) (io.WriteCloser, error) {
tr, err := TranslatorTo(charset)
if err != nil {
return nil, err
}
return NewTranslatingWriter(w, tr), nil
}

// Info returns information about a character set, or nil
// if the character set is not found.
func Info(name string) *Charset {
for _, f := range factories {
if info := f.Info(name); info != nil {
return info
}
}
return nil
}

// Names returns the canonical names of all supported character sets, in alphabetical order.
func Names() []string {
// TODO eliminate duplicates
var names []string
for _, f := range factories {
names = append(names, f.Names()...)
}
return names
}

// TranslatorFrom returns a translator that will translate from
// the named character set to UTF-8.
func TranslatorFrom(charset string) (Translator, error) {
var err error
var tr Translator
for _, f := range factories {
tr, err = f.TranslatorFrom(charset)
if err == nil {
break
}
}
if tr == nil {
return nil, err
}
return tr, nil
}

// TranslatorTo returns a translator that will translate from UTF-8
// to the named character set.
func TranslatorTo(charset string) (Translator, error) {
var err error
var tr Translator
for _, f := range factories {
tr, err = f.TranslatorTo(charset)
if err == nil {
break
}
}
if tr == nil {
return nil, err
}
return tr, nil
}

func normalizedChar(c rune) rune {
switch {
case c >= 'A' && c <= 'Z':
c = c - 'A' + 'a'
case c == '_':
c = '-'
}
return c
}

// NormalisedName returns s with all Roman capitals
// mapped to lower case, and '_' mapped to '-'
func NormalizedName(s string) string {
return strings.Map(normalizedChar, s)
}

type translatingWriter struct {
w io.Writer
tr Translator
buf []byte // unconsumed data from writer.
}

// NewTranslatingWriter returns a new WriteCloser writing to w.
// It passes the written bytes through the given Translator.
func NewTranslatingWriter(w io.Writer, tr Translator) io.WriteCloser {
return &translatingWriter{w: w, tr: tr}
}

func (w *translatingWriter) Write(data []byte) (rn int, rerr error) {
wdata := data
if len(w.buf) > 0 {
w.buf = append(w.buf, data...)
wdata = w.buf
}
n, cdata, err := w.tr.Translate(wdata, false)
if err != nil {
// TODO
}
if n > 0 {
_, err = w.w.Write(cdata)
if err != nil {
return 0, err
}
}
w.buf = w.buf[:0]
if n < len(wdata) {
w.buf = append(w.buf, wdata[n:]...)
}
return len(data), nil
}

func (p *translatingWriter) Close() error {
for {
n, data, err := p.tr.Translate(p.buf, true)
p.buf = p.buf[n:]
if err != nil {
// TODO
}
// If the Translator produces no data
// at EOF, then assume that it never will.
if len(data) == 0 {
break
}
n, err = p.w.Write(data)
if err != nil {
return err
}
if n < len(data) {
return io.ErrShortWrite
}
if len(p.buf) == 0 {
break
}
}
return nil
}

type translatingReader struct {
r io.Reader
tr Translator
cdata []byte // unconsumed data from converter.
rdata []byte // unconverted data from reader.
err error // final error from reader.
}

// NewTranslatingReader returns a new Reader that
// translates data using the given Translator as it reads r.
func NewTranslatingReader(r io.Reader, tr Translator) io.Reader {
return &translatingReader{r: r, tr: tr}
}

func (r *translatingReader) Read(buf []byte) (int, error) {
for {
if len(r.cdata) > 0 {
n := copy(buf, r.cdata)
r.cdata = r.cdata[n:]
return n, nil
}
if r.err == nil {
r.rdata = ensureCap(r.rdata, len(r.rdata)+len(buf))
n, err := r.r.Read(r.rdata[len(r.rdata):cap(r.rdata)])
// Guard against non-compliant Readers.
if n == 0 && err == nil {
err = io.EOF
}
r.rdata = r.rdata[0 : len(r.rdata)+n]
r.err = err
} else if len(r.rdata) == 0 {
break
}
nc, cdata, cvterr := r.tr.Translate(r.rdata, r.err != nil)
if cvterr != nil {
// TODO
}
r.cdata = cdata

// Ensure that we consume all bytes at eof
// if the converter refuses them.
if nc == 0 && r.err != nil {
nc = len(r.rdata)
}

// Copy unconsumed data to the start of the rdata buffer.
r.rdata = r.rdata[0:copy(r.rdata, r.rdata[nc:])]
}
return 0, r.err
}

// ensureCap returns s with a capacity of at least n bytes.
// If cap(s) < n, then it returns a new copy of s with the
// required capacity.
func ensureCap(s []byte, n int) []byte {
if n <= cap(s) {
return s
}
// logic adapted from appendslice1 in runtime
m := cap(s)
if m == 0 {
m = n
} else {
for {
if m < 1024 {
m += m
} else {
m += m / 4
}
if m >= n {
break
}
}
}
t := make([]byte, len(s), m)
copy(t, s)
return t
}

func appendRune(buf []byte, r rune) []byte {
n := len(buf)
buf = ensureCap(buf, n+utf8.UTFMax)
nu := utf8.EncodeRune(buf[n:n+utf8.UTFMax], r)
return buf[0 : n+nu]
}
Oops, something went wrong.

0 comments on commit d539043

Please sign in to comment.
You can’t perform that action at this time.