pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:1:   /* -*- c -*-   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: builtin.cmod,v 1.144 2003/11/14 10:26:43 mast Exp $ + || $Id: builtin.cmod,v 1.145 2003/12/08 11:13:12 nilsson Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin.cmod:1793:       if (!str->str.s && args) {    int sum = 0;    int shift = 0;    for (j=0; j < args; j++) {    struct pike_string *a = Pike_sp[j-args].u.string;    sum += a->len;    shift |= a->size_shift;    }    if (sum < str->initial) { -  sum = str->initial; +  sum = str->initial * 2;    }    shift = shift & ~(shift >> 1);    init_string_builder_alloc(&str->str, sum, shift);    /* We know it will be a string that really is this wide. */    str->str.known_shift = shift;    }       for( j = 0; j<args; j++ )    {    struct pike_string *a = Pike_sp[j-args].u.string;    string_builder_shared_strcat( &str->str, a );    }       if (str->str.s) {    RETURN str->str.s->len;    } else {    RETURN 0;    }    }    -  +  /*! @decl void putchar(int c) +  *! Appends the character @[c] at the end of the string. +  */ +  PIKEFUN void putchar(int c) { +  struct Buffer_struct *str = THIS; +  if(!str->str.s) +  init_string_builder_alloc(&str->str, str->initial, 0); +  string_builder_putchar(&str->str, c); +  } +     /*! @decl string get_copy()    *!    *! Get the data from the buffer. Significantly slower than @[get],    *! but does not clear the buffer.    */    PIKEFUN string get_copy()    {    struct pike_string *str = THIS->str.s;    if( str )    {