1 /* Copyright (c) 1992, 1999, 2001, 2002 John E. Davis
2 * This file is part of the S-Lang library.
4 * Trimmed down for use in GNU Midnight Commander.
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Perl Artistic License.
14 /* p and ch may point to the same buffer */
15 char *_SLexpand_escaped_char(char *p
, char *ch
)
18 int max
= 0, num
, base
= 0;
25 default: num
= ch1
; break;
26 case 'n': num
= '\n'; break;
27 case 't': num
= '\t'; break;
28 case 'v': num
= '\v'; break;
29 case 'b': num
= '\b'; break;
30 case 'r': num
= '\r'; break;
31 case 'f': num
= '\f'; break;
32 case 'E': case 'e': num
= 27; break;
37 case '0': case '1': case '2': case '3':
38 case '4': case '5': case '6': case '7':
40 base
= 8; i
= 2; num
= ch1
- '0';
43 case 'd': /* decimal -- S-Lang extension */
62 if ((ch1
<= max
) && (ch1
>= '0'))
64 num
= base
* num
+ (ch1
- '0');
69 if ((ch1
< 'a') || ((ch1
> 'f'))) break;
70 num
= base
* num
+ 10 + (ch1
- 'a');