ports/162465: [PATCH] Make sunpinyin 2.0.4-compatible, XDG-compatible, etc.

Zhihao Yuan lichray at gmail.com
Fri Nov 11 08:50:08 UTC 2011


>Number:         162465
>Category:       ports
>Synopsis:       [PATCH] Make sunpinyin 2.0.4-compatible, XDG-compatible, etc.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 11 08:50:07 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Zhihao Yuan
>Release:        FreeBSD 8.2-STABLE amd64
>Organization:
Northern Illinois University
>Environment:
System: FreeBSD elitebook.hp 8.2-STABLE FreeBSD 8.2-STABLE #3: Sun Oct 30 03:43:12 CDT 2011 lichray at elitebook.hp:/usr/obj/home/lichray/devel/freebsd-8/sys/HOUKAGO amd64


	
>Description:
	
	1. patch-2.0.4-compatible
	sunpinyin-2.0.4 is not released, but I'm porting a front-end which uses several changes from the newer version. This patch is enough.

	2. patch-xdg
	Change the config dir from .sunpinyin to .config/sunpinyin. It's safe because we have no front-ends in ports tree, so no one has these configured :)

	3. patch-src...
	Remove the unneeded and repeated message on terminal.
>How-To-Repeat:
	
>Fix:

	

--- sunpinyin-2.0.3_1.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/chinese/sunpinyin.orig/Makefile /usr/ports/chinese/sunpinyin/Makefile
--- /usr/ports/chinese/sunpinyin.orig/Makefile	2011-11-10 20:46:15.000000000 -0600
+++ /usr/ports/chinese/sunpinyin/Makefile	2011-11-10 22:40:43.167388774 -0600
@@ -7,6 +7,7 @@
 
 PORTNAME=	sunpinyin
 PORTVERSION=	2.0.3
+PORTREVISION=	1
 CATEGORIES=	chinese devel
 MASTER_SITES=	${MASTER_SITE_GOOGLE_CODE}:1 \
 		http://open-gram.googlecode.com/files/:2
diff -ruN --exclude=CVS /usr/ports/chinese/sunpinyin.orig/files/patch-2.0.4-compatible /usr/ports/chinese/sunpinyin/files/patch-2.0.4-compatible
--- /usr/ports/chinese/sunpinyin.orig/files/patch-2.0.4-compatible	1969-12-31 18:00:00.000000000 -0600
+++ /usr/ports/chinese/sunpinyin/files/patch-2.0.4-compatible	2011-11-10 23:05:36.750075415 -0600
@@ -0,0 +1,88 @@
+--- src/ime-core/imi_view_classic.h.orig	2011-02-17 21:39:52.000000000 -0600
++++ src/ime-core/imi_view_classic.h	2011-11-10 23:00:20.374788681 -0600
+@@ -61,6 +61,9 @@ public:
+     virtual int  onCandidatePageRequest(int pgno, bool relative);
+     virtual int  onCandidateSelectRequest(int index);
+ 
++    void makeSelection(int candiIdx, unsigned& mask);
++    void deleteCandidate(int candiIdx, unsigned& mask);
++
+ private:
+     unsigned    m_cursorFrIdx;
+     unsigned    m_candiFrIdx;
+@@ -75,8 +78,6 @@ private:
+     inline void _erase (bool backward, unsigned& mask);
+ 
+     inline void _getCandidates ();
+-    inline void _makeSelection (int candiIdx, unsigned& mask);
+-    inline void _deleteCandidate (int candiIdx, unsigned& mask);
+ 
+     inline void _commitChar (TWCHAR ch);
+     inline void _commitString (const wstring& wstr);
+--- src/ime-core/imi_view_classic.cpp.orig	2011-02-17 21:39:52.000000000 -0600
++++ src/ime-core/imi_view_classic.cpp	2011-11-10 23:01:01.213605402 -0600
+@@ -168,7 +168,7 @@ CIMIClassicView::onKeyEvent(const CKeyEv
+              !m_pIC->isEmpty ()) {
+         changeMasks |= KEYEVENT_USED;
+         unsigned sel = (keyvalue == '0'? 9: keyvalue-'1');        
+-        _deleteCandidate (sel, changeMasks);
++        deleteCandidate (sel, changeMasks);
+         goto PROCESSED;
+ 
+     } else if ((modifiers & (IM_CTRL_MASK | IM_ALT_MASK | IM_SUPER_MASK | IM_RELEASE_MASK)) == 0) {
+@@ -177,7 +177,7 @@ CIMIClassicView::onKeyEvent(const CKeyEv
+             if (!m_pIC->isEmpty ()) {
+                 changeMasks |= KEYEVENT_USED;
+                 unsigned sel = (keyvalue == '0'? 9: keyvalue-'1');
+-                _makeSelection (sel, changeMasks);
++                makeSelection (sel, changeMasks);
+             } else {
+                 m_numeric_mode = true;
+             }
+@@ -216,7 +216,7 @@ CIMIClassicView::onKeyEvent(const CKeyEv
+         } else if (keycode == IM_VK_SPACE) {
+             if (!m_pIC->isEmpty ()) {
+                 changeMasks |= KEYEVENT_USED;
+-                _makeSelection (0, changeMasks);
++                makeSelection (0, changeMasks);
+             } else {
+                 wstring wstr = (m_pIC->fullPuncOp()) (keyvalue);
+                 if (wstr.size()) {
+@@ -327,7 +327,7 @@ CIMIClassicView::onCandidateSelectReques
+     unsigned changeMasks = 0;
+ 
+     if (!m_pIC->isEmpty())
+-        _makeSelection(index, changeMasks);
++        makeSelection(index, changeMasks);
+ 
+     updateWindows(changeMasks);
+     return 0;
+@@ -612,7 +612,7 @@ CIMIClassicView::_moveEnd (unsigned& mas
+ }
+ 
+ void
+-CIMIClassicView::_makeSelection (int candiIdx, unsigned& mask)
++CIMIClassicView::makeSelection (int candiIdx, unsigned& mask)
+ {
+     candiIdx += m_candiPageFirst;
+     if (!m_tailSentence.empty ()) --candiIdx;
+@@ -655,7 +655,7 @@ CIMIClassicView::_makeSelection (int can
+ }
+     
+ void
+-CIMIClassicView::_deleteCandidate (int candiIdx, unsigned& mask)
++CIMIClassicView::deleteCandidate (int candiIdx, unsigned& mask)
+ {
+     candiIdx += m_candiPageFirst;
+     if (!m_tailSentence.empty ()) --candiIdx;
+--- src/ime-core/imi_view.h.orig	2011-02-17 21:39:52.000000000 -0600
++++ src/ime-core/imi_view.h	2011-11-10 23:05:14.515633839 -0600
+@@ -188,7 +188,7 @@ public:
+     CIMIWinHandler* getWinHandler(void) {return m_pWinHandler;}
+ 
+     void setHotkeyProfile (CHotkeyProfile *prof) { m_pHotkeyProfile = prof;}
+-    void setCandiWindowSize (unsigned size) {m_candiWindowSize = size<10? size: 10;}
++    void setCandiWindowSize (unsigned size) {m_candiWindowSize = size;}
+     CHotkeyProfile* getHotkeyProfile() { return m_pHotkeyProfile; }
+     unsigned getCandiWindowSize() { return m_candiWindowSize; }
+ 
diff -ruN --exclude=CVS /usr/ports/chinese/sunpinyin.orig/files/patch-src_ime-core_imi__winHandler.cpp /usr/ports/chinese/sunpinyin/files/patch-src_ime-core_imi__winHandler.cpp
--- /usr/ports/chinese/sunpinyin.orig/files/patch-src_ime-core_imi__winHandler.cpp	1969-12-31 18:00:00.000000000 -0600
+++ /usr/ports/chinese/sunpinyin/files/patch-src_ime-core_imi__winHandler.cpp	2011-11-11 02:31:36.212515692 -0600
@@ -0,0 +1,16 @@
+--- ./src/ime-core/imi_winHandler.cpp~	2011-02-17 21:39:52.000000000 -0600
++++ ./src/ime-core/imi_winHandler.cpp	2011-11-11 02:29:45.163309361 -0600
+@@ -85,6 +85,7 @@ CIMIWinHandler::throwBackKey(unsigned ke
+ void
+ CIMIWinHandler::updateStatus(int key, int value)
+ {
++#ifdef DEBUG
+     switch (key) {
+     case STATUS_ID_CN:
+         printf("CN status is "); break;
+@@ -99,4 +100,5 @@ CIMIWinHandler::updateStatus(int key, in
+ 
+     printf("%d\n", value);
+     fflush(stdout);
++#endif
+ }
diff -ruN --exclude=CVS /usr/ports/chinese/sunpinyin.orig/files/patch-xdg /usr/ports/chinese/sunpinyin/files/patch-xdg
--- /usr/ports/chinese/sunpinyin.orig/files/patch-xdg	1969-12-31 18:00:00.000000000 -0600
+++ /usr/ports/chinese/sunpinyin/files/patch-xdg	2011-11-10 23:09:34.000000000 -0600
@@ -0,0 +1,29 @@
+diff -uNr src/ime-core/imi_options.cpp src/ime-core/imi_options.cpp
+--- src/ime-core/imi_options.cpp	2010-09-22 13:14:32.876000000 +0800
++++ src/ime-core/imi_options.cpp	2010-09-22 13:21:48.181000000 +0800
+@@ -73,8 +73,11 @@
+ 
+     if (!m_user_data_dir.size()) {
+         char path[256];
+-        const char *home = getenv ("HOME");
+-        snprintf (path, sizeof(path), "%s/%s", home, SUNPINYIN_USERDATA_DIR_PREFIX);
++        const char *home = getenv ("XDG_CONFIG_HOME");
++        if(home == NULL)
++            snprintf (path, sizeof(path), "%s/.config/%s", getenv("HOME"), SUNPINYIN_USERDATA_DIR_PREFIX);
++        else
++            snprintf (path, sizeof(path), "%s/%s", home, SUNPINYIN_USERDATA_DIR_PREFIX);
+         m_user_data_dir = path;
+     }
+ 
+diff -uNr src/ime-core/imi_options.h src/ime-core/imi_options.h
+--- src/ime-core/imi_options.h	2010-09-22 13:14:35.883000000 +0800
++++ src/ime-core/imi_options.h	2010-09-22 13:15:20.760000002 +0800
+@@ -50,7 +50,7 @@
+ #include "pinyin/shuangpin_seg.h"
+ 
+ #ifndef SUNPINYIN_USERDATA_DIR_PREFIX
+-#define SUNPINYIN_USERDATA_DIR_PREFIX ".sunpinyin"
++#define SUNPINYIN_USERDATA_DIR_PREFIX "sunpinyin"
+ #endif
+ 
+ struct CSimplifiedChinesePolicy : public IConfigurable
--- sunpinyin-2.0.3_1.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list