示例#1
0
文件: ddicrawler.cpp 项目: mtassin/4e
// Why bother...
static void Trim_Eval_Whitespace(T_XML_Node node)
{
    long            result;
    T_Glyph_Ptr     ptr;
    T_XML_Node      child;
    T_Glyph         buffer[MAX_XML_BUFFER_SIZE];

    /* If this is an eval script node, trim whitespace on it
    */
    XML_Get_Name(node, buffer);
    if (strcmp(buffer, "eval") == 0) {
        XML_Get_PCDATA(node, buffer);
        ptr = buffer + strlen(buffer);
        while (x_Is_Space(ptr[-1]) && x_Is_Space(ptr[-2]))
            *--ptr = '\0';
        XML_Set_PCDATA(node, buffer);
        }

    /* Call this function recursively on all children
    */
    result = XML_Get_First_Child(node, &child);
    while (result == 0) {
        Trim_Eval_Whitespace(child);
        result = XML_Get_Next_Child(node, &child);
        }
}
示例#2
0
static void Output_Options(T_Background_Info * info, bool is_skill, T_List_Ids * id_list, C_Pool * pool)
{
    T_Glyph         backup;
    T_Glyph_Ptr     text, temp, end, table, search;
    bool            is_skip;
    T_Glyph         buffer[500];

    if (info->description == NULL)
        return;

    if (is_skill) {
        search = "Associated Skills: {/i}";
        table = "skill";
        }
    else {
        search = "Associated Languages: {/i}";
        table = "language";
        }

    text = strstr(info->description, search);
    if (text == NULL)
        return;
    text += strlen(search);
    while (x_Is_Space(*text))
        text++;

    /* Parse out the next skill name
    */
    while (true) {
        end = strchr(text, ',');
        end = Get_Earliest(end, strchr(text, '.'));
        end = Get_Earliest(end, strchr(text, '{'));
        if (end != NULL) {
            backup = *end;
            *end = '\0';
            }


        /* Note that Output_Language takes care of checking whether the
            language exists for us
        */
        if (!is_skill) {
            is_skip = (Mapping_Find("bglangskip", text, false, false) != NULL);
            if (!is_skip)
                Output_Language(info->node, text, info, id_list, pool, "User", "BackLang");
            }
        else {
            temp = Mapping_Find(table, text, false, true);
            if (temp != NULL)
                Output_Tag(info->node, "BackSkill", temp, info);
            else {
                sprintf(buffer, "Skill not found for backgrounds: %s\n", text);
                Log_Message(buffer);
                }
            }

        if (end != NULL)
            *end = backup;

        if ((end == NULL) || (*end == '{') || (*end == '\0'))
            return;

        /* Skip over spaces, commas, etc, to next skill
        */
        text = end + 1;
        while (x_Is_Space(*text) || x_Is_Punct(*text))
            text++;

        /* If we're at the end of the string, or if we hit a newline, we're
            done
        */
        if ((*text == '\0') || (*text == '{'))
            return;
        }
}