Reworked x_scan_next_buffer() functions to better use buffer struct.

A step towards extracting the generic scan function from the two
specific lexer functions.