mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05: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 d2cf6912b9c1ddf8e608d3a0f663ffc7a3fec1c2)
This commit is contained in:
parent
b178ee6cb6
commit
bd777335e0
@ -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) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user