1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-06-16 07:45:23 +00:00

FIX: 'insert-string &add -1 -2147483647' was '-./,),(-*,(' instead of '-2147483648'.

This commit is contained in:
Renaud 2015-06-06 08:25:44 +08:00
parent 4a0759fa89
commit 90c170e200

33
eval.c
View File

@ -1076,35 +1076,30 @@ 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 int sign ; /* sign of resulting number */
/* 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 */
char *sp; /* pointer into result */ *sp = 0 ;
int sign; /* sign of resulting number */
static char result[INTWIDTH + 1]; /* resulting string */
/* 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 ;
} }
/* /*