@@ -207,39 +207,39 @@ static void set_buffer_for_string(MYSQL_BIND* bind_buffer, unsigned long *length
207
207
/* return 0 if the given bignum can cast as LONG_LONG, otherwise 1 */
208
208
static int my_big2ll (VALUE bignum , LONG_LONG * ptr )
209
209
{
210
- unsigned LONG_LONG num ;
211
- size_t len ;
212
- int nlz_bits = 0 ;
210
+ unsigned LONG_LONG num ;
211
+ size_t len ;
212
+ int nlz_bits = 0 ;
213
213
#ifdef HAVE_RB_ABSINT_SIZE
214
- len = rb_absint_size (bignum , & nlz_bits );
214
+ len = rb_absint_size (bignum , & nlz_bits );
215
215
#else
216
- len = RBIGNUM_LEN (bignum ) * SIZEOF_BDIGITS ;
216
+ len = RBIGNUM_LEN (bignum ) * SIZEOF_BDIGITS ;
217
217
#endif
218
- if (len > 8 ) goto overflow ;
219
- if (RBIGNUM_POSITIVE_P (bignum )) {
220
- num = rb_big2ull (bignum );
221
- if (num > LLONG_MAX )
222
- goto overflow ;
223
- * ptr = num ;
224
- }
225
- else {
226
- if (len == 8 && nlz_bits == 0 &&
227
- /* only -0x8000000000000000 is safe if `len == 8 && nlz_bits == 0` */
218
+ if (len > 8 ) goto overflow ;
219
+ if (RBIGNUM_POSITIVE_P (bignum )) {
220
+ num = rb_big2ull (bignum );
221
+ if (num > LLONG_MAX )
222
+ goto overflow ;
223
+ * ptr = num ;
224
+ }
225
+ else {
226
+ if (len == 8 && nlz_bits == 0 &&
227
+ /* only -0x8000000000000000 is safe if `len == 8 && nlz_bits == 0` */
228
228
#ifdef HAVE_RB_ABSINT_SINGLEBIT_P
229
- !rb_absint_singlebit_p (bignum )
229
+ !rb_absint_singlebit_p (bignum )
230
230
#elif defined(HAVE_RB_BIG_AND )
231
- rb_big_and (bignum , LL2NUM (LLONG_MAX )) != INT2FIX (0 )
231
+ rb_big_and (bignum , LL2NUM (LLONG_MAX )) != INT2FIX (0 )
232
232
#else
233
- rb_big_cmp (bignum , LL2NUM (LLONG_MIN )) == INT2FIX (-1 )
233
+ rb_big_cmp (bignum , LL2NUM (LLONG_MIN )) == INT2FIX (-1 )
234
234
#endif
235
- ) {
236
- goto overflow ;
237
- }
238
- * ptr = rb_big2ll (bignum );
235
+ ) {
236
+ goto overflow ;
239
237
}
240
- return 0 ;
238
+ * ptr = rb_big2ll (bignum );
239
+ }
240
+ return 0 ;
241
241
overflow :
242
- return 1 ;
242
+ return 1 ;
243
243
}
244
244
245
245
/* call-seq: stmt.execute
@@ -304,21 +304,21 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
304
304
break ;
305
305
case T_BIGNUM :
306
306
{
307
- LONG_LONG num ;
308
- if (my_big2ll (argv [i ], & num ) == 0 ) {
309
- bind_buffers [i ].buffer_type = MYSQL_TYPE_LONGLONG ;
310
- bind_buffers [i ].buffer = xmalloc (sizeof (long long int ));
311
- * (LONG_LONG * )(bind_buffers [i ].buffer ) = num ;
312
- } else {
313
- /* The bignum was larger than we can fit in LONG_LONG, send it as a string */
314
- VALUE rb_val_as_string = rb_big2str (argv [i ], 10 );
315
- bind_buffers [i ].buffer_type = MYSQL_TYPE_NEWDECIMAL ;
316
- params_enc [i ] = rb_val_as_string ;
307
+ LONG_LONG num ;
308
+ if (my_big2ll (argv [i ], & num ) == 0 ) {
309
+ bind_buffers [i ].buffer_type = MYSQL_TYPE_LONGLONG ;
310
+ bind_buffers [i ].buffer = xmalloc (sizeof (long long int ));
311
+ * (LONG_LONG * )(bind_buffers [i ].buffer ) = num ;
312
+ } else {
313
+ /* The bignum was larger than we can fit in LONG_LONG, send it as a string */
314
+ VALUE rb_val_as_string = rb_big2str (argv [i ], 10 );
315
+ bind_buffers [i ].buffer_type = MYSQL_TYPE_NEWDECIMAL ;
316
+ params_enc [i ] = rb_val_as_string ;
317
317
#ifdef HAVE_RUBY_ENCODING_H
318
- params_enc [i ] = rb_str_export_to_enc (params_enc [i ], conn_enc );
318
+ params_enc [i ] = rb_str_export_to_enc (params_enc [i ], conn_enc );
319
319
#endif
320
- set_buffer_for_string (& bind_buffers [i ], & length_buffers [i ], params_enc [i ]);
321
- }
320
+ set_buffer_for_string (& bind_buffers [i ], & length_buffers [i ], params_enc [i ]);
321
+ }
322
322
}
323
323
break ;
324
324
case T_FLOAT :
0 commit comments