Re: [Patch] fix non-english letters in root-menu -> windows and window-menu->In group issue



Hi All,

I am debugging this problem recently, but I found this problem caused by
some defect of librep. If someone is familiar with librep, please
continue to debug it. 

Attachment is a test program, it gets window name from sawfish wm
through connecting socket directly. you can test it using a window with
a utf-8 window name, eg. use firefox open a website with a utf-8
title(eg. www.163.cn).

compiling:
firstly, please set CLIENT_PATH correctly, then:
gcc -rdynamic -o testclient testclient.c -ldl

usage:
run xwininfo get a window id (with utf-8 window name)
run testclient, input the window id, you will see the window name from
sawfish wm.

following is my result:
This is the actual window name:

PNG image

But the test program is:
dcwang swida:~/pool$ xwininfo
xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x1c0004e "163|163邮箱|163博客|163聊天室|163相册|信息龙163.CN--个人娱乐专家 - Mozilla Firefox"


dcwang swida:~/pool$ ./testclient 
please input a window id(Note, window id must exists!):
0x1c0004e
window name is "163|163\0.)\/)*\/..\0-/\/..\//)|163\0--\/*-\/,*\0--\/..\/-*|163\0-0\/))\/**\0--\/-,\/.)\0--\/..\/-,|163\0-/\/,+\//0\0--\/).\/*,|\0-,\/0/\/-)\0-.\/))\/./\0.)\/0.\/,)163.CN--\0-,\//0\/.*\0-,\/0*\/0*\0--\/-0\//)\0-,\/0)\/*0\0-,\//0\/++\0--\/..\//. - Mozilla Firefox"

I think the bug must be exist in function "rep_call_lisp1", please see
the source file "src/server.c:110".


>>>>> Wang Diancheng <dianchengwang gmail com> writes:

    > Hi Chris, Sorry, I'm so busy recently, so many jobs. And
    > sawfish-ui use many lisp's knowledge, I'm not good at it, anyway,
    > I'll try to fix these bugs ASAP.

    > Wang Diancheng
    >>>>> Christopher Roy Bratusek <zanghar freenet de> writes:

    >> Any news from sawfish-ui + utf8? (just wanted to ask) Meanwhile
    >> I'll squash some other bugs :)

    >> Chris

    >> P.S.: I hope you fix it as this is -of course- currently blocking
    >> 1.5.0

    >> Am Mon, 01 Jun 2009 12:10:26 +0800 schrieb Wang Diancheng
    >> <dianchengwang gmail com>:

    >>> >>>>> Christopher Roy Bratusek <zanghar freenet de> writes:
    >>> 
    >>> > Am Sun, 31 May 2009 17:09:00 +0800 schrieb Wang Diancheng >
    >>> <dianchengwang gmail com>:
    >>> 
    >>> >> Hi,
    >>> >> 
    >>> >> attachments fix non-english letters in non-root-menu ->
    >>> windows >> and >> window-menu-> In group issue.
    >>> >> 
    >>> >> related Proposed Goals:
    >>> >> 
    >>> >> * Non-English Letters * CJK Letters
    >>> >> 
    >>> >> related bug:
    >>> >> 
    >>> >> 577913
    >>> >> 
    >>> >> This bug caused by function substring, when using this >>
    >>> function, it can lead to malformed UTF-8 characters.
    >>> >> 
    >>> >> I add a module to librep named utf8 located in
    >>> 'rep.util.utf8', >> which provide two function
    >>> "utf8-string-length" and >> "utf8-substring", then call them
    >>> when extracting substring to >> window-name.
    >>> >> 
    >>> >> Please review my patches, thanks.
    >>> >> 
    >>> >> Wang Diancheng
    >>> >> 
    >>> 
    >>> >> Hi Wang,
    >>> 
    >>> > long time ago I heard something from you :)
    >>> 
    >>> > I Just tried it: and it's working!
    >>> 
    >>> > While you're at UTF-8, could you try to fix the same issue in
    >>> > Sawfish-UI?
    >>> 
    >>> > That would be great!
    >>> 
    >>> > Thanks in advance, Chris
    >>> 
    >>> Hi, Christopher
    >>> 
    >>> I didn't read sawfish-ui code before, anyway, I'll try it.
    >>> 

#include <stdio.h>
#include <stdlib.h>

#include <dlfcn.h>
#define CLIENT_PATH "/usr/lib/rep/i686-everest-linux-gnu/sawfish/client.so"
int main()
{
     void *handle;
     int (*client_open)(char *);
     char *error;
     char *(*client_eval) (char *form, int *lenp, int *errorp);
     
     handle = dlopen(CLIENT_PATH, RTLD_LAZY);
     if (!handle) {
	  fprintf(stderr, "%s\n", dlerror());
	  exit(EXIT_FAILURE);
     }

           dlerror();    /* Clear any existing error */

           /* Writing: cosine = (double (*)(double)) dlsym(handle, "cos");
              would seem more natural, but the C99 standard leaves
              casting from "void *" to a function pointer undefined.
              The assignment used below is the POSIX.1-2003 (Technical
              Corrigendum 1) workaround; see the Rationale for the
              POSIX specification of dlsym(). */

           *(void **) (&client_open) = dlsym(handle, "client_open");
           *(void **) (&client_eval) = dlsym(handle, "client_eval");
           if ((error = dlerror()) != NULL)  {
               fprintf(stderr, "%s\n", error);
               exit(EXIT_FAILURE);
           }

           (*client_open)(NULL);
	   int errorp;
	   int lenp;
	   char window_id[256];
	   char form[512];
	   printf("please input a window id(Note, window id must exists!):\n");
	   scanf("%s", window_id);
	   sprintf(form,"(window-name (get-window-by-id %s))",window_id);
	   char *res = client_eval(form, &lenp,&errorp);
	   printf("window name is %s\n",res);
           dlclose(handle);
           exit(EXIT_SUCCESS);

}

/*
** Local Variables:
** compile-command: "gcc -rdynamic -o testclient testclient.c -ldl"
** End:
*/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]