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

Side by Side Diff: Source/platform/ParsingUtilities.h

Issue 656063002: Subresource Integrity: Improve parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 template<typename CharType, bool characterPredicate(CharType)> 44 template<typename CharType, bool characterPredicate(CharType)>
45 bool skipExactly(const CharType*& position, const CharType* end) 45 bool skipExactly(const CharType*& position, const CharType* end)
46 { 46 {
47 if (position < end && characterPredicate(*position)) { 47 if (position < end && characterPredicate(*position)) {
48 ++position; 48 ++position;
49 return true; 49 return true;
50 } 50 }
51 return false; 51 return false;
52 } 52 }
53 53
54 template<typename CharType> 54 template <typename CharType>
55 bool skipToken(const CharType*& position, const CharType* end, const char* token )
56 {
57 const CharType* current = position;
58 while (current < end && *token) {
59 if (*current != *token++)
jww 2014/10/15 23:26:04 I find this inline post-increment extremely confus
Mike West 2014/10/16 06:17:22 Done.
60 return false;
61 ++current;
62 }
63 if (*token)
64 return false;
65
66 position = current;
67 return true;
68 }
69
70 template <typename CharType>
55 void skipUntil(const CharType*& position, const CharType* end, CharType delimite r) 71 void skipUntil(const CharType*& position, const CharType* end, CharType delimite r)
56 { 72 {
57 while (position < end && *position != delimiter) 73 while (position < end && *position != delimiter)
58 ++position; 74 ++position;
59 } 75 }
60 76
61 template<typename CharType, bool characterPredicate(CharType)> 77 template<typename CharType, bool characterPredicate(CharType)>
62 void skipUntil(const CharType*& position, const CharType* end) 78 void skipUntil(const CharType*& position, const CharType* end)
63 { 79 {
64 while (position < end && !characterPredicate(*position)) 80 while (position < end && !characterPredicate(*position))
65 ++position; 81 ++position;
66 } 82 }
67 83
68 template<typename CharType, bool characterPredicate(CharType)> 84 template<typename CharType, bool characterPredicate(CharType)>
69 void skipWhile(const CharType*& position, const CharType* end) 85 void skipWhile(const CharType*& position, const CharType* end)
70 { 86 {
71 while (position < end && characterPredicate(*position)) 87 while (position < end && characterPredicate(*position))
72 ++position; 88 ++position;
73 } 89 }
74 90
75 template<typename CharType, bool characterPredicate(CharType)> 91 template<typename CharType, bool characterPredicate(CharType)>
76 void reverseSkipWhile(const CharType*& position, const CharType* start) 92 void reverseSkipWhile(const CharType*& position, const CharType* start)
77 { 93 {
78 while (position >= start && characterPredicate(*position)) 94 while (position >= start && characterPredicate(*position))
79 --position; 95 --position;
80 } 96 }
81 97
82 #endif 98 #endif
83 99
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698