19#define TOUPPER(c) (islower(c) ? toupper(c) : (c))
20#define TOCTRL(x) (TOUPPER(x) & 037)
21#define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
22#define OCTVALUE(c) ((c) - '0')
23#define ISDIGIT(c) ((c) >= '0' && (c) <= '9')
24#define ISXDIGIT(c) (ISDIGIT((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
27 (((c) >= 'a' && (c) <= 'f') \
29 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
32char *
ansicstr (
const char *
string,
int len,
int flags,
int *sawc,
int *rlen)
43 if((
string == 0) || (len == 0) || (*
string ==
'\0'))
49 ret = (
char*)TAP_MemAlloc(4*len + 1);
56 for(r = ret, s =
string; s && *s;)
59 if (c !=
'\\' || *s ==
'\0')
65 case 'a': c =
'\a';
break;
66 case 'v': c =
'\v';
break;
67 case 'b': c =
'\b';
break;
69 case 'E': c =
ESC;
break;
70 case 'f': c =
'\f';
break;
71 case 'n': c =
'\n';
break;
72 case 'r': c =
'\r';
break;
73 case 't': c =
'\t';
break;
96 temp = 2 + ((flags & 1) && (c ==
'0'));
97 for (c -=
'0';
ISOCTAL (*s) && temp--; s++)
105 if ((flags & 2) && *s ==
'{')
111 for (temp = 2, c = 0;
ISXDIGIT ((
unsigned char)*s) && temp--; s++)
120 for ( ;
ISXDIGIT ((
unsigned char)*s); s++)
180 if(rlen) *rlen = r - ret;
183 else if((flags & 1) == 0 && *s == 0)
185 else if((flags & 1) == 0 && (c = *s))
188 if((flags & 2) && c ==
'\\' && c == *s)
211 if(rlen) *rlen = r - ret;
char * ansicstr(const char *string, int len, int flags, int *sawc, int *rlen)