Date: Sun, 29 Dec 2002 19:43:52 +0800 (CST) From: Michael Hsin <mhsin@mhsin.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/46609: [PATCH] Fix chinese/irssi crashing problem Message-ID: <200212291143.gBTBhqkE094863@Ada.mhsin.org>
next in thread | raw e-mail | index | archive | help
>Number: 46609 >Category: ports >Synopsis: [PATCH] Fix chinese/irssi crashing problem >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Dec 29 03:50:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Michael Hsin >Release: FreeBSD 4.6-STABLE i386 >Organization: NTU CSIE >Environment: System: FreeBSD a.mhsin.org 4.6-STABLE FreeBSD 4.6-STABLE #2: Sun Sep 1 19:42:18 CST 2002 root@a.mhsin.org:/usr/obj/usr/src/sys/fake i386 >Description: chinese/irssi crashes when erase_to_end_of_line(^K) is invoked. >How-To-Repeat: Type some Chinese words, then press ^A ^K (move to begin of line, then erase to end of line). >Fix: Update two patch files(patch-src::fe-text::gui-entry.[ch]) and add a new patch file(patch-src::fe-text::gui-readline.c) with the shar file below: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # files # files/patch-src::fe-text::gui-entry.c # files/patch-src::fe-text::gui-entry.h # files/patch-src::fe-text::gui-readline.c # echo c - files mkdir -p files > /dev/null 2>&1 echo x - files/patch-src::fe-text::gui-entry.c sed 's/^X//' >files/patch-src::fe-text::gui-entry.c << 'END-of-files/patch-src::fe-text::gui-entry.c' X--- src/fe-text/gui-entry.c.orig Tue Oct 15 02:45:08 2002 X+++ src/fe-text/gui-entry.c Sun Dec 29 19:18:05 2002 X@@ -68,6 +68,27 @@ X g_free(entry); X } X X+/* Fixes the cursor position if it at big5_lo . X+ Direct: -1 , left shift 1 byte. X+ Direct: 0, +1 , right shift 1 byte. X+*/ X+static int _fix_big5_pos(unichar *p, int pos, int direct) X+{ X+ int newpos; X+ X+ for (newpos=0; newpos<pos && p[newpos] != 0; ) { X+ if (is_big5(p[newpos], p[newpos+1])) X+ newpos += 2; X+ else X+ newpos ++; X+ } X+ X+ if (newpos != pos) X+ pos += direct > 0 ? 1 : -1; X+ X+ return pos; X+} X+ X /* Fixes the cursor position in screen */ X static void gui_entry_fix_cursor(GUI_ENTRY_REC *entry) X { X@@ -85,6 +106,8 @@ X entry->scrstart = entry->pos - entry->scrpos; X } X X+ entry->scrstart = _fix_big5_pos(entry->text, entry->scrstart, -1); X+ X if (old_scrstart != entry->scrstart) X entry->redraw_needed_from = 0; X } X@@ -200,7 +223,7 @@ X } X } X X-void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const char *str) X+void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const unsigned char *str) X { X int oldlen; X X@@ -236,7 +259,7 @@ X entry->utf8 = utf8; X } X X-void gui_entry_set_text(GUI_ENTRY_REC *entry, const char *str) X+void gui_entry_set_text(GUI_ENTRY_REC *entry, const unsigned char *str) X { X g_return_if_fail(entry != NULL); X g_return_if_fail(str != NULL); X@@ -265,7 +288,7 @@ X return buf; X } X X-void gui_entry_insert_text(GUI_ENTRY_REC *entry, const char *str) X+void gui_entry_insert_text(GUI_ENTRY_REC *entry, const unsigned char *str) X { X unichar chr; X int i, len; X@@ -341,13 +364,30 @@ X return buf; X } X X+void gui_entry_erase_to(GUI_ENTRY_REC *entry, int pos, int update_cutbuffer) X+{ X+ int newpos, size = 0; X+ X+ g_return_if_fail(entry != NULL); X+ for(newpos = gui_entry_get_pos(entry); newpos > pos; size ++) X+ newpos = _fix_big5_pos(entry->text, newpos - 1, -1); X+ gui_entry_erase(entry, size, update_cutbuffer); X+} X+ X void gui_entry_erase(GUI_ENTRY_REC *entry, int size, int update_cutbuffer) X { X+ int newpos; X+ X g_return_if_fail(entry != NULL); X X if (entry->pos < size) X return; X X+ /* recount the erase size with big5 charsets */ X+ for (newpos = entry->pos; newpos > 0 && size > 0; size--) X+ newpos = _fix_big5_pos(entry->text, newpos-1, -1); X+ size = entry->pos - newpos; X+ X if (update_cutbuffer) { X /* put erased text to cutbuffer */ X if (entry->cutbuffer == NULL || entry->cutbuffer_len < size) { X@@ -471,10 +511,24 @@ X X void gui_entry_move_pos(GUI_ENTRY_REC *entry, int pos) X { X+ int newpos; X+ X g_return_if_fail(entry != NULL); X X- if (entry->pos+pos >= 0 && entry->pos+pos <= entry->text_len) X- entry->pos += pos; X+ /* move cursor with big5 charset */ X+ newpos = _fix_big5_pos(entry->text, entry->pos, -1); X+ if (pos > 0) { X+ while (pos > 0 && newpos < entry->text_len) { X+ newpos = _fix_big5_pos(entry->text, newpos+1, 1); X+ pos --; X+ } X+ } else { X+ while (pos < 0 && newpos > 0) { X+ newpos = _fix_big5_pos(entry->text, newpos-1, -1); X+ pos ++; X+ } X+ } X+ entry->pos = newpos; X X gui_entry_fix_cursor(entry); X gui_entry_draw(entry); END-of-files/patch-src::fe-text::gui-entry.c echo x - files/patch-src::fe-text::gui-entry.h sed 's/^X//' >files/patch-src::fe-text::gui-entry.h << 'END-of-files/patch-src::fe-text::gui-entry.h' X--- src/fe-text/gui-entry.h.orig Wed Feb 20 20:46:45 2002 X+++ src/fe-text/gui-entry.h Sun Dec 29 19:19:26 2002 X@@ -28,17 +28,18 @@ X void gui_entry_move(GUI_ENTRY_REC *entry, int xpos, int ypos, int width); X void gui_entry_set_active(GUI_ENTRY_REC *entry); X X-void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const char *str); X+void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const unsigned char *str); X void gui_entry_set_hidden(GUI_ENTRY_REC *entry, int hidden); X void gui_entry_set_utf8(GUI_ENTRY_REC *entry, int utf8); X X-void gui_entry_set_text(GUI_ENTRY_REC *entry, const char *str); X+void gui_entry_set_text(GUI_ENTRY_REC *entry, const unsigned char *str); X char *gui_entry_get_text(GUI_ENTRY_REC *entry); X X-void gui_entry_insert_text(GUI_ENTRY_REC *entry, const char *str); X+void gui_entry_insert_text(GUI_ENTRY_REC *entry, const unsigned char *str); X void gui_entry_insert_char(GUI_ENTRY_REC *entry, unichar chr); X X char *gui_entry_get_cutbuffer(GUI_ENTRY_REC *entry); X+void gui_entry_erase_to(GUI_ENTRY_REC *entry, int pos, int update_cutbuffer); X void gui_entry_erase(GUI_ENTRY_REC *entry, int size, int update_cutbuffer); X void gui_entry_erase_word(GUI_ENTRY_REC *entry, int to_space); X void gui_entry_erase_next_word(GUI_ENTRY_REC *entry, int to_space); END-of-files/patch-src::fe-text::gui-entry.h echo x - files/patch-src::fe-text::gui-readline.c sed 's/^X//' >files/patch-src::fe-text::gui-readline.c << 'END-of-files/patch-src::fe-text::gui-readline.c' X--- src/fe-text/gui-readline.c.orig Mon Nov 11 15:00:02 2002 X+++ src/fe-text/gui-readline.c Sun Dec 29 19:17:27 2002 X@@ -302,7 +302,7 @@ X X pos = gui_entry_get_pos(active_entry); X gui_entry_set_pos(active_entry, active_entry->text_len); X- gui_entry_erase(active_entry, active_entry->text_len - pos, TRUE); X+ gui_entry_erase_to(active_entry, pos, TRUE); X } X X static void key_yank_from_cutbuffer(void) END-of-files/patch-src::fe-text::gui-readline.c exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212291143.gBTBhqkE094863>