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

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:575:    return b;    }       static int io_read_byte_uc( Buffer *io )    {    return io->buffer[io->offset++];    }       static INT_TYPE io_read_number_uc( Buffer *io, size_t len )    { -  LONGEST res = 0; +  INT_TYPE res = 0;    while( LIKELY(len--) ) {    res <<= 8;    res |= io_read_byte_uc(io);    }    return res;    }       static INT_TYPE io_read_signed_number_uc( Buffer *io, size_t len )    {    INT_TYPE res = 0;    if( LIKELY(len--) ) {    res = (INT8)io_read_byte_uc(io);    while( LIKELY(len--) ) {    res <<= 8;    res |= io_read_byte_uc(io);    }    }    return res;    }    -  static LONGEST io_read_number( Buffer *io, size_t len ) +  static INT64 io_read_number( Buffer *io, size_t len )    { -  LONGEST res; +  INT64 res;    if( !io_avail(io, len) )    return -1;    /* ensure only leading 0:s */    for (; UNLIKELY(len > SIZEOF_INT_TYPE); len--)    if( UNLIKELY(io_read_byte_uc(io)) )    Pike_error("Integer (%dbit) overflow.\n", SIZEOF_INT_TYPE*8);       res = io_read_number_uc( io, len );       if ( UNLIKELY(res < 0) )    Pike_error("Signed (%dbit) overflow.\n", SIZEOF_INT_TYPE*8);    return res;    }       static struct object *io_read_bignum( Buffer *io, size_t len )    {    struct object *o;    MP_INT *i;    unsigned char *p; -  LONGEST res; +        if( !io_avail(io,len) ) return NULL;    o = fast_clone_object(bignum_program);    i = (void*)o->storage;    mpz_import( i, len, 1, 1, 0, 0, io_read_pointer(io) );    io_consume(io,len);    return o;    }       static void io_add_bignum( Buffer *io, struct object *o, int width )
pike.git/src/modules/_Stdio/buffer.cmod:1679:    *! @[offset] is substracted from the specified length prior to reading the    *! string. Typical usage involves substracting @[n] to account    *! for the room used by the size.    *!    *! If there is not enough data available return 0.    *!    *! Note that pike string can not be longer than 0x7fffffff bytes (~2Gb).    */    PIKEFUN string(0..255) read_hstring( int bytes, void|int offset )    { -  LONGEST len; +  INT64 len;    Buffer *io = THIS;    struct pike_string *s;    ONERROR e;       io_rewind_on_error( io, &e );    len = io_read_number( io, bytes );       if (offset)    len -= offset->u.integer;   
pike.git/src/modules/_Stdio/buffer.cmod:1724:    *!    *! If there is not enough data available return UNDEFINED.    *!    *! Note that pike string can not be longer than 0x7fffffff bytes (~2Gb).    *!    *! @param sentinel    *! A different character can be used as end sentinel of the string.    */    PIKEFUN string(0..255) read_cstring(void|int sentinel)    { -  LONGEST len; +  INT64 len;    Buffer *io = THIS;    struct pike_string *s;    ONERROR e;    int end = 0;    if( sentinel )    end = sentinel->u.integer;       io_rewind_on_error( io, &e );    len = 0;    do {
pike.git/src/modules/_Stdio/buffer.cmod:1781:    *!    *! Usually this is OK, since it often represents something that    *! should be parsed before the next whatever is extracted from    *! the buffer, but do take care.    *!    *! If you need to unlink the new buffer after it has been    *! created, call @[trim] in it.    */    PIKEFUN Buffer read_hbuffer( int bytes, int|void copy )    { -  LONGEST len; +  INT64 len;    int do_copy = 0;    Buffer *io = THIS;    ONERROR e;       io_rewind_on_error( io, &e );       if( copy ) do_copy = copy->u.integer;    Pike_sp-=args;       len = io_read_number( io, bytes );