Commit graph

3 commits

Author SHA1 Message Date
Julius Volz 2c49860f69 Add license notice for code adapted from Go
Fix https://github.com/prometheus/prometheus/issues/9884

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2021-12-05 09:01:52 +01:00
Julius Volz 46c5260761 Support escape sequences in strings and add raw strings.
This adapts some functionality from the Go standard library for string
literal lexing and unquoting/unescaping.

The following string types are now supported:

Double- or single-quoted strings:

  These support all escape sequences that Go supports in double-quoted
  string literals. The difference is that Prometheus also has
  single-quoted strings (instead of single-quoted runes in Go). Raw
  newlines are not allowed.

Backtick-quoted raw strings:

  Strings quoted in backticks are treated as raw strings just like in Go
  and may contain raw newlines and other special characters directly.

Fixes https://github.com/prometheus/prometheus/issues/1122
Fixes https://github.com/prometheus/prometheus/issues/1121
2015-10-08 19:17:21 +02:00
Julius Volz 7e86cd1ef4 Add Unquote() strutil function. 2015-09-30 21:56:25 +02:00