| 116 | } |
| 117 | |
| 118 | static const uint64_t* processSpec(FILE* stream, int* outCount, const std::string& spec, |
| 119 | const uint64_t* ptr, const uint64_t* end) { |
| 120 | auto stars = countStars(spec); |
| 121 | assert(stars < 3 && "cannot have more than two placeholders"); |
| 122 | switch (stars) { |
| 123 | case 0: |
| 124 | return consumeArgument(stream, outCount, spec, ptr, end); |
| 125 | case 1: |
| 126 | // Undefined behaviour if there are not enough arguments. |
| 127 | if (end - ptr < 2) { |
| 128 | return end; |
| 129 | } |
| 130 | return consumeArgument(stream, outCount, spec, ptr + 1, end, ptr[0]); |
| 131 | case 2: |
| 132 | // Undefined behaviour if there are not enough arguments. |
| 133 | if (end - ptr < 3) { |
| 134 | return end; |
| 135 | } |
| 136 | return consumeArgument(stream, outCount, spec, ptr + 2, end, ptr[0], ptr[1]); |
| 137 | } |
| 138 | |
| 139 | // Undefined behaviour if three are more than two stars. |
| 140 | return end; |
| 141 | } |
| 142 | |
| 143 | /** \brief Process a printf message using the system printf function. |
| 144 | * \param begin Start of the uint64_t array containing the message. |
no test coverage detected