| 132 | |
| 133 | |
| 134 | U32 CompilerStringTable::add(const char *str, bool caseSens, bool tag) |
| 135 | { |
| 136 | // Is it already in? |
| 137 | Entry **walk; |
| 138 | for(walk = &list; *walk; walk = &((*walk)->next)) |
| 139 | { |
| 140 | if((*walk)->tag != tag) |
| 141 | continue; |
| 142 | |
| 143 | if(caseSens) |
| 144 | { |
| 145 | if(!dStrcmp((*walk)->string, str)) |
| 146 | return (*walk)->start; |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | if(!dStricmp((*walk)->string, str)) |
| 151 | return (*walk)->start; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | // Write it out. |
| 156 | Entry *newStr = (Entry *) consoleAlloc(sizeof(Entry)); |
| 157 | *walk = newStr; |
| 158 | newStr->next = NULL; |
| 159 | newStr->start = totalLen; |
| 160 | U32 len = dStrlen(str) + 1; |
| 161 | if(tag && len < 7) // alloc space for the numeric tag 1 for tag, 5 for # and 1 for nul |
| 162 | len = 7; |
| 163 | totalLen += len; |
| 164 | newStr->string = (char *) consoleAlloc(len); |
| 165 | newStr->len = len; |
| 166 | newStr->tag = tag; |
| 167 | dStrcpy(newStr->string, str); |
| 168 | return newStr->start; |
| 169 | } |
| 170 | |
| 171 | U32 CompilerStringTable::addIntString(U32 value) |
| 172 | { |
no test coverage detected