+ buffer[bufp++] = *str++;
+ /*
+ * Though the character literals are more compact, most
+ * terminal descriptions use numbers and are not easy
+ * to read in character-literal form.
+ */
+ switch (numbers) {
+ case -1:
+ if (str[0] == S_QUOTE
+ && str[1] != '\\'
+ && REALPRINT(str+1)
+ && str[2] == S_QUOTE) {
+ sprintf(buffer+bufp, "{%d}", str[1]);
+ bufp += strlen(buffer+bufp);
+ str += 2;
+ } else {
+ buffer[bufp++] = *str;
+ }
+ break;
+ /*
+ * If we have a "%{number}", try to translate it into
+ * a "%'char'" form, since that will run a little faster
+ * when we're interpreting it. Also, having one form
+ * for the constant makes it simpler to compare terminal
+ * descriptions.
+ */
+ case 1:
+ if (str[0] == L_BRACE
+ && isdigit(str[1])) {
+ char *dst = 0;
+ long value = strtol(str+1, &dst, 0);
+ if (dst != 0
+ && *dst == R_BRACE
+ && value < 127
+ && value != '\\' /* FIXME */
+ && isprint((int)value)) {
+ ch = (int)value;
+ buffer[bufp++] = S_QUOTE;
+ if (ch == '\\'
+ || ch == S_QUOTE)
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = ch;
+ buffer[bufp++] = S_QUOTE;
+ str = dst;
+ } else {
+ buffer[bufp++] = *str;
+ }
+ } else {
+ buffer[bufp++] = *str;
+ }
+ break;
+ default:
+ buffer[bufp++] = *str;
+ break;
+ }