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.236 2009/04/10 11:43:57 grubba Exp $ + || $Id: stralloc.c,v 1.237 2009/11/30 10:08:24 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:2938:    case 'u':    string_builder_append_integer(s, pike_va_int(VA_LIST_ADDR(args), flags), 10,    flags, min_width, precision);    break;    case 'd':    flags |= APPEND_SIGNED;    string_builder_append_integer(s, pike_va_int(VA_LIST_ADDR(args), flags), 10,    flags, min_width, precision);    break;    -  /* FIMXE: TODO: Doubles (ie 'a', 'e', 'E', 'g', 'G'). */ -  +     /* %f used in modules/Image/colors.c. */ -  +  case 'a': +  case 'e': +  case 'E':    case 'f': -  +  case 'g': +  case 'G':    {    double val = va_arg(args, double);    size_t bytes; -  +  char nfmt[] = { '%', fmt[-1], 0 };       if (PIKE_ISNAN(val)) {    /* NaN */    string_builder_strcat(s, "nan");    break;    }    if (val < 0.0) {    string_builder_putchar(s, '-');    val = -val;    } else if (flags & APPEND_SIGNED) {    string_builder_putchar(s, '+');    } -  if (val+val == val) { -  if (val > 0.0) { +  if ((val+val == val) && (val > 0.0)) {    /* Infinity */    string_builder_strcat(s, "inf"); -  } else { -  string_builder_strcat(s, "0.0"); -  } +     break;    }    /* FIXME: Field lengths and precision. */ -  if ((bytes = SNPRINTF(NULL, 0, "%f", val))) { +  if ((bytes = SNPRINTF(NULL, 0, nfmt, val))) {    p_wchar0 *p = string_builder_allocate(s, bytes, 0); -  size_t check = SNPRINTF((char*)p, bytes+1, "%f", val); +  size_t check = SNPRINTF((char*)p, bytes+1, nfmt, val);    if (check != bytes) { -  Pike_fatal("string_builder_vsprintf(): snprintf(%f) is not " -  "trustworthy: %"PRINTSIZET"u != %"PRINTSIZET"u\n", -  val, bytes, check); +  Pike_fatal("string_builder_vsprintf(): snprintf(\"%s\", %f) " +  "is not trustworthy: " +  "%"PRINTSIZET"u != %"PRINTSIZET"u\n", +  nfmt, val, bytes, check);    }    if (s->s->size_shift) {    /* We need to widen the string we just wrote. */    if (s->s->size_shift == 1) {    p_wchar1 *p1 = (p_wchar1 *)p;    while (bytes--) {    p1[bytes] = p[bytes];    }    } else {    p_wchar2 *p2 = (p_wchar2 *)p;
pike.git/src/stralloc.c:2995:    p2[bytes] = p[bytes];    }    }    }    }    }    break;       default:    Pike_fatal("string_builder_vsprintf(): Invalid formatting method: " -  "'%c' 0x%x.\n", fmt[-1], fmt[-1]); +  "\"%%%c\" 0x%x.\n", (fmt[-1] & 0xff), fmt[-1]);    }    break;    }    } else {    const char *start = fmt;    while (*fmt && (*fmt != '%'))    fmt++;    string_builder_binary_strcat(s, start, fmt-start);    }    }
pike.git/src/stralloc.c:3087:    {    while (WIDE_ISSPACE(c))    {    INC_PCHARP(str,1);    c=EXTRACT_PCHARP(str);    }    switch (c)    {    case '-':    neg++; -  case '+': /* fall-through */ +  /* FALL_THROUGH */ +  case '+':    INC_PCHARP(str,1);    c=EXTRACT_PCHARP(str);    }    }       if (!base)    {    if (c != '0')    base = 10;    else if (INDEX_PCHARP(str,1) == 'x' || INDEX_PCHARP(str,1) == 'X')