~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/int2str.c

  • Committer: Monty Taylor
  • Date: 2008-07-31 19:56:51 UTC
  • mto: (202.3.5 gettextize)
  • mto: This revision was merged to the branch mainline in revision 243.
  • Revision ID: monty@inaugust.com-20080731195651-8rolsypajn99uc2p
Some cleanups/decoupling in mystring.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    optimized int10_to_str() function.
46
46
 
47
47
  RETURN VALUE
48
 
    Pointer to ending NUL character or NullS if radix is bad.
 
48
    Pointer to ending NUL character or (char *)0 if radix is bad.
49
49
*/
50
50
  
51
51
char *
56
56
  register char *p;
57
57
  long int new_val;
58
58
  char *dig_vec= upcase ? _dig_vec_upper : _dig_vec_lower;
59
 
  ulong uval= (ulong) val;
 
59
  unsigned long uval= (unsigned long) val;
60
60
 
61
61
  if (radix < 0)
62
62
  {
63
63
    if (radix < -36 || radix > -2)
64
 
      return NullS;
 
64
      return (char *)0;
65
65
    if (val < 0)
66
66
    {
67
67
      *dst++ = '-';
68
68
      /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */
69
 
      uval = (ulong)0 - uval;
 
69
      uval = (unsigned long)0 - uval;
70
70
    }
71
71
    radix = -radix;
72
72
  }
73
73
  else if (radix > 36 || radix < 2)
74
 
    return NullS;
 
74
    return (char *)0;
75
75
 
76
76
  /*
77
77
    The slightly contorted code which follows is due to the fact that
87
87
  */
88
88
  p = &buffer[sizeof(buffer)-1];
89
89
  *p = '\0';
90
 
  new_val= uval / (ulong) radix;
91
 
  *--p = dig_vec[(uchar) (uval- (ulong) new_val*(ulong) radix)];
 
90
  new_val= uval / (unsigned long) radix;
 
91
  *--p = dig_vec[(unsigned char) (uval- (unsigned long) new_val*(unsigned long) radix)];
92
92
  val = new_val;
93
93
#ifdef HAVE_LDIV
94
94
  while (val != 0)
102
102
  while (val != 0)
103
103
  {
104
104
    new_val=val/radix;
105
 
    *--p = dig_vec[(uchar) (val-new_val*radix)];
 
105
    *--p = dig_vec[(unsigned char) (val-new_val*radix)];
106
106
    val= new_val;
107
107
  }
108
108
#endif