OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 for (int i = 0; i < size;) { | 412 for (int i = 0; i < size;) { |
413 int read = fread(&chars[i], 1, size - i, file); | 413 int read = fread(&chars[i], 1, size - i, file); |
414 i += read; | 414 i += read; |
415 } | 415 } |
416 fclose(file); | 416 fclose(file); |
417 *size_out = size; | 417 *size_out = size; |
418 return chars; | 418 return chars; |
419 } | 419 } |
420 | 420 |
421 | 421 |
422 static char* ReadToken(const char* data, char token) { | 422 static char* ReadToken(char* data, char token) { |
423 char* next = ::strchr(data, token); | 423 char* next = i::OS::StrChr(data, token); |
424 if (next != NULL) { | 424 if (next != NULL) { |
425 *next = '\0'; | 425 *next = '\0'; |
426 return (next + 1); | 426 return (next + 1); |
427 } | 427 } |
428 | 428 |
429 return NULL; | 429 return NULL; |
430 } | 430 } |
431 | 431 |
432 | 432 |
433 static char* ReadLine(const char* data) { | 433 static char* ReadLine(char* data) { |
434 return ReadToken(data, '\n'); | 434 return ReadToken(data, '\n'); |
435 } | 435 } |
436 | 436 |
437 | 437 |
438 static char* ReadWord(const char* data) { | 438 static char* ReadWord(char* data) { |
439 return ReadToken(data, ' '); | 439 return ReadToken(data, ' '); |
440 } | 440 } |
441 | 441 |
442 | 442 |
443 // Reads a file into a v8 string. | 443 // Reads a file into a v8 string. |
444 Handle<String> Shell::ReadFile(const char* name) { | 444 Handle<String> Shell::ReadFile(const char* name) { |
445 int size = 0; | 445 int size = 0; |
446 char* chars = ReadChars(name, &size); | 446 char* chars = ReadChars(name, &size); |
447 if (chars == NULL) return Handle<String>(); | 447 if (chars == NULL) return Handle<String>(); |
448 Handle<String> result = String::New(chars); | 448 Handle<String> result = String::New(chars); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 return 0; | 605 return 0; |
606 } | 606 } |
607 | 607 |
608 | 608 |
609 } // namespace v8 | 609 } // namespace v8 |
610 | 610 |
611 | 611 |
612 int main(int argc, char* argv[]) { | 612 int main(int argc, char* argv[]) { |
613 return v8::Shell::Main(argc, argv); | 613 return v8::Shell::Main(argc, argv); |
614 } | 614 } |
OLD | NEW |