forked from firka/flutter
Dart SDK roll for 2018/07/26 (flutter/engine#5876)
This commit is contained in:
@@ -26,7 +26,7 @@ enum FileType {
|
||||
typedef Reader = List<int> Function();
|
||||
|
||||
class BytesOf extends Key { BytesOf(dynamic value) : super(value); }
|
||||
class UTF8Of extends Key { UTF8Of(dynamic value) : super(value); }
|
||||
class utf8Of extends Key { utf8Of(dynamic value) : super(value); }
|
||||
class Latin1Of extends Key { Latin1Of(dynamic value) : super(value); }
|
||||
|
||||
bool matchesSignature(List<int> bytes, List<int> signature) {
|
||||
@@ -59,7 +59,7 @@ const String kMultiLicenseFileHeader = 'Notices for files contained in';
|
||||
|
||||
bool isMultiLicenseNotice(Reader reader) {
|
||||
List<int> bytes = reader();
|
||||
return (ASCII.decode(bytes.take(kMultiLicenseFileHeader.length).toList(), allowInvalid: true) == kMultiLicenseFileHeader);
|
||||
return (ascii.decode(bytes.take(kMultiLicenseFileHeader.length).toList(), allowInvalid: true) == kMultiLicenseFileHeader);
|
||||
}
|
||||
|
||||
FileType identifyFile(String name, Reader reader) {
|
||||
@@ -114,7 +114,7 @@ FileType identifyFile(String name, Reader reader) {
|
||||
case 'tzdata': return FileType.binary;
|
||||
case 'compressed_atrace_data.txt': return FileType.binary;
|
||||
// Source files that don't use UTF-8
|
||||
case 'Messages_de_DE.properties': // has a few non-ASCII characters they forgot to escape (from gnu-libstdc++)
|
||||
case 'Messages_de_DE.properties': // has a few non-ascii characters they forgot to escape (from gnu-libstdc++)
|
||||
case 'mmx_blendtmp.h': // author name in comment contains latin1 (mesa)
|
||||
case 'calling_convention.txt': // contains a soft hyphen instead of a real hyphen for some reason (mesa)
|
||||
// Character encoding data files
|
||||
@@ -310,11 +310,11 @@ abstract class TextFile extends File {
|
||||
}
|
||||
|
||||
// mixin
|
||||
abstract class UTF8TextFile extends TextFile {
|
||||
abstract class utf8TextFile extends TextFile {
|
||||
@override
|
||||
String readString() {
|
||||
try {
|
||||
return cache(new UTF8Of(this), () => UTF8.decode(readBytes()));
|
||||
return cache(new utf8Of(this), () => utf8.decode(readBytes()));
|
||||
} on FormatException {
|
||||
print(fullName);
|
||||
rethrow;
|
||||
@@ -330,15 +330,15 @@ abstract class Latin1TextFile extends TextFile {
|
||||
final List<int> bytes = readBytes();
|
||||
if (bytes.any((int byte) => byte == 0x00))
|
||||
throw '$fullName contains a U+0000 NULL and is probably not actually encoded as Win1252';
|
||||
bool isUTF8 = false;
|
||||
bool isutf8 = false;
|
||||
try {
|
||||
cache(new UTF8Of(this), () => UTF8.decode(readBytes()));
|
||||
isUTF8 = true;
|
||||
cache(new utf8Of(this), () => utf8.decode(readBytes()));
|
||||
isutf8 = true;
|
||||
} on FormatException {
|
||||
}
|
||||
if (isUTF8)
|
||||
if (isutf8)
|
||||
throw '$fullName contains valid UTF-8 and is probably not actually encoded as Win1252';
|
||||
return LATIN1.decode(bytes);
|
||||
return latin1.decode(bytes);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -460,7 +460,7 @@ class FileSystemDirectory extends IoNode implements Directory {
|
||||
case FileType.tar: yield new FileSystemTarFile(fileEntity); break;
|
||||
case FileType.gz: yield new FileSystemGZipFile(fileEntity); break;
|
||||
case FileType.bzip2: yield new FileSystemBZip2File(fileEntity); break;
|
||||
case FileType.text: yield new FileSystemUTF8TextFile(fileEntity); break;
|
||||
case FileType.text: yield new FileSystemutf8TextFile(fileEntity); break;
|
||||
case FileType.latin1Text: yield new FileSystemLatin1TextFile(fileEntity); break;
|
||||
case FileType.metadata: break; // ignore this file
|
||||
}
|
||||
@@ -499,8 +499,8 @@ class FileSystemFile extends IoNode implements File {
|
||||
}
|
||||
}
|
||||
|
||||
class FileSystemUTF8TextFile extends FileSystemFile with UTF8TextFile {
|
||||
FileSystemUTF8TextFile(io.File file) : super(file);
|
||||
class FileSystemutf8TextFile extends FileSystemFile with utf8TextFile {
|
||||
FileSystemutf8TextFile(io.File file) : super(file);
|
||||
}
|
||||
|
||||
class FileSystemLatin1TextFile extends FileSystemFile with Latin1TextFile {
|
||||
@@ -554,7 +554,7 @@ class ArchiveDirectory extends IoNode implements Directory {
|
||||
case FileType.tar: _files.add(new ArchiveTarFile(entryFullName, entry)); break;
|
||||
case FileType.gz: _files.add(new ArchiveGZipFile(entryFullName, entry)); break;
|
||||
case FileType.bzip2: _files.add(new ArchiveBZip2File(entryFullName, entry)); break;
|
||||
case FileType.text: _files.add(new ArchiveUTF8TextFile(entryFullName, entry)); break;
|
||||
case FileType.text: _files.add(new Archiveutf8TextFile(entryFullName, entry)); break;
|
||||
case FileType.latin1Text: _files.add(new ArchiveLatin1TextFile(entryFullName, entry)); break;
|
||||
case FileType.metadata: break; // ignore this file
|
||||
}
|
||||
@@ -595,8 +595,8 @@ class ArchiveFile extends IoNode implements File {
|
||||
}
|
||||
}
|
||||
|
||||
class ArchiveUTF8TextFile extends ArchiveFile with UTF8TextFile {
|
||||
ArchiveUTF8TextFile(String fullName, a.ArchiveFile file) : super(fullName, file);
|
||||
class Archiveutf8TextFile extends ArchiveFile with utf8TextFile {
|
||||
Archiveutf8TextFile(String fullName, a.ArchiveFile file) : super(fullName, file);
|
||||
}
|
||||
|
||||
class ArchiveLatin1TextFile extends ArchiveFile with Latin1TextFile {
|
||||
@@ -634,7 +634,7 @@ class InMemoryFile extends IoNode implements File {
|
||||
case FileType.tar: return new InMemoryTarFile(fullName, bytes); break;
|
||||
case FileType.gz: return new InMemoryGZipFile(fullName, bytes); break;
|
||||
case FileType.bzip2: return new InMemoryBZip2File(fullName, bytes); break;
|
||||
case FileType.text: return new InMemoryUTF8TextFile(fullName, bytes); break;
|
||||
case FileType.text: return new InMemoryutf8TextFile(fullName, bytes); break;
|
||||
case FileType.latin1Text: return new InMemoryLatin1TextFile(fullName, bytes); break;
|
||||
case FileType.metadata: break; // ignore this file
|
||||
}
|
||||
@@ -654,8 +654,8 @@ class InMemoryFile extends IoNode implements File {
|
||||
List<int> readBytes() => _bytes;
|
||||
}
|
||||
|
||||
class InMemoryUTF8TextFile extends InMemoryFile with UTF8TextFile {
|
||||
InMemoryUTF8TextFile(String fullName, List<int> file) : super(fullName, file);
|
||||
class InMemoryutf8TextFile extends InMemoryFile with utf8TextFile {
|
||||
InMemoryutf8TextFile(String fullName, List<int> file) : super(fullName, file);
|
||||
}
|
||||
|
||||
class InMemoryLatin1TextFile extends InMemoryFile with Latin1TextFile {
|
||||
|
||||
@@ -322,25 +322,25 @@ abstract class License implements Comparable<License> {
|
||||
throw 'incomplete license detected:\n---\n$body\n---';
|
||||
// if (type == LicenseType.unknown)
|
||||
// print('need detector for:\n----\n$body\n----');
|
||||
bool isUTF8 = true;
|
||||
bool isutf8 = true;
|
||||
List<int> latin1Encoded;
|
||||
try {
|
||||
latin1Encoded = LATIN1.encode(body);
|
||||
isUTF8 = false;
|
||||
latin1Encoded = latin1.encode(body);
|
||||
isutf8 = false;
|
||||
} on ArgumentError { }
|
||||
if (!isUTF8) {
|
||||
if (!isutf8) {
|
||||
bool isAscii = false;
|
||||
try {
|
||||
ASCII.decode(latin1Encoded);
|
||||
ascii.decode(latin1Encoded);
|
||||
isAscii = true;
|
||||
} on FormatException { }
|
||||
if (isAscii)
|
||||
return;
|
||||
try {
|
||||
UTF8.decode(latin1Encoded);
|
||||
isUTF8 = true;
|
||||
utf8.decode(latin1Encoded);
|
||||
isutf8 = true;
|
||||
} on FormatException { }
|
||||
if (isUTF8)
|
||||
if (isutf8)
|
||||
throw 'tried to create a License object with text that appears to have been misdecoded as Latin1 instead of as UTF-8:\n$body';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class RepositorySourceFile extends RepositoryLicensedFile {
|
||||
try {
|
||||
contents = io.readString();
|
||||
} on FormatException {
|
||||
print('non-UTF8 data in $io');
|
||||
print('non-utf8 data in $io');
|
||||
system.exit(2);
|
||||
}
|
||||
_licenses = determineLicensesFor(contents, name, parent, origin: '$this');
|
||||
@@ -736,33 +736,33 @@ class RepositoryMultiLicenseNoticesForFilesFile extends RepositoryLicenseFile {
|
||||
// "Notices for files contained in the"
|
||||
// ...then have a second line which is 60 "=" characters
|
||||
final List<List<int>> contents = splitIntList(io.readBytes(), 0x0A).toList();
|
||||
if (!ASCII.decode(contents[0]).startsWith('Notices for files contained in') ||
|
||||
ASCII.decode(contents[1]) != '============================================================\n')
|
||||
if (!ascii.decode(contents[0]).startsWith('Notices for files contained in') ||
|
||||
ascii.decode(contents[1]) != '============================================================\n')
|
||||
throw 'unrecognised syntax: ${io.fullName}';
|
||||
int index = 2;
|
||||
while (index < contents.length) {
|
||||
if (ASCII.decode(contents[index]) != 'Notices for file(s):\n')
|
||||
if (ascii.decode(contents[index]) != 'Notices for file(s):\n')
|
||||
throw 'unrecognised syntax on line ${index + 1}: ${io.fullName}';
|
||||
index += 1;
|
||||
final List<String> names = <String>[];
|
||||
do {
|
||||
names.add(ASCII.decode(contents[index]));
|
||||
names.add(ascii.decode(contents[index]));
|
||||
index += 1;
|
||||
} while (ASCII.decode(contents[index]) != '------------------------------------------------------------\n');
|
||||
} while (ascii.decode(contents[index]) != '------------------------------------------------------------\n');
|
||||
index += 1;
|
||||
final List<List<int>> body = <List<int>>[];
|
||||
do {
|
||||
body.add(contents[index]);
|
||||
index += 1;
|
||||
} while (index < contents.length &&
|
||||
ASCII.decode(contents[index], allowInvalid: true) != '============================================================\n');
|
||||
ascii.decode(contents[index], allowInvalid: true) != '============================================================\n');
|
||||
index += 1;
|
||||
final List<int> bodyBytes = body.expand((List<int> line) => line).toList();
|
||||
String bodyText;
|
||||
try {
|
||||
bodyText = UTF8.decode(bodyBytes);
|
||||
bodyText = utf8.decode(bodyBytes);
|
||||
} on FormatException {
|
||||
bodyText = LATIN1.decode(bodyBytes);
|
||||
bodyText = latin1.decode(bodyBytes);
|
||||
}
|
||||
License license = new License.unique(bodyText, LicenseType.unknown, origin: io.fullName);
|
||||
for (String name in names) {
|
||||
@@ -2545,7 +2545,7 @@ Future<Null> main(List<String> arguments) async {
|
||||
system.File goldenFile = new system.File(
|
||||
path.join(argResults['golden'], 'licenses_${component.io.name}'));
|
||||
String goldenSignature = await goldenFile.openRead()
|
||||
.transform(UTF8.decoder).transform(new LineSplitter()).first;
|
||||
.transform(utf8.decoder).transform(new LineSplitter()).first;
|
||||
Match goldenMatch = signaturePattern.matchAsPrefix(goldenSignature);
|
||||
if (goldenMatch != null && goldenMatch.group(1) == signature) {
|
||||
system.stderr.writeln(' Skipping this component - no change in signature');
|
||||
|
||||
Reference in New Issue
Block a user