mirror of https://github.com/rusefi/lua.git
detail ('signal' -> 'sign' in comments)
This commit is contained in:
parent
4c0e36a46e
commit
e4e5aa85a2
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lbaselib.c,v 1.316 2017/05/26 19:14:29 roberto Exp roberto $
|
** $Id: lbaselib.c,v 1.317 2017/06/27 18:32:49 roberto Exp roberto $
|
||||||
** Basic library
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -49,7 +49,7 @@ static const char *b_str2int (const char *s, int base, lua_Integer *pn) {
|
||||||
lua_Unsigned n = 0;
|
lua_Unsigned n = 0;
|
||||||
int neg = 0;
|
int neg = 0;
|
||||||
s += strspn(s, SPACECHARS); /* skip initial spaces */
|
s += strspn(s, SPACECHARS); /* skip initial spaces */
|
||||||
if (*s == '-') { s++; neg = 1; } /* handle signal */
|
if (*s == '-') { s++; neg = 1; } /* handle sign */
|
||||||
else if (*s == '+') s++;
|
else if (*s == '+') s++;
|
||||||
if (!isalnum((unsigned char)*s)) /* no digit? */
|
if (!isalnum((unsigned char)*s)) /* no digit? */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lbitlib.c,v 1.29 2015/10/08 15:55:35 roberto Exp roberto $
|
** $Id: lbitlib.c,v 1.30 2015/11/11 19:08:09 roberto Exp roberto $
|
||||||
** Standard library for bitwise operations
|
** Standard library for bitwise operations
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -131,7 +131,7 @@ static int b_arshift (lua_State *L) {
|
||||||
else { /* arithmetic shift for 'negative' number */
|
else { /* arithmetic shift for 'negative' number */
|
||||||
if (i >= LUA_NBITS) r = ALLONES;
|
if (i >= LUA_NBITS) r = ALLONES;
|
||||||
else
|
else
|
||||||
r = trim((r >> i) | ~(trim(~(lua_Unsigned)0) >> i)); /* add signal bit */
|
r = trim((r >> i) | ~(trim(~(lua_Unsigned)0) >> i)); /* add sign bit */
|
||||||
pushunsigned(L, r);
|
pushunsigned(L, r);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
6
liolib.c
6
liolib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: liolib.c,v 2.151 2016/12/20 18:37:00 roberto Exp roberto $
|
** $Id: liolib.c,v 2.152 2017/02/09 14:50:05 roberto Exp roberto $
|
||||||
** Standard I/O (and system) library
|
** Standard I/O (and system) library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -447,7 +447,7 @@ static int read_number (lua_State *L, FILE *f) {
|
||||||
decp[1] = '.'; /* always accept a dot */
|
decp[1] = '.'; /* always accept a dot */
|
||||||
l_lockfile(rn.f);
|
l_lockfile(rn.f);
|
||||||
do { rn.c = l_getc(rn.f); } while (isspace(rn.c)); /* skip spaces */
|
do { rn.c = l_getc(rn.f); } while (isspace(rn.c)); /* skip spaces */
|
||||||
test2(&rn, "-+"); /* optional signal */
|
test2(&rn, "-+"); /* optional sign */
|
||||||
if (test2(&rn, "00")) {
|
if (test2(&rn, "00")) {
|
||||||
if (test2(&rn, "xX")) hex = 1; /* numeral is hexadecimal */
|
if (test2(&rn, "xX")) hex = 1; /* numeral is hexadecimal */
|
||||||
else count = 1; /* count initial '0' as a valid digit */
|
else count = 1; /* count initial '0' as a valid digit */
|
||||||
|
@ -456,7 +456,7 @@ static int read_number (lua_State *L, FILE *f) {
|
||||||
if (test2(&rn, decp)) /* decimal point? */
|
if (test2(&rn, decp)) /* decimal point? */
|
||||||
count += readdigits(&rn, hex); /* fractional part */
|
count += readdigits(&rn, hex); /* fractional part */
|
||||||
if (count > 0 && test2(&rn, (hex ? "pP" : "eE"))) { /* exponent mark? */
|
if (count > 0 && test2(&rn, (hex ? "pP" : "eE"))) { /* exponent mark? */
|
||||||
test2(&rn, "-+"); /* exponent signal */
|
test2(&rn, "-+"); /* exponent sign */
|
||||||
readdigits(&rn, 0); /* exponent digits */
|
readdigits(&rn, 0); /* exponent digits */
|
||||||
}
|
}
|
||||||
ungetc(rn.c, rn.f); /* unread look-ahead char */
|
ungetc(rn.c, rn.f); /* unread look-ahead char */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lobject.c,v 2.118 2017/10/10 20:05:40 roberto Exp roberto $
|
** $Id: lobject.c,v 2.119 2017/11/08 14:50:23 roberto Exp roberto $
|
||||||
** Some generic functions over Lua objects
|
** Some generic functions over Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -206,7 +206,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) {
|
||||||
int hasdot = 0; /* true after seen a dot */
|
int hasdot = 0; /* true after seen a dot */
|
||||||
*endptr = cast(char *, s); /* nothing is valid yet */
|
*endptr = cast(char *, s); /* nothing is valid yet */
|
||||||
while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
|
while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
|
||||||
neg = isneg(&s); /* check signal */
|
neg = isneg(&s); /* check sign */
|
||||||
if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */
|
if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */
|
||||||
return 0.0; /* invalid format (no '0x') */
|
return 0.0; /* invalid format (no '0x') */
|
||||||
for (s += 2; ; s++) { /* skip '0x' and read numeral */
|
for (s += 2; ; s++) { /* skip '0x' and read numeral */
|
||||||
|
@ -230,9 +230,9 @@ static lua_Number lua_strx2number (const char *s, char **endptr) {
|
||||||
e *= 4; /* each digit multiplies/divides value by 2^4 */
|
e *= 4; /* each digit multiplies/divides value by 2^4 */
|
||||||
if (*s == 'p' || *s == 'P') { /* exponent part? */
|
if (*s == 'p' || *s == 'P') { /* exponent part? */
|
||||||
int exp1 = 0; /* exponent value */
|
int exp1 = 0; /* exponent value */
|
||||||
int neg1; /* exponent signal */
|
int neg1; /* exponent sign */
|
||||||
s++; /* skip 'p' */
|
s++; /* skip 'p' */
|
||||||
neg1 = isneg(&s); /* signal */
|
neg1 = isneg(&s); /* sign */
|
||||||
if (!lisdigit(cast_uchar(*s)))
|
if (!lisdigit(cast_uchar(*s)))
|
||||||
return 0.0; /* invalid; must have at least one digit */
|
return 0.0; /* invalid; must have at least one digit */
|
||||||
while (lisdigit(cast_uchar(*s))) /* read exponent */
|
while (lisdigit(cast_uchar(*s))) /* read exponent */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.257 2017/07/07 16:34:32 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.258 2017/11/08 14:50:23 roberto Exp roberto $
|
||||||
** Standard library for string operations and pattern-matching
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -994,7 +994,7 @@ static int num2straux (char *buff, int sz, lua_Number x) {
|
||||||
lua_Number m = l_mathop(frexp)(x, &e); /* 'x' fraction and exponent */
|
lua_Number m = l_mathop(frexp)(x, &e); /* 'x' fraction and exponent */
|
||||||
int n = 0; /* character count */
|
int n = 0; /* character count */
|
||||||
if (m < 0) { /* is number negative? */
|
if (m < 0) { /* is number negative? */
|
||||||
buff[n++] = '-'; /* add signal */
|
buff[n++] = '-'; /* add sign */
|
||||||
m = -m; /* make it positive */
|
m = -m; /* make it positive */
|
||||||
}
|
}
|
||||||
buff[n++] = '0'; buff[n++] = 'x'; /* add "0x" */
|
buff[n++] = '0'; buff[n++] = 'x'; /* add "0x" */
|
||||||
|
|
Loading…
Reference in New Issue