Hilite place of syntax error.
| 89 | |
| 90 | /// Hilite place of syntax error. |
| 91 | void writeQueryWithHighlightedErrorPositions( |
| 92 | WriteBuffer & out, |
| 93 | const char * begin, |
| 94 | const char * end, |
| 95 | const Token * positions_to_hilite, /// must go in ascending order |
| 96 | size_t num_positions_to_hilite) |
| 97 | { |
| 98 | const char * pos = begin; |
| 99 | for (size_t position_to_hilite_idx = 0; position_to_hilite_idx < num_positions_to_hilite; ++position_to_hilite_idx) |
| 100 | { |
| 101 | const char * current_position_to_hilite = positions_to_hilite[position_to_hilite_idx].begin; |
| 102 | |
| 103 | assert(current_position_to_hilite <= end); |
| 104 | assert(current_position_to_hilite >= begin); |
| 105 | |
| 106 | out.write(pos, current_position_to_hilite - pos); |
| 107 | |
| 108 | if (current_position_to_hilite == end) |
| 109 | { |
| 110 | out << "\033[41;1m \033[0m"; |
| 111 | return; |
| 112 | } |
| 113 | else |
| 114 | { |
| 115 | size_t bytes_to_hilite = UTF8::seqLength(*current_position_to_hilite); |
| 116 | |
| 117 | /// Bright on red background. |
| 118 | out << "\033[41;1m"; |
| 119 | out.write(current_position_to_hilite, bytes_to_hilite); |
| 120 | out << "\033[0m"; |
| 121 | pos = current_position_to_hilite + bytes_to_hilite; |
| 122 | } |
| 123 | } |
| 124 | out.write(pos, end - pos); |
| 125 | } |
| 126 | |
| 127 | |
| 128 | void writeQueryAroundTheError( |
no test coverage detected