|
在 OS X 下编译的补丁。
主要的修改是:
* 使用 config.h
* 使用 AM_ICONV 来确定 iconv 的参数类型
* 使用 machine/endian.h 来确定 endian。
补丁以后,需要重新 aclocal & autoheader & automake & autoconf
本补丁应该也使用于运行在 x86 上的 Darwin 以及运行在 PPC 上的 Linux。
如果安装有以前版本的 fcitx,似乎需要先删除 ~/.fcitx 下的用户码表和词频文件。
[PHP]diff -Naur fcitx-2.1.0rc/configure.in fcitx-2.1.0rc-darwin/configure.in
--- fcitx-2.1.0rc/configure.in Mon May 17 21:09:39 2004
+++ fcitx-2.1.0rc-darwin/configure.in Mon May 24 09:33:17 2004
@@ -3,6 +3,7 @@
AC_INIT(src/main.c)
AM_INIT_AUTOMAKE(fcitx, 2.1.0rc)
+AM_CONFIG_HEADER([config.h])
dnl Find out what type of system we are
AC_CANONICAL_HOST
@@ -14,11 +15,12 @@
AC_PROG_RANLIB
# Checks for libraries.
+AM_ICONV
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([limits.h malloc.h stdlib.h string.h sys/param.h unistd.h])
+AC_CHECK_HEADERS([limits.h malloc.h stdlib.h string.h sys/param.h unistd.h wait.h machine/endian.h])
# x11
AC_PATH_X
@@ -62,27 +64,12 @@
AM_CONDITIONAL(HAVE_XFT, $have_xft)
if test "x$have_xft" = "xtrue"; then
- LIBS="$LIBS $X_LIBS $XFT_LIBS"
+ LIBS="$LIBS $X_LIBS $XFT_LIBS -lX11 $LIBICONV"
CFLAGS="$CFLAGS $X_CFLAGS $XFT_CFLAGS -D_USE_XFT"
else
- LIBS="$LIBS $X_LIBS -lX11"
+ LIBS="$LIBS $X_LIBS -lX11 $LIBICONV"
CFLAGS="$CFLAGS $X_CFLAGS"
fi
-
-AC_MSG_CHECKING(for OS-dependent information)
-case "$host" in
- *-linux* )
- AC_MSG_RESULT([Linux ($host) found.])
- ;;
- *-darwin* )
- AC_MSG_RESULT([Darwin (Mac OS X) ($host) found.])
- AC_DEFINE(DARWIN)
- LIBS="$LIBS -liconv"
- ;;
- *)
- AC_MSG_RESULT([Unknown system type $host found.])
- ;;
-esac
CFLAGS="$CFLAGS -Wall -Werror"
diff -Naur fcitx-2.1.0rc/lib/IMConn.c fcitx-2.1.0rc-darwin/lib/IMConn.c
--- fcitx-2.1.0rc/lib/IMConn.c Tue Apr 13 23:54:12 2004
+++ fcitx-2.1.0rc-darwin/lib/IMConn.c Mon May 24 00:05:06 2004
@@ -29,12 +29,18 @@
******************************************************************/
+#include <config.h>
+
#include <X11/Xlib.h>
-#if defined(DARWIN)
-#include <sys/malloc.h>
-#else
+
+#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
#include <string.h>
#include "IMdkit.h"
#include <stdarg.h>
diff -Naur fcitx-2.1.0rc/src/InputWindow.c fcitx-2.1.0rc-darwin/src/InputWindow.c
--- fcitx-2.1.0rc/src/InputWindow.c Thu May 20 10:28:27 2004
+++ fcitx-2.1.0rc-darwin/src/InputWindow.c Mon May 24 00:45:15 2004
@@ -1,3 +1,5 @@
+#include <config.h>
+
#include "InputWindow.h"
#include <string.h>
@@ -110,7 +112,7 @@
char str1[] = "Ay÷–";
char str2[10];
char *ps1, *ps2;
- int l1, l2;
+ size_t l1, l2;
if (!xftFont)
return;
@@ -120,8 +122,12 @@
ps2 = str2;
ps1 = str1;
+#if ICONV_CONST == const
+ l1 = iconv (convUTF8, (const char **) &ps1, &l1, &ps2, &l2);
+#else
l1 = iconv (convUTF8, (char **) &ps1, &l1, &ps2, &l2);
-
+#endif
+
XftTextExtentsUtf8 (dpy, xftFont, str2, strlen (str2), &extents);
iInputWindowHeight = extents.height * 2 + extents.height / 2 + 8;
}
diff -Naur fcitx-2.1.0rc/src/MyErrorsHandlers.c fcitx-2.1.0rc-darwin/src/MyErrorsHandlers.c
--- fcitx-2.1.0rc/src/MyErrorsHandlers.c Sun May 16 04:18:26 2004
+++ fcitx-2.1.0rc-darwin/src/MyErrorsHandlers.c Mon May 24 00:21:00 2004
@@ -1,19 +1,23 @@
+#include <config.h>
+
#include "MyErrorsHandlers.h"
#include <stdio.h>
#include <signal.h>
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#if defined(DARWIN)
-#include <sys/wait.h>
-#else
+#endif
+#ifdef HAVE_WAIT_H
#include <wait.h>
+#else
+#include <sys/wait.h>
#endif
#include "wbx.h"
#include "erbi.h"
#include "py.h"
-#if defined(DARWIN)
+#ifndef SIGUNUSED
#define SIGUNUSED 32
#endif
diff -Naur fcitx-2.1.0rc/src/py.c fcitx-2.1.0rc-darwin/src/py.c
--- fcitx-2.1.0rc/src/py.c Fri May 21 03:21:08 2004
+++ fcitx-2.1.0rc-darwin/src/py.c Mon May 24 11:52:19 2004
@@ -1,3 +1,5 @@
+#include <config.h>
+
#include <stdio.h>
#include <sys/stat.h>
#include <limits.h>
@@ -5,6 +7,10 @@
#include <string.h>
#include <unistd.h>
+#ifdef HAVE_MACHINE_ENDIAN_H
+#include <machine/endian.h>
+#endif
+
#include "ime.h"
#include "tools.h"
#include "InputWindow.h"
@@ -95,11 +101,11 @@
{
FILE *fp;
char strPath[PATH_MAX];
- #if defined(DARWIN)
+// #if defined(DARWIN)
unsigned int i, j, iLen;
- #else
- int i, j, iLen;
- #endif
+// #else
+// int i, j, iLen;
+// #endif
strcpy (strPath, PKGDATADIR "/data/");
strcat (strPath, PY_BASE_FILE);
@@ -108,6 +114,10 @@
return False;
fread (&iPYFACount, sizeof (int), 1, fp);
+#if BYTE_ORDER == BIG_ENDIAN
+ iPYFACount = ReverseInt(iPYFACount);
+#endif
+
PYFAList = (PYFA *) malloc (sizeof (PYFA) * iPYFACount);
if (!PYFAList)
return False;
@@ -116,11 +126,17 @@
fread (PYFAList.strMap, sizeof (char) * 2, 1, fp);
PYFAList.strMap[2] = '\0';
fread (&(PYFAList.iBase), sizeof (int), 1, fp);
+#if BYTE_ORDER == BIG_ENDIAN
+ PYFAList.iBase = ReverseInt(PYFAList.iBase);
+#endif
PYFAList.pyBase = (PyBase *) malloc (sizeof (PyBase) * PYFAList.iBase);
for (j = 0; j < PYFAList.iBase; j++) {
fread (PYFAList.pyBase[j].strHZ, sizeof (char) * 2, 1, fp);
PYFAList.pyBase[j].strHZ[2] = '\0';
fread (&iLen, sizeof (int), 1, fp);
+#if BYTE_ORDER == BIG_ENDIAN
+ iLen = ReverseInt(iLen);
+#endif
PYFAList.pyBase[j].iIndex = iLen;
PYFAList.pyBase[j].iHit = 0;
PYFAList.pyBase[j].flag = 0;
@@ -164,7 +180,7 @@
else {
while (!feof (fp)) {
if (!fread (&i, sizeof (int), 1, fp))
- #if defined(DARWIN)
+ #if BYTE_ORDER == BIG_ENDIAN
i = ReverseInt(i);
#endif
break;
@@ -172,7 +188,7 @@
break;
strBase[2] = '\0';
if (!fread (&k, sizeof (int), 1, fp))
- #if defined(DARWIN)
+ #if BYTE_ORDER == BIG_ENDIAN
k = ReverseInt(k);
#endif
break;
@@ -184,6 +200,9 @@
for (k = 0; k < PYFAList.pyBase[j].iPhrase; k++) {
fread (&iLen, sizeof (int), 1, fp);
+#if BYTE_ORDER == BIG_ENDIAN
+ iLen = ReverseInt(iLen);
+#endif
PYFAList.pyBase[j].phrase[k].strMap = (char *) malloc (sizeof (char) * (iLen + 1));
fread (PYFAList.pyBase[j].phrase[k].strMap, sizeof (char) * iLen, 1, fp);
PYFAList.pyBase[j].phrase[k].strMap[iLen] = '\0';
@@ -425,7 +444,6 @@
LoadPYBaseDict ();
if (!bSingleHZMode && !bPYOtherDictLoaded)
LoadPYOtherDict ();
-
val = IRV_TO_PROCESS;
if (!bIsPYAddFreq && !bIsPYDelFreq && !bIsPYDelUserPhr) {
diff -Naur fcitx-2.1.0rc/src/tools.c fcitx-2.1.0rc-darwin/src/tools.c
--- fcitx-2.1.0rc/src/tools.c Thu May 20 11:04:58 2004
+++ fcitx-2.1.0rc-darwin/src/tools.c Mon May 24 10:18:58 2004
@@ -7,6 +7,10 @@
#include <string.h>
#include <ctype.h>
+#ifdef HAVE_MACHINE_ENDIAN_H
+#include <machine/endian.h>
+#endif
+
#include "ui.h"
#include "version.h"
#include "MainWindow.h"
@@ -105,17 +109,17 @@
extern Bool bUseAA;
#endif
-#if defined(DARWIN)
+#if BYTE_ORDER == BIG_ENDIAN
/* function to reverse byte order for integer
-this is required for Mac machine*/
-int ReverseInt (unsigned int pc_int)
+this is required for Big-endian machine*/
+unsigned int ReverseInt (unsigned int pc_int)
{
- int mac_int;
- unsigned char * p;
+ unsigned int mac_int;
- mac_int = pc_int;
- p = (unsigned char*) &pc_int;
- mac_int = (p[3] << 24) + (p[2] << 16) + (p[1] << 8) + p[0];
+ mac_int = ((pc_int & 0x000000ff) << 24) |
+ ((pc_int & 0x0000ff00) << 8) |
+ ((pc_int & 0x00ff0000) >> 8) |
+ ((pc_int & 0xff000000) >> 24);
return mac_int;
}
#endif
diff -Naur fcitx-2.1.0rc/src/tools.h fcitx-2.1.0rc-darwin/src/tools.h
--- fcitx-2.1.0rc/src/tools.h Sun May 16 00:32:05 2004
+++ fcitx-2.1.0rc-darwin/src/tools.h Mon May 24 10:09:25 2004
@@ -4,6 +4,11 @@
#include <stdio.h>
#include "ime.h"
+#ifdef HAVE_MACHINE_ENDIAN_H
+#include <machine/endian.h>
+#endif
+
+
#define MAX_HZ_SAVED 10
void LoadConfig (Bool bMode);
@@ -16,8 +21,8 @@
void SetTriggerKeys (char *str);
Bool CheckHZCharset (char *strHZ);
-#if defined(DARWIN)
-int ReverseInt (unsigned int pc_int);
+#if BYTE_ORDER == BIG_ENDIAN
+unsigned int ReverseInt (unsigned int pc_int);
#endif
#endif
diff -Naur fcitx-2.1.0rc/src/ui.c fcitx-2.1.0rc-darwin/src/ui.c
--- fcitx-2.1.0rc/src/ui.c Thu May 20 10:59:07 2004
+++ fcitx-2.1.0rc-darwin/src/ui.c Mon May 24 00:49:08 2004
@@ -1,3 +1,5 @@
+#include <config.h>
+
#include "ui.h"
#include <X11/Xlocale.h>
@@ -5,9 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#if defined(DARWIN)
-#include <sys/malloc.h>
-#else
+#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include <iconv.h>
@@ -281,7 +281,7 @@
XGlyphInfo extents;
unsigned char str1[100];
char *ps;
- int l1, l2;
+ size_t l1, l2;
if (!xftFont)
return 0;
@@ -290,7 +290,12 @@
l2 = 99;
ps = str1;
+#if ICONV_CONST == const
+ l1 = iconv (convUTF8, (const char **) &str, &l1, &ps, &l2);
+#else
l1 = iconv (convUTF8, (char **) &str, &l1, &ps, &l2);
+#endif
+
*ps = '\0';
XftTextExtentsUtf8 (dpy, font, str1, strlen (str1), &extents);
@@ -320,7 +325,7 @@
void OutputString (Window window, XftFont *font, char *str, int x, int y, XColor color)
{
char strOutput[100] = ""; //∏√≥§??”?∏√π?”√??
- int l1, l2;
+ size_t l1, l2;
char *ps;
XftColor xftColor;
XRenderColor renderColor;
@@ -333,7 +338,12 @@
l2 = 99;
ps = strOutput;
- l1 = iconv (convUTF8, (char **) (&str), &l1, &ps, &l2);
+#if ICONV_CONST == const
+ l1 = iconv (convUTF8, (const char **) (&str), &l1, &ps, &l2);
+#else
+ l1 = iconv (convUTF8, (char **) &str, &l1, &ps, &l2);
+#endif
+
renderColor.red = color.red;
renderColor.green = color.green;
diff -Naur fcitx-2.1.0rc/src/xim.c fcitx-2.1.0rc-darwin/src/xim.c
--- fcitx-2.1.0rc/src/xim.c Thu May 20 08:33:31 2004
+++ fcitx-2.1.0rc-darwin/src/xim.c Mon May 24 00:51:56 2004
@@ -1,3 +1,5 @@
+#include <config.h>
+
#include <X11/Xlib.h>
#include <iconv.h>
@@ -354,7 +356,12 @@
ps = strOutput;
l1 = strlen (strHZ);
l2 = 299;
- iconv (convUTF8, (char **) (&strHZ), (size_t *) & l1, &ps, (size_t *) & l2);
+#if ICONV_CONST == const
+ iconv (convUTF8, (const char **) (&strHZ), (size_t *) & l1, &ps, (size_t *) & l2);
+#else
+ iconv (convUTF8, (char **) &strHZ, (size_t *) &l1, &ps, (size_t *) &l2);
+#endif
+
*ps = '\0';
ps = strOutput;
}[/PHP] |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|