Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: pkg/compiler/lib/src/apiimpl.dart

Issue 1290643007: dart2js: remove trailing 0 byte when reading .packages (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library leg_apiimpl; 5 library leg_apiimpl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:package_config/packages.dart'; 10 import 'package:package_config/packages.dart';
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 Future setupPackages(Uri uri) { 385 Future setupPackages(Uri uri) {
386 if (packageRoot != null) { 386 if (packageRoot != null) {
387 // Use "non-file" packages because the file version requires a [Directory] 387 // Use "non-file" packages because the file version requires a [Directory]
388 // and we can't depend on 'dart:io' classes. 388 // and we can't depend on 'dart:io' classes.
389 packages = new NonFilePackagesDirectoryPackages(packageRoot); 389 packages = new NonFilePackagesDirectoryPackages(packageRoot);
390 } else if (packageConfig != null) { 390 } else if (packageConfig != null) {
391 return callUserProvider(packageConfig).then((packageConfigContents) { 391 return callUserProvider(packageConfig).then((packageConfigContents) {
392 if (packageConfigContents is String) { 392 if (packageConfigContents is String) {
393 packageConfigContents = UTF8.encode(packageConfigContents); 393 packageConfigContents = UTF8.encode(packageConfigContents);
394 } 394 }
395 // The input provider may put a trailing 0 byte when it reads a source
396 // file, which confuses the package config parser.
397 if (packageConfigContents.length > 0
398 && packageConfigContents.last == 0) {
399 packageConfigContents = packageConfigContents.sublist(
400 0, packageConfigContents.length - 1);
401 }
395 packages = 402 packages =
396 new MapPackages(pkgs.parse(packageConfigContents, packageConfig)); 403 new MapPackages(pkgs.parse(packageConfigContents, packageConfig));
397 }); 404 });
398 } else { 405 } else {
399 if (packagesDiscoveryProvider == null) { 406 if (packagesDiscoveryProvider == null) {
400 packages = Packages.noPackages; 407 packages = Packages.noPackages;
401 } else { 408 } else {
402 return callUserPackagesDiscovery(uri).then((p) { 409 return callUserPackagesDiscovery(uri).then((p) {
403 packages = p; 410 packages = p;
404 }); 411 });
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 print('$message: ${tryToString(exception)}'); 498 print('$message: ${tryToString(exception)}');
492 print(tryToString(stackTrace)); 499 print(tryToString(stackTrace));
493 } 500 }
494 501
495 fromEnvironment(String name) => environment[name]; 502 fromEnvironment(String name) => environment[name];
496 503
497 LibraryInfo lookupLibraryInfo(String libraryName) { 504 LibraryInfo lookupLibraryInfo(String libraryName) {
498 return library_info.LIBRARIES[libraryName]; 505 return library_info.LIBRARIES[libraryName];
499 } 506 }
500 } 507 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698