add string to wish history list */
| 6224 | |
| 6225 | /* add string to wish history list */ |
| 6226 | void |
| 6227 | wish_history_add(char *buf) |
| 6228 | { |
| 6229 | #ifdef DEBUG |
| 6230 | int i; |
| 6231 | |
| 6232 | if (!wizard) |
| 6233 | return; |
| 6234 | |
| 6235 | for (i = 0; i < MAX_WISH_HISTORY; i++) { |
| 6236 | int idx = (wish_history_idx + i) % MAX_WISH_HISTORY; |
| 6237 | |
| 6238 | if (!wish_history[idx]) |
| 6239 | continue; |
| 6240 | if (!strncmpi(wish_history[idx], buf, strlen(wish_history[idx]))) |
| 6241 | break; |
| 6242 | |
| 6243 | } |
| 6244 | |
| 6245 | if (i == MAX_WISH_HISTORY) { |
| 6246 | int idx = (wish_history_idx + i) % MAX_WISH_HISTORY; |
| 6247 | |
| 6248 | if (wish_history[idx]) |
| 6249 | free(wish_history[idx]); |
| 6250 | wish_history[idx] = (char *) alloc(strlen(buf) + 1); |
| 6251 | strcpy(wish_history[idx], buf); |
| 6252 | wish_history_idx = (wish_history_idx + 1) % MAX_WISH_HISTORY; |
| 6253 | } |
| 6254 | #endif /* DEBUG */ |
| 6255 | } |
| 6256 | |
| 6257 | /* release any old wish text; called from freedynamicdata(save.c) */ |
| 6258 | void |
no test coverage detected