Blob


1 #!/bin/sh
3 file="${1:?missing input file}"
5 sed -e '/^$/d' \
6 -e '/^#/d' \
7 -e 's/;.*//' \
8 -e 's/[ \t]*$//' \
9 -e 's/\.\./ /' \
10 "$file" \
11 | awk '
12 BEGIN {
13 print "#include \"utf8.h\""
14 print "int is_emoji(uint32_t cp) {"
16 e=""
17 }
19 {
20 if (NF == 1) {
21 printf("%sif (cp == 0x%s)", e, $1);
22 } else {
23 printf("%sif (cp >= 0x%s && cp <= 0x%s)", e, $1, $2);
24 }
26 print " return 1;"
28 e="else "
29 }
31 END {
32 print "return 0; }"
33 }
34 '