http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/kr/pretty/formatter.go
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/kr/pretty/formatter.go 
b/newt/vendor/github.com/kr/pretty/formatter.go
new file mode 100644
index 0000000..8dacda2
--- /dev/null
+++ b/newt/vendor/github.com/kr/pretty/formatter.go
@@ -0,0 +1,337 @@
+package pretty
+
+import (
+       "fmt"
+       "io"
+       "reflect"
+       "strconv"
+       "text/tabwriter"
+
+       "github.com/kr/text"
+)
+
+const (
+       limit = 50
+)
+
+type formatter struct {
+       x     interface{}
+       force bool
+       quote bool
+}
+
+// Formatter makes a wrapper, f, that will format x as go source with line
+// breaks and tabs. Object f responds to the "%v" formatting verb when both the
+// "#" and " " (space) flags are set, for example:
+//
+//     fmt.Sprintf("%# v", Formatter(x))
+//
+// If one of these two flags is not set, or any other verb is used, f will
+// format x according to the usual rules of package fmt.
+// In particular, if x satisfies fmt.Formatter, then x.Format will be called.
+func Formatter(x interface{}) (f fmt.Formatter) {
+       return formatter{x: x, quote: true}
+}
+
+func (fo formatter) String() string {
+       return fmt.Sprint(fo.x) // unwrap it
+}
+
+func (fo formatter) passThrough(f fmt.State, c rune) {
+       s := "%"
+       for i := 0; i < 128; i++ {
+               if f.Flag(i) {
+                       s += string(i)
+               }
+       }
+       if w, ok := f.Width(); ok {
+               s += fmt.Sprintf("%d", w)
+       }
+       if p, ok := f.Precision(); ok {
+               s += fmt.Sprintf(".%d", p)
+       }
+       s += string(c)
+       fmt.Fprintf(f, s, fo.x)
+}
+
+func (fo formatter) Format(f fmt.State, c rune) {
+       if fo.force || c == 'v' && f.Flag('#') && f.Flag(' ') {
+               w := tabwriter.NewWriter(f, 4, 4, 1, ' ', 0)
+               p := &printer{tw: w, Writer: w, visited: make(map[visit]int)}
+               p.printValue(reflect.ValueOf(fo.x), true, fo.quote)
+               w.Flush()
+               return
+       }
+       fo.passThrough(f, c)
+}
+
+type printer struct {
+       io.Writer
+       tw      *tabwriter.Writer
+       visited map[visit]int
+       depth   int
+}
+
+func (p *printer) indent() *printer {
+       q := *p
+       q.tw = tabwriter.NewWriter(p.Writer, 4, 4, 1, ' ', 0)
+       q.Writer = text.NewIndentWriter(q.tw, []byte{'\t'})
+       return &q
+}
+
+func (p *printer) printInline(v reflect.Value, x interface{}, showType bool) {
+       if showType {
+               io.WriteString(p, v.Type().String())
+               fmt.Fprintf(p, "(%#v)", x)
+       } else {
+               fmt.Fprintf(p, "%#v", x)
+       }
+}
+
+// printValue must keep track of already-printed pointer values to avoid
+// infinite recursion.
+type visit struct {
+       v   uintptr
+       typ reflect.Type
+}
+
+func (p *printer) printValue(v reflect.Value, showType, quote bool) {
+       if p.depth > 10 {
+               io.WriteString(p, "!%v(DEPTH EXCEEDED)")
+               return
+       }
+
+       switch v.Kind() {
+       case reflect.Bool:
+               p.printInline(v, v.Bool(), showType)
+       case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, 
reflect.Int64:
+               p.printInline(v, v.Int(), showType)
+       case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, 
reflect.Uint64, reflect.Uintptr:
+               p.printInline(v, v.Uint(), showType)
+       case reflect.Float32, reflect.Float64:
+               p.printInline(v, v.Float(), showType)
+       case reflect.Complex64, reflect.Complex128:
+               fmt.Fprintf(p, "%#v", v.Complex())
+       case reflect.String:
+               p.fmtString(v.String(), quote)
+       case reflect.Map:
+               t := v.Type()
+               if showType {
+                       io.WriteString(p, t.String())
+               }
+               writeByte(p, '{')
+               if nonzero(v) {
+                       expand := !canInline(v.Type())
+                       pp := p
+                       if expand {
+                               writeByte(p, '\n')
+                               pp = p.indent()
+                       }
+                       keys := v.MapKeys()
+                       for i := 0; i < v.Len(); i++ {
+                               showTypeInStruct := true
+                               k := keys[i]
+                               mv := v.MapIndex(k)
+                               pp.printValue(k, false, true)
+                               writeByte(pp, ':')
+                               if expand {
+                                       writeByte(pp, '\t')
+                               }
+                               showTypeInStruct = t.Elem().Kind() == 
reflect.Interface
+                               pp.printValue(mv, showTypeInStruct, true)
+                               if expand {
+                                       io.WriteString(pp, ",\n")
+                               } else if i < v.Len()-1 {
+                                       io.WriteString(pp, ", ")
+                               }
+                       }
+                       if expand {
+                               pp.tw.Flush()
+                       }
+               }
+               writeByte(p, '}')
+       case reflect.Struct:
+               t := v.Type()
+               if v.CanAddr() {
+                       addr := v.UnsafeAddr()
+                       vis := visit{addr, t}
+                       if vd, ok := p.visited[vis]; ok && vd < p.depth {
+                               p.fmtString(t.String()+"{(CYCLIC REFERENCE)}", 
false)
+                               break // don't print v again
+                       }
+                       p.visited[vis] = p.depth
+               }
+
+               if showType {
+                       io.WriteString(p, t.String())
+               }
+               writeByte(p, '{')
+               if nonzero(v) {
+                       expand := !canInline(v.Type())
+                       pp := p
+                       if expand {
+                               writeByte(p, '\n')
+                               pp = p.indent()
+                       }
+                       for i := 0; i < v.NumField(); i++ {
+                               showTypeInStruct := true
+                               if f := t.Field(i); f.Name != "" {
+                                       io.WriteString(pp, f.Name)
+                                       writeByte(pp, ':')
+                                       if expand {
+                                               writeByte(pp, '\t')
+                                       }
+                                       showTypeInStruct = labelType(f.Type)
+                               }
+                               pp.printValue(getField(v, i), showTypeInStruct, 
true)
+                               if expand {
+                                       io.WriteString(pp, ",\n")
+                               } else if i < v.NumField()-1 {
+                                       io.WriteString(pp, ", ")
+                               }
+                       }
+                       if expand {
+                               pp.tw.Flush()
+                       }
+               }
+               writeByte(p, '}')
+       case reflect.Interface:
+               switch e := v.Elem(); {
+               case e.Kind() == reflect.Invalid:
+                       io.WriteString(p, "nil")
+               case e.IsValid():
+                       pp := *p
+                       pp.depth++
+                       pp.printValue(e, showType, true)
+               default:
+                       io.WriteString(p, v.Type().String())
+                       io.WriteString(p, "(nil)")
+               }
+       case reflect.Array, reflect.Slice:
+               t := v.Type()
+               if showType {
+                       io.WriteString(p, t.String())
+               }
+               if v.Kind() == reflect.Slice && v.IsNil() && showType {
+                       io.WriteString(p, "(nil)")
+                       break
+               }
+               if v.Kind() == reflect.Slice && v.IsNil() {
+                       io.WriteString(p, "nil")
+                       break
+               }
+               writeByte(p, '{')
+               expand := !canInline(v.Type())
+               pp := p
+               if expand {
+                       writeByte(p, '\n')
+                       pp = p.indent()
+               }
+               for i := 0; i < v.Len(); i++ {
+                       showTypeInSlice := t.Elem().Kind() == reflect.Interface
+                       pp.printValue(v.Index(i), showTypeInSlice, true)
+                       if expand {
+                               io.WriteString(pp, ",\n")
+                       } else if i < v.Len()-1 {
+                               io.WriteString(pp, ", ")
+                       }
+               }
+               if expand {
+                       pp.tw.Flush()
+               }
+               writeByte(p, '}')
+       case reflect.Ptr:
+               e := v.Elem()
+               if !e.IsValid() {
+                       writeByte(p, '(')
+                       io.WriteString(p, v.Type().String())
+                       io.WriteString(p, ")(nil)")
+               } else {
+                       pp := *p
+                       pp.depth++
+                       writeByte(pp, '&')
+                       pp.printValue(e, true, true)
+               }
+       case reflect.Chan:
+               x := v.Pointer()
+               if showType {
+                       writeByte(p, '(')
+                       io.WriteString(p, v.Type().String())
+                       fmt.Fprintf(p, ")(%#v)", x)
+               } else {
+                       fmt.Fprintf(p, "%#v", x)
+               }
+       case reflect.Func:
+               io.WriteString(p, v.Type().String())
+               io.WriteString(p, " {...}")
+       case reflect.UnsafePointer:
+               p.printInline(v, v.Pointer(), showType)
+       case reflect.Invalid:
+               io.WriteString(p, "nil")
+       }
+}
+
+func canInline(t reflect.Type) bool {
+       switch t.Kind() {
+       case reflect.Map:
+               return !canExpand(t.Elem())
+       case reflect.Struct:
+               for i := 0; i < t.NumField(); i++ {
+                       if canExpand(t.Field(i).Type) {
+                               return false
+                       }
+               }
+               return true
+       case reflect.Interface:
+               return false
+       case reflect.Array, reflect.Slice:
+               return !canExpand(t.Elem())
+       case reflect.Ptr:
+               return false
+       case reflect.Chan, reflect.Func, reflect.UnsafePointer:
+               return false
+       }
+       return true
+}
+
+func canExpand(t reflect.Type) bool {
+       switch t.Kind() {
+       case reflect.Map, reflect.Struct,
+               reflect.Interface, reflect.Array, reflect.Slice,
+               reflect.Ptr:
+               return true
+       }
+       return false
+}
+
+func labelType(t reflect.Type) bool {
+       switch t.Kind() {
+       case reflect.Interface, reflect.Struct:
+               return true
+       }
+       return false
+}
+
+func (p *printer) fmtString(s string, quote bool) {
+       if quote {
+               s = strconv.Quote(s)
+       }
+       io.WriteString(p, s)
+}
+
+func tryDeepEqual(a, b interface{}) bool {
+       defer func() { recover() }()
+       return reflect.DeepEqual(a, b)
+}
+
+func writeByte(w io.Writer, b byte) {
+       w.Write([]byte{b})
+}
+
+func getField(v reflect.Value, i int) reflect.Value {
+       val := v.Field(i)
+       if val.Kind() == reflect.Interface && !val.IsNil() {
+               val = val.Elem()
+       }
+       return val
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/kr/pretty/pretty.go
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/kr/pretty/pretty.go 
b/newt/vendor/github.com/kr/pretty/pretty.go
new file mode 100644
index 0000000..d3df868
--- /dev/null
+++ b/newt/vendor/github.com/kr/pretty/pretty.go
@@ -0,0 +1,98 @@
+// Package pretty provides pretty-printing for Go values. This is
+// useful during debugging, to avoid wrapping long output lines in
+// the terminal.
+//
+// It provides a function, Formatter, that can be used with any
+// function that accepts a format string. It also provides
+// convenience wrappers for functions in packages fmt and log.
+package pretty
+
+import (
+       "fmt"
+       "io"
+       "log"
+)
+
+// Errorf is a convenience wrapper for fmt.Errorf.
+//
+// Calling Errorf(f, x, y) is equivalent to
+// fmt.Errorf(f, Formatter(x), Formatter(y)).
+func Errorf(format string, a ...interface{}) error {
+       return fmt.Errorf(format, wrap(a, false)...)
+}
+
+// Fprintf is a convenience wrapper for fmt.Fprintf.
+//
+// Calling Fprintf(w, f, x, y) is equivalent to
+// fmt.Fprintf(w, f, Formatter(x), Formatter(y)).
+func Fprintf(w io.Writer, format string, a ...interface{}) (n int, error 
error) {
+       return fmt.Fprintf(w, format, wrap(a, false)...)
+}
+
+// Log is a convenience wrapper for log.Printf.
+//
+// Calling Log(x, y) is equivalent to
+// log.Print(Formatter(x), Formatter(y)), but each operand is
+// formatted with "%# v".
+func Log(a ...interface{}) {
+       log.Print(wrap(a, true)...)
+}
+
+// Logf is a convenience wrapper for log.Printf.
+//
+// Calling Logf(f, x, y) is equivalent to
+// log.Printf(f, Formatter(x), Formatter(y)).
+func Logf(format string, a ...interface{}) {
+       log.Printf(format, wrap(a, false)...)
+}
+
+// Logln is a convenience wrapper for log.Printf.
+//
+// Calling Logln(x, y) is equivalent to
+// log.Println(Formatter(x), Formatter(y)), but each operand is
+// formatted with "%# v".
+func Logln(a ...interface{}) {
+       log.Println(wrap(a, true)...)
+}
+
+// Print pretty-prints its operands and writes to standard output.
+//
+// Calling Print(x, y) is equivalent to
+// fmt.Print(Formatter(x), Formatter(y)), but each operand is
+// formatted with "%# v".
+func Print(a ...interface{}) (n int, errno error) {
+       return fmt.Print(wrap(a, true)...)
+}
+
+// Printf is a convenience wrapper for fmt.Printf.
+//
+// Calling Printf(f, x, y) is equivalent to
+// fmt.Printf(f, Formatter(x), Formatter(y)).
+func Printf(format string, a ...interface{}) (n int, errno error) {
+       return fmt.Printf(format, wrap(a, false)...)
+}
+
+// Println pretty-prints its operands and writes to standard output.
+//
+// Calling Print(x, y) is equivalent to
+// fmt.Println(Formatter(x), Formatter(y)), but each operand is
+// formatted with "%# v".
+func Println(a ...interface{}) (n int, errno error) {
+       return fmt.Println(wrap(a, true)...)
+}
+
+// Sprintf is a convenience wrapper for fmt.Sprintf.
+//
+// Calling Sprintf(f, x, y) is equivalent to
+// fmt.Sprintf(f, Formatter(x), Formatter(y)).
+func Sprintf(format string, a ...interface{}) string {
+       return fmt.Sprintf(format, wrap(a, false)...)
+}
+
+func wrap(a []interface{}, force bool) []interface{} {
+       w := make([]interface{}, len(a))
+       for i, x := range a {
+               w[i] = formatter{x: x, force: force}
+       }
+       return w
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/kr/pretty/zero.go
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/kr/pretty/zero.go 
b/newt/vendor/github.com/kr/pretty/zero.go
new file mode 100644
index 0000000..abb5b6f
--- /dev/null
+++ b/newt/vendor/github.com/kr/pretty/zero.go
@@ -0,0 +1,41 @@
+package pretty
+
+import (
+       "reflect"
+)
+
+func nonzero(v reflect.Value) bool {
+       switch v.Kind() {
+       case reflect.Bool:
+               return v.Bool()
+       case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, 
reflect.Int64:
+               return v.Int() != 0
+       case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, 
reflect.Uint64, reflect.Uintptr:
+               return v.Uint() != 0
+       case reflect.Float32, reflect.Float64:
+               return v.Float() != 0
+       case reflect.Complex64, reflect.Complex128:
+               return v.Complex() != complex(0, 0)
+       case reflect.String:
+               return v.String() != ""
+       case reflect.Struct:
+               for i := 0; i < v.NumField(); i++ {
+                       if nonzero(getField(v, i)) {
+                               return true
+                       }
+               }
+               return false
+       case reflect.Array:
+               for i := 0; i < v.Len(); i++ {
+                       if nonzero(v.Index(i)) {
+                               return true
+                       }
+               }
+               return false
+       case reflect.Map, reflect.Interface, reflect.Slice, reflect.Ptr, 
reflect.Chan, reflect.Func:
+               return !v.IsNil()
+       case reflect.UnsafePointer:
+               return v.Pointer() != 0
+       }
+       return true
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/kr/text/License
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/kr/text/License 
b/newt/vendor/github.com/kr/text/License
new file mode 100644
index 0000000..480a328
--- /dev/null
+++ b/newt/vendor/github.com/kr/text/License
@@ -0,0 +1,19 @@
+Copyright 2012 Keith Rarick
+
+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.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/kr/text/Readme
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/kr/text/Readme 
b/newt/vendor/github.com/kr/text/Readme
new file mode 100644
index 0000000..7e6e7c0
--- /dev/null
+++ b/newt/vendor/github.com/kr/text/Readme
@@ -0,0 +1,3 @@
+This is a Go package for manipulating paragraphs of text.
+
+See http://go.pkgdoc.org/github.com/kr/text for full documentation.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/kr/text/doc.go
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/kr/text/doc.go 
b/newt/vendor/github.com/kr/text/doc.go
new file mode 100644
index 0000000..cf4c198
--- /dev/null
+++ b/newt/vendor/github.com/kr/text/doc.go
@@ -0,0 +1,3 @@
+// Package text provides rudimentary functions for manipulating text in
+// paragraphs.
+package text

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/kr/text/indent.go
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/kr/text/indent.go 
b/newt/vendor/github.com/kr/text/indent.go
new file mode 100644
index 0000000..4ebac45
--- /dev/null
+++ b/newt/vendor/github.com/kr/text/indent.go
@@ -0,0 +1,74 @@
+package text
+
+import (
+       "io"
+)
+
+// Indent inserts prefix at the beginning of each non-empty line of s. The
+// end-of-line marker is NL.
+func Indent(s, prefix string) string {
+       return string(IndentBytes([]byte(s), []byte(prefix)))
+}
+
+// IndentBytes inserts prefix at the beginning of each non-empty line of b.
+// The end-of-line marker is NL.
+func IndentBytes(b, prefix []byte) []byte {
+       var res []byte
+       bol := true
+       for _, c := range b {
+               if bol && c != '\n' {
+                       res = append(res, prefix...)
+               }
+               res = append(res, c)
+               bol = c == '\n'
+       }
+       return res
+}
+
+// Writer indents each line of its input.
+type indentWriter struct {
+       w   io.Writer
+       bol bool
+       pre [][]byte
+       sel int
+       off int
+}
+
+// NewIndentWriter makes a new write filter that indents the input
+// lines. Each line is prefixed in order with the corresponding
+// element of pre. If there are more lines than elements, the last
+// element of pre is repeated for each subsequent line.
+func NewIndentWriter(w io.Writer, pre ...[]byte) io.Writer {
+       return &indentWriter{
+               w:   w,
+               pre: pre,
+               bol: true,
+       }
+}
+
+// The only errors returned are from the underlying indentWriter.
+func (w *indentWriter) Write(p []byte) (n int, err error) {
+       for _, c := range p {
+               if w.bol {
+                       var i int
+                       i, err = w.w.Write(w.pre[w.sel][w.off:])
+                       w.off += i
+                       if err != nil {
+                               return n, err
+                       }
+               }
+               _, err = w.w.Write([]byte{c})
+               if err != nil {
+                       return n, err
+               }
+               n++
+               w.bol = c == '\n'
+               if w.bol {
+                       w.off = 0
+                       if w.sel < len(w.pre)-1 {
+                               w.sel++
+                       }
+               }
+       }
+       return n, nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/kr/text/wrap.go
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/kr/text/wrap.go 
b/newt/vendor/github.com/kr/text/wrap.go
new file mode 100644
index 0000000..b09bb03
--- /dev/null
+++ b/newt/vendor/github.com/kr/text/wrap.go
@@ -0,0 +1,86 @@
+package text
+
+import (
+       "bytes"
+       "math"
+)
+
+var (
+       nl = []byte{'\n'}
+       sp = []byte{' '}
+)
+
+const defaultPenalty = 1e5
+
+// Wrap wraps s into a paragraph of lines of length lim, with minimal
+// raggedness.
+func Wrap(s string, lim int) string {
+       return string(WrapBytes([]byte(s), lim))
+}
+
+// WrapBytes wraps b into a paragraph of lines of length lim, with minimal
+// raggedness.
+func WrapBytes(b []byte, lim int) []byte {
+       words := bytes.Split(bytes.Replace(bytes.TrimSpace(b), nl, sp, -1), sp)
+       var lines [][]byte
+       for _, line := range WrapWords(words, 1, lim, defaultPenalty) {
+               lines = append(lines, bytes.Join(line, sp))
+       }
+       return bytes.Join(lines, nl)
+}
+
+// WrapWords is the low-level line-breaking algorithm, useful if you need more
+// control over the details of the text wrapping process. For most uses, either
+// Wrap or WrapBytes will be sufficient and more convenient.
+//
+// WrapWords splits a list of words into lines with minimal "raggedness",
+// treating each byte as one unit, accounting for spc units between adjacent
+// words on each line, and attempting to limit lines to lim units. Raggedness
+// is the total error over all lines, where error is the square of the
+// difference of the length of the line and lim. Too-long lines (which only
+// happen when a single word is longer than lim units) have pen penalty units
+// added to the error.
+func WrapWords(words [][]byte, spc, lim, pen int) [][][]byte {
+       n := len(words)
+
+       length := make([][]int, n)
+       for i := 0; i < n; i++ {
+               length[i] = make([]int, n)
+               length[i][i] = len(words[i])
+               for j := i + 1; j < n; j++ {
+                       length[i][j] = length[i][j-1] + spc + len(words[j])
+               }
+       }
+
+       nbrk := make([]int, n)
+       cost := make([]int, n)
+       for i := range cost {
+               cost[i] = math.MaxInt32
+       }
+       for i := n - 1; i >= 0; i-- {
+               if length[i][n-1] <= lim || i == n-1 {
+                       cost[i] = 0
+                       nbrk[i] = n
+               } else {
+                       for j := i + 1; j < n; j++ {
+                               d := lim - length[i][j-1]
+                               c := d*d + cost[j]
+                               if length[i][j-1] > lim {
+                                       c += pen // too-long lines get a worse 
penalty
+                               }
+                               if c < cost[i] {
+                                       cost[i] = c
+                                       nbrk[i] = j
+                               }
+                       }
+               }
+       }
+
+       var lines [][][]byte
+       i := 0
+       for i < n {
+               lines = append(lines, words[i:nbrk[i]])
+               i = nbrk[i]
+       }
+       return lines
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/mattn/go-sqlite3/.gitignore
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/mattn/go-sqlite3/.gitignore 
b/newt/vendor/github.com/mattn/go-sqlite3/.gitignore
new file mode 100644
index 0000000..bf90dfd
--- /dev/null
+++ b/newt/vendor/github.com/mattn/go-sqlite3/.gitignore
@@ -0,0 +1,3 @@
+*.db
+*.exe
+*.dll

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/mattn/go-sqlite3/.travis.yml
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/mattn/go-sqlite3/.travis.yml 
b/newt/vendor/github.com/mattn/go-sqlite3/.travis.yml
new file mode 100644
index 0000000..03d626f
--- /dev/null
+++ b/newt/vendor/github.com/mattn/go-sqlite3/.travis.yml
@@ -0,0 +1,8 @@
+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 3qJVUE0iQwqnCbmNcDsjYu1nh4J4KIFXx

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/mattn/go-sqlite3/LICENSE
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/mattn/go-sqlite3/LICENSE 
b/newt/vendor/github.com/mattn/go-sqlite3/LICENSE
new file mode 100644
index 0000000..ca458bb
--- /dev/null
+++ b/newt/vendor/github.com/mattn/go-sqlite3/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 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.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/mattn/go-sqlite3/README.md
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/mattn/go-sqlite3/README.md 
b/newt/vendor/github.com/mattn/go-sqlite3/README.md
new file mode 100644
index 0000000..d69e305
--- /dev/null
+++ b/newt/vendor/github.com/mattn/go-sqlite3/README.md
@@ -0,0 +1,75 @@
+go-sqlite3
+==========
+
+[![Build 
Status](https://travis-ci.org/mattn/go-sqlite3.svg?branch=master)](https://travis-ci.org/mattn/go-sqlite3)
+[![Coverage 
Status](https://coveralls.io/repos/mattn/go-sqlite3/badge.svg?branch=master)](https://coveralls.io/r/mattn/go-sqlite3?branch=master)
+[![GoDoc](https://godoc.org/github.com/mattn/go-sqlite3?status.svg)](http://godoc.org/github.com/mattn/go-sqlite3)
+
+Description
+-----------
+
+sqlite3 driver conforming to the built-in database/sql interface
+
+Installation
+------------
+
+This package can be installed with the go get command:
+
+    go get github.com/mattn/go-sqlite3
+    
+_go-sqlite3_ is *cgo* package.
+If you want to build your app using go-sqlite3, you need gcc.
+However, if you install _go-sqlite3_ with `go install 
github.com/mattn/go-sqlite3`, you don't need gcc to build your app anymore.
+    
+Documentation
+-------------
+
+API documentation can be found here: 
http://godoc.org/github.com/mattn/go-sqlite3
+
+Examples can be found under the `./_example` directory
+
+FAQ
+---
+
+* Want to build go-sqlite3 with libsqlite3 on my linux.
+
+    Use `go build --tags "libsqlite3 linux"`
+
+* Want to build go-sqlite3 with icu extension.
+
+   Use `go build --tags "icu"`
+
+* Can't build go-sqlite3 on windows 64bit.
+
+    > Probably, you are using go 1.0, go1.0 has a problem when it comes to 
compiling/linking on windows 64bit. 
+    > See: https://github.com/mattn/go-sqlite3/issues/27
+
+* Getting insert error while query is opened.
+
+    > You can pass some arguments into the connection string, for example, a 
URI.
+    > See: https://github.com/mattn/go-sqlite3/issues/39
+
+* Do you want to cross compile? mingw on Linux or Mac?
+
+    > See: https://github.com/mattn/go-sqlite3/issues/106
+    > See also: 
http://www.limitlessfx.com/cross-compile-golang-app-for-windows-from-linux.html
+
+* Want to get time.Time with current locale
+
+    Use `loc=auto` in SQLite3 filename schema like `file:foo.db?loc=auto`.
+
+License
+-------
+
+MIT: http://mattn.mit-license.org/2012
+
+sqlite3-binding.c, sqlite3-binding.h, sqlite3ext.h
+
+The -binding suffix was added to avoid build failures under gccgo.
+
+In this repository, those files are an amalgamation of code that was copied 
from SQLite3. The license of that code is the same as the license of SQLite3.
+
+Author
+------
+
+Yasuhiro Matsumoto (a.k.a mattn)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/mattn/go-sqlite3/backup.go
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/mattn/go-sqlite3/backup.go 
b/newt/vendor/github.com/mattn/go-sqlite3/backup.go
new file mode 100644
index 0000000..3807c60
--- /dev/null
+++ b/newt/vendor/github.com/mattn/go-sqlite3/backup.go
@@ -0,0 +1,70 @@
+// Copyright (C) 2014 Yasuhiro Matsumoto <[email protected]>.
+//
+// Use of this source code is governed by an MIT-style
+// license that can be found in the LICENSE file.
+
+package sqlite3
+
+/*
+#include <sqlite3-binding.h>
+#include <stdlib.h>
+*/
+import "C"
+import (
+       "runtime"
+       "unsafe"
+)
+
+type SQLiteBackup struct {
+       b *C.sqlite3_backup
+}
+
+func (c *SQLiteConn) Backup(dest string, conn *SQLiteConn, src string) 
(*SQLiteBackup, error) {
+       destptr := C.CString(dest)
+       defer C.free(unsafe.Pointer(destptr))
+       srcptr := C.CString(src)
+       defer C.free(unsafe.Pointer(srcptr))
+
+       if b := C.sqlite3_backup_init(c.db, destptr, conn.db, srcptr); b != nil 
{
+               bb := &SQLiteBackup{b: b}
+               runtime.SetFinalizer(bb, (*SQLiteBackup).Finish)
+               return bb, nil
+       }
+       return nil, c.lastError()
+}
+
+// Backs up for one step. Calls the underlying `sqlite3_backup_step` function.
+// This function returns a boolean indicating if the backup is done and
+// an error signalling any other error. Done is returned if the underlying C
+// function returns SQLITE_DONE (Code 101)
+func (b *SQLiteBackup) Step(p int) (bool, error) {
+       ret := C.sqlite3_backup_step(b.b, C.int(p))
+       if ret == C.SQLITE_DONE {
+               return true, nil
+       } else if ret != 0 && ret != C.SQLITE_LOCKED && ret != C.SQLITE_BUSY {
+               return false, Error{Code: ErrNo(ret)}
+       }
+       return false, nil
+}
+
+func (b *SQLiteBackup) Remaining() int {
+       return int(C.sqlite3_backup_remaining(b.b))
+}
+
+func (b *SQLiteBackup) PageCount() int {
+       return int(C.sqlite3_backup_pagecount(b.b))
+}
+
+func (b *SQLiteBackup) Finish() error {
+       return b.Close()
+}
+
+func (b *SQLiteBackup) Close() error {
+       ret := C.sqlite3_backup_finish(b.b)
+       if ret != 0 {
+               return Error{Code: ErrNo(ret)}
+       }
+       b.b = nil
+       runtime.SetFinalizer(b, nil)
+       return nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/b002dd0c/newt/vendor/github.com/mattn/go-sqlite3/callback.go
----------------------------------------------------------------------
diff --git a/newt/vendor/github.com/mattn/go-sqlite3/callback.go 
b/newt/vendor/github.com/mattn/go-sqlite3/callback.go
new file mode 100644
index 0000000..e2bf3c6
--- /dev/null
+++ b/newt/vendor/github.com/mattn/go-sqlite3/callback.go
@@ -0,0 +1,336 @@
+// Copyright (C) 2014 Yasuhiro Matsumoto <[email protected]>.
+//
+// Use of this source code is governed by an MIT-style
+// license that can be found in the LICENSE file.
+
+package sqlite3
+
+// You can't export a Go function to C and have definitions in the C
+// preamble in the same file, so we have to have callbackTrampoline in
+// its own file. Because we need a separate file anyway, the support
+// code for SQLite custom functions is in here.
+
+/*
+#include <sqlite3-binding.h>
+#include <stdlib.h>
+
+void _sqlite3_result_text(sqlite3_context* ctx, const char* s);
+void _sqlite3_result_blob(sqlite3_context* ctx, const void* b, int l);
+*/
+import "C"
+
+import (
+       "errors"
+       "fmt"
+       "math"
+       "reflect"
+       "sync"
+       "unsafe"
+)
+
+//export callbackTrampoline
+func callbackTrampoline(ctx *C.sqlite3_context, argc int, argv 
**C.sqlite3_value) {
+       args := (*[(math.MaxInt32 - 1) / 
unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc]
+       fi := lookupHandle(uintptr(C.sqlite3_user_data(ctx))).(*functionInfo)
+       fi.Call(ctx, args)
+}
+
+//export stepTrampoline
+func stepTrampoline(ctx *C.sqlite3_context, argc int, argv **C.sqlite3_value) {
+       args := (*[(math.MaxInt32 - 1) / 
unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc]
+       ai := lookupHandle(uintptr(C.sqlite3_user_data(ctx))).(*aggInfo)
+       ai.Step(ctx, args)
+}
+
+//export doneTrampoline
+func doneTrampoline(ctx *C.sqlite3_context) {
+       handle := uintptr(C.sqlite3_user_data(ctx))
+       ai := lookupHandle(handle).(*aggInfo)
+       ai.Done(ctx)
+}
+
+// Use handles to avoid passing Go pointers to C.
+
+type handleVal struct {
+       db  *SQLiteConn
+       val interface{}
+}
+
+var handleLock sync.Mutex
+var handleVals = make(map[uintptr]handleVal)
+var handleIndex uintptr = 100
+
+func newHandle(db *SQLiteConn, v interface{}) uintptr {
+       handleLock.Lock()
+       defer handleLock.Unlock()
+       i := handleIndex
+       handleIndex++
+       handleVals[i] = handleVal{db, v}
+       return i
+}
+
+func lookupHandle(handle uintptr) interface{} {
+       handleLock.Lock()
+       defer handleLock.Unlock()
+       r, ok := handleVals[handle]
+       if !ok {
+               if handle >= 100 && handle < handleIndex {
+                       panic("deleted handle")
+               } else {
+                       panic("invalid handle")
+               }
+       }
+       return r.val
+}
+
+func deleteHandles(db *SQLiteConn) {
+       handleLock.Lock()
+       defer handleLock.Unlock()
+       for handle, val := range handleVals {
+               if val.db == db {
+                       delete(handleVals, handle)
+               }
+       }
+}
+
+// This is only here so that tests can refer to it.
+type callbackArgRaw C.sqlite3_value
+
+type callbackArgConverter func(*C.sqlite3_value) (reflect.Value, error)
+
+type callbackArgCast struct {
+       f   callbackArgConverter
+       typ reflect.Type
+}
+
+func (c callbackArgCast) Run(v *C.sqlite3_value) (reflect.Value, error) {
+       val, err := c.f(v)
+       if err != nil {
+               return reflect.Value{}, err
+       }
+       if !val.Type().ConvertibleTo(c.typ) {
+               return reflect.Value{}, fmt.Errorf("cannot convert %s to %s", 
val.Type(), c.typ)
+       }
+       return val.Convert(c.typ), nil
+}
+
+func callbackArgInt64(v *C.sqlite3_value) (reflect.Value, error) {
+       if C.sqlite3_value_type(v) != C.SQLITE_INTEGER {
+               return reflect.Value{}, fmt.Errorf("argument must be an 
INTEGER")
+       }
+       return reflect.ValueOf(int64(C.sqlite3_value_int64(v))), nil
+}
+
+func callbackArgBool(v *C.sqlite3_value) (reflect.Value, error) {
+       if C.sqlite3_value_type(v) != C.SQLITE_INTEGER {
+               return reflect.Value{}, fmt.Errorf("argument must be an 
INTEGER")
+       }
+       i := int64(C.sqlite3_value_int64(v))
+       val := false
+       if i != 0 {
+               val = true
+       }
+       return reflect.ValueOf(val), nil
+}
+
+func callbackArgFloat64(v *C.sqlite3_value) (reflect.Value, error) {
+       if C.sqlite3_value_type(v) != C.SQLITE_FLOAT {
+               return reflect.Value{}, fmt.Errorf("argument must be a FLOAT")
+       }
+       return reflect.ValueOf(float64(C.sqlite3_value_double(v))), nil
+}
+
+func callbackArgBytes(v *C.sqlite3_value) (reflect.Value, error) {
+       switch C.sqlite3_value_type(v) {
+       case C.SQLITE_BLOB:
+               l := C.sqlite3_value_bytes(v)
+               p := C.sqlite3_value_blob(v)
+               return reflect.ValueOf(C.GoBytes(p, l)), nil
+       case C.SQLITE_TEXT:
+               l := C.sqlite3_value_bytes(v)
+               c := unsafe.Pointer(C.sqlite3_value_text(v))
+               return reflect.ValueOf(C.GoBytes(c, l)), nil
+       default:
+               return reflect.Value{}, fmt.Errorf("argument must be BLOB or 
TEXT")
+       }
+}
+
+func callbackArgString(v *C.sqlite3_value) (reflect.Value, error) {
+       switch C.sqlite3_value_type(v) {
+       case C.SQLITE_BLOB:
+               l := C.sqlite3_value_bytes(v)
+               p := (*C.char)(C.sqlite3_value_blob(v))
+               return reflect.ValueOf(C.GoStringN(p, l)), nil
+       case C.SQLITE_TEXT:
+               c := (*C.char)(unsafe.Pointer(C.sqlite3_value_text(v)))
+               return reflect.ValueOf(C.GoString(c)), nil
+       default:
+               return reflect.Value{}, fmt.Errorf("argument must be BLOB or 
TEXT")
+       }
+}
+
+func callbackArgGeneric(v *C.sqlite3_value) (reflect.Value, error) {
+       switch C.sqlite3_value_type(v) {
+       case C.SQLITE_INTEGER:
+               return callbackArgInt64(v)
+       case C.SQLITE_FLOAT:
+               return callbackArgFloat64(v)
+       case C.SQLITE_TEXT:
+               return callbackArgString(v)
+       case C.SQLITE_BLOB:
+               return callbackArgBytes(v)
+       case C.SQLITE_NULL:
+               // Interpret NULL as a nil byte slice.
+               var ret []byte
+               return reflect.ValueOf(ret), nil
+       default:
+               panic("unreachable")
+       }
+}
+
+func callbackArg(typ reflect.Type) (callbackArgConverter, error) {
+       switch typ.Kind() {
+       case reflect.Interface:
+               if typ.NumMethod() != 0 {
+                       return nil, errors.New("the only supported interface 
type is interface{}")
+               }
+               return callbackArgGeneric, nil
+       case reflect.Slice:
+               if typ.Elem().Kind() != reflect.Uint8 {
+                       return nil, errors.New("the only supported slice type 
is []byte")
+               }
+               return callbackArgBytes, nil
+       case reflect.String:
+               return callbackArgString, nil
+       case reflect.Bool:
+               return callbackArgBool, nil
+       case reflect.Int64:
+               return callbackArgInt64, nil
+       case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint8, 
reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Int, reflect.Uint:
+               c := callbackArgCast{callbackArgInt64, typ}
+               return c.Run, nil
+       case reflect.Float64:
+               return callbackArgFloat64, nil
+       case reflect.Float32:
+               c := callbackArgCast{callbackArgFloat64, typ}
+               return c.Run, nil
+       default:
+               return nil, fmt.Errorf("don't know how to convert to %s", typ)
+       }
+}
+
+func callbackConvertArgs(argv []*C.sqlite3_value, converters 
[]callbackArgConverter, variadic callbackArgConverter) ([]reflect.Value, error) 
{
+       var args []reflect.Value
+
+       if len(argv) < len(converters) {
+               return nil, fmt.Errorf("function requires at least %d 
arguments", len(converters))
+       }
+
+       for i, arg := range argv[:len(converters)] {
+               v, err := converters[i](arg)
+               if err != nil {
+                       return nil, err
+               }
+               args = append(args, v)
+       }
+
+       if variadic != nil {
+               for _, arg := range argv[len(converters):] {
+                       v, err := variadic(arg)
+                       if err != nil {
+                               return nil, err
+                       }
+                       args = append(args, v)
+               }
+       }
+       return args, nil
+}
+
+type callbackRetConverter func(*C.sqlite3_context, reflect.Value) error
+
+func callbackRetInteger(ctx *C.sqlite3_context, v reflect.Value) error {
+       switch v.Type().Kind() {
+       case reflect.Int64:
+       case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint8, 
reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Int, reflect.Uint:
+               v = v.Convert(reflect.TypeOf(int64(0)))
+       case reflect.Bool:
+               b := v.Interface().(bool)
+               if b {
+                       v = reflect.ValueOf(int64(1))
+               } else {
+                       v = reflect.ValueOf(int64(0))
+               }
+       default:
+               return fmt.Errorf("cannot convert %s to INTEGER", v.Type())
+       }
+
+       C.sqlite3_result_int64(ctx, C.sqlite3_int64(v.Interface().(int64)))
+       return nil
+}
+
+func callbackRetFloat(ctx *C.sqlite3_context, v reflect.Value) error {
+       switch v.Type().Kind() {
+       case reflect.Float64:
+       case reflect.Float32:
+               v = v.Convert(reflect.TypeOf(float64(0)))
+       default:
+               return fmt.Errorf("cannot convert %s to FLOAT", v.Type())
+       }
+
+       C.sqlite3_result_double(ctx, C.double(v.Interface().(float64)))
+       return nil
+}
+
+func callbackRetBlob(ctx *C.sqlite3_context, v reflect.Value) error {
+       if v.Type().Kind() != reflect.Slice || v.Type().Elem().Kind() != 
reflect.Uint8 {
+               return fmt.Errorf("cannot convert %s to BLOB", v.Type())
+       }
+       i := v.Interface()
+       if i == nil || len(i.([]byte)) == 0 {
+               C.sqlite3_result_null(ctx)
+       } else {
+               bs := i.([]byte)
+               C._sqlite3_result_blob(ctx, unsafe.Pointer(&bs[0]), 
C.int(len(bs)))
+       }
+       return nil
+}
+
+func callbackRetText(ctx *C.sqlite3_context, v reflect.Value) error {
+       if v.Type().Kind() != reflect.String {
+               return fmt.Errorf("cannot convert %s to TEXT", v.Type())
+       }
+       C._sqlite3_result_text(ctx, C.CString(v.Interface().(string)))
+       return nil
+}
+
+func callbackRet(typ reflect.Type) (callbackRetConverter, error) {
+       switch typ.Kind() {
+       case reflect.Slice:
+               if typ.Elem().Kind() != reflect.Uint8 {
+                       return nil, errors.New("the only supported slice type 
is []byte")
+               }
+               return callbackRetBlob, nil
+       case reflect.String:
+               return callbackRetText, nil
+       case reflect.Bool, reflect.Int8, reflect.Int16, reflect.Int32, 
reflect.Int64, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, 
reflect.Int, reflect.Uint:
+               return callbackRetInteger, nil
+       case reflect.Float32, reflect.Float64:
+               return callbackRetFloat, nil
+       default:
+               return nil, fmt.Errorf("don't know how to convert to %s", typ)
+       }
+}
+
+func callbackError(ctx *C.sqlite3_context, err error) {
+       cstr := C.CString(err.Error())
+       defer C.free(unsafe.Pointer(cstr))
+       C.sqlite3_result_error(ctx, cstr, -1)
+}
+
+// Test support code. Tests are not allowed to import "C", so we can't
+// declare any functions that use C.sqlite3_value.
+func callbackSyntheticForTests(v reflect.Value, err error) 
callbackArgConverter {
+       return func(*C.sqlite3_value) (reflect.Value, error) {
+               return v, err
+       }
+}


Reply via email to