| 94 | } |
| 95 | |
| 96 | void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransformation &target) |
| 97 | { |
| 98 | std::string s1 = GetRequiredDatum(data, name), s2; |
| 99 | ByteQueue q; |
| 100 | |
| 101 | while (!s1.empty()) |
| 102 | { |
| 103 | while (s1[0] == ' ') |
| 104 | { |
| 105 | s1 = s1.substr(1); |
| 106 | if (s1.empty()) |
| 107 | goto end; // avoid invalid read if s1 is empty |
| 108 | } |
| 109 | |
| 110 | int repeat = 1; |
| 111 | if (s1[0] == 'r') |
| 112 | { |
| 113 | repeat = atoi(s1.c_str()+1); |
| 114 | s1 = s1.substr(s1.find(' ')+1); |
| 115 | } |
| 116 | |
| 117 | s2 = ""; // MSVC 6 doesn't have clear(); |
| 118 | |
| 119 | if (s1[0] == '\"') |
| 120 | { |
| 121 | s2 = s1.substr(1, s1.find('\"', 1)-1); |
| 122 | s1 = s1.substr(s2.length() + 2); |
| 123 | } |
| 124 | else if (s1.substr(0, 2) == "0x") |
| 125 | { |
| 126 | StringSource(s1.substr(2, s1.find(' ')), true, new HexDecoder(new StringSink(s2))); |
| 127 | s1 = s1.substr(STDMIN(s1.find(' '), s1.length())); |
| 128 | } |
| 129 | else |
| 130 | { |
| 131 | StringSource(s1.substr(0, s1.find(' ')), true, new HexDecoder(new StringSink(s2))); |
| 132 | s1 = s1.substr(STDMIN(s1.find(' '), s1.length())); |
| 133 | } |
| 134 | |
| 135 | while (repeat--) |
| 136 | { |
| 137 | q.Put((const byte *)s2.data(), s2.size()); |
| 138 | RandomizedTransfer(q, target, false); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | end: |
| 143 | RandomizedTransfer(q, target, true); |
| 144 | } |
| 145 | |
| 146 | std::string GetDecodedDatum(const TestData &data, const char *name) |
| 147 | { |
no test coverage detected