| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 156 } |
| 157 v8::String::Utf8Value str(args[i]); | 157 v8::String::Utf8Value str(args[i]); |
| 158 const char* cstr = ToCString(str); | 158 const char* cstr = ToCString(str); |
| 159 printf("%s", cstr); | 159 printf("%s", cstr); |
| 160 } | 160 } |
| 161 printf("\n"); | 161 printf("\n"); |
| 162 return Undefined(); | 162 return Undefined(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 Handle<Value> Shell::SetEnvironment(const Arguments& args) { | |
| 167 if (args.Length() != 2) { | |
| 168 const char* message = "setenv() takes two arguments"; | |
| 169 return ThrowException(String::New(message)); | |
| 170 } | |
| 171 String::Utf8Value var(args[0]); | |
| 172 String::Utf8Value value(args[1]); | |
| 173 if (*var == NULL) { | |
| 174 const char* message = | |
| 175 "os.setenv(): String conversion of variable name failed."; | |
| 176 return ThrowException(String::New(message)); | |
| 177 } | |
| 178 if (*value == NULL) { | |
| 179 const char* message = | |
| 180 "os.setenv(): String conversion of variable contents failed."; | |
| 181 return ThrowException(String::New(message)); | |
| 182 } | |
| 183 setenv(*var, *value, 1); | |
| 184 return v8::Undefined(); | |
| 185 } | |
| 186 | |
| 187 | |
| 188 Handle<Value> Shell::Load(const Arguments& args) { | 166 Handle<Value> Shell::Load(const Arguments& args) { |
| 189 for (int i = 0; i < args.Length(); i++) { | 167 for (int i = 0; i < args.Length(); i++) { |
| 190 HandleScope handle_scope; | 168 HandleScope handle_scope; |
| 191 String::Utf8Value file(args[i]); | 169 String::Utf8Value file(args[i]); |
| 192 if (*file == NULL) { | 170 if (*file == NULL) { |
| 193 return ThrowException(String::New("Error loading file")); | 171 return ThrowException(String::New("Error loading file")); |
| 194 } | 172 } |
| 195 Handle<String> source = ReadFile(*file); | 173 Handle<String> source = ReadFile(*file); |
| 196 if (source.IsEmpty()) { | 174 if (source.IsEmpty()) { |
| 197 return ThrowException(String::New("Error loading file")); | 175 return ThrowException(String::New("Error loading file")); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 return 0; | 670 return 0; |
| 693 } | 671 } |
| 694 | 672 |
| 695 | 673 |
| 696 } // namespace v8 | 674 } // namespace v8 |
| 697 | 675 |
| 698 | 676 |
| 699 int main(int argc, char* argv[]) { | 677 int main(int argc, char* argv[]) { |
| 700 return v8::Shell::Main(argc, argv); | 678 return v8::Shell::Main(argc, argv); |
| 701 } | 679 } |
| OLD | NEW |