Branch: Tag:

2003-12-08

2003-12-08 11:13:12 by Martin Nilsson <mani@lysator.liu.se>

If the first string addition to the String.Buffer is larger than the initial value, initialize the buffer to be twice as big. Added putchar to String.Buffer.

Rev: src/builtin.cmod:1.145

2:   || 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"
1800:    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);
1821:    }    }    +  /*! @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],