diff options
author | moteus <mimir@newmail.ru> | 2012-09-05 15:53:47 +0400 |
---|---|---|
committer | moteus <mimir@newmail.ru> | 2012-09-05 15:53:47 +0400 |
commit | e52ac7f6beaf32bdebb7e3af33448e79df5cc6b6 (patch) | |
tree | 5d873efa4f76204d768ce05ad2cd28132c34d487 | |
parent | aa8939f91a1846a8ae94c96e30eecd93e81e9ab2 (diff) |
Merge from http://scite-ru.googlecode.com/
-rw-r--r-- | src/lua_int64.c | 10 | ||||
-rw-r--r-- | src/lua_int64.h | 8 | ||||
-rw-r--r-- | src/lua_tstring.c | 138 | ||||
-rw-r--r-- | src/win_trace.c | 5 | ||||
-rw-r--r-- | src/winreg.c | 12 |
5 files changed, 91 insertions, 82 deletions
diff --git a/src/lua_int64.c b/src/lua_int64.c index d30cc50..3739b37 100644 --- a/src/lua_int64.c +++ b/src/lua_int64.c @@ -1,10 +1,10 @@ -#include <windows.h> +#include <windows.h>
#include <lua.h>
#include <lualib.h>
-#include <lauxlib.h> -#include <luamacro.h> -#include <stdmacro.h> - +#include <lauxlib.h>
+#include "luamacro.h"
+#include "stdmacro.h"
+
// from NSIS source code
int atoINT64(const char* s, INT64 *pv){
diff --git a/src/lua_int64.h b/src/lua_int64.h index 9e954ec..6bed1dd 100644 --- a/src/lua_int64.h +++ b/src/lua_int64.h @@ -15,8 +15,14 @@ INT64 lua_checkINT64(lua_State *L, int i); int atoUINT64(const char* s, UINT64 * pv);
int atoINT64(const char* s, INT64 *pv);
+#ifdef __GNUC__
+ #define CONST_9007199254740992 0x20000000000000LL
+#else
+ #define CONST_9007199254740992 9007199254740992
+#endif
+
#define lua_pushUINT64(L,n) \
- if(n > 9007199254740992){ \
+ if( n > CONST_9007199254740992 ){ \
char buf[24]; \
lua_pushstring(L, _ui64toa(n, buf, 10)); \
}else{ \
diff --git a/src/lua_tstring.c b/src/lua_tstring.c index f1ede73..8a24cfe 100644 --- a/src/lua_tstring.c +++ b/src/lua_tstring.c @@ -1,5 +1,5 @@ -#include <limits.h> -#include <string.h> +#include <limits.h>
+#include <string.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
@@ -19,23 +19,23 @@ size_t lua_utf8towcsZ(lua_State *L, const char *s, int len){ // Found ASCII.
UNCH = pUTF8[0];
}else if (pUTF8[0] < 0xE0){ //224
- if ((pUTF8[1] & 0xC0) == 0x80) { - /* A two-byte-character lead-byte not followed by trail-byte represents itself.*/ - UNCH = (wchar_t) (((pUTF8[0] & 0x1F) << 6) | (pUTF8[1] & 0x3F)); - pUTF8 += 1; - }else{ - /* A two-byte-character lead-byte not followed by trail-byte represents itself. */ - UNCH = pUTF8[0]; + if ((pUTF8[1] & 0xC0) == 0x80) {
+ /* A two-byte-character lead-byte not followed by trail-byte represents itself.*/
+ UNCH = (wchar_t) (((pUTF8[0] & 0x1F) << 6) | (pUTF8[1] & 0x3F));
+ pUTF8 += 1;
+ }else{
+ /* A two-byte-character lead-byte not followed by trail-byte represents itself. */
+ UNCH = pUTF8[0];
+ }
+ }else if (pUTF8[0] < 0xF0) {//240
+ if (((pUTF8[1] & 0xC0) == 0x80) && ((pUTF8[2] & 0xC0) == 0x80)) {
+ /* Three-byte-character lead byte followed by two trail bytes.*/
+ UNCH = (wchar_t) (((pUTF8[0] & 0x0F) << 12) | ((pUTF8[1] & 0x3F) << 6) | (pUTF8[2] & 0x3F));
+ pUTF8 += 2;
+ }else{
+ /* Three-byte-character lead byte followed by two trail bytes.*/
+ UNCH = pUTF8[0];
}
- }else if (pUTF8[0] < 0xF0) {//240 - if (((pUTF8[1] & 0xC0) == 0x80) && ((pUTF8[2] & 0xC0) == 0x80)) { - /* Three-byte-character lead byte followed by two trail bytes.*/ - UNCH = (wchar_t) (((pUTF8[0] & 0x0F) << 12) | ((pUTF8[1] & 0x3F) << 6) | (pUTF8[2] & 0x3F)); - pUTF8 += 2; - }else{ - /* Three-byte-character lead byte followed by two trail bytes.*/ - UNCH = pUTF8[0]; - } }else{
UNCH = pUTF8[0];
}
@@ -62,23 +62,23 @@ size_t lua_utf8towcs(lua_State *L, const char *s, int len){ // Found ASCII.
UNCH = pUTF8[0];
}else if (pUTF8[0] < 0xE0){ //224
- if ((pUTF8[1] & 0xC0) == 0x80) { - /* A two-byte-character lead-byte not followed by trail-byte represents itself.*/ - UNCH = (wchar_t) (((pUTF8[0] & 0x1F) << 6) | (pUTF8[1] & 0x3F)); - pUTF8 += 1; - }else{ - /* A two-byte-character lead-byte not followed by trail-byte represents itself. */ - UNCH = pUTF8[0]; + if ((pUTF8[1] & 0xC0) == 0x80) {
+ /* A two-byte-character lead-byte not followed by trail-byte represents itself.*/
+ UNCH = (wchar_t) (((pUTF8[0] & 0x1F) << 6) | (pUTF8[1] & 0x3F));
+ pUTF8 += 1;
+ }else{
+ /* A two-byte-character lead-byte not followed by trail-byte represents itself. */
+ UNCH = pUTF8[0];
+ }
+ }else if (pUTF8[0] < 0xF0) {//240
+ if (((pUTF8[1] & 0xC0) == 0x80) && ((pUTF8[2] & 0xC0) == 0x80)) {
+ /* Three-byte-character lead byte followed by two trail bytes.*/
+ UNCH = (wchar_t) (((pUTF8[0] & 0x0F) << 12) | ((pUTF8[1] & 0x3F) << 6) | (pUTF8[2] & 0x3F));
+ pUTF8 += 2;
+ }else{
+ /* Three-byte-character lead byte followed by two trail bytes.*/
+ UNCH = pUTF8[0];
}
- }else if (pUTF8[0] < 0xF0) {//240 - if (((pUTF8[1] & 0xC0) == 0x80) && ((pUTF8[2] & 0xC0) == 0x80)) { - /* Three-byte-character lead byte followed by two trail bytes.*/ - UNCH = (wchar_t) (((pUTF8[0] & 0x0F) << 12) | ((pUTF8[1] & 0x3F) << 6) | (pUTF8[2] & 0x3F)); - pUTF8 += 2; - }else{ - /* Three-byte-character lead byte followed by two trail bytes.*/ - UNCH = pUTF8[0]; - } }else{
UNCH = pUTF8[0];
}
@@ -190,18 +190,18 @@ void lua_addutf8_from_wchar(luaL_Buffer * pB, wchar_t ch){ }
// gets an int character value, if string is >= 2 chars checks if utf
wchar_t lua_checkwchar_from_utf8(lua_State *L, int i){
- const char* psz = luaL_checkstring(L, i);
+ const unsigned char* psz = (const unsigned char *)luaL_checkstring(L, i);
if ((psz[0] && psz[1] == 0) || psz[0] == 0) {
return psz[0];// single character
}else if ((psz[0] >= 0xC0) && (psz[0] < 0xE0)
&& (psz[1] & 0xC0) == 0x80
&& (psz[2] == 0)// Two-byte-character lead-byte followed by a trail-byte.
- ){ return (wchar_t)(((psz[0] & 0x1F) << 6) | (psz[1] & 0x3F)); + ){ return (wchar_t)(((psz[0] & 0x1F) << 6) | (psz[1] & 0x3F));
}else if ((psz[0] >= 0xE0) && (psz[0] < 0xF0)
&& ((psz[1] & 0xC0) == 0x80)
&& ((psz[2] & 0xC0) == 0x80)
- && (psz[3] == 0)// Three-utf-character lead utf followed by two trail bytes. - ){ return (wchar_t)(((psz[0] & 0x0F) << 12) | ((psz[1] & 0x3F) << 6) | (psz[2] & 0x3F)); + && (psz[3] == 0)// Three-utf-character lead utf followed by two trail bytes.
+ ){ return (wchar_t)(((psz[0] & 0x0F) << 12) | ((psz[1] & 0x3F) << 6) | (psz[2] & 0x3F));
}else{
luaL_argerror(L, i, "character expected");
}
@@ -240,19 +240,19 @@ const wchar_t *lua_checklwcs_from_utf8(lua_State *L, int narg, size_t* l){ }
// lua utf8 string to wide string, with len, optional
const wchar_t *lua_optlwcs_from_utf8(lua_State *L, int narg, const wchar_t *def, size_t *len){
- if (lua_isnoneornil(L, narg)) { - if (len) - *len = (def ? wcslen(def) : 0); - return def; - } + if (lua_isnoneornil(L, narg)) {
+ if (len)
+ *len = (def ? wcslen(def) : 0);
+ return def;
+ }
else return lua_checklwcs_from_utf8(L, narg, len);
}
// lua push wide string, convert to utf8
-void lua_pushutf8_from_wcs (lua_State *L, const wchar_t *s) { - if (s == NULL) - lua_pushnil(L); - else - lua_wcstoutf8(L, s, wcslen(s)); +void lua_pushutf8_from_wcs (lua_State *L, const wchar_t *s) {
+ if (s == NULL)
+ lua_pushnil(L);
+ else
+ lua_wcstoutf8(L, s, wcslen(s));
}
@@ -288,11 +288,11 @@ const wchar_t *lua_checklwcs_from_char(lua_State *L, int narg, size_t* l){ }
// Lua char string to wide string, with len, optional
const wchar_t *lua_optlwcs_from_char (lua_State *L, int narg, const wchar_t *def, size_t *len){
- if (lua_isnoneornil(L, narg)) { - if (len) - *len = (def ? wcslen(def) : 0); - return def; - } + if (lua_isnoneornil(L, narg)) {
+ if (len)
+ *len = (def ? wcslen(def) : 0);
+ return def;
+ }
else return lua_checklwcs_from_char(L, narg, len);
}
// Maps a wchar_t character string to its char string counterpart.
@@ -343,23 +343,23 @@ size_t lua_utf8towcsZ2(lua_State *L, const char *s, int len){ // Found ASCII.
*pBuf++ = pUTF8[0];
}else if (pUTF8[0] < 0xE0){ //224
- if ((pUTF8[1] & 0xC0) == 0x80) { - // A two-byte-character lead-byte not followed by trail-byte represents itself. - *pBuf++ = (wchar_t) (((pUTF8[0] & 0x1F) << 6) | (pUTF8[1] & 0x3F)); - pUTF8 += 1; - }else{ - // A two-byte-character lead-byte not followed by trail-byte represents itself. - *pBuf++ = pUTF8[0]; + if ((pUTF8[1] & 0xC0) == 0x80) {
+ // A two-byte-character lead-byte not followed by trail-byte represents itself.
+ *pBuf++ = (wchar_t) (((pUTF8[0] & 0x1F) << 6) | (pUTF8[1] & 0x3F));
+ pUTF8 += 1;
+ }else{
+ // A two-byte-character lead-byte not followed by trail-byte represents itself.
+ *pBuf++ = pUTF8[0];
+ }
+ }else if (pUTF8[0] < 0xF0) {//240
+ if (((pUTF8[1] & 0xC0) == 0x80) && ((pUTF8[2] & 0xC0) == 0x80)) {
+ // Three-byte-character lead byte followed by two trail bytes.
+ *pBuf++ = (wchar_t) (((pUTF8[0] & 0x0F) << 12) | ((pUTF8[1] & 0x3F) << 6) | (pUTF8[2] & 0x3F));
+ pUTF8 += 2;
+ }else{
+ // Three-byte-character lead byte followed by two trail bytes.
+ *pBuf++ = pUTF8[0];
}
- }else if (pUTF8[0] < 0xF0) {//240 - if (((pUTF8[1] & 0xC0) == 0x80) && ((pUTF8[2] & 0xC0) == 0x80)) { - // Three-byte-character lead byte followed by two trail bytes. - *pBuf++ = (wchar_t) (((pUTF8[0] & 0x0F) << 12) | ((pUTF8[1] & 0x3F) << 6) | (pUTF8[2] & 0x3F)); - pUTF8 += 2; - }else{ - // Three-byte-character lead byte followed by two trail bytes. - *pBuf++ = pUTF8[0]; - } }else{
*pBuf++ = pUTF8[0];
}
diff --git a/src/win_trace.c b/src/win_trace.c index 04d4b7d..3bab1b6 100644 --- a/src/win_trace.c +++ b/src/win_trace.c @@ -1,5 +1,6 @@ #include <windows.h>
+/*
BOOL CALLBACK IsDebuggerPresentStub(VOID);
BOOL (CALLBACK *IsDebuggerPresent)(VOID) = IsDebuggerPresentStub;
@@ -10,9 +11,9 @@ BOOL CALLBACK IsDebuggerPresentStub(VOID){ *(FARPROC *)&IsDebuggerPresent = fp;
return IsDebuggerPresent();
}
- return 0;
+ return 0;
}
-
+*/
void win_traceA(const char *pszFmt, ...){
CHAR tchbuf[1024] = {'$',0};
diff --git a/src/winreg.c b/src/winreg.c index e7f8f35..e3aafb3 100644 --- a/src/winreg.c +++ b/src/winreg.c @@ -5,7 +5,9 @@ #include <assert.h>
#define lua_assert assert
-#include <tchar.h>
+#ifndef uintptr_t
+ typedef unsigned uintptr_t;
+#endif
#include <lua.h>
#include <lualib.h>
@@ -282,10 +284,10 @@ BOOL reg_aux_setvalue(lua_State *L, HKEY hKey, const TCHAR * pszVal, int type, i if(lua_istable(L, i)){
int n;
int last = luaL_getn(L, i);
- for (n = 1; n <= last; n++) { - lua_rawgeti(L, i, n); - luaL_addstring(&B, lua_checkstring(L, -1)); - luaL_addchar(&B, 0); + for (n = 1; n <= last; n++) {
+ lua_rawgeti(L, i, n);
+ luaL_addstring(&B, lua_checkstring(L, -1));
+ luaL_addchar(&B, 0);
}
}else{
luaL_checktype(L, i, LUA_TSTRING);
|