mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 15:26:23 -05:00
FIX: 'insert-string &add -1 -2147483647' was '-./,),(-*,(' instead of '-2147483648'.
This commit is contained in:
parent
4a0759fa89
commit
90c170e200
31
eval.c
31
eval.c
@ -1076,33 +1076,28 @@ static int svar(struct variable_description *var, char *value)
|
|||||||
*
|
*
|
||||||
* int i; integer to translate to a string
|
* int i; integer to translate to a string
|
||||||
*/
|
*/
|
||||||
char *i_to_a(int i)
|
char *i_to_a( int i) {
|
||||||
{
|
unsigned u ;
|
||||||
#define INTWIDTH sizeof( int) * 3
|
|
||||||
|
|
||||||
char *sp; /* pointer into result */
|
|
||||||
int sign ; /* sign of resulting number */
|
int sign ; /* sign of resulting number */
|
||||||
static char result[INTWIDTH + 1]; /* resulting string */
|
/* returns result string: sign digits null */
|
||||||
|
static char result[ 1 + (sizeof i * 5 + 1) / 2 + 1] ;
|
||||||
|
char *sp = &result[ sizeof result - 1] ; /* points on result's last byte */
|
||||||
|
|
||||||
|
*sp = 0 ;
|
||||||
|
|
||||||
/* record the sign... */
|
/* record the sign... */
|
||||||
sign = 1;
|
sign = i < 0 ;
|
||||||
if (i < 0) {
|
u = sign ? -i : i ;
|
||||||
sign = -1;
|
|
||||||
i = -i;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* and build the string (backwards!) */
|
/* and build the string (backwards!) */
|
||||||
sp = result + INTWIDTH;
|
|
||||||
*sp = 0;
|
|
||||||
do {
|
do {
|
||||||
*(--sp) = '0' + i % 10 ; /* install the new digit */
|
*(--sp) = '0' + u % 10 ; /* install the new digit */
|
||||||
i = i / 10;
|
u = u / 10 ;
|
||||||
} while (i);
|
} while( u) ;
|
||||||
|
|
||||||
/* and fix the sign */
|
/* and fix the sign */
|
||||||
if (sign == -1) {
|
if( sign)
|
||||||
*(--sp) = '-'; /* and install the minus sign */
|
*(--sp) = '-'; /* and install the minus sign */
|
||||||
}
|
|
||||||
|
|
||||||
return sp ;
|
return sp ;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user