=========================================================================== Parameter: - Returns: - Changes Globals: - ===========================================================================
| 180 | // Changes Globals: - |
| 181 | //=========================================================================== |
| 182 | void PS_CreatePunctuationTable(script_t *script, punctuation_t *punctuations) |
| 183 | { |
| 184 | int i; |
| 185 | punctuation_t *p, *lastp, *newp; |
| 186 | |
| 187 | //get memory for the table |
| 188 | if (!script->punctuationtable) script->punctuationtable = (punctuation_t **) |
| 189 | GetMemory(256 * sizeof(punctuation_t *)); |
| 190 | Com_Memset(script->punctuationtable, 0, 256 * sizeof(punctuation_t *)); |
| 191 | //add the punctuations in the list to the punctuation table |
| 192 | for (i = 0; punctuations[i].p; i++) |
| 193 | { |
| 194 | newp = &punctuations[i]; |
| 195 | lastp = NULL; |
| 196 | //sort the punctuations in this table entry on length (longer punctuations first) |
| 197 | for (p = script->punctuationtable[(unsigned int) newp->p[0]]; p; p = p->next) |
| 198 | { |
| 199 | if (strlen(p->p) < strlen(newp->p)) |
| 200 | { |
| 201 | newp->next = p; |
| 202 | if (lastp) lastp->next = newp; |
| 203 | else script->punctuationtable[(unsigned int) newp->p[0]] = newp; |
| 204 | break; |
| 205 | } //end if |
| 206 | lastp = p; |
| 207 | } //end for |
| 208 | if (!p) |
| 209 | { |
| 210 | newp->next = NULL; |
| 211 | if (lastp) lastp->next = newp; |
| 212 | else script->punctuationtable[(unsigned int) newp->p[0]] = newp; |
| 213 | } //end if |
| 214 | } //end for |
| 215 | } //end of the function PS_CreatePunctuationTable |
| 216 | //=========================================================================== |
| 217 | // |
| 218 | // Parameter: - |
no test coverage detected