Skip to content

Commit 2c49860

Browse files
committed
Add license notice for code adapted from Go
Fix prometheus/prometheus#9884 Signed-off-by: Julius Volz <[email protected]>
1 parent 14986e5 commit 2c49860

File tree

3 files changed

+80
-7
lines changed

3 files changed

+80
-7
lines changed

NOTICE

+5
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ https://github.com/dgryski/go-tsz
9191
Copyright (c) 2015,2016 Damian Gryski <[email protected]>
9292
See https://github.com/dgryski/go-tsz/blob/master/LICENSE for license details.
9393

94+
The Go programming language
95+
https://go.dev/
96+
Copyright (c) 2009 The Go Authors
97+
See https://go.dev/LICENSE for license details.
98+
9499
The Codicon icon font from Microsoft
95100
https://github.com/microsoft/vscode-codicons
96101
Copyright (c) Microsoft Corporation and other contributors

util/strutil/quote.go

+39-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,45 @@
1010
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
13+
//
14+
// NOTE: The functions in this file (Unquote, unquoteChar, contains, unhex)
15+
// have been adapted from the "strconv" package of the Go standard library
16+
// to work for Prometheus-style strings. Go's special-casing for single
17+
// quotes was removed and single quoted strings are now treated the same as
18+
// double-quoted ones.
19+
//
20+
// The original copyright notice from the Go project for these parts is
21+
// reproduced here:
22+
//
23+
// ========================================================================
24+
// Copyright (c) 2009 The Go Authors. All rights reserved.
25+
//
26+
// Redistribution and use in source and binary forms, with or without
27+
// modification, are permitted provided that the following conditions are
28+
// met:
29+
//
30+
// * Redistributions of source code must retain the above copyright
31+
// notice, this list of conditions and the following disclaimer.
32+
// * Redistributions in binary form must reproduce the above
33+
// copyright notice, this list of conditions and the following disclaimer
34+
// in the documentation and/or other materials provided with the
35+
// distribution.
36+
// * Neither the name of Google Inc. nor the names of its
37+
// contributors may be used to endorse or promote products derived from
38+
// this software without specific prior written permission.
39+
//
40+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51+
// ========================================================================
1352

1453
package strutil
1554

@@ -24,13 +63,6 @@ var ErrSyntax = errors.New("invalid syntax")
2463
// Unquote interprets s as a single-quoted, double-quoted, or backquoted
2564
// Prometheus query language string literal, returning the string value that s
2665
// quotes.
27-
//
28-
// NOTE: This function as well as the necessary helper functions below
29-
// (unquoteChar, contains, unhex) and associated tests have been adapted from
30-
// the corresponding functions in the "strconv" package of the Go standard
31-
// library to work for Prometheus-style strings. Go's special-casing for single
32-
// quotes was removed and single quoted strings are now treated the same as
33-
// double quoted ones.
3466
func Unquote(s string) (t string, err error) {
3567
n := len(s)
3668
if n < 2 {

util/strutil/quote_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,42 @@
1010
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
13+
//
14+
// NOTE: The test code in this file has been adapted from the "strconv"
15+
// package of the Go standard library to work for Prometheus-style strings.
16+
//
17+
// The original copyright notice from the Go project for these parts is
18+
// reproduced here:
19+
//
20+
// ========================================================================
21+
// Copyright (c) 2009 The Go Authors. All rights reserved.
22+
//
23+
// Redistribution and use in source and binary forms, with or without
24+
// modification, are permitted provided that the following conditions are
25+
// met:
26+
//
27+
// * Redistributions of source code must retain the above copyright
28+
// notice, this list of conditions and the following disclaimer.
29+
// * Redistributions in binary form must reproduce the above
30+
// copyright notice, this list of conditions and the following disclaimer
31+
// in the documentation and/or other materials provided with the
32+
// distribution.
33+
// * Neither the name of Google Inc. nor the names of its
34+
// contributors may be used to endorse or promote products derived from
35+
// this software without specific prior written permission.
36+
//
37+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
38+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
40+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
41+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48+
// ========================================================================
1349

1450
package strutil
1551

0 commit comments

Comments
 (0)