~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/field/long.cc

  • Committer: Brian Aker
  • Date: 2008-07-22 18:31:32 UTC
  • Revision ID: brian@tangent.org-20080722183132-ne2ntl7g7mdf2eez
uint32 -> uin32_t

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
int Field_long::store(double nr)
52
52
{
53
53
  int error= 0;
54
 
  int32 res;
 
54
  int32_t res;
55
55
  nr=rint(nr);
56
56
  if (unsigned_flag)
57
57
  {
67
67
      error= 1;
68
68
    }
69
69
    else
70
 
      res=(int32) (ulong) nr;
 
70
      res=(int32_t) (ulong) nr;
71
71
  }
72
72
  else
73
73
  {
74
74
    if (nr < (double) INT32_MIN)
75
75
    {
76
 
      res=(int32) INT32_MIN;
 
76
      res=(int32_t) INT32_MIN;
77
77
      error= 1;
78
78
    }
79
79
    else if (nr > (double) INT32_MAX)
80
80
    {
81
 
      res=(int32) INT32_MAX;
 
81
      res=(int32_t) INT32_MAX;
82
82
      error= 1;
83
83
    }
84
84
    else
85
 
      res=(int32) (int64_t) nr;
 
85
      res=(int32_t) (int64_t) nr;
86
86
  }
87
87
  if (error)
88
88
    set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
102
102
int Field_long::store(int64_t nr, bool unsigned_val)
103
103
{
104
104
  int error= 0;
105
 
  int32 res;
 
105
  int32_t res;
106
106
 
107
107
  if (unsigned_flag)
108
108
  {
113
113
    }
114
114
    else if ((uint64_t) nr >= (1LL << 32))
115
115
    {
116
 
      res=(int32) (uint32) ~0L;
 
116
      res=(int32_t) (uint32_t) ~0L;
117
117
      error= 1;
118
118
    }
119
119
    else
120
 
      res=(int32) (uint32) nr;
 
120
      res=(int32_t) (uint32_t) nr;
121
121
  }
122
122
  else
123
123
  {
125
125
      nr= ((int64_t) INT32_MAX) + 1;           // Generate overflow
126
126
    if (nr < (int64_t) INT32_MIN) 
127
127
    {
128
 
      res=(int32) INT32_MIN;
 
128
      res=(int32_t) INT32_MIN;
129
129
      error= 1;
130
130
    }
131
131
    else if (nr > (int64_t) INT32_MAX)
132
132
    {
133
 
      res=(int32) INT32_MAX;
 
133
      res=(int32_t) INT32_MAX;
134
134
      error= 1;
135
135
    }
136
136
    else
137
 
      res=(int32) nr;
 
137
      res=(int32_t) nr;
138
138
  }
139
139
  if (error)
140
140
    set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
153
153
 
154
154
double Field_long::val_real(void)
155
155
{
156
 
  int32 j;
 
156
  int32_t j;
157
157
#ifdef WORDS_BIGENDIAN
158
158
  if (table->s->db_low_byte_first)
159
159
    j=sint4korr(ptr);
160
160
  else
161
161
#endif
162
162
    longget(j,ptr);
163
 
  return unsigned_flag ? (double) (uint32) j : (double) j;
 
163
  return unsigned_flag ? (double) (uint32_t) j : (double) j;
164
164
}
165
165
 
166
166
int64_t Field_long::val_int(void)
167
167
{
168
 
  int32 j;
 
168
  int32_t j;
169
169
  /* See the comment in Field_long::store(long long) */
170
170
  assert(table->in_use == current_thd);
171
171
#ifdef WORDS_BIGENDIAN
174
174
  else
175
175
#endif
176
176
    longget(j,ptr);
177
 
  return unsigned_flag ? (int64_t) (uint32) j : (int64_t) j;
 
177
  return unsigned_flag ? (int64_t) (uint32_t) j : (int64_t) j;
178
178
}
179
179
 
180
180
String *Field_long::val_str(String *val_buffer,
185
185
  uint mlength=max(field_length+1,12*cs->mbmaxlen);
186
186
  val_buffer->alloc(mlength);
187
187
  char *to=(char*) val_buffer->ptr();
188
 
  int32 j;
 
188
  int32_t j;
189
189
#ifdef WORDS_BIGENDIAN
190
190
  if (table->s->db_low_byte_first)
191
191
    j=sint4korr(ptr);
194
194
    longget(j,ptr);
195
195
 
196
196
  if (unsigned_flag)
197
 
    length=cs->cset->long10_to_str(cs,to,mlength, 10,(long) (uint32)j);
 
197
    length=cs->cset->long10_to_str(cs,to,mlength, 10,(long) (uint32_t)j);
198
198
  else
199
199
    length=cs->cset->long10_to_str(cs,to,mlength,-10,(long) j);
200
200
  val_buffer->length(length);
211
211
 
212
212
int Field_long::cmp(const uchar *a_ptr, const uchar *b_ptr)
213
213
{
214
 
  int32 a,b;
 
214
  int32_t a,b;
215
215
#ifdef WORDS_BIGENDIAN
216
216
  if (table->s->db_low_byte_first)
217
217
  {
225
225
    longget(b,b_ptr);
226
226
  }
227
227
  if (unsigned_flag)
228
 
    return ((uint32) a < (uint32) b) ? -1 : ((uint32) a > (uint32) b) ? 1 : 0;
 
228
    return ((uint32_t) a < (uint32_t) b) ? -1 : ((uint32_t) a > (uint32_t) b) ? 1 : 0;
229
229
  return (a < b) ? -1 : (a > b) ? 1 : 0;
230
230
}
231
231