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

Side by Side Diff: src/char-predicates-inl.h

Issue 42280: Made Date parser work on flat strings instead of arbitrary ones. (Closed)
Patch Set: Created 11 years, 9 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 | src/dateparser.h » ('j') | src/dateparser.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 25 matching lines...) Expand all
36 inline bool IsCarriageReturn(uc32 c) { 36 inline bool IsCarriageReturn(uc32 c) {
37 return c == 0x000D; 37 return c == 0x000D;
38 } 38 }
39 39
40 40
41 inline bool IsLineFeed(uc32 c) { 41 inline bool IsLineFeed(uc32 c) {
42 return c == 0x000A; 42 return c == 0x000A;
43 } 43 }
44 44
45 45
46 static inline bool IsInRange(int value, int lower_limit, int higher_limit) {
47 ASSERT(lower_limit <= higher_limit);
48 return static_cast<unsigned int>(value - lower_limit) <=
49 static_cast<unsigned int>(higher_limit - lower_limit);
50 }
51
52
46 inline bool IsDecimalDigit(uc32 c) { 53 inline bool IsDecimalDigit(uc32 c) {
47 // ECMA-262, 3rd, 7.8.3 (p 16) 54 // ECMA-262, 3rd, 7.8.3 (p 16)
48 return 55 return IsInRange(c, '0', '9');
49 '0' <= c && c <= '9';
50 } 56 }
51 57
52 58
53 inline bool IsHexDigit(uc32 c) { 59 inline bool IsHexDigit(uc32 c) {
54 // ECMA-262, 3rd, 7.6 (p 15) 60 // ECMA-262, 3rd, 7.6 (p 15)
55 return 61 return IsDecimalDigit(c) || IsInRange(c | 0x20, 'a', 'f');
56 ('0' <= c && c <= '9') ||
57 ('A' <= c && c <= 'F') ||
58 ('a' <= c && c <= 'f');
59 } 62 }
60 63
61 64
62 inline bool IsRegExpWord(uc16 c) { 65 inline bool IsRegExpWord(uc16 c) {
63 return ('a' <= c && c <= 'z') 66 return IsInRange(c | 0x20, 'a', 'z')
64 || ('A' <= c && c <= 'Z') 67 || IsDecimalDigit(c)
65 || ('0' <= c && c <= '9')
66 || (c == '_'); 68 || (c == '_');
67 } 69 }
68 70
69 71
70 inline bool IsRegExpNewline(uc16 c) { 72 inline bool IsRegExpNewline(uc16 c) {
71 switch (c) { 73 switch (c) {
72 // CR LF LS PS 74 // CR LF LS PS
73 case 0x000A: case 0x000D: case 0x2028: case 0x2029: 75 case 0x000A: case 0x000D: case 0x2028: case 0x2029:
74 return false; 76 return false;
75 default: 77 default:
76 return true; 78 return true;
77 } 79 }
78 } 80 }
79 81
80 82
81 } } // namespace v8::internal 83 } } // namespace v8::internal
82 84
83 #endif // V8_CHAR_PREDICATES_INL_H_ 85 #endif // V8_CHAR_PREDICATES_INL_H_
OLDNEW
« no previous file with comments | « no previous file | src/dateparser.h » ('j') | src/dateparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698