~ubuntu-branches/debian/squeeze/mysql-5.1/squeeze

« back to all changes in this revision

Viewing changes to client/sql_string.cc

  • Committer: Package Import Robot
  • Author(s): Moritz Muehlenhoff
  • Date: 2014-01-14 10:40:30 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140114104030-44alii0hx3x3g41y
Tags: 5.1.73-1
* New upstream release
  http://dev.mysql.com/doc/relnotes/mysql/5.1/en/news-5-1-73.html
* Update patches
* Disable flaky test rpl.rpl_innodb_bug28430 breaking the build. It's  marked
  as experimental by upstream and the internet is full of reports about it's
  unrelialibity

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
 
1
/*
 
2
   Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
/* This file is originally from the mysql distribution. Coded by monty */
17
19
 
116
118
 
117
119
bool String::set(double num,uint decimals, CHARSET_INFO *cs)
118
120
{
119
 
  char buff[331];
 
121
  char buff[FLOATING_POINT_BUFFER];
120
122
  uint dummy_errors;
121
123
 
122
124
  str_charset=cs;
123
125
  if (decimals >= NOT_FIXED_DEC)
124
126
  {
125
 
    uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
 
127
    // Enough for a DATETIME
 
128
    uint32 len= sprintf(buff, "%.15g", num);
126
129
    return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
127
130
  }
128
131
#ifdef HAVE_FCONVERT
185
188
#else
186
189
#ifdef HAVE_SNPRINTF
187
190
  buff[sizeof(buff)-1]=0;                       // Safety
188
 
  snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num);
 
191
  IF_DBUG(int num_chars= )
 
192
    snprintf(buff, sizeof(buff)-1, "%.*f",(int) decimals, num);
 
193
  DBUG_ASSERT(num_chars > 0);
 
194
  DBUG_ASSERT(num_chars < (int) sizeof(buff));
189
195
#else
190
196
  sprintf(buff,"%.*f",(int) decimals,num);
191
197
#endif
674
680
void String::qs_append(double d)
675
681
{
676
682
  char *buff = Ptr + str_length;
677
 
  str_length+= my_sprintf(buff, (buff, "%.15g", d));
 
683
  str_length+= sprintf(buff, buff, "%.15g", d);
678
684
}
679
685
 
680
686
void String::qs_append(double *d)
755
761
{
756
762
  if (from->Alloced_length >= from_length)
757
763
    return from;
758
 
  if (from->alloced || !to || from == to)
 
764
  if ((from->alloced && (from->Alloced_length != 0)) || !to || from == to)
759
765
  {
760
766
    (void) from->realloc(from_length);
761
767
    return from;