~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/sql_string.cc

  • Committer: Stewart Smith
  • Date: 2008-07-09 01:40:54 UTC
  • mfrom: (105 drizzle)
  • mto: This revision was merged to the branch mainline in revision 111.
  • Revision ID: stewart@flamingspork.com-20080709014054-xfgfzirbhqzrzkkj
mergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
    uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME
129
129
    return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
130
130
  }
131
 
#ifdef HAVE_FCONVERT
132
 
  int decpt,sign;
133
 
  char *pos,*to;
134
 
 
135
 
  VOID(fconvert(num,(int) decimals,&decpt,&sign,buff+1));
136
 
  if (!my_isdigit(&my_charset_latin1, buff[1]))
137
 
  {                                             // Nan or Inf
138
 
    pos=buff+1;
139
 
    if (sign)
140
 
    {
141
 
      buff[0]='-';
142
 
      pos=buff;
143
 
    }
144
 
    uint dummy_errors;
145
 
    return copy(pos,(uint32) strlen(pos), &my_charset_latin1, cs, &dummy_errors);
146
 
  }
147
 
  if (alloc((uint32) ((uint32) decpt+3+decimals)))
148
 
    return TRUE;
149
 
  to=Ptr;
150
 
  if (sign)
151
 
    *to++='-';
152
 
 
153
 
  pos=buff+1;
154
 
  if (decpt < 0)
155
 
  {                                     /* value is < 0 */
156
 
    *to++='0';
157
 
    if (!decimals)
158
 
      goto end;
159
 
    *to++='.';
160
 
    if ((uint32) -decpt > decimals)
161
 
      decpt= - (int) decimals;
162
 
    decimals=(uint32) ((int) decimals+decpt);
163
 
    while (decpt++ < 0)
164
 
      *to++='0';
165
 
  }
166
 
  else if (decpt == 0)
167
 
  {
168
 
    *to++= '0';
169
 
    if (!decimals)
170
 
      goto end;
171
 
    *to++='.';
172
 
  }
173
 
  else
174
 
  {
175
 
    while (decpt-- > 0)
176
 
      *to++= *pos++;
177
 
    if (!decimals)
178
 
      goto end;
179
 
    *to++='.';
180
 
  }
181
 
  while (decimals--)
182
 
    *to++= *pos++;
183
 
 
184
 
end:
185
 
  *to=0;
186
 
  str_length=(uint32) (to-Ptr);
187
 
  return FALSE;
188
 
#else
189
131
#ifdef HAVE_SNPRINTF
190
132
  buff[sizeof(buff)-1]=0;                       // Safety
191
133
  snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num);
194
136
#endif
195
137
  return copy(buff,(uint32) strlen(buff), &my_charset_latin1, cs,
196
138
              &dummy_errors);
197
 
#endif
198
139
}
199
140
 
200
141