pike.git / src / modules / _Stdio / buffer.cmod

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:188:    io->buffer = xrealloc( io->buffer, new_len );    io->allocated = new_len;    }    return io->buffer+io->len;    }          /*! @decl protected bool range_error( int howmuch )    *!    *! This function is called when an attempt is made to read out of bounds. -  *! The default implementation simply returnns 0. +     *! -  *! Override this function to change the behaviour +  *! The default implementation simply returns @expr{0@} (zero).    *! -  +  *! Override this function to change the behavior. +  *! +  *! @param howmuch    *! The argument @[howmuch] indicates how much data is needed:    *! -  *! @dl -  *! @item int(1..) howmuch -  *! Need @[howmuch] bytes more -  *! @item int(0..0) howmuch -  *! The amount of data needed is not certain. -  *! This most often happens when @[sscanf] or @[read_json] is used -  *! @item int(..-1) howmuch=... -  *! Tried to @[unread] X bytes. There is usually no way to satisfy -  *! the requested range. +  *! @int +  *! @value 1.. +  *! Need @[howmuch] bytes more +  *! @value 0 howmuch +  *! The amount of data needed is not certain. +  *! This most often happens when @[sscanf] or @[read_json] is used +  *! @value ..-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. -  *! @enddl +  *! 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. +  *! @endint    *!    *! @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).    */    PIKEFUN int(0..1) range_error( int howmuch )
pike.git/src/modules/_Stdio/buffer.cmod:229:    {    /* Default: throw error if so desired, otherwise return 0. */    pop_n_elems(args);    push_int(0);    }       static void io_range_error_throw( IOBuffer *io, int howmuch )    {    if( io->error_mode )    { -  if( howmuch ) +  if( howmuch > 0 )    { -  push_text("Trying to read %d outside allowed range\n"); +  push_text("Trying to read %d bytes outside allowed range\n");    push_int(howmuch);    f_sprintf(2);    }    else    push_text("Illegal arguments\n");       ref_push_object( io->this );    push_object(clone_object(io->error_mode, 2));    f_throw(1);    }