]> git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/src/third_party/duktape-1.3.0/src-separate/duk_util_misc.c
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / civetweb / src / third_party / duktape-1.3.0 / src-separate / duk_util_misc.c
1 /*
2 * Misc util stuff
3 */
4
5 #include "duk_internal.h"
6
7 /*
8 * Lowercase digits for radix values 2 to 36. Also doubles as lowercase
9 * hex nybble table.
10 */
11
12 DUK_INTERNAL duk_uint8_t duk_lc_digits[36] = {
13 '0', '1', '2', '3', '4', '5', '6', '7',
14 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
15 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
16 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
17 'w', 'x', 'y', 'z'
18 };
19
20 DUK_INTERNAL duk_uint8_t duk_uc_nybbles[16] = {
21 '0', '1', '2', '3', '4', '5', '6', '7',
22 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
23 };
24
25 /*
26 * Table for decoding ASCII hex digits, -1 if invalid.
27 */
28
29 DUK_INTERNAL duk_int8_t duk_hex_dectab[256] = {
30 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00-0x0f */
31 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10-0x1f */
32 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x20-0x2f */
33 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 0x30-0x3f */
34 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x40-0x4f */
35 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x50-0x5f */
36 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x60-0x6f */
37 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x70-0x7f */
38 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x80-0x8f */
39 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x90-0x9f */
40 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xa0-0xaf */
41 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb0-0xbf */
42 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc0-0xcf */
43 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd0-0xdf */
44 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe0-0xef */
45 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xf0-0xff */
46 };
47
48 /*
49 * Arbitrary byteswap for potentially unaligned values
50 *
51 * Used to byteswap pointers e.g. in debugger code.
52 */
53
54 #if defined(DUK_USE_DEBUGGER_SUPPORT) /* For now only needed by the debugger. */
55 DUK_INTERNAL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len) {
56 duk_uint8_t tmp;
57 duk_uint8_t *q = p + len - 1;
58
59 while (p - q < 0) {
60 tmp = *p;
61 *p = *q;
62 *q = tmp;
63 p++;
64 q--;
65 }
66 }
67 #endif