Branch: Tag:

2009-06-30

2009-06-30 21:39:51 by Martin Stjernholm <mast@lysator.liu.se>

Made the fix more robust.

(Man pages shouldn't be trusted to be completely accurate.)

Rev: src/operators.c:1.248
Rev: src/testsuite.in:1.876

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: 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"
483:    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;   
1629:    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)