summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldump.c4
-rw-r--r--lstrlib.c16
-rw-r--r--lundump.c6
3 files changed, 13 insertions, 13 deletions
diff --git a/ldump.c b/ldump.c
index 5076c430..0c42d772 100644
--- a/ldump.c
+++ b/ldump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldump.c,v 2.26 2014/03/11 18:05:46 roberto Exp roberto $ 2** $Id: ldump.c,v 2.27 2014/03/11 18:56:27 roberto Exp roberto $
3** save precompiled Lua chunks 3** save precompiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -27,7 +27,7 @@ typedef struct {
27 27
28/* 28/*
29** All high-level dumps go through DumpVector; you can change it to 29** All high-level dumps go through DumpVector; you can change it to
30** change the endianess of the result 30** change the endianness of the result
31*/ 31*/
32#define DumpVector(v,n,D) DumpBlock(v,(n)*sizeof((v)[0]),D) 32#define DumpVector(v,n,D) DumpBlock(v,(n)*sizeof((v)[0]),D)
33 33
diff --git a/lstrlib.c b/lstrlib.c
index 25569085..3da669d7 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.188 2014/03/21 13:52:33 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.189 2014/03/21 14:26:44 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -975,7 +975,7 @@ static int getendian (lua_State *L, int arg) {
975 if (*endian == 'n') /* native? */ 975 if (*endian == 'n') /* native? */
976 return nativeendian.little; 976 return nativeendian.little;
977 luaL_argcheck(L, *endian == 'l' || *endian == 'b', arg, 977 luaL_argcheck(L, *endian == 'l' || *endian == 'b', arg,
978 "endianess must be 'l'/'b'/'n'"); 978 "endianness must be 'l'/'b'/'n'");
979 return (*endian == 'l'); 979 return (*endian == 'l');
980} 980}
981 981
@@ -1075,9 +1075,9 @@ static int unpackint_l (lua_State *L) {
1075} 1075}
1076 1076
1077 1077
1078static void correctendianess (lua_State *L, char *b, int size, int endianarg) { 1078static void correctendianness (lua_State *L, char *b, int size, int endianarg) {
1079 int endian = getendian(L, endianarg); 1079 int endian = getendian(L, endianarg);
1080 if (endian != nativeendian.little) { /* not native endianess? */ 1080 if (endian != nativeendian.little) { /* not native endianness? */
1081 int i = 0; 1081 int i = 0;
1082 while (i < --size) { 1082 while (i < --size) {
1083 char temp = b[i]; 1083 char temp = b[i];
@@ -1113,7 +1113,7 @@ static int packfloat_l (lua_State *L) {
1113 d = (double)n; 1113 d = (double)n;
1114 pn = (char*)&d; 1114 pn = (char*)&d;
1115 } 1115 }
1116 correctendianess(L, pn, size, 3); 1116 correctendianness(L, pn, size, 3);
1117 lua_pushlstring(L, pn, size); 1117 lua_pushlstring(L, pn, size);
1118 return 1; 1118 return 1;
1119} 1119}
@@ -1129,19 +1129,19 @@ static int unpackfloat_l (lua_State *L) {
1129 "string too short"); 1129 "string too short");
1130 if (size == sizeof(lua_Number)) { 1130 if (size == sizeof(lua_Number)) {
1131 memcpy(&res, s + pos - 1, size); 1131 memcpy(&res, s + pos - 1, size);
1132 correctendianess(L, (char*)&res, size, 4); 1132 correctendianness(L, (char*)&res, size, 4);
1133 } 1133 }
1134 else if (size == sizeof(float)) { 1134 else if (size == sizeof(float)) {
1135 float f; 1135 float f;
1136 memcpy(&f, s + pos - 1, size); 1136 memcpy(&f, s + pos - 1, size);
1137 correctendianess(L, (char*)&f, size, 4); 1137 correctendianness(L, (char*)&f, size, 4);
1138 res = (lua_Number)f; 1138 res = (lua_Number)f;
1139 } 1139 }
1140 else { /* native lua_Number may be neither float nor double */ 1140 else { /* native lua_Number may be neither float nor double */
1141 double d; 1141 double d;
1142 lua_assert(size == sizeof(double)); 1142 lua_assert(size == sizeof(double));
1143 memcpy(&d, s + pos - 1, size); 1143 memcpy(&d, s + pos - 1, size);
1144 correctendianess(L, (char*)&d, size, 4); 1144 correctendianness(L, (char*)&d, size, 4);
1145 res = (lua_Number)d; 1145 res = (lua_Number)d;
1146 } 1146 }
1147 lua_pushnumber(L, res); 1147 lua_pushnumber(L, res);
diff --git a/lundump.c b/lundump.c
index e9d445e6..ddf55239 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 2.33 2014/03/11 18:05:46 roberto Exp roberto $ 2** $Id: lundump.c,v 2.34 2014/03/11 18:56:27 roberto Exp roberto $
3** load precompiled Lua chunks 3** load precompiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -42,7 +42,7 @@ static l_noret error(LoadState *S, const char *why) {
42 42
43/* 43/*
44** All high-level loads go through LoadVector; you can change it to 44** All high-level loads go through LoadVector; you can change it to
45** adapt to the endianess of the input 45** adapt to the endianness of the input
46*/ 46*/
47#define LoadVector(S,b,n) LoadBlock(S,b,(n)*sizeof((b)[0])) 47#define LoadVector(S,b,n) LoadBlock(S,b,(n)*sizeof((b)[0]))
48 48
@@ -231,7 +231,7 @@ static void checkHeader (LoadState *S) {
231 checksize(S, lua_Integer); 231 checksize(S, lua_Integer);
232 checksize(S, lua_Number); 232 checksize(S, lua_Number);
233 if (LoadInteger(S) != LUAC_INT) 233 if (LoadInteger(S) != LUAC_INT)
234 error(S, "endianess mismatch in"); 234 error(S, "endianness mismatch in");
235 if (LoadNumber(S) != LUAC_NUM) 235 if (LoadNumber(S) != LUAC_NUM)
236 error(S, "float format mismatch in"); 236 error(S, "float format mismatch in");
237} 237}