/** * @brief Get the start and end point of a block in the given text * @param[in,out] text The text pointer to get the start and end for. The pointer is set to the end of the block in this function. * @param[out] start The pointer to the beginning of the block * @return The amount of characters in the block, or -1 if the text does not start with the script block character '{' */ int Com_GetBlock (const char **text, const char **start) { const char *token = Com_Parse(text); if (*token != '{') return -1; *start = *text; Com_SkipBlock(text); const char *end = *text - 1; /* The pointer to the end of the block */ return end - *start; }
static void CL_ParseMessageID (const char* name, const char** text) { /* get it's body */ const char* token = Com_Parse(text); if (!*text || *token != '{') { Com_Printf("CL_ParseMessageID: msgid \"%s\" without body ignored\n", name); return; } /* search for game types with same name */ int i; for (i = 0; i < numMsgIDs; i++) if (Q_streq(token, msgIDs[i].id)) break; if (i == numMsgIDs) { msgid_t* msgid = &msgIDs[numMsgIDs++]; if (numMsgIDs >= MAX_MSGIDS) Sys_Error("CL_ParseMessageID: MAX_MSGIDS exceeded"); OBJZERO(*msgid); msgid->id = Mem_PoolStrDup(name, cl_msgidPool, 0); const unsigned int hash = Com_HashKey(msgid->id, MAX_MSGIDHASH); HASH_Add(msgIDHash, msgid, hash); do { const char* errhead = "CL_ParseMessageID: unexpected end of file (msgid "; token = Com_EParse(text, errhead, name); if (!*text) break; if (*token == '}') break; if (Q_streq(token, "text")) { /* found a definition */ token = Com_EParse(text, errhead, name, msgIDText, MSGIDSIZE); if (!*text) break; if (token[0] == '_') token++; if (token[0] != '\0') msgid->text = _(token); else msgid->text = token; if (msgid->text == token) { msgid->text = Mem_PoolStrDup(token, cl_msgidPool, 0); Com_Printf("no translation for %s\n", msgid->id); } } } while (*text); } else { Com_Printf("CL_ParseMessageID: msgid \"%s\" with same already exists - ignore the second one\n", name); Com_SkipBlock(text); } }