Skip to content

Commit

Permalink
1.7.6
Browse files Browse the repository at this point in the history
・LuaモジュールのUTF-8ラッパーで無限に再帰呼び出しするケースがあったバグを修正しました。

・LuaモジュールのUTF-8ラッパーでtmpnam関数の使い方を間違っていたバグを修正しました。
  • Loading branch information
nathancorvussolis committed Aug 27, 2014
1 parent 8caac96 commit 8c7e052
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 69 deletions.
2 changes: 1 addition & 1 deletion CorvusSKK.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.30501.0
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "installer", "installer\installer.vcxproj", "{C65505E2-5456-473C-91B1-C6D91B294DC3}"
ProjectSection(ProjectDependencies) = postProject
Expand Down
6 changes: 3 additions & 3 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define COMMON_H

#define TEXTSERVICE_NAME L"CorvusSKK"
#define TEXTSERVICE_VER L"1.7.5"
#define TEXTSERVICE_VER L"1.7.6"

#ifndef _DEBUG
#define TEXTSERVICE_DESC TEXTSERVICE_NAME
Expand All @@ -14,8 +14,8 @@
//for resource
#define RC_AUTHOR "nathancorvussolis"
#define RC_PRODUCT "CorvusSKK"
#define RC_VERSION "1.7.5"
#define RC_VERSION_D 1,7,5,0
#define RC_VERSION "1.7.6"
#define RC_VERSION_D 1,7,6,0

#define MAX_KRNLOBJNAME 256
#define CONV_POINT_NUM 256
Expand Down
2 changes: 1 addition & 1 deletion installer/README.TXT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

================================================================================
CorvusSKK version 1.7.5
CorvusSKK version 1.7.6

https://code.google.com/p/corvus-skk/
[email protected]
Expand Down
2 changes: 1 addition & 1 deletion installer/config-lua/test_search.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package.path = ".\\?.lua;" .. package.path
package.path = ".\\?.lua;" .. package.path
package.cpath = ".\\?.dll;" .. package.cpath

crvmgr = require("test_c")
Expand Down
2 changes: 1 addition & 1 deletion installer/corvusskk-x64.wxs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<?define version="1.7.5" ?>
<?define version="1.7.6" ?>
<Product Id="*" Name="CorvusSKK" Language="1033" Version="$(var.version)" Manufacturer="CorvusSKK Project" UpgradeCode="DBDB315C-1F74-4051-8A67-705D0FD16497">

<Package Id="*" Compressed="yes" Description="CorvusSKK" Comments="version $(var.version)" Platform="x64" InstallerVersion="405" InstallScope="perMachine" InstallPrivileges="elevated" />
Expand Down
2 changes: 1 addition & 1 deletion installer/corvusskk-x86.wxs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<?define version="1.7.5" ?>
<?define version="1.7.6" ?>
<Product Id="*" Name="CorvusSKK" Language="1033" Version="$(var.version)" Manufacturer="CorvusSKK Project" UpgradeCode="3F1244EC-9A5C-4041-9A33-E26B03C63C9B">

<Package Id="*" Compressed="yes" Description="CorvusSKK" Comments="version $(var.version)" Platform="x86" InstallerVersion="405" InstallScope="perMachine" InstallPrivileges="elevated" />
Expand Down
78 changes: 42 additions & 36 deletions lua/lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,29 +421,30 @@ static int runargs (lua_State *L, char **argv, int n) {


static int handle_luainit (lua_State *L) {
#ifdef U8W_H
int d;
#endif
const char *name = "=" LUA_INITVERSION;
const char *init = getenv(name + 1);
if (init == NULL) {
name = "=" LUA_INIT;
init = getenv(name + 1); /* try alternative name */
}
if (init == NULL) return LUA_OK;
#ifndef U8W_H
else if (init[0] == '@')
return dofile(L, init+1);
else
return dostring(L, init, name);
#else
#ifdef U8W_H
else if(init[0] == '@') {
int d = dofile(L, init + 1);
free((void*)init);
return d;
d = dofile(L, init + 1);
}
else {
int d = dostring(L, init, name);
free((void*)init);
return d;
d = dostring(L, init, name);
}
free((void *)init);
return d;
#else
else if (init[0] == '@')
return dofile(L, init+1);
else
return dostring(L, init, name);
#endif
}

Expand Down Expand Up @@ -491,17 +492,19 @@ static int pmain (lua_State *L) {


#ifdef U8W_H
int wmain(int argc, wchar_t **wargv) {
char **argv;
int i, n;
int status, result;
lua_State *L;

setlocale(LC_ALL, "");
void free_u8argv(int argc, char **argv) {
int i;
for(i = 0; i < argc; i++) {
if(argv && argv[i]) free(argv[i]);
}
if(argv) free(argv);
}

argv = (char **)calloc(argc + 1, sizeof(void *));
char **make_u8argv(int argc, wchar_t **wargv) {
int i, n;
char **argv = (char **)calloc(argc + 1, sizeof(void *));
if(argv == NULL) {
return EXIT_FAILURE;
return NULL;
} else {
for(i = 0; i < argc; i++) {
n = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
Expand All @@ -512,23 +515,29 @@ int wmain(int argc, wchar_t **wargv) {
}
}
if(n <= 0 || argv[i] == NULL) {
for(i = 0; i < argc; i++) {
if(argv && argv[i]) free(argv[i]);
}
if(argv) free(argv);
return EXIT_FAILURE;
free_u8argv(argc, argv);
return NULL;
}
}
}
return argv;
}

int wmain(int argc, wchar_t **wargv) {
char **argv;
int status, result;
lua_State *L;

setlocale(LC_ALL, "");

argv = make_u8argv(argc, wargv);
if(argv == NULL) return EXIT_FAILURE;

L = luaL_newstate(); /* create state */
if(L == NULL) {
l_message(argv[0], "cannot create state: not enough memory");

for(i = 0; i < argc; i++) {
if(argv && argv[i]) free(argv[i]);
}
if(argv) free(argv);
free_u8argv(argc, argv);

return EXIT_FAILURE;
}
Expand All @@ -542,20 +551,17 @@ int wmain(int argc, wchar_t **wargv) {
finalreport(L, status);
lua_close(L);

for(i = 0; i < argc; i++) {
if(argv && argv[i]) free(argv[i]);
}
if(argv) free(argv);
free_u8argv(argc, argv);

return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
}
#else
int main(int argc, char **argv) {
int status, result;
lua_State *L = luaL_newstate(); /* create state */
if(L == NULL) {
if (L == NULL) {
l_message(argv[0], "cannot create state: not enough memory");
return EXIT_FAILURE;
return EXIT_FAILURE;
}
/* call 'pmain' in protected mode */
lua_pushcfunction(L, &pmain);
Expand Down
4 changes: 2 additions & 2 deletions luaxx/loadlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,14 +643,14 @@ static void setpath (lua_State *L, const char *fieldname, const char *envname1,
lua_pushstring(L, def); /* use default */
else {
#ifdef U8W_H
const char *path_env = path;
const char *path_env = path;
#endif
/* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP,
LUA_PATH_SEP AUXMARK LUA_PATH_SEP);
luaL_gsub(L, path, AUXMARK, def);
#ifdef U8W_H
free((void*)path_env);
free((void *)path_env);
#endif
lua_remove(L, -2);
}
Expand Down
2 changes: 1 addition & 1 deletion luaxx/loslib.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int os_getenv (lua_State *L) {
#ifdef U8W_H
const char *env = getenv(luaL_checkstring(L, 1));
lua_pushstring(L, env); /* if NULL push nil */
free((void*)env);
free((void *)env);
#else
lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */
#endif
Expand Down
5 changes: 4 additions & 1 deletion luaxx/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,11 @@
*/
#if defined(LUA_LIB) || defined(lua_c)
#include <stdio.h>
/*#define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)*/
#ifdef U8W_H
#define luai_writestring(s,l) fprintf(stdout, "%s", s)
#else
#define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
#endif
#define luai_writeline() (luai_writestring("\n", 1), fflush(stdout))
#endif

Expand Down
1 change: 1 addition & 0 deletions luaxx/luaxx.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<ClInclude Include="ltable.h" />
<ClInclude Include="ltm.h" />
<ClInclude Include="lua.h" />
<ClInclude Include="lua.hpp" />
<ClInclude Include="luaconf.h" />
<ClInclude Include="lualib.h" />
<ClInclude Include="lundump.h" />
Expand Down
3 changes: 3 additions & 0 deletions luaxx/luaxx.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
<ClInclude Include="lua.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lua.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="luaconf.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
2 changes: 1 addition & 1 deletion luaxx/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

#include <windows.h>

#define U8W_EXT
#define U8W_EXP
31 changes: 18 additions & 13 deletions luaxx/u8w.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
Conversion from UTF-8 to UTF-16 and vice versa for Windows API and C runtime
Put '#include "u8w.h"' after standard header files include directive.
Call setlocale function before using following functions.
UTF-8 Wrapper for Windows
*/

#include <stdio.h>
Expand All @@ -10,6 +8,7 @@
#include <locale.h>
#include <Windows.h>

#define U8W_C
#include "u8w.h"

static wchar_t *u8wstr(const char *s)
Expand Down Expand Up @@ -319,21 +318,27 @@ u8api char *u8getenv(const char *varname)

u8api char *u8tmpnam(char *str)
{
wchar_t *wbuf;
static char buf[L_tmpnam];
wchar_t wbuf[L_tmpnam];
wchar_t *w;
char *b = NULL;
char *b, *t = NULL;

wbuf = u8wstr(str);
if(wbuf) {
w = _wtmpnam(wbuf);
if(w) {
b = u8str(w);
free(w);
w = _wtmpnam(wbuf);
if(w) {
b = u8str(w);
if(b) {
if(str == NULL) {
t = buf;
}
else {
t = str;
}
strcpy_s(t, L_tmpnam, b);
free(b);
}
free(wbuf);
}

return b;
return t;
}

u8api int u8system(const char *command)
Expand Down
14 changes: 7 additions & 7 deletions luaxx/u8w.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
Conversion from UTF-8 to UTF-16 and vice versa for Windows API and C runtime
Put '#include "u8w.h"' after standard header files include directive.
Call setlocale function before using following functions.
UTF-8 Wrapper for Windows
*/

#ifndef U8W_H
Expand All @@ -10,7 +8,7 @@
#include <stdio.h>
#include <Windows.h>

#ifdef U8W_EXT
#ifdef U8W_EXP
#define u8api __declspec(dllexport)
#else
#define u8api __declspec(dllimport)
Expand All @@ -29,13 +27,14 @@ u8api int u8printf(const char *format, ...);
u8api char *u8fgets(char *buf, int len, FILE *file);
u8api int u8fputs(const char *buf, FILE *file);
u8api char *u8getenv(const char *varname); /* call free function to deallocate */
u8api char *u8tmpnam(char *buf);
u8api char *u8tmpnam(char *str);
u8api int u8system(const char *command);
u8api int u8remove(const char *fname);
u8api int u8rename(const char *oldfname, const char *newfname);
u8api char *u8setlocale(int category, const char *locale);

#if defined(U8W_EXT) || defined(lua_c)
#ifndef U8W_C
#if defined(U8W_EXT) || defined(U8W_EXP) || defined(lua_c)
#undef LoadString

#define GetModuleFileNameA u8GetModuleFileName
Expand All @@ -55,6 +54,7 @@ u8api char *u8setlocale(int category, const char *locale);
#define remove u8remove
#define rename u8rename
#define setlocale u8setlocale
#endif /* U8W_EXT or lua_c */
#endif /* U8W_EXT or U8W_EXP or lua_c */
#endif /* U8W_C */

#endif /* U8W_H */

0 comments on commit 8c7e052

Please sign in to comment.