Get the next character in the buffer, filling it from FP if necessary. If an invalid multi-byte character is seen, we assume the program wants to fall back to the read byte. */
| 148 | If an invalid multi-byte character is seen, we assume the program wants to |
| 149 | fall back to the read byte. */ |
| 150 | MBBUF_INLINE mcel_t |
| 151 | mbbuf_get_char (mbbuf_t *mbbuf) |
| 152 | { |
| 153 | idx_t available = mbbuf_fill (mbbuf); |
| 154 | if (available <= 0) |
| 155 | return (mcel_t) { .ch = MBBUF_EOF }; |
| 156 | mcel_t g = mcel_scan (mbbuf->buffer + mbbuf->offset, |
| 157 | mbbuf->buffer + mbbuf->length); |
| 158 | if (! g.err) |
| 159 | mbbuf->offset += g.len; |
| 160 | else |
| 161 | { |
| 162 | /* Assume the program will emit the byte, but keep the error flag. */ |
| 163 | g.ch = (unsigned char) mbbuf->buffer[mbbuf->offset++]; |
| 164 | } |
| 165 | return g; |
| 166 | } |
| 167 | |
| 168 | /* Returns a pointer to the first byte in the previously read character from |
| 169 | mbbuf_get_char. */ |
no test coverage detected