mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +00:00
Delete old wcwidth() implementation
This shaves away 144kb of bss memory from every binary linking printf at the expense of slightly increased binary footprint. Kudos for Byron Lai.
This commit is contained in:
parent
2db2f40a98
commit
a657f3e878
15 changed files with 11 additions and 814 deletions
|
@ -1,204 +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 "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/nr.h"
|
||||
#include "libc/nexgen32e/kompressor.h"
|
||||
#include "libc/sysv/consts/madv.h"
|
||||
|
||||
.rodata.cst4
|
||||
kCombiningCharsBits:
|
||||
.long 114752 * 8
|
||||
.endobj kCombiningCharsBits,globl,hidden
|
||||
.previous
|
||||
|
||||
.initbss 400,_init_kCombiningChars
|
||||
kCombiningChars:
|
||||
.zero 114752
|
||||
.endobj kCombiningChars,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 400,_init_kCombiningChars
|
||||
push %rsi
|
||||
mov $1203,%edx
|
||||
call lz4cpy
|
||||
mov %rax,%rdi
|
||||
pop %rsi
|
||||
add $1208,%rsi
|
||||
.init.end 400,_init_kCombiningChars
|
||||
|
||||
// o/tool/build/lz4toasm.com
|
||||
// -o o/libc/str/CombiningChars.s
|
||||
// -s kCombiningChars
|
||||
// o/libc/str/CombiningChars.bin.lz4
|
||||
.initro 400,_init_kCombiningChars
|
||||
kCombiningCharsLz4:
|
||||
.byte 0x1f,0x00,0x01,0x00,0x4c,0x19,0xff,0x01 #▼ ☺ L↓λ☺
|
||||
.byte 0x00,0x0f,0x30,0x00,0x0f,0x2f,0xf8,0x03 # ☼0 ☼/°♥
|
||||
.byte 0x22,0x00,0x0d,0x10,0xfe,0x49,0x00,0x23 #. ♪►■I .
|
||||
.byte 0xbf,0xb6,0x0e,0x00,0x42,0x3f,0x00,0xff #┐╢♫ B⁇ λ
|
||||
.byte 0x17,0x39,0x00,0x00,0x5e,0x00,0x17,0x01 #↨9 ^ ↨☺
|
||||
.byte 0x28,0x00,0x92,0xc0,0xbf,0x9f,0x3d,0x00 #( Æ└┐ƒ=
|
||||
.byte 0x00,0x00,0x80,0x02,0x86,0x00,0x17,0x07 # Ç☻å ↨•
|
||||
.byte 0x1a,0x00,0x13,0xff,0x28,0x00,0x91,0xf8 #→ ‼λ( æ°
|
||||
.byte 0x0f,0x20,0x00,0x00,0xc0,0xfb,0xef,0x3e #☼ └√∩>
|
||||
.byte 0x0e,0x00,0x1b,0x0e,0x8a,0x00,0x26,0xff #♫ ←♫è &λ
|
||||
.byte 0xff,0x37,0x00,0xa2,0x14,0xfe,0x21,0xfe #λ7 ó¶■!■
|
||||
.byte 0x00,0x0c,0x00,0x00,0x00,0x02,0x10,0x00 # ♀ ☻►
|
||||
.byte 0x40,0x10,0x1e,0x20,0x00,0x10,0x00,0x23 #@►▲ ► .
|
||||
.byte 0x40,0x06,0x10,0x00,0x20,0x86,0x39,0x1a #@♠► å9→
|
||||
.byte 0x00,0x24,0x23,0x00,0x10,0x00,0x21,0xbe # $. ► !╛
|
||||
.byte 0x21,0x20,0x00,0x13,0xfc,0x30,0x00,0x41 #! ‼ⁿ0 A
|
||||
.byte 0x90,0x1e,0x20,0x40,0x40,0x00,0x13,0x04 #É▲ @@ ‼♦
|
||||
.byte 0x5e,0x00,0x22,0x01,0x20,0x08,0x00,0x13 #^ .☺ ◘ ‼
|
||||
.byte 0x11,0x93,0x00,0x38,0xc1,0x3d,0x60,0x60 #◄ô 8┴=``
|
||||
.byte 0x00,0x31,0x90,0x40,0x30,0x40,0x00,0x13 # 1É@0@ ‼
|
||||
.byte 0x00,0x0f,0x01,0x13,0x18,0x70,0x00,0x06 # ☼☺‼↑p ♠
|
||||
.byte 0x9f,0x00,0x27,0x04,0x5c,0x0d,0x00,0x48 #ƒ ‘♦\♪ H
|
||||
.byte 0xf2,0x07,0x80,0x7f,0x1d,0x00,0x45,0xf2 #≥•Ç⌂↔ E≥
|
||||
.byte 0x1f,0x00,0x3f,0x0d,0x00,0x43,0x03,0x00 #▼ ⁇♪ C♥
|
||||
.byte 0x00,0xa0,0x57,0x00,0x50,0xfe,0x7f,0xdf # áW P■⌂▀
|
||||
.byte 0xe0,0xff,0x41,0x01,0x28,0x1f,0x40,0x2f #αλA☺(▼@/
|
||||
.byte 0x00,0xff,0x00,0xe0,0xfd,0x66,0x00,0x00 # λ α²f
|
||||
.byte 0x00,0xc3,0x01,0x00,0x1e,0x00,0x64,0x20 # ├☺ ▲ d
|
||||
.byte 0x00,0x20,0xcc,0x01,0x0b,0x0f,0xd2,0x01 # ╠☺♂☼╥☺
|
||||
.byte 0x1d,0x06,0x66,0x00,0x1f,0x00,0x01,0x00 #↔♠f ▼ ☺
|
||||
.byte 0x62,0x13,0x1c,0x04,0x00,0x26,0x0c,0x00 #b‼∟♦ &♀
|
||||
.byte 0x42,0x01,0x52,0xb0,0x3f,0x40,0xfe,0x0f #B☺R░⁇@■☼
|
||||
.byte 0xe8,0x00,0x1a,0x78,0x2e,0x00,0x26,0x60 #Φ →x. &`
|
||||
.byte 0x00,0x85,0x01,0x04,0x14,0x00,0x4f,0x87 # à☺♦¶ Oç
|
||||
.byte 0x01,0x04,0x0e,0x60,0x00,0x07,0x22,0x80 #☺♦♫` •.Ç
|
||||
.byte 0x09,0x08,0x00,0x63,0x40,0x7f,0xe5,0x1f #○◘ c@⌂σ▼
|
||||
.byte 0xf8,0x9f,0x2a,0x01,0x05,0x8e,0x01,0x11 #°ƒ*☺♣Ä☺◄
|
||||
.byte 0x0f,0x06,0x00,0x32,0xd0,0x17,0x04,0x70 #☼♠ 2╨↨♦p
|
||||
.byte 0x02,0x01,0xd0,0x01,0x23,0x3c,0x3b,0x32 #☻☺╨☺.<;2
|
||||
.byte 0x00,0x13,0xa3,0xde,0x01,0x2f,0xf0,0xcf # ‼ú▐☺/≡╧
|
||||
.byte 0x58,0x00,0x00,0x6f,0xf7,0xff,0xfd,0x21 #X o≈λ²!
|
||||
.byte 0x10,0x03,0x8c,0x01,0x0c,0x1f,0xfb,0x1f #►♥î☺♀▼√▼
|
||||
.byte 0x01,0x2e,0x52,0xf8,0x00,0x00,0x00,0x7c #☺.R° |
|
||||
.byte 0x0b,0x00,0x2c,0xdf,0xff,0x62,0x00,0x2f #♂ ,▀λb /
|
||||
.byte 0x01,0x00,0x01,0x00,0xff,0x6b,0x1d,0x80 #☺ ☺ λk↔Ç
|
||||
.byte 0xff,0x01,0x1c,0x80,0xa2,0x01,0x0f,0x68 #λ☺∟Çó☺☼h
|
||||
.byte 0x00,0x32,0x19,0x3c,0x0e,0x00,0x2f,0x06 # 2↓<♫ /♠
|
||||
.byte 0x00,0x01,0x00,0xff,0xff,0xff,0xff,0xff # ☺ λλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xb3,0x20,0x80,0xf7,0xf6,0x12,0x28 #λ│ Ç≈÷↕(
|
||||
.byte 0xc0,0x00,0xfb,0x12,0x0f,0x33,0x00,0x0c #└ √↕☼3 ♀
|
||||
.byte 0x23,0x44,0x08,0xf4,0x11,0x0b,0x18,0x00 #.D◘⌠◄♂↑
|
||||
.byte 0x11,0x30,0x60,0x0f,0x11,0x03,0x70,0x0f #◄0`☼◄♥p☼
|
||||
.byte 0x62,0xc0,0x3f,0x00,0x00,0x80,0xff,0x4c #b└⁇ ÇλL
|
||||
.byte 0x00,0x02,0x10,0x14,0x20,0xc8,0x33,0x06 # ☻►¶ ╚3♠
|
||||
.byte 0x00,0x05,0x29,0x13,0x52,0x7e,0x66,0x00 # ♣)‼R~f
|
||||
.byte 0x08,0x10,0xf8,0x13,0x02,0x11,0x00,0x21 #◘►°‼☻◄ !
|
||||
.byte 0x9d,0xc1,0x43,0x12,0x2f,0x30,0x40,0x7c #¥┴C↕/0@|
|
||||
.byte 0x00,0x0a,0x2f,0x20,0x21,0x96,0x0a,0xff # ◙/ !û◙λ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xdb,0x1f,0x40,0x60,0x1f,0x4b,0x2f,0x00 #█▼@`▼K/
|
||||
.byte 0x00,0x06,0x1a,0x08,0x1f,0x80,0x3f,0x00 # ♠→◘▼Ç⁇
|
||||
.byte 0x0c,0x1f,0x0e,0x7f,0x00,0x2c,0x1f,0x20 #♀▼♫⌂ ,▼
|
||||
.byte 0x1d,0x00,0x09,0x0e,0x3e,0x1c,0x2f,0xc0 #↔ ○♫>∟/└
|
||||
.byte 0x07,0xdd,0x01,0xbd,0x22,0x6e,0xf0,0x23 #•▌☺╜.n≡.
|
||||
.byte 0x1e,0x0f,0x1c,0x00,0x01,0x1f,0x60,0x64 #▲☼∟ ☺▼`d
|
||||
.byte 0x00,0x34,0x1f,0xf0,0x44,0x00,0x30,0x05 # 4▼≡D 0♣
|
||||
.byte 0xf4,0x20,0x0b,0x18,0x00,0x1a,0x02,0xb1 #⌠ ♂↑ →☻▒
|
||||
.byte 0x1e,0x03,0x72,0x1c,0x24,0x78,0x26,0xda #▲♥r∟$x&┌
|
||||
.byte 0x01,0x00,0xf0,0x0c,0x33,0x80,0xef,0x1f #☺ ≡♀3Ç∩▼
|
||||
.byte 0x2e,0x00,0x13,0x08,0x52,0x0d,0x48,0xc0 #. ‼◘R♪H└
|
||||
.byte 0x7f,0x00,0x1e,0x66,0x02,0x1f,0xd3,0xe4 #⌂ ▲f☻▼╙Σ
|
||||
.byte 0x02,0x01,0x36,0x80,0xf8,0x07,0xc0,0x20 #☻☺6ǰ•└
|
||||
.byte 0x00,0x7e,0x00,0x3f,0xc0,0x1f,0x1f,0xc7 # ~ ⁇└▼▼╟
|
||||
.byte 0x02,0x06,0x19,0x5c,0x28,0x03,0x3f,0xf8 #☻♠↓\(♥⁇°
|
||||
.byte 0x85,0x0d,0xb1,0x1c,0x0b,0x22,0xb0,0x01 #à♪▒∟♂.░☺
|
||||
.byte 0xa3,0x0d,0x04,0x30,0x00,0x19,0xa7,0xde #ú♪♦0 ↓º▐
|
||||
.byte 0x00,0x29,0x28,0xbf,0x78,0x20,0x2f,0xbc # )(┐x /╝
|
||||
.byte 0x0f,0x38,0x0e,0x0d,0x1f,0xff,0xf4,0x1c #☼8♫♪▼λ⌠∟
|
||||
.byte 0x20,0x20,0xf0,0x0c,0x74,0x00,0x11,0xfe # ≡♀t ◄■
|
||||
.byte 0xd2,0x02,0x52,0xf8,0x79,0x80,0x00,0x7e #╥☻R°yÇ ~
|
||||
.byte 0x4c,0x03,0x3f,0xfc,0x7f,0x03,0x4c,0x00 #L♥⁇ⁿ⌂♥L
|
||||
.byte 0x1f,0x17,0x7f,0xb1,0x00,0x5b,0xfc,0xff #▼↨⌂▒ [ⁿλ
|
||||
.byte 0xff,0xfc,0x6d,0x20,0x00,0x26,0x7e,0xb4 #λⁿm &~┤
|
||||
.byte 0x21,0x00,0x1f,0xa3,0x58,0x00,0x18,0x1f #! ▼úX ↑▼
|
||||
.byte 0x18,0x23,0x07,0xff,0xff,0x96,0x2f,0xff #↑.•λλû/λ
|
||||
.byte 0x01,0xfb,0x0d,0xff,0xff,0xff,0xff,0xff #☺√♪λλλλλ
|
||||
.byte 0xff,0xc9,0x04,0xf0,0x0a,0x1f,0x7f,0x1c #λ╔♦≡◙▼⌂∟
|
||||
.byte 0x19,0x70,0x04,0x08,0x00,0x1f,0x07,0x30 #↓p♦◘ ▼•0
|
||||
.byte 0x18,0xff,0xff,0xff,0xff,0xff,0xff,0xff #↑λλλλλλλ
|
||||
.byte 0xff,0xff,0x96,0x2f,0x60,0x0f,0x5f,0x25 #λλû/`☼_%
|
||||
.byte 0xff,0xff,0x87,0x5d,0x03,0xf8,0xff,0xe7 #λλç]♥°λτ
|
||||
.byte 0x0f,0x30,0x34,0x05,0x66,0x37,0x0f,0xba #☼04♣f7☼║
|
||||
.byte 0x14,0xe2,0x01,0x01,0x00,0x12,0x7f,0x2d #¶Γ☺☺ ↕⌂-
|
||||
.byte 0x3a,0x20,0x1f,0x20,0x01,0x26,0x3f,0xf8 #: ▼ ☺&⁇°
|
||||
.byte 0xfe,0xff,0xc0,0x00,0x97,0x5f,0x7f,0xff #■λ└ ù_⌂λ
|
||||
.byte 0xff,0xf9,0xdb,0x13,0x0e,0x0e,0x1f,0x7f #λ∙█‼♫♫▼⌂
|
||||
.byte 0xb9,0x1a,0x24,0x0f,0xda,0x01,0xa9,0x0a #╣→$☼┌☺⌐◙
|
||||
.byte 0xf4,0x00,0x3f,0xf0,0x07,0x00,0x01,0x00 #⌠ ⁇≡• ☺
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0x46,0x57,0x02,0x00 #λλλλFW☻
|
||||
.byte 0x00,0x00,0xff,0x01,0x00,0x0c,0x20,0x00 # λ☺ ♀
|
||||
.byte 0x1f,0xff,0x01,0x00,0x07,0x50,0xff,0xff #▼λ☺ •Pλλ
|
||||
.byte 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
.endobj kCombiningCharsLz4,globl,hidden
|
||||
.previous
|
|
@ -1,93 +0,0 @@
|
|||
// o/$(MODE)/tool/build/lz4toasm.com -o o/$(MODE)/libc/str/EastAsianWidth.s -s kEastAsianWidth o/$(MODE)/libc/str/EastAsianWidth.bin.lz4
|
||||
#include "libc/nexgen32e/kompressor.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
.rodata
|
||||
.balign 4
|
||||
kEastAsianWidthBits:
|
||||
.long 32768 * 8
|
||||
.endobj kEastAsianWidthBits,globl,hidden
|
||||
.previous
|
||||
|
||||
.initbss 500,_init_kEastAsianWidth
|
||||
kEastAsianWidth:
|
||||
.zero 32768
|
||||
.endobj kEastAsianWidth,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 500,_init_kEastAsianWidth
|
||||
push %rsi
|
||||
mov $500,%edx
|
||||
call lz4cpy
|
||||
mov %rax,%rdi
|
||||
pop %rsi
|
||||
add $504,%rsi
|
||||
.init.end 500,_init_kEastAsianWidth
|
||||
|
||||
.initro 500,_init_kEastAsianWidth
|
||||
kEastAsianWidthLz4:
|
||||
.byte 0x1f,0x00,0x01,0x00,0xff,0xff,0x0e,0x17 #▼ ☺ λλ♫↨
|
||||
.byte 0xff,0x01,0x00,0x0f,0x30,0x01,0xff,0x12 #λ☺ ☼0☺λ↕
|
||||
.byte 0xaf,0x88,0x99,0xf0,0xad,0xae,0xfb,0x2b #»êÖ≡¡«√+
|
||||
.byte 0x00,0x81,0xfb,0x13,0x01,0xf6,0x3f,0x0c # ü√‼☺÷?♀
|
||||
.byte 0x00,0x06,0x1a,0x00,0x04,0x2f,0x1e,0x09 # ♠→ ♦/▲○
|
||||
.byte 0x5c,0x00,0x2d,0x43,0x60,0x00,0x00,0x30 #\ -C` 0
|
||||
.byte 0xa9,0x02,0x10,0x0f,0x06,0x00,0xf3,0x0d #⌐☻►☼♠ ≤♪
|
||||
.byte 0x80,0x00,0x00,0x08,0x00,0x02,0x0c,0x00 #Ç ◘ ☻♀
|
||||
.byte 0x60,0x30,0x40,0x10,0x00,0x00,0x04,0x2c #`0@► ♦,
|
||||
.byte 0x24,0x20,0x0c,0x00,0x00,0x00,0x01,0x00 #$ ♀ ☺
|
||||
.byte 0x00,0x00,0x50,0xb8,0x33,0x00,0x10,0xe0 # P╕3 ►α
|
||||
.byte 0x11,0x00,0x1f,0x80,0x00,0x01,0x58,0x12 #◄ ▼Ç ☺X↕
|
||||
.byte 0x18,0x07,0x00,0x1f,0x21,0xb0,0x03,0x55 #↑• ▼!░♥U
|
||||
.byte 0x16,0xfb,0xb2,0x03,0x3f,0x0f,0x00,0xff #▬√▓♥?☼ λ
|
||||
.byte 0x01,0x00,0x06,0x11,0x3f,0x35,0x01,0x03 #☺ ♠◄?5☺♥
|
||||
.byte 0x0d,0x00,0x4e,0x7f,0xfe,0xff,0xff,0x0b #♪ N⌂■λλ♂
|
||||
.byte 0x00,0x41,0xff,0xff,0xff,0xe0,0x06,0x00 # Aλλλα♠
|
||||
.byte 0x07,0x13,0x00,0x11,0x7f,0x06,0x00,0x17 #•‼ ◄⌂♠ ↨
|
||||
.byte 0x07,0x5e,0x00,0x02,0x12,0x00,0x2f,0x00 #•^ ☻↕ /
|
||||
.byte 0xff,0x01,0x00,0xff,0xff,0xff,0x5d,0x0e #λ☺ λλλ]♫
|
||||
.byte 0xa0,0x07,0x0f,0x01,0x00,0xff,0xff,0xff #á•☼☺ λλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xbe #λλλλλλλ╛
|
||||
.byte 0x13,0x1f,0x67,0x0e,0x0f,0x0c,0x13,0x83 #‼▼g♫☼♀‼â
|
||||
.byte 0x1f,0x1f,0x60,0x13,0x3d,0x0f,0x63,0x06 #▼▼`‼=☼c♠
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0x66,0x2f,0x0f #λλλλλf/☼
|
||||
.byte 0x00,0x01,0x00,0xff,0xff,0xf9,0x04,0xb0 # ☺ λλ∙♦░
|
||||
.byte 0x1a,0x2f,0xd1,0xe0,0x00,0x1d,0xff,0x10 #→/╤α ↔λ►
|
||||
.byte 0x0f,0xa8,0x15,0x21,0x0f,0xa2,0x00,0x50 #☼¿§!☼ó P
|
||||
.byte 0x12,0x03,0xa6,0x00,0x3f,0xf7,0xff,0x7f #↕♥ª ?≈λ⌂
|
||||
.byte 0xd9,0x04,0x00,0x08,0xcd,0x19,0x1b,0x01 #┘♦ ◘═↓←☺
|
||||
.byte 0x1c,0x00,0x2f,0x7f,0x00,0x01,0x00,0xff #∟ /⌂ ☺ λ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xf8,0x1f,0x0f,0x80 #λλλλ°▼☼Ç
|
||||
.byte 0x18,0xff,0xff,0xf1,0x0f,0x00,0x03,0x4c #↑λλ±☼ ♥L
|
||||
.byte 0x1f,0x07,0x04,0x08,0xff,0xff,0xff,0xff #▼•♦◘λλλλ
|
||||
.byte 0x92,0x0f,0xc5,0x04,0x10,0x03,0x27,0x16 #Æ☼┼♦►♥'▬
|
||||
.byte 0x4f,0x07,0x00,0xf0,0x00,0x6b,0x1b,0x1f #O• ≡ k←▼
|
||||
.byte 0x0f,0x04,0x10,0xff,0xff,0xff,0xff,0xff #☼♦►λλλλλ
|
||||
.byte 0xff,0xff,0x94,0x1f,0x10,0x19,0x00,0x05 #λλö▼►↓ ♣
|
||||
.byte 0x0f,0x22,0x39,0x05,0x29,0x40,0xfe,0xd5 #☼.9♣)@■╒
|
||||
.byte 0x0c,0x12,0x07,0x14,0x08,0x6f,0x0f,0xff #♀↕•¶◘o☼λ
|
||||
.byte 0x01,0x03,0x00,0x3f,0x60,0x08,0x04,0x34 #☺♥ ?`◘♦4
|
||||
.byte 0x01,0xe0,0xbf,0x10,0x08,0x15,0xdf,0x36 #☺α┐►◘§▀6
|
||||
.byte 0x38,0x10,0x87,0x08,0x00,0x15,0x11,0x64 #8►ç◘ §◄d
|
||||
.byte 0x08,0x1f,0xfd,0x40,0x08,0x03,0x15,0x9f #◘▼²@◘♥§ƒ
|
||||
.byte 0xad,0x38,0x11,0x78,0x4d,0x1f,0x10,0x04 #¡8◄xM▼►♦
|
||||
.byte 0xf3,0x39,0x07,0xb4,0x00,0x1c,0xf8,0x6a #≤9•┤ ∟°j
|
||||
.byte 0x1f,0x05,0xde,0x38,0x6f,0x10,0x27,0x00 #▼♣▐8o►'
|
||||
.byte 0x00,0x18,0xf0,0x81,0x0d,0x0a,0x0f,0x9e # ↑≡ü♪◙☼€
|
||||
.byte 0x08,0x12,0x18,0xe0,0x8f,0x00,0x20,0x7b #◘↕↑αÅ {
|
||||
.byte 0xfc,0x06,0x00,0x20,0xe7,0xc7,0x05,0x00 #ⁿ♠ τ╟♣
|
||||
.byte 0x0f,0xe0,0x1f,0x01,0x5f,0x0f,0x07,0x07 #☼α▼☺_☼••
|
||||
.byte 0x00,0x3f,0xe0,0x20,0x9b,0x0f,0x01,0x00 # ?α ¢☼☺
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0x0b,0x1f,0x3f,0xfc,0x1f,0xff,0xff,0xff #♂▼?ⁿ▼λλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff #λλλλλλλλ
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0x08,0x50,0xff #λλλλλ◘Pλ
|
||||
.byte 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00
|
||||
.endobj kEastAsianWidthLz4,globl,hidden
|
||||
.previous
|
|
@ -138,11 +138,6 @@ ssize_t strfmon(char *, size_t, const char *, ...);
|
|||
long a64l(const char *);
|
||||
char *l64a(long);
|
||||
|
||||
char *strntolower(char *, size_t) libcesque;
|
||||
char *strtolower(char *) libcesque paramsnonnull();
|
||||
char *strntoupper(char *, size_t) libcesque;
|
||||
char *strtoupper(char *) libcesque paramsnonnull();
|
||||
|
||||
typedef unsigned mbstate_t;
|
||||
|
||||
wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t);
|
||||
|
|
|
@ -93,32 +93,6 @@ $(LIBC_STR_A_OBJS): private \
|
|||
-Wframe-larger-than=4096 \
|
||||
-Walloca-larger-than=4096
|
||||
|
||||
o/$(MODE)/libc/str/eastasianwidth.bin: \
|
||||
libc/str/eastasianwidth.txt \
|
||||
o/$(MODE)/tool/decode/mkwides.com
|
||||
@$(COMPILE) -AMKWIDES -T$@ o/$(MODE)/tool/decode/mkwides.com -o $@ $<
|
||||
o/$(MODE)/libc/str/eastasianwidth.bin.lz4: \
|
||||
o/$(MODE)/libc/str/eastasianwidth.bin \
|
||||
o/$(MODE)/third_party/lz4cli/lz4cli.com
|
||||
@$(COMPILE) -ALZ4 -T$@ o/$(MODE)/third_party/lz4cli/lz4cli.com -q -f -9 --content-size $< $@
|
||||
o/$(MODE)/libc/str/eastasianwidth.s: \
|
||||
o/$(MODE)/libc/str/eastasianwidth.bin.lz4 \
|
||||
o/$(MODE)/tool/build/lz4toasm.com
|
||||
@$(COMPILE) -ABIN2ASM -T$@ o/$(MODE)/tool/build/lz4toasm.com -s kEastAsianWidth -o $@ $<
|
||||
|
||||
o/$(MODE)/libc/str/combiningchars.bin: \
|
||||
libc/str/strdata.txt \
|
||||
o/$(MODE)/tool/decode/mkcombos.com
|
||||
@$(COMPILE) -AMKCOMBOS -T$@ o/$(MODE)/tool/decode/mkcombos.com -o $@ $<
|
||||
o/$(MODE)/libc/str/combiningchars.bin.lz4: \
|
||||
o/$(MODE)/libc/str/combiningchars.bin \
|
||||
o/$(MODE)/third_party/lz4cli/lz4cli.com
|
||||
@$(COMPILE) -ALZ4 -T$@ o/$(MODE)/third_party/lz4cli/lz4cli.com -q -f -9 --content-size $< $@
|
||||
o/$(MODE)/libc/str/combiningchars.s: \
|
||||
o/$(MODE)/libc/str/combiningchars.bin.lz4 \
|
||||
o/$(MODE)/tool/build/lz4toasm.com
|
||||
@$(COMPILE) -ABIN2ASM -T$@ o/$(MODE)/tool/build/lz4toasm.com -s kCombiningChars -o $@ $<
|
||||
|
||||
LIBC_STR_LIBS = $(foreach x,$(LIBC_STR_ARTIFACTS),$($(x)))
|
||||
LIBC_STR_SRCS = $(foreach x,$(LIBC_STR_ARTIFACTS),$($(x)_SRCS))
|
||||
LIBC_STR_HDRS = $(foreach x,$(LIBC_STR_ARTIFACTS),$($(x)_HDRS))
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- 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 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/str/str.h"
|
||||
|
||||
char *strntolower(char *s, size_t n) {
|
||||
unsigned char *p = (unsigned char *)s;
|
||||
for (;;) {
|
||||
if (n-- && *p) {
|
||||
if ('A' <= *p && *p <= 'Z') {
|
||||
*p += 'a' - 'A';
|
||||
}
|
||||
++p;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*-*- 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 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/str/str.h"
|
||||
|
||||
/**
|
||||
* Mutates string to ASCII uppercase w/ limit.
|
||||
*
|
||||
* @praam s is string
|
||||
* @praam n is max bytes to consider
|
||||
* @return string
|
||||
*/
|
||||
char *strntoupper(char *s, size_t n) {
|
||||
size_t i;
|
||||
for (i = 0; s[i] && i < n; ++i) {
|
||||
if ('a' <= s[i] && s[i] <= 'z') {
|
||||
s[i] -= 'a' - 'A';
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- 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 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/str/str.h"
|
||||
|
||||
/**
|
||||
* Mutates string to ASCII lowercase.
|
||||
*
|
||||
* @praam s is string
|
||||
* @return string
|
||||
*/
|
||||
char *strtolower(char *s) {
|
||||
size_t i;
|
||||
for (i = 0; s[i]; ++i) {
|
||||
if ('A' <= s[i] && s[i] <= 'Z') {
|
||||
s[i] += 'a' - 'A';
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- 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 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/str/str.h"
|
||||
|
||||
/**
|
||||
* Mutates string to ASCII uppercase.
|
||||
*
|
||||
* @praam s is string
|
||||
* @return string
|
||||
*/
|
||||
char *strtoupper(char *s) {
|
||||
size_t i;
|
||||
for (i = 0; s[i]; ++i) {
|
||||
if ('a' <= s[i] && s[i] <= 'z') {
|
||||
s[i] -= 'a' - 'A';
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
|
@ -21,33 +21,10 @@
|
|||
#include "libc/str/unicode.h"
|
||||
#include "libc/str/wcwidth_osx.internal.h"
|
||||
|
||||
extern const uint8_t kEastAsianWidth[];
|
||||
extern const uint32_t kEastAsianWidthBits;
|
||||
extern const uint8_t kCombiningChars[];
|
||||
extern const uint32_t kCombiningCharsBits;
|
||||
|
||||
/**
|
||||
* Returns cell width of monospace character.
|
||||
*/
|
||||
int wcwidth(wchar_t c) {
|
||||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
if (LIKELY(32 <= c && c < 127)) {
|
||||
return 1;
|
||||
} else if (!c) {
|
||||
return 0;
|
||||
} else if ((uint32_t)c > 0x10FFFD || //
|
||||
(0 < c && c < 32) || //
|
||||
(0x7f <= c && c < 0xA0)) {
|
||||
return -1;
|
||||
} else if ((0 <= c && c < kCombiningCharsBits) &&
|
||||
!!(kCombiningChars[c >> 3] & (1 << (c & 7)))) {
|
||||
return 0;
|
||||
} else if (0 <= c && c < kEastAsianWidthBits) {
|
||||
return 1 + !!(kEastAsianWidth[c >> 3] & (1 << (c & 7)));
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
int res;
|
||||
if (LIKELY(32 <= c && c < 127)) return 1;
|
||||
if (VERY_UNLIKELY((uint32_t)c >= 0x100000)) {
|
||||
|
@ -60,5 +37,4 @@ int wcwidth(wchar_t c) {
|
|||
if (iswcntrl(c)) return -1;
|
||||
}
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue