New Upstream Release - golang-vbom-util
Ready changes
Summary
Merged new upstream version: 0.0~git20200925.1b7a9fa (was: 0.0~git20180919.efcd4e0).
Diff
diff --git a/README.md b/README.md
index 72de507..dd67195 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-## util [![GoDoc](https://godoc.org/vbom.ml/util?status.svg)](https://godoc.org/vbom.ml/util)
+# util [![PkgGoDev](https://pkg.go.dev/badge/github.com/fvbommel/util)](https://pkg.go.dev/github.com/fvbommel/util)
- import "vbom.ml/util"
+ import "github.com/fvbommel/util"
Go utility packages.
diff --git a/cmd/short-regexp/main.go b/cmd/short-regexp/main.go
index cea7dc1..8b31066 100644
--- a/cmd/short-regexp/main.go
+++ b/cmd/short-regexp/main.go
@@ -8,7 +8,7 @@ import (
"os"
"strings"
- "vbom.ml/util"
+ "github.com/fvbommel/util"
)
func main() {
diff --git a/debian/changelog b/debian/changelog
index 9370292..fad0b83 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-vbom-util (0.0~git20200925.1b7a9fa-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk> Tue, 04 Jul 2023 09:09:37 -0000
+
golang-vbom-util (0.0~git20180919.efcd4e0-3) unstable; urgency=medium
[ Debian Janitor ]
diff --git a/doc.go b/doc.go
index 7c83e85..379a067 100644
--- a/doc.go
+++ b/doc.go
@@ -1,2 +1,2 @@
// Package util includes various small pieces of code.
-package util // import "vbom.ml/util"
+package util // import "github.com/fvbommel/util"
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..c162b57
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,8 @@
+module github.com/fvbommel/util
+
+go 1.13
+
+require (
+ github.com/bruth/assert v0.0.0-20130823105606-de420fa3b72e
+ github.com/kr/pretty v0.2.1 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..df22909
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,7 @@
+github.com/bruth/assert v0.0.0-20130823105606-de420fa3b72e h1:18Bcw7yGMr4XX2bbTapZ3x1qafKD0O4skD1go3CrsfQ=
+github.com/bruth/assert v0.0.0-20130823105606-de420fa3b72e/go.mod h1:MT8TZkfLPRir91B19sXF7pmKBma+n6ecyjbqgXabchs=
+github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
+github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
diff --git a/rope/README.md b/rope/README.md
index 361aaae..a646d60 100644
--- a/rope/README.md
+++ b/rope/README.md
@@ -1,6 +1,6 @@
-## rope [![GoDoc](https://godoc.org/vbom.ml/util/rope?status.svg)](https://godoc.org/vbom.ml/util/rope)
+# rope [![PkgGoDev](https://pkg.go.dev/badge/github.com/fvbommel/util/rope)](https://pkg.go.dev/github.com/fvbommel/util/rope)
- import "vbom.ml/util/rope"
+ import "github.com/fvbommel/util/rope"
Package rope implements a "heavy-weight string", which represents very long strings more efficiently (especially when many concatenations are performed).
diff --git a/rope/rebalance_test.go b/rope/rebalance_test.go
index 90755f0..592b145 100644
--- a/rope/rebalance_test.go
+++ b/rope/rebalance_test.go
@@ -33,7 +33,7 @@ func init() {
//~ n := New("a")
var r Rope
- for i := 0; i < 100; i++ {
+ for i := rune(0); i < 100; i++ {
r = r.AppendString(string(' ' + i))
}
rebalanceTestRopes = append(rebalanceTestRopes, r)
diff --git a/rope/rope.go b/rope/rope.go
index e993e67..3a8ccd7 100644
--- a/rope/rope.go
+++ b/rope/rope.go
@@ -6,7 +6,7 @@
//
// Rope values are immutable, so each operation returns its result instead
// of modifying the receiver. This immutability also makes them thread-safe.
-package rope // import "vbom.ml/util/rope"
+package rope
import (
"bytes"
diff --git a/sortorder/README.md b/sortorder/README.md
index ed8da0e..a72c0d6 100644
--- a/sortorder/README.md
+++ b/sortorder/README.md
@@ -1,5 +1,3 @@
-## sortorder [![GoDoc](https://godoc.org/vbom.ml/util/sortorder?status.svg)](https://godoc.org/vbom.ml/util/sortorder)
+# sortorder has migrated
- import "vbom.ml/util/sortorder"
-
-Sort orders and comparison functions.
+Please update your references to point to [`"github.com/fvbommel/sortorder"`](https://github.com/fvbommel/sortorder) instead.
diff --git a/sortorder/doc.go b/sortorder/doc.go
deleted file mode 100644
index 61b37a9..0000000
--- a/sortorder/doc.go
+++ /dev/null
@@ -1,5 +0,0 @@
-// Package sortorder implements sort orders and comparison functions.
-//
-// Currently, it only implements so-called "natural order", where integers
-// embedded in strings are compared by value.
-package sortorder // import "vbom.ml/util/sortorder"
diff --git a/sortorder/natsort.go b/sortorder/natsort.go
deleted file mode 100644
index 66a52c7..0000000
--- a/sortorder/natsort.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package sortorder
-
-// Natural implements sort.Interface to sort strings in natural order. This
-// means that e.g. "abc2" < "abc12".
-//
-// Non-digit sequences and numbers are compared separately. The former are
-// compared bytewise, while the latter are compared numerically (except that
-// the number of leading zeros is used as a tie-breaker, so e.g. "2" < "02")
-//
-// Limitation: only ASCII digits (0-9) are considered.
-type Natural []string
-
-func (n Natural) Len() int { return len(n) }
-func (n Natural) Swap(i, j int) { n[i], n[j] = n[j], n[i] }
-func (n Natural) Less(i, j int) bool { return NaturalLess(n[i], n[j]) }
-
-func isdigit(b byte) bool { return '0' <= b && b <= '9' }
-
-// NaturalLess compares two strings using natural ordering. This means that e.g.
-// "abc2" < "abc12".
-//
-// Non-digit sequences and numbers are compared separately. The former are
-// compared bytewise, while the latter are compared numerically (except that
-// the number of leading zeros is used as a tie-breaker, so e.g. "2" < "02")
-//
-// Limitation: only ASCII digits (0-9) are considered.
-func NaturalLess(str1, str2 string) bool {
- idx1, idx2 := 0, 0
- for idx1 < len(str1) && idx2 < len(str2) {
- c1, c2 := str1[idx1], str2[idx2]
- dig1, dig2 := isdigit(c1), isdigit(c2)
- switch {
- case dig1 != dig2: // Digits before other characters.
- return dig1 // True if LHS is a digit, false if the RHS is one.
- case !dig1: // && !dig2, because dig1 == dig2
- // UTF-8 compares bytewise-lexicographically, no need to decode
- // codepoints.
- if c1 != c2 {
- return c1 < c2
- }
- idx1++
- idx2++
- default: // Digits
- // Eat zeros.
- for ; idx1 < len(str1) && str1[idx1] == '0'; idx1++ {
- }
- for ; idx2 < len(str2) && str2[idx2] == '0'; idx2++ {
- }
- // Eat all digits.
- nonZero1, nonZero2 := idx1, idx2
- for ; idx1 < len(str1) && isdigit(str1[idx1]); idx1++ {
- }
- for ; idx2 < len(str2) && isdigit(str2[idx2]); idx2++ {
- }
- // If lengths of numbers with non-zero prefix differ, the shorter
- // one is less.
- if len1, len2 := idx1-nonZero1, idx2-nonZero2; len1 != len2 {
- return len1 < len2
- }
- // If they're equal, string comparison is correct.
- if nr1, nr2 := str1[nonZero1:idx1], str2[nonZero2:idx2]; nr1 != nr2 {
- return nr1 < nr2
- }
- // Otherwise, the one with less zeros is less.
- // Because everything up to the number is equal, comparing the index
- // after the zeros is sufficient.
- if nonZero1 != nonZero2 {
- return nonZero1 < nonZero2
- }
- }
- // They're identical so far, so continue comparing.
- }
- // So far they are identical. At least one is ended. If the other continues,
- // it sorts last.
- return len(str1) < len(str2)
-}
diff --git a/sortorder/natsort_test.go b/sortorder/natsort_test.go
deleted file mode 100644
index 5680c94..0000000
--- a/sortorder/natsort_test.go
+++ /dev/null
@@ -1,230 +0,0 @@
-package sortorder
-
-import (
- "flag"
- "math/rand"
- "reflect"
- "sort"
- "strconv"
- "testing"
-
- "github.com/xlab/handysort"
-)
-
-func TestStringSort(t *testing.T) {
- a := []string{
- "ab", "abc1",
- "abc01", "abc2",
- "abc5", "abc10",
- }
- b := []string{
- "abc5", "abc1",
- "abc01", "ab",
- "abc10", "abc2",
- }
- sort.Sort(Natural(b))
- if !reflect.DeepEqual(a, b) {
- t.Errorf("Error: sort failed, expected: %#q, got: %#q", a, b)
- }
-}
-
-func TestNaturalLess(t *testing.T) {
- testset := []struct {
- s1, s2 string
- less bool
- }{
- {"0", "00", true},
- {"00", "0", false},
- {"aa", "ab", true},
- {"ab", "abc", true},
- {"abc", "ad", true},
- {"ab1", "ab2", true},
- {"ab1c", "ab1c", false},
- {"ab12", "abc", true},
- {"ab2a", "ab10", true},
- {"a0001", "a0000001", true},
- {"a10", "abcdefgh2", true},
- {"аб2аб", "аб10аб", true},
- {"2аб", "3аб", true},
- //
- {"a1b", "a01b", true},
- {"a01b", "a1b", false},
- {"ab01b", "ab010b", true},
- {"ab010b", "ab01b", false},
- {"a01b001", "a001b01", true},
- {"a001b01", "a01b001", false},
- {"a1", "a1x", true},
- {"1ax", "1b", true},
- {"1b", "1ax", false},
- //
- {"082", "83", true},
- //
- {"083a", "9a", false},
- {"9a", "083a", true},
- }
- for _, v := range testset {
- if res := NaturalLess(v.s1, v.s2); res != v.less {
- t.Errorf("Compared %#q to %#q: expected %v, got %v",
- v.s1, v.s2, v.less, res)
- }
- if res := handysort.StringLess(v.s1, v.s2); res != v.less {
- t.Logf("handysort: Compared %#q to %#q: expected %v, got %v",
- v.s1, v.s2, v.less, res)
- }
- }
-}
-
-var testEquivalence = flag.Bool("equivalence", false, "Test equivalence with handysort")
-
-func TestEquivalenceToXlabStringLess(t *testing.T) {
- if !*testEquivalence {
- t.Skip("Skipping exhaustive test without -equivalence")
- }
-
- set := testSet(300)
- for _, list := range set[:1] {
- list = list[:100]
- for _, lhs := range list {
- for _, rhs := range list {
- nl := NaturalLess(lhs, rhs)
- sl := handysort.StringLess(lhs, rhs)
- if nl != sl {
- t.Errorf("difference to handysort: %v vs %v for %#q < %#q", nl, sl, lhs, rhs)
- }
- }
- }
- }
-}
-
-func BenchmarkStdStringSort(b *testing.B) {
- set := testSet(300)
- arr := make([]string, len(set[0]))
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for _, list := range set {
- b.StopTimer()
- copy(arr, list)
- b.StartTimer()
-
- sort.Strings(arr)
- }
- }
-}
-
-func BenchmarkNaturalStringSort(b *testing.B) {
- set := testSet(300)
- arr := make([]string, len(set[0]))
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for _, list := range set {
- b.StopTimer()
- copy(arr, list)
- b.StartTimer()
-
- sort.Sort(Natural(arr))
- }
- }
-}
-
-func BenchmarkHandyStringSort(b *testing.B) {
- set := testSet(300)
- arr := make([]string, len(set[0]))
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for _, list := range set {
- b.StopTimer()
- copy(arr, list)
- b.StartTimer()
-
- sort.Sort(handysort.Strings(arr))
- }
- }
-}
-
-func BenchmarkStdStringLess(b *testing.B) {
- set := testSet(300)
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range set[0] {
- k := (j + 1) % len(set[0])
- _ = set[0][j] < set[0][k]
- }
- }
-}
-
-func BenchmarkNaturalLess(b *testing.B) {
- set := testSet(300)
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range set[0] {
- k := (j + 1) % len(set[0])
- _ = NaturalLess(set[0][j], set[0][k])
- }
- }
-}
-
-func BenchmarkHandyStringLess(b *testing.B) {
- set := testSet(300)
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- for j := range set[0] {
- k := (j + 1) % len(set[0])
- _ = handysort.StringLess(set[0][j], set[0][k])
- }
- }
-}
-
-// Get 1000 arrays of 10000-string-arrays (less if -short is specified).
-func testSet(seed int) [][]string {
- gen := &generator{
- src: rand.New(rand.NewSource(
- int64(seed),
- )),
- }
- n := 1000
- if testing.Short() {
- n = 1
- }
- set := make([][]string, n)
- for i := range set {
- strings := make([]string, 10000)
- for idx := range strings {
- // Generate a random string
- strings[idx] = gen.NextString()
- }
- set[i] = strings
- }
- return set
-}
-
-type generator struct {
- src *rand.Rand
-}
-
-func (g *generator) NextInt(max int) int {
- return g.src.Intn(max)
-}
-
-// Gets random random-length alphanumeric string.
-func (g *generator) NextString() (str string) {
- // Random-length 3-8 chars part
- strlen := g.src.Intn(6) + 3
- // Random-length 1-3 num
- numlen := g.src.Intn(3) + 1
- // Random position for num in string
- numpos := g.src.Intn(strlen + 1)
- // Generate the number
- var num string
- for i := 0; i < numlen; i++ {
- num += strconv.Itoa(g.src.Intn(10))
- }
- // Put it all together
- for i := 0; i < strlen+1; i++ {
- if i == numpos {
- str += num
- } else {
- str += string('a' + g.src.Intn(16))
- }
- }
- return str
-}
diff --git a/sortorder/please-migrate.go b/sortorder/please-migrate.go
new file mode 100644
index 0000000..eeeb4ea
--- /dev/null
+++ b/sortorder/please-migrate.go
@@ -0,0 +1,3 @@
+// Package sortorder has moved to a new import path.
+// Please update your references to point to "github.com/fvbommel/sortorder" instead.
+package sortorder // import "github.com/fvbommel/sortorder"