Changeset 30560 in webkit
- Timestamp:
- Feb 24, 2008 11:11:40 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r30555 r30560 1 2008-02-24 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Mark Rowe. 4 5 http://bugs.webkit.org/show_bug.cgi?id=17529 6 Add support for reading from stdin from testkjs 7 8 * kjs/testkjs.cpp: 9 (GlobalObject::GlobalObject): Add readline function to global object. 10 (functionReadline): Added. Reads characters from stdin until a '\n' or 11 EOF is encountered. The input is returned as a String to the caller. 12 1 13 2008-02-24 Sam Weinig <sam@webkit.org> 2 14 -
trunk/JavaScriptCore/kjs/testkjs.cpp
r30555 r30560 63 63 static JSValue* functionRun(ExecState*, JSObject*, const List&); 64 64 static JSValue* functionLoad(ExecState*, JSObject*, const List&); 65 static JSValue* functionReadline(ExecState*, JSObject*, const List&); 65 66 static JSValue* functionQuit(ExecState*, JSObject*, const List&); 66 67 … … 137 138 putDirectFunction(new PrototypeFunction(globalExec(), functionPrototype(), 1, "run", functionRun)); 138 139 putDirectFunction(new PrototypeFunction(globalExec(), functionPrototype(), 1, "load", functionLoad)); 140 putDirectFunction(new PrototypeFunction(globalExec(), functionPrototype(), 0, "readline", functionReadline)); 139 141 140 142 JSObject* array = arrayConstructor()->construct(globalExec(), globalExec()->emptyList()); … … 197 199 198 200 return jsUndefined(); 201 } 202 203 JSValue* functionReadline(ExecState*, JSObject*, const List&) 204 { 205 Vector<char, 256> line; 206 int c; 207 while ((c = getchar()) != EOF) { 208 // FIXME: Should we also break on \r? 209 if (c == '\n') 210 break; 211 line.append(c); 212 } 213 line.append('\0'); 214 return jsString(line.data()); 199 215 } 200 216
Note: See TracChangeset
for help on using the changeset viewer.