You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2015/11/21 01:42:43 UTC
[18/42] incubator-mynewt-newt git commit: Move newt source into a
"newt" subdirectory.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go
new file mode 100644
index 0000000..8261ec6
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go
@@ -0,0 +1,14 @@
+package main
+
+import (
+ curl "github.com/andelf/go-curl"
+)
+
+func main() {
+ easy := curl.EasyInit()
+ defer easy.Cleanup()
+ if easy != nil {
+ easy.Setopt(curl.OPT_URL, "http://www.google.com/")
+ easy.Perform()
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go
new file mode 100644
index 0000000..8976233
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go
@@ -0,0 +1,56 @@
+package curl
+
+import (
+ "log"
+)
+
+const (
+ _DEBUG = 10 * (iota + 1)
+ _INFO
+ _WARN
+ _ERROR
+)
+
+const _DEFAULT_LOG_LEVEL = _WARN
+
+var log_level = _DEFAULT_LOG_LEVEL
+
+// SetLogLevel changes the log level which determines the granularity of the
+// messages that are logged. Available log levels are: "DEBUG", "INFO",
+// "WARN", "ERROR" and "DEFAULT_LOG_LEVEL".
+func SetLogLevel(levelName string) {
+ switch levelName {
+ case "DEBUG":
+ log_level = _DEBUG
+ case "INFO":
+ log_level = _INFO
+ case "WARN":
+ log_level = _WARN
+ case "ERROR":
+ log_level = _ERROR
+ case "DEFAULT_LOG_LEVEL":
+ log_level = _DEFAULT_LOG_LEVEL
+ }
+}
+
+func logf(limitLevel int, format string, args ...interface{}) {
+ if log_level <= limitLevel {
+ log.Printf(format, args...)
+ }
+}
+
+func debugf(format string, args ...interface{}) {
+ logf(_DEBUG, format, args...)
+}
+
+func infof(format string, args ...interface{}) {
+ logf(_INFO, format, args...)
+}
+
+func warnf(format string, args ...interface{}) {
+ logf(_WARN, format, args...)
+}
+
+func errorf(format string, args ...interface{}) {
+ logf(_ERROR, format, args...)
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go
new file mode 100644
index 0000000..387705a
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go
@@ -0,0 +1,64 @@
+
+package curl
+
+import (
+ "testing"
+ "bytes"
+ "log"
+ "os"
+ "fmt"
+ "regexp"
+)
+
+func TestDefaultLogLevel(t *testing.T) {
+ if log_level != _DEFAULT_LOG_LEVEL {t.Error("Test failed, expected DEFAULT_LOG_LEVEL level.")}
+}
+
+func TestSetLogLevel(t *testing.T) {
+ SetLogLevel("DEBUG")
+ defer SetLogLevel("DEFAULT_LOG_LEVEL")
+ if log_level != _DEBUG {t.Error("Test failed, expected DEBUG level.")}
+ SetLogLevel("INFO")
+ if log_level != _INFO {t.Error("Test failed, expected INFO level.")}
+ SetLogLevel("WARN")
+ if log_level != _WARN {t.Error("Test failed, expected WARN level.")}
+ SetLogLevel("ERROR")
+ if log_level != _ERROR {t.Error("Test failed, expected ERROR level.")}
+}
+
+var (
+ testFormat = "test format %s"
+ testArgument = "test string 1"
+ expectedRegexp = regexp.MustCompile(".*" + fmt.Sprintf(testFormat, testArgument) + "\n$")
+)
+
+
+func TestLogf(t *testing.T) {
+ buf := new(bytes.Buffer)
+ log.SetOutput(buf)
+ defer log.SetOutput(os.Stderr)
+ SetLogLevel("DEBUG")
+ defer SetLogLevel("DEFAULT_LOG_LEVEL")
+
+ logf(_DEBUG, testFormat, testArgument)
+ line := buf.String()
+ matched := expectedRegexp.MatchString(line)
+ if !matched {
+ t.Errorf("log output should match %q and is %q.", expectedRegexp, line)
+ }
+}
+
+func TestLogfUsesLogLevel(t *testing.T) {
+ buf := new(bytes.Buffer)
+ log.SetOutput(buf)
+ defer log.SetOutput(os.Stderr)
+ SetLogLevel("WARN")
+ defer SetLogLevel("DEFAULT_LOG_LEVEL")
+
+ logf(_DEBUG, testFormat, testArgument)
+ line := buf.String()
+ expectedLine := ""
+ if line != expectedLine {
+ t.Errorf("log output should match %q and is %q.", expectedLine, line)
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py
new file mode 100644
index 0000000..08047e5
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+
+import re
+
+
+
+opts = []
+codes = []
+infos = []
+pattern = re.compile(r'CINIT\((.*?),\s+(LONG|OBJECTPOINT|FUNCTIONPOINT|OFF_T),\s+(\d+)\)')
+pattern2 = re.compile('^\s+(CURLE_[A-Z_0-9]+),')
+pattern3 = re.compile('^\s+(CURLINFO_[A-Z_0-9]+)\s+=')
+for line in open("./curl/include/curl/curl.h"):
+ match = pattern.findall(line)
+ if match:
+ opts.append(match[0][0])
+ if line.startswith('#define CURLOPT_'):
+ o = line.split()
+ opts.append(o[1][8:]) # strip :(
+
+ match = pattern2.findall(line)
+ if match:
+ codes.append(match[0])
+
+ if line.startswith('#define CURLE_'):
+ c = line.split()
+ codes.append(c[1])
+
+ match = pattern3.findall(line)
+ if match:
+ infos.append(match[0])
+
+ if line.startswith('#define CURLINFO_'):
+ i = line.split()
+ if '0x' not in i[2]: # :(
+ infos.append(i[1])
+
+
+template = """
+// generated by codegen.py
+
+package curl
+/*
+#include <curl/curl.h>
+#include "compat.h"
+*/
+import "C"
+
+// CURLcode
+const (
+{code_part}
+)
+
+// easy.Setopt(flag, ...)
+const (
+{opt_part}
+)
+
+// easy.Getinfo(flag)
+const (
+{info_part}
+)
+
+// generated ends
+"""
+
+code_part = []
+for c in codes:
+ code_part.append("\t{:<25} = C.{}".format(c[4:], c))
+
+code_part = '\n'.join(code_part)
+
+opt_part = []
+for o in opts:
+ opt_part.append("\tOPT_{0:<25} = C.CURLOPT_{0}".format(o))
+
+opt_part = '\n'.join(opt_part)
+
+info_part = []
+for i in infos:
+ info_part.append("\t{:<25} = C.{}".format(i[4:], i))
+
+info_part = '\n'.join(info_part)
+
+
+with open('./const_gen.go', 'w') as fp:
+ fp.write(template.format(**locals()))
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py
new file mode 100644
index 0000000..e7f2860
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py
@@ -0,0 +1,162 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import re
+import os
+
+def version_symbol(ver):
+ os.system("cd ./curl && git checkout {}".format(ver))
+ opts = []
+ codes = []
+ infos = []
+ vers = []
+ pattern = re.compile(r'CINIT\((.*?), (LONG|OBJECTPOINT|FUNCTIONPOINT|OFF_T), (\d+)\)')
+ pattern2 = re.compile('^\s+(CURLE_[A-Z_0-9]+),')
+ pattern3 = re.compile('^\s+(CURLINFO_[A-Z_0-9]+)\s+=')
+ for line in open("./curl/include/curl/curl.h"):
+ match = pattern.findall(line)
+ if match:
+ opts.append("CURLOPT_" + match[0][0])
+ if line.startswith('#define CURLOPT_'):
+ o = line.split()
+ opts.append(o[1])
+
+ match = pattern2.findall(line)
+ if match:
+ codes.append(match[0])
+
+ if line.startswith('#define CURLE_'):
+ c = line.split()
+ codes.append(c[1])
+
+ match = pattern3.findall(line)
+ if match:
+ infos.append(match[0])
+
+ if line.startswith('#define CURLINFO_'):
+ i = line.split()
+ if '0x' not in i[2]: # :(
+ infos.append(i[1])
+
+ if line.startswith('#define CURL_VERSION_'):
+ i = line.split()
+ vers.append(i[1])
+
+ return opts, codes, infos, vers
+
+
+versions = """
+curl-7_10_1
+curl-7_10_2
+curl-7_10_3
+curl-7_10_4
+curl-7_10_5
+curl-7_10_6
+curl-7_10_7
+curl-7_10_8
+curl-7_11_0
+curl-7_11_1
+curl-7_11_2
+curl-7_12_0
+curl-7_12_1
+curl-7_12_2
+curl-7_12_3
+curl-7_13_0
+curl-7_13_1
+curl-7_13_2
+curl-7_14_0
+curl-7_14_1
+curl-7_15_0
+curl-7_15_1
+curl-7_15_2
+curl-7_15_3
+curl-7_15_4
+curl-7_15_5
+curl-7_16_0
+curl-7_16_1
+curl-7_16_2
+curl-7_16_3
+curl-7_16_4
+curl-7_17_0
+curl-7_17_1
+curl-7_18_0
+curl-7_18_1
+curl-7_18_2
+curl-7_19_0
+curl-7_19_1
+curl-7_19_2
+curl-7_19_3
+curl-7_19_4
+curl-7_19_5
+curl-7_19_6
+curl-7_19_7
+curl-7_20_0
+curl-7_20_1
+curl-7_21_0
+curl-7_21_1
+curl-7_21_2
+curl-7_21_3
+curl-7_21_4
+curl-7_21_5
+curl-7_21_6
+curl-7_21_7
+curl-7_22_0
+curl-7_23_0
+curl-7_23_1
+curl-7_24_0
+curl-7_25_0
+curl-7_26_0
+curl-7_27_0
+curl-7_28_0
+curl-7_28_1
+curl-7_29_0
+curl-7_30_0
+curl-7_31_0
+curl-7_32_0
+curl-7_33_0
+curl-7_34_0
+curl-7_35_0
+curl-7_36_0""".split()[::-1]
+
+last = version_symbol("master")
+
+template = """
+/* generated by compatgen.py */
+#include<curl/curl.h>
+
+
+"""
+
+result = [template]
+result_tail = ["/* generated ends */\n"]
+if __name__ == '__main__':
+ for ver in versions:
+ minor, patch = map(int, ver.split("_")[-2:])
+
+ opts, codes, infos, vers = curr = version_symbol(ver)
+
+ for o in last[0]:
+ if o not in opts:
+ result.append("#define {} 0".format(o)) # 0 for nil option
+ for c in last[1]:
+ if c not in codes:
+ result.append("#define {} -1".format(c)) # -1 for error
+ for i in last[2]:
+ if i not in infos:
+ result.append("#define {} 0".format(i)) # 0 for nil
+ for v in last[3]:
+ if v not in vers:
+ result.append("#define {} 0".format(v)) # 0 for nil
+
+ result.append("#if (LIBCURL_VERSION_MINOR == {} && LIBCURL_VERSION_PATCH < {}) || LIBCURL_VERSION_MINOR < {} ".format(minor, patch, minor))
+
+ result_tail.insert(0, "#endif /* 7.{}.{} */".format(minor, patch))
+
+ last = curr
+
+result.append("#error your version is TOOOOOOOO low")
+
+result.extend(result_tail)
+
+with open("./compat.h", 'w') as fp:
+ fp.write('\n'.join(result))
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go
new file mode 100644
index 0000000..814fd6e
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go
@@ -0,0 +1,154 @@
+package curl
+
+/*
+#include <stdlib.h>
+#include <curl/curl.h>
+
+static CURLMcode curl_multi_setopt_long(CURLM *handle, CURLMoption option, long parameter) {
+ return curl_multi_setopt(handle, option, parameter);
+}
+static CURLMcode curl_multi_setopt_pointer(CURLM *handle, CURLMoption option, void *parameter) {
+ return curl_multi_setopt(handle, option, parameter);
+}
+static CURLMcode curl_multi_fdset_pointer(CURLM *handle,
+ void *read_fd_set,
+ void *write_fd_set,
+ void *exc_fd_set,
+ int *max_fd)
+{
+ return curl_multi_fdset(handle, read_fd_set, write_fd_set, exc_fd_set, max_fd);
+}
+static CURLMsg *curl_multi_info_read_pointer(CURLM *handle, int *msgs_in_queue)
+{
+ return curl_multi_info_read(handle, msgs_in_queue);
+}
+*/
+import "C"
+
+import (
+ "unsafe"
+ "syscall"
+)
+
+type CurlMultiError C.CURLMcode
+type CurlMultiMsg C.CURLMSG
+
+func (e CurlMultiError) Error() string {
+ // ret is const char*, no need to free
+ ret := C.curl_multi_strerror(C.CURLMcode(e))
+ return C.GoString(ret)
+}
+
+func newCurlMultiError(errno C.CURLMcode) error {
+ // cannot use C.CURLM_OK here, cause multi.h use a undefined emum num
+ if errno == 0 { // if nothing wrong
+ return nil
+ }
+ return CurlMultiError(errno)
+}
+
+func newCURLMessage(message *C.CURLMsg) (msg *CURLMessage){
+ if message == nil {
+ return nil
+ }
+ msg = new(CURLMessage)
+ msg.Msg = CurlMultiMsg(message.msg)
+ msg.Easy_handle = &CURL{handle: message.easy_handle}
+ msg.Data = message.data
+ return msg
+}
+
+type CURLM struct {
+ handle unsafe.Pointer
+}
+
+type CURLMessage struct {
+ Msg CurlMultiMsg
+ Easy_handle *CURL
+ Data [8]byte
+}
+
+// curl_multi_init - create a multi handle
+func MultiInit() *CURLM {
+ p := C.curl_multi_init()
+ return &CURLM{p}
+}
+
+// curl_multi_cleanup - close down a multi session
+func (mcurl *CURLM) Cleanup() error {
+ p := mcurl.handle
+ return newCurlMultiError(C.curl_multi_cleanup(p))
+}
+
+// curl_multi_perform - reads/writes available data from each easy handle
+func (mcurl *CURLM) Perform() (int, error) {
+ p := mcurl.handle
+ running_handles := C.int(-1)
+ err := newCurlMultiError(C.curl_multi_perform(p, &running_handles))
+ return int(running_handles), err
+}
+
+// curl_multi_add_handle - add an easy handle to a multi session
+func (mcurl *CURLM) AddHandle(easy *CURL) error {
+ mp := mcurl.handle
+ easy_handle := easy.handle
+ return newCurlMultiError(C.curl_multi_add_handle(mp, easy_handle))
+}
+
+// curl_multi_remove_handle - remove an easy handle from a multi session
+func (mcurl *CURLM) RemoveHandle(easy *CURL) error {
+ mp := mcurl.handle
+ easy_handle := easy.handle
+ return newCurlMultiError(C.curl_multi_remove_handle(mp, easy_handle))
+}
+
+func (mcurl *CURLM) Timeout() (int, error) {
+ p := mcurl.handle
+ timeout := C.long(-1)
+ err := newCurlMultiError(C.curl_multi_timeout(p, &timeout))
+ return int(timeout), err
+}
+
+func (mcurl *CURLM) Setopt(opt int, param interface{}) error {
+ p := mcurl.handle
+ if param == nil {
+ return newCurlMultiError(C.curl_multi_setopt_pointer(p, C.CURLMoption(opt), nil))
+ }
+ switch {
+ // currently cannot support these option
+ // case MOPT_SOCKETFUNCTION, MOPT_SOCKETDATA, MOPT_TIMERFUNCTION, MOPT_TIMERDATA:
+ // panic("not supported CURLM.Setopt opt")
+ case opt >= C.CURLOPTTYPE_LONG:
+ val := C.long(0)
+ switch t := param.(type) {
+ case int:
+ val := C.long(t)
+ return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
+ case bool:
+ val = C.long(0)
+ if t {
+ val = C.long(1)
+ }
+ return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
+ }
+ }
+ panic("not supported CURLM.Setopt opt or param")
+ return nil
+}
+
+func (mcurl *CURLM) Fdset(rset, wset, eset *syscall.FdSet) (int, error) {
+ p := mcurl.handle
+ read := unsafe.Pointer(rset)
+ write := unsafe.Pointer(wset)
+ exc := unsafe.Pointer(eset)
+ maxfd := C.int(-1)
+ err := newCurlMultiError(C.curl_multi_fdset_pointer(p, read, write,
+ exc, &maxfd))
+ return int(maxfd), err
+}
+
+func (mcurl *CURLM) Info_read() (*CURLMessage, int) {
+ p := mcurl.handle
+ left := C.int(0)
+ return newCURLMessage(C.curl_multi_info_read_pointer(p, &left)), int(left)
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/andelf/go-curl/share.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/share.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/share.go
new file mode 100644
index 0000000..8d1e16d
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/share.go
@@ -0,0 +1,62 @@
+package curl
+
+/*
+#include <curl/curl.h>
+
+static CURLSHcode curl_share_setopt_long(CURLSH *handle, CURLSHoption option, long parameter) {
+ return curl_share_setopt(handle, option, parameter);
+}
+static CURLSHcode curl_share_setopt_pointer(CURLSH *handle, CURLSHoption option, void *parameter) {
+ return curl_share_setopt(handle, option, parameter);
+}
+*/
+import "C"
+
+import "unsafe"
+
+// implement os.Error interface
+type CurlShareError C.CURLMcode
+
+func (e CurlShareError) Error() string {
+ // ret is const char*, no need to free
+ ret := C.curl_share_strerror(C.CURLSHcode(e))
+ return C.GoString(ret)
+}
+
+func newCurlShareError(errno C.CURLSHcode) error {
+ if errno == 0 { // if nothing wrong
+ return nil
+ }
+ return CurlShareError(errno)
+}
+
+type CURLSH struct {
+ handle unsafe.Pointer
+}
+
+func ShareInit() *CURLSH {
+ p := C.curl_share_init()
+ return &CURLSH{p}
+}
+
+func (shcurl *CURLSH) Cleanup() error {
+ p := shcurl.handle
+ return newCurlShareError(C.curl_share_cleanup(p))
+}
+
+func (shcurl *CURLSH) Setopt(opt int, param interface{}) error {
+ p := shcurl.handle
+ if param == nil {
+ return newCurlShareError(C.curl_share_setopt_pointer(p, C.CURLSHoption(opt), nil))
+ }
+ switch opt {
+ // case SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC, SHOPT_USERDATA:
+ // panic("not supported")
+ case SHOPT_SHARE, SHOPT_UNSHARE:
+ if val, ok := param.(int); ok {
+ return newCurlShareError(C.curl_share_setopt_long(p, C.CURLSHoption(opt), C.long(val)))
+ }
+ }
+ panic("not supported CURLSH.Setopt opt or param")
+ return nil
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/.gitignore
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/.gitignore b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/.gitignore
new file mode 100644
index 0000000..0026861
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/.gitignore
@@ -0,0 +1,22 @@
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
+*.o
+*.a
+*.so
+
+# Folders
+_obj
+_test
+
+# Architecture specific extensions/prefixes
+*.[568vq]
+[568vq].out
+
+*.cgo1.go
+*.cgo2.c
+_cgo_defun.c
+_cgo_gotypes.go
+_cgo_export.*
+
+_testmain.go
+
+*.exe
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/LICENSE
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/LICENSE b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/LICENSE
new file mode 100644
index 0000000..c33dcc7
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/LICENSE
@@ -0,0 +1,354 @@
+Mozilla Public License, version 2.0
+
+1. Definitions
+
+1.1. “Contributor”
+
+ means each individual or legal entity that creates, contributes to the
+ creation of, or owns Covered Software.
+
+1.2. “Contributor Version”
+
+ means the combination of the Contributions of others (if any) used by a
+ Contributor and that particular Contributor’s Contribution.
+
+1.3. “Contribution”
+
+ means Covered Software of a particular Contributor.
+
+1.4. “Covered Software”
+
+ means Source Code Form to which the initial Contributor has attached the
+ notice in Exhibit A, the Executable Form of such Source Code Form, and
+ Modifications of such Source Code Form, in each case including portions
+ thereof.
+
+1.5. “Incompatible With Secondary Licenses”
+ means
+
+ a. that the initial Contributor has attached the notice described in
+ Exhibit B to the Covered Software; or
+
+ b. that the Covered Software was made available under the terms of version
+ 1.1 or earlier of the License, but not also under the terms of a
+ Secondary License.
+
+1.6. “Executable Form”
+
+ means any form of the work other than Source Code Form.
+
+1.7. “Larger Work”
+
+ means a work that combines Covered Software with other material, in a separate
+ file or files, that is not Covered Software.
+
+1.8. “License”
+
+ means this document.
+
+1.9. “Licensable”
+
+ means having the right to grant, to the maximum extent possible, whether at the
+ time of the initial grant or subsequently, any and all of the rights conveyed by
+ this License.
+
+1.10. “Modifications”
+
+ means any of the following:
+
+ a. any file in Source Code Form that results from an addition to, deletion
+ from, or modification of the contents of Covered Software; or
+
+ b. any new file in Source Code Form that contains any Covered Software.
+
+1.11. “Patent Claims” of a Contributor
+
+ means any patent claim(s), including without limitation, method, process,
+ and apparatus claims, in any patent Licensable by such Contributor that
+ would be infringed, but for the grant of the License, by the making,
+ using, selling, offering for sale, having made, import, or transfer of
+ either its Contributions or its Contributor Version.
+
+1.12. “Secondary License”
+
+ means either the GNU General Public License, Version 2.0, the GNU Lesser
+ General Public License, Version 2.1, the GNU Affero General Public
+ License, Version 3.0, or any later versions of those licenses.
+
+1.13. “Source Code Form”
+
+ means the form of the work preferred for making modifications.
+
+1.14. “You” (or “Your”)
+
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, “You” includes any entity that controls, is
+ controlled by, or is under common control with You. For purposes of this
+ definition, “control” means (a) the power, direct or indirect, to cause
+ the direction or management of such entity, whether by contract or
+ otherwise, or (b) ownership of more than fifty percent (50%) of the
+ outstanding shares or beneficial ownership of such entity.
+
+
+2. License Grants and Conditions
+
+2.1. Grants
+
+ Each Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ a. under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or as
+ part of a Larger Work; and
+
+ b. under Patent Claims of such Contributor to make, use, sell, offer for
+ sale, have made, import, and otherwise transfer either its Contributions
+ or its Contributor Version.
+
+2.2. Effective Date
+
+ The licenses granted in Section 2.1 with respect to any Contribution become
+ effective for each Contribution on the date the Contributor first distributes
+ such Contribution.
+
+2.3. Limitations on Grant Scope
+
+ The licenses granted in this Section 2 are the only rights granted under this
+ License. No additional rights or licenses will be implied from the distribution
+ or licensing of Covered Software under this License. Notwithstanding Section
+ 2.1(b) above, no patent license is granted by a Contributor:
+
+ a. for any code that a Contributor has removed from Covered Software; or
+
+ b. for infringements caused by: (i) Your and any other third party’s
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+ c. under Patent Claims infringed by Covered Software in the absence of its
+ Contributions.
+
+ This License does not grant any rights in the trademarks, service marks, or
+ logos of any Contributor (except as may be necessary to comply with the
+ notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+ No Contributor makes additional grants as a result of Your choice to
+ distribute the Covered Software under a subsequent version of this License
+ (see Section 10.2) or under the terms of a Secondary License (if permitted
+ under the terms of Section 3.3).
+
+2.5. Representation
+
+ Each Contributor represents that the Contributor believes its Contributions
+ are its original creation(s) or it has sufficient rights to grant the
+ rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+ This License is not intended to limit any rights You have under applicable
+ copyright doctrines of fair use, fair dealing, or other equivalents.
+
+2.7. Conditions
+
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
+ Section 2.1.
+
+
+3. Responsibilities
+
+3.1. Distribution of Source Form
+
+ All distribution of Covered Software in Source Code Form, including any
+ Modifications that You create or to which You contribute, must be under the
+ terms of this License. You must inform recipients that the Source Code Form
+ of the Covered Software is governed by the terms of this License, and how
+ they can obtain a copy of this License. You may not attempt to alter or
+ restrict the recipients’ rights in the Source Code Form.
+
+3.2. Distribution of Executable Form
+
+ If You distribute Covered Software in Executable Form then:
+
+ a. such Covered Software must also be made available in Source Code Form,
+ as described in Section 3.1, and You must inform recipients of the
+ Executable Form how they can obtain a copy of such Source Code Form by
+ reasonable means in a timely manner, at a charge no more than the cost
+ of distribution to the recipient; and
+
+ b. You may distribute such Executable Form under the terms of this License,
+ or sublicense it under different terms, provided that the license for
+ the Executable Form does not attempt to limit or alter the recipients’
+ rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+ You may create and distribute a Larger Work under terms of Your choice,
+ provided that You also comply with the requirements of this License for the
+ Covered Software. If the Larger Work is a combination of Covered Software
+ with a work governed by one or more Secondary Licenses, and the Covered
+ Software is not Incompatible With Secondary Licenses, this License permits
+ You to additionally distribute such Covered Software under the terms of
+ such Secondary License(s), so that the recipient of the Larger Work may, at
+ their option, further distribute the Covered Software under the terms of
+ either this License or such Secondary License(s).
+
+3.4. Notices
+
+ You may not remove or alter the substance of any license notices (including
+ copyright notices, patent notices, disclaimers of warranty, or limitations
+ of liability) contained within the Source Code Form of the Covered
+ Software, except that You may alter any license notices to the extent
+ required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+ You may choose to offer, and to charge a fee for, warranty, support,
+ indemnity or liability obligations to one or more recipients of Covered
+ Software. However, You may do so only on Your own behalf, and not on behalf
+ of any Contributor. You must make it absolutely clear that any such
+ warranty, support, indemnity, or liability obligation is offered by You
+ alone, and You hereby agree to indemnify every Contributor for any
+ liability incurred by such Contributor as a result of warranty, support,
+ indemnity or liability terms You offer. You may include additional
+ disclaimers of warranty and limitations of liability specific to any
+ jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+
+ If it is impossible for You to comply with any of the terms of this License
+ with respect to some or all of the Covered Software due to statute, judicial
+ order, or regulation then You must: (a) comply with the terms of this License
+ to the maximum extent possible; and (b) describe the limitations and the code
+ they affect. Such description must be placed in a text file included with all
+ distributions of the Covered Software under this License. Except to the
+ extent prohibited by statute or regulation, such description must be
+ sufficiently detailed for a recipient of ordinary skill to be able to
+ understand it.
+
+5. Termination
+
+5.1. The rights granted under this License will terminate automatically if You
+ fail to comply with any of its terms. However, if You become compliant,
+ then the rights granted under this License from a particular Contributor
+ are reinstated (a) provisionally, unless and until such Contributor
+ explicitly and finally terminates Your grants, and (b) on an ongoing basis,
+ if such Contributor fails to notify You of the non-compliance by some
+ reasonable means prior to 60 days after You have come back into compliance.
+ Moreover, Your grants from a particular Contributor are reinstated on an
+ ongoing basis if such Contributor notifies You of the non-compliance by
+ some reasonable means, this is the first time You have received notice of
+ non-compliance with this License from such Contributor, and You become
+ compliant prior to 30 days after Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+ infringement claim (excluding declaratory judgment actions, counter-claims,
+ and cross-claims) alleging that a Contributor Version directly or
+ indirectly infringes any patent, then the rights granted to You by any and
+ all Contributors for the Covered Software under Section 2.1 of this License
+ shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
+ license agreements (excluding distributors and resellers) which have been
+ validly granted by You or Your distributors under this License prior to
+ termination shall survive termination.
+
+6. Disclaimer of Warranty
+
+ Covered Software is provided under this License on an “as is” basis, without
+ warranty of any kind, either expressed, implied, or statutory, including,
+ without limitation, warranties that the Covered Software is free of defects,
+ merchantable, fit for a particular purpose or non-infringing. The entire
+ risk as to the quality and performance of the Covered Software is with You.
+ Should any Covered Software prove defective in any respect, You (not any
+ Contributor) assume the cost of any necessary servicing, repair, or
+ correction. This disclaimer of warranty constitutes an essential part of this
+ License. No use of any Covered Software is authorized under this License
+ except under this disclaimer.
+
+7. Limitation of Liability
+
+ Under no circumstances and under no legal theory, whether tort (including
+ negligence), contract, or otherwise, shall any Contributor, or anyone who
+ distributes Covered Software as permitted above, be liable to You for any
+ direct, indirect, special, incidental, or consequential damages of any
+ character including, without limitation, damages for lost profits, loss of
+ goodwill, work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses, even if such party shall have been
+ informed of the possibility of such damages. This limitation of liability
+ shall not apply to liability for death or personal injury resulting from such
+ party’s negligence to the extent applicable law prohibits such limitation.
+ Some jurisdictions do not allow the exclusion or limitation of incidental or
+ consequential damages, so this exclusion and limitation may not apply to You.
+
+8. Litigation
+
+ Any litigation relating to this License may be brought only in the courts of
+ a jurisdiction where the defendant maintains its principal place of business
+ and such litigation shall be governed by laws of that jurisdiction, without
+ reference to its conflict-of-law provisions. Nothing in this Section shall
+ prevent a party’s ability to bring cross-claims or counter-claims.
+
+9. Miscellaneous
+
+ This License represents the complete agreement concerning the subject matter
+ hereof. If any provision of this License is held to be unenforceable, such
+ provision shall be reformed only to the extent necessary to make it
+ enforceable. Any law or regulation which provides that the language of a
+ contract shall be construed against the drafter shall not be used to construe
+ this License against a Contributor.
+
+
+10. Versions of the License
+
+10.1. New Versions
+
+ Mozilla Foundation is the license steward. Except as provided in Section
+ 10.3, no one other than the license steward has the right to modify or
+ publish new versions of this License. Each version will be given a
+ distinguishing version number.
+
+10.2. Effect of New Versions
+
+ You may distribute the Covered Software under the terms of the version of
+ the License under which You originally received the Covered Software, or
+ under the terms of any subsequent version published by the license
+ steward.
+
+10.3. Modified Versions
+
+ If you create software not governed by this License, and you want to
+ create a new license for such software, you may create and use a modified
+ version of this License if you rename the license and remove any
+ references to the name of the license steward (except to note that such
+ modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
+ If You choose to distribute Source Code Form that is Incompatible With
+ Secondary Licenses under the terms of this version of the License, the
+ notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+
+ This Source Code Form is subject to the
+ terms of the Mozilla Public License, v.
+ 2.0. If a copy of the MPL was not
+ distributed with this file, You can
+ obtain one at
+ http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular file, then
+You may include the notice in a location (such as a LICENSE file in a relevant
+directory) where a recipient would be likely to look for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - “Incompatible With Secondary Licenses” Notice
+
+ This Source Code Form is “Incompatible
+ With Secondary Licenses”, as defined by
+ the Mozilla Public License, v. 2.0.
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/README.md
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/README.md b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/README.md
new file mode 100644
index 0000000..49490ea
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/README.md
@@ -0,0 +1,36 @@
+# logutils
+
+logutils is a Go package that augments the standard library "log" package
+to make logging a bit more modern, without fragmenting the Go ecosystem
+with new logging packages.
+
+## The simplest thing that could possibly work
+
+Presumably your application already uses the default `log` package. To switch, you'll want your code to look like the following:
+
+```go
+package main
+
+import (
+ "log"
+ "os"
+
+ "github.com/hashicorp/logutils"
+)
+
+func main() {
+ filter := &logutils.LevelFilter{
+ Levels: []logutils.LogLevel{"DEBUG", "WARN", "ERROR"},
+ MinLevel: logutils.LogLevel("WARN"),
+ Writer: os.Stderr,
+ }
+ log.SetOutput(filter)
+
+ log.Print("[DEBUG] Debugging") // this will not print
+ log.Print("[WARN] Warning") // this will
+ log.Print("[ERROR] Erring") // and so will this
+ log.Print("Message I haven't updated") // and so will this
+}
+```
+
+This logs to standard error exactly like go's standard logger. Any log messages you haven't converted to have a level will continue to print as before.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level.go b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level.go
new file mode 100644
index 0000000..6381bf1
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level.go
@@ -0,0 +1,81 @@
+// Package logutils augments the standard log package with levels.
+package logutils
+
+import (
+ "bytes"
+ "io"
+ "sync"
+)
+
+type LogLevel string
+
+// LevelFilter is an io.Writer that can be used with a logger that
+// will filter out log messages that aren't at least a certain level.
+//
+// Once the filter is in use somewhere, it is not safe to modify
+// the structure.
+type LevelFilter struct {
+ // Levels is the list of log levels, in increasing order of
+ // severity. Example might be: {"DEBUG", "WARN", "ERROR"}.
+ Levels []LogLevel
+
+ // MinLevel is the minimum level allowed through
+ MinLevel LogLevel
+
+ // The underlying io.Writer where log messages that pass the filter
+ // will be set.
+ Writer io.Writer
+
+ badLevels map[LogLevel]struct{}
+ once sync.Once
+}
+
+// Check will check a given line if it would be included in the level
+// filter.
+func (f *LevelFilter) Check(line []byte) bool {
+ f.once.Do(f.init)
+
+ // Check for a log level
+ var level LogLevel
+ x := bytes.IndexByte(line, '[')
+ if x >= 0 {
+ y := bytes.IndexByte(line[x:], ']')
+ if y >= 0 {
+ level = LogLevel(line[x+1 : x+y])
+ }
+ }
+
+ _, ok := f.badLevels[level]
+ return !ok
+}
+
+func (f *LevelFilter) Write(p []byte) (n int, err error) {
+ // Note in general that io.Writer can receive any byte sequence
+ // to write, but the "log" package always guarantees that we only
+ // get a single line. We use that as a slight optimization within
+ // this method, assuming we're dealing with a single, complete line
+ // of log data.
+
+ if !f.Check(p) {
+ return len(p), nil
+ }
+
+ return f.Writer.Write(p)
+}
+
+// SetMinLevel is used to update the minimum log level
+func (f *LevelFilter) SetMinLevel(min LogLevel) {
+ f.MinLevel = min
+ f.init()
+}
+
+func (f *LevelFilter) init() {
+ badLevels := make(map[LogLevel]struct{})
+ for _, level := range f.Levels {
+ if level == f.MinLevel {
+ break
+ }
+ badLevels[level] = struct{}{}
+ }
+ f.badLevels = badLevels
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level_benchmark_test.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level_benchmark_test.go b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level_benchmark_test.go
new file mode 100644
index 0000000..3c2caf7
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level_benchmark_test.go
@@ -0,0 +1,37 @@
+package logutils
+
+import (
+ "io/ioutil"
+ "testing"
+)
+
+var messages [][]byte
+
+func init() {
+ messages = [][]byte{
+ []byte("[TRACE] foo"),
+ []byte("[DEBUG] foo"),
+ []byte("[INFO] foo"),
+ []byte("[WARN] foo"),
+ []byte("[ERROR] foo"),
+ }
+}
+
+func BenchmarkDiscard(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ ioutil.Discard.Write(messages[i%len(messages)])
+ }
+}
+
+func BenchmarkLevelFilter(b *testing.B) {
+ filter := &LevelFilter{
+ Levels: []LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"},
+ MinLevel: "WARN",
+ Writer: ioutil.Discard,
+ }
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ filter.Write(messages[i%len(messages)])
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level_test.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level_test.go b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level_test.go
new file mode 100644
index 0000000..f6b6ac3
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/hashicorp/logutils/level_test.go
@@ -0,0 +1,94 @@
+package logutils
+
+import (
+ "bytes"
+ "io"
+ "log"
+ "testing"
+)
+
+func TestLevelFilter_impl(t *testing.T) {
+ var _ io.Writer = new(LevelFilter)
+}
+
+func TestLevelFilter(t *testing.T) {
+ buf := new(bytes.Buffer)
+ filter := &LevelFilter{
+ Levels: []LogLevel{"DEBUG", "WARN", "ERROR"},
+ MinLevel: "WARN",
+ Writer: buf,
+ }
+
+ logger := log.New(filter, "", 0)
+ logger.Print("[WARN] foo")
+ logger.Println("[ERROR] bar")
+ logger.Println("[DEBUG] baz")
+ logger.Println("[WARN] buzz")
+
+ result := buf.String()
+ expected := "[WARN] foo\n[ERROR] bar\n[WARN] buzz\n"
+ if result != expected {
+ t.Fatalf("bad: %#v", result)
+ }
+}
+
+func TestLevelFilterCheck(t *testing.T) {
+ filter := &LevelFilter{
+ Levels: []LogLevel{"DEBUG", "WARN", "ERROR"},
+ MinLevel: "WARN",
+ Writer: nil,
+ }
+
+ testCases := []struct {
+ line string
+ check bool
+ }{
+ {"[WARN] foo\n", true},
+ {"[ERROR] bar\n", true},
+ {"[DEBUG] baz\n", false},
+ {"[WARN] buzz\n", true},
+ }
+
+ for _, testCase := range testCases {
+ result := filter.Check([]byte(testCase.line))
+ if result != testCase.check {
+ t.Errorf("Fail: %s", testCase.line)
+ }
+ }
+}
+
+func TestLevelFilter_SetMinLevel(t *testing.T) {
+ filter := &LevelFilter{
+ Levels: []LogLevel{"DEBUG", "WARN", "ERROR"},
+ MinLevel: "ERROR",
+ Writer: nil,
+ }
+
+ testCases := []struct {
+ line string
+ checkBefore bool
+ checkAfter bool
+ }{
+ {"[WARN] foo\n", false, true},
+ {"[ERROR] bar\n", true, true},
+ {"[DEBUG] baz\n", false, false},
+ {"[WARN] buzz\n", false, true},
+ }
+
+ for _, testCase := range testCases {
+ result := filter.Check([]byte(testCase.line))
+ if result != testCase.checkBefore {
+ t.Errorf("Fail: %s", testCase.line)
+ }
+ }
+
+ // Update the minimum level to WARN
+ filter.SetMinLevel("WARN")
+
+ for _, testCase := range testCases {
+ result := filter.Check([]byte(testCase.line))
+ if result != testCase.checkAfter {
+ t.Errorf("Fail: %s", testCase.line)
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/LICENSE
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/LICENSE b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/LICENSE
new file mode 100644
index 0000000..5f0d1fb
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2014 Alan Shreve
+
+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.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/README.md
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/README.md b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/README.md
new file mode 100644
index 0000000..7a950d1
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/README.md
@@ -0,0 +1,23 @@
+# mousetrap
+
+mousetrap is a tiny library that answers a single question.
+
+On a Windows machine, was the process invoked by someone double clicking on
+the executable file while browsing in explorer?
+
+### Motivation
+
+Windows developers unfamiliar with command line tools will often "double-click"
+the executable for a tool. Because most CLI tools print the help and then exit
+when invoked without arguments, this is often very frustrating for those users.
+
+mousetrap provides a way to detect these invocations so that you can provide
+more helpful behavior and instructions on how to run the CLI tool. To see what
+this looks like, both from an organizational and a technical perspective, see
+https://inconshreveable.com/09-09-2014/sweat-the-small-stuff/
+
+### The interface
+
+The library exposes a single interface:
+
+ func StartedByExplorer() (bool)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_others.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_others.go b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_others.go
new file mode 100644
index 0000000..9d2d8a4
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_others.go
@@ -0,0 +1,15 @@
+// +build !windows
+
+package mousetrap
+
+// StartedByExplorer returns true if the program was invoked by the user
+// double-clicking on the executable from explorer.exe
+//
+// It is conservative and returns false if any of the internal calls fail.
+// It does not guarantee that the program was run from a terminal. It only can tell you
+// whether it was launched from explorer.exe
+//
+// On non-Windows platforms, it always returns false.
+func StartedByExplorer() bool {
+ return false
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows.go b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows.go
new file mode 100644
index 0000000..336142a
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows.go
@@ -0,0 +1,98 @@
+// +build windows
+// +build !go1.4
+
+package mousetrap
+
+import (
+ "fmt"
+ "os"
+ "syscall"
+ "unsafe"
+)
+
+const (
+ // defined by the Win32 API
+ th32cs_snapprocess uintptr = 0x2
+)
+
+var (
+ kernel = syscall.MustLoadDLL("kernel32.dll")
+ CreateToolhelp32Snapshot = kernel.MustFindProc("CreateToolhelp32Snapshot")
+ Process32First = kernel.MustFindProc("Process32FirstW")
+ Process32Next = kernel.MustFindProc("Process32NextW")
+)
+
+// ProcessEntry32 structure defined by the Win32 API
+type processEntry32 struct {
+ dwSize uint32
+ cntUsage uint32
+ th32ProcessID uint32
+ th32DefaultHeapID int
+ th32ModuleID uint32
+ cntThreads uint32
+ th32ParentProcessID uint32
+ pcPriClassBase int32
+ dwFlags uint32
+ szExeFile [syscall.MAX_PATH]uint16
+}
+
+func getProcessEntry(pid int) (pe *processEntry32, err error) {
+ snapshot, _, e1 := CreateToolhelp32Snapshot.Call(th32cs_snapprocess, uintptr(0))
+ if snapshot == uintptr(syscall.InvalidHandle) {
+ err = fmt.Errorf("CreateToolhelp32Snapshot: %v", e1)
+ return
+ }
+ defer syscall.CloseHandle(syscall.Handle(snapshot))
+
+ var processEntry processEntry32
+ processEntry.dwSize = uint32(unsafe.Sizeof(processEntry))
+ ok, _, e1 := Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))
+ if ok == 0 {
+ err = fmt.Errorf("Process32First: %v", e1)
+ return
+ }
+
+ for {
+ if processEntry.th32ProcessID == uint32(pid) {
+ pe = &processEntry
+ return
+ }
+
+ ok, _, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))
+ if ok == 0 {
+ err = fmt.Errorf("Process32Next: %v", e1)
+ return
+ }
+ }
+}
+
+func getppid() (pid int, err error) {
+ pe, err := getProcessEntry(os.Getpid())
+ if err != nil {
+ return
+ }
+
+ pid = int(pe.th32ParentProcessID)
+ return
+}
+
+// StartedByExplorer returns true if the program was invoked by the user double-clicking
+// on the executable from explorer.exe
+//
+// It is conservative and returns false if any of the internal calls fail.
+// It does not guarantee that the program was run from a terminal. It only can tell you
+// whether it was launched from explorer.exe
+func StartedByExplorer() bool {
+ ppid, err := getppid()
+ if err != nil {
+ return false
+ }
+
+ pe, err := getProcessEntry(ppid)
+ if err != nil {
+ return false
+ }
+
+ name := syscall.UTF16ToString(pe.szExeFile[:])
+ return name == "explorer.exe"
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows_1.4.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows_1.4.go b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows_1.4.go
new file mode 100644
index 0000000..9a28e57
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows_1.4.go
@@ -0,0 +1,46 @@
+// +build windows
+// +build go1.4
+
+package mousetrap
+
+import (
+ "os"
+ "syscall"
+ "unsafe"
+)
+
+func getProcessEntry(pid int) (*syscall.ProcessEntry32, error) {
+ snapshot, err := syscall.CreateToolhelp32Snapshot(syscall.TH32CS_SNAPPROCESS, 0)
+ if err != nil {
+ return nil, err
+ }
+ defer syscall.CloseHandle(snapshot)
+ var procEntry syscall.ProcessEntry32
+ procEntry.Size = uint32(unsafe.Sizeof(procEntry))
+ if err = syscall.Process32First(snapshot, &procEntry); err != nil {
+ return nil, err
+ }
+ for {
+ if procEntry.ProcessID == uint32(pid) {
+ return &procEntry, nil
+ }
+ err = syscall.Process32Next(snapshot, &procEntry)
+ if err != nil {
+ return nil, err
+ }
+ }
+}
+
+// StartedByExplorer returns true if the program was invoked by the user double-clicking
+// on the executable from explorer.exe
+//
+// It is conservative and returns false if any of the internal calls fail.
+// It does not guarantee that the program was run from a terminal. It only can tell you
+// whether it was launched from explorer.exe
+func StartedByExplorer() bool {
+ pe, err := getProcessEntry(os.Getppid())
+ if err != nil {
+ return false
+ }
+ return "explorer.exe" == syscall.UTF16ToString(pe.ExeFile[:])
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/.gitignore
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/.gitignore b/newt/Godeps/_workspace/src/github.com/kr/pretty/.gitignore
new file mode 100644
index 0000000..1f0a99f
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/pretty/.gitignore
@@ -0,0 +1,4 @@
+[568].out
+_go*
+_test*
+_obj
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/License
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/License b/newt/Godeps/_workspace/src/github.com/kr/pretty/License
new file mode 100644
index 0000000..05c783c
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/pretty/License
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+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/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/Readme
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/Readme b/newt/Godeps/_workspace/src/github.com/kr/pretty/Readme
new file mode 100644
index 0000000..c589fc6
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/pretty/Readme
@@ -0,0 +1,9 @@
+package pretty
+
+ import "github.com/kr/pretty"
+
+ Package pretty provides pretty-printing for Go values.
+
+Documentation
+
+ http://godoc.org/github.com/kr/pretty
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/diff.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/diff.go b/newt/Godeps/_workspace/src/github.com/kr/pretty/diff.go
new file mode 100644
index 0000000..8fe8e24
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/pretty/diff.go
@@ -0,0 +1,158 @@
+package pretty
+
+import (
+ "fmt"
+ "io"
+ "reflect"
+)
+
+type sbuf []string
+
+func (s *sbuf) Write(b []byte) (int, error) {
+ *s = append(*s, string(b))
+ return len(b), nil
+}
+
+// Diff returns a slice where each element describes
+// a difference between a and b.
+func Diff(a, b interface{}) (desc []string) {
+ Fdiff((*sbuf)(&desc), a, b)
+ return desc
+}
+
+// Fdiff writes to w a description of the differences between a and b.
+func Fdiff(w io.Writer, a, b interface{}) {
+ diffWriter{w: w}.diff(reflect.ValueOf(a), reflect.ValueOf(b))
+}
+
+type diffWriter struct {
+ w io.Writer
+ l string // label
+}
+
+func (w diffWriter) printf(f string, a ...interface{}) {
+ var l string
+ if w.l != "" {
+ l = w.l + ": "
+ }
+ fmt.Fprintf(w.w, l+f, a...)
+}
+
+func (w diffWriter) diff(av, bv reflect.Value) {
+ if !av.IsValid() && bv.IsValid() {
+ w.printf("nil != %#v", bv.Interface())
+ return
+ }
+ if av.IsValid() && !bv.IsValid() {
+ w.printf("%#v != nil", av.Interface())
+ return
+ }
+ if !av.IsValid() && !bv.IsValid() {
+ return
+ }
+
+ at := av.Type()
+ bt := bv.Type()
+ if at != bt {
+ w.printf("%v != %v", at, bt)
+ return
+ }
+
+ // numeric types, including bool
+ if at.Kind() < reflect.Array {
+ a, b := av.Interface(), bv.Interface()
+ if a != b {
+ w.printf("%#v != %#v", a, b)
+ }
+ return
+ }
+
+ switch at.Kind() {
+ case reflect.String:
+ a, b := av.Interface(), bv.Interface()
+ if a != b {
+ w.printf("%q != %q", a, b)
+ }
+ case reflect.Ptr:
+ switch {
+ case av.IsNil() && !bv.IsNil():
+ w.printf("nil != %v", bv.Interface())
+ case !av.IsNil() && bv.IsNil():
+ w.printf("%v != nil", av.Interface())
+ case !av.IsNil() && !bv.IsNil():
+ w.diff(av.Elem(), bv.Elem())
+ }
+ case reflect.Struct:
+ for i := 0; i < av.NumField(); i++ {
+ w.relabel(at.Field(i).Name).diff(av.Field(i), bv.Field(i))
+ }
+ case reflect.Slice:
+ lenA := av.Len()
+ lenB := bv.Len()
+ if lenA != lenB {
+ w.printf("%s[%d] != %s[%d]", av.Type(), lenA, bv.Type(), lenB)
+ break
+ }
+ for i := 0; i < lenA; i++ {
+ w.relabel(fmt.Sprintf("[%d]", i)).diff(av.Index(i), bv.Index(i))
+ }
+ case reflect.Map:
+ ak, both, bk := keyDiff(av.MapKeys(), bv.MapKeys())
+ for _, k := range ak {
+ w := w.relabel(fmt.Sprintf("[%#v]", k.Interface()))
+ w.printf("%q != (missing)", av.MapIndex(k))
+ }
+ for _, k := range both {
+ w := w.relabel(fmt.Sprintf("[%#v]", k.Interface()))
+ w.diff(av.MapIndex(k), bv.MapIndex(k))
+ }
+ for _, k := range bk {
+ w := w.relabel(fmt.Sprintf("[%#v]", k.Interface()))
+ w.printf("(missing) != %q", bv.MapIndex(k))
+ }
+ case reflect.Interface:
+ w.diff(reflect.ValueOf(av.Interface()), reflect.ValueOf(bv.Interface()))
+ default:
+ if !reflect.DeepEqual(av.Interface(), bv.Interface()) {
+ w.printf("%# v != %# v", Formatter(av.Interface()), Formatter(bv.Interface()))
+ }
+ }
+}
+
+func (d diffWriter) relabel(name string) (d1 diffWriter) {
+ d1 = d
+ if d.l != "" && name[0] != '[' {
+ d1.l += "."
+ }
+ d1.l += name
+ return d1
+}
+
+func keyDiff(a, b []reflect.Value) (ak, both, bk []reflect.Value) {
+ for _, av := range a {
+ inBoth := false
+ for _, bv := range b {
+ if reflect.DeepEqual(av.Interface(), bv.Interface()) {
+ inBoth = true
+ both = append(both, av)
+ break
+ }
+ }
+ if !inBoth {
+ ak = append(ak, av)
+ }
+ }
+ for _, bv := range b {
+ inBoth := false
+ for _, av := range a {
+ if reflect.DeepEqual(av.Interface(), bv.Interface()) {
+ inBoth = true
+ break
+ }
+ }
+ if !inBoth {
+ bk = append(bk, bv)
+ }
+ }
+ return
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/diff_test.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/diff_test.go b/newt/Godeps/_workspace/src/github.com/kr/pretty/diff_test.go
new file mode 100644
index 0000000..3c388f1
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/pretty/diff_test.go
@@ -0,0 +1,74 @@
+package pretty
+
+import (
+ "testing"
+)
+
+type difftest struct {
+ a interface{}
+ b interface{}
+ exp []string
+}
+
+type S struct {
+ A int
+ S *S
+ I interface{}
+ C []int
+}
+
+var diffs = []difftest{
+ {a: nil, b: nil},
+ {a: S{A: 1}, b: S{A: 1}},
+
+ {0, "", []string{`int != string`}},
+ {0, 1, []string{`0 != 1`}},
+ {S{}, new(S), []string{`pretty.S != *pretty.S`}},
+ {"a", "b", []string{`"a" != "b"`}},
+ {S{}, S{A: 1}, []string{`A: 0 != 1`}},
+ {new(S), &S{A: 1}, []string{`A: 0 != 1`}},
+ {S{S: new(S)}, S{S: &S{A: 1}}, []string{`S.A: 0 != 1`}},
+ {S{}, S{I: 0}, []string{`I: nil != 0`}},
+ {S{I: 1}, S{I: "x"}, []string{`I: int != string`}},
+ {S{}, S{C: []int{1}}, []string{`C: []int[0] != []int[1]`}},
+ {S{C: []int{}}, S{C: []int{1}}, []string{`C: []int[0] != []int[1]`}},
+ {S{C: []int{1, 2, 3}}, S{C: []int{1, 2, 4}}, []string{`C[2]: 3 != 4`}},
+ {S{}, S{A: 1, S: new(S)}, []string{`A: 0 != 1`, `S: nil != &{0 <nil> <nil> []}`}},
+}
+
+func TestDiff(t *testing.T) {
+ for _, tt := range diffs {
+ got := Diff(tt.a, tt.b)
+ eq := len(got) == len(tt.exp)
+ if eq {
+ for i := range got {
+ eq = eq && got[i] == tt.exp[i]
+ }
+ }
+ if !eq {
+ t.Errorf("diffing % #v", tt.a)
+ t.Errorf("with % #v", tt.b)
+ diffdiff(t, got, tt.exp)
+ continue
+ }
+ }
+}
+
+func diffdiff(t *testing.T, got, exp []string) {
+ minus(t, "unexpected:", got, exp)
+ minus(t, "missing:", exp, got)
+}
+
+func minus(t *testing.T, s string, a, b []string) {
+ var i, j int
+ for i = 0; i < len(a); i++ {
+ for j = 0; j < len(b); j++ {
+ if a[i] == b[j] {
+ break
+ }
+ }
+ if j == len(b) {
+ t.Error(s, a[i])
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/example_test.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/example_test.go b/newt/Godeps/_workspace/src/github.com/kr/pretty/example_test.go
new file mode 100644
index 0000000..ecf40f3
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/pretty/example_test.go
@@ -0,0 +1,20 @@
+package pretty_test
+
+import (
+ "fmt"
+ "github.com/kr/pretty"
+)
+
+func Example() {
+ type myType struct {
+ a, b int
+ }
+ var x = []myType{{1, 2}, {3, 4}, {5, 6}}
+ fmt.Printf("%# v", pretty.Formatter(x))
+ // output:
+ // []pretty_test.myType{
+ // {a:1, b:2},
+ // {a:3, b:4},
+ // {a:5, b:6},
+ // }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/formatter.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/formatter.go b/newt/Godeps/_workspace/src/github.com/kr/pretty/formatter.go
new file mode 100644
index 0000000..8dacda2
--- /dev/null
+++ b/newt/Godeps/_workspace/src/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/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/formatter_test.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/formatter_test.go b/newt/Godeps/_workspace/src/github.com/kr/pretty/formatter_test.go
new file mode 100644
index 0000000..5f3204e
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/pretty/formatter_test.go
@@ -0,0 +1,261 @@
+package pretty
+
+import (
+ "fmt"
+ "io"
+ "strings"
+ "testing"
+ "unsafe"
+)
+
+type test struct {
+ v interface{}
+ s string
+}
+
+type LongStructTypeName struct {
+ longFieldName interface{}
+ otherLongFieldName interface{}
+}
+
+type SA struct {
+ t *T
+ v T
+}
+
+type T struct {
+ x, y int
+}
+
+type F int
+
+func (f F) Format(s fmt.State, c rune) {
+ fmt.Fprintf(s, "F(%d)", int(f))
+}
+
+var long = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+
+var gosyntax = []test{
+ {nil, `nil`},
+ {"", `""`},
+ {"a", `"a"`},
+ {1, "int(1)"},
+ {1.0, "float64(1)"},
+ {[]int(nil), "[]int(nil)"},
+ {[0]int{}, "[0]int{}"},
+ {complex(1, 0), "(1+0i)"},
+ //{make(chan int), "(chan int)(0x1234)"},
+ {unsafe.Pointer(uintptr(unsafe.Pointer(&long))), fmt.Sprintf("unsafe.Pointer(0x%02x)", uintptr(unsafe.Pointer(&long)))},
+ {func(int) {}, "func(int) {...}"},
+ {map[int]int{1: 1}, "map[int]int{1:1}"},
+ {int32(1), "int32(1)"},
+ {io.EOF, `&errors.errorString{s:"EOF"}`},
+ {[]string{"a"}, `[]string{"a"}`},
+ {
+ []string{long},
+ `[]string{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"}`,
+ },
+ {F(5), "pretty.F(5)"},
+ {
+ SA{&T{1, 2}, T{3, 4}},
+ `pretty.SA{
+ t: &pretty.T{x:1, y:2},
+ v: pretty.T{x:3, y:4},
+}`,
+ },
+ {
+ map[int][]byte{1: {}},
+ `map[int][]uint8{
+ 1: {},
+}`,
+ },
+ {
+ map[int]T{1: {}},
+ `map[int]pretty.T{
+ 1: {},
+}`,
+ },
+ {
+ long,
+ `"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"`,
+ },
+ {
+ LongStructTypeName{
+ longFieldName: LongStructTypeName{},
+ otherLongFieldName: long,
+ },
+ `pretty.LongStructTypeName{
+ longFieldName: pretty.LongStructTypeName{},
+ otherLongFieldName: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+}`,
+ },
+ {
+ &LongStructTypeName{
+ longFieldName: &LongStructTypeName{},
+ otherLongFieldName: (*LongStructTypeName)(nil),
+ },
+ `&pretty.LongStructTypeName{
+ longFieldName: &pretty.LongStructTypeName{},
+ otherLongFieldName: (*pretty.LongStructTypeName)(nil),
+}`,
+ },
+ {
+ []LongStructTypeName{
+ {nil, nil},
+ {3, 3},
+ {long, nil},
+ },
+ `[]pretty.LongStructTypeName{
+ {},
+ {
+ longFieldName: int(3),
+ otherLongFieldName: int(3),
+ },
+ {
+ longFieldName: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+ otherLongFieldName: nil,
+ },
+}`,
+ },
+ {
+ []interface{}{
+ LongStructTypeName{nil, nil},
+ []byte{1, 2, 3},
+ T{3, 4},
+ LongStructTypeName{long, nil},
+ },
+ `[]interface {}{
+ pretty.LongStructTypeName{},
+ []uint8{0x1, 0x2, 0x3},
+ pretty.T{x:3, y:4},
+ pretty.LongStructTypeName{
+ longFieldName: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+ otherLongFieldName: nil,
+ },
+}`,
+ },
+}
+
+func TestGoSyntax(t *testing.T) {
+ for _, tt := range gosyntax {
+ s := fmt.Sprintf("%# v", Formatter(tt.v))
+ if tt.s != s {
+ t.Errorf("expected %q", tt.s)
+ t.Errorf("got %q", s)
+ t.Errorf("expraw\n%s", tt.s)
+ t.Errorf("gotraw\n%s", s)
+ }
+ }
+}
+
+type I struct {
+ i int
+ R interface{}
+}
+
+func (i *I) I() *I { return i.R.(*I) }
+
+func TestCycle(t *testing.T) {
+ type A struct{ *A }
+ v := &A{}
+ v.A = v
+
+ // panics from stack overflow without cycle detection
+ t.Logf("Example cycle:\n%# v", Formatter(v))
+
+ p := &A{}
+ s := fmt.Sprintf("%# v", Formatter([]*A{p, p}))
+ if strings.Contains(s, "CYCLIC") {
+ t.Errorf("Repeated address detected as cyclic reference:\n%s", s)
+ }
+
+ type R struct {
+ i int
+ *R
+ }
+ r := &R{
+ i: 1,
+ R: &R{
+ i: 2,
+ R: &R{
+ i: 3,
+ },
+ },
+ }
+ r.R.R.R = r
+ t.Logf("Example longer cycle:\n%# v", Formatter(r))
+
+ r = &R{
+ i: 1,
+ R: &R{
+ i: 2,
+ R: &R{
+ i: 3,
+ R: &R{
+ i: 4,
+ R: &R{
+ i: 5,
+ R: &R{
+ i: 6,
+ R: &R{
+ i: 7,
+ R: &R{
+ i: 8,
+ R: &R{
+ i: 9,
+ R: &R{
+ i: 10,
+ R: &R{
+ i: 11,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+ // here be pirates
+ r.R.R.R.R.R.R.R.R.R.R.R = r
+ t.Logf("Example very long cycle:\n%# v", Formatter(r))
+
+ i := &I{
+ i: 1,
+ R: &I{
+ i: 2,
+ R: &I{
+ i: 3,
+ R: &I{
+ i: 4,
+ R: &I{
+ i: 5,
+ R: &I{
+ i: 6,
+ R: &I{
+ i: 7,
+ R: &I{
+ i: 8,
+ R: &I{
+ i: 9,
+ R: &I{
+ i: 10,
+ R: &I{
+ i: 11,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+ iv := i.I().I().I().I().I().I().I().I().I().I()
+ *iv = *i
+ t.Logf("Example long interface cycle:\n%# v", Formatter(i))
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/pretty.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/pretty.go b/newt/Godeps/_workspace/src/github.com/kr/pretty/pretty.go
new file mode 100644
index 0000000..d3df868
--- /dev/null
+++ b/newt/Godeps/_workspace/src/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/e95057f4/newt/Godeps/_workspace/src/github.com/kr/pretty/zero.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/pretty/zero.go b/newt/Godeps/_workspace/src/github.com/kr/pretty/zero.go
new file mode 100644
index 0000000..abb5b6f
--- /dev/null
+++ b/newt/Godeps/_workspace/src/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/e95057f4/newt/Godeps/_workspace/src/github.com/kr/text/License
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/text/License b/newt/Godeps/_workspace/src/github.com/kr/text/License
new file mode 100644
index 0000000..480a328
--- /dev/null
+++ b/newt/Godeps/_workspace/src/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/e95057f4/newt/Godeps/_workspace/src/github.com/kr/text/Readme
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/text/Readme b/newt/Godeps/_workspace/src/github.com/kr/text/Readme
new file mode 100644
index 0000000..7e6e7c0
--- /dev/null
+++ b/newt/Godeps/_workspace/src/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/e95057f4/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/Readme
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/Readme b/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/Readme
new file mode 100644
index 0000000..1c1f4e6
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/Readme
@@ -0,0 +1,5 @@
+Package colwriter provides a write filter that formats
+input lines in multiple columns.
+
+The package is a straightforward translation from
+/src/cmd/draw/mc.c in Plan 9 from User Space.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/column.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/column.go b/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/column.go
new file mode 100644
index 0000000..7302ce9
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/column.go
@@ -0,0 +1,147 @@
+// Package colwriter provides a write filter that formats
+// input lines in multiple columns.
+//
+// The package is a straightforward translation from
+// /src/cmd/draw/mc.c in Plan 9 from User Space.
+package colwriter
+
+import (
+ "bytes"
+ "io"
+ "unicode/utf8"
+)
+
+const (
+ tab = 4
+)
+
+const (
+ // Print each input line ending in a colon ':' separately.
+ BreakOnColon uint = 1 << iota
+)
+
+// A Writer is a filter that arranges input lines in as many columns as will
+// fit in its width. Tab '\t' chars in the input are translated to sequences
+// of spaces ending at multiples of 4 positions.
+//
+// If BreakOnColon is set, each input line ending in a colon ':' is written
+// separately.
+//
+// The Writer assumes that all Unicode code points have the same width; this
+// may not be true in some fonts.
+type Writer struct {
+ w io.Writer
+ buf []byte
+ width int
+ flag uint
+}
+
+// NewWriter allocates and initializes a new Writer writing to w.
+// Parameter width controls the total number of characters on each line
+// across all columns.
+func NewWriter(w io.Writer, width int, flag uint) *Writer {
+ return &Writer{
+ w: w,
+ width: width,
+ flag: flag,
+ }
+}
+
+// Write writes p to the writer w. The only errors returned are ones
+// encountered while writing to the underlying output stream.
+func (w *Writer) Write(p []byte) (n int, err error) {
+ var linelen int
+ var lastWasColon bool
+ for i, c := range p {
+ w.buf = append(w.buf, c)
+ linelen++
+ if c == '\t' {
+ w.buf[len(w.buf)-1] = ' '
+ for linelen%tab != 0 {
+ w.buf = append(w.buf, ' ')
+ linelen++
+ }
+ }
+ if w.flag&BreakOnColon != 0 && c == ':' {
+ lastWasColon = true
+ } else if lastWasColon {
+ if c == '\n' {
+ pos := bytes.LastIndex(w.buf[:len(w.buf)-1], []byte{'\n'})
+ if pos < 0 {
+ pos = 0
+ }
+ line := w.buf[pos:]
+ w.buf = w.buf[:pos]
+ if err = w.columnate(); err != nil {
+ if len(line) < i {
+ return i - len(line), err
+ }
+ return 0, err
+ }
+ if n, err := w.w.Write(line); err != nil {
+ if r := len(line) - n; r < i {
+ return i - r, err
+ }
+ return 0, err
+ }
+ }
+ lastWasColon = false
+ }
+ if c == '\n' {
+ linelen = 0
+ }
+ }
+ return len(p), nil
+}
+
+// Flush should be called after the last call to Write to ensure that any data
+// buffered in the Writer is written to output.
+func (w *Writer) Flush() error {
+ return w.columnate()
+}
+
+func (w *Writer) columnate() error {
+ words := bytes.Split(w.buf, []byte{'\n'})
+ w.buf = nil
+ if len(words[len(words)-1]) == 0 {
+ words = words[:len(words)-1]
+ }
+ maxwidth := 0
+ for _, wd := range words {
+ if n := utf8.RuneCount(wd); n > maxwidth {
+ maxwidth = n
+ }
+ }
+ maxwidth++ // space char
+ wordsPerLine := w.width / maxwidth
+ if wordsPerLine <= 0 {
+ wordsPerLine = 1
+ }
+ nlines := (len(words) + wordsPerLine - 1) / wordsPerLine
+ for i := 0; i < nlines; i++ {
+ col := 0
+ endcol := 0
+ for j := i; j < len(words); j += nlines {
+ endcol += maxwidth
+ _, err := w.w.Write(words[j])
+ if err != nil {
+ return err
+ }
+ col += utf8.RuneCount(words[j])
+ if j+nlines < len(words) {
+ for col < endcol {
+ _, err := w.w.Write([]byte{' '})
+ if err != nil {
+ return err
+ }
+ col++
+ }
+ }
+ }
+ _, err := w.w.Write([]byte{'\n'})
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/column_test.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/column_test.go b/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/column_test.go
new file mode 100644
index 0000000..ce388f5
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/text/colwriter/column_test.go
@@ -0,0 +1,90 @@
+package colwriter
+
+import (
+ "bytes"
+ "testing"
+)
+
+var src = `
+.git
+.gitignore
+.godir
+Procfile:
+README.md
+api.go
+apps.go
+auth.go
+darwin.go
+data.go
+dyno.go:
+env.go
+git.go
+help.go
+hkdist
+linux.go
+ls.go
+main.go
+plugin.go
+run.go
+scale.go
+ssh.go
+tail.go
+term
+unix.go
+update.go
+version.go
+windows.go
+`[1:]
+
+var tests = []struct {
+ wid int
+ flag uint
+ src string
+ want string
+}{
+ {80, 0, "", ""},
+ {80, 0, src, `
+.git README.md darwin.go git.go ls.go scale.go unix.go
+.gitignore api.go data.go help.go main.go ssh.go update.go
+.godir apps.go dyno.go: hkdist plugin.go tail.go version.go
+Procfile: auth.go env.go linux.go run.go term windows.go
+`[1:]},
+ {80, BreakOnColon, src, `
+.git .gitignore .godir
+
+Procfile:
+README.md api.go apps.go auth.go darwin.go data.go
+
+dyno.go:
+env.go hkdist main.go scale.go term version.go
+git.go linux.go plugin.go ssh.go unix.go windows.go
+help.go ls.go run.go tail.go update.go
+`[1:]},
+ {20, 0, `
+Hello
+Γειά σου
+안녕
+今日は
+`[1:], `
+Hello 안녕
+Γειά σου 今日は
+`[1:]},
+}
+
+func TestWriter(t *testing.T) {
+ for _, test := range tests {
+ b := new(bytes.Buffer)
+ w := NewWriter(b, test.wid, test.flag)
+ if _, err := w.Write([]byte(test.src)); err != nil {
+ t.Error(err)
+ }
+ if err := w.Flush(); err != nil {
+ t.Error(err)
+ }
+ if g := b.String(); test.want != g {
+ t.Log("\n" + test.want)
+ t.Log("\n" + g)
+ t.Errorf("%q != %q", test.want, g)
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/newt/Godeps/_workspace/src/github.com/kr/text/doc.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/kr/text/doc.go b/newt/Godeps/_workspace/src/github.com/kr/text/doc.go
new file mode 100644
index 0000000..cf4c198
--- /dev/null
+++ b/newt/Godeps/_workspace/src/github.com/kr/text/doc.go
@@ -0,0 +1,3 @@
+// Package text provides rudimentary functions for manipulating text in
+// paragraphs.
+package text