// appropriate importer.
switch exportFormat {
case 'u':
- // TODO(taking): Look into whether this should be LastIndex instead of Index.
- s = s[:strings.Index(s, "\n$$\n")]
+ // exported strings may contain "\n$$\n" - search backwards
+ s = s[:strings.LastIndex(s, "\n$$\n")]
input := pkgbits.NewPkgDecoder(id, s)
pkg = ReadPackage(nil, packages, input)
default:
}
// 2) find export data
i := bytes.Index(data, []byte("\n$$B\n")) + 5
+ // Export data can contain "\n$$\n" in string constants, however,
+ // searching for the next end of section marker "\n$$\n" is good enough for testzs.
j := bytes.Index(data[i:], []byte("\n$$\n")) + i
if i < 0 || j < 0 || i > j {
t.Fatalf("export data section not found (i = %d, j = %d)", i, j)
C8 = 42
C9 int = 42
C10 float64 = 42
+ C11 = "\n$$\n" // an object file export data marker - export data extraction must not be led astray
)
type (
}
// 2) find export data
i := bytes.Index(data, []byte("\n$$B\n")) + 5
+ // Export data can contain "\n$$\n" in string constants, however,
+ // searching for the next end of section marker "\n$$\n" is good enough for tests.
j := bytes.Index(data[i:], []byte("\n$$\n")) + i
if i < 0 || j < 0 || i > j {
t.Fatalf("export data section not found (i = %d, j = %d)", i, j)
C8 = 42
C9 int = 42
C10 float64 = 42
+ C11 = "\n$$\n" // an object file export data marker - export data extraction must not be led astray
)
type (