~q3cpma/misc-tools

ref: 023b3736bfe7bc4caeebda9a5d07d060870f0128 misc-tools/gen_unicode_tolower_lut.sh -rwxr-xr-x 748 bytes
023b3736q3cpma Fix gen_unicode_tolower_lut.sh typo 5 months ago
                                                                                
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
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
set -eu
cd -- "$(dirname -- "$0")"
self=./$(basename -- "$0")
. ./build_util.sh


cat <<'EOF'
#pragma once

#include <stdint.h>

static const uint32_t unicode_tolower_lut[] =
{
EOF
if preadlinkf "$(command -v awk)" | grep -q '/gawk$'
then
	gawk=
fi
last=$(awk ${gawk+-Wposix} -F';' '
	($3 == "Lt" || $3 == "Lu") && length($14) {
		last = $1
	}
	END {print last}' "$1"
)
awk ${gawk+-Wposix} -F';' -vlast="$last" '
	BEGIN {lineno = 0}
	("0x" $1) + 0 != lineno {  # Fill gaps in Unicode tables
		for (; lineno < ("0x" $1) + 0; ++lineno)
			printf "[0x%04X] = 0x%04X,\n", lineno, lineno
	}
	{
		printf "[0x%s] = 0x%s,\n",
			$1, (($3 == "Lt" || $3 == "Lu") && length($14) ? $14 : $1)
		++lineno
	}
	$1 == last {exit}' "$1"
cat <<'EOF'
};
EOF