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

Side by Side Diff: bin/process_script.cc

Issue 8371016: Fix infinite recursion when dealing with cyclic library dependencies. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « bin/main.cc ('k') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Handle dart scripts. 5 // Handle dart scripts.
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 *path_sep = '\0'; 42 *path_sep = '\0';
43 intptr_t len = snprintf(NULL, 0, "%s%s%s", 43 intptr_t len = snprintf(NULL, 0, "%s%s%s",
44 path, File::PathSeparator(), filename); 44 path, File::PathSeparator(), filename);
45 char* absolute_filename = reinterpret_cast<char*>(malloc(len + 1)); 45 char* absolute_filename = reinterpret_cast<char*>(malloc(len + 1));
46 ASSERT(absolute_filename != NULL); 46 ASSERT(absolute_filename != NULL);
47 47
48 snprintf(absolute_filename, len + 1, "%s%s%s", 48 snprintf(absolute_filename, len + 1, "%s%s%s",
49 path, File::PathSeparator(), filename); 49 path, File::PathSeparator(), filename);
50 50
51 free(path); 51 free(path);
52 return absolute_filename; 52 char* canonical_filename = File::GetCanonicalPath(absolute_filename);
53 if (canonical_filename == NULL) {
54 return absolute_filename;
55 }
56 free(absolute_filename);
57 return canonical_filename;
53 } 58 }
54 59
55 60
56 static Dart_Result ReadStringFromFile(const char* filename) { 61 static Dart_Result ReadStringFromFile(const char* filename) {
57 File* file = File::OpenFile(filename, false); 62 File* file = File::OpenFile(filename, false);
58 if (file == NULL) { 63 if (file == NULL) {
59 const char* format = "Unable to open file: %s"; 64 const char* format = "Unable to open file: %s";
60 intptr_t len = snprintf(NULL, 0, format, filename); 65 intptr_t len = snprintf(NULL, 0, format, filename);
61 // TODO(iposva): Allocate from the zone instead of leaking error string 66 // TODO(iposva): Allocate from the zone instead of leaking error string
62 // here. On the other hand the binary is about the exit anyway. 67 // here. On the other hand the binary is about the exit anyway.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 Dart_Result LoadScript(const char* script_name) { 154 Dart_Result LoadScript(const char* script_name) {
150 Dart_Result result = ReadStringFromFile(script_name); 155 Dart_Result result = ReadStringFromFile(script_name);
151 if (!Dart_IsValidResult(result)) { 156 if (!Dart_IsValidResult(result)) {
152 return result; 157 return result;
153 } 158 }
154 Dart_Handle source = Dart_GetResult(result); 159 Dart_Handle source = Dart_GetResult(result);
155 Dart_Handle url = Dart_NewString(script_name); 160 Dart_Handle url = Dart_NewString(script_name);
156 161
157 return Dart_LoadScript(url, source, LibraryTagHandler); 162 return Dart_LoadScript(url, source, LibraryTagHandler);
158 } 163 }
OLDNEW
« no previous file with comments | « bin/main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698