mirror of https://github.com/golang/go.git
Merge a38e4ec203 into 49cdf0c42e
This commit is contained in:
commit
03df2c6e27
|
|
@ -81,7 +81,7 @@ func marshalCorpusFile(vals ...any) []byte {
|
|||
// We arbitrarily draw the line at UTF-8 validity, which biases toward the
|
||||
// "rune" interpretation. (However, we accept either format as input.)
|
||||
if utf8.ValidRune(t) {
|
||||
fmt.Fprintf(b, "rune(%q)\n", t)
|
||||
fmt.Fprintf(b, "int32(%v)/rune(%q)\n", t, t)
|
||||
} else {
|
||||
fmt.Fprintf(b, "int32(%v)\n", t)
|
||||
}
|
||||
|
|
@ -117,6 +117,12 @@ func unmarshalCorpusFile(b []byte) ([]any, error) {
|
|||
if len(line) == 0 {
|
||||
continue
|
||||
}
|
||||
if bytes.HasPrefix(line, []byte("int32")) ||
|
||||
bytes.HasPrefix(line, []byte("rune")) {
|
||||
if idx := bytes.IndexByte(line, '/'); idx != -1 {
|
||||
line = line[:idx]
|
||||
}
|
||||
}
|
||||
v, err := parseCorpusValue(line)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("malformed line %q: %v", line, err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue