mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-14 10:18:02 +00:00
Get LIBC_FMT to build for aarch64
This commit is contained in:
parent
036b9a0002
commit
7e46645193
15 changed files with 482 additions and 618 deletions
|
@ -1,300 +0,0 @@
|
||||||
#if 0
|
|
||||||
/*─────────────────────────────────────────────────────────────────╗
|
|
||||||
│ To the extent possible under law, Justine Tunney has waived │
|
|
||||||
│ all copyright and related or neighboring rights to this file, │
|
|
||||||
│ as it is written in the following disclaimers: │
|
|
||||||
│ • http://unlicense.org/ │
|
|
||||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
|
||||||
╚─────────────────────────────────────────────────────────────────*/
|
|
||||||
#endif
|
|
||||||
#include "libc/stdio/stdio.h"
|
|
||||||
#include "libc/str/str.h"
|
|
||||||
|
|
||||||
int _cescapec2(int);
|
|
||||||
|
|
||||||
uint32_t kCescapeC[256] = {
|
|
||||||
[0] = '\\' | '0' << 8 | '0' << 16 | '0' << 24,
|
|
||||||
[1] = '\\' | '0' << 8 | '0' << 16 | '1' << 24,
|
|
||||||
[2] = '\\' | '0' << 8 | '0' << 16 | '2' << 24,
|
|
||||||
[3] = '\\' | '0' << 8 | '0' << 16 | '3' << 24,
|
|
||||||
[4] = '\\' | '0' << 8 | '0' << 16 | '4' << 24,
|
|
||||||
[5] = '\\' | '0' << 8 | '0' << 16 | '5' << 24,
|
|
||||||
[6] = '\\' | '0' << 8 | '0' << 16 | '6' << 24,
|
|
||||||
[7] = '\\' | 'a' << 8,
|
|
||||||
[8] = '\\' | 'b' << 8,
|
|
||||||
[9] = '\\' | 't' << 8,
|
|
||||||
[10] = '\\' | 'n' << 8,
|
|
||||||
[11] = '\\' | 'v' << 8,
|
|
||||||
[12] = '\\' | 'f' << 8,
|
|
||||||
[13] = '\\' | 'r' << 8,
|
|
||||||
[14] = '\\' | '0' << 8 | '1' << 16 | '6' << 24,
|
|
||||||
[15] = '\\' | '0' << 8 | '1' << 16 | '7' << 24,
|
|
||||||
[16] = '\\' | '0' << 8 | '2' << 16 | '0' << 24,
|
|
||||||
[17] = '\\' | '0' << 8 | '2' << 16 | '1' << 24,
|
|
||||||
[18] = '\\' | '0' << 8 | '2' << 16 | '2' << 24,
|
|
||||||
[19] = '\\' | '0' << 8 | '2' << 16 | '3' << 24,
|
|
||||||
[20] = '\\' | '0' << 8 | '2' << 16 | '4' << 24,
|
|
||||||
[21] = '\\' | '0' << 8 | '2' << 16 | '5' << 24,
|
|
||||||
[22] = '\\' | '0' << 8 | '2' << 16 | '6' << 24,
|
|
||||||
[23] = '\\' | '0' << 8 | '2' << 16 | '7' << 24,
|
|
||||||
[24] = '\\' | '0' << 8 | '3' << 16 | '0' << 24,
|
|
||||||
[25] = '\\' | '0' << 8 | '3' << 16 | '1' << 24,
|
|
||||||
[26] = '\\' | '0' << 8 | '3' << 16 | '2' << 24,
|
|
||||||
[27] = '\\' | '0' << 8 | '3' << 16 | '3' << 24,
|
|
||||||
[28] = '\\' | '0' << 8 | '3' << 16 | '4' << 24,
|
|
||||||
[29] = '\\' | '0' << 8 | '3' << 16 | '5' << 24,
|
|
||||||
[30] = '\\' | '0' << 8 | '3' << 16 | '6' << 24,
|
|
||||||
[31] = '\\' | '0' << 8 | '3' << 16 | '7' << 24,
|
|
||||||
[32] = ' ',
|
|
||||||
[33] = '!',
|
|
||||||
[34] = '\\' | '"' << 8,
|
|
||||||
[35] = '#',
|
|
||||||
[36] = '$',
|
|
||||||
[37] = '%',
|
|
||||||
[38] = '&',
|
|
||||||
[39] = '\\' | '\'' << 8,
|
|
||||||
[40] = '(',
|
|
||||||
[41] = ')',
|
|
||||||
[42] = '*',
|
|
||||||
[43] = '+',
|
|
||||||
[44] = ',',
|
|
||||||
[45] = '-',
|
|
||||||
[46] = '.',
|
|
||||||
[47] = '/',
|
|
||||||
[48] = '0',
|
|
||||||
[49] = '1',
|
|
||||||
[50] = '2',
|
|
||||||
[51] = '3',
|
|
||||||
[52] = '4',
|
|
||||||
[53] = '5',
|
|
||||||
[54] = '6',
|
|
||||||
[55] = '7',
|
|
||||||
[56] = '8',
|
|
||||||
[57] = '9',
|
|
||||||
[58] = ':',
|
|
||||||
[59] = ';',
|
|
||||||
[60] = '<',
|
|
||||||
[61] = '=',
|
|
||||||
[62] = '>',
|
|
||||||
[63] = '?',
|
|
||||||
[64] = '@',
|
|
||||||
[65] = 'A',
|
|
||||||
[66] = 'B',
|
|
||||||
[67] = 'C',
|
|
||||||
[68] = 'D',
|
|
||||||
[69] = 'E',
|
|
||||||
[70] = 'F',
|
|
||||||
[71] = 'G',
|
|
||||||
[72] = 'H',
|
|
||||||
[73] = 'I',
|
|
||||||
[74] = 'J',
|
|
||||||
[75] = 'K',
|
|
||||||
[76] = 'L',
|
|
||||||
[77] = 'M',
|
|
||||||
[78] = 'N',
|
|
||||||
[79] = 'O',
|
|
||||||
[80] = 'P',
|
|
||||||
[81] = 'Q',
|
|
||||||
[82] = 'R',
|
|
||||||
[83] = 'S',
|
|
||||||
[84] = 'T',
|
|
||||||
[85] = 'U',
|
|
||||||
[86] = 'V',
|
|
||||||
[87] = 'W',
|
|
||||||
[88] = 'X',
|
|
||||||
[89] = 'Y',
|
|
||||||
[90] = 'Z',
|
|
||||||
[91] = '[',
|
|
||||||
[92] = '\\' | '\\' << 8,
|
|
||||||
[93] = ']',
|
|
||||||
[94] = '^',
|
|
||||||
[95] = '_',
|
|
||||||
[96] = '`',
|
|
||||||
[97] = 'a',
|
|
||||||
[98] = 'b',
|
|
||||||
[99] = 'c',
|
|
||||||
[100] = 'd',
|
|
||||||
[101] = 'e',
|
|
||||||
[102] = 'f',
|
|
||||||
[103] = 'g',
|
|
||||||
[104] = 'h',
|
|
||||||
[105] = 'i',
|
|
||||||
[106] = 'j',
|
|
||||||
[107] = 'k',
|
|
||||||
[108] = 'l',
|
|
||||||
[109] = 'm',
|
|
||||||
[110] = 'n',
|
|
||||||
[111] = 'o',
|
|
||||||
[112] = 'p',
|
|
||||||
[113] = 'q',
|
|
||||||
[114] = 'r',
|
|
||||||
[115] = 's',
|
|
||||||
[116] = 't',
|
|
||||||
[117] = 'u',
|
|
||||||
[118] = 'v',
|
|
||||||
[119] = 'w',
|
|
||||||
[120] = 'x',
|
|
||||||
[121] = 'y',
|
|
||||||
[122] = 'z',
|
|
||||||
[123] = '{',
|
|
||||||
[124] = '|',
|
|
||||||
[125] = '}',
|
|
||||||
[126] = '~',
|
|
||||||
[127] = '\\' | '1' << 8 | '7' << 16 | '7' << 24,
|
|
||||||
[128] = '\\' | '2' << 8 | '0' << 16 | '0' << 24,
|
|
||||||
[129] = '\\' | '2' << 8 | '0' << 16 | '1' << 24,
|
|
||||||
[130] = '\\' | '2' << 8 | '0' << 16 | '2' << 24,
|
|
||||||
[131] = '\\' | '2' << 8 | '0' << 16 | '3' << 24,
|
|
||||||
[132] = '\\' | '2' << 8 | '0' << 16 | '4' << 24,
|
|
||||||
[133] = '\\' | '2' << 8 | '0' << 16 | '5' << 24,
|
|
||||||
[134] = '\\' | '2' << 8 | '0' << 16 | '6' << 24,
|
|
||||||
[135] = '\\' | '2' << 8 | '0' << 16 | '7' << 24,
|
|
||||||
[136] = '\\' | '2' << 8 | '1' << 16 | '0' << 24,
|
|
||||||
[137] = '\\' | '2' << 8 | '1' << 16 | '1' << 24,
|
|
||||||
[138] = '\\' | '2' << 8 | '1' << 16 | '2' << 24,
|
|
||||||
[139] = '\\' | '2' << 8 | '1' << 16 | '3' << 24,
|
|
||||||
[140] = '\\' | '2' << 8 | '1' << 16 | '4' << 24,
|
|
||||||
[141] = '\\' | '2' << 8 | '1' << 16 | '5' << 24,
|
|
||||||
[142] = '\\' | '2' << 8 | '1' << 16 | '6' << 24,
|
|
||||||
[143] = '\\' | '2' << 8 | '1' << 16 | '7' << 24,
|
|
||||||
[144] = '\\' | '2' << 8 | '2' << 16 | '0' << 24,
|
|
||||||
[145] = '\\' | '2' << 8 | '2' << 16 | '1' << 24,
|
|
||||||
[146] = '\\' | '2' << 8 | '2' << 16 | '2' << 24,
|
|
||||||
[147] = '\\' | '2' << 8 | '2' << 16 | '3' << 24,
|
|
||||||
[148] = '\\' | '2' << 8 | '2' << 16 | '4' << 24,
|
|
||||||
[149] = '\\' | '2' << 8 | '2' << 16 | '5' << 24,
|
|
||||||
[150] = '\\' | '2' << 8 | '2' << 16 | '6' << 24,
|
|
||||||
[151] = '\\' | '2' << 8 | '2' << 16 | '7' << 24,
|
|
||||||
[152] = '\\' | '2' << 8 | '3' << 16 | '0' << 24,
|
|
||||||
[153] = '\\' | '2' << 8 | '3' << 16 | '1' << 24,
|
|
||||||
[154] = '\\' | '2' << 8 | '3' << 16 | '2' << 24,
|
|
||||||
[155] = '\\' | '2' << 8 | '3' << 16 | '3' << 24,
|
|
||||||
[156] = '\\' | '2' << 8 | '3' << 16 | '4' << 24,
|
|
||||||
[157] = '\\' | '2' << 8 | '3' << 16 | '5' << 24,
|
|
||||||
[158] = '\\' | '2' << 8 | '3' << 16 | '6' << 24,
|
|
||||||
[159] = '\\' | '2' << 8 | '3' << 16 | '7' << 24,
|
|
||||||
[160] = '\\' | '2' << 8 | '4' << 16 | '0' << 24,
|
|
||||||
[161] = '\\' | '2' << 8 | '4' << 16 | '1' << 24,
|
|
||||||
[162] = '\\' | '2' << 8 | '4' << 16 | '2' << 24,
|
|
||||||
[163] = '\\' | '2' << 8 | '4' << 16 | '3' << 24,
|
|
||||||
[164] = '\\' | '2' << 8 | '4' << 16 | '4' << 24,
|
|
||||||
[165] = '\\' | '2' << 8 | '4' << 16 | '5' << 24,
|
|
||||||
[166] = '\\' | '2' << 8 | '4' << 16 | '6' << 24,
|
|
||||||
[167] = '\\' | '2' << 8 | '4' << 16 | '7' << 24,
|
|
||||||
[168] = '\\' | '2' << 8 | '5' << 16 | '0' << 24,
|
|
||||||
[169] = '\\' | '2' << 8 | '5' << 16 | '1' << 24,
|
|
||||||
[170] = '\\' | '2' << 8 | '5' << 16 | '2' << 24,
|
|
||||||
[171] = '\\' | '2' << 8 | '5' << 16 | '3' << 24,
|
|
||||||
[172] = '\\' | '2' << 8 | '5' << 16 | '4' << 24,
|
|
||||||
[173] = '\\' | '2' << 8 | '5' << 16 | '5' << 24,
|
|
||||||
[174] = '\\' | '2' << 8 | '5' << 16 | '6' << 24,
|
|
||||||
[175] = '\\' | '2' << 8 | '5' << 16 | '7' << 24,
|
|
||||||
[176] = '\\' | '2' << 8 | '6' << 16 | '0' << 24,
|
|
||||||
[177] = '\\' | '2' << 8 | '6' << 16 | '1' << 24,
|
|
||||||
[178] = '\\' | '2' << 8 | '6' << 16 | '2' << 24,
|
|
||||||
[179] = '\\' | '2' << 8 | '6' << 16 | '3' << 24,
|
|
||||||
[180] = '\\' | '2' << 8 | '6' << 16 | '4' << 24,
|
|
||||||
[181] = '\\' | '2' << 8 | '6' << 16 | '5' << 24,
|
|
||||||
[182] = '\\' | '2' << 8 | '6' << 16 | '6' << 24,
|
|
||||||
[183] = '\\' | '2' << 8 | '6' << 16 | '7' << 24,
|
|
||||||
[184] = '\\' | '2' << 8 | '7' << 16 | '0' << 24,
|
|
||||||
[185] = '\\' | '2' << 8 | '7' << 16 | '1' << 24,
|
|
||||||
[186] = '\\' | '2' << 8 | '7' << 16 | '2' << 24,
|
|
||||||
[187] = '\\' | '2' << 8 | '7' << 16 | '3' << 24,
|
|
||||||
[188] = '\\' | '2' << 8 | '7' << 16 | '4' << 24,
|
|
||||||
[189] = '\\' | '2' << 8 | '7' << 16 | '5' << 24,
|
|
||||||
[190] = '\\' | '2' << 8 | '7' << 16 | '6' << 24,
|
|
||||||
[191] = '\\' | '2' << 8 | '7' << 16 | '7' << 24,
|
|
||||||
[192] = '\\' | '3' << 8 | '0' << 16 | '0' << 24,
|
|
||||||
[193] = '\\' | '3' << 8 | '0' << 16 | '1' << 24,
|
|
||||||
[194] = '\\' | '3' << 8 | '0' << 16 | '2' << 24,
|
|
||||||
[195] = '\\' | '3' << 8 | '0' << 16 | '3' << 24,
|
|
||||||
[196] = '\\' | '3' << 8 | '0' << 16 | '4' << 24,
|
|
||||||
[197] = '\\' | '3' << 8 | '0' << 16 | '5' << 24,
|
|
||||||
[198] = '\\' | '3' << 8 | '0' << 16 | '6' << 24,
|
|
||||||
[199] = '\\' | '3' << 8 | '0' << 16 | '7' << 24,
|
|
||||||
[200] = '\\' | '3' << 8 | '1' << 16 | '0' << 24,
|
|
||||||
[201] = '\\' | '3' << 8 | '1' << 16 | '1' << 24,
|
|
||||||
[202] = '\\' | '3' << 8 | '1' << 16 | '2' << 24,
|
|
||||||
[203] = '\\' | '3' << 8 | '1' << 16 | '3' << 24,
|
|
||||||
[204] = '\\' | '3' << 8 | '1' << 16 | '4' << 24,
|
|
||||||
[205] = '\\' | '3' << 8 | '1' << 16 | '5' << 24,
|
|
||||||
[206] = '\\' | '3' << 8 | '1' << 16 | '6' << 24,
|
|
||||||
[207] = '\\' | '3' << 8 | '1' << 16 | '7' << 24,
|
|
||||||
[208] = '\\' | '3' << 8 | '2' << 16 | '0' << 24,
|
|
||||||
[209] = '\\' | '3' << 8 | '2' << 16 | '1' << 24,
|
|
||||||
[210] = '\\' | '3' << 8 | '2' << 16 | '2' << 24,
|
|
||||||
[211] = '\\' | '3' << 8 | '2' << 16 | '3' << 24,
|
|
||||||
[212] = '\\' | '3' << 8 | '2' << 16 | '4' << 24,
|
|
||||||
[213] = '\\' | '3' << 8 | '2' << 16 | '5' << 24,
|
|
||||||
[214] = '\\' | '3' << 8 | '2' << 16 | '6' << 24,
|
|
||||||
[215] = '\\' | '3' << 8 | '2' << 16 | '7' << 24,
|
|
||||||
[216] = '\\' | '3' << 8 | '3' << 16 | '0' << 24,
|
|
||||||
[217] = '\\' | '3' << 8 | '3' << 16 | '1' << 24,
|
|
||||||
[218] = '\\' | '3' << 8 | '3' << 16 | '2' << 24,
|
|
||||||
[219] = '\\' | '3' << 8 | '3' << 16 | '3' << 24,
|
|
||||||
[220] = '\\' | '3' << 8 | '3' << 16 | '4' << 24,
|
|
||||||
[221] = '\\' | '3' << 8 | '3' << 16 | '5' << 24,
|
|
||||||
[222] = '\\' | '3' << 8 | '3' << 16 | '6' << 24,
|
|
||||||
[223] = '\\' | '3' << 8 | '3' << 16 | '7' << 24,
|
|
||||||
[224] = '\\' | '3' << 8 | '4' << 16 | '0' << 24,
|
|
||||||
[225] = '\\' | '3' << 8 | '4' << 16 | '1' << 24,
|
|
||||||
[226] = '\\' | '3' << 8 | '4' << 16 | '2' << 24,
|
|
||||||
[227] = '\\' | '3' << 8 | '4' << 16 | '3' << 24,
|
|
||||||
[228] = '\\' | '3' << 8 | '4' << 16 | '4' << 24,
|
|
||||||
[229] = '\\' | '3' << 8 | '4' << 16 | '5' << 24,
|
|
||||||
[230] = '\\' | '3' << 8 | '4' << 16 | '6' << 24,
|
|
||||||
[231] = '\\' | '3' << 8 | '4' << 16 | '7' << 24,
|
|
||||||
[232] = '\\' | '3' << 8 | '5' << 16 | '0' << 24,
|
|
||||||
[233] = '\\' | '3' << 8 | '5' << 16 | '1' << 24,
|
|
||||||
[234] = '\\' | '3' << 8 | '5' << 16 | '2' << 24,
|
|
||||||
[235] = '\\' | '3' << 8 | '5' << 16 | '3' << 24,
|
|
||||||
[236] = '\\' | '3' << 8 | '5' << 16 | '4' << 24,
|
|
||||||
[237] = '\\' | '3' << 8 | '5' << 16 | '5' << 24,
|
|
||||||
[238] = '\\' | '3' << 8 | '5' << 16 | '6' << 24,
|
|
||||||
[239] = '\\' | '3' << 8 | '5' << 16 | '7' << 24,
|
|
||||||
[240] = '\\' | '3' << 8 | '6' << 16 | '0' << 24,
|
|
||||||
[241] = '\\' | '3' << 8 | '6' << 16 | '1' << 24,
|
|
||||||
[242] = '\\' | '3' << 8 | '6' << 16 | '2' << 24,
|
|
||||||
[243] = '\\' | '3' << 8 | '6' << 16 | '3' << 24,
|
|
||||||
[244] = '\\' | '3' << 8 | '6' << 16 | '4' << 24,
|
|
||||||
[245] = '\\' | '3' << 8 | '6' << 16 | '5' << 24,
|
|
||||||
[246] = '\\' | '3' << 8 | '6' << 16 | '6' << 24,
|
|
||||||
[247] = '\\' | '3' << 8 | '6' << 16 | '7' << 24,
|
|
||||||
[248] = '\\' | '3' << 8 | '7' << 16 | '0' << 24,
|
|
||||||
[249] = '\\' | '3' << 8 | '7' << 16 | '1' << 24,
|
|
||||||
[250] = '\\' | '3' << 8 | '7' << 16 | '2' << 24,
|
|
||||||
[251] = '\\' | '3' << 8 | '7' << 16 | '3' << 24,
|
|
||||||
[252] = '\\' | '3' << 8 | '7' << 16 | '4' << 24,
|
|
||||||
[253] = '\\' | '3' << 8 | '7' << 16 | '5' << 24,
|
|
||||||
[254] = '\\' | '3' << 8 | '7' << 16 | '6' << 24,
|
|
||||||
[255] = '\\' | '3' << 8 | '7' << 16 | '7' << 24,
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 256; ++i) {
|
|
||||||
printf("[%d] = ", i);
|
|
||||||
int j = 0;
|
|
||||||
uint32_t x = _cescapec(i);
|
|
||||||
do {
|
|
||||||
if (j) {
|
|
||||||
printf(" | ");
|
|
||||||
}
|
|
||||||
if (isprint(x & 255)) {
|
|
||||||
if ((x & 255) == '\\') {
|
|
||||||
printf("'\\\\'");
|
|
||||||
} else {
|
|
||||||
printf("'%c'", x & 255);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("%d", x & 255);
|
|
||||||
}
|
|
||||||
if (j) {
|
|
||||||
printf(" << %d", j);
|
|
||||||
}
|
|
||||||
j += 8;
|
|
||||||
} while ((x >>= 8));
|
|
||||||
printf(",\n");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,129 +0,0 @@
|
||||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
|
||||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
|
||||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
|
||||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
|
||||||
│ │
|
|
||||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
|
||||||
│ any purpose with or without fee is hereby granted, provided that the │
|
|
||||||
│ above copyright notice and this permission notice appear in all copies. │
|
|
||||||
│ │
|
|
||||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
|
||||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
|
||||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
|
||||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
|
||||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
|
||||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
|
||||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
|
||||||
#include "ape/relocations.h"
|
|
||||||
#include "libc/macros.internal.h"
|
|
||||||
|
|
||||||
// Escapes byte for string literal.
|
|
||||||
//
|
|
||||||
// This turns stuff like (char)0xFF into \0377. The returned
|
|
||||||
// string is word-encoded, e.g. '\\'|'0'<<010|'3'<<020|etc.
|
|
||||||
//
|
|
||||||
// @param dil contains byte to escape
|
|
||||||
// @see libc/nexgen32e/cescapec.c
|
|
||||||
_cescapec:
|
|
||||||
.leafprologue
|
|
||||||
.profilable
|
|
||||||
movzbl %dil,%edi
|
|
||||||
lea -7(%rdi),%ecx
|
|
||||||
cmp $85,%cl
|
|
||||||
ja 1f
|
|
||||||
mov $'\\',%eax
|
|
||||||
movzbl %cl,%ecx
|
|
||||||
jmp *_cescapectab(,%rcx,8)
|
|
||||||
.Lanchorpoint:
|
|
||||||
.LBEL: mov $'a',%ah
|
|
||||||
.leafepilogue
|
|
||||||
.LBS: mov $'b',%ah
|
|
||||||
.leafepilogue
|
|
||||||
.LHT: mov $'t',%ah
|
|
||||||
.leafepilogue
|
|
||||||
.LLF: mov $'n',%ah
|
|
||||||
.leafepilogue
|
|
||||||
.LVT: mov $'v',%ah
|
|
||||||
.leafepilogue
|
|
||||||
.LFF: mov $'f',%ah
|
|
||||||
.leafepilogue
|
|
||||||
.LCR: mov $'r',%ah
|
|
||||||
.leafepilogue
|
|
||||||
.LDQ: mov $'\"',%ah
|
|
||||||
.leafepilogue
|
|
||||||
.LSQ: mov $'\'',%ah
|
|
||||||
.leafepilogue
|
|
||||||
.LBSL: mov $'\\',%ah
|
|
||||||
.leafepilogue
|
|
||||||
#ifdef __STRICT_ANSI__
|
|
||||||
.LQM: mov $'?',%ah
|
|
||||||
.leafepilogue
|
|
||||||
#else
|
|
||||||
.LQM:
|
|
||||||
#endif
|
|
||||||
1: mov %edi,%eax
|
|
||||||
lea -0x20(%rax),%ecx
|
|
||||||
cmp $0x5E,%ecx
|
|
||||||
ja 2f
|
|
||||||
.leafepilogue
|
|
||||||
2: and $-64,%eax
|
|
||||||
mov %edi,%ecx
|
|
||||||
and $56,%ecx
|
|
||||||
shl $13,%ecx
|
|
||||||
and $7,%edi
|
|
||||||
shl $24,%edi
|
|
||||||
or %ecx,%edi
|
|
||||||
lea (%rdi,%rax,4),%eax
|
|
||||||
add $'0'<<030|'0'<<020|'0'<<010|'\\',%eax
|
|
||||||
.leafepilogue
|
|
||||||
.endfn _cescapec,globl
|
|
||||||
|
|
||||||
.initro 300,_init_cescapec
|
|
||||||
_cescapectab.ro:
|
|
||||||
.byte 1,.LBEL-.Lanchorpoint
|
|
||||||
.byte 1,.LBS-.Lanchorpoint
|
|
||||||
.byte 1,.LHT-.Lanchorpoint
|
|
||||||
.byte 1,.LLF-.Lanchorpoint
|
|
||||||
.byte 1,.LVT-.Lanchorpoint
|
|
||||||
.byte 1,.LFF-.Lanchorpoint
|
|
||||||
.byte 1,.LCR-.Lanchorpoint
|
|
||||||
.byte 20,1b-.Lanchorpoint
|
|
||||||
.byte 1,.LDQ-.Lanchorpoint
|
|
||||||
.byte '\''-'\"'-1,1b-.Lanchorpoint
|
|
||||||
.byte 1,.LSQ-.Lanchorpoint
|
|
||||||
.byte '?'-'\''-1,1b-.Lanchorpoint
|
|
||||||
.byte 1,.LQM-.Lanchorpoint
|
|
||||||
.byte '\\'-'?'-1,1b-.Lanchorpoint
|
|
||||||
.byte 1,.LBSL-.Lanchorpoint
|
|
||||||
.equ .L_cescapectab.ro.size,.-_cescapectab.ro
|
|
||||||
.org 8 - .L_cescapectab.ro.size % 8 + .
|
|
||||||
.endobj _cescapectab.ro,globl,hidden
|
|
||||||
.previous
|
|
||||||
|
|
||||||
.initbss 300,_init_cescapec
|
|
||||||
_cescapectab:
|
|
||||||
.rept '\\'-7+1
|
|
||||||
.quad 0
|
|
||||||
.endr
|
|
||||||
.endobj _cescapectab
|
|
||||||
.previous
|
|
||||||
|
|
||||||
.init.start 300,_init_cescapec
|
|
||||||
ezlea .Lanchorpoint,dx
|
|
||||||
mov $.L_cescapectab.ro.size/2,%ch
|
|
||||||
0: xor %eax,%eax
|
|
||||||
lodsb
|
|
||||||
mov %al,%cl
|
|
||||||
lodsb
|
|
||||||
add %rdx,%rax
|
|
||||||
1: stosq
|
|
||||||
dec %cl
|
|
||||||
jnz 1b
|
|
||||||
dec %ch
|
|
||||||
jnz 0b
|
|
||||||
.if .L_cescapectab.ro.size % 8
|
|
||||||
add $(8-.L_cescapectab.ro.size%8),%rsi
|
|
||||||
.endif
|
|
||||||
.init.end 300,_init_cescapec
|
|
56
libc/nexgen32e/cescapec.c
Normal file
56
libc/nexgen32e/cescapec.c
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||||
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||||
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||||
|
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||||
|
│ │
|
||||||
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||||
|
│ any purpose with or without fee is hereby granted, provided that the │
|
||||||
|
│ above copyright notice and this permission notice appear in all copies. │
|
||||||
|
│ │
|
||||||
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||||
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||||
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||||
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||||
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||||
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||||
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||||
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
#include "libc/str/str.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts byte to word-encoded C string literal representation.
|
||||||
|
*/
|
||||||
|
int _cescapec(int c) {
|
||||||
|
switch ((c &= 255)) {
|
||||||
|
case '\a':
|
||||||
|
return '\\' | 'a' << 8;
|
||||||
|
case '\b':
|
||||||
|
return '\\' | 'b' << 8;
|
||||||
|
case '\t':
|
||||||
|
return '\\' | 't' << 8;
|
||||||
|
case '\n':
|
||||||
|
return '\\' | 'n' << 8;
|
||||||
|
case '\v':
|
||||||
|
return '\\' | 'v' << 8;
|
||||||
|
case '\f':
|
||||||
|
return '\\' | 'f' << 8;
|
||||||
|
case '\r':
|
||||||
|
return '\\' | 'r' << 8;
|
||||||
|
case '"':
|
||||||
|
return '\\' | '"' << 8;
|
||||||
|
case '\'':
|
||||||
|
return '\\' | '\'' << 8;
|
||||||
|
case '\\':
|
||||||
|
return '\\' | '\\' << 8;
|
||||||
|
default:
|
||||||
|
if (' ' <= c && c <= '~') {
|
||||||
|
return c;
|
||||||
|
} else {
|
||||||
|
return '\\' | //
|
||||||
|
('0' + (c >> 6)) << 8 | //
|
||||||
|
('0' + ((c >> 3) & 7)) << 16 | //
|
||||||
|
('0' + (c & 7)) << 24;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
84
libc/nexgen32e/kbase36.c
Normal file
84
libc/nexgen32e/kbase36.c
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||||
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||||
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||||
|
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||||
|
│ │
|
||||||
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||||
|
│ any purpose with or without fee is hereby granted, provided that the │
|
||||||
|
│ above copyright notice and this permission notice appear in all copies. │
|
||||||
|
│ │
|
||||||
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||||
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||||
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||||
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||||
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||||
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||||
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||||
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
#include "libc/str/tab.internal.h"
|
||||||
|
|
||||||
|
_Alignas(uint8_t) const uint8_t kBase36[256] = {
|
||||||
|
['0'] = 1, //
|
||||||
|
['1'] = 2, //
|
||||||
|
['2'] = 3, //
|
||||||
|
['3'] = 4, //
|
||||||
|
['4'] = 5, //
|
||||||
|
['5'] = 6, //
|
||||||
|
['6'] = 7, //
|
||||||
|
['7'] = 8, //
|
||||||
|
['8'] = 9, //
|
||||||
|
['9'] = 10, //
|
||||||
|
['A'] = 11, //
|
||||||
|
['B'] = 12, //
|
||||||
|
['C'] = 13, //
|
||||||
|
['D'] = 14, //
|
||||||
|
['E'] = 15, //
|
||||||
|
['F'] = 16, //
|
||||||
|
['G'] = 17, //
|
||||||
|
['H'] = 18, //
|
||||||
|
['I'] = 19, //
|
||||||
|
['J'] = 20, //
|
||||||
|
['K'] = 21, //
|
||||||
|
['L'] = 22, //
|
||||||
|
['M'] = 23, //
|
||||||
|
['N'] = 24, //
|
||||||
|
['O'] = 25, //
|
||||||
|
['P'] = 26, //
|
||||||
|
['Q'] = 27, //
|
||||||
|
['R'] = 28, //
|
||||||
|
['S'] = 29, //
|
||||||
|
['T'] = 30, //
|
||||||
|
['U'] = 31, //
|
||||||
|
['V'] = 32, //
|
||||||
|
['W'] = 33, //
|
||||||
|
['X'] = 34, //
|
||||||
|
['Y'] = 35, //
|
||||||
|
['Z'] = 36, //
|
||||||
|
['a'] = 11, //
|
||||||
|
['b'] = 12, //
|
||||||
|
['c'] = 13, //
|
||||||
|
['d'] = 14, //
|
||||||
|
['e'] = 15, //
|
||||||
|
['f'] = 16, //
|
||||||
|
['g'] = 17, //
|
||||||
|
['h'] = 18, //
|
||||||
|
['i'] = 19, //
|
||||||
|
['j'] = 20, //
|
||||||
|
['k'] = 21, //
|
||||||
|
['l'] = 22, //
|
||||||
|
['m'] = 23, //
|
||||||
|
['n'] = 24, //
|
||||||
|
['o'] = 25, //
|
||||||
|
['p'] = 26, //
|
||||||
|
['q'] = 27, //
|
||||||
|
['r'] = 28, //
|
||||||
|
['s'] = 29, //
|
||||||
|
['t'] = 30, //
|
||||||
|
['u'] = 31, //
|
||||||
|
['v'] = 32, //
|
||||||
|
['w'] = 33, //
|
||||||
|
['x'] = 34, //
|
||||||
|
['y'] = 35, //
|
||||||
|
['z'] = 36, //
|
||||||
|
};
|
|
@ -18,7 +18,7 @@
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/macros.internal.h"
|
#include "libc/macros.internal.h"
|
||||||
.rodata
|
.rodata
|
||||||
.balign 16
|
.balign 2
|
||||||
|
|
||||||
// ibm cp437 unicode table w/ string literal safety
|
// ibm cp437 unicode table w/ string literal safety
|
||||||
//
|
//
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/str/tab.internal.h"
|
#include "libc/str/tab.internal.h"
|
||||||
|
|
||||||
const uint8_t kToLower[256] = {
|
_Alignas(uint8_t) const uint8_t kToLower[256] = {
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||||
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
||||||
28, 29, 30, 31, ' ', '!', '\"', '#', '$', '%', '&', '\'', '(', ')',
|
28, 29, 30, 31, ' ', '!', '\"', '#', '$', '%', '&', '\'', '(', ')',
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/str/tab.internal.h"
|
#include "libc/str/tab.internal.h"
|
||||||
|
|
||||||
const uint8_t kToUpper[256] = {
|
_Alignas(uint8_t) const uint8_t kToUpper[256] = {
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||||
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
||||||
28, 29, 30, 31, ' ', '!', '\"', '#', '$', '%', '&', '\'', '(', ')',
|
28, 29, 30, 31, ' ', '!', '\"', '#', '$', '%', '&', '\'', '(', ')',
|
||||||
|
|
|
@ -1,142 +0,0 @@
|
||||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
|
||||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
|
||||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
|
||||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
|
||||||
│ │
|
|
||||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
|
||||||
│ any purpose with or without fee is hereby granted, provided that the │
|
|
||||||
│ above copyright notice and this permission notice appear in all copies. │
|
|
||||||
│ │
|
|
||||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
|
||||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
|
||||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
|
||||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
|
||||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
|
||||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
|
||||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
|
||||||
#include "libc/nexgen32e/x86feature.h"
|
|
||||||
#include "libc/macros.internal.h"
|
|
||||||
|
|
||||||
// Returns length of wchar_t string w/ security blankets.
|
|
||||||
//
|
|
||||||
// This is like wcsnlen() except it'll return 0 if (1) RDI is NULL
|
|
||||||
// or (2) a NUL-terminator wasn't found in the first RSI chars.
|
|
||||||
//
|
|
||||||
// @param rdi is a nullable NUL-terminated wchar_t string pointer
|
|
||||||
// @param rsi is the maximum number of chars to consider
|
|
||||||
// @return rax is the number of chars, excluding the NUL
|
|
||||||
wcsnlen_s:
|
|
||||||
.leafprologue
|
|
||||||
.profilable
|
|
||||||
xor %eax,%eax
|
|
||||||
xor %r10d,%r10d
|
|
||||||
test %rdi,%rdi
|
|
||||||
jnz 0f
|
|
||||||
.leafepilogue
|
|
||||||
.endfn wcsnlen_s,globl
|
|
||||||
|
|
||||||
// Returns length of NUL-terminated memory, with limit.
|
|
||||||
//
|
|
||||||
// @param rdi is non-null memory
|
|
||||||
// @param rsi is the maximum number of chars to consider
|
|
||||||
// @return rax is the number of chars, excluding the NUL
|
|
||||||
// @asyncsignalsafe
|
|
||||||
wcsnlen:
|
|
||||||
.leafprologue
|
|
||||||
.profilable
|
|
||||||
or $-1,%r10
|
|
||||||
0: xor %edx,%edx
|
|
||||||
xor %r11d,%r11d
|
|
||||||
mov %rdi,%r8
|
|
||||||
jmp wcssak
|
|
||||||
|
|
||||||
// Returns pointer to first instance of character in range.
|
|
||||||
//
|
|
||||||
// @param rdi is a non-null pointer to memory
|
|
||||||
// @param esi is the search word
|
|
||||||
// @return rax points to word if found, or else undefined behavior
|
|
||||||
rawwmemchr:
|
|
||||||
or $-1,%rdx
|
|
||||||
// fallthrough
|
|
||||||
|
|
||||||
// Returns pointer to first instance of character in range.
|
|
||||||
//
|
|
||||||
// @param rdi is a non-null pointer to memory
|
|
||||||
// @param esi is the int32_t search word (officially wchar_t)
|
|
||||||
// @param rdx is length of memory in chars
|
|
||||||
// @return rax points to word if found or NULL
|
|
||||||
// @asyncsignalsafe
|
|
||||||
wmemchr:.leafprologue
|
|
||||||
.profilable
|
|
||||||
xor %r8,%r8
|
|
||||||
xor %r10,%r10
|
|
||||||
mov %rdx,%rcx
|
|
||||||
mov %esi,%edx
|
|
||||||
mov %esi,%r11d
|
|
||||||
mov %rcx,%rsi
|
|
||||||
// fallthrough
|
|
||||||
|
|
||||||
// Swiss army knife of wchar_t string scanning.
|
|
||||||
// Seven fast functions in one.
|
|
||||||
//
|
|
||||||
// @param rdi is non-null wchar_t string memory
|
|
||||||
// @param rsi is max number of chars to consider
|
|
||||||
// @param edx is search character #1
|
|
||||||
// @param r11d is search character #2
|
|
||||||
// @param r8 is subtracted from result (for length vs. pointer)
|
|
||||||
// @param r9 masks result if r11w is found (for NUL vs. NULL)
|
|
||||||
// @param r10 masks result on chars exhausted (for length v. NULL)
|
|
||||||
// @return rax end pointer after r8/r9/r10 modifications
|
|
||||||
wcssak: lea -4(%rdi),%rax
|
|
||||||
.balign 16
|
|
||||||
1: add $4,%rax
|
|
||||||
sub $1,%rsi
|
|
||||||
jb .Lend
|
|
||||||
test $31,%al
|
|
||||||
jz .Lfast
|
|
||||||
.Lint: mov (%rax),%ecx
|
|
||||||
cmp %ecx,%edx
|
|
||||||
je .Ldone
|
|
||||||
cmp %ecx,%r11d
|
|
||||||
je .Lnul
|
|
||||||
jmp 1b
|
|
||||||
.Ldone: sub %r8,%rax
|
|
||||||
jmp .Lret
|
|
||||||
.Lend: mov %r10,%r9
|
|
||||||
.Lnul: sub %r8,%rax
|
|
||||||
and %r9,%rax
|
|
||||||
.Lret: test %r8,%r8
|
|
||||||
jz 0f
|
|
||||||
shr $2,%rax
|
|
||||||
0: .leafepilogue
|
|
||||||
.Lslow: add $8,%rsi
|
|
||||||
jmp .Lint
|
|
||||||
.Lfast:
|
|
||||||
#if !X86_NEED(AVX2)
|
|
||||||
testb X86_HAVE(AVX2)+kCpuids(%rip)
|
|
||||||
jz .Lint
|
|
||||||
#endif
|
|
||||||
movd %edx,%xmm0
|
|
||||||
movd %r11d,%xmm1
|
|
||||||
vpbroadcastd %xmm0,%ymm0
|
|
||||||
vpbroadcastd %xmm1,%ymm1
|
|
||||||
sub $32,%rax
|
|
||||||
1: add $32,%rax
|
|
||||||
sub $8,%rsi
|
|
||||||
jb .Lslow
|
|
||||||
vmovdqa (%rax),%ymm2
|
|
||||||
vpcmpeqd %ymm0,%ymm2,%ymm3
|
|
||||||
vpcmpeqd %ymm1,%ymm2,%ymm2
|
|
||||||
vpor %ymm3,%ymm2,%ymm2
|
|
||||||
vpmovmskb %ymm2,%ecx
|
|
||||||
bsf %ecx,%ecx
|
|
||||||
je 1b
|
|
||||||
vzeroupper
|
|
||||||
add %rcx,%rax
|
|
||||||
jmp .Lint
|
|
||||||
.endfn wcssak
|
|
||||||
.endfn wmemchr,globl
|
|
||||||
.endfn rawwmemchr,globl
|
|
||||||
.endfn wcsnlen,globl
|
|
|
@ -16,9 +16,9 @@
|
||||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/str/str.h"
|
#include "libc/str/tab.internal.h"
|
||||||
|
|
||||||
const signed char kHexToInt[256] = {
|
_Alignas(int8_t) const int8_t kHexToInt[256] = {
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x00
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x00
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x10
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x10
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x20
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x20
|
||||||
|
|
|
@ -84,8 +84,6 @@ char *strstr(const char *, const char *) strlenesque;
|
||||||
char *strcasestr(const char *, const char *) strlenesque;
|
char *strcasestr(const char *, const char *) strlenesque;
|
||||||
char16_t *strstr16(const char16_t *, const char16_t *) strlenesque;
|
char16_t *strstr16(const char16_t *, const char16_t *) strlenesque;
|
||||||
wchar_t *wcsstr(const wchar_t *, const wchar_t *) strlenesque;
|
wchar_t *wcsstr(const wchar_t *, const wchar_t *) strlenesque;
|
||||||
void *rawwmemchr(const void *, wchar_t)
|
|
||||||
strlenesque returnsnonnull;
|
|
||||||
int strcmp(const char *, const char *) strlenesque;
|
int strcmp(const char *, const char *) strlenesque;
|
||||||
int strncmp(const char *, const char *, size_t) strlenesque;
|
int strncmp(const char *, const char *, size_t) strlenesque;
|
||||||
int strcmp16(const char16_t *, const char16_t *) strlenesque;
|
int strcmp16(const char16_t *, const char16_t *) strlenesque;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||||
│ │
|
│ │
|
||||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||||
│ any purpose with or without fee is hereby granted, provided that the │
|
│ any purpose with or without fee is hereby granted, provided that the │
|
||||||
|
@ -16,30 +16,21 @@
|
||||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/macros.internal.h"
|
#include "libc/str/str.h"
|
||||||
|
|
||||||
// Base 36 Decoder Table.
|
/**
|
||||||
//
|
* Returns length of NUL-terminated wide string w/ limit.
|
||||||
// This supports uppercase and lowercase. For encoding, the string
|
*
|
||||||
// 0123456789abcdefghijklmnopqrstuvwxyz can be used, which linkers
|
* @param s is wide string
|
||||||
// are able to deduplicate.
|
* @param n is max length (a count of wide characters, not bytes)
|
||||||
.initbss 300,_init_kBase36
|
* @return length in characters
|
||||||
kBase36:.zero 256
|
* @asyncsignalsafe
|
||||||
.endobj kBase36,globl,hidden
|
*/
|
||||||
.previous
|
size_t wcsnlen(const wchar_t *s, size_t n) {
|
||||||
|
wchar_t *p;
|
||||||
.init.start 300,_init_kBase36
|
if ((p = wmemchr(s, 0, n))) {
|
||||||
add $'0',%rdi
|
return p - s;
|
||||||
xor %eax,%eax
|
} else {
|
||||||
pushpop 10,%rcx
|
return n;
|
||||||
0: inc %eax
|
}
|
||||||
stosb
|
}
|
||||||
.loop 0b
|
|
||||||
add $'A'-1-'9',%rdi
|
|
||||||
pushpop 'Z'+1-'A',%rcx
|
|
||||||
0: inc %eax
|
|
||||||
mov %al,0x20(%rdi)
|
|
||||||
stosb
|
|
||||||
.loop 0b
|
|
||||||
add $255-'Z',%rdi
|
|
||||||
.init.end 300,_init_kBase36
|
|
32
libc/str/wcsnlen_s.c
Normal file
32
libc/str/wcsnlen_s.c
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||||
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||||
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||||
|
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||||
|
│ │
|
||||||
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||||
|
│ any purpose with or without fee is hereby granted, provided that the │
|
||||||
|
│ above copyright notice and this permission notice appear in all copies. │
|
||||||
|
│ │
|
||||||
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||||
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||||
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||||
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||||
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||||
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||||
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||||
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
#include "libc/str/str.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns length of NUL-terminated wide string w/ limit & blankets.
|
||||||
|
*
|
||||||
|
* @param s is wide string
|
||||||
|
* @param n is max length (a count of wide characters, not bytes)
|
||||||
|
* @return length in characters
|
||||||
|
* @asyncsignalsafe
|
||||||
|
*/
|
||||||
|
size_t wcsnlen_s(const wchar_t *s, size_t n) {
|
||||||
|
if (!s) return 0;
|
||||||
|
return wcsnlen(s, n);
|
||||||
|
}
|
|
@ -18,5 +18,17 @@
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/str/str.h"
|
#include "libc/str/str.h"
|
||||||
|
|
||||||
int _cescapec2(int c) {
|
/**
|
||||||
|
* Returns pointer to first instance of character in range.
|
||||||
|
*
|
||||||
|
* @asyncsignalsafe
|
||||||
|
*/
|
||||||
|
wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n) {
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < n; ++i) {
|
||||||
|
if (s[i] == c) {
|
||||||
|
return (void *)(s + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
|
@ -95,6 +95,10 @@ TEST(strnlen_s, null_ReturnsZero) {
|
||||||
ASSERT_EQ(0, strnlen_s(NULL, 3));
|
ASSERT_EQ(0, strnlen_s(NULL, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(wcsnlen_s, null_ReturnsZero) {
|
||||||
|
ASSERT_EQ(0, wcsnlen_s(NULL, 3));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(strnlen, nulNotFound_ReturnsSize) {
|
TEST(strnlen, nulNotFound_ReturnsSize) {
|
||||||
int sizes[] = {1, 2, 7, 8, 15, 16, 31, 32, 33};
|
int sizes[] = {1, 2, 7, 8, 15, 16, 31, 32, 33};
|
||||||
for (unsigned i = 0; i < ARRAYLEN(sizes); ++i) {
|
for (unsigned i = 0; i < ARRAYLEN(sizes); ++i) {
|
||||||
|
@ -110,6 +114,11 @@ TEST(strnlen_s, nulNotFound) {
|
||||||
ASSERT_EQ(3, strnlen_s(buf, 3));
|
ASSERT_EQ(3, strnlen_s(buf, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(wcsnlen_s, nulNotFound) {
|
||||||
|
wchar_t buf[3] = {1, 2, 3};
|
||||||
|
ASSERT_EQ(3, wcsnlen_s(buf, 3));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(strlen, fuzz) {
|
TEST(strlen, fuzz) {
|
||||||
char *b;
|
char *b;
|
||||||
size_t n, n1, n2;
|
size_t n, n1, n2;
|
||||||
|
|
|
@ -19,15 +19,268 @@
|
||||||
#include "libc/str/str.h"
|
#include "libc/str/str.h"
|
||||||
#include "libc/testlib/testlib.h"
|
#include "libc/testlib/testlib.h"
|
||||||
|
|
||||||
|
static const uint32_t kCescapecGolden[256] = {
|
||||||
|
[0] = '\\' | '0' << 8 | '0' << 16 | '0' << 24,
|
||||||
|
[1] = '\\' | '0' << 8 | '0' << 16 | '1' << 24,
|
||||||
|
[2] = '\\' | '0' << 8 | '0' << 16 | '2' << 24,
|
||||||
|
[3] = '\\' | '0' << 8 | '0' << 16 | '3' << 24,
|
||||||
|
[4] = '\\' | '0' << 8 | '0' << 16 | '4' << 24,
|
||||||
|
[5] = '\\' | '0' << 8 | '0' << 16 | '5' << 24,
|
||||||
|
[6] = '\\' | '0' << 8 | '0' << 16 | '6' << 24,
|
||||||
|
[7] = '\\' | 'a' << 8,
|
||||||
|
[8] = '\\' | 'b' << 8,
|
||||||
|
[9] = '\\' | 't' << 8,
|
||||||
|
[10] = '\\' | 'n' << 8,
|
||||||
|
[11] = '\\' | 'v' << 8,
|
||||||
|
[12] = '\\' | 'f' << 8,
|
||||||
|
[13] = '\\' | 'r' << 8,
|
||||||
|
[14] = '\\' | '0' << 8 | '1' << 16 | '6' << 24,
|
||||||
|
[15] = '\\' | '0' << 8 | '1' << 16 | '7' << 24,
|
||||||
|
[16] = '\\' | '0' << 8 | '2' << 16 | '0' << 24,
|
||||||
|
[17] = '\\' | '0' << 8 | '2' << 16 | '1' << 24,
|
||||||
|
[18] = '\\' | '0' << 8 | '2' << 16 | '2' << 24,
|
||||||
|
[19] = '\\' | '0' << 8 | '2' << 16 | '3' << 24,
|
||||||
|
[20] = '\\' | '0' << 8 | '2' << 16 | '4' << 24,
|
||||||
|
[21] = '\\' | '0' << 8 | '2' << 16 | '5' << 24,
|
||||||
|
[22] = '\\' | '0' << 8 | '2' << 16 | '6' << 24,
|
||||||
|
[23] = '\\' | '0' << 8 | '2' << 16 | '7' << 24,
|
||||||
|
[24] = '\\' | '0' << 8 | '3' << 16 | '0' << 24,
|
||||||
|
[25] = '\\' | '0' << 8 | '3' << 16 | '1' << 24,
|
||||||
|
[26] = '\\' | '0' << 8 | '3' << 16 | '2' << 24,
|
||||||
|
[27] = '\\' | '0' << 8 | '3' << 16 | '3' << 24,
|
||||||
|
[28] = '\\' | '0' << 8 | '3' << 16 | '4' << 24,
|
||||||
|
[29] = '\\' | '0' << 8 | '3' << 16 | '5' << 24,
|
||||||
|
[30] = '\\' | '0' << 8 | '3' << 16 | '6' << 24,
|
||||||
|
[31] = '\\' | '0' << 8 | '3' << 16 | '7' << 24,
|
||||||
|
[32] = ' ',
|
||||||
|
[33] = '!',
|
||||||
|
[34] = '\\' | '"' << 8,
|
||||||
|
[35] = '#',
|
||||||
|
[36] = '$',
|
||||||
|
[37] = '%',
|
||||||
|
[38] = '&',
|
||||||
|
[39] = '\\' | '\'' << 8,
|
||||||
|
[40] = '(',
|
||||||
|
[41] = ')',
|
||||||
|
[42] = '*',
|
||||||
|
[43] = '+',
|
||||||
|
[44] = ',',
|
||||||
|
[45] = '-',
|
||||||
|
[46] = '.',
|
||||||
|
[47] = '/',
|
||||||
|
[48] = '0',
|
||||||
|
[49] = '1',
|
||||||
|
[50] = '2',
|
||||||
|
[51] = '3',
|
||||||
|
[52] = '4',
|
||||||
|
[53] = '5',
|
||||||
|
[54] = '6',
|
||||||
|
[55] = '7',
|
||||||
|
[56] = '8',
|
||||||
|
[57] = '9',
|
||||||
|
[58] = ':',
|
||||||
|
[59] = ';',
|
||||||
|
[60] = '<',
|
||||||
|
[61] = '=',
|
||||||
|
[62] = '>',
|
||||||
|
[63] = '?',
|
||||||
|
[64] = '@',
|
||||||
|
[65] = 'A',
|
||||||
|
[66] = 'B',
|
||||||
|
[67] = 'C',
|
||||||
|
[68] = 'D',
|
||||||
|
[69] = 'E',
|
||||||
|
[70] = 'F',
|
||||||
|
[71] = 'G',
|
||||||
|
[72] = 'H',
|
||||||
|
[73] = 'I',
|
||||||
|
[74] = 'J',
|
||||||
|
[75] = 'K',
|
||||||
|
[76] = 'L',
|
||||||
|
[77] = 'M',
|
||||||
|
[78] = 'N',
|
||||||
|
[79] = 'O',
|
||||||
|
[80] = 'P',
|
||||||
|
[81] = 'Q',
|
||||||
|
[82] = 'R',
|
||||||
|
[83] = 'S',
|
||||||
|
[84] = 'T',
|
||||||
|
[85] = 'U',
|
||||||
|
[86] = 'V',
|
||||||
|
[87] = 'W',
|
||||||
|
[88] = 'X',
|
||||||
|
[89] = 'Y',
|
||||||
|
[90] = 'Z',
|
||||||
|
[91] = '[',
|
||||||
|
[92] = '\\' | '\\' << 8,
|
||||||
|
[93] = ']',
|
||||||
|
[94] = '^',
|
||||||
|
[95] = '_',
|
||||||
|
[96] = '`',
|
||||||
|
[97] = 'a',
|
||||||
|
[98] = 'b',
|
||||||
|
[99] = 'c',
|
||||||
|
[100] = 'd',
|
||||||
|
[101] = 'e',
|
||||||
|
[102] = 'f',
|
||||||
|
[103] = 'g',
|
||||||
|
[104] = 'h',
|
||||||
|
[105] = 'i',
|
||||||
|
[106] = 'j',
|
||||||
|
[107] = 'k',
|
||||||
|
[108] = 'l',
|
||||||
|
[109] = 'm',
|
||||||
|
[110] = 'n',
|
||||||
|
[111] = 'o',
|
||||||
|
[112] = 'p',
|
||||||
|
[113] = 'q',
|
||||||
|
[114] = 'r',
|
||||||
|
[115] = 's',
|
||||||
|
[116] = 't',
|
||||||
|
[117] = 'u',
|
||||||
|
[118] = 'v',
|
||||||
|
[119] = 'w',
|
||||||
|
[120] = 'x',
|
||||||
|
[121] = 'y',
|
||||||
|
[122] = 'z',
|
||||||
|
[123] = '{',
|
||||||
|
[124] = '|',
|
||||||
|
[125] = '}',
|
||||||
|
[126] = '~',
|
||||||
|
[127] = '\\' | '1' << 8 | '7' << 16 | '7' << 24,
|
||||||
|
[128] = '\\' | '2' << 8 | '0' << 16 | '0' << 24,
|
||||||
|
[129] = '\\' | '2' << 8 | '0' << 16 | '1' << 24,
|
||||||
|
[130] = '\\' | '2' << 8 | '0' << 16 | '2' << 24,
|
||||||
|
[131] = '\\' | '2' << 8 | '0' << 16 | '3' << 24,
|
||||||
|
[132] = '\\' | '2' << 8 | '0' << 16 | '4' << 24,
|
||||||
|
[133] = '\\' | '2' << 8 | '0' << 16 | '5' << 24,
|
||||||
|
[134] = '\\' | '2' << 8 | '0' << 16 | '6' << 24,
|
||||||
|
[135] = '\\' | '2' << 8 | '0' << 16 | '7' << 24,
|
||||||
|
[136] = '\\' | '2' << 8 | '1' << 16 | '0' << 24,
|
||||||
|
[137] = '\\' | '2' << 8 | '1' << 16 | '1' << 24,
|
||||||
|
[138] = '\\' | '2' << 8 | '1' << 16 | '2' << 24,
|
||||||
|
[139] = '\\' | '2' << 8 | '1' << 16 | '3' << 24,
|
||||||
|
[140] = '\\' | '2' << 8 | '1' << 16 | '4' << 24,
|
||||||
|
[141] = '\\' | '2' << 8 | '1' << 16 | '5' << 24,
|
||||||
|
[142] = '\\' | '2' << 8 | '1' << 16 | '6' << 24,
|
||||||
|
[143] = '\\' | '2' << 8 | '1' << 16 | '7' << 24,
|
||||||
|
[144] = '\\' | '2' << 8 | '2' << 16 | '0' << 24,
|
||||||
|
[145] = '\\' | '2' << 8 | '2' << 16 | '1' << 24,
|
||||||
|
[146] = '\\' | '2' << 8 | '2' << 16 | '2' << 24,
|
||||||
|
[147] = '\\' | '2' << 8 | '2' << 16 | '3' << 24,
|
||||||
|
[148] = '\\' | '2' << 8 | '2' << 16 | '4' << 24,
|
||||||
|
[149] = '\\' | '2' << 8 | '2' << 16 | '5' << 24,
|
||||||
|
[150] = '\\' | '2' << 8 | '2' << 16 | '6' << 24,
|
||||||
|
[151] = '\\' | '2' << 8 | '2' << 16 | '7' << 24,
|
||||||
|
[152] = '\\' | '2' << 8 | '3' << 16 | '0' << 24,
|
||||||
|
[153] = '\\' | '2' << 8 | '3' << 16 | '1' << 24,
|
||||||
|
[154] = '\\' | '2' << 8 | '3' << 16 | '2' << 24,
|
||||||
|
[155] = '\\' | '2' << 8 | '3' << 16 | '3' << 24,
|
||||||
|
[156] = '\\' | '2' << 8 | '3' << 16 | '4' << 24,
|
||||||
|
[157] = '\\' | '2' << 8 | '3' << 16 | '5' << 24,
|
||||||
|
[158] = '\\' | '2' << 8 | '3' << 16 | '6' << 24,
|
||||||
|
[159] = '\\' | '2' << 8 | '3' << 16 | '7' << 24,
|
||||||
|
[160] = '\\' | '2' << 8 | '4' << 16 | '0' << 24,
|
||||||
|
[161] = '\\' | '2' << 8 | '4' << 16 | '1' << 24,
|
||||||
|
[162] = '\\' | '2' << 8 | '4' << 16 | '2' << 24,
|
||||||
|
[163] = '\\' | '2' << 8 | '4' << 16 | '3' << 24,
|
||||||
|
[164] = '\\' | '2' << 8 | '4' << 16 | '4' << 24,
|
||||||
|
[165] = '\\' | '2' << 8 | '4' << 16 | '5' << 24,
|
||||||
|
[166] = '\\' | '2' << 8 | '4' << 16 | '6' << 24,
|
||||||
|
[167] = '\\' | '2' << 8 | '4' << 16 | '7' << 24,
|
||||||
|
[168] = '\\' | '2' << 8 | '5' << 16 | '0' << 24,
|
||||||
|
[169] = '\\' | '2' << 8 | '5' << 16 | '1' << 24,
|
||||||
|
[170] = '\\' | '2' << 8 | '5' << 16 | '2' << 24,
|
||||||
|
[171] = '\\' | '2' << 8 | '5' << 16 | '3' << 24,
|
||||||
|
[172] = '\\' | '2' << 8 | '5' << 16 | '4' << 24,
|
||||||
|
[173] = '\\' | '2' << 8 | '5' << 16 | '5' << 24,
|
||||||
|
[174] = '\\' | '2' << 8 | '5' << 16 | '6' << 24,
|
||||||
|
[175] = '\\' | '2' << 8 | '5' << 16 | '7' << 24,
|
||||||
|
[176] = '\\' | '2' << 8 | '6' << 16 | '0' << 24,
|
||||||
|
[177] = '\\' | '2' << 8 | '6' << 16 | '1' << 24,
|
||||||
|
[178] = '\\' | '2' << 8 | '6' << 16 | '2' << 24,
|
||||||
|
[179] = '\\' | '2' << 8 | '6' << 16 | '3' << 24,
|
||||||
|
[180] = '\\' | '2' << 8 | '6' << 16 | '4' << 24,
|
||||||
|
[181] = '\\' | '2' << 8 | '6' << 16 | '5' << 24,
|
||||||
|
[182] = '\\' | '2' << 8 | '6' << 16 | '6' << 24,
|
||||||
|
[183] = '\\' | '2' << 8 | '6' << 16 | '7' << 24,
|
||||||
|
[184] = '\\' | '2' << 8 | '7' << 16 | '0' << 24,
|
||||||
|
[185] = '\\' | '2' << 8 | '7' << 16 | '1' << 24,
|
||||||
|
[186] = '\\' | '2' << 8 | '7' << 16 | '2' << 24,
|
||||||
|
[187] = '\\' | '2' << 8 | '7' << 16 | '3' << 24,
|
||||||
|
[188] = '\\' | '2' << 8 | '7' << 16 | '4' << 24,
|
||||||
|
[189] = '\\' | '2' << 8 | '7' << 16 | '5' << 24,
|
||||||
|
[190] = '\\' | '2' << 8 | '7' << 16 | '6' << 24,
|
||||||
|
[191] = '\\' | '2' << 8 | '7' << 16 | '7' << 24,
|
||||||
|
[192] = '\\' | '3' << 8 | '0' << 16 | '0' << 24,
|
||||||
|
[193] = '\\' | '3' << 8 | '0' << 16 | '1' << 24,
|
||||||
|
[194] = '\\' | '3' << 8 | '0' << 16 | '2' << 24,
|
||||||
|
[195] = '\\' | '3' << 8 | '0' << 16 | '3' << 24,
|
||||||
|
[196] = '\\' | '3' << 8 | '0' << 16 | '4' << 24,
|
||||||
|
[197] = '\\' | '3' << 8 | '0' << 16 | '5' << 24,
|
||||||
|
[198] = '\\' | '3' << 8 | '0' << 16 | '6' << 24,
|
||||||
|
[199] = '\\' | '3' << 8 | '0' << 16 | '7' << 24,
|
||||||
|
[200] = '\\' | '3' << 8 | '1' << 16 | '0' << 24,
|
||||||
|
[201] = '\\' | '3' << 8 | '1' << 16 | '1' << 24,
|
||||||
|
[202] = '\\' | '3' << 8 | '1' << 16 | '2' << 24,
|
||||||
|
[203] = '\\' | '3' << 8 | '1' << 16 | '3' << 24,
|
||||||
|
[204] = '\\' | '3' << 8 | '1' << 16 | '4' << 24,
|
||||||
|
[205] = '\\' | '3' << 8 | '1' << 16 | '5' << 24,
|
||||||
|
[206] = '\\' | '3' << 8 | '1' << 16 | '6' << 24,
|
||||||
|
[207] = '\\' | '3' << 8 | '1' << 16 | '7' << 24,
|
||||||
|
[208] = '\\' | '3' << 8 | '2' << 16 | '0' << 24,
|
||||||
|
[209] = '\\' | '3' << 8 | '2' << 16 | '1' << 24,
|
||||||
|
[210] = '\\' | '3' << 8 | '2' << 16 | '2' << 24,
|
||||||
|
[211] = '\\' | '3' << 8 | '2' << 16 | '3' << 24,
|
||||||
|
[212] = '\\' | '3' << 8 | '2' << 16 | '4' << 24,
|
||||||
|
[213] = '\\' | '3' << 8 | '2' << 16 | '5' << 24,
|
||||||
|
[214] = '\\' | '3' << 8 | '2' << 16 | '6' << 24,
|
||||||
|
[215] = '\\' | '3' << 8 | '2' << 16 | '7' << 24,
|
||||||
|
[216] = '\\' | '3' << 8 | '3' << 16 | '0' << 24,
|
||||||
|
[217] = '\\' | '3' << 8 | '3' << 16 | '1' << 24,
|
||||||
|
[218] = '\\' | '3' << 8 | '3' << 16 | '2' << 24,
|
||||||
|
[219] = '\\' | '3' << 8 | '3' << 16 | '3' << 24,
|
||||||
|
[220] = '\\' | '3' << 8 | '3' << 16 | '4' << 24,
|
||||||
|
[221] = '\\' | '3' << 8 | '3' << 16 | '5' << 24,
|
||||||
|
[222] = '\\' | '3' << 8 | '3' << 16 | '6' << 24,
|
||||||
|
[223] = '\\' | '3' << 8 | '3' << 16 | '7' << 24,
|
||||||
|
[224] = '\\' | '3' << 8 | '4' << 16 | '0' << 24,
|
||||||
|
[225] = '\\' | '3' << 8 | '4' << 16 | '1' << 24,
|
||||||
|
[226] = '\\' | '3' << 8 | '4' << 16 | '2' << 24,
|
||||||
|
[227] = '\\' | '3' << 8 | '4' << 16 | '3' << 24,
|
||||||
|
[228] = '\\' | '3' << 8 | '4' << 16 | '4' << 24,
|
||||||
|
[229] = '\\' | '3' << 8 | '4' << 16 | '5' << 24,
|
||||||
|
[230] = '\\' | '3' << 8 | '4' << 16 | '6' << 24,
|
||||||
|
[231] = '\\' | '3' << 8 | '4' << 16 | '7' << 24,
|
||||||
|
[232] = '\\' | '3' << 8 | '5' << 16 | '0' << 24,
|
||||||
|
[233] = '\\' | '3' << 8 | '5' << 16 | '1' << 24,
|
||||||
|
[234] = '\\' | '3' << 8 | '5' << 16 | '2' << 24,
|
||||||
|
[235] = '\\' | '3' << 8 | '5' << 16 | '3' << 24,
|
||||||
|
[236] = '\\' | '3' << 8 | '5' << 16 | '4' << 24,
|
||||||
|
[237] = '\\' | '3' << 8 | '5' << 16 | '5' << 24,
|
||||||
|
[238] = '\\' | '3' << 8 | '5' << 16 | '6' << 24,
|
||||||
|
[239] = '\\' | '3' << 8 | '5' << 16 | '7' << 24,
|
||||||
|
[240] = '\\' | '3' << 8 | '6' << 16 | '0' << 24,
|
||||||
|
[241] = '\\' | '3' << 8 | '6' << 16 | '1' << 24,
|
||||||
|
[242] = '\\' | '3' << 8 | '6' << 16 | '2' << 24,
|
||||||
|
[243] = '\\' | '3' << 8 | '6' << 16 | '3' << 24,
|
||||||
|
[244] = '\\' | '3' << 8 | '6' << 16 | '4' << 24,
|
||||||
|
[245] = '\\' | '3' << 8 | '6' << 16 | '5' << 24,
|
||||||
|
[246] = '\\' | '3' << 8 | '6' << 16 | '6' << 24,
|
||||||
|
[247] = '\\' | '3' << 8 | '6' << 16 | '7' << 24,
|
||||||
|
[248] = '\\' | '3' << 8 | '7' << 16 | '0' << 24,
|
||||||
|
[249] = '\\' | '3' << 8 | '7' << 16 | '1' << 24,
|
||||||
|
[250] = '\\' | '3' << 8 | '7' << 16 | '2' << 24,
|
||||||
|
[251] = '\\' | '3' << 8 | '7' << 16 | '3' << 24,
|
||||||
|
[252] = '\\' | '3' << 8 | '7' << 16 | '4' << 24,
|
||||||
|
[253] = '\\' | '3' << 8 | '7' << 16 | '5' << 24,
|
||||||
|
[254] = '\\' | '3' << 8 | '7' << 16 | '6' << 24,
|
||||||
|
[255] = '\\' | '3' << 8 | '7' << 16 | '7' << 24,
|
||||||
|
};
|
||||||
|
|
||||||
TEST(_cescapec, test) {
|
TEST(_cescapec, test) {
|
||||||
EXPECT_EQ(' ', _cescapec(0x20));
|
int i;
|
||||||
EXPECT_EQ('~', _cescapec(0x7E));
|
for (i = 0; i < 256; ++i) {
|
||||||
EXPECT_EQ('\\' | 'r' << 8, _cescapec('\r'));
|
ASSERT_EQ(kCescapecGolden[i], _cescapec(i));
|
||||||
EXPECT_EQ('\\' | 'n' << 8, _cescapec('\n'));
|
}
|
||||||
EXPECT_EQ('\\' | '0' << 8 | '0' << 16 | '0' << 24, _cescapec(0));
|
|
||||||
EXPECT_EQ('\\' | '0' << 8 | '3' << 16 | '3' << 24, _cescapec('\e'));
|
|
||||||
EXPECT_EQ('\\' | '1' << 8 | '7' << 16 | '7' << 24, _cescapec(0x7F));
|
|
||||||
EXPECT_EQ('\\' | '3' << 8 | '7' << 16 | '7' << 24, _cescapec(0xFF));
|
|
||||||
EXPECT_EQ('\\' | '3' << 8 | '7' << 16 | '7' << 24, _cescapec(0xFFFF));
|
|
||||||
EXPECT_EQ('\\' | '3' << 8 | '7' << 16 | '7' << 24, _cescapec(-1));
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue