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

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:605:    struct pike_string *num;    LONGEST res;    num = io_read_string( io, len );    if( !num ) return NULL;    push_string( num );    push_int( 256 );    return clone_object( get_auto_bignum_program(), 2 );    }       static void io_add_bignum( IOBuffer *io, struct object *o, int width ) +  ATTRIBUTE((noclone,noinline)); +  +  static void io_add_bignum( IOBuffer *io, struct object *o, int width )    { -  char *p; -  INT_TYPE len; +  unsigned char*d; +  struct pike_string *s;       push_int(256);    apply( o, "digits", 1 );    -  p = Pike_sp[-1].u.string->str; -  len = Pike_sp[-1].u.string->len; +  s = Pike_sp[-1].u.string;    -  if( len > width ) +  if( s->len > width )    Pike_error("Number too large to store in %d bits\n", width*8);    -  if( len < width ) +  d = io_add_space( io, width, 0 ); +  io->len += width; +  +  if( width-s->len )    { -  INT_TYPE null = 0; -  while( len < width ) -  { -  int a = MIN(width-len, (int)sizeof(INT_TYPE)); -  io_append( io, &null, a ); -  width-=a; +  memset( d, 0, width-s->len ); +  d += width-s->len;    } -  } -  io_append( io, p, width ); +  memcpy(d,s->str,s->len);    pop_stack();    }       static void io_add_int_uc( IOBuffer *io, ptrdiff_t i, size_t bytes )    {    unsigned char *x = io->buffer+io->len;    io->len += bytes;    while(bytes--)    {    x[bytes] = i;
pike.git/src/modules/_Stdio/buffer.cmod:1478:    PIKEFUN IOBuffer read_hbuffer( int bytes, int|void copy )    {    LONGEST len;    int do_copy = 0;    IOBuffer *io = THIS;    ONERROR e;       io_rewind_on_error( io, &e );       if( copy ) do_copy = copy->u.integer; -  pop_n_elems(args); +  Pike_sp-=args;       len = io_read_number( io, bytes );    if( len >= 0 && io_avail( io, len ) )    {    push_object( io_read_buffer( io, len, do_copy ) );    io_unset_rewind_on_error( io, &e );    return;    }    CALL_AND_UNSET_ONERROR(e);    push_int(0); -  return; -  /* -  io_read_buffer will not throw here, since io_avail is true. -  */ +     }       /*! @decl IOBuffer read_buffer( int n )    *! @decl IOBuffer read_buffer( int n, bool copy )    *!    *! Same as @[read], but returns the result as an IOBuffer.    *!    *! No data is copied unless @[copy] is specified and true, the new buffer    *! points into the old one.    *!
pike.git/src/modules/_Stdio/buffer.cmod:1516:    *! 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.    */    PIKEFUN IOBuffer read_buffer( int bytes, int|void copy )    {    int do_copy = 0;    struct object *o;    if( copy )    do_copy = copy->u.integer; -  pop_n_elems(args); +  Pike_sp-=args;    if( (o = io_read_buffer( THIS, bytes, do_copy )) )    push_object(o);    else    push_int(0);    }       /*! @decl IOBuffer sprintf(strict_sprintf_format format, sprintf_args ... args)    *!    *! Appends the output from @[sprintf] at the end of the buffer.    *!