mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Use Lua auto buffers when possible
This commit is contained in:
parent
13ee75150c
commit
da6d610056
8 changed files with 204 additions and 101 deletions
|
@ -20,25 +20,7 @@
|
|||
#include "libc/str/str.h"
|
||||
#include "net/http/http.h"
|
||||
|
||||
// -_0-9A-Za-z
|
||||
static const char kHostChars[256] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, // 0x20
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0x30
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 0x70
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xf0
|
||||
};
|
||||
extern const char kHostChars[256]; // -_0-9A-Za-z
|
||||
|
||||
/**
|
||||
* Returns true if host seems legit.
|
||||
|
|
70
net/http/khostchars.S
Normal file
70
net/http/khostchars.S
Normal file
|
@ -0,0 +1,70 @@
|
|||
#include "libc/macros.internal.h"
|
||||
|
||||
// generated by:
|
||||
// o//tool/build/xlat.com -DA _- -skHostChars
|
||||
//
|
||||
// present absent
|
||||
// ──────────────── ────────────────
|
||||
// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00
|
||||
// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10
|
||||
// - ␠!“#§%&‘()*+, ./ 0x20
|
||||
// 0123456789 :;<=>⁇ 0x30
|
||||
// ABCDEFGHIJKLMNO @ 0x40
|
||||
// PQRSTUVWXYZ _ [⭝]^ 0x50
|
||||
// abcdefghijklmno ` 0x60
|
||||
// pqrstuvwxyz {|}~⌂ 0x70
|
||||
// ÇüéâäàåçêëèïîìÄÅ 0x80
|
||||
// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90
|
||||
// áíóúñѪº¿⌐¬½¼¡«» 0xa0
|
||||
// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0
|
||||
// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0
|
||||
// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0
|
||||
// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0
|
||||
// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0
|
||||
//
|
||||
// const char kHostChars[256] = {
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, // 0x20
|
||||
// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0x30
|
||||
// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40
|
||||
// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50
|
||||
// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60
|
||||
// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 0x70
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0
|
||||
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xf0
|
||||
// };
|
||||
|
||||
.initbss 300,_init_kHostChars
|
||||
kHostChars:
|
||||
.zero 256
|
||||
.endobj kHostChars,globl
|
||||
.previous
|
||||
|
||||
.initro 300,_init_kHostChars
|
||||
kHostChars.rom:
|
||||
.byte 45,0 # 00-2c ∅-,
|
||||
.byte 1,1 # 2d-2d ---
|
||||
.byte 2,0 # 2e-2f .-/
|
||||
.byte 10,1 # 30-39 0-9
|
||||
.byte 7,0 # 3a-40 :-@
|
||||
.byte 26,1 # 41-5a A-Z
|
||||
.byte 4,0 # 5b-5e [-^
|
||||
.byte 1,1 # 5f-5f _-_
|
||||
.byte 1,0 # 60-60 `-`
|
||||
.byte 26,1 # 61-7a a-z
|
||||
.byte 133,0 # 7b-ff {-λ
|
||||
.byte 0,0 # terminator
|
||||
.endobj kHostChars.rom,globl
|
||||
|
||||
.init.start 300,_init_kHostChars
|
||||
call rldecode
|
||||
.init.end 300,_init_kHostChars
|
||||
|
||||
// 29 bytes total (11% original size)
|
Loading…
Add table
Add a link
Reference in a new issue