Pike v8.1 release 6

Method Stdio.Buffer()->range_error()


Method range_error

protected bool range_error(int howmuch)

Description

This function is called when an attempt is made to read out of bounds.

The default implementation simply returns 0 (zero).

Override this function to change the behavior.

Parameter howmuch

The argument howmuch indicates how much data is needed:

(1..)

Need howmuch bytes more

0

The amount of data needed is not certain. This most often happens when sscanf or read_json is used

(..-1)

Tried to unread -howmuch bytes. There is usually no way to satisfy the requested range.

The only supported way is to extract the data from the buffer, add the requested amount of "go backbuffer", add the data back, and forward -howmuch bytes.

Returns

true if the operation should be retried, false otherwise.

Do not return true unless you have added data to the buffer, doing so could result in an infinite loop (since no data is added, the range_error will be called again immediately).