Browse Source

Added extra argument to longlong2str() to make it have same prototype is int2str()

Changed to use longlong10_to_str() instead of longlong2str() when base is 10 or -10 as former is much faster than later
Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit.

client/mysqltest.cc:
  longlong2str() -> longlong10_to_str()
include/m_string.h:
  Added extra argument to longlong2str() to make it have same prototype is int2str()
mysys/charset.c:
  Fixed compiler warning
mysys/mf_soundex.c:
  Fixed compiler warning
mysys/my_getopt.c:
  longlong2str() -> longlong10_to_str()
sql/create_options.cc:
  Fixed compiler warning
sql/item_strfunc.cc:
  Added extra argument to longlong2str
sql/opt_range.cc:
  longlong2str() -> longlong10_to_str()
sql/partition_info.cc:
  longlong2str() -> longlong10_to_str()
sql/slave.cc:
  longlong2str() -> longlong10_to_str()
sql/sql_bitmap.h:
  Added extra argument to longlong2str
sql/sql_partition.cc:
  Added extra argument to longlong2str
sql/sql_select.cc:
  longlong2str() -> longlong10_to_str()
sql/sql_show.cc:
  Added extra argument to longlong2str
storage/innodb_plugin/handler/ha_innodb.cc:
  Update to new parameters for longlong2str()
storage/maria/ma_dbug.c:
  longlong2str() -> longlong10_to_str()
storage/maria/maria_chk.c:
  Added extra argument to longlong2str
storage/myisam/mi_dbug.c:
  longlong2str() -> longlong10_to_str()
storage/myisam/myisamchk.c:
  Added extra argument to longlong2str
storage/xtradb/handler/ha_innodb.cc:
  Update to new parameters for longlong2str()
strings/longlong2str.c:
  Added extra argument to longlong2str() to make it have same prototype is int2str()
strings/my_vsnprintf.c:
  Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit.
  Added cast to get rid of compiler warnings
pull/843/head
Michael Widenius 16 years ago
parent
commit
165eb1186c
  1. 4
      client/mysqltest.cc
  2. 4
      include/m_string.h
  3. 4
      mysys/charset.c
  4. 2
      mysys/mf_soundex.c
  5. 2
      mysys/my_getopt.c
  6. 9
      sql/create_options.cc
  7. 4
      sql/item_strfunc.cc
  8. 13
      sql/opt_range.cc
  9. 4
      sql/partition_info.cc
  10. 4
      sql/slave.cc
  11. 2
      sql/sql_bitmap.h
  12. 2
      sql/sql_partition.cc
  13. 8
      sql/sql_select.cc
  14. 2
      sql/sql_show.cc
  15. 6
      storage/innodb_plugin/handler/ha_innodb.cc
  16. 4
      storage/maria/ma_dbug.c
  17. 2
      storage/maria/maria_chk.c
  18. 4
      storage/myisam/mi_dbug.c
  19. 2
      storage/myisam/myisamchk.c
  20. 10
      storage/xtradb/handler/ha_innodb.cc
  21. 7
      strings/longlong2str.c
  22. 14
      strings/my_vsnprintf.c

4
client/mysqltest.cc

@ -7671,7 +7671,7 @@ void mark_progress(struct st_command* command __attribute__((unused)),
die("Out of memory");
/* Milliseconds since start */
end= longlong2str(timer, buf, 10);
end= longlong10_to_str(timer, buf, 10);
dynstr_append_mem(&ds_progress, buf, (int)(end-buf));
dynstr_append_mem(&ds_progress, "\t", 1);
@ -8429,7 +8429,7 @@ void timer_output(void)
{
char buf[32], *end;
ulonglong timer= timer_now() - timer_start;
end= longlong2str(timer, buf, 10);
end= longlong10_to_str(timer, buf, 10);
str_to_file(timer_file,buf, (int) (end-buf));
/* Timer has been written to the file, don't use it anymore */
timer_file= 0;

4
include/m_string.h

@ -210,7 +210,7 @@ extern char *str2int(const char *src,int radix,long lower,long upper,
long *val);
longlong my_strtoll10(const char *nptr, char **endptr, int *error);
#if SIZEOF_LONG == SIZEOF_LONG_LONG
#define longlong2str(A,B,C) int2str((A),(B),(C),1)
#define longlong2str(A,B,C,D) int2str((A),(B),(C),(D))
#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
#undef strtoll
#define strtoll(A,B,C) strtol((A),(B),(C))
@ -223,7 +223,7 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error);
#endif
#else
#ifdef HAVE_LONG_LONG
extern char *longlong2str(longlong val,char *dst,int radix);
extern char *longlong2str(longlong val,char *dst,int radix, int upcase);
extern char *longlong10_to_str(longlong val,char *dst,int radix);
#if (!defined(HAVE_STRTOULL) || defined(NO_STRTOLL_PROTO))
extern longlong strtoll(const char *str, char **ptr, int base);

4
mysys/charset.c

@ -406,9 +406,9 @@ static my_pthread_once_t charsets_template= MY_PTHREAD_ONCE_INIT;
static void init_available_charsets(void)
{
char fname[FN_REFLEN + sizeof(MY_CHARSET_INDEX)];
struct charset_info_st **cs;
struct charset_info_st **cs;
bzero(&all_charsets,sizeof(all_charsets));
bzero((char*) &all_charsets,sizeof(all_charsets));
init_compiled_charsets(MYF(0));
/* Copy compiled charsets */

2
mysys/mf_soundex.c

@ -47,7 +47,7 @@ void soundex(CHARSET_INFO * cs,register char * out_pntr, char * in_pntr,
{
char ch,last_ch;
reg3 char * end;
register uchar *map=cs->to_upper;
register const uchar *map=cs->to_upper;
if (remove_garbage)
{

2
mysys/my_getopt.c

@ -1271,7 +1271,7 @@ void my_print_variables(const struct my_option *options)
printf("%s\n", llstr(*((longlong*) value), buff));
break;
case GET_ULL:
longlong2str(*((ulonglong*) value), buff, 10);
longlong10_to_str(*((ulonglong*) value), buff, 10);
printf("%s\n", buff);
break;
case GET_DOUBLE:

9
sql/create_options.cc

@ -136,9 +136,10 @@ static bool set_one_value(ha_create_table_option *opt,
DBUG_RETURN(0);
}
my_option optp= { opt->name, 1, 0, (uchar **)val, 0, 0, GET_ULL,
REQUIRED_ARG, opt->def_value, opt->min_value, opt->max_value,
0, opt->block_size, 0};
my_option optp=
{ opt->name, 1, 0, (uchar **)val, 0, 0, GET_ULL,
REQUIRED_ARG, opt->def_value, opt->min_value, opt->max_value,
0, (long) opt->block_size, 0};
ulonglong orig_val= strtoull(value->str, NULL, 10);
my_bool unused;
@ -167,7 +168,7 @@ static bool set_one_value(ha_create_table_option *opt,
{
uint *val= (uint *)((char *)base + opt->offset), num;
*val= opt->def_value;
*val= (uint) opt->def_value;
if (!value->str)
DBUG_RETURN(0);

4
sql/item_strfunc.cc

@ -2701,7 +2701,7 @@ String *Item_func_conv::val_str(String *str)
from_base, &endptr, &err);
}
ptr= longlong2str(dec, ans, to_base);
ptr= longlong2str(dec, ans, to_base, 1);
if (str->copy(ans, (uint32) (ptr-ans), default_charset()))
return &my_empty_string;
return str;
@ -2868,7 +2868,7 @@ String *Item_func_hex::val_str(String *str)
if ((null_value= args[0]->null_value))
return 0;
ptr= longlong2str(dec,ans,16);
ptr= longlong2str(dec,ans,16,1);
if (str->copy(ans,(uint32) (ptr-ans),default_charset()))
return &my_empty_string; // End of memory
return str;

13
sql/opt_range.cc

@ -9010,7 +9010,7 @@ void QUICK_RANGE_SELECT::add_keys_and_lengths(String *key_names,
uint length;
KEY *key_info= head->key_info + index;
key_names->append(key_info->name);
length= longlong2str(max_used_key_length, buf, 10) - buf;
length= longlong10_to_str(max_used_key_length, buf, 10) - buf;
used_lengths->append(buf, length);
}
@ -9035,7 +9035,7 @@ void QUICK_INDEX_MERGE_SELECT::add_keys_and_lengths(String *key_names,
KEY *key_info= head->key_info + quick->index;
key_names->append(key_info->name);
length= longlong2str(quick->max_used_key_length, buf, 10) - buf;
length= longlong10_to_str(quick->max_used_key_length, buf, 10) - buf;
used_lengths->append(buf, length);
}
if (pk_quick_select)
@ -9043,7 +9043,8 @@ void QUICK_INDEX_MERGE_SELECT::add_keys_and_lengths(String *key_names,
KEY *key_info= head->key_info + pk_quick_select->index;
key_names->append(',');
key_names->append(key_info->name);
length= longlong2str(pk_quick_select->max_used_key_length, buf, 10) - buf;
length= (longlong10_to_str(pk_quick_select->max_used_key_length, buf, 10)
- buf);
used_lengths->append(',');
used_lengths->append(buf, length);
}
@ -9068,7 +9069,7 @@ void QUICK_ROR_INTERSECT_SELECT::add_keys_and_lengths(String *key_names,
used_lengths->append(',');
}
key_names->append(key_info->name);
length= longlong2str(quick->max_used_key_length, buf, 10) - buf;
length= longlong10_to_str(quick->max_used_key_length, buf, 10) - buf;
used_lengths->append(buf, length);
}
@ -9077,7 +9078,7 @@ void QUICK_ROR_INTERSECT_SELECT::add_keys_and_lengths(String *key_names,
KEY *key_info= head->key_info + cpk_quick->index;
key_names->append(',');
key_names->append(key_info->name);
length= longlong2str(cpk_quick->max_used_key_length, buf, 10) - buf;
length= longlong10_to_str(cpk_quick->max_used_key_length, buf, 10) - buf;
used_lengths->append(',');
used_lengths->append(buf, length);
}
@ -11240,7 +11241,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::add_keys_and_lengths(String *key_names,
char buf[64];
uint length;
key_names->append(index_info->name);
length= longlong2str(max_used_key_length, buf, 10) - buf;
length= longlong10_to_str(max_used_key_length, buf, 10) - buf;
used_lengths->append(buf, length);
}

4
sql/partition_info.cc

@ -1104,8 +1104,8 @@ void partition_info::print_no_partition_found(TABLE *table)
if (part_expr->null_value)
buf_ptr= (char*)"NULL";
else
longlong2str(err_value, buf,
part_expr->unsigned_flag ? 10 : -10);
longlong10_to_str(err_value, buf,
part_expr->unsigned_flag ? 10 : -10);
my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), buf_ptr);
dbug_tmp_restore_column_map(table->read_set, old_map);
}

4
sql/slave.cc

@ -3969,11 +3969,11 @@ bool flush_relay_log_info(Relay_log_info* rli)
my_b_seek(file, 0L);
pos=strmov(buff, rli->group_relay_log_name);
*pos++='\n';
pos=longlong2str(rli->group_relay_log_pos, pos, 10);
pos= longlong10_to_str(rli->group_relay_log_pos, pos, 10);
*pos++='\n';
pos=strmov(pos, rli->group_master_log_name);
*pos++='\n';
pos=longlong2str(rli->group_master_log_pos, pos, 10);
pos=longlong10_to_str(rli->group_master_log_pos, pos, 10);
*pos='\n';
if (my_b_write(file, (uchar*) buff, (size_t) (pos-buff)+1))
error=1;

2
sql/sql_bitmap.h

@ -162,7 +162,7 @@ public:
my_bool is_subset(const Bitmap<64>& map2) const { return !(map & ~map2.map); }
my_bool is_overlapping(const Bitmap<64>& map2) const { return (map & map2.map)!= 0; }
my_bool operator==(const Bitmap<64>& map2) const { return map == map2.map; }
char *print(char *buf) const { longlong2str(map,buf,16); return buf; }
char *print(char *buf) const { longlong2str(map,buf,16,1); return buf; }
ulonglong to_ulonglong() const { return map; }
class Iterator : public Table_map_iterator
{

2
sql/sql_partition.cc

@ -1905,7 +1905,7 @@ static int add_int(File fptr, longlong number)
static int add_uint(File fptr, ulonglong number)
{
char buff[32];
longlong2str(number, buff, 10);
longlong2str(number, buff, 10, 1);
return add_string(fptr, buff);
}

8
sql/sql_select.cc

@ -16859,8 +16859,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
item_list.push_back(new Item_string(key_info->name,
strlen(key_info->name),
system_charset_info));
length= longlong2str(tab->ref.key_length, keylen_str_buf, 10) -
keylen_str_buf;
length= (longlong10_to_str(tab->ref.key_length, keylen_str_buf, 10) -
keylen_str_buf);
item_list.push_back(new Item_string(keylen_str_buf, length,
system_charset_info));
for (store_key **ref=tab->ref.key_copy ; *ref ; ref++)
@ -16878,8 +16878,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
register uint length;
item_list.push_back(new Item_string(key_info->name,
strlen(key_info->name),cs));
length= longlong2str(key_info->key_length, keylen_str_buf, 10) -
keylen_str_buf;
length= (longlong10_to_str(key_info->key_length, keylen_str_buf, 10) -
keylen_str_buf);
item_list.push_back(new Item_string(keylen_str_buf,
length,
system_charset_info));

2
sql/sql_show.cc

@ -1171,7 +1171,7 @@ static bool get_field_default_value(THD *thd, TABLE *table,
if (field_type == MYSQL_TYPE_BIT)
{
longlong dec= field->val_int();
char *ptr= longlong2str(dec, tmp + 2, 2);
char *ptr= longlong2str(dec, tmp + 2, 2, 1);
uint32 length= (uint32) (ptr - tmp);
tmp[0]= 'b';
tmp[1]= '\'';

6
storage/innodb_plugin/handler/ha_innodb.cc

@ -2672,7 +2672,7 @@ innobase_rollback_to_savepoint(
/* TODO: use provided savepoint data area to store savepoint data */
longlong2str((ulint)savepoint, name, 36);
longlong2str((ulint)savepoint, name, 36, 1);
error = (int) trx_rollback_to_savepoint_for_mysql(trx, name,
&mysql_binlog_cache_pos);
@ -2703,7 +2703,7 @@ innobase_release_savepoint(
/* TODO: use provided savepoint data area to store savepoint data */
longlong2str((ulint)savepoint, name, 36);
longlong2str((ulint)savepoint, name, 36, 1);
error = (int) trx_release_savepoint_for_mysql(trx, name);
@ -2750,7 +2750,7 @@ innobase_savepoint(
/* TODO: use provided savepoint data area to store savepoint data */
char name[64];
longlong2str((ulint)savepoint,name,36);
longlong2str((ulint)savepoint,name,36,1);
error = (int) trx_savepoint_for_mysql(trx, name, (ib_int64_t)0);

4
storage/maria/ma_dbug.c

@ -124,7 +124,7 @@ void _ma_print_keydata(FILE *stream, register HA_KEYSEG *keyseg,
case HA_KEYTYPE_LONGLONG:
{
char buff[21];
longlong2str(mi_sint8korr(key),buff,-10);
longlong10_to_str(mi_sint8korr(key),buff,-10);
VOID(fprintf(stream,"%s",buff));
key=end;
break;
@ -132,7 +132,7 @@ void _ma_print_keydata(FILE *stream, register HA_KEYSEG *keyseg,
case HA_KEYTYPE_ULONGLONG:
{
char buff[21];
longlong2str(mi_sint8korr(key),buff,10);
longlong10_to_str(mi_sint8korr(key),buff,10);
VOID(fprintf(stream,"%s",buff));
key=end;
break;

2
storage/maria/maria_chk.c

@ -1512,7 +1512,7 @@ static void descript(HA_CHECK *param, register MARIA_HA *info, char *name)
printf("Recordlength: %16d\n",(int) share->base.pack_reclength);
if (! maria_is_all_keys_active(share->state.key_map, share->base.keys))
{
longlong2str(share->state.key_map,buff,2);
longlong2str(share->state.key_map,buff,2,1);
printf("Using only keys '%s' of %d possibly keys\n",
buff, share->base.keys);
}

4
storage/myisam/mi_dbug.c

@ -118,7 +118,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg,
case HA_KEYTYPE_LONGLONG:
{
char buff[21];
longlong2str(mi_sint8korr(key),buff,-10);
longlong10_to_str(mi_sint8korr(key),buff,-10);
VOID(fprintf(stream,"%s",buff));
key=end;
break;
@ -126,7 +126,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg,
case HA_KEYTYPE_ULONGLONG:
{
char buff[21];
longlong2str(mi_sint8korr(key),buff,10);
longlong10_to_str(mi_sint8korr(key),buff,10);
VOID(fprintf(stream,"%s",buff));
key=end;
break;

2
storage/myisam/myisamchk.c

@ -1314,7 +1314,7 @@ static void descript(HA_CHECK *param, register MI_INFO *info, char * name)
printf("Recordlength: %13d\n",(int) share->base.pack_reclength);
if (! mi_is_all_keys_active(share->state.key_map, share->base.keys))
{
longlong2str(share->state.key_map,buff,2);
longlong2str(share->state.key_map,buff,2,1);
printf("Using only keys '%s' of %d possibly keys\n",
buff, share->base.keys);
}

10
storage/xtradb/handler/ha_innodb.cc

@ -2459,11 +2459,11 @@ innobase_change_buffering_inited_ok:
my_b_seek(&info_file, 0L);
pos=strmov(buff, trx_sys_mysql_relay_log_name);
*pos++='\n';
pos=longlong2str(trx_sys_mysql_relay_log_pos, pos, 10);
pos=longlong10_to_str(trx_sys_mysql_relay_log_pos, pos, 10);
*pos++='\n';
pos=strmov(pos, trx_sys_mysql_master_log_name);
*pos++='\n';
pos=longlong2str(trx_sys_mysql_master_log_pos, pos, 10);
pos=longlong10_to_str(trx_sys_mysql_master_log_pos, pos, 10);
*pos='\n';
if (my_b_write(&info_file, (uchar*) buff, (size_t) (pos-buff)+1))
@ -2931,7 +2931,7 @@ innobase_rollback_to_savepoint(
/* TODO: use provided savepoint data area to store savepoint data */
longlong2str((ulint)savepoint, name, 36);
longlong2str((ulint)savepoint, name, 36, 1);
error = (int) trx_rollback_to_savepoint_for_mysql(trx, name,
&mysql_binlog_cache_pos);
@ -2962,7 +2962,7 @@ innobase_release_savepoint(
/* TODO: use provided savepoint data area to store savepoint data */
longlong2str((ulint)savepoint, name, 36);
longlong2str((ulint)savepoint, name, 36, 1);
error = (int) trx_release_savepoint_for_mysql(trx, name);
@ -3009,7 +3009,7 @@ innobase_savepoint(
/* TODO: use provided savepoint data area to store savepoint data */
char name[64];
longlong2str((ulint)savepoint,name,36);
longlong2str((ulint)savepoint,name,36,1);
error = (int) trx_savepoint_for_mysql(trx, name, (ib_int64_t)0);

7
strings/longlong2str.c

@ -46,11 +46,12 @@
This assumes that longlong multiplication is faster than longlong division.
*/
char *longlong2str(longlong val,char *dst,int radix)
char *longlong2str(longlong val,char *dst,int radix, int upcase)
{
char buffer[65];
register char *p;
long long_val;
const char *dig_vec= upcase ? _dig_vec_upper : _dig_vec_lower;
ulonglong uval= (ulonglong) val;
if (radix < 0)
@ -80,14 +81,14 @@ char *longlong2str(longlong val,char *dst,int radix)
{
ulonglong quo= uval/(uint) radix;
uint rem= (uint) (uval- quo* (uint) radix);
*--p = _dig_vec_upper[rem];
*--p = _dig_vec[rem];
uval= quo;
}
long_val= (long) uval;
while (long_val != 0)
{
long quo= long_val/radix;
*--p = _dig_vec_upper[(uchar) (long_val - quo*radix)];
*--p = _dig_vec[(uchar) (long_val - quo*radix)];
long_val= quo;
}
while ((*dst++ = *p++) != 0) ;

14
strings/my_vsnprintf.c

@ -235,19 +235,19 @@ static char *process_int_arg(char *to, char *end, size_t length,
store_start= buff;
if (arg_type == 'd')
store_end= int10_to_str(par, store_start, -10);
store_end= longlong10_to_str(par, store_start, -10);
else if (arg_type == 'u')
store_end= int10_to_str(par, store_start, 10);
store_end= longlong10_to_str(par, store_start, 10);
else if (arg_type == 'p')
{
store_start[0]= '0';
store_start[1]= 'x';
store_end= int2str(par, store_start + 2, 16, 0);
store_end= longlong2str(par, store_start + 2, 16, 0);
}
else
{
DBUG_ASSERT(arg_type == 'X' || arg_type =='x');
store_end= int2str(par, store_start, 16, (arg_type == 'X'));
store_end= longlong2str(par, store_start, 16, (arg_type == 'X'));
}
if ((res_length= (size_t) (store_end - store_start)) > to_length)
@ -430,9 +430,9 @@ start:
{
/* Integer parameter */
longlong larg;
length= ((print_arr[i].flags & LENGTH_ARG) ?
args_arr[print_arr[i].length].longlong_arg :
(longlong) print_arr[i].length);
length= (int) ((print_arr[i].flags & LENGTH_ARG) ?
args_arr[print_arr[i].length].longlong_arg :
(longlong) print_arr[i].length);
if (args_arr[print_arr[i].arg_idx].have_longlong)
larg = args_arr[print_arr[i].arg_idx].longlong_arg;

Loading…
Cancel
Save