int main () { static struct t_s { char s[14]; /* string to convert */ int base; long ret; /* result must */ int err; /* errno must */ unsigned char len; /* endptr displacement must */ } t[] = { { "2147483647", 0, 0x7fffffff, 0, 10 }, { "0x7fffffff", 0, 0x7fffffff, 0, 10 }, { "017777777777", 0, 0x7fffffff, 0, 12 }, { "2147483648", 0, 0x7fffffff, ERANGE, 10 }, { "0x80000000", 0, 0x7fffffff, ERANGE, 10 }, { "020000000000", 0, 0x7fffffff, ERANGE, 12 }, { "-2147483647", 0, 0x80000001, 0, 11 }, { "-0x7fffffff", 0, 0x80000001, 0, 11 }, { "-017777777777", 0, 0x80000001, 0, 13 }, { "-2147483648", 0, 0x80000000, 0, 11 }, { "-0x80000000", 0, 0x80000000, 0, 11 }, { "-020000000000", 0, 0x80000000, 0, 13 }, { "-2147483649", 0, 0x80000000, ERANGE, 11 }, { "-0x80000001", 0, 0x80000000, ERANGE, 11 }, { "-020000000001", 0, 0x80000000, ERANGE, 13 }, }; int i; for (i = 0; i != (int)(sizeof(t)/sizeof(t[0])); i++) { struct t_s *p = t+i; if (t_strtol (p->s, p->base, p->ret, p->err, p->len)) exit (i+1); } return 0; }
int main () { PROGMEM static const struct t_s { char s[34]; /* string to convert */ int base; long ret; /* result must */ int err; /* errno must */ unsigned char len; /* endptr displacement must */ } t[] = { { "0", 2, 0, 0, 1 }, { "1", 2, 1, 0, 1 }, { "-1", 2, -1, 0, 2 }, { "10101010", 2, 0xaa, 0, 8 }, { "1111111111111111111111111111110", 2, 0x7ffffffe, 0, 31 }, { "1111111111111111111111111111111", 2, 0x7fffffff, 0, 31 }, { "10000000000000000000000000000000", 2, 0x7fffffff, ERANGE, 32 }, { "10000000000000000000000000000001", 2, 0x7fffffff, ERANGE, 32 }, { "-1111111111111111111111111111111", 2, 0x80000001, 0, 32 }, { "-10000000000000000000000000000000", 2, 0x80000000, 0, 33 }, { "-10000000000000000000000000000001", 2, 0x80000000, ERANGE, 33 }, { "-10000000000000000000000000000010", 2, 0x80000000, ERANGE, 33 }, }; struct t_s tt; int i; for (i = 0; i != (int)(sizeof(t)/sizeof(t[0])); i++) { struct t_s *p; memcpy_P (&tt, t + i, sizeof(tt)); p = &tt; if (t_strtol (p->s, p->base, p->ret, p->err, p->len)) exit (i+1); } return 0; }
litehtml::tchar_t litehtml::el_before_after_base::convert_escape( const tchar_t* txt ) { tchar_t* sss = 0; return (tchar_t) t_strtol(txt, &sss, 16); }