return str;
}
-/*
- * in-place interpretation of string:
- *
- * backslash-escaped: "\a\b\E\e\n\r\t", "\octal"
- * Ctrl chars: ^@ .. ^_, ^?
- *
- * Emacs-style: "M-" prefix
- *
- * Also,
- * "M-x" prefixed strings, append "\r" if needed
- * "\E]" prefixed strings (XTerm escape sequence) append ST if needed
- *
- * returns the converted string length
- */
-int
-rxvt_Str_escaped (char *str) NOTHROW
-{
- char ch, *s, *d;
- int i, num, append = 0;
-
- if (!str || !*str)
- return 0;
-
- d = s = str;
-
- if (*s == 'M' && s[1] == '-')
- {
- /* Emacs convenience, replace leading `M-..' with `\E..' */
- *d++ = C0_ESC;
- s += 2;
- if (toupper (*s) == 'X')
- /* append carriage-return for `M-xcommand' */
- for (*d++ = 'x', append = '\r', s++; isspace (*s); s++) ;
- }
- for (; (ch = *s++);)
- {
- if (ch == '\\')
- {
- ch = *s++;
- if (ch >= '0' && ch <= '7')
- { /* octal */
- num = ch - '0';
- for (i = 0; i < 2; i++, s++)
- {
- ch = *s;
- if (ch < '0' || ch > '7')
- break;
- num = num * 8 + ch - '0';
- }
- ch = (char)num;
- }
- else if (ch == 'a')
- ch = C0_BEL; /* bell */
- else if (ch == 'b')
- ch = C0_BS; /* backspace */
- else if (ch == 'E' || ch == 'e')
- ch = C0_ESC; /* escape */
- else if (ch == 'n')
- ch = '\n'; /* newline */
- else if (ch == 'r')
- ch = '\r'; /* carriage-return */
- else if (ch == 't')
- ch = C0_HT; /* tab */
- }
- else if (ch == '^')
- {
- ch = *s++;
- ch = toupper (ch);
- ch = (ch == '?' ? 127 : (ch - '@'));
- }
- *d++ = ch;
- }
-
- /* ESC] is an XTerm escape sequence, must be terminated */
- if (*str == '\0' && str[1] == C0_ESC && str[2] == ']')
- append = CHAR_ST;
-
- /* add trailing character as required */
- if (append && d[-1] != append)
- *d++ = append;
- *d = '\0';
-
- return (d - str);
-}
-
/*
* Split a comma-separated string into an array, stripping leading and
* trailing spaces from each entry. Empty strings are properly returned