Beispiel #1
0
void Info_RemoveKey(VStr& s, const VStr& key)
{
    guard(Info_RemoveKey);
    if (s.IsEmpty())
    {
        return;
    }
    if (s.Length() >= MAX_INFO_STRING)
    {
        Host_Error("Info_RemoveKey: oversize infostring");
    }

    if (strchr(*key, '\\'))
    {
        GCon->Log("Can't use a key with a \\");
        return;
    }

    int i = 0;
    while (1)
    {
        int start = i;
        if (s[i] == '\\')
            i++;
        int KeyStart = i;
        while (s[i] != '\\')
        {
            if (!s[i])
                return;
            i++;
        }
        VStr pkey(s, KeyStart, i - KeyStart);
        i++;

        int ValStart = i;
        while (s[i] != '\\' && s[i])
        {
            i++;
        }
        VStr value(s, ValStart, i - ValStart);

        if (!key.Cmp(pkey))
        {
            s = VStr(s, 0, start) + VStr(s, i, s.Length() - i);	// remove this part
            return;
        }

        if (!s[i])
            return;
    }
    unguard;
}