| 4795 | static NEARDATA const char *oth_names[] = { "Bagged/Boxed items" }; |
| 4796 | |
| 4797 | DISABLE_WARNING_FORMAT_NONLITERAL |
| 4798 | |
| 4799 | char * |
| 4800 | let_to_name(char let, boolean unpaid, boolean showsym) |
| 4801 | { |
| 4802 | const char *ocsymfmt = " ('%c')"; |
| 4803 | const int invbuf_sympadding = 8; /* arbitrary */ |
| 4804 | const char *class_name; |
| 4805 | const char *pos; |
| 4806 | int oclass = (let >= 1 && let < MAXOCLASSES) ? let : 0; |
| 4807 | unsigned len; |
| 4808 | |
| 4809 | if (oclass) |
| 4810 | class_name = names[oclass]; |
| 4811 | else if ((pos = strchr(oth_symbols, let)) != 0) |
| 4812 | class_name = oth_names[pos - oth_symbols]; |
| 4813 | else |
| 4814 | class_name = names[ILLOBJ_CLASS]; |
| 4815 | |
| 4816 | len = Strlen(class_name) + (unpaid ? sizeof "unpaid_" : sizeof "") |
| 4817 | + (oclass ? (Strlen(ocsymfmt) + invbuf_sympadding) : 0); |
| 4818 | if (len > gi.invbufsiz) { |
| 4819 | if (gi.invbuf) |
| 4820 | free((genericptr_t) gi.invbuf); |
| 4821 | gi.invbufsiz = len + 10; /* add slop to reduce incremental realloc */ |
| 4822 | gi.invbuf = (char *) alloc(gi.invbufsiz); |
| 4823 | } |
| 4824 | if (unpaid) |
| 4825 | Strcat(strcpy(gi.invbuf, "Unpaid "), class_name); |
| 4826 | else |
| 4827 | Strcpy(gi.invbuf, class_name); |
| 4828 | if ((oclass != 0) && showsym) { |
| 4829 | char *bp = eos(gi.invbuf); |
| 4830 | int mlen = invbuf_sympadding - Strlen(class_name); |
| 4831 | while (--mlen > 0) { |
| 4832 | *bp = ' '; |
| 4833 | bp++; |
| 4834 | } |
| 4835 | *bp = '\0'; |
| 4836 | Sprintf(eos(gi.invbuf), ocsymfmt, def_oc_syms[oclass].sym); |
| 4837 | } |
| 4838 | return gi.invbuf; |
| 4839 | } |
| 4840 | |
| 4841 | RESTORE_WARNING_FORMAT_NONLITERAL |
| 4842 |
no test coverage detected