Jonathan Harris <jhar(a)tardis.ed.ac.uk> writes:
static char buf[MAX_MENUITEM_LENGTH+2];
+ char *ptr;
unsigned int ll, lr;
/* Left flush part of the string */
ll = gui_item_display_flush_left (pgui_item, buf, MAX_MENUITEM_LENGTH);
+
+ /* Escape '&' as '&&' */
+ ptr = buf;
+ while ((ptr=memchr (ptr, '&', ll-(ptr-buf))) != NULL)
+ {
+ memmove (ptr+1, ptr, ll-(ptr-buf));
+ ll++;
+ ptr+=2;
+ }
Uhm... Since you are potentially doubling the size of the string,
shouldn't you make sure it fits in the buffer?,
Jan
--
Jan Vroonhof
http://www.math.ethz.ch/~vroonhof/
Mathematik, vroonhof @ math.ethz.ch
HG E16, ETH-Zentrum, Tel: +41-1-6325456/25154
Raemistrasse 101, CH-8092 Zuerich. Fax: +41-1-6321085