pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:1:   /*   || 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: stralloc.c,v 1.208 2006/03/20 18:39:16 grubba Exp $ + || $Id: stralloc.c,v 1.209 2006/03/20 18:57:00 grubba Exp $   */      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "dynamic_buffer.h"   #include "pike_macros.h"   #include "pike_memory.h"   #include "pike_error.h"   #include "gc.h"
pike.git/src/stralloc.c:2437:   {    string_build_mkspace(s,str->len,str->size_shift);       pike_string_cpy(MKPCHARP_STR_OFF(s->s,s->s->len), str);    s->known_shift=MAXIMUM(s->known_shift,str->size_shift);    s->s->len+=str->len;    /* Ensure NUL-termination */    s->s->str[s->s->len << s->s->size_shift] = 0;   }    - PMOD_EXPORT void string_builder_quote_string(struct string_builder *buf, + PMOD_EXPORT ptrdiff_t string_builder_quote_string(struct string_builder *buf,    struct pike_string *str, -  int flags, ptrdiff_t max_len) +  ptrdiff_t i, +  ptrdiff_t max_len, +  int flags)   {    ptrdiff_t old_len = buf->s->len; -  ptrdiff_t i; +     -  for (i = 0; i < str->len; i++) { +  for (; i < str->len; i++) {    p_wchar2 ch = index_shared_string(str, i);    if (ch > 0xffff) {    /* Huge character. */    string_builder_binary_strcat(buf, "\\U", 2);    string_builder_append_integer(buf, ch, 16, APPEND_ZERO_PAD, 8, 8);    } else if (ch > 0xff) {    /* Unicode character. */    string_builder_binary_strcat(buf, "\\u", 2);    string_builder_append_integer(buf, ch, 16, APPEND_ZERO_PAD, 4, 4);    } else if (ch & 0x60) {
pike.git/src/stralloc.c:2470:    } else if ((ch == '"') || (ch == '\\')) {    string_builder_putchar(buf, '\\');    }    string_builder_putchar(buf, ch);    } else {    p_wchar2 next_ch;    /* Control character. */    string_builder_putchar(buf, '\\');    if ((ch > 6) && (ch < 14)) {    string_builder_putchar(buf, "0123456abtnvfr"[ch]); +  if ((ch == 10) && (flags & QUOTE_BREAK_AT_LF)) { +  if (buf->s->len > max_len) { +  /* Too bad; no place for the lf. */ +  buf->s->len = old_len; +  return i; +  } +  return i+1; +  }    goto next;    }    if (ch == 27) {    string_builder_putchar(buf, 'e');    goto next;    }    /* Check if we can use an octal escape. */    if ((i+1 < str->len) &&    ((next_ch = index_shared_string(str, i+1)) >= '0') &&    (next_ch <= '7')) {
pike.git/src/stralloc.c:2495:    string_builder_append_integer(buf, ch, 8, 0, 1, 1);    string_builder_binary_strcat(buf, "\"\"", 2);    }    goto next;    }    string_builder_append_integer(buf, ch, 8, 0, 1, 1);    }    next:    if (buf->s->len > max_len) {    buf->s->len = old_len; -  break; +  return i;    }    old_len = buf->s->len;    } -  +  return i;   }      PMOD_EXPORT void string_builder_append_integer(struct string_builder *s,    LONGEST val,    unsigned int base,    int flags,    size_t min_width,    size_t precision)   {    unsigned LONGEST tmp;