Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/lua-winreg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoteus <mimir@newmail.ru>2012-09-05 15:53:47 +0400
committermoteus <mimir@newmail.ru>2012-09-05 15:53:47 +0400
commite52ac7f6beaf32bdebb7e3af33448e79df5cc6b6 (patch)
tree5d873efa4f76204d768ce05ad2cd28132c34d487 /src/lua_tstring.c
parentaa8939f91a1846a8ae94c96e30eecd93e81e9ab2 (diff)
Merge from http://scite-ru.googlecode.com/
Diffstat (limited to 'src/lua_tstring.c')
-rw-r--r--src/lua_tstring.c138
1 files changed, 69 insertions, 69 deletions
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];
}