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

Side by Side Diff: src/scanner-base.h

Issue 5129002: Fix off-by-one in hex-parsing. (Closed)
Patch Set: Created 10 years, 1 month 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 | test/mjsunit/compiler/literals.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 30 matching lines...) Expand all
41 41
42 namespace v8 { 42 namespace v8 {
43 namespace internal { 43 namespace internal {
44 44
45 // Returns the value (0 .. 15) of a hexadecimal character c. 45 // Returns the value (0 .. 15) of a hexadecimal character c.
46 // If c is not a legal hexadecimal character, returns a value < 0. 46 // If c is not a legal hexadecimal character, returns a value < 0.
47 inline int HexValue(uc32 c) { 47 inline int HexValue(uc32 c) {
48 c -= '0'; 48 c -= '0';
49 if (static_cast<unsigned>(c) <= 9) return c; 49 if (static_cast<unsigned>(c) <= 9) return c;
50 c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36. 50 c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36.
51 if (static_cast<unsigned>(c) <= 6) return c + 10; 51 if (static_cast<unsigned>(c) <= 5) return c + 10;
52 return -1; 52 return -1;
53 } 53 }
54 54
55 // ---------------------------------------------------------------------------- 55 // ----------------------------------------------------------------------------
56 // UTF16Buffer - scanner input source with pushback. 56 // UTF16Buffer - scanner input source with pushback.
57 57
58 class UTF16Buffer { 58 class UTF16Buffer {
59 public: 59 public:
60 UTF16Buffer(); 60 UTF16Buffer();
61 virtual ~UTF16Buffer() {} 61 virtual ~UTF16Buffer() {}
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 // keyword with the current prefix). 500 // keyword with the current prefix).
501 const char* keyword_; 501 const char* keyword_;
502 int counter_; 502 int counter_;
503 Token::Value keyword_token_; 503 Token::Value keyword_token_;
504 }; 504 };
505 505
506 506
507 } } // namespace v8::internal 507 } } // namespace v8::internal
508 508
509 #endif // V8_SCANNER_BASE_H_ 509 #endif // V8_SCANNER_BASE_H_
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/compiler/literals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698