lua-users home
lua-l archive

Re: [patch][c++] fix conversion from const char*

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



From: Irfan Adilovic <irfanadilovic@gmail.com>
Reply: Lua mailing list <lua-l@lists.lua.org>
Date: 26 June 2016 at 17:11:47
To: lua-l@lists.lua.org <lua-l@lists.lua.org>
Subject: [patch][c++] fix "invalid conversion from ‘void*’ to ‘char*’"

In the 5.3.3 release, lua/lstrlib.cc:936:

char *ppoint = memchr(buff, point, nb);

is not valid c++ code. This should be fixed with a c-style cast:

@@ -935,3 +935,3 @@ static void checkdp (char *buff, int nb) {
char point = lua_getlocaledecpoint(); /* try locale point */
- char *ppoint = memchr(buff, point, nb);
+ char *ppoint = (char *)(memchr(buff, point, nb));
if (ppoint) *ppoint = '.'; /* change it to a dot */

-- Irfan

There is a similar issue in lobject.c with respect to lua-as-C++.

diff --git a/lua-5.3.3/src/lobject.c b/lua-5.3.3/src/lobject.c

index a44b385..2542d9f 100644
--- a/lua-5.3.3/src/lobject.c
+++ b/lua-5.3.3/src/lobject.c
@@ -280,7 +280,7 @@ static const char *l_str2d (const char *s, lua_Number *result) {
endptr = l_str2dloc(s, result, mode); /* try to convert */
if (endptr == NULL) { /* failed? may be a different locale */
char buff[L_MAXLENNUM + 1];
- char *pdot = strchr(s, '.');
+ const char *pdot = strchr(s, '.');
if (strlen(s) > L_MAXLENNUM || pdot == NULL)
return NULL; /* string too long or no dot; fail */
strcpy(buff, s); /* copy string to buffer */



Scott


AltStyle によって変換されたページ (->オリジナル) /