pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.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: operators.c,v 1.247 2009/06/30 14:14:57 mast Exp $ + || $Id: operators.c,v 1.248 2009/06/30 21:39:51 mast Exp $   */      #include "global.h"   #include <math.h>   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"   #include "mapping.h"   #include "array.h"   #include "stralloc.h"
pike.git/src/operators.c:476:       default:    Pike_error("Cannot cast %s to string.\n", get_name_of_type(sp[-1].type));       case PIKE_T_STRING:    return;       case T_FLOAT:    sprintf(buf,"%.*"PRINTPIKEFLOAT"g",    MAX_FLOAT_PREC_LEN, sp[-1].u.float_number); -  /* Ensure that a decimal point gets printed, since "g" removes it -  * completely if only zeroes would follow. Don't need to check for -  * an 'e', since if that is printed then "g" behaved like the "e" -  * format, and it always prints a '.' if the precision isn't -  * zero. */ -  if (!strchr (buf, '.')) +  /* Ensure that either an exponent or a decimal point gets printed, +  * since %g can remove both which would make it look like an integer. */ +  if (!strchr (buf, '.') && !strchr (buf, 'e'))    strcat (buf, ".0");    break;       case T_INT:    sprintf(buf, "%"PRINTPIKEINT"d", sp[-1].u.integer);    break;    }       sp[-1].type = PIKE_T_STRING;    sp[-1].u.string = make_shared_string(buf);
pike.git/src/operators.c:1622: Inside #if defined(PIKE_DEBUG)
   Pike_fatal ("Formatted integer %s is %"PRINTSIZET"u, "    "longer than assumed max %"PRINTSIZET"u.\n",    buffer, strlen (buffer), MAX_INT_SPRINTF_LEN);   #endif    goto append_buffer;       case T_FLOAT:    sprintf(buffer,"%.*"PRINTPIKEFLOAT"g",    MAX_FLOAT_PREC_LEN, sp[e].u.float_number);    /* See comment for T_FLOAT in o_cast_to_string. */ -  if (!strchr (buffer, '.')) +  if (!strchr (buffer, '.') && !strchr (buffer, 'e'))    strcat (buffer, ".0");   #ifdef PIKE_DEBUG    if (strlen (buffer) > MAX_FLOAT_SPRINTF_LEN)    Pike_fatal ("Formatted float %s is %"PRINTSIZET"u, "    "longer than assumed max %"PRINTSIZET"u.\n",    buffer, strlen (buffer), MAX_FLOAT_SPRINTF_LEN);   #endif       append_buffer:    switch(max_shift)