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

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:211:    memcpy( io->buffer, old, io->len );    io_unlink_external_storage(io);    }    }       PMOD_EXPORT unsigned char *io_add_space_do_something( Buffer *io, size_t bytes, int force )    ATTRIBUTE((noclone,noinline));    PMOD_EXPORT unsigned char *io_add_space_do_something( Buffer *io, size_t bytes, int force )    {    if( bytes && io->len+bytes < io->len ) -  Pike_error("Too large buffer, can not have more than %lu bytes", +  Pike_error("Too large buffer, can not have more than %lu bytes.",    (size_t)-1);          io_ensure_unlocked(io);    io_ensure_malloced(io, bytes);       /*    * It is actually not certain that checking this is a good idea.    *    * The reason being that if the current buffer size is very small
pike.git/src/modules/_Stdio/buffer.cmod:251:    (io->allocated>>1) +    (io->allocated>>3);/* io->allocated * 0.625 */       if( growth < bytes )    growth = bytes + (bytes>>1);       if( io->allocated + growth < io->allocated )    {    growth = bytes+1;    if( io->allocated + growth < io->allocated ) -  Pike_error("Overflow in buffer size calculations\n"); +  Pike_error("Overflow in buffer size calculations.\n");    }    io->buffer = xrealloc( io->buffer, io->allocated + growth );    io->num_malloc++;    io->allocated += growth;    }    return io->buffer+io->len;    }       /*! @decl protected bool range_error( int howmuch )    *!
pike.git/src/modules/_Stdio/buffer.cmod:678:    {    mpz_init( &tmp );    mpz_add_ui( &tmp, i, 1);    pad = 0xff;    i = &tmp;    }       bytes = (mpz_sizeinbase( i, 2 )+7) / 8;       if( bytes > width ) -  Pike_error("Number too large to store in %d bits\n", width*8); +  Pike_error("Number too large to store in %d bits.\n", width*8);       d = io_add_space( io, width, 0 );    io->len += width;       if( width > bytes )    {    memset( d, pad, width-bytes );    d += width-bytes;    }   
pike.git/src/modules/_Stdio/buffer.cmod:793:    END_CYCLIC();    return len;    }    case PIKE_T_OBJECT: {    size_t len;    if( get_memory_object_memory( p->u.object, NULL, &len, NULL ) )    return len;    break;    }    } -  Pike_error("Illegal argument (not an 8bit string or 8bit buffer object)\n"); +  Pike_error("Illegal argument (not an 8bit string or 8bit buffer object).\n");    }       /* NOTE: Can return negative integers. */    static INT_TYPE get_small_int( struct svalue *s )    ATTRIBUTE((noclone,noinline));       static INT_TYPE get_small_int( struct svalue *s )    {    if( LIKELY(TYPEOF(*s) == PIKE_T_INT) )    return s->u.integer;       if( is_bignum_object_in_svalue( s ) )    {    INT64 i64;    if( int64_from_bignum( &i64, s->u.object ) )    return i64; -  Pike_error("Too big bignum, can not fit in indicated width\n"); +  Pike_error("Too big bignum, can not fit in indicated width.\n");    } -  Pike_error("Non integer argument\n"); +  Pike_error("Non integer argument.\n");    }       static void io_append_svalue( Buffer *io, struct svalue *p )    ATTRIBUTE((noinline));       static void io_append_svalue( Buffer *io, struct svalue *p )    {    switch( TYPEOF(*p) )    {    case PIKE_T_STRING:    {    struct pike_string *s = p->u.string;    if( !s->len ) return; -  if( s->size_shift ) Pike_error("Buffer only handles 8bit data\n"); +  if( s->size_shift ) Pike_error("Buffer only handles 8bit data.\n");    if( !io->buffer )    {   #ifdef PIKE_DEBUG    if (io->str) Pike_fatal("Buffer with string but NULL buffer.\n");   #endif    io->str = s;    io->buffer = (unsigned char*)s->str;    io->len = s->len;    add_ref(s);    io_trigger_output( io );
pike.git/src/modules/_Stdio/buffer.cmod:876:    io->buffer = ptr;    io->len = len;       io->source = p->u.object;    add_ref(io->source);    return;    }    if( t != MEMOBJ_NONE )    io_append( io, ptr, len );    else -  Pike_error("Unsupported argument type\n"); +  Pike_error("Unsupported argument type.\n");    }    break;    case PIKE_T_INT:    {    unsigned char a = p->u.integer;    io_append( io, &a, 1 );    }    }    }   
pike.git/src/modules/_Stdio/buffer.cmod:954:    else    {    /* some other object. Just call read */    while( nbytes )    {    push_int( MINIMUM(READ_CHUNKSIZE, nbytes) );    safe_apply( f, "read", 1 );    if( TYPEOF(Pike_sp[-1]) != PIKE_T_STRING || Pike_sp[-1].u.string->len == 0 )    break;    if( Pike_sp[-1].u.string->size_shift ) -  Pike_error("Can not handle non-8bit data\n"); +  Pike_error("Can not handle non-8bit data.\n");    io_append( io, Pike_sp[-1].u.string->str, Pike_sp[-1].u.string->len );    nbytes -= Pike_sp[-1].u.string->len;    pop_stack();    }    }       if (!bread) RETURN -1;       io_trigger_output( io );   
pike.git/src/modules/_Stdio/buffer.cmod:1406:    int size_size, void|int offset )    {    Buffer *io = THIS;    size_t len = io_svalue_len(io, str);       if( offset )    len += offset->u.integer;       if( size_size < (int)sizeof(size_t) &&    len > (((size_t)1)<<(8*size_size))-1 ) -  Pike_error("Too long string, need larger size field\n"); +  Pike_error("Too long string, need larger size field.\n");       io_add_int( io, len, size_size );    io_append_svalue( io, str );    pop_n_elems(args);    ref_push_object(io->this);    }       /*! @decl Buffer add_int( int i, int(0..) width )    *!    *! Adds a generic integer to the buffer as an (width*8)bit
pike.git/src/modules/_Stdio/buffer.cmod:1502:    int i,l = a->size;    struct svalue *it = a->item;    unsigned char *ptr;    ptrdiff_t n=0;    ONERROR e;    Buffer *io = THIS;       io_unwrite_on_error(io, &e);       if( bpi < 0 ) -  Pike_error("Illegal int width\n"); +  Pike_error("Illegal int width.\n");      #if SIZEOF_LONG == 4    if( DO_INT32_MUL_OVERFLOW( l, bpi, &n ) )   #else    if( DO_INT64_MUL_OVERFLOW( l, bpi, &n ) )   #endif -  Pike_error("Result size exceeds ptrdiff_t size\n"); +  Pike_error("Result size exceeds ptrdiff_t size.\n");       io_add_space( io, n, 0 );    switch( bpi )    {    case 1:    for( i=0; i<l; i++ )    io_append_byte_uc( io, get_small_int(it+i) );    break;    case 2:    for( i=0; i<l; i++ )
pike.git/src/modules/_Stdio/buffer.cmod:1598:    again:    if( io_avail( io, off ) )    {    io_read_pointer(io)[off]=(val&0xff);    }    else    {    /* hm, well. We could extend the buffer. Should we? */    if( io_range_error(io, off ) )    goto again; -  Pike_error("Writing outside buffer\n"); +  Pike_error("Writing outside buffer.\n");    }    }       /*! @decl int _sizeof()    *!    *! Returns the buffer size, in bytes.    *! This is how much you can read from the buffer until it runs out of data.    */    PIKEFUN int(0..) _sizeof()    flags ID_PROTECTED;
pike.git/src/modules/_Stdio/buffer.cmod:2085:    PIKEFUN Buffer sprintf(mixed ... ignored)    rawtype tFuncV(tAttr("strict_sprintf_format", tOr(tStr, tObj)),    tAttr("sprintf_args", tMix), tObjIs_BUFFER);    {    ONERROR _e;    struct string_builder tmp;    init_string_builder(&tmp,0);    SET_ONERROR(_e, free_string_builder, &tmp);    low_f_sprintf(args, &tmp);    if( tmp.s->size_shift ) -  Pike_error("Buffer only handles 8bit data\n"); +  Pike_error("Buffer only handles 8bit data.\n");    io_append( THIS, tmp.s->str, tmp.s->len );    pop_n_elems(args);    CALL_AND_UNSET_ONERROR(_e);    ref_push_object(Pike_fp->current_object);    }       /*! @decl array sscanf(string(8bit) format)    *!    *! Reads data from the beginning of the buffer to match the    *! specifed format, then return an array with the matches.
pike.git/src/modules/_Stdio/buffer.cmod:2175:    if( -stop == (ptrdiff_t)io_len(THIS) || (err && !strncmp(err,"Unterminated",12)))    {    if( io_range_error(THIS,0) )    goto retry;    push_undefined();    }    else    {    /* FIXME: Use real json error? */    if( err ) -  Pike_error("Syntax error in json at offset %d: %s\n", -stop, err ); +  Pike_error("Syntax error in json at offset %d: %s,\n", -stop, err );    else -  Pike_error("Syntax error in json at offset %d\n", -stop ); +  Pike_error("Syntax error in json at offset %d.\n", -stop );    }    }    else    {    if( whites &&    (io_is_whitespace(THIS,stop)<=0 && io_is_whitespace(THIS,stop-1)<=0))    {    if( stop == (ptrdiff_t)io_len(THIS) )    {    if( io_range_error(THIS,0) )    goto retry;    pop_stack();    push_undefined();    }    else -  Pike_error("Missing whitespace between json values at offset %d\n", stop ); +  Pike_error("Missing whitespace between json values at offset %d.\n", stop );    }    else    {    if( whites )    while( io_is_whitespace( THIS, stop ) )    stop++;    io_consume( THIS, stop );    }    }    }