From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21280 invoked by alias); 5 Aug 2003 00:42:44 -0000 Mailing-List: contact guile-gtk-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: guile-gtk-owner@sources.redhat.com Received: (qmail 21272 invoked from network); 5 Aug 2003 00:42:43 -0000 Received: from unknown (HELO snoopy.pacific.net.au) (61.8.0.36) by sources.redhat.com with SMTP; 5 Aug 2003 00:42:43 -0000 Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.4) with ESMTP id h750gddK031407 for ; Tue, 5 Aug 2003 10:42:39 +1000 Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h750gcCh024137 for ; Tue, 5 Aug 2003 10:42:38 +1000 (EST) Received: from localhost (ppp64.dyn228.pacific.net.au [203.143.228.64]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h750gbPs017982 for ; Tue, 5 Aug 2003 10:42:37 +1000 (EST) Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19jpuF-0001Wd-00; Tue, 05 Aug 2003 10:42:27 +1000 To: guile-gtk@sources.redhat.com Subject: gdk-event-string and NULL From: Kevin Ryde Mail-Copies-To: never Date: Tue, 05 Aug 2003 00:42:00 -0000 Message-ID: <87vftd0wb0.fsf@zip.com.au> User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SW-Source: 2003-q3/txt/msg00025.txt.bz2 --=-=-= Content-length: 755 I propose to made a change, * gdk-1.2.defs, gdk-support.c (gdk_event_string): Return #f for key.string == NULL as occurs for GDK_KEY_RELEASE, previously returned an empty string, but only due to a of 0 bytes from NULL. Use scm_mem2string to return whole key.length, since string can contain '\0' bytes. I think this can be regarded as a bug fix. Returning an empty string for GDK_KEY_RELEASE looks like only a happy coincidence, not an intended feature. Certainly #f for NULL corresponds to the general behaviour in other places. I think it's unlikely anyone would be depending on an empty string, since it's the key press where one is interested in the string, there's nothing useful to get on the release. --=-=-= Content-Disposition: attachment; filename=gdk-support.c.event-string.diff Content-length: 967 --- gdk-support.c.~1.30.~ 2003-08-05 10:32:59.000000000 +1000 +++ gdk-support.c 2003-08-05 10:38:34.000000000 +1000 @@ -548,22 +548,22 @@ } } -gchar * +/* key.string should be NULL in GDK_KEY_RELEASE and non-NULL in + GDK_KEY_PRESS, but there's no need to be concerned about that, just + return a string or #f according to what the field contains. */ +SCM gdk_event_string (GdkEvent *event) { - switch (event->any.type) - { - case GDK_KEY_PRESS: - case GDK_KEY_RELEASE: - { - gchar *str = g_malloc (event->key.length+1); - strncpy (str, event->key.string, event->key.length); - str[event->key.length] = '\0'; - return str; - } - default: - return NULL; - } + switch (event->any.type) { + case GDK_KEY_PRESS: + case GDK_KEY_RELEASE: + if (event->key.string != NULL) + return scm_mem2string (event->key.string, event->key.length); + break; + default: + break; + } + return SCM_BOOL_F; } GdkWindow * --=-=-=--