Skip to content

Instantly share code, notes, and snippets.

@southly
Created February 11, 2011 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save southly/822436 to your computer and use it in GitHub Desktop.
Save southly/822436 to your computer and use it in GitHub Desktop.
cmigemo-1.3c-MIT.tar.bz2 からの差分
From 8816683b89f46640ec509cf54a7d0e927429a264 Mon Sep 17 00:00:00 2001
From: NANRI <southly@gmail.com>
Date: Sun, 30 Jan 2011 02:39:05 +0900
Subject: [PATCH] calling convention modified.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- migemo_setproc_char2int
- migemo_setproc_int2char
で指定する関数の呼び出し規約を stdcall に変更する.
これに関連する関数の呼び出し規約も同様に変更する.
以下の関数の呼び出し規約を変更した.
- cp932_char2int
- cp932_int2char
- eucjp_char2int
- eucjp_int2char
- utf8_char2int
- utf8_int2char
- default_char2int
- default_int2char
---
src/charset.c | 12 ++++++------
src/charset.h | 22 ++++++++++++++--------
src/migemo.h | 10 ++++++++--
src/romaji.h | 8 +++++++-
src/rxgen.c | 4 ++--
src/rxgen.h | 10 ++++++++--
6 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/src/charset.c b/src/charset.c
index ea07535..d35e7bc 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -11,7 +11,7 @@
#include <stdio.h>
#include "charset.h"
- int
+ int CALLBACK
cp932_char2int(const unsigned char* in, unsigned int* out)
{
if (((0x81 <= in[0] && in[0] <= 0x9f)
@@ -31,7 +31,7 @@ cp932_char2int(const unsigned char* in, unsigned int* out)
}
}
- int
+ int CALLBACK
cp932_int2char(unsigned int in, unsigned char* out)
{
if (in >= 0x100)
@@ -49,7 +49,7 @@ cp932_int2char(unsigned int in, unsigned char* out)
#define IS_EUC_RANGE(c) (0xa1 <= (c) && (c) <= 0xfe)
- int
+ int CALLBACK
eucjp_char2int(const unsigned char* in, unsigned int* out)
{
if ((in[0] == 0x8e && 0xa0 <= in[1] && in[1] <= 0xdf)
@@ -67,7 +67,7 @@ eucjp_char2int(const unsigned char* in, unsigned int* out)
}
}
- int
+ int CALLBACK
eucjp_int2char(unsigned int in, unsigned char* out)
{
/* CP932と内容は同じだが将来JISX0213に対応させるために分離しておく */
@@ -110,7 +110,7 @@ utf8_char2int_noascii(const unsigned char* in, unsigned int* out)
return len;
}
- int
+ int CALLBACK
utf8_char2int(const unsigned char* in, unsigned int* out)
{
int retval = utf8_char2int_noascii(in, out);
@@ -124,7 +124,7 @@ utf8_char2int(const unsigned char* in, unsigned int* out)
}
}
- int
+ int CALLBACK
utf8_int2char(unsigned int in, unsigned char* out)
{
if (in < 0x80)
diff --git a/src/charset.h b/src/charset.h
index e1c6e1f..8efb608 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -16,8 +16,14 @@ enum {
CHARSET_UTF8 = 3,
};
-typedef int (*charset_proc_char2int)(const unsigned char*, unsigned int*);
-typedef int (*charset_proc_int2char)(unsigned int, unsigned char*);
+#if defined(_MSC_VER)
+# define CALLBACK __stdcall
+#else
+# define CALLBACK
+#endif
+
+typedef int (CALLBACK *charset_proc_char2int)(const unsigned char*, unsigned int*);
+typedef int (CALLBACK *charset_proc_int2char)(unsigned int, unsigned char*);
#define CHARSET_PROC_CHAR2INT charset_proc_char2int
#define CHARSET_PROC_INT2CHAR charset_proc_int2char
@@ -25,12 +31,12 @@ typedef int (*charset_proc_int2char)(unsigned int, unsigned char*);
extern "C" {
#endif
-int cp932_char2int(const unsigned char* in, unsigned int* out);
-int cp932_int2char(unsigned int in, unsigned char* out);
-int eucjp_char2int(const unsigned char* in, unsigned int* out);
-int eucjp_int2char(unsigned int in, unsigned char* out);
-int utf8_char2int(const unsigned char* in, unsigned int* out);
-int utf8_int2char(unsigned int in, unsigned char* out);
+int CALLBACK cp932_char2int(const unsigned char* in, unsigned int* out);
+int CALLBACK cp932_int2char(unsigned int in, unsigned char* out);
+int CALLBACK eucjp_char2int(const unsigned char* in, unsigned int* out);
+int CALLBACK eucjp_int2char(unsigned int in, unsigned char* out);
+int CALLBACK utf8_char2int(const unsigned char* in, unsigned int* out);
+int CALLBACK utf8_int2char(unsigned int in, unsigned char* out);
int charset_detect_file(const char* path);
int charset_detect_buf(const unsigned char* buf, int len);
diff --git a/src/migemo.h b/src/migemo.h
index 433f056..1441553 100644
--- a/src/migemo.h
+++ b/src/migemo.h
@@ -27,9 +27,15 @@
#define MIGEMO_OPINDEX_SELECT_OUT 4
#define MIGEMO_OPINDEX_NEWLINE 5
+#if defined(_MSC_VER)
+# define CALLBACK __stdcall
+#else
+# define CALLBACK
+#endif
+
/* see: rxgen.h */
-typedef int (*MIGEMO_PROC_CHAR2INT)(const unsigned char*, unsigned int*);
-typedef int (*MIGEMO_PROC_INT2CHAR)(unsigned int, unsigned char*);
+typedef int (CALLBACK *MIGEMO_PROC_CHAR2INT)(const unsigned char*, unsigned int*);
+typedef int (CALLBACK *MIGEMO_PROC_INT2CHAR)(unsigned int, unsigned char*);
/**
* Migemoオブジェクト。migemo_open()で作成され、migemo_closeで破棄される。
diff --git a/src/romaji.h b/src/romaji.h
index a5062ab..c257b6c 100644
--- a/src/romaji.h
+++ b/src/romaji.h
@@ -9,8 +9,14 @@
#ifndef ROMAJI_H
#define ROMAJI_H
+#if defined(_MSC_VER)
+# define CALLBACK __stdcall
+#else
+# define CALLBACK
+#endif
+
typedef struct _romaji romaji;
-typedef int (*romaji_proc_char2int)(const unsigned char*, unsigned int*);
+typedef int (CALLBACK *romaji_proc_char2int)(const unsigned char*, unsigned int*);
#define ROMAJI_PROC_CHAR2INT romaji_proc_char2int
#ifdef __cplusplus
diff --git a/src/rxgen.c b/src/rxgen.c
index e381ab5..cb59067 100644
--- a/src/rxgen.c
+++ b/src/rxgen.c
@@ -78,7 +78,7 @@ rnode_delete(rnode* node)
* rxgen interfaces
*/
- static int
+ static int CALLBACK
default_char2int(const unsigned char* in, unsigned int* out)
{
if (out)
@@ -86,7 +86,7 @@ default_char2int(const unsigned char* in, unsigned int* out)
return 1;
}
- static int
+ static int CALLBACK
default_int2char(unsigned int in, unsigned char* out)
{
int len = 0;
diff --git a/src/rxgen.h b/src/rxgen.h
index cb7476c..d3231d5 100644
--- a/src/rxgen.h
+++ b/src/rxgen.h
@@ -9,9 +9,15 @@
#ifndef RXGEN_H
#define RXGEN_H
+#if defined(_MSC_VER)
+# define CALLBACK __stdcall
+#else
+# define CALLBACK
+#endif
+
typedef struct _rxgen rxgen;
-typedef int (*rxgen_proc_char2int)(const unsigned char*, unsigned int*);
-typedef int (*rxgen_proc_int2char)(unsigned int, unsigned char*);
+typedef int (CALLBACK *rxgen_proc_char2int)(const unsigned char*, unsigned int*);
+typedef int (CALLBACK *rxgen_proc_int2char)(unsigned int, unsigned char*);
#define RXGEN_PROC_CHAR2INT rxgen_proc_char2int
#define RXGEN_PROC_INT2CHAR rxgen_proc_int2char
--
1.7.3.3
@southly
Copy link
Author

southly commented Feb 11, 2011

メール出したのでメモ。
http://xyzzy.s53.xrea.com/wiki/index.php?%BC%C1%CC%E4%C8%A2%2F10 の件を何とかするための一歩。

@southly
Copy link
Author

southly commented Feb 12, 2011

却下されたので改変したDLLを作成する方向で

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment