* Returns a new malloc'ed string if one is found * in the string table matching 'key'. Also translates * \n escapes in the string. */
| 198 | * \n escapes in the string. |
| 199 | */ |
| 200 | char *newStringForStringTableKey( |
| 201 | char *table, |
| 202 | char *key |
| 203 | ) |
| 204 | { |
| 205 | char *val, *newstr, *p; |
| 206 | INTN size; |
| 207 | |
| 208 | if (getValueForStringTableKey(table, key, &val, &size)) { |
| 209 | newstr = malloc(size+1); |
| 210 | for (p = newstr; size; size--, p++, val++) { |
| 211 | if ((*p = *val) == '\\') { |
| 212 | switch (*++val) { |
| 213 | case 'r': |
| 214 | *p = '\r'; |
| 215 | break; |
| 216 | case 'n': |
| 217 | *p = '\n'; |
| 218 | break; |
| 219 | case 't': |
| 220 | *p = '\t'; |
| 221 | break; |
| 222 | default: |
| 223 | *p = *val; |
| 224 | break; |
| 225 | } |
| 226 | size--; |
| 227 | } |
| 228 | } |
| 229 | *p = '\0'; |
| 230 | return newstr; |
| 231 | } else { |
| 232 | return 0; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | char * |
| 237 | newStringForKey(char *key) |
nothing calls this directly
no test coverage detected