--- xselect.c 2003-04-07 04:35:06.000000000 +0800 +++ /home/huxw/tmp_src/emacs/src/xselect.c 2003-05-26 10:29:46.641097720 +0800 @@ -1496,6 +1496,11 @@ Lisp_Object target_type; /* for error messages only */ Atom selection_atom; /* for error messages only */ { + // by huxw start here + XTextProperty text_prop; + char** local_list; + int local_number; + // by huxw end here Atom actual_type; int actual_format; unsigned long actual_size; @@ -1554,12 +1559,50 @@ /* It's been read. Now convert it to a lisp object in some semi-rational manner. */ + //by huxw start here + if (XSupportsLocale()) { + int local_status; + + text_prop.value = (char*)data; + text_prop.encoding = actual_type; + text_prop.format = actual_format; + text_prop.nitems = actual_size; + + local_status = XmbTextPropertyToTextList(display, &text_prop, &local_list, &local_number); + if (local_status < Success || !local_number || !*local_list ) { + printf("failed due to XmbTextPropertyToTextList\n"); + printf("XNoMemory is %d, XLocaleNotSupported is %d, XConverterNotFound is %d\n", XNoMemory, XLocaleNotSupported, XConverterNotFound); + printf("status is %d, number is %d, \n", local_status, local_number ); + } else { + printf("XmbTextPropertyToTextList successfullly\n"); + xfree((char*)data); + printf("xfree data successfully\n"); + data = strdup(*local_list); + printf("strdup data successfully, data is %s\n", (char*)data); + XFreeStringList(local_list); + printf("XFreeStringList successfully\n"); + } + } else { + printf("no support this locale\n"); + } + //by huxw end here + +#if 0 val = selection_data_to_lisp_data (display, data, bytes, actual_type, actual_format); +#else + val = selection_data_to_lisp_data (display, data, strlen(data), actual_type, actual_format); +#endif /* Use xfree, not XFree, because x_get_window_property calls xmalloc itself. */ - xfree ((char *) data); + + // by huxw start here +// xfree ((char *) data); + printf("selection_data_to_lisp_data successfully\n"); + free(data); + printf("free data successfully\n"); + // by huxw end here return val; }