~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/decimal.c

  • Committer: Brian Aker
  • Date: 2008-08-10 17:18:41 UTC
  • mfrom: (287.3.13 codestyle)
  • Revision ID: brian@tangent.org-20080810171841-pkvi2ky94wbd0nt5
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#line 18 "decimal.c"
17
 
 
18
16
/*
19
17
=======================================================================
20
18
  NOTE: this library implements SQL standard "exact numeric" type
231
229
  to->sign= 0;
232
230
  if ((intpart= to->intg= (precision - frac)))
233
231
  {
234
 
    int firstdigits= intpart % DIG_PER_DEC1;
 
232
    const int firstdigits= intpart % DIG_PER_DEC1;
235
233
    if (firstdigits)
236
234
      *buf++= powers10[firstdigits] - 1; /* get 9 99 999 ... */
237
235
    for(intpart/= DIG_PER_DEC1; intpart; intpart--)
240
238
 
241
239
  if ((to->frac= frac))
242
240
  {
243
 
    int lastdigits= frac % DIG_PER_DEC1;
 
241
    const int lastdigits= frac % DIG_PER_DEC1;
244
242
    for(frac/= DIG_PER_DEC1; frac; frac--)
245
243
      *buf++= DIG_MAX;
246
244
    if (lastdigits)
783
781
*/
784
782
 
785
783
int
786
 
internal_str2dec(const char *from, decimal_t *to, char **end, bool fixed)
 
784
internal_str2dec(char *from, decimal_t *to, char **end, bool fixed)
787
785
{
788
 
  const char *s= from, *s1, *endp, *end_of_string= *end;
 
786
  char *s= from, *s1;
 
787
  char *end_of_string = *end;
 
788
  char *endp;
789
789
  int i, intg, frac, error, intg1, frac1;
790
790
  dec1 x,*buf;
791
791
  sanity(to);
818
818
    endp= s;
819
819
  }
820
820
 
821
 
  *end= (char*) endp;
 
821
  *end= endp;
822
822
 
823
823
  if (frac+intg == 0)
824
824
    goto fatal_error;
896
896
  if (endp+1 < end_of_string && (*endp == 'e' || *endp == 'E'))
897
897
  {
898
898
    int str_error;
899
 
    int64_t exponent= my_strtoll10(endp+1, (char**) &end_of_string,
 
899
    const int64_t exponent= my_strtoll10(endp+1, (char**) &end_of_string,
900
900
                                    &str_error);
901
901
 
902
902
    if (end_of_string != endp +1)               /* If at least one digit */