aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2005-09-12 10:27:20 +0000
committerKim F. Storm2005-09-12 10:27:20 +0000
commitdf6304968670f3ead5a22d833b0442b9288d1ec7 (patch)
treeb09b2ec55b3b54e673bbe9a41010c9b00e90b826 /src
parentacc23b87a7e350f3e36c8968f1bcb9cc7c8d3333 (diff)
downloademacs-df6304968670f3ead5a22d833b0442b9288d1ec7.tar.gz
emacs-df6304968670f3ead5a22d833b0442b9288d1ec7.zip
(x_encode_text): Declare static. Add FREEP arg.
(x_set_name_internal): Call x_encode_text with new FREEP arg to know if xfree is needed instead of guessing.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 0bcf458b042..a0f6f3b3743 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1515,11 +1515,12 @@ x_set_scroll_bar_background (f, value, oldval)
1515 Otherwise store 0 in *STRINGP, which means that the `encoding' of 1515 Otherwise store 0 in *STRINGP, which means that the `encoding' of
1516 the result should be `COMPOUND_TEXT'. */ 1516 the result should be `COMPOUND_TEXT'. */
1517 1517
1518unsigned char * 1518static unsigned char *
1519x_encode_text (string, coding_system, selectionp, text_bytes, stringp) 1519x_encode_text (string, coding_system, selectionp, text_bytes, stringp, freep)
1520 Lisp_Object string, coding_system; 1520 Lisp_Object string, coding_system;
1521 int *text_bytes, *stringp; 1521 int *text_bytes, *stringp;
1522 int selectionp; 1522 int selectionp;
1523 int *freep;
1523{ 1524{
1524 unsigned char *str = SDATA (string); 1525 unsigned char *str = SDATA (string);
1525 int chars = SCHARS (string); 1526 int chars = SCHARS (string);
@@ -1536,6 +1537,7 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp)
1536 /* No multibyte character in OBJ. We need not encode it. */ 1537 /* No multibyte character in OBJ. We need not encode it. */
1537 *text_bytes = bytes; 1538 *text_bytes = bytes;
1538 *stringp = 1; 1539 *stringp = 1;
1540 *freep = 0;
1539 return str; 1541 return str;
1540 } 1542 }
1541 1543
@@ -1563,6 +1565,7 @@ x_encode_text (string, coding_system, selectionp, text_bytes, stringp)
1563 *stringp = (charset_info == 1 1565 *stringp = (charset_info == 1
1564 || (!EQ (coding_system, Qcompound_text) 1566 || (!EQ (coding_system, Qcompound_text)
1565 && !EQ (coding_system, Qcompound_text_with_extensions))); 1567 && !EQ (coding_system, Qcompound_text_with_extensions)));
1568 *freep = 1;
1566 return buf; 1569 return buf;
1567} 1570}
1568 1571
@@ -1601,16 +1604,13 @@ x_set_name_internal (f, name)
1601 in the future which can encode all Unicode characters. 1604 in the future which can encode all Unicode characters.
1602 But, for the moment, there's no way to know that the 1605 But, for the moment, there's no way to know that the
1603 current window manager supports it or not. */ 1606 current window manager supports it or not. */
1604 text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); 1607 text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp,
1608 &do_free_text_value);
1605 text.encoding = (stringp ? XA_STRING 1609 text.encoding = (stringp ? XA_STRING
1606 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1610 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1607 text.format = 8; 1611 text.format = 8;
1608 text.nitems = bytes; 1612 text.nitems = bytes;
1609 1613
1610 /* Check early, because ENCODE_UTF_8 below may GC and name may be
1611 relocated. */
1612 do_free_text_value = text.value != SDATA (name);
1613
1614 if (NILP (f->icon_name)) 1614 if (NILP (f->icon_name))
1615 { 1615 {
1616 icon = text; 1616 icon = text;
@@ -1619,12 +1619,11 @@ x_set_name_internal (f, name)
1619 { 1619 {
1620 /* See the above comment "Note: Encoding strategy". */ 1620 /* See the above comment "Note: Encoding strategy". */
1621 icon.value = x_encode_text (f->icon_name, coding_system, 0, 1621 icon.value = x_encode_text (f->icon_name, coding_system, 0,
1622 &bytes, &stringp); 1622 &bytes, &stringp, &do_free_icon_value);
1623 icon.encoding = (stringp ? XA_STRING 1623 icon.encoding = (stringp ? XA_STRING
1624 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1624 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1625 icon.format = 8; 1625 icon.format = 8;
1626 icon.nitems = bytes; 1626 icon.nitems = bytes;
1627 do_free_icon_value = icon.value != SDATA (f->icon_name);
1628 } 1627 }
1629 1628
1630#ifdef USE_GTK 1629#ifdef USE_GTK
@@ -1987,7 +1986,7 @@ xic_create_fontsetname (base_fontname, motif)
1987 - the same but with the family also replaced with -*-*-. */ 1986 - the same but with the family also replaced with -*-*-. */
1988 char *p = base_fontname; 1987 char *p = base_fontname;
1989 int i; 1988 int i;
1990 1989
1991 for (i = 0; *p; p++) 1990 for (i = 0; *p; p++)
1992 if (*p == '-') i++; 1991 if (*p == '-') i++;
1993 if (i != 14) 1992 if (i != 14)
@@ -2011,7 +2010,7 @@ xic_create_fontsetname (base_fontname, motif)
2011 char *allcs = "*-*-*-*-*-*-*"; 2010 char *allcs = "*-*-*-*-*-*-*";
2012 char *allfamilies = "-*-*-"; 2011 char *allfamilies = "-*-*-";
2013 char *all = "*-*-*-*-"; 2012 char *all = "*-*-*-*-";
2014 2013
2015 for (i = 0, p = base_fontname; i < 8; p++) 2014 for (i = 0, p = base_fontname; i < 8; p++)
2016 { 2015 {
2017 if (*p == '-') 2016 if (*p == '-')