Ejemplo n.º 1
0
bool ParseMenuItemLabel(char *p_string, char *&r_endstr, MCMenuItem *p_menuitem)
{
	char *t_str = p_string;
	while (t_str < r_endstr)
	{
		if (IsEscapeChar(t_str, r_endstr - t_str, p_menuitem->menumode))
		{
			memmove(t_str, t_str + 1, (r_endstr - t_str) - 1);
			r_endstr--;
			t_str++;
		}
		else if (p_menuitem->menumode != WM_OPTION && t_str[0] == '&' && p_menuitem->mnemonic == 0 && (r_endstr - t_str) > 1)
		{
			p_menuitem->mnemonic = (t_str - p_string) + 1;
			memmove(t_str, t_str + 1, (r_endstr - t_str) - 1);
			r_endstr--;
		}
		else if (p_menuitem->menumode != WM_OPTION && t_str[0] == '/')
		{
			t_str[0] = '\0';
			p_menuitem->label.set(p_string, t_str - p_string);
			t_str++;
			ParseMenuItemAccelerator(t_str, r_endstr, p_menuitem);
			return false;
		}
		else
			t_str++;

	}
	p_menuitem->label.set(p_string, t_str - p_string);
	return false;
}
Ejemplo n.º 2
0
/* Function: Filter ============================================================
 * Abstract:
 *  Filter the outgoing message to translate any bytes that conflict with
 *  escape chars.  If a byte does conflict, the byte is replaced with two
 *  bytes:  The first is the escape character and the second is the conflicted
 *  byte exclusive or'd with the mask character.  If a byte does not conflict,
 *  it is unchanged.  Returns the new size of the buffer after filtering.
 *
 * Note: In the worst case where every char is an escape char, the
 *       destination buffer will be 2 times the size of the source buffer.
 */
PRIVATE uint32_T Filter(char *dest, char *src, uint32_T bytes)
{
    uint32_T i;
    uint32_T newSize = bytes;
    char     *pDest  = dest;
    char     *pSrc   = src;

    for (i=0 ; i<bytes ; i++, pSrc++) {
	if (IsEscapeChar(*pSrc)) {
	    *pDest = escape_character;
	    pDest++;
	    *pDest = (char)((*pSrc) ^ mask_character);
	    pDest++;
	    newSize++;
	} else {
	    *pDest = *pSrc;
	    pDest++;
	}
    }
    return newSize;

} /* end Filter */