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

Side by Side Diff: samples/lineprocessor.cc

Issue 549086: Fix lineprocessor: compilation (Closed)
Patch Set: merge Created 10 years, 11 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 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return ReadLine(); 403 return ReadLine();
404 } 404 }
405 405
406 v8::Handle<v8::String> ReadLine() { 406 v8::Handle<v8::String> ReadLine() {
407 const int kBufferSize = 1024 + 1; 407 const int kBufferSize = 1024 + 1;
408 char buffer[kBufferSize]; 408 char buffer[kBufferSize];
409 409
410 char* res; 410 char* res;
411 { 411 {
412 v8::Unlocker unlocker; 412 v8::Unlocker unlocker;
413 res = fgets(buffer, buffer_size, stdin); 413 res = fgets(buffer, kBufferSize, stdin);
414 } 414 }
415 if (res == NULL) { 415 if (res == NULL) {
416 v8::Handle<v8::Primitive> t = v8::Undefined(); 416 v8::Handle<v8::Primitive> t = v8::Undefined();
417 return reinterpret_cast<v8::Handle<v8::String>&>(t); 417 return reinterpret_cast<v8::Handle<v8::String>&>(t);
418 } 418 }
419 // remove newline char 419 // remove newline char
420 for (char* pos = buffer; *pos != '\0'; pos++) { 420 for (char* pos = buffer; *pos != '\0'; pos++) {
421 if (*pos == '\n') { 421 if (*pos == '\n') {
422 *pos = '\0'; 422 *pos = '\0';
423 break; 423 break;
424 } 424 }
425 } 425 }
426 return v8::String::New(buffer); 426 return v8::String::New(buffer);
427 } 427 }
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