Commit ccc41712 authored by monty@mysql.com's avatar monty@mysql.com

Portability fix (using 'char' as argument to C functions may give warnings)

parent be7f1a35
...@@ -225,7 +225,7 @@ extern long strtol(const char *str, char **ptr, int base); ...@@ -225,7 +225,7 @@ extern long strtol(const char *str, char **ptr, int base);
extern ulong strtoul(const char *str, char **ptr, int base); extern ulong strtoul(const char *str, char **ptr, int base);
#endif #endif
extern char *int2str(long val, char *dst, int radix, char upcase); extern char *int2str(long val, char *dst, int radix, int upcase);
extern char *int10_to_str(long val,char *dst,int radix); extern char *int10_to_str(long val,char *dst,int radix);
extern char *str2int(const char *src,int radix,long lower,long upper, extern char *str2int(const char *src,int radix,long lower,long upper,
long *val); long *val);
......
...@@ -385,6 +385,7 @@ select 1; ...@@ -385,6 +385,7 @@ select 1;
1 1
1 1
select @@session.key_buffer_size; select @@session.key_buffer_size;
ERROR HY000: Variable 'key_buffer_size' is a GLOBAL variable
set ft_boolean_syntax = @@init_connect; set ft_boolean_syntax = @@init_connect;
ERROR HY000: Variable 'ft_boolean_syntax' is a GLOBAL variable and should be set with SET GLOBAL ERROR HY000: Variable 'ft_boolean_syntax' is a GLOBAL variable and should be set with SET GLOBAL
set global ft_boolean_syntax = @@init_connect; set global ft_boolean_syntax = @@init_connect;
......
...@@ -34,7 +34,7 @@ char NEAR _dig_vec_lower[] = ...@@ -34,7 +34,7 @@ char NEAR _dig_vec_lower[] =
val - value to convert val - value to convert
dst - points to buffer where string representation should be stored dst - points to buffer where string representation should be stored
radix - radix of scale of notation radix - radix of scale of notation
upcase - flag indicating that whenever we should use upper-case digits upcase - set to 1 if we should use upper-case digits
DESCRIPTION DESCRIPTION
Converts the (long) integer value to its character form and moves it to Converts the (long) integer value to its character form and moves it to
...@@ -52,33 +52,38 @@ char NEAR _dig_vec_lower[] = ...@@ -52,33 +52,38 @@ char NEAR _dig_vec_lower[] =
char * char *
int2str(register long int val, register char *dst, register int radix, int2str(register long int val, register char *dst, register int radix,
char upcase) int upcase)
{ {
char buffer[65]; char buffer[65];
register char *p; register char *p;
long int new_val; long int new_val;
char *dig_vec= upcase ? _dig_vec_upper : _dig_vec_lower; char *dig_vec= upcase ? _dig_vec_upper : _dig_vec_lower;
if (radix < 0) { if (radix < 0)
if (radix < -36 || radix > -2) return NullS; {
if (val < 0) { if (radix < -36 || radix > -2)
return NullS;
if (val < 0)
{
*dst++ = '-'; *dst++ = '-';
val = -val; val = -val;
} }
radix = -radix; radix = -radix;
} else {
if (radix > 36 || radix < 2) return NullS;
} }
/* The slightly contorted code which follows is due to the else if (radix > 36 || radix < 2)
fact that few machines directly support unsigned long / and %. return NullS;
Certainly the VAX C compiler generates a subroutine call. In
the interests of efficiency (hollow laugh) I let this happen /*
for the first digit only; after that "val" will be in range so The slightly contorted code which follows is due to the fact that
that signed integer division will do. Sorry 'bout that. few machines directly support unsigned long / and %. Certainly
CHECK THE CODE PRODUCED BY YOUR C COMPILER. The first % and / the VAX C compiler generates a subroutine call. In the interests
should be unsigned, the second % and / signed, but C compilers of efficiency (hollow laugh) I let this happen for the first digit
tend to be extraordinarily sensitive to minor details of style. only; after that "val" will be in range so that signed integer
This works on a VAX, that's all I claim for it. division will do. Sorry 'bout that. CHECK THE CODE PRODUCED BY
YOUR C COMPILER. The first % and / should be unsigned, the second
% and / signed, but C compilers tend to be extraordinarily
sensitive to minor details of style. This works on a VAX, that's
all I claim for it.
*/ */
p = &buffer[sizeof(buffer)-1]; p = &buffer[sizeof(buffer)-1];
*p = '\0'; *p = '\0';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment