Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jan 2002 01:35:25 +0800 (CST)
From:      mhsin@mhsin.org
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   ports/34343: chinese/irssi will crash when ^K at beginning of line
Message-ID:  <200201271735.g0RHZP630706@mhsin.org>

next in thread | raw e-mail | index | archive | help

>Number:         34343
>Category:       ports
>Synopsis:       chinese/irssi will crash when ^K at beginning of line
>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 Jan 27 09:40:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Michael Hsin
>Release:        FreeBSD 4.3-RELEASE i386
>Organization:
>Environment:
System: FreeBSD mhsin.org 4.3-RELEASE FreeBSD 4.3-RELEASE #1: Sat Jun 9 19:54:25 CST 2001 root@mhsin.org:/usr/src/sys/compile/mhsin i386


>Description:
	When use ^K (erase to end of line) at beginning of a line which
	has a Big5 word at beginning, chinese/irssi will invoke an assertion
	error.
>How-To-Repeat:
	Run chinese/irssi, type a Big5 word, move to beginning of line, then
	press ^K to erase whole line. 
>Fix:
	New files/patch_src_fe-text_gui-entry.c
	(Also add a variable in settings to control Big5 style cursor
	 movement. 
	 
	 "fe-text" = { big5_cursor_movement = "yes"; };
	)

--- src/fe-text/gui-entry.c.orig	Sun Mar  4 02:04:10 2001
+++ src/fe-text/gui-entry.c	Sat Jan 26 20:38:19 2002
@@ -29,6 +29,28 @@
 static int prompt_hidden;
 static char *prompt;
 
+#ifdef WANT_BIG5
+#include "settings.h"
+
+int gui_is_big5(char *str, int pos)
+{
+  int a;
+  
+  if(pos < 0)
+    return 0;
+  for(a = 0; a < pos;)
+  {
+    if(str[0] == '\0')
+      break;
+    if(is_big5(str[a], str[a + 1]))
+      a += 2;
+    else
+      a ++;
+  }
+  return ((a == pos) && is_big5(str[a], str[a + 1]));
+}
+#endif WANT_BIG5
+
 static void entry_screenpos(void)
 {
 	if (pos-scrstart < COLS-2-promptlen && pos-scrstart > 0) {
@@ -42,6 +64,14 @@
 	} else {
 		scrpos = (COLS-promptlen)*2/3;
 		scrstart = pos-scrpos;
+#ifdef WANT_BIG5
+		if((scrstart > 0) &&
+		   gui_is_big5(entry->str, scrstart - 1))
+		{
+		  scrstart --;
+		  scrpos ++;
+		}
+#endif WANT_BIG5
 	}
 }
 
@@ -152,6 +182,12 @@
 {
 	if (pos < size) return;
 
+#ifdef WANT_BIG5
+	if (settings_get_bool("big5_cursor_movement"))
+	  if(size == 1 && gui_is_big5(entry->str, pos - 2))
+	    size++;
+#endif WANT_BIG5
+
 	pos -= size;
 	g_string_erase(entry, pos, size);
 
@@ -217,6 +253,16 @@
 
 void gui_entry_move_pos(int p)
 {
+#ifdef WANT_BIG5
+	if(settings_get_bool("big5_cursor_movement"))
+	{
+	  if (p == 1 && gui_is_big5(entry->str, pos))
+	    p++;
+	  else if (p == -1 && gui_is_big5(entry->str, pos - 2))
+	    p--;
+	}
+#endif WANT_BIG5
+
 	if (pos+p >= 0 && pos+p <= entry->len)
 		pos += p;
 
@@ -277,6 +323,9 @@
 	prompt = NULL; promptlen = 0;
 	permanent_prompt = FALSE;
         prompt_hidden = FALSE;
+#ifdef WANT_BIG5
+	settings_add_bool("fe-text", "big5_cursor_movement", FALSE);
+#endif WANT_BIG5
 }
 
 void gui_entry_deinit(void)

>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?200201271735.g0RHZP630706>