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.246 2009/02/06 00:47:01 srb Exp $ + || $Id: operators.c,v 1.247 2009/06/30 14:14:57 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:150:   #endif /* AUTO_BIGNUM */       default:    index_error:    if (ind->type == T_INT)    Pike_error ("Cannot index %s with %"PRINTPIKEINT"d.\n",    (what->type == T_INT && !what->u.integer)?    "the NULL value":get_name_of_type(what->type),    ind->u.integer);    else if (ind->type == T_FLOAT) -  Pike_error ("Cannot index %s with %"PRINTPIKEFLOAT"g.\n", +  Pike_error ("Cannot index %s with %"PRINTPIKEFLOAT"e.\n",    (what->type == T_INT && !what->u.integer)?    "the NULL value":get_name_of_type(what->type),    ind->u.float_number);    else if (ind->type == T_STRING)    Pike_error ("Cannot index %s with \"%S\".\n",    (what->type == T_INT && !what->u.integer)?    "the NULL value":get_name_of_type(what->type),    ind->u.string);    else    Pike_error ("Cannot index %s with %s.\n",
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, '.')) +  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:1614: Inside #if defined(PIKE_DEBUG)
   if (strlen (buffer) > MAX_INT_SPRINTF_LEN)    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, '.')) +  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)    {