1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-28 01:35:32 +00:00

Save X11 window title regardless of unconvertible characters

If Xutf8TextPropertyToTextList or XmbTextPropertyToTextList returns a
positive number, that means some characters were unconvertible and
have been replaced with XDefaultString().  Use the resulting string
even in that case, as if the function had returned Success.
The previous version ignored the string and didn't even free it.
(cherry picked from commit d2cf6912b9)
This commit is contained in:
Kalle Olavi Niemitalo 2011-04-13 00:18:32 +03:00 committed by Kalle Olavi Niemitalo
parent b178ee6cb6
commit bd777335e0

View File

@ -506,19 +506,27 @@ xprop_to_string(Display *display, const XTextProperty *text_prop, int to_cp)
unsigned char *ret = NULL;
/* <X11/Xlib.h> defines X_HAVE_UTF8_STRING if
* Xutf8TextPropertyToTextList is available. */
* Xutf8TextPropertyToTextList is available.
*
* The X...TextPropertyToTextList functions return a negative
* error code, or Success=0, or the number of unconvertible
* characters. Use the result even if some characters were
* unconvertible, because convert_string() can be lossy too,
* and it seems better to restore an approximation of the
* original title than to restore a default title that may be
* entirely different. */
#if defined(CONFIG_UTF8) && defined(X_HAVE_UTF8_STRING)
from_cp = get_cp_index("UTF-8");
if (Xutf8TextPropertyToTextList(display, text_prop, &list,
&count) != Success)
&count) < 0)
return NULL;
#else /* !defined(X_HAVE_UTF8_STRING) || !defined(CONFIG_UTF8) */
from_cp = get_cp_index("System");
if (XmbTextPropertyToTextList(display, text_prop, &list,
&count) != Success)
&count) < 0)
return NULL;
#endif /* !defined(X_HAVE_UTF8_STRING) || !defined(CONFIG_UTF8) */